MSWSP: add ids for another unknown Property Set
[wireshark-wip.git] / plugins / wimax / msg_dsd.c
bloba4649827b5696ac36b6b571dfddc96567b2c665b
1 /* msg_dsd.c
2 * WiMax MAC Management DSD-REQ/RSP Messages decoder
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.
29 /* Include files */
31 #include "config.h"
34 #define DEBUG
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_dsd_decoder = -1;
44 static gint ett_mac_mgmt_msg_dsd_req_decoder = -1;
45 static gint ett_mac_mgmt_msg_dsd_rsp_decoder = -1;
46 /* static gint ett_dsd_ul_sfe_decoder = -1; */
47 /* static gint ett_dsd_dl_sfe_decoder = -1; */
48 /* static gint ett_dsd_hmac_tuple = -1; */
49 /* static gint ett_dsd_cmac_tuple = -1; */
51 /* fix fields */
52 static gint hf_dsd_transaction_id = -1;
53 static gint hf_dsd_service_flow_id = -1;
54 static gint hf_dsd_confirmation_code = -1;
55 static gint hf_dsd_invalid_tlv = -1;
56 static gint hf_dsd_unknown_type = -1;
59 static void dissect_mac_mgmt_msg_dsd_req_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
61 guint offset = 0;
62 guint tvb_len, tlv_len, tlv_value_offset;
63 gint tlv_type;
64 proto_item *dsd_item;
65 proto_tree *dsd_tree;
66 proto_tree *tlv_tree = NULL;
67 tlv_info_t tlv_info;
69 { /* we are being asked for details */
70 /* Get the tvb reported length */
71 tvb_len = tvb_reported_length(tvb);
72 /* display MAC message type */
73 dsd_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, -1,
74 "Dynamic Service Deletion Request (DSD-REQ)");
75 /* add MAC DSx subtree */
76 dsd_tree = proto_item_add_subtree(dsd_item, ett_mac_mgmt_msg_dsd_req_decoder);
77 /* Decode and display the DSD message */
78 /* display the Transaction ID */
79 proto_tree_add_item(dsd_tree, hf_dsd_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);
80 /* move to next field */
81 offset += 2;
82 /* display the Service Flow ID */
83 proto_tree_add_item(dsd_tree, hf_dsd_service_flow_id, tvb, offset, 4, ENC_BIG_ENDIAN);
84 /* move to next field */
85 offset += 4;
86 /* process DSD REQ message TLV Encode Information */
87 while(offset < tvb_len)
88 { /* get the TLV information */
89 init_tlv_info(&tlv_info, tvb, offset);
90 /* get the TLV type */
91 tlv_type = get_tlv_type(&tlv_info);
92 /* get the TLV length */
93 tlv_len = get_tlv_length(&tlv_info);
94 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
95 { /* invalid tlv info */
96 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DSD-REQ TLV error");
97 proto_tree_add_item(dsd_tree, hf_dsd_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
98 break;
100 /* get the TLV value offset */
101 tlv_value_offset = get_tlv_value_offset(&tlv_info);
102 #ifdef DEBUG /* for debug only */
103 proto_tree_add_protocol_format(dsd_tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, tlv_len + tlv_value_offset, "DSD-REQ TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len + tlv_value_offset, offset, tvb_len);
104 #endif
105 /* process TLV */
106 switch (tlv_type)
108 case HMAC_TUPLE: /* Table 348d */
109 /* decode and display the HMAC Tuple */
110 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dsd_req_decoder, dsd_tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, tlv_len, "HMAC Tuple");
111 wimax_hmac_tuple_decoder(tlv_tree, tvb, offset+tlv_value_offset, tlv_len);
112 break;
113 case CMAC_TUPLE: /* Table 348b */
114 /* decode and display the CMAC Tuple */
115 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dsd_req_decoder, dsd_tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, tlv_len, "CMAC Tuple");
116 wimax_cmac_tuple_decoder(tlv_tree, tvb, offset+tlv_value_offset, tlv_len);
117 break;
118 default:
119 /* display the unknown tlv in hex */
120 add_tlv_subtree(&tlv_info, dsd_tree, hf_dsd_unknown_type, tvb, offset, ENC_NA);
121 break;
123 offset += (tlv_len+tlv_value_offset);
124 } /* end of while loop */
128 static void dissect_mac_mgmt_msg_dsd_rsp_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
130 guint offset = 0;
131 guint tvb_len, tlv_len, tlv_value_offset;
132 gint tlv_type;
133 proto_item *dsd_item;
134 proto_tree *dsd_tree;
135 proto_tree *tlv_tree = NULL;
136 tlv_info_t tlv_info;
138 { /* we are being asked for details */
139 /* Get the tvb reported length */
140 tvb_len = tvb_reported_length(tvb);
141 /* display MAC message type */
142 dsd_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, -1,
143 "Dynamic Service Deletion Response (DSD-RSP)");
144 /* add MAC DSx subtree */
145 dsd_tree = proto_item_add_subtree(dsd_item, ett_mac_mgmt_msg_dsd_rsp_decoder);
146 /* Decode and display the DSD message */
147 /* display the Transaction ID */
148 proto_tree_add_item(dsd_tree, hf_dsd_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);
149 /* move to next field */
150 offset += 2;
151 /* display the Confirmation Code */
152 proto_tree_add_item(dsd_tree, hf_dsd_confirmation_code, tvb, offset, 1, ENC_BIG_ENDIAN);
153 /* move to next field */
154 offset++;
155 /* display the Service Flow ID */
156 proto_tree_add_item(dsd_tree, hf_dsd_service_flow_id, tvb, offset, 4, ENC_BIG_ENDIAN);
157 /* move to next field */
158 offset += 4;
159 /* process DSD RSP message TLV Encode Information */
160 while(offset < tvb_len)
161 { /* get the TLV information */
162 init_tlv_info(&tlv_info, tvb, offset);
163 /* get the TLV type */
164 tlv_type = get_tlv_type(&tlv_info);
165 /* get the TLV length */
166 tlv_len = get_tlv_length(&tlv_info);
167 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
168 { /* invalid tlv info */
169 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DSD RSP TLV error");
170 proto_tree_add_item(dsd_tree, hf_dsd_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
171 break;
173 /* get the TLV value offset */
174 tlv_value_offset = get_tlv_value_offset(&tlv_info);
175 #ifdef DEBUG /* for debug only */
176 proto_tree_add_protocol_format(dsd_tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, tlv_len + tlv_value_offset, "DSD-RSP TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len + tlv_value_offset, offset, tvb_len);
177 #endif
178 /* process TLV */
179 switch (tlv_type)
181 case HMAC_TUPLE: /* Table 348d */
182 /* decode and display the HMAC Tuple */
183 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dsd_req_decoder, dsd_tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, tlv_len, "HMAC Tuple");
184 wimax_hmac_tuple_decoder(tlv_tree, tvb, offset+tlv_value_offset, tlv_len);
185 break;
186 case CMAC_TUPLE: /* Table 348b */
187 /* decode and display the CMAC Tuple */
188 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dsd_req_decoder, dsd_tree, proto_mac_mgmt_msg_dsd_decoder, tvb, offset, tlv_len, "CMAC Tuple");
189 wimax_cmac_tuple_decoder(tlv_tree, tvb, offset+tlv_value_offset, tlv_len);
190 break;
191 default:
192 add_tlv_subtree(&tlv_info, dsd_tree, hf_dsd_unknown_type, tvb, offset, ENC_NA);
193 break;
195 offset += (tlv_len+tlv_value_offset);
196 } /* end of while loop */
200 /* Register Wimax Mac Payload Protocol and Dissector */
201 void proto_register_mac_mgmt_msg_dsd(void)
203 /* DSx display */
204 static hf_register_info hf[] =
207 &hf_dsd_confirmation_code,
209 "Confirmation code", "wmx.dsd.confirmation_code",
210 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL
214 &hf_dsd_service_flow_id,
216 "Service Flow ID", "wmx.dsd.service_flow_id",
217 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL
221 &hf_dsd_transaction_id,
223 "Transaction ID", "wmx.dsd.transaction_id",
224 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL
228 &hf_dsd_invalid_tlv,
230 "Invalid TLV", "wmx.dsd.invalid_tlv",
231 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL
235 &hf_dsd_unknown_type,
237 "Unknown type", "wmx.dsd.unknown_type",
238 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL
243 /* Setup protocol subtree array */
244 static gint *ett[] =
246 &ett_mac_mgmt_msg_dsd_req_decoder,
247 &ett_mac_mgmt_msg_dsd_rsp_decoder,
248 /* &ett_dsd_ul_sfe_decoder, */
249 /* &ett_dsd_dl_sfe_decoder, */
250 /* &ett_dsd_hmac_tuple, */
251 /* &ett_dsd_cmac_tuple, */
254 proto_mac_mgmt_msg_dsd_decoder = proto_register_protocol (
255 "WiMax DSD Messages", /* name */
256 "WiMax DSD", /* short name */
257 "wmx.dsd" /* abbrev */
260 proto_register_field_array(proto_mac_mgmt_msg_dsd_decoder, hf, array_length(hf));
261 proto_register_subtree_array(ett, array_length(ett));
264 void
265 proto_reg_handoff_mac_mgmt_msg_dsd(void)
267 dissector_handle_t dsd_handle;
269 dsd_handle = create_dissector_handle(dissect_mac_mgmt_msg_dsd_req_decoder, proto_mac_mgmt_msg_dsd_decoder);
270 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_DSD_REQ, dsd_handle);
272 dsd_handle = create_dissector_handle(dissect_mac_mgmt_msg_dsd_rsp_decoder, proto_mac_mgmt_msg_dsd_decoder);
273 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_DSD_RSP, dsd_handle);