MSWSP: add ids for another unknown Property Set
[wireshark-wip.git] / plugins / wimax / msg_dreg.c
blob756b8070a897ce31b6a31a3f0bcf6b1927b89112
1 /* msg_dreg.c
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>
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"
33 #include "moduleinfo.h"
35 #include <glib.h>
36 #include <epan/packet.h>
37 #include "crc.h"
38 #include "wimax_tlv.h"
39 #include "wimax_mac.h"
40 #include "wimax_utils.h"
42 extern gboolean include_cor2_changes;
44 /* Forward reference */
45 static void dissect_dreg_tlv(proto_tree *dreg_tree, gint tlv_type, tvbuff_t *tvb, guint tlv_offset, guint tlv_len);
47 static gint proto_mac_mgmt_msg_dreg_req_decoder = -1;
48 static gint proto_mac_mgmt_msg_dreg_cmd_decoder = -1;
50 static gint ett_mac_mgmt_msg_dreg_decoder = -1;
52 /* Setup protocol subtree array */
53 static gint *ett[] =
55 &ett_mac_mgmt_msg_dreg_decoder,
58 /* DREG fields */
59 /* static gint hf_ack_type_reserved = -1; */
60 static gint hf_dreg_cmd_action = -1;
61 static gint hf_dreg_cmd_action_cor2 = -1;
62 static gint hf_dreg_cmd_reserved = -1;
63 static gint hf_dreg_paging_cycle = -1;
64 static gint hf_dreg_paging_offset = -1;
65 static gint hf_dreg_paging_group_id = -1;
66 static gint hf_dreg_req_duration = -1;
67 static gint hf_paging_controller_id = -1;
68 static gint hf_mac_hash_skip_threshold = -1;
69 static gint hf_dreg_paging_cycle_request = -1;
70 static gint hf_dreg_retain_ms_service_sbc = -1;
71 static gint hf_dreg_retain_ms_service_pkm = -1;
72 static gint hf_dreg_retain_ms_service_reg = -1;
73 static gint hf_dreg_retain_ms_service_network_address = -1;
74 static gint hf_dreg_retain_ms_service_tod = -1;
75 static gint hf_dreg_retain_ms_service_tftp = -1;
76 static gint hf_dreg_retain_ms_service_full_service = -1;
77 static gint hf_dreg_consider_paging_pref = -1;
78 static gint hf_tlv_value = -1;
79 static gint hf_dreg_req_action = -1;
80 static gint hf_dreg_req_reserved = -1;
81 static gint hf_dreg_invalid_tlv = -1;
83 /* STRING RESOURCES */
84 static const value_string vals_dreg_req_code[] = {
85 {0, "SS De-Registration request from BS and network"},
86 {1, "MS request for De-Registration from serving BS and initiation of Idle Mode"},
87 {2, "MS response for the Unsolicited De-Registration initiated by BS"},
88 {3, "Reject for the unsolicited DREG-CMD with action \
89 code 05 (idle mode request) by the BS. \
90 Applicable only when MS has pending UL data to transmit"},
91 {4, "Reserved"},
92 {0, NULL}
95 static const value_string vals_dreg_cmd_action[] = {
96 {0, "SS shall immediately terminate service with the BS and \
97 should attempt network entry at another BS"},
98 {1, "SS shall listen to the current channel BS but shall not \
99 transmit until an RES-CMD message or DREG-CMD with \
100 Action Code 02 or 03 is received"},
101 {2, "SS shall listen to the BS but only transmit \
102 on the Basic, and Primary Management Connections"},
103 {3, "SS shall return to normal operation and may transmit on \
104 any of its active connections"},
105 {4, "SS shall terminate current Normal Operations with the BS; \
106 the BS shall transmit this action code only in response \
107 to any SS DREG-REQ message"},
108 {5, "MS shall immediately begin de-registration from serving \
109 BS and request initiation of MS Idle Mode"},
110 {6, "The MS may retransmit the DREG-REQ message after the \
111 time duration (REQ-duration) provided in the message"},
112 {7, "The MS shall not retransmit the DREG-REQ message and shall \
113 wait for the DREG-CMD message. BS transmittal of a \
114 subsequent DREG-CMD with Action Code 03 shall cancel \
115 this restriction"},
116 {0, NULL}
119 static const value_string vals_dreg_cmd_action_cor2[] = {
120 {0, "SS shall immediately terminate service with the BS and \
121 should attempt network entry at another BS"},
122 {1, "SS shall listen to the current channel BS but shall not \
123 transmit until an RES-CMD message or DREG-CMD with \
124 Action Code 02 or 03 is received"},
125 {2, "SS shall listen to the BS but only transmit \
126 on the Basic, and Primary Management Connections"},
127 {3, "SS shall return to normal operation and may transmit on \
128 any of its active connections"},
129 {4, "Only valid in response to a DREG-REQ message with DREG \
130 Code = 00. SS shall terminate current Normal Operations with the BS"},
131 {5, "MS shall immediately begin de-registration from serving \
132 BS and request initiation of MS Idle Mode"},
133 {6, "Only valid in response to a DREG-REQ message with DREG \
134 Code = 01. The MS may retransmit the DREG-REQ message after the \
135 REQ-duration provided in the message; \
136 BS sending a subsequent DREG-CMD message with \
137 Action Code 03 cancels this restriction"},
138 {0, NULL}
141 /* Decode sub-TLV's of either DREG-REQ or DREG-CMD. */
142 static void dissect_dreg_tlv(proto_tree *dreg_tree, gint tlv_type, tvbuff_t *tvb, guint tlv_offset, guint tlv_len)
144 switch (tlv_type) {
145 case DREG_PAGING_INFO:
146 proto_tree_add_item(dreg_tree, hf_dreg_paging_cycle, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
147 proto_tree_add_item(dreg_tree, hf_dreg_paging_offset, tvb, tlv_offset + 2, 1, ENC_BIG_ENDIAN);
148 proto_tree_add_item(dreg_tree, hf_dreg_paging_group_id, tvb, tlv_offset + 3, 2, ENC_BIG_ENDIAN);
149 break;
150 case DREG_REQ_DURATION:
151 proto_tree_add_item(dreg_tree, hf_dreg_req_duration, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
152 break;
153 case DREG_PAGING_CONTROLLER_ID:
154 proto_tree_add_item(dreg_tree, hf_paging_controller_id, tvb, tlv_offset, 6, ENC_NA);
155 break;
156 case DREG_IDLE_MODE_RETAIN_INFO:
157 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_sbc, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
158 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_pkm, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
159 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_reg, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
160 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_network_address, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
161 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_tod, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
162 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_tftp, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
163 proto_tree_add_item(dreg_tree, hf_dreg_retain_ms_service_full_service, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
164 proto_tree_add_item(dreg_tree, hf_dreg_consider_paging_pref, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
165 break;
166 case DREG_MAC_HASH_SKIP_THRESHOLD:
167 proto_tree_add_item(dreg_tree, hf_mac_hash_skip_threshold, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
168 break;
169 case DREG_PAGING_CYCLE_REQUEST:
170 proto_tree_add_item(dreg_tree, hf_dreg_paging_cycle_request, tvb, tlv_offset, 2, ENC_BIG_ENDIAN);
171 break;
172 default:
173 proto_tree_add_item(dreg_tree, hf_tlv_value, tvb, tlv_offset, tlv_len, ENC_NA);
174 break;
178 /* Register Wimax Mac Payload Protocol and Dissector */
179 void proto_register_mac_mgmt_msg_dreg_req(void)
181 /* DREG fields display */
182 static hf_register_info hf[] =
185 &hf_dreg_consider_paging_pref,
187 "Consider Paging Preference of each Service Flow in resource retention", "wmx.dreg.consider_paging_preference",
188 FT_UINT8, BASE_DEC, NULL, 0x80, NULL, HFILL
192 &hf_dreg_invalid_tlv,
194 "Invalid TLV", "wmx.dreg.invalid_tlv",
195 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
199 &hf_mac_hash_skip_threshold,
201 "MAC Hash Skip Threshold", "wmx.dreg.mac_hash_skip_threshold",
202 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
206 &hf_paging_controller_id,
208 "Paging Controller ID", "wmx.dreg.paging_controller_id",
209 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL
213 &hf_dreg_paging_cycle,
215 "PAGING CYCLE", "wmx.dreg.paging_cycle",
216 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
220 &hf_dreg_paging_cycle_request,
222 "Paging Cycle Request", "wmx.dreg.paging_cycle_request",
223 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
227 &hf_dreg_paging_group_id,
229 "Paging-group-ID", "wmx.dreg.paging_group_id",
230 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
234 &hf_dreg_paging_offset,
236 "PAGING OFFSET", "wmx.dreg.paging_offset",
237 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
241 &hf_dreg_req_duration,
243 "REQ-duration (Waiting value for the DREG-REQ message re-transmission in frames)", "wmx.dreg.req_duration",
244 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
248 &hf_dreg_retain_ms_service_full_service,
250 "Retain MS service and operation information associated with Full service", "wmx.dreg.retain_ms_full_service",
251 FT_UINT8, BASE_DEC, NULL, 0x40, NULL, HFILL
255 &hf_dreg_retain_ms_service_network_address,
257 "Retain MS service and operational information associated with Network Address", "wmx.dreg.retain_ms_service_network_address",
258 FT_UINT8, BASE_DEC, NULL, 0x08, NULL, HFILL
262 &hf_dreg_retain_ms_service_pkm,
264 "Retain MS service and operational information associated with PKM-REQ/RSP", "wmx.dreg.retain_ms_service_pkm",
265 FT_UINT8, BASE_DEC, NULL, 0x02, NULL, HFILL
269 &hf_dreg_retain_ms_service_reg,
271 "Retain MS service and operational information associated with REG-REQ/RSP", "wmx.dreg.retain_ms_service_reg",
272 FT_UINT8, BASE_DEC, NULL, 0x04, NULL, HFILL
276 &hf_dreg_retain_ms_service_sbc,
278 "Retain MS service and operational information associated with SBC-REQ/RSP", "wmx.dreg.retain_ms_service_sbc",
279 FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL
283 &hf_dreg_retain_ms_service_tftp,
285 "Retain MS service and operational information associated with TFTP messages", "wmx.dreg.retain_ms_service_tftp",
286 FT_UINT8, BASE_DEC, NULL, 0x20, NULL, HFILL
290 &hf_dreg_retain_ms_service_tod,
292 "Retain MS service and operational information associated with Time of Day", "wmx.dreg.retain_ms_service_tod",
293 FT_UINT8, BASE_DEC, NULL, 0x10, NULL, HFILL
297 &hf_dreg_cmd_action,
299 "DREG-CMD Action code", "wmx.dreg_cmd.action",
300 FT_UINT8, BASE_DEC, VALS(vals_dreg_cmd_action), 0x07, NULL, HFILL
304 &hf_dreg_cmd_action_cor2,
306 "DREG-CMD Action code", "wmx.dreg_cmd.action",
307 FT_UINT8, BASE_DEC, VALS(vals_dreg_cmd_action_cor2), 0x07, NULL, HFILL
311 &hf_dreg_cmd_reserved,
313 "Reserved", "wmx.dreg_cmd.action_reserved",
314 FT_UINT8, BASE_DEC, NULL, 0xF8, NULL, HFILL
318 &hf_dreg_req_action,
320 "DREG-REQ Action code", "wmx.dreg_req.action",
321 FT_UINT8, BASE_DEC, VALS(vals_dreg_req_code), 0x03, NULL, HFILL
325 &hf_dreg_req_reserved,
327 "Reserved", "wmx.dreg_req.action_reserved",
328 FT_UINT8, BASE_DEC, NULL, 0xFC, NULL, HFILL
332 &hf_tlv_value,
334 "Value", "wmx.dreg.unknown_tlv_value",
335 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
338 #if 0
340 &hf_ack_type_reserved,
342 "Reserved", "wmx.ack_type_reserved",
343 FT_UINT8, BASE_DEC, NULL, 0x03, NULL, HFILL
346 #endif
349 proto_mac_mgmt_msg_dreg_req_decoder = proto_register_protocol (
350 "WiMax DREG-REQ Messages", /* name */
351 "WiMax DREG-REQ", /* short name */
352 "wmx.dreg_req" /* abbrev */
355 proto_register_field_array(proto_mac_mgmt_msg_dreg_req_decoder, hf, array_length(hf));
356 proto_register_subtree_array(ett, array_length(ett));
359 /* Register Wimax Mac Payload Protocol and Dissector */
360 void proto_register_mac_mgmt_msg_dreg_cmd(void)
362 proto_mac_mgmt_msg_dreg_cmd_decoder = proto_register_protocol (
363 "WiMax DREG-CMD Messages", /* name */
364 "WiMax DREG-CMD", /* short name */
365 "wmx.dreg_cmd" /* abbrev */
369 /* Decode DREG-REQ messages. */
370 static void dissect_mac_mgmt_msg_dreg_req_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
372 guint offset = 0;
373 guint tlv_offset;
374 guint tvb_len;
375 proto_item *dreg_req_item;
376 proto_tree *dreg_req_tree;
377 proto_tree *tlv_tree = NULL;
378 tlv_info_t tlv_info;
379 gint tlv_type;
380 gint tlv_len;
381 gboolean hmac_found = FALSE;
383 { /* we are being asked for details */
385 /* Get the tvb reported length */
386 tvb_len = tvb_reported_length(tvb);
387 /* display MAC payload type DREG-REQ */
388 dreg_req_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, 0, -1, "MAC Management Message, DREG-REQ");
389 /* add MAC DREG REQ subtree */
390 dreg_req_tree = proto_item_add_subtree(dreg_req_item, ett_mac_mgmt_msg_dreg_decoder);
391 /* display the Action Code */
392 proto_tree_add_item(dreg_req_tree, hf_dreg_req_action, tvb, offset, 1, ENC_BIG_ENDIAN);
393 /* show the Reserved bits */
394 proto_tree_add_item(dreg_req_tree, hf_dreg_req_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
395 offset++;
397 while(offset < tvb_len)
399 /* Get the TLV data. */
400 init_tlv_info(&tlv_info, tvb, offset);
401 /* get the TLV type */
402 tlv_type = get_tlv_type(&tlv_info);
403 /* get the TLV length */
404 tlv_len = get_tlv_length(&tlv_info);
405 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
406 { /* invalid tlv info */
407 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DREG-REQ TLV error");
408 proto_tree_add_item(dreg_req_tree, hf_dreg_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
409 break;
411 /* get the offset to the TLV data */
412 tlv_offset = offset + get_tlv_value_offset(&tlv_info);
414 switch (tlv_type) {
415 case HMAC_TUPLE: /* Table 348d */
416 /* decode and display the HMAC Tuple */
417 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_req_tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, offset, tlv_len, "HMAC Tuple");
418 wimax_hmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
419 hmac_found = TRUE;
420 break;
421 case CMAC_TUPLE: /* Table 348b */
422 /* decode and display the CMAC Tuple */
423 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_req_tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, offset, tlv_len, "CMAC Tuple");
424 wimax_cmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
425 break;
426 default:
427 /* Decode DREG-REQ sub-TLV's */
428 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_req_tree, proto_mac_mgmt_msg_dreg_req_decoder, tvb, offset, tlv_len, "DREG-REQ sub-TLV's");
429 dissect_dreg_tlv(tlv_tree, tlv_type, tvb, tlv_offset, tlv_len);
430 break;
434 offset = tlv_len + tlv_offset;
435 } /* end of TLV process while loop */
436 if (!hmac_found)
437 proto_item_append_text(dreg_req_tree, " (HMAC Tuple is missing !)");
441 /* Decode DREG-CMD messages. */
442 static void dissect_mac_mgmt_msg_dreg_cmd_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
444 guint offset = 0;
445 guint tlv_offset;
446 guint tvb_len;
447 proto_item *dreg_cmd_item;
448 proto_tree *dreg_cmd_tree;
449 proto_tree *tlv_tree = NULL;
450 tlv_info_t tlv_info;
451 gint tlv_type;
452 gint tlv_len;
453 gboolean hmac_found = FALSE;
455 { /* we are being asked for details */
457 /* Get the tvb reported length */
458 tvb_len = tvb_reported_length(tvb);
459 /* display MAC payload type DREG-CMD */
460 dreg_cmd_item = proto_tree_add_protocol_format(tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, 0, -1, "MAC Management Message, DREG-CMD");
461 /* add MAC DREG CMD subtree */
462 dreg_cmd_tree = proto_item_add_subtree(dreg_cmd_item, ett_mac_mgmt_msg_dreg_decoder);
463 /* display the Action Code */
464 if (include_cor2_changes)
465 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_action_cor2, tvb, offset, 1, ENC_BIG_ENDIAN);
466 else
467 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_action, tvb, offset, 1, ENC_BIG_ENDIAN);
468 /* show the Reserved bits */
469 proto_tree_add_item(dreg_cmd_tree, hf_dreg_cmd_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
470 offset ++;
472 while(offset < tvb_len)
474 /* Get the TLV data. */
475 init_tlv_info(&tlv_info, tvb, offset);
476 /* get the TLV type */
477 tlv_type = get_tlv_type(&tlv_info);
478 /* get the TLV length */
479 tlv_len = get_tlv_length(&tlv_info);
480 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
481 { /* invalid tlv info */
482 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "DREG-CMD TLV error");
483 proto_tree_add_item(dreg_cmd_tree, hf_dreg_invalid_tlv, tvb, offset, (tvb_len - offset), ENC_NA);
484 break;
486 /* get the offset to the TLV data */
487 tlv_offset = offset + get_tlv_value_offset(&tlv_info);
489 switch (tlv_type) {
490 case HMAC_TUPLE: /* Table 348d */
491 /* decode and display the HMAC Tuple */
492 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_cmd_tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, offset, tlv_len, "HMAC Tuple");
493 wimax_hmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
494 hmac_found = TRUE;
495 break;
496 case CMAC_TUPLE: /* Table 348b */
497 /* decode and display the CMAC Tuple */
498 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_cmd_tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, offset, tlv_len, "CMAC Tuple");
499 wimax_cmac_tuple_decoder(tlv_tree, tvb, tlv_offset, tlv_len);
500 break;
501 default:
502 /* Decode DREG-CMD sub-TLV's */
503 tlv_tree = add_protocol_subtree(&tlv_info, ett_mac_mgmt_msg_dreg_decoder, dreg_cmd_tree, proto_mac_mgmt_msg_dreg_cmd_decoder, tvb, offset, tlv_len, "DREG-CMD sub-TLV's");
504 dissect_dreg_tlv(tlv_tree, tlv_type, tvb, tlv_offset, tlv_len);
505 break;
508 offset = tlv_len + tlv_offset;
509 } /* end of TLV process while loop */
510 if (!hmac_found)
511 proto_item_append_text(dreg_cmd_tree, " (HMAC Tuple is missing !)");
515 void
516 proto_reg_handoff_mac_mgmt_msg_dreg(void)
518 dissector_handle_t dreg_handle;
520 dreg_handle = create_dissector_handle(dissect_mac_mgmt_msg_dreg_req_decoder, proto_mac_mgmt_msg_dreg_req_decoder);
521 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_DREG_REQ, dreg_handle);
523 dreg_handle = create_dissector_handle(dissect_mac_mgmt_msg_dreg_cmd_decoder, proto_mac_mgmt_msg_dreg_cmd_decoder);
524 dissector_add_uint("wmx.mgmtmsg", MAC_MGMT_MSG_DREG_CMD, dreg_handle);