2 * WiMax MAC Management DSD-REQ/RSP Messages decoder
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: Lu Pan <lu.pan@intel.com>
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.
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; */
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
)
62 guint tvb_len
, tlv_len
, tlv_value_offset
;
66 proto_tree
*tlv_tree
= NULL
;
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 */
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 */
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
);
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
);
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
);
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
);
119 /* display the unknown tlv in hex */
120 add_tlv_subtree(&tlv_info
, dsd_tree
, hf_dsd_unknown_type
, tvb
, offset
, ENC_NA
);
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
)
131 guint tvb_len
, tlv_len
, tlv_value_offset
;
133 proto_item
*dsd_item
;
134 proto_tree
*dsd_tree
;
135 proto_tree
*tlv_tree
= NULL
;
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 */
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 */
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 */
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
);
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
);
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
);
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
);
192 add_tlv_subtree(&tlv_info
, dsd_tree
, hf_dsd_unknown_type
, tvb
, offset
, ENC_NA
);
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)
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
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 */
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
));
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
);