2 * WiMax MAC Management DREG-REQ, DREG-CMD Message decoders
4 * Copyright (c) 2007 by Intel Corporation.
6 * Author: John R. Underwood <junderx@yahoo.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #include "moduleinfo.h"
38 #include <epan/packet.h>
40 #include "wimax_tlv.h"
41 #include "wimax_mac.h"
42 #include "wimax_utils.h"
44 extern gint man_ofdma;
45 extern gboolean include_cor2_changes;
47 /* Forward reference */
48 static void dissect_dreg_tlv(proto_tree *dreg_tree, gint tlv_type, tvbuff_t *tvb, guint tlv_offset, guint tlv_len);
49 void dissect_mac_mgmt_msg_dreg_req_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
50 void dissect_mac_mgmt_msg_dreg_cmd_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
52 static gint proto_mac_mgmt_msg_dreg_req_decoder = -1;
53 static gint proto_mac_mgmt_msg_dreg_cmd_decoder = -1;
55 static gint ett_mac_mgmt_msg_dreg_decoder = -1;
57 /* Setup protocol subtree array */
60 &ett_mac_mgmt_msg_dreg_decoder,
64 static gint hf_dreg_cmd_message_type = -1;
65 static gint hf_dreg_req_message_type = -1;
66 static gint hf_ack_type_reserved = -1;
67 static gint hf_dreg_cmd_action = -1;
68 static gint hf_dreg_cmd_action_cor2 = -1;
69 static gint hf_dreg_cmd_reserved = -1;
70 static gint hf_dreg_paging_cycle = -1;
71 static gint hf_dreg_paging_offset = -1;
72 static gint hf_dreg_paging_group_id = -1;
73 static gint hf_dreg_req_duration = -1;
74 static gint hf_paging_controller_id = -1;
75 static gint hf_mac_hash_skip_threshold = -1;
76 static gint hf_dreg_paging_cycle_request = -1;
77 static gint hf_dreg_retain_ms_service_sbc = -1;
78 static gint hf_dreg_retain_ms_service_pkm = -1;
79 static gint hf_dreg_retain_ms_service_reg = -1;
80 static gint hf_dreg_retain_ms_service_network_address = -1;
81 static gint hf_dreg_retain_ms_service_tod = -1;
82 static gint hf_dreg_retain_ms_service_tftp = -1;
83 static gint hf_dreg_retain_ms_service_full_service = -1;
84 static gint hf_dreg_consider_paging_pref = -1;
85 static gint hf_tlv_value = -1;
86 static gint hf_dreg_req_action = -1;
87 static gint hf_dreg_req_reserved = -1;
88 static gint hf_dreg_invalid_tlv = -1;
90 /* STRING RESOURCES */
91 static const value_string vals_dreg_req_code[] = {
92 {0, "SS De-Registration request from BS and network"},
93 {1, "MS request for De-Registration from serving BS and initiation of Idle Mode"},
94 {2, "MS response for the Unsolicited De-Registration initiated by BS"},
95 {3, "Reject for the unsolicited DREG-CMD with action \
96 code 05 (idle mode request) by the BS. \
97 Applicable only when MS has pending UL data to transmit"},
102 static const value_string vals_dreg_cmd_action[] = {
103 {0, "SS shall immediately terminate service with the BS and \
104 should attempt network entry at another BS"},
105 {1, "SS shall listen to the current channel BS but shall not \
106 transmit until an RES-CMD message or DREG-CMD with \
107 Action Code 02 or 03 is received"},
108 {2, "SS shall listen to the BS but only transmit \
109 on the Basic, and Primary Management Connections"},
110 {3, "SS shall return to normal operation and may transmit on \
111 any of its active connections"},
112 {4, "SS shall terminate current Normal Operations with the BS; \
113 the BS shall transmit this action code only in response \
114 to any SS DREG-REQ message"},
115 {5, "MS shall immediately begin de-registration from serving \
116 BS and request initiation of MS Idle Mode"},
117 {6, "The MS may retransmit the DREG-REQ message after the \
118 time duration (REQ-duration) provided in the message"},
119 {7, "The MS shall not retransmit the DREG-REQ message and shall \
120 wait for the DREG-CMD message. BS transmittal of a \
121 subsequent DREG-CMD with Action Code 03 shall cancel \
126 static const value_string vals_dreg_cmd_action_cor2[] = {
127 {0, "SS shall immediately terminate service with the BS and \
128 should attempt network entry at another BS"},
129 {1, "SS shall listen to the current channel BS but shall not \
130 transmit until an RES-CMD message or DREG-CMD with \
131 Action Code 02 or 03 is received"},
132 {2, "SS shall listen to the BS but only transmit \
133 on the Basic, and Primary Management Connections"},
134 {3, "SS shall return to normal operation and may transmit on \
135 any of its active connections"},
136 {4, "Only valid in response to a DREG-REQ message with DREG \
137 Code = 00. SS shall terminate current Normal Operations with the BS"},
138 {5, "MS shall immediately begin de-registration from serving \
139 BS and request initiation of MS Idle Mode"},
140 {6, "Only valid in response to a DREG-REQ message with DREG \
141 Code = 01. The MS may retransmit the DREG-REQ message after the \
142 REQ-duration provided in the message; \
143 BS sending a subsequent DREG-CMD message with \
144 Action Code 03 cancels this restriction"},
148 /* Decode sub-TLV's of either DREG-REQ or DREG-CMD. */
149 static void dissect_dreg_tlv(proto_tree *dreg_tree, gint tlv_type, tvbuff_t *tvb, guint tlv_offset, guint tlv_len)
152 case DREG_PAGING_INFO:
153 proto_tree_add_item(dreg_tree, hf_dreg_paging_cycle, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
154 proto_tree_add_item(dreg_tree, hf_dreg_paging_offset, tvb, tlv_offset + 2, 1, ENC_BIG_ENDIAN);
155 proto_tree_add_item(dreg_tree, hf_dreg_paging_group_id, tvb, tlv_offset + 3, 2, ENC_BIG_ENDIAN);
157 case DREG_REQ_DURATION:
158 proto_tree_add_item(dreg_tree, hf_dreg_req_duration, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
160 case DREG_PAGING_CONTROLLER_ID:
161 proto_tree_add_item(dreg_tree, hf_paging_controller_id, tvb, tlv_offset, 6, FALSE);
163 case DREG_IDLE_MODE_RETAIN_INFO:
164 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_sbc, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
165 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_pkm, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
166 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_reg, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
167 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_network_address, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
168 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_tod, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
169 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_tftp, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
170 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_full_service, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
171 proto_tree_add_item(dreg_tree, hf_dreg_consider_paging_pref, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
173 case DREG_MAC_HASH_SKIP_THRESHOLD:
174 proto_tree_add_item(dreg_tree, hf_mac_hash_skip_threshold, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
176 case DREG_PAGING_CYCLE_REQUEST:
177 proto_tree_add_item(dreg_tree, hf_dreg_paging_cycle_request, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
180 proto_tree_add_item(dreg_tree, hf_tlv_value, tvb, tlv_offset, tlv_len, ENC_NA);
185 /* Register Wimax Mac Payload Protocol and Dissector */
186 void proto_register_mac_mgmt_msg_dreg_req(void)
188 /* DREG fields display */
189 static hf_register_info hf[] =
192 &hf_dreg_consider_paging_pref,
194 "Consider Paging Preference of each Service Flow in resource retention", "wmx.dreg.consider_paging_preference",
195 FT_UINT8, BASE_DEC, NULL, 0x80, NULL, HFILL
199 &hf_dreg_invalid_tlv,
201 "Invalid TLV", "wmx.dreg.invalid_tlv",
202 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
206 &hf_mac_hash_skip_threshold,
208 "MAC Hash Skip Threshold", "wmx.dreg.mac_hash_skip_threshold",
209 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
213 &hf_paging_controller_id,
215 "Paging Controller ID", "wmx.dreg.paging_controller_id",
216 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL
220 &hf_dreg_paging_cycle,
222 "PAGING CYCLE", "wmx.dreg.paging_cycle",
223 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
227 &hf_dreg_paging_cycle_request,
229 "Paging Cycle Request", "wmx.dreg.paging_cycle_request",
230 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
234 &hf_dreg_paging_group_id,
236 "Paging-group-ID", "wmx.dreg.paging_group_id",
237 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
241 &hf_dreg_paging_offset,
243 "PAGING OFFSET", "wmx.dreg.paging_offset",
244 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
248 &hf_dreg_req_duration,
250 "REQ-duration (Waiting value for the DREG-REQ message re-transmission in frames)", "wmx.dreg.req_duration",
251 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
255 &hf_dreg_retain_ms_service_full_service,
257 "Retain MS service and operation information associated with Full service", "wmx.dreg.retain_ms_full_service",
258 FT_UINT8, BASE_DEC, NULL, 0x40, NULL, HFILL
262 &hf_dreg_retain_ms_service_network_address,
264 "Retain MS service and operational information associated with Network Address", "wmx.dreg.retain_ms_service_network_address",
265 FT_UINT8, BASE_DEC, NULL, 0x08, NULL, HFILL
269 &hf_dreg_retain_ms_service_pkm,
271 "Retain MS service and operational information associated with PKM-REQ/RSP", "wmx.dreg.retain_ms_service_pkm",
272 FT_UINT8, BASE_DEC, NULL, 0x02, NULL, HFILL
276 &hf_dreg_retain_ms_service_reg,
278 "Retain MS service and operational information associated with REG-REQ/RSP", "wmx.dreg.retain_ms_service_reg",
279 FT_UINT8, BASE_DEC, NULL, 0x04, NULL, HFILL
283 &hf_dreg_retain_ms_service_sbc,
285 "Retain MS service and operational information associated with SBC-REQ/RSP", "wmx.dreg.retain_ms_service_sbc",
286 FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL
290 &hf_dreg_retain_ms_service_tftp,
292 "Retain MS service and operational information associated with TFTP messages", "wmx.dreg.retain_ms_service_tftp",
293 FT_UINT8, BASE_DEC, NULL, 0x20, NULL, HFILL
297 &hf_dreg_retain_ms_service_tod,
299 "Retain MS service and operational information associated with Time of Day", "wmx.dreg.retain_ms_service_tod",
300 FT_UINT8, BASE_DEC, NULL, 0x10, NULL, HFILL
304 &hf_dreg_cmd_message_type,
306 "MAC Management Message Type", "wmx.macmgtmsgtype.dreg_cmd",
307 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
313 "DREG-CMD Action code", "wmx.dreg_cmd.action",
314 FT_UINT8, BASE_DEC, VALS(vals_dreg_cmd_action), 0x07, NULL, HFILL
318 &hf_dreg_cmd_action_cor2,
320 "DREG-CMD Action code", "wmx.dreg_cmd.action",
321 FT_UINT8, BASE_DEC, VALS(vals_dreg_cmd_action_cor2), 0x07, NULL, HFILL
325 &hf_dreg_cmd_reserved,
327 "Reserved", "wmx.dreg_cmd.action_reserved",
328 FT_UINT8, BASE_DEC, NULL, 0xF8, NULL, HFILL
332 &hf_dreg_req_message_type,
334 "MAC Management Message Type", "wmx.macmgtmsgtype.dreg_req",
335 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
341 "DREG-REQ Action code", "wmx.dreg_req.action",
342 FT_UINT8, BASE_DEC, VALS(vals_dreg_req_code), 0x03, NULL, HFILL
346 &hf_dreg_req_reserved,
348 "Reserved", "wmx.dreg_req.action_reserved",
349 FT_UINT8, BASE_DEC, NULL, 0xFC, NULL, HFILL
355 "Value", "wmx.dreg.unknown_tlv_value",
356 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
360 &hf_ack_type_reserved,
362 "Reserved", "wmx.ack_type_reserved",
363 FT_UINT8, BASE_DEC, NULL, 0x03, NULL, HFILL
368 proto_mac_mgmt_msg_dreg_req_decoder = proto_register_protocol (
369 "WiMax DREG-REQ/CMD Messages", /* name */
370 "WiMax DREG-REQ/CMD (dreg)", /* short name */
371 "wmx.dreg" /* abbrev */
374 proto_register_field_array(proto_mac_mgmt_msg_dreg_req_decoder, hf, array_length(hf));
375 proto_register_subtree_array(ett, array_length(ett));
378 /* Register Wimax Mac Payload Protocol and Dissector */
379 void proto_register_mac_mgmt_msg_dreg_cmd(void)
381 proto_mac_mgmt_msg_dreg_cmd_decoder = proto_mac_mgmt_msg_dreg_req_decoder;
384 /* Decode DREG-REQ messages. */
385 void dissect_mac_mgmt_msg_dreg_req_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
389 guint tvb_len, payload_type;
390 proto_item *dreg_req_item = NULL;
391 proto_tree *dreg_req_tree = NULL;
392 proto_tree *tlv_tree = NULL;
396 gboolean hmac_found = FALSE;
398 /* Ensure the right payload type */
399 payload_type = tvb_get_guint8(tvb, 0);
400 if(payload_type != MAC_MGMT_MSG_DREG_REQ)
406 { /* we are being asked for details */
408 /* Get the tvb reported length */
409 tvb_len = tvb_reported_length(tvb);
410 /* display MAC payload type DREG-REQ */
411 dreg_req_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, 0, tvb_len, "MAC Management Message, DREG-REQ (49)");
412 /* add MAC DREG REQ subtree */
413 dreg_req_tree = proto_item_add_subtree(dreg_req_item, ett_mac_mgmt_msg_dreg_decoder);
414 /* display the Message Type */
415 proto_tree_add_item(dreg_req_tree, hf_dreg_req_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
417 /* display the Action Code */
418 proto_tree_add_item(dreg_req_tree, hf_dreg_req_action, tvb, offset, 1, ENC_BIG_ENDIAN);
419 /* show the Reserved bits */
420 proto_tree_add_item(dreg_req_tree, hf_dreg_req_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
423 while(offset < tvb_len)
425 /* Get the TLV data. */
426 init_tlv_info(&tlv_info, tvb, offset);
427 /* get the TLV type */
428 tlv_type = get_tlv_type(&tlv_info);
429 /* get the TLV length */
430 tlv_len = get_tlv_length(&tlv_info);
431 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
432 { /* invalid tlv info */
433 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DREG-REQ TLV error");
434 proto_tree_add_item(dreg_req_tree, hf_dreg_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
437 /* get the offset to the TLV data */
438 tlv_offset = offset + get_tlv_value_offset(&tlv_info);
441 case HMAC_TUPLE: /* Table 348d */
442 /* decode and display the HMAC Tuple */
443 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_req_tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, tlv_offset, tlv_len, "HMAC Tuple (%u byte(s))", tlv_len);
444 wimax_hmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
447 case CMAC_TUPLE: /* Table 348b */
448 /* decode and display the CMAC Tuple */
449 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_req_tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, tlv_offset, tlv_len, "CMAC Tuple (%u byte(s))", tlv_len);
450 wimax_cmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
453 /* Decode DREG-REQ sub-TLV's */
454 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_req_tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, tlv_offset, tlv_len, "DREG-REQ sub-TLV's (%u byte(s))", tlv_len);
455 dissect_dreg_tlv(tlv_tree, tlv_type, tvb, tlv_offset, tlv_len);
460 offset = tlv_len + tlv_offset;
461 } /* end of TLV process while loop */
463 proto_item_append_text(dreg_req_tree, " (HMAC Tuple is missing !)");
467 /* Decode DREG-CMD messages. */
468 void dissect_mac_mgmt_msg_dreg_cmd_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
472 guint tvb_len, payload_type;
473 proto_item *dreg_cmd_item = NULL;
474 proto_tree *dreg_cmd_tree = NULL;
475 proto_tree *tlv_tree = NULL;
479 gboolean hmac_found = FALSE;
481 /* Ensure the right payload type */
482 payload_type = tvb_get_guint8(tvb, 0);
483 if(payload_type != MAC_MGMT_MSG_DREG_CMD)
489 { /* we are being asked for details */
491 /* Get the tvb reported length */
492 tvb_len = tvb_reported_length(tvb);
493 /* display MAC payload type DREG-CMD */
494 dreg_cmd_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, 0, tvb_len, "MAC Management Message, DREG-CMD (29)");
495 /* add MAC DREG CMD subtree */
496 dreg_cmd_tree = proto_item_add_subtree(dreg_cmd_item, ett_mac_mgmt_msg_dreg_decoder);
497 /* display the Message Type */
498 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
500 /* display the Action Code */
501 if (include_cor2_changes)
502 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_action_cor2, tvb, offset, 1, ENC_BIG_ENDIAN);
504 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_action, tvb, offset, 1, ENC_BIG_ENDIAN);
505 /* show the Reserved bits */
506 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
509 while(offset < tvb_len)
511 /* Get the TLV data. */
512 init_tlv_info(&tlv_info, tvb, offset);
513 /* get the TLV type */
514 tlv_type = get_tlv_type(&tlv_info);
515 /* get the TLV length */
516 tlv_len = get_tlv_length(&tlv_info);
517 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
518 { /* invalid tlv info */
519 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DREG-CMD TLV error");
520 proto_tree_add_item(dreg_cmd_tree, hf_dreg_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
523 /* get the offset to the TLV data */
524 tlv_offset = offset + get_tlv_value_offset(&tlv_info);
527 case HMAC_TUPLE: /* Table 348d */
528 /* decode and display the HMAC Tuple */
529 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_cmd_tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, tlv_offset, tlv_len, "HMAC Tuple (%u byte(s))", tlv_len);
530 wimax_hmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
533 case CMAC_TUPLE: /* Table 348b */
534 /* decode and display the CMAC Tuple */
535 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_cmd_tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, tlv_offset, tlv_len, "CMAC Tuple (%u byte(s))", tlv_len);
536 wimax_cmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
539 /* Decode DREG-CMD sub-TLV's */
540 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_cmd_tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, tlv_offset, tlv_len, "DREG-CMD sub-TLV's (%u byte(s))", tlv_len);
541 dissect_dreg_tlv(tlv_tree, tlv_type, tvb, tlv_offset, tlv_len);
545 offset = tlv_len + tlv_offset;
546 } /* end of TLV process while loop */
548 proto_item_append_text(dreg_cmd_tree, " (HMAC Tuple is missing !)");