MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / plugins / wimax / msg_pkm.c
blob545a059912c88d366ff770db0b801fb118385dc9
1 /* msg_pkm.c
2 * WiMax MAC Management PKM-REQ/RSP Messages decoders
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: Lu Pan <lu.pan@intel.com>
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1999 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #define DEBUG // for debug only
33 /* Include files */
35 #include "config.h"
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include "wimax_tlv.h"
40 #include "wimax_mac.h"
41 #include "wimax_utils.h"
43 static gint proto_mac_mgmt_msg_pkm_decoder = -1;
44 static gint ett_mac_mgmt_msg_pkm_req_decoder = -1;
45 static gint ett_mac_mgmt_msg_pkm_rsp_decoder = -1;
47 static const value_string vals_pkm_msg_code[] =
49 {3, "SA ADD"},
50 {4, "Auth Request"},
51 {5, "Auth Reply"},
52 {6, "Auth Reject"},
53 {7, "Key Request"},
54 {8, "Key Reply"},
55 {9, "Key Reject"},
56 {10, "Auth Invalid"},
57 {11, "TEK Invalid"},
58 {12, "Auth Info"},
59 {13, "PKMv2 RSA-Request"},
60 {14, "PKMv2 RSA-Reply"},
61 {15, "PKMv2 RSA-Reject"},
62 {16, "PKMv2 RSA-Acknowledgement"},
63 {17, "PKMv2 EAP Start"},
64 {18, "PKMv2 EAP-Transfer"},
65 {19, "PKMv2 Authenticated EAP-Transfer"},
66 {20, "PKMv2 SA TEK Challenge"},
67 {21, "PKMv2 SA TEK Request"},
68 {22, "PKMv2 SA TEK Response"},
69 {23, "PKMv2 Key-Request"},
70 {24, "PKMv2 Key-Reply"},
71 {25, "PKMv2 Key-Reject"},
72 {26, "PKMv2 SA-Addition"},
73 {27, "PKMv2 TEK-Invalid"},
74 {28, "PKMv2 Group-Key-Update-Command"},
75 {29, "PKMv2 EAP Complete"},
76 {30, "PKMv2 Authenticated EAP Start"},
77 { 0, NULL}
80 /* fix fields */
81 static gint hf_pkm_msg_code = -1;
82 static gint hf_pkm_msg_pkm_id = -1;
85 /* Wimax Mac PKM-REQ Message Dissector */
86 static void dissect_mac_mgmt_msg_pkm_req_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
88 guint offset = 0;
89 proto_item *pkm_item;
90 proto_tree *pkm_tree;
92 /* display MAC payload type PKM-REQ */
93 pkm_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_pkm_decoder, tvb, offset, -1, "Privacy Key Management Request (PKM-REQ)");
94 /* add MAC PKM subtree */
95 pkm_tree = proto_item_add_subtree(pkm_item, ett_mac_mgmt_msg_pkm_req_decoder);
96 /* Decode and display the Privacy Key Management Request Message (PKM-REQ) (table 24) */
97 /* display the PKM Code */
98 proto_tree_add_item(pkm_tree, hf_pkm_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
99 /* set the offset for the PKM ID */
100 offset++;
101 /* display the PKM ID */
102 proto_tree_add_item(pkm_tree, hf_pkm_msg_pkm_id, tvb, offset, 1, ENC_BIG_ENDIAN);
103 /* set the offset for the TLV Encoded info */
104 offset++;
105 wimax_pkm_tlv_encoded_attributes_decoder(tvb_new_subset_remaining(tvb, offset), pinfo, pkm_tree);
108 /* Wimax Mac PKM-RSP Message Dissector */
109 static void dissect_mac_mgmt_msg_pkm_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
111 guint offset = 0;
112 proto_item *pkm_item;
113 proto_tree *pkm_tree;
115 /* display MAC payload type PKM-RSP */
116 pkm_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_pkm_decoder, tvb, offset, -1, "Privacy Key Management Response (PKM-RSP)");
117 /* add MAC PKM subtree */
118 pkm_tree = proto_item_add_subtree(pkm_item, ett_mac_mgmt_msg_pkm_rsp_decoder);
119 /* Decode and display the Privacy Key Management Response (PKM-RSP) (table 25) */
120 /* display the PKM Code */
121 proto_tree_add_item(pkm_tree, hf_pkm_msg_code, tvb, offset, 1, ENC_BIG_ENDIAN);
122 /* set the offset for the PKM ID */
123 offset++;
124 /* display the PKM ID */
125 proto_tree_add_item(pkm_tree, hf_pkm_msg_pkm_id, tvb, offset, 1, ENC_BIG_ENDIAN);
126 /* set the offset for the TLV Encoded info */
127 offset++;
128 /* process the PKM TLV Encoded Attributes */
129 wimax_pkm_tlv_encoded_attributes_decoder(tvb_new_subset_remaining(tvb, offset), pinfo, pkm_tree);
132 /* Register Wimax Mac PKM-REQ/RSP Messages Dissectors */
133 void proto_register_mac_mgmt_msg_pkm(void)
135 /* PKM display */
136 static hf_register_info hf_pkm[] =
139 &hf_pkm_msg_code,
140 {"Code", "wmx.pkm.msg_code",FT_UINT8, BASE_DEC, VALS(vals_pkm_msg_code),0x0, NULL, HFILL}
143 &hf_pkm_msg_pkm_id,
144 {"PKM Identifier", "wmx.pkm.msg_pkm_identifier",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
148 /* Setup protocol subtree array */
149 static gint *ett_pkm[] =
151 &ett_mac_mgmt_msg_pkm_req_decoder,
152 &ett_mac_mgmt_msg_pkm_rsp_decoder,
155 proto_mac_mgmt_msg_pkm_decoder = proto_register_protocol (
156 "WiMax PKM-REQ/RSP Messages", /* name */
157 "WiMax PKM-REQ/RSP (pkm)", /* short name */
158 "wmx.pkm" /* abbrev */
161 proto_register_field_array(proto_mac_mgmt_msg_pkm_decoder, hf_pkm, array_length(hf_pkm));
162 proto_register_subtree_array(ett_pkm, array_length(ett_pkm));
165 void proto_reg_handoff_mac_mgmt_msg_pkm(void)
167 dissector_handle_t mac_mgmt_msg_pkm_req_handle;
168 dissector_handle_t mac_mgmt_msg_pkm_rsp_handle;
170 mac_mgmt_msg_pkm_req_handle = create_dissector_handle(dissect_mac_mgmt_msg_pkm_req_decoder, proto_mac_mgmt_msg_pkm_decoder);
171 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_PKM_REQ, mac_mgmt_msg_pkm_req_handle );
172 mac_mgmt_msg_pkm_rsp_handle = create_dissector_handle(dissect_mac_mgmt_msg_pkm_rsp_decoder, proto_mac_mgmt_msg_pkm_decoder);
173 dissector_add_uint( "wmx.mgmtmsg", MAC_MGMT_MSG_PKM_RSP, mac_mgmt_msg_pkm_rsp_handle );