Use ENC_NA as proto_tree_add_item() encoding arg for FT_ETHER hf[] field type.
[obnox/wireshark/wip.git] / plugins / wimax / msg_dreg.c
1 /* msg_dreg.c
2  * WiMax MAC Management DREG-REQ, DREG-CMD Message decoders
3  *
4  * Copyright (c) 2007 by Intel Corporation.
5  *
6  * Author: John R. Underwood <junderx@yahoo.com>
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1999 Gerald Combs
13  *
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.
18  *
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.
23  *
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.
27  */
28
29 /* Include files */
30
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34
35 #include "moduleinfo.h"
36
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include "crc.h"
40 #include "wimax_tlv.h"
41 #include "wimax_mac.h"
42 #include "wimax_utils.h"
43
44 extern gint man_ofdma;
45 extern  gboolean include_cor2_changes;
46
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);
51
52 static gint proto_mac_mgmt_msg_dreg_req_decoder = -1;
53 static gint proto_mac_mgmt_msg_dreg_cmd_decoder = -1;
54
55 static gint ett_mac_mgmt_msg_dreg_decoder = -1;
56
57 /* Setup protocol subtree array */
58 static gint *ett[] =
59 {
60         &ett_mac_mgmt_msg_dreg_decoder,
61 };
62
63 /* DREG fields */
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;
89
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"},
98         {4, "Reserved"},
99         {0,                             NULL}
100 };
101
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 \
122 this restriction"},
123         {0,                             NULL}
124 };
125
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"},
145         {0,                             NULL}
146 };
147
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)
150 {
151         switch (tlv_type) {
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);
156                         break;
157                 case DREG_REQ_DURATION:
158                         proto_tree_add_item(dreg_tree, hf_dreg_req_duration, tvb, tlv_offset, 1, ENC_BIG_ENDIAN);
159                         break;
160                 case DREG_PAGING_CONTROLLER_ID:
161                         proto_tree_add_item(dreg_tree, hf_paging_controller_id, tvb, tlv_offset, 6, ENC_NA);
162                         break;
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);
172                         break;
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);
175                         break;
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);
178                         break;
179                 default:
180                         proto_tree_add_item(dreg_tree, hf_tlv_value, tvb, tlv_offset, tlv_len, ENC_NA);
181                         break;
182         }
183 }
184
185 /* Register Wimax Mac Payload Protocol and Dissector */
186 void proto_register_mac_mgmt_msg_dreg_req(void)
187 {
188         /* DREG fields display */
189         static hf_register_info hf[] =
190         {
191                 {
192                         &hf_dreg_consider_paging_pref,
193                         {
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
196                         }
197                 },
198                 {
199                         &hf_dreg_invalid_tlv,
200                         {
201                                 "Invalid TLV", "wmx.dreg.invalid_tlv",
202                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL
203                         }
204                 },
205                 {
206                         &hf_mac_hash_skip_threshold,
207                         {
208                                 "MAC Hash Skip Threshold", "wmx.dreg.mac_hash_skip_threshold",
209                                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
210                         }
211                 },
212                 {
213                         &hf_paging_controller_id,
214                         {
215                                 "Paging Controller ID", "wmx.dreg.paging_controller_id",
216                                 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL
217                         }
218                 },
219                 {
220                         &hf_dreg_paging_cycle,
221                         {
222                                 "PAGING CYCLE", "wmx.dreg.paging_cycle",
223                                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
224                         }
225                 },
226                 {
227                         &hf_dreg_paging_cycle_request,
228                         {
229                                 "Paging Cycle Request", "wmx.dreg.paging_cycle_request",
230                                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
231                         }
232                 },
233                 {
234                         &hf_dreg_paging_group_id,
235                         {
236                                 "Paging-group-ID", "wmx.dreg.paging_group_id",
237                                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
238                         }
239                 },
240                 {
241                         &hf_dreg_paging_offset,
242                         {
243                                 "PAGING OFFSET", "wmx.dreg.paging_offset",
244                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
245                         }
246                 },
247                 {
248                         &hf_dreg_req_duration,
249                         {
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
252                         }
253                 },
254                 {
255                         &hf_dreg_retain_ms_service_full_service,
256                         {
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
259                         }
260                 },
261                 {
262                         &hf_dreg_retain_ms_service_network_address,
263                         {
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
266                         }
267                 },
268                 {
269                         &hf_dreg_retain_ms_service_pkm,
270                         {
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
273                         }
274                 },
275                 {
276                         &hf_dreg_retain_ms_service_reg,
277                         {
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
280                         }
281                 },
282                 {
283                         &hf_dreg_retain_ms_service_sbc,
284                         {
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
287                         }
288                 },
289                 {
290                         &hf_dreg_retain_ms_service_tftp,
291                         {
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
294                         }
295                 },
296                 {
297                         &hf_dreg_retain_ms_service_tod,
298                         {
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
301                         }
302                 },
303                 {
304                         &hf_dreg_cmd_message_type,
305                         {
306                                 "MAC Management Message Type", "wmx.macmgtmsgtype.dreg_cmd",
307                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
308                         }
309                 },
310                 {
311                         &hf_dreg_cmd_action,
312                         {
313                                 "DREG-CMD Action code", "wmx.dreg_cmd.action",
314                                 FT_UINT8, BASE_DEC, VALS(vals_dreg_cmd_action), 0x07, NULL, HFILL
315                         }
316                 },
317                 {
318                         &hf_dreg_cmd_action_cor2,
319                         {
320                                 "DREG-CMD Action code", "wmx.dreg_cmd.action",
321                                 FT_UINT8, BASE_DEC, VALS(vals_dreg_cmd_action_cor2), 0x07, NULL, HFILL
322                         }
323                 },
324                 {
325                         &hf_dreg_cmd_reserved,
326                         {
327                                 "Reserved", "wmx.dreg_cmd.action_reserved",
328                                 FT_UINT8, BASE_DEC, NULL, 0xF8, NULL, HFILL
329                         }
330                 },
331                 {
332                         &hf_dreg_req_message_type,
333                         {
334                                 "MAC Management Message Type", "wmx.macmgtmsgtype.dreg_req",
335                                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL
336                         }
337                 },
338                 {
339                         &hf_dreg_req_action,
340                         {
341                                 "DREG-REQ Action code", "wmx.dreg_req.action",
342                                 FT_UINT8, BASE_DEC, VALS(vals_dreg_req_code), 0x03, NULL, HFILL
343                         }
344                 },
345                 {
346                         &hf_dreg_req_reserved,
347                         {
348                                 "Reserved", "wmx.dreg_req.action_reserved",
349                                 FT_UINT8, BASE_DEC, NULL, 0xFC, NULL, HFILL
350                         }
351                 },
352                 {
353                         &hf_tlv_value,
354                         {
355                                 "Value", "wmx.dreg.unknown_tlv_value",
356                                 FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL
357                         }
358                 },
359                 {
360                         &hf_ack_type_reserved,
361                         {
362                                 "Reserved", "wmx.ack_type_reserved",
363                                 FT_UINT8, BASE_DEC, NULL, 0x03, NULL, HFILL
364                         }
365                 }
366         };
367
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 */
372                 );
373
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));
376 }
377
378 /* Register Wimax Mac Payload Protocol and Dissector */
379 void proto_register_mac_mgmt_msg_dreg_cmd(void)
380 {
381         proto_mac_mgmt_msg_dreg_cmd_decoder = proto_mac_mgmt_msg_dreg_req_decoder;
382 }
383
384 /* Decode DREG-REQ messages. */
385 void dissect_mac_mgmt_msg_dreg_req_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
386 {
387         guint offset = 0;
388         guint tlv_offset;
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;
393         tlv_info_t tlv_info;
394         gint tlv_type;
395         gint tlv_len;
396         gboolean hmac_found = FALSE;
397
398         /* Ensure the right payload type */
399         payload_type = tvb_get_guint8(tvb, 0);
400         if(payload_type != MAC_MGMT_MSG_DREG_REQ)
401         {
402                 return;
403         }
404
405         if (tree)
406         {       /* we are being asked for details */
407
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);
416                 offset++;
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);
421                 offset++;
422
423                 while(offset < tvb_len)
424                 {
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);
435                                 break;
436                         }
437                         /* get the offset to the TLV data */
438                         tlv_offset = offset + get_tlv_value_offset(&tlv_info);
439
440                         switch (tlv_type) {
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);
445                                         hmac_found = TRUE;
446                                         break;
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);
451                                         break;
452                                 default:
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);
456                                         break;
457                         }
458
459
460                         offset = tlv_len + tlv_offset;
461                 }       /* end of TLV process while loop */
462                 if (!hmac_found)
463                         proto_item_append_text(dreg_req_tree, " (HMAC Tuple is missing !)");
464         }
465 }
466
467 /* Decode DREG-CMD messages. */
468 void dissect_mac_mgmt_msg_dreg_cmd_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
469 {
470         guint offset = 0;
471         guint tlv_offset;
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;
476         tlv_info_t tlv_info;
477         gint tlv_type;
478         gint tlv_len;
479         gboolean hmac_found = FALSE;
480
481         /* Ensure the right payload type */
482         payload_type = tvb_get_guint8(tvb, 0);
483         if(payload_type != MAC_MGMT_MSG_DREG_CMD)
484         {
485                 return;
486         }
487
488         if (tree)
489         {       /* we are being asked for details */
490
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);
499                 offset ++;
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);
503                 else
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);
507                 offset ++;
508
509                 while(offset < tvb_len)
510                 {
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);
521                                 break;
522                         }
523                         /* get the offset to the TLV data */
524                         tlv_offset = offset + get_tlv_value_offset(&tlv_info);
525
526                         switch (tlv_type) {
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);
531                                         hmac_found = TRUE;
532                                         break;
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);
537                                         break;
538                                 default:
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);
542                                         break;
543                         }
544
545                         offset = tlv_len + tlv_offset;
546                 }       /* end of TLV process while loop */
547                 if (!hmac_found)
548                         proto_item_append_text(dreg_cmd_tree, " (HMAC Tuple is missing !)");
549         }
550 }
551