66676a2826c140db9d0895a1e6d9d7a0096dcd0c
[obnox/wireshark/wip.git] / plugins / wimax / wimax_utils.c
1 /* wimax_utils.c
2  * WiMax Utility Decoders
3  *
4  * Copyright (c) 2007 by Intel Corporation.
5  *
6  * Author: Lu Pan <lu.pan@intel.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 /*
30 #define DEBUG
31 */
32
33 #ifdef HAVE_CONFIG_H
34 #include "config.h"
35 #endif
36
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include "wimax_tlv.h"
40 #include "wimax_mac.h"
41
42 #include "wimax_bits.h"
43
44 extern gint proto_mac_mgmt_msg_rng_req_decoder;
45 extern gint proto_mac_mgmt_msg_reg_req_decoder;
46
47 extern gint mac_sdu_length;                   /* declared in packet-wmx.c */
48 extern  gboolean include_cor2_changes;
49
50 /* forward reference */
51 void wimax_service_flow_encodings_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
52 void wimax_error_parameter_set_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
53 void wimax_security_negotiation_parameters_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
54 void wimax_tek_parameters_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
55 void wimax_pkm_configuration_settings_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
56 void wimax_sa_descriptor_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
57 void wimax_pkm_tlv_encoded_attributes_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
58 void wimax_cryptographic_suite_list_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
59 void wimax_security_capabilities_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
60 void wimax_vendor_specific_information_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
61 guint wimax_common_tlv_encoding_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
62
63 static gint proto_wimax_utility_decoders = -1;
64 static gint ett_wimax_service_flow_encodings = -1;
65 static gint ett_wimax_cst_encoding_rules = -1;
66 static gint ett_wimax_error_parameter_set = -1;
67 static gint ett_wimax_hmac_tuple = -1;
68 static gint ett_wimax_cmac_tuple = -1;
69 static gint ett_wimax_short_hmac_tuple = -1;
70 static gint ett_security_negotiation_parameters = -1;
71 static gint ett_pkm_tlv_encoded_attributes_decoder = -1;
72 static gint ett_sa_descriptor_decoder = -1;
73 static gint ett_cryptographic_suite_list_decoder = -1;
74 static gint ett_security_capabilities_decoder = -1;
75 static gint ett_vendor_specific_info_decoder = -1;
76 static gint ett_vendor_id_encoding_decoder = -1;
77 static gint ett_ul_service_flow_decoder = -1;
78 static gint ett_dl_service_flow_decoder = -1;
79
80 static dissector_handle_t eap_handle = NULL;
81
82 /* The following two variables save the Scheduling Service type for
83    the Grant Management subheader dissector and track whether or not
84    one has been seen.
85    */
86 static guint scheduling_service_type = -1;
87 gint seen_a_service_type = 0;
88
89 /* The following two functions set and access the variables above */
90 guint get_service_type( void )
91 {
92         return scheduling_service_type;
93 }
94
95 void set_service_type( guint set_to )
96 {
97         if( seen_a_service_type == 0 ){
98                 scheduling_service_type = set_to;
99                 seen_a_service_type = 1;
100         }
101 }
102
103 /* Setup protocol subtree array */
104 static gint *ett[] =
105 {
106         &ett_wimax_service_flow_encodings,
107         &ett_wimax_cst_encoding_rules,
108         &ett_wimax_error_parameter_set,
109         &ett_wimax_hmac_tuple,
110         &ett_wimax_cmac_tuple,
111         &ett_wimax_short_hmac_tuple,
112         &ett_security_negotiation_parameters,
113         &ett_pkm_tlv_encoded_attributes_decoder,
114         &ett_sa_descriptor_decoder,
115         &ett_cryptographic_suite_list_decoder,
116         &ett_security_capabilities_decoder,
117         &ett_vendor_specific_info_decoder,
118         &ett_vendor_id_encoding_decoder,
119         &ett_ul_service_flow_decoder,
120         &ett_dl_service_flow_decoder,
121 };
122
123 static const value_string vals_mbs_service[] =
124 {
125         {0, "No available MBS"},
126         {1, "Single-BS-MBS"},
127         {2, "Multi-BS-MBS"},
128         {0,  NULL}
129 };
130
131 static const value_string vals_ul_grant_scheduling[] =
132 {
133         {0, "Reserved"},
134         {1, "Undefined (BS implementation-dependent)"},
135         {2, "BE (default)"},
136         {3, "nrtPS"},
137         {4, "rtPS"},
138         {5, "Extended rtPS"},
139         {6, "UGS"},
140         {0,  NULL}
141 };
142
143 static const value_string vals_fixed_len_sdu[] =
144 {
145         {0, "Variable-length SDUs (default)"},
146         {1, "Fixed-length SDUs"},
147         {0,  NULL}
148 };
149
150 static const value_string vals_arq_enable[] =
151 {
152         {0, "ARQ not requested/accepted"},
153         {1, "ARQ requested/accepted"},
154         {0,  NULL}
155 };
156 static const value_string vals_arq_block_lifetime[] =
157 {
158         {0, "Infinite"},
159         {0, NULL}
160 };
161 static const value_string vals_arq_sync_loss_timeout[] =
162 {
163         {0, "Infinite"},
164         {0, NULL}
165 };
166
167 static const value_string vals_arq_deliver_in_order[] =
168 {
169         {0, "Order of delivery is not preserved"},
170         {1, "Order of delivery is preserved"},
171         {0,  NULL}
172 };
173 static const value_string vals_arq_rx_purge_timeout[] =
174 {
175         {0, "Infinite"},
176         {0, NULL}
177 };
178
179 static const value_string vals_fsn_size[] =
180 {
181         {0, "3-bit FSN"},
182         {1, "11-bit FSN (default)"},
183         {0,  NULL}
184 };
185
186 static const value_string vals_sn_fb_enable[] =
187 {
188         {0, "Is disabled (default)"},
189         {1, "Is enabled"},
190         {0,  NULL}
191 };
192
193 static const value_string vals_harq[] =
194 {
195         {0, "Non HARQ (default)"},
196         {1, "HARQ connection" },
197         {0,  NULL}
198 };
199
200 static const value_string vals_cs_specification[] =
201 {
202         {0, "Reserved"},
203         {1, "Packet, IPv4"},
204         {2, "Packet, IPv6"},
205         {3, "Packet, IEEE 802.3/Ethernet"},
206         {4, "Packet, IEEE 802.1Q VLAN"},
207         {5, "Packet, IPv4 over IEEE 802.3/Ethernet"},
208         {6, "Packet, IPv6 over IEEE 802.3/Ethernet"},
209         {7, "Packet, IPv4 over IEEE 802.1Q VLAN"},
210         {8, "Packet, IPv6 over IEEE 802.1Q VLAN"},
211         {9, "ATM"},
212         {10, "Packet, IEEE 802.3/Ethernet with ROCH header compression"},
213         {11, "Packet, IEEE 802.3/Ethernet with ECRTP header compression"},
214         {12, "Packet, IP2 with ROCH header compression"},
215         {13, "Packet, IP2 with ECRTP header compression"},
216         {0, NULL}
217 };
218
219 static const value_string vals_type_of_data_delivery_services[] =
220 {
221         {0, "Continuing grant service"},
222         {1, "Real time variable rate service"},
223         {2, "Non-real time variable rate service"},
224         {3, "Best-efforts service"},
225         {4, "Extended real-time variable rate service"},
226         {0,  NULL}
227 };
228
229 static const value_string vals_paging_preference[] =
230 {
231         {0, "No paging generation"},
232         {1, "Paging generation"},
233         {0,  NULL}
234 };
235 static const value_string vals_pdu_sn_ext_subheader[] =
236 {
237         {0, "No support for PDU SN in this connection (default)"},
238         {1, "PDU SN (short) extended Subheader"},
239         {2, "PDU SN (long) extended Subheader"},
240         {0,  NULL}
241 };
242
243 static const value_string vals_cst_classifier_action[] =
244 {
245         {0, "DSC Add Classifier"},
246         {1, "DSC Replace Classifier"},
247         {2, "DSC Delete Classifier"},
248         {0,  NULL}
249 };
250
251 static const value_string vals_cst_phs_dsc_action[] =
252 {
253         {0, "Add PHS rule"},
254         {1, "Set PHS rule"},
255         {2, "Delete PHS rule"},
256         {3, "Delete all PHS rules"},
257         {0,  NULL}
258 };
259
260 static const value_string vals_verify[] =
261 {
262         {0, "Verify"},
263         {1, "Don't verify"},
264         {0,  NULL}
265 };
266
267 static const value_string vals_atm_switching_encodings[] =
268 {
269         {0, "No switching methodology applied"},
270         {1, "VP switching"},
271         {2, "VC switching"},
272         {0,  NULL}
273 };
274
275 static const value_string vals_cc[] =
276 {
277         {0, "OK/success"},
278         {1, "Reject-other"},
279         {2, "Reject-unrecognized-configuration-setting"},
280         {3, "Reject-temporary / reject-resource"},
281         {4, "Reject-permanent / reject-admin"},
282         {5, "Reject-not-owner"},
283         {6, "Reject-service-flow-not-found"},
284         {7, "Reject-service-flow-exists"},
285         {8, "Reject-required-parameter-not-present"},
286         {9, "Reject-header-suppression"},
287         {10, "Reject-unknown-transaction-id"},
288         {11, "Reject-authentication-failure"},
289         {12, "Reject-add-aborted"},
290         {13, "Reject-exceeded-dynamic-service-limit"},
291         {14, "Reject-not-authorized-for-the-request-SAID"},
292         {15, "Reject-fail-to-establish-the-requested-SA"},
293         {16, "Reject-not-supported-parameter"},
294         {17, "Reject-not-supported-parameter-value"},
295         {0,  NULL}
296 };
297
298 static const value_string vals_classification_action_rule[] =
299 {
300         {0, "None"},
301         {1, "Discarded packet"},
302         {0,  NULL}
303 };
304
305 static const true_false_string tfs_supported =
306 {
307     "supported",
308     "not supported"
309 };
310
311 static const true_false_string disabled_enabled =
312 {
313         "enabled",
314         "disabled"
315 };
316
317 static const true_false_string default_enabled =
318 {
319         "enabled",
320         "use default action"
321 };
322
323 static const value_string vals_pkm_attr_error_codes[] =
324 {       /* table 373 */
325         {0, "All (no information)"},
326         {1, "Auth Reject Auth Invalid (unauthorized SS)"},
327         {2, "Auth Reject, Key Reject (unauthorized SAID)"},
328         {3, "Auth Invalid (unsolicited)"},
329         {4, "Auth Invalid, TEK Invalid (invalid key sequence number)"},
330         {5, "Auth Invalid (message (key request) authorization failure)"},
331         {6, "Auth Reject (permanent authorization failure)"},
332         {0,  NULL}
333 };
334
335 static const value_string vs_sa_type[] =
336 {
337         {0, "Primary"},
338         {1, "Static"},
339         {2, "Dynamic"},
340         {0,  NULL}
341 };
342
343 static const value_string va_key_push_modes[] =
344 {
345         {0, "GKEK update mode"},
346         {1, "GTEK update mode"},
347         {0,  NULL}
348 };
349
350 static const value_string vals_pkm_version[] =
351 {
352         {0, "Reserved"},
353         {1, "PKM (Initial standard release"},
354         {0,  NULL}
355 };
356
357 static const value_string vs_success_reject[] =
358 {
359         {0, "Success"},
360         {1, "Reject"},
361         {0,  NULL}
362 };
363
364 static const value_string vs_sa_service_type[] =
365 {
366         {0, "Unicast service"},
367         {1, "Group multicast service"},
368         {2, "MBS service"},
369         {0,  NULL}
370 };
371
372 static const value_string vals_data_encryption_ids[] =
373 {       /* table 375 */
374         {0, "No data encryption"},
375         {1, "CBC-Mode, 56-bit DES"},
376         {2, "CCM-Mode, 128-bit AES"},
377         {3, "CBC-Mode, 128-bit AES"},
378         {128, "CTR-Mode, 128-bit AES for MBS with 8 bit ROC"},
379         {0,  NULL}
380 };
381
382 static const value_string vals_data_authentication_ids[] =
383 {       /* table 376 */
384         {0, "No data authentication"},
385         {1, "CCM-Mode, 128-bit AES"},
386         {0,  NULL}
387 };
388
389 static const value_string vals_tek_encryption_ids[] =
390 {       /* table 377 */
391         {0, "No TEK encryption"},
392         {1, "3-DES EDE with 128-bit key"},
393         {2, "RSA with 1024-bit key"},
394         {3, "ECB mode AES with 128-bit key"},
395         {4, "AES key wrap with 128-bit key"},
396         {0,  NULL}
397 };
398
399 static const value_string vals_dcd_mac_version[] =
400 {
401     {1, "Conformance with IEEE Std 802.16-2001"},
402     {2, "Conformance with IEEE Std 802.16c-2002 and its predecessors"},
403     {3, "Conformance with IEEE Std 802.16a-2003 and its predecessors"},
404     {4, "Conformance with IEEE Std 802.16-2004"},
405     {5, "Conformance with IEEE Std 802.16-2004 and IEEE Std 802.16e-2005"},
406     {6, "reserved"},
407     {0, NULL}
408 };
409
410 /* fix fields */
411 static gint hf_sfe_unknown_type = -1;
412 static gint hf_sfe_sf_id = -1;
413 static gint hf_sfe_cid = -1;
414 static gint hf_sfe_service_class_name = -1;
415 static gint hf_sfe_mbs_service = -1;
416 static gint hf_sfe_qos_params_set = -1;
417 static gint hf_sfe_set_provisioned = -1;
418 static gint hf_sfe_set_admitted = -1;
419 static gint hf_sfe_set_active = -1;
420 static gint hf_sfe_set_rsvd = -1;
421 static gint hf_sfe_traffic_priority = -1;
422 static gint hf_sfe_max_str = -1;
423 static gint hf_sfe_max_traffic_burst = -1;
424 static gint hf_sfe_min_rtr = -1;
425 static gint hf_sfe_reserved_10 = -1;
426 static gint hf_sfe_ul_grant_scheduling = -1;
427 static gint hf_sfe_req_tx_policy = -1;
428 static gint hf_sfe_policy_broadcast_bwr = -1;
429 static gint hf_sfe_policy_multicast_bwr = -1;
430 static gint hf_sfe_policy_piggyback = -1;
431 static gint hf_sfe_policy_fragment = -1;
432 static gint hf_sfe_policy_headers = -1;
433 static gint hf_sfe_policy_packing = -1;
434 static gint hf_sfe_policy_crc = -1;
435 static gint hf_sfe_policy_rsvd1 = -1;
436 static gint hf_sfe_jitter = -1;
437 static gint hf_sfe_max_latency = -1;
438 static gint hf_sfe_fixed_len_sdu = -1;
439 static gint hf_sfe_sdu_size = -1;
440 static gint hf_sfe_target_said = -1;
441 static gint hf_sfe_cs_specification = -1;
442 static gint hf_sfe_type_of_data_delivery_services = -1;
443 static gint hf_sfe_sdu_inter_arrival_interval = -1;
444 static gint hf_sfe_time_base = -1;
445 static gint hf_sfe_paging_preference = -1;
446 static gint hf_sfe_mbs_zone_identifier_assignment = -1;
447 static gint hf_sfe_sn_feedback_enabled = -1;
448 static gint hf_sfe_harq_service_flows = -1;
449 static gint hf_sfe_harq_channel_mapping_index = -1;
450 static gint hf_sfe_fsn_size = -1;
451 static gint hf_sfe_unsolicited_grant_interval = -1;
452 static gint hf_sfe_unsolicited_polling_interval = -1;
453 static gint hf_sfe_harq_channel_mapping = -1;
454 static gint hf_sfe_global_service_class_name = -1;
455 static gint hf_sfe_reserved_36 = -1;
456 static gint hf_sfe_reserved_34 = -1;
457
458 static gint hf_sfe_arq_enable = -1;
459 static gint hf_sfe_arq_transmitter_delay = -1;
460 static gint hf_sfe_arq_receiver_delay = -1;
461 static gint hf_sfe_arq_block_lifetime = -1;
462 static gint hf_sfe_arq_sync_loss_timeout = -1;
463 static gint hf_sfe_arq_transmitter_delay_cor2 = -1;
464 static gint hf_sfe_arq_receiver_delay_cor2 = -1;
465 static gint hf_sfe_arq_block_lifetime_cor2 = -1;
466 static gint hf_sfe_arq_sync_loss_timeout_cor2 = -1;
467 static gint hf_sfe_arq_deliver_in_order = -1;
468 static gint hf_sfe_arq_rx_purge_timeout = -1;
469 static gint hf_sfe_arq_window_size = -1;
470 static gint hf_sfe_arq_block_size = -1;
471 static gint hf_sfe_arq_block_size_cor2 = -1;
472 static gint hf_sfe_arq_min_block_size = -1;
473 static gint hf_sfe_arq_max_block_size = -1;
474
475 static gint hf_sfe_cid_alloc_for_active_bs = -1;
476 static gint hf_sfe_cid_alloc_for_active_bs_cid = -1;
477 static gint hf_sfe_pdu_sn_ext_subheader_reorder = -1;
478 static gint hf_sfe_mbs_contents_ids = -1;
479 static gint hf_sfe_mbs_contents_ids_id = -1;
480 static gint hf_sfe_authorization_token = -1;
481
482 static gint hf_cst_classifier_dsc_action = -1;
483 static gint hf_cst_error_set_errored_param = -1;
484 static gint hf_cst_error_set_error_code = -1;
485 static gint hf_cst_error_set_error_msg = -1;
486
487 static gint hf_cst_pkt_class_rule = -1;
488
489 static gint hf_cst_pkt_class_rule_priority = -1;
490 static gint hf_cst_pkt_class_rule_range_mask = -1;
491 static gint hf_cst_pkt_class_rule_tos_low = -1;
492 static gint hf_cst_pkt_class_rule_tos_high = -1;
493 static gint hf_cst_pkt_class_rule_tos_mask = -1;
494 static gint hf_cst_pkt_class_rule_protocol = -1;
495 /*static gint hf_cst_pkt_class_rule_protocol_number = -1;*/
496 static gint hf_cst_pkt_class_rule_ip_masked_src_address = -1;
497 static gint hf_cst_pkt_class_rule_ip_masked_dest_address = -1;
498 static gint hf_cst_pkt_class_rule_src_ipv4 = -1;
499 static gint hf_cst_pkt_class_rule_dest_ipv4 = -1;
500 static gint hf_cst_pkt_class_rule_mask_ipv4 = -1;
501 static gint hf_cst_pkt_class_rule_src_ipv6 = -1;
502 static gint hf_cst_pkt_class_rule_dest_ipv6 = -1;
503 static gint hf_cst_pkt_class_rule_mask_ipv6 = -1;
504 static gint hf_cst_pkt_class_rule_prot_src_port_range = -1;
505 static gint hf_cst_pkt_class_rule_src_port_low = -1;
506 static gint hf_cst_pkt_class_rule_src_port_high = -1;
507 static gint hf_cst_pkt_class_rule_prot_dest_port_range = -1;
508 static gint hf_cst_pkt_class_rule_dest_port_low = -1;
509 static gint hf_cst_pkt_class_rule_dest_port_high = -1;
510 static gint hf_cst_pkt_class_rule_dest_mac_address = -1;
511 static gint hf_cst_pkt_class_rule_dest_mac = -1;
512 static gint hf_cst_pkt_class_rule_src_mac_address = -1;
513 static gint hf_cst_pkt_class_rule_src_mac = -1;
514 static gint hf_cst_pkt_class_rule_mask_mac = -1;
515 static gint hf_cst_pkt_class_rule_ethertype = -1;
516 static gint hf_cst_pkt_class_rule_etype = -1;
517 static gint hf_cst_pkt_class_rule_eprot1 = -1;
518 static gint hf_cst_pkt_class_rule_eprot2 = -1;
519 static gint hf_cst_pkt_class_rule_user_priority          = -1;
520 static gint hf_cst_pkt_class_rule_pri_low                = -1;
521 static gint hf_cst_pkt_class_rule_pri_high               = -1;
522 static gint hf_cst_pkt_class_rule_vlan_id                = -1;
523 static gint hf_cst_pkt_class_rule_vlan_id1               = -1;
524 static gint hf_cst_pkt_class_rule_vlan_id2               = -1;
525 static gint hf_cst_pkt_class_rule_phsi                   = -1;
526 static gint hf_cst_pkt_class_rule_index                  = -1;
527 static gint hf_cst_pkt_class_rule_ipv6_flow_label        = -1;
528 static gint hf_cst_pkt_class_rule_vendor_spec            = -1;
529 static gint hf_cst_pkt_class_rule_classifier_action_rule = -1;
530 static gint hf_cst_pkt_class_rule_classifier_action_rule_bit0 = -1;
531 static gint hf_cst_pkt_class_rule_classifier_action_rule_bit1 = -1;
532
533 static gint hf_cst_large_context_id = -1;
534 static gint hf_cst_short_format_context_id = -1;
535
536 static gint hf_cst_phs_dsc_action = -1;
537 static gint hf_cst_phs_rule = -1;
538 static gint hf_cst_phs_phsi = -1;
539 static gint hf_cst_phs_phsf = -1;
540 static gint hf_cst_phs_phsm = -1;
541 static gint hf_cst_phs_phss = -1;
542 static gint hf_cst_phs_phsv = -1;
543 static gint hf_cst_phs_vendor_spec = -1;
544 static gint hf_cst_invalid_tlv = -1;
545
546 static gint hf_csper_atm_switching_encoding = -1;
547 static gint hf_csper_atm_classifier = -1;
548 static gint hf_csper_atm_classifier_vpi = -1;
549 static gint hf_csper_atm_classifier_vci = -1;
550 static gint hf_csper_atm_classifier_id = -1;
551 /*static gint hf_csper_atm_classifier_dsc_action = -1;*/
552 static gint hf_csper_unknown_type = -1;
553
554 static gint hf_xmac_tuple_rsvd = -1;
555 static gint hf_xmac_tuple_key_seq_num = -1;
556 static gint hf_hmac_tuple_hmac_digest = -1;
557 static gint hf_packet_number_counter = -1;
558 static gint hf_cmac_tuple_cmac_value = -1;
559 static gint hf_cmac_tuple_bsid = -1;
560
561 /* bit masks */
562 /* 11.13.4 */
563 #define SFE_QOS_PARAMS_SET_PROVISIONED_SET 0x01
564 #define SFE_QOS_PARAMS_SET_ADMITTED_SET    0x02
565 #define SFE_QOS_PARAMS_SET_ACTIVE_SET      0x04
566 #define SFE_QOS_PARAMS_SET_RESERVED        0xF8
567 /* 11.13.12 */
568 #define SFE_REQ_TX_POLICY_BROADCAST_BWR    0x01
569 #define SFE_REQ_TX_POLICY_MULTICAST_BWR    0x02
570 #define SFE_REQ_TX_POLICY_PIGGYBACK        0x04
571 #define SFE_REQ_TX_POLICY_FRAGMENT_DATA    0x08
572 #define SFE_REQ_TX_POLICY_PAYLOAD_HEADER   0x10
573 #define SFE_REQ_TX_POLICY_PACKINGS         0x20
574 #define SFE_REQ_TX_POLICY_CRC              0x40
575 #define SFE_REQ_TX_POLICY_RESERVED         0x80
576
577 /* bit masks */
578 /* 11.13.19.3.4.17 */
579 #define CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_BIT0 0x80
580 #define CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_RSV  0x7F
581
582 /* bit masks */
583 /* 11.1.2 (table 348) */
584 #define XMAC_TUPLE_RESERVED        0xF0
585 #define XMAC_TUPLE_KEY_SEQ_NUM     0x0F
586
587 /* WiMax Security Negotiation Parameters display */
588 static gint hf_snp_pkm_version_support = -1;
589 static gint hf_snp_pkm_version_support_bit0 = -1;
590 static gint hf_snp_pkm_version_support_bit1 = -1;
591 static gint hf_snp_pkm_version_support_reserved = -1;
592 static gint hf_snp_auth_policy_support = -1;
593 static gint hf_snp_auth_policy_support_bit0 = -1;
594 static gint hf_snp_auth_policy_support_bit1 = -1;
595 static gint hf_snp_auth_policy_support_bit2 = -1;
596 static gint hf_snp_auth_policy_support_bit3 = -1;
597 static gint hf_snp_auth_policy_support_bit4 = -1;
598 static gint hf_snp_auth_policy_support_bit5 = -1;
599 static gint hf_snp_auth_policy_support_bit6 = -1;
600 static gint hf_snp_auth_policy_support_bit7 = -1;
601 static gint hf_snp_mac_mode = -1;
602 static gint hf_snp_mac_mode_bit0 = -1;
603 static gint hf_snp_mac_mode_bit1 = -1;
604 static gint hf_snp_mac_mode_bit1_rsvd = -1;
605 static gint hf_snp_mac_mode_bit2 = -1;
606 static gint hf_snp_mac_mode_bit3 = -1;
607 static gint hf_snp_mac_mode_bit4 = -1;
608 static gint hf_snp_mac_mode_bit5 = -1;
609 static gint hf_snp_mac_mode_reserved = -1;
610 static gint hf_snp_mac_mode_reserved1 = -1;
611 static gint hf_snp_pn_window_size = -1;
612 static gint hf_snp_max_conc_transactions = -1;
613 static gint hf_snp_max_suppt_sec_assns = -1;
614 static gint hf_snp_unknown_type = -1;
615
616 /* bit masks */
617 /* 11.8.4.1 */
618 #define SNP_PKM_VERSION_SUPPORT_BIT0 0x01
619 #define SNP_PKM_VERSION_SUPPORT_BIT1 0x02
620 #define SNP_PKM_VERSION_SUPPORT_RSV  0xFC
621 /* 11.8.4.2 */
622 #define SNP_AUTH_POLICY_SUPPORT_BIT0 0x01
623 #define SNP_AUTH_POLICY_SUPPORT_BIT1 0x02
624 #define SNP_AUTH_POLICY_SUPPORT_BIT2 0x04
625 #define SNP_AUTH_POLICY_SUPPORT_BIT3 0x08
626 #define SNP_AUTH_POLICY_SUPPORT_BIT4 0x10
627 #define SNP_AUTH_POLICY_SUPPORT_BIT5 0x20
628 #define SNP_AUTH_POLICY_SUPPORT_BIT6 0x40
629 #define SNP_AUTH_POLICY_SUPPORT_BIT7 0x80
630 /* 11.8.4.3 */
631 #define SNP_MAC_MODE_BIT0 0x01
632 #define SNP_MAC_MODE_BIT1 0x02
633 #define SNP_MAC_MODE_BIT2 0x04
634 #define SNP_MAC_MODE_BIT3 0x08
635 #define SNP_MAC_MODE_BIT4 0x10
636 #define SNP_MAC_MODE_BIT5 0x20
637 #define SNP_MAC_MODE_RSV  0xE0
638 #define SNP_MAC_MODE_RSV1 0xC0
639
640 /* PKM display */
641 static gint hf_pkm_msg_unknown_type = -1;
642 static gint hf_pkm_msg_attr_display = -1;
643 static gint hf_pkm_config_settings_authorize_waitout = -1;
644 static gint hf_pkm_config_settings_reauthorize_waitout = -1;
645 static gint hf_pkm_config_settings_grace_time = -1;
646 static gint hf_pkm_config_settings_operational_waittime = -1;
647 static gint hf_pkm_msg_attr_auth_key = -1;
648 static gint hf_pkm_msg_attr_tek = -1;
649 static gint hf_pkm_msg_attr_key_life_time = -1;
650 static gint hf_pkm_msg_attr_key_seq_num = -1;
651 static gint hf_pkm_msg_attr_hmac_digest = -1;
652 static gint hf_pkm_msg_attr_said = -1;
653 static gint hf_pkm_msg_attr_cbc_iv = -1;
654 static gint hf_pkm_msg_attr_error_code = -1;
655 static gint hf_pkm_msg_attr_ca_certificate = -1;
656 static gint hf_pkm_msg_attr_ss_certificate = -1;
657 static gint hf_pkm_attr_auth_result_code = -1;
658 static gint hf_pkm_attr_sa_service_type = -1;
659 static gint hf_pkm_attr_frame_number = -1;
660 static gint hf_pkm_attr_ss_random = -1;
661 static gint hf_pkm_attr_bs_random = -1;
662 static gint hf_pkm_attr_pre_pak = -1;
663 static gint hf_pkm_attr_bs_certificate = -1;
664 static gint hf_pkm_attr_sig_bs = -1;
665 static gint hf_pkm_attr_ms_mac_address = -1;
666 static gint hf_pkm_attr_cmac_digest = -1;
667 static gint hf_pkm_attr_cmac_digest_pn = -1;
668 static gint hf_pkm_attr_cmac_digest_value = -1;
669 static gint hf_pkm_attr_eap_payload = -1;
670 static gint hf_pkm_attr_nonce = -1;
671 static gint hf_pkm_sa_type = -1;
672 static gint hf_pkm_msg_crypto_suite = -1;
673 static gint hf_pkm_msg_crypto_suite_msb = -1;
674 static gint hf_pkm_msg_crypto_suite_middle = -1;
675 static gint hf_pkm_msg_crypto_suite_lsb = -1;
676 /*static gint hf_pkm_msg_version = -1;*/
677 static gint hf_pkm_attr_push_modes = -1;
678 static gint hf_pkm_attr_key_push_counter = -1;
679 static gint hf_pkm_attr_gkek = -1;
680 static gint hf_pkm_attr_sig_ss = -1;
681 static gint hf_pkm_attr_akid = -1;
682 static gint hf_pkm_config_settings_rekey_wait_timeout = -1;
683 static gint hf_pkm_config_settings_tek_grace_time = -1;
684 static gint hf_pkm_config_settings_authorize_reject_wait_timeout = -1;
685
686 static gint hf_pkm_attr_pak_ak_seq_number = -1;
687 static gint hf_pkm_attr_associated_gkek_seq_number = -1;
688 static gint hf_pkm_attr_gkek_params = -1;
689
690 static gint hf_common_tlv_unknown_type = -1;
691 static gint hf_common_tlv_mac_version = -1;
692 static gint hf_common_tlv_vendor_id = -1;
693 static gint hf_common_tlv_vendor_specific_type = -1;
694 static gint hf_common_tlv_vendor_specific_length = -1;
695 static gint hf_common_tlv_vendor_specific_length_size = -1;
696 static gint hf_common_tlv_vendor_specific_value = -1;
697
698 /* Register WiMax Utility Routines */
699 void proto_register_wimax_utility_decoders(void)
700 {
701         /* WiMax Service Flow Encodings display */
702         static hf_register_info hf_sfe[] =
703         {
704                 {       /* 1 Service Flow ID */
705                         &hf_sfe_sf_id,
706                         {"Service Flow ID", "wmx.sfe.sf_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
707                 },
708                 {       /* 2 CID */
709                         &hf_sfe_cid,
710                         {"CID", "wmx.sfe.cid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
711                 },
712                 {       /* 3 Service Class Name */
713                         &hf_sfe_service_class_name,
714                         {"Service Class Name", "wmx.sfe.service_class_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
715                 },
716                 {       /* 4 MBS Service */
717                         &hf_sfe_mbs_service,
718                         {"MBS Service", "wmx.sfe.mbs_service", FT_UINT8, BASE_DEC, VALS(vals_mbs_service), 0x0, NULL, HFILL}
719                 },
720                 {       /* 5 QoS Parameter Set Type */
721                         &hf_sfe_qos_params_set,
722                         {"QoS Parameter Set Type", "wmx.sfe.qos_params_set", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
723                 },
724                 {       /* 5.1 */
725                         &hf_sfe_set_provisioned,
726                         {"Provisioned Set", "wmx.sfe.qos_params_set.provisioned", FT_BOOLEAN, 8, NULL, SFE_QOS_PARAMS_SET_PROVISIONED_SET, NULL, HFILL}
727                 },
728                 {       /* 5.2 */
729                         &hf_sfe_set_admitted,
730                         {"Admitted Set", "wmx.sfe.qos_params_set.admitted", FT_BOOLEAN, 8, NULL, SFE_QOS_PARAMS_SET_ADMITTED_SET, NULL, HFILL}
731                 },
732                 {       /* 5.3 */
733                         &hf_sfe_set_active,
734                         {"Active Set", "wmx.sfe.qos_params_set.active", FT_BOOLEAN, 8, NULL, SFE_QOS_PARAMS_SET_ACTIVE_SET, NULL, HFILL}
735                 },
736                 {       /* 5.4 */
737                         &hf_sfe_set_rsvd,
738                         {"Reserved", "wmx.sfe.qos_params_set.rsvd", FT_UINT8, BASE_HEX, NULL, SFE_QOS_PARAMS_SET_RESERVED, NULL, HFILL}
739                 },
740                 {       /* 6 Traffic Priority */
741                         &hf_sfe_traffic_priority,
742                         {"Traffic Priority", "wmx.sfe.traffic_priority", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
743                 },
744                 {       /* 7 Maximum Sustained Traffic Rate */
745                         &hf_sfe_max_str,
746                         {"Maximum Sustained Traffic Rate", "wmx.sfe.msr", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
747                 },
748                 {       /* 8 Maximum Traffic Burst */
749                         &hf_sfe_max_traffic_burst,
750                         {"Maximum Traffic Burst", "wmx.sfe.max_traffic_burst", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
751                 },
752                 {       /* 9 Minimum Reserved Traffic Rate */
753                         &hf_sfe_min_rtr,
754                         {"Minimum Reserved Traffic Rate", "wmx.sfe.mrr", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
755                 },
756                 {
757                         /* 10 Reserved */
758                         &hf_sfe_reserved_10,
759                         {"Reserved", "wmx.sfe.reserved_10", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
760                 },
761 #if 0
762                 {       /* 10 reserved by 16E */
763                         &hf_sfe_mtr,
764                         {"Minimum tolerable traffic rate", "wmx.sfe.mtr", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}
765                 },
766 #endif
767                 {       /* 11 Service Flow Scheduling Type */
768                         &hf_sfe_ul_grant_scheduling,
769                         {"Uplink Grant Scheduling Type", "wmx.sfe.uplink_grant_scheduling", FT_UINT8, BASE_DEC, VALS(vals_ul_grant_scheduling), 0x0, NULL, HFILL}
770                 },
771                 {       /* 12 Request/Transmission Policy */
772                         &hf_sfe_req_tx_policy,
773                         {"Request/Transmission Policy", "wmx.sfe.req_tx_policy", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
774                 },
775                 {       /* 12.1 */
776                         &hf_sfe_policy_broadcast_bwr,
777                         {"The Service Flow Shall Not Use Broadcast Bandwidth Request Opportunities", "wmx.sfe.policy.broadcast_bwr", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_BROADCAST_BWR, NULL, HFILL}
778                 },
779                 {       /* 12.2 */
780                         &hf_sfe_policy_multicast_bwr,
781                         {"The Service Flow Shall Not Use Multicast Bandwidth Request Opportunities", "wmx.sfe.policy.bit1", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_MULTICAST_BWR, NULL, HFILL}
782                 },
783                 {       /* 12.3 */
784                         &hf_sfe_policy_piggyback,
785                         {"The Service Flow Shall Not Piggyback Requests With Data", "wmx.sfe.policy.piggyback", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_PIGGYBACK, NULL, HFILL}
786                 },
787                 {       /* 12.4 */
788                         &hf_sfe_policy_fragment,
789                         {"The Service Flow Shall Not Fragment Data", "wmx.sfe.policy.fragment", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_FRAGMENT_DATA, NULL, HFILL}
790                 },
791                 {       /* 12.5 */
792                         &hf_sfe_policy_headers,
793                         {"The Service Flow Shall Not Suppress Payload Headers", "wmx.sfe.policy.headers", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_PAYLOAD_HEADER, NULL, HFILL}
794                 },
795                 {       /* 12.6 */
796                         &hf_sfe_policy_packing,
797                         {"The Service Flow Shall Not Pack Multiple SDUs (Or Fragments) Into Single MAC PDUs", "wmx.sfe.policy.packing", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_PACKINGS, NULL, HFILL}
798                 },
799                 {       /* 12.7 */
800                         &hf_sfe_policy_crc,
801                         {"The Service Flow Shall Not Include CRC In The MAC PDU", "wmx.sfe.policy.crc", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_CRC, NULL, HFILL}
802                 },
803                 {       /* 12.8 */
804                         &hf_sfe_policy_rsvd1,
805                         {"Reserved", "wmx.sfe.policy.rsvd1", FT_UINT8, BASE_HEX, NULL, SFE_REQ_TX_POLICY_RESERVED, NULL, HFILL}
806                 },
807                 {       /* 13 Tolerated Jitter */
808                         &hf_sfe_jitter,
809                         {"Tolerated Jitter", "wmx.sfe.jitter", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
810                 },
811                 {       /* 14 Maximum Latency */
812                         &hf_sfe_max_latency,
813                         {"Maximum Latency", "wmx.sfe.max_latency", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
814                 },
815                 {       /* 15 Fixed/Variable Length SDU */
816                         &hf_sfe_fixed_len_sdu,
817                         {"Fixed/Variable Length SDU", "wmx.sfe.fixed_len_sdu", FT_UINT8, BASE_DEC, VALS(vals_fixed_len_sdu), 0x0, NULL, HFILL}
818                 },
819                 {       /* 16 SDU Size */
820                         &hf_sfe_sdu_size,
821                         {"SDU Size", "wmx.sfe.sdu_size", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
822                 },
823                 {       /* 17 SAID Onto Which SF Is Mapped */
824                         &hf_sfe_target_said,
825                         {"SAID Onto Which SF Is Mapped", "wmx.sfe.target_said", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
826                 },
827                 {       /* 18 ARQ Enable */
828                         &hf_sfe_arq_enable,
829                         {"ARQ Enable", "wmx.arq.enable", FT_UINT8, BASE_DEC, VALS(vals_arq_enable), 0x0, NULL, HFILL}
830                 },
831                 {       /* 19 ARQ Window Size */
832                         &hf_sfe_arq_window_size,
833                         {"ARQ Window Size", "wmx.arq.window_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
834                 },
835                 {       /* 20 ARQ Transmitter Delay */
836                         &hf_sfe_arq_transmitter_delay,
837                         {"ARQ Transmitter Delay (10us granularity)", "wmx.arq.transmitter_delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
838                 },
839                 {       /* 21 ARQ Receiver Delay */
840                         &hf_sfe_arq_receiver_delay,
841                         {"ARQ Receiver Delay (10us granularity)", "wmx.arq.receiver_delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
842                 },
843                 {       /* 22 ARQ Block Lifetime */
844                         &hf_sfe_arq_block_lifetime,
845                         {"ARQ Block Lifetime (10us granularity)", "wmx.arq.block_lifetime", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
846                 },
847                 {       /* 23 ARQ Sync Loss Timeout */
848                         &hf_sfe_arq_sync_loss_timeout,
849                         {"ARQ Sync Loss Timeout (10us granularity)", "wmx.arq.sync_loss_timeout", FT_UINT16, BASE_DEC, VALS(&vals_arq_sync_loss_timeout), 0x0, NULL, HFILL}
850                 },
851                 {       /* 20 ARQ Transmitter Delay */
852                         &hf_sfe_arq_transmitter_delay_cor2,
853                         {"ARQ Transmitter Delay (100us granularity)", "wmx.arq.transmitter_delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
854                 },
855                 {       /* 21 ARQ Receiver Delay */
856                         &hf_sfe_arq_receiver_delay_cor2,
857                         {"ARQ Receiver Delay (100us granularity)", "wmx.arq.receiver_delay", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
858                 },
859                 {       /* 22 ARQ Block Lifetime */
860                         &hf_sfe_arq_block_lifetime_cor2,
861                         {"ARQ Block Lifetime (100us granularity)", "wmx.arq.block_lifetime", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
862                 },
863                 {       /* 23 ARQ Sync Loss Timeout */
864                         &hf_sfe_arq_sync_loss_timeout_cor2,
865                         {"ARQ Sync Loss Timeout (100us granularity)", "wmx.arq.sync_loss_timeout", FT_UINT16, BASE_DEC, VALS(&vals_arq_sync_loss_timeout), 0x0, NULL, HFILL}
866                 },
867                 {       /* 24 ARQ Deliver In Order */
868                         &hf_sfe_arq_deliver_in_order,
869                         {"ARQ Deliver In Order", "wmx.arq.deliver_in_order", FT_UINT8, BASE_DEC, VALS(&vals_arq_deliver_in_order), 0x0, NULL, HFILL}
870                 },
871                 {       /* 25 ARQ Purge Timeout */
872                         &hf_sfe_arq_rx_purge_timeout,
873                         {"ARQ RX Purge Timeout (100us granularity)", "wmx.arq.rx_purge_timeout", FT_UINT16, BASE_DEC, VALS(&vals_arq_rx_purge_timeout), 0x0, NULL, HFILL}
874                 },
875                 {       /* 26 ARQ Block Size */
876                         &hf_sfe_arq_block_size,
877                         {"ARQ Block Size", "wmx.arq.block_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
878                 },
879                 {       /* 26 ARQ Block Size */
880                         &hf_sfe_arq_block_size_cor2,
881                         {"ARQ Block Size", "wmx.arq.block_size", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
882                 },
883                 {       /* 26 ARQ Block Size for Corrigendum 2 */
884                         &hf_sfe_arq_min_block_size,
885                         {"ARQ Minimum Block Size", "wmx.arq.min_block_size", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}
886                 },
887                 {       /* 26 ARQ Block Size for Corrigendum 2 */
888                         &hf_sfe_arq_max_block_size,
889                         {"ARQ Maximum Block Size", "wmx.arq.max_block_size", FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}
890                 },
891         /* 27 reserved */
892                 {       /* 28 CS Specification */
893                         &hf_sfe_cs_specification,
894                         {"CS Specification", "wmx.sfe.cs_specification", FT_UINT8, BASE_DEC, VALS(vals_cs_specification), 0x0, NULL, HFILL}
895                 },
896                         {       /* 29 Type of Data Delivery Services */
897                         &hf_sfe_type_of_data_delivery_services,
898                         {"Type of Data Delivery Services", "wmx.sfe.type_of_data_delivery_services", FT_UINT8, BASE_DEC, VALS(vals_type_of_data_delivery_services), 0x0, NULL, HFILL}
899                 },
900                         {       /* 30 SDU Inter-Arrival Interval */
901                         &hf_sfe_sdu_inter_arrival_interval,
902                         {"SDU Inter-Arrival Interval (in the resolution of 0.5 ms)", "wmx.sfe.sdu_inter_arrival_interval", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
903                 },
904                         {       /* 31 Time Base */
905                         &hf_sfe_time_base,
906                         {"Time Base", "wmx.sfe.time_base", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
907                 },
908                         {       /* 32 Paging Preference */
909                         &hf_sfe_paging_preference,
910                         {"Paging Preference", "wmx.sfe.paging_preference", FT_UINT8, BASE_DEC, VALS(vals_paging_preference), 0x0, NULL, HFILL}
911                 },
912                         {       /* 33 MBS Zone Identifier */
913                         &hf_sfe_mbs_zone_identifier_assignment,
914                         {"MBS Zone Identifier", "wmx.sfe.mbs_zone_identifier", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
915                 },
916                         {       /* 34 Traffic Indication Preference */
917                         &hf_sfe_reserved_34,
918                         {"Reserved", "wmx.sfe.reserved_34", FT_UINT8, BASE_DEC, NULL /*VALS(vals_traffic_indication_preference)*/, 0x0, NULL, HFILL}
919                 },
920                 {       /* 35 Global Service Class Name */
921                         &hf_sfe_global_service_class_name,
922                         {"Global Service Class Name", "wmx.sfe.global_service_class_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
923                 },
924         /* 36 reserved by 16E */
925                         /* 36 Reserved */
926                 {
927                         &hf_sfe_reserved_36,
928                         {"Reserved", "wmx.sfe.reserved_36", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
929                 },
930                         {       /* 37 SN Feedback Enable */
931                         &hf_sfe_sn_feedback_enabled,
932                         {"SN Feedback", "wmx.sfe.sn_feedback_enabled", FT_UINT8, BASE_DEC, VALS(vals_sn_fb_enable), 0x0, NULL, HFILL}
933                 },
934                 {       /* 38 FSN Size */
935                         &hf_sfe_fsn_size,
936                         {"FSN Size", "wmx.sfe.fsn_size", FT_UINT8, BASE_DEC, VALS(vals_fsn_size), 0x0, NULL, HFILL}
937                 },
938                 {       /* 39 CID allocation for Active BSs */
939                         &hf_sfe_cid_alloc_for_active_bs,
940                         {"CID Allocation For Active BSs", "wmx.sfe.cid_alloc_for_active_bs", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
941                 },
942                 {       /* 39.1 */
943                         &hf_sfe_cid_alloc_for_active_bs_cid,
944                         {"CID", "wmx.sfe.cid_alloc_for_active_bs_cid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
945                 },
946                         {       /* 40 Unsolicited Grant Interval */
947                         &hf_sfe_unsolicited_grant_interval,
948                         {"Unsolicited Grant Interval", "wmx.sfe.unsolicited_grant_interval", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
949                 },
950                         {       /* 41 Unsolicited Polling Interval */
951                         &hf_sfe_unsolicited_polling_interval,
952                         {"Unsolicited Polling Interval", "wmx.sfe.unsolicited_polling_interval", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
953                 },
954                 {       /* 42 PDU SN extended subheader for HARQ reordering */
955                         &hf_sfe_pdu_sn_ext_subheader_reorder,
956                         {"PDU SN Extended Subheader For HARQ Reordering", "wmx.sfe.pdu_sn_ext_subheader_reorder", FT_UINT8, BASE_DEC, VALS(vals_pdu_sn_ext_subheader), 0x0, NULL, HFILL}
957                 },
958                 {       /* 43 MBS contents ID */
959                         &hf_sfe_mbs_contents_ids,
960                         {"MBS contents IDs", "wmx.sfe.mbs_contents_ids", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
961                 },
962                 {       /* 43.1 */
963                         &hf_sfe_mbs_contents_ids_id,
964                         {"MBS Contents ID", "wmx.sfe.mbs_contents_ids_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
965                 },
966                         {       /* 44 HARQ Service Flows */
967                         &hf_sfe_harq_service_flows,
968                         {"HARQ Service Flows", "wmx.sfe.harq_service_flows", FT_UINT8, BASE_DEC, VALS(vals_harq), 0x0, NULL, HFILL}
969                 },
970                 {       /* 45 Authorization Token */
971                         &hf_sfe_authorization_token,
972                         {"Authorization Token", "wmx.sfe.authorization_token", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
973                 },
974                         {       /* 46 HARQ Channel Mapping */
975                         &hf_sfe_harq_channel_mapping,
976                         {"HARQ Channel Mapping", "wmx.sfe.harq_channel_mapping", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
977                 },
978                         {       /* 46.1 HARQ Channel Index*/
979                         &hf_sfe_harq_channel_mapping_index,
980                         {"HARQ Channel Index", "wmx.sfe.harq_channel_mapping.index", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
981                 },
982         /* unknown types */
983                 {       /* unknown SFE types */
984                         &hf_sfe_unknown_type,
985                         {"Unknown SFE TLV type", "wmx.sfe.unknown_type", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
986                 }
987         };
988
989         /* WiMax Convergence Service Parameter Encoding Rules display */
990         static hf_register_info hf_csper[] =
991         {       /* 99 - 111 CS parameter encoding rules */
992                 {       /* Classifier DSC Action */
993                         &hf_cst_classifier_dsc_action,
994                         {"Classifier DSC Action", "wmx.cst.classifier_action", FT_UINT8, BASE_DEC, VALS(vals_cst_classifier_action), 0x0, NULL, HFILL}
995                 },
996                 {       /* Errored Parameter */
997                         &hf_cst_error_set_errored_param,
998                         {"Errored Parameter", "wmx.cst.error_set.errored_param", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
999                 },
1000                 {       /* Error Code */
1001                         &hf_cst_error_set_error_code,
1002                         {"Error Code", "wmx.cst.error_set.error_code", FT_UINT8, BASE_HEX, VALS(vals_cc), 0x0, NULL, HFILL}
1003                 },
1004                 {       /* Error Message */
1005                         &hf_cst_error_set_error_msg,
1006                         {"Error Message", "wmx.cst.error_set.error_msg", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
1007                 },
1008                 {       /* Packet Classification Rule */
1009                         &hf_cst_pkt_class_rule,
1010                         {"Packet Classification Rule", "wmx.cst.pkt_class_rule", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1011                 },
1012                 {       /* Classification Rule Priority */
1013                         &hf_cst_pkt_class_rule_priority,
1014                         {"Classification Rule Priority", "wmx.cst.pkt_class_rule.priority", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1015                 },
1016                 {       /* ToS/Differentiated Services Codepoint (DSCP) Range And Mask */
1017                         &hf_cst_pkt_class_rule_range_mask,
1018                         {"ToS/Differentiated Services Codepoint (DSCP) Range And Mask", "wmx.cst.pkt_class_rule.range_mask", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1019                 },
1020                 {       /* ToS-Low */
1021                         &hf_cst_pkt_class_rule_tos_low,
1022                         {"ToS-Low", "wmx.cst.pkt_class_rule.tos-low", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1023                 },
1024                 {       /* ToS-High */
1025                         &hf_cst_pkt_class_rule_tos_high,
1026                         {"ToS-High", "wmx.cst.pkt_class_rule.tos-high", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1027                 },
1028                 {       /* ToS-Mask */
1029                         &hf_cst_pkt_class_rule_tos_mask,
1030                         {"ToS-Mask", "wmx.cst.pkt_class_rule.tos-mask", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1031                 },
1032                 {       /* Protocol */
1033                         &hf_cst_pkt_class_rule_protocol,
1034                         {"Protocol", "wmx.cst.pkt_class_rule.protocol", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1035                 },
1036 #if 0 /* Removed by the changes of 802.16E 2005 */
1037                 {       /* Protocol */
1038                         &hf_cst_pkt_class_rule_protocol,
1039                         {"Protocol", "wmx.cst.pkt_class_rule.protocol", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1040                 },
1041                 {       /* Protocol Number */
1042                         &hf_cst_pkt_class_rule_protocol_number,
1043                         {"Protocol Number", "wmx.cst.pkt_class_rule.protocol.number", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1044                 },
1045 #endif
1046                 {       /* IP Masked Source Address */
1047                         &hf_cst_pkt_class_rule_ip_masked_src_address,
1048                         {"IP Masked Source Address", "wmx.cst.pkt_class_rule.ip_masked_src_address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1049                 },
1050                 {       /* IP Masked Destination Address */
1051                         &hf_cst_pkt_class_rule_ip_masked_dest_address,
1052                         {"IP Masked Destination Address", "wmx.cst.pkt_class_rule.ip_masked_dest_address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1053                 },
1054                 {       /* IPv4 Source Address */
1055                         &hf_cst_pkt_class_rule_src_ipv4,
1056                         {"IPv4 Source Address", "wmx.cst.pkt_class_rule.src_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL}
1057                 },
1058                 {       /* IPv4 Destination Address */
1059                         &hf_cst_pkt_class_rule_dest_ipv4,
1060                         {"IPv4 Destination Address", "wmx.cst.pkt_class_rule.dst_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL}
1061                 },
1062                 {       /* IPv4 Mask */
1063                         &hf_cst_pkt_class_rule_mask_ipv4,
1064                         {"IPv4 Mask", "wmx.cst.pkt_class_rule.mask_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL}
1065                 },
1066                 {       /* IPv6 Source Address */
1067                         &hf_cst_pkt_class_rule_src_ipv6,
1068                         {"IPv6 Source Address", "wmx.cst.pkt_class_rule.src_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
1069                 },
1070                 {       /* IPv6 Destination Address */
1071                         &hf_cst_pkt_class_rule_dest_ipv6,
1072                         {"IPv6 Destination Address", "wmx.cst.pkt_class_rule.dst_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
1073                 },
1074                 {       /* IPv6 Mask */
1075                         &hf_cst_pkt_class_rule_mask_ipv6,
1076                         {"IPv6 Mask", "wmx.cst.pkt_class_rule.mask_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
1077                 },
1078                 {       /* Protocol Source Port Range */
1079                         &hf_cst_pkt_class_rule_prot_src_port_range,
1080                         {"Protocol Source Port Range", "wmx.cst.pkt_class_rule.prot_src_port_range", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1081                 },
1082                 {       /* Src-Port Low */
1083                         &hf_cst_pkt_class_rule_src_port_low,
1084                         {"Src-Port Low", "wmx.cst.pkt_class_rule.src_port_low", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1085                 },
1086                 {       /* Src-Port High */
1087                         &hf_cst_pkt_class_rule_src_port_high,
1088                         {"Src-Port High", "wmx.cst.pkt_class_rule.src_port_high", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1089                 },
1090                 {       /* Protocol Destination Port Range */
1091                         &hf_cst_pkt_class_rule_prot_dest_port_range,
1092                         {"Protocol Destination Port Range", "wmx.cst.pkt_class_rule.prot_dest_port_range", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1093                 },
1094                 {       /* Dst-Port Low */
1095                         &hf_cst_pkt_class_rule_dest_port_low,
1096                         {"Dst-Port Low", "wmx.cst.pkt_class_rule.dst_port_low", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1097                 },
1098                 {       /* Dst-Port High */
1099                         &hf_cst_pkt_class_rule_dest_port_high,
1100                         {"Dst-Port High", "wmx.cst.pkt_class_rule.dst_port_high", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1101                 },
1102                 {       /* 802.3/Ethernet Destination MAC Address */
1103                         &hf_cst_pkt_class_rule_dest_mac_address,
1104                         {"802.3/Ethernet Destination MAC Address", "wmx.cst.pkt_class_rule.dest_mac_address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1105                 },
1106                 {       /* Destination MAC Address */
1107                         &hf_cst_pkt_class_rule_dest_mac,
1108                         {"Destination MAC Address", "wmx.cst.pkt_class_rule.dst_mac", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}
1109                 },
1110                 {       /* 802.3/Ethernet Source MAC Address */
1111                         &hf_cst_pkt_class_rule_src_mac_address,
1112                         {"802.3/Ethernet Source MAC Address", "wmx.cst.pkt_class_rule.src_mac_address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1113                 },
1114                 {       /* Source MAC Address */
1115                         &hf_cst_pkt_class_rule_src_mac,
1116                         {"Source MAC Address", "wmx.cst.pkt_class_rule.src_mac", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}
1117                 },
1118                 {       /* MAC Address Mask */
1119                         &hf_cst_pkt_class_rule_mask_mac,
1120                         {"MAC Address Mask", "wmx.cst.pkt_class_rule.mask_mac", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL}
1121                 },
1122                 {       /* Ethertype/IEEE Std 802.2-1998 SAP */
1123                         &hf_cst_pkt_class_rule_ethertype,
1124                         {"Ethertype/IEEE Std 802.2-1998 SAP", "wmx.cst.pkt_class_rule.ethertype", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1125                 },
1126                 {       /* Ethertype */
1127                         &hf_cst_pkt_class_rule_etype,
1128                         {"Ethertype", "wmx.cst.pkt_class_rule.ethertype", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1129                 },
1130                 {       /* Eprot1 */
1131                         &hf_cst_pkt_class_rule_eprot1,
1132                         {"Eprot1", "wmx.cst.pkt_class_rule.eprot1", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1133                 },
1134                 {       /* Eprot2 */
1135                         &hf_cst_pkt_class_rule_eprot2,
1136                         {"Eprot2", "wmx.cst.pkt_class_rule.eprot2", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1137                 },
1138                 {       /* IEEE Std 802.1D-1998 User_Priority */
1139                         &hf_cst_pkt_class_rule_user_priority,
1140                         {"IEEE Std 802.1D-1998 User_Priority", "wmx.cst.pkt_class_rule.user_priority", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1141                 },
1142                 {
1143                         &hf_cst_pkt_class_rule_pri_low,
1144                         {"Pri-Low", "wmx.cst.pkt_class_rule.pri-low", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1145                 },
1146                 {
1147                         &hf_cst_pkt_class_rule_pri_high,
1148                         {"Pri-High", "wmx.cst.pkt_class_rule.pri-high", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1149                 },
1150                 {       /* IEEE Std 802.1Q-1998 VLAN_ID */
1151                         &hf_cst_pkt_class_rule_vlan_id,
1152                         {"IEEE Std 802.1Q-1998 VLAN_ID", "wmx.cst.pkt_class_rule.vlan_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1153                 },
1154                 {       /* Vlan_Id1 */
1155                         &hf_cst_pkt_class_rule_vlan_id1,
1156                         {"Vlan_Id1", "wmx.cst.pkt_class_rule.vlan_id1", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1157                 },
1158                 {       /* Vlan_Id2 */
1159                         &hf_cst_pkt_class_rule_vlan_id2,
1160                         {"Vlan_Id2", "wmx.cst.pkt_class_rule.vlan_id2", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1161                 },
1162                 {       /* Associated PHSI */
1163                         &hf_cst_pkt_class_rule_phsi,
1164                         {"Associated PHSI", "wmx.cst.pkt_class_rule.phsi", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1165                 },
1166                 {       /* Packet Classifier Rule Index */
1167                         &hf_cst_pkt_class_rule_index,
1168                         {"Packet Classifier Rule Index (PCRI)", "wmx.cst.pkt_class_rule.index", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1169                 },
1170                 {       /* Large Context ID for ROHC/ECRTP Compressed Packet or ROHC Feedback Packet */
1171                         &hf_cst_large_context_id,
1172                         {"Large Context ID", "wmx.cst.large_context_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1173                 },
1174                 {       /* Short-Format Context ID for ROHC/ECRTP Compressed Packet or ROHC Feedback Packet */
1175                         &hf_cst_short_format_context_id,
1176                         {"Short-Format Context ID", "wmx.cst.short_format_context_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1177                 },
1178                 {       /* Vendor-Specific Classifier Parameters */
1179                         &hf_cst_pkt_class_rule_vendor_spec,
1180                         {"Vendor-Specific Classifier Parameters", "wmx.cst.pkt_class_rule.vendor_spec", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1181                 },
1182                 {       /* Classifier Action Rule */
1183                         &hf_cst_pkt_class_rule_classifier_action_rule,
1184                         {"Classifier Action Rule", "wmx.cst.pkt_class_rule.classifier.action.rule", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1185                 },
1186                 {
1187                         &hf_cst_pkt_class_rule_classifier_action_rule_bit0,
1188                         {"Bit #0", "wmx.cst.pkt_class_rule.classifier.action.rule.bit0", FT_UINT8, BASE_HEX, VALS(vals_classification_action_rule), CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_BIT0, NULL, HFILL}
1189                 },
1190                 {
1191                         &hf_cst_pkt_class_rule_classifier_action_rule_bit1,
1192                         {"Reserved", "wmx.cst.pkt_class_rule.classifier.action.rule.reserved", FT_UINT8, BASE_HEX, NULL, CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_RSV, NULL, HFILL}
1193                 },
1194                 {       /* PHS DSC action */
1195                         &hf_cst_phs_dsc_action,
1196                         {"PHS DSC action", "wmx.cst.phs_dsc_action", FT_UINT8, BASE_DEC, VALS(vals_cst_phs_dsc_action), 0x0, NULL, HFILL}
1197                 },
1198                 {       /* PHS Rule */
1199                         &hf_cst_phs_rule,
1200                         {"PHS Rule", "wmx.cst.phs_rule", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1201                 },
1202                 {       /* PHS Rule 1 */
1203                         &hf_cst_phs_phsi,
1204                         {"PHSI", "wmx.cst.phs_rule.phsi", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1205                 },
1206                 {       /* PHS Rule 2 */
1207                         &hf_cst_phs_phsf,
1208                         {"PHSF", "wmx.cst.phs_rule.phsf", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1209                 },
1210                 {       /* PHS Rule 3 */
1211                         &hf_cst_phs_phsm,
1212                         {"PHSM (bit x: 0-don't suppress the (x+1) byte; 1-suppress the (x+1) byte)", "wmx.cst.phs_rule.phsm", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1213                 },
1214                 {       /* PHS Rule 4 */
1215                         &hf_cst_phs_phss,
1216                         {"PHSS", "wmx.cst.phs_rule.phss", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1217                 },
1218                 {       /* PHS Rule 5 */
1219                         &hf_cst_phs_phsv,
1220                         {"PHSV", "wmx.cst.phs_rule.phsv", FT_UINT8, BASE_DEC, VALS(vals_verify), 0x0, NULL, HFILL}
1221                 },
1222                 {       /* PHS Rule 143 */
1223                         &hf_cst_phs_vendor_spec,
1224                         {"Vendor-Specific PHS Parameters", "wmx.cst.phs.vendor_spec", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1225                 },
1226                 {       /* IPv6 Flow Label */
1227                         &hf_cst_pkt_class_rule_ipv6_flow_label,
1228                         {"IPv6 Flow Label", "wmx.cst.pkt_class_rule.ipv6_flow_label", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
1229                 },
1230                 {       /* ATM Switching Encoding */
1231                         &hf_csper_atm_switching_encoding,
1232                         {"ATM Switching Encoding", "wmx.csper.atm_switching_encoding", FT_UINT8, BASE_DEC, VALS(vals_atm_switching_encodings), 0x0, NULL, HFILL}
1233                 },
1234                 {       /* ATM Classifier TLV */
1235                         &hf_csper_atm_classifier,
1236                         {"ATM Classifier TLV", "wmx.csper.atm_classifier", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1237                 },
1238                 {       /* ATM VPI Classifier */
1239                         &hf_csper_atm_classifier_vpi,
1240                         {"VPI Classifier", "wmx.csper.atm_classifier_vpi", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
1241                 },
1242                 {       /* ATM VCI Classifier */
1243                         &hf_csper_atm_classifier_vci,
1244                         {"VCI Classifier", "wmx.csper.atm_classifier_vci", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
1245                 },
1246                 {       /* ATM Classifier ID */
1247                         &hf_csper_atm_classifier_id,
1248                         {"Classifier ID", "wmx.csper.atm_classifier_tlv", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1249                 },
1250         /* unknown types */
1251                 {       /* unknown CSPER types */
1252                         &hf_csper_unknown_type,
1253                         {"Unknown CSPER TLV type", "wmx.csper.unknown_type", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1254                 },
1255                 {
1256                         &hf_cst_invalid_tlv,
1257                         {"Invalid TLV", "wmx.cst.invalid_tlv", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1258                 }
1259         };
1260
1261         /* WiMax HMAC/CMAC/Short-HMAC Tuples display */
1262         static hf_register_info hf_xmac[] =
1263         {
1264                 {
1265                         &hf_xmac_tuple_rsvd,
1266                         {"Reserved", "wmx.xmac_tuple.reserved", FT_UINT8, BASE_HEX, NULL, XMAC_TUPLE_RESERVED, NULL, HFILL}
1267                 },
1268                 {
1269                         &hf_xmac_tuple_key_seq_num,
1270                         {"Key Sequence Number", "wmx.xmac_tuple.key_sn", FT_UINT8, BASE_DEC, NULL, XMAC_TUPLE_KEY_SEQ_NUM, NULL, HFILL}
1271                 },
1272                 {
1273                         &hf_hmac_tuple_hmac_digest,
1274                         {"HMAC Digest", "wmx.xmac_tuple.hmac_digest", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1275                 },
1276                 {
1277                         &hf_cmac_tuple_bsid,
1278                         {"BSID", "wmx.cmac_tuple.bsid", FT_ETHER, BASE_HEX, NULL, 0x0, NULL, HFILL}
1279                 },
1280                 {
1281                         &hf_cmac_tuple_cmac_value,
1282                         {"CMAC Value", "wmx.cmac_tuple.cmac.value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1283                 },
1284                 {
1285                         &hf_packet_number_counter,
1286                         {"Packet Number Counter", "wmx.xmac_tuple.packet_number_count", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1287                 }
1288         };
1289
1290         static hf_register_info hf_snp[] =
1291         {
1292                 {       /* 11.8.4.1 */
1293                         &hf_snp_pkm_version_support,
1294                         {"PKM Version Support", "wmx.security_negotiation_parameters.pkm_version_support",FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1295                 },
1296                 {
1297                         &hf_snp_pkm_version_support_bit0,
1298                         {"PKM version 1", "wmx.security_negotiation_parameters.pkm_version_support.bit0",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_PKM_VERSION_SUPPORT_BIT0, NULL, HFILL}
1299                 },
1300                 {
1301                         &hf_snp_pkm_version_support_bit1,
1302                         {"PKM version 2", "wmx.security_negotiation_parameters.pkm_version_support.bit1",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_PKM_VERSION_SUPPORT_BIT1, NULL, HFILL}
1303                 },
1304                 {
1305                         &hf_snp_pkm_version_support_reserved,
1306                         {"Reserved", "wmx.security_negotiation_parameters.pkm_version_support.reserved",FT_UINT8, BASE_HEX, NULL, SNP_PKM_VERSION_SUPPORT_RSV, NULL, HFILL}
1307                 },
1308                 {       /* 11.8.4.2 */
1309                         &hf_snp_auth_policy_support,
1310                         {"Authorization Policy Support", "wmx.security_negotiation_parameters.auth_policy_support",FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1311                 },
1312                 {
1313                         &hf_snp_auth_policy_support_bit0,
1314                         {"RSA-based Authorization At The Initial Network Entry", "wmx.security_negotiation_parameters.auth_policy_support.bit0",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_AUTH_POLICY_SUPPORT_BIT0, NULL, HFILL}
1315                 },
1316                 {
1317                         &hf_snp_auth_policy_support_bit1,
1318                         {"EAP-based Authorization At The Initial Network Entry", "wmx.security_negotiation_parameters.auth_policy_support.bit1",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_AUTH_POLICY_SUPPORT_BIT1, NULL, HFILL}
1319                 },
1320                 {
1321                         &hf_snp_auth_policy_support_bit2,
1322                         {"Authenticated EAP-based Authorization At The Initial Network Entry", "wmx.security_negotiation_parameters.auth_policy_support.bit2",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_AUTH_POLICY_SUPPORT_BIT2, NULL, HFILL}
1323                 },
1324                 {
1325                         &hf_snp_auth_policy_support_bit3,
1326                         {"Reserved", "wmx.security_negotiation_parameters.auth_policy_support.bit3",FT_UINT8, BASE_HEX, NULL, SNP_AUTH_POLICY_SUPPORT_BIT3, NULL, HFILL}
1327                 },
1328                 {
1329                         &hf_snp_auth_policy_support_bit4,
1330                         {"RSA-based Authorization At Re-entry", "wmx.security_negotiation_parameters.auth_policy_support.bit4",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_AUTH_POLICY_SUPPORT_BIT4, NULL, HFILL}
1331                 },
1332                 {
1333                         &hf_snp_auth_policy_support_bit5,
1334                         {"EAP-based Authorization At Re-entry", "wmx.security_negotiation_parameters.auth_policy_support.bit5",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_AUTH_POLICY_SUPPORT_BIT5, NULL, HFILL}
1335                 },
1336                 {
1337                         &hf_snp_auth_policy_support_bit6,
1338                         {"Authenticated EAP-based Authorization At Re-entry", "wmx.security_negotiation_parameters.auth_policy_support.bit6",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_AUTH_POLICY_SUPPORT_BIT6, NULL, HFILL}
1339                 },
1340                 {
1341                         &hf_snp_auth_policy_support_bit7,
1342                         {"Reserved", "wmx.security_negotiation_parameters.auth_policy_support.bit7",FT_UINT8, BASE_HEX, NULL, SNP_AUTH_POLICY_SUPPORT_BIT7, NULL, HFILL}
1343                 },
1344                 {       /* 11.8.4.3 */
1345                         &hf_snp_mac_mode,
1346                         {"MAC (Message Authentication Code) Mode", "wmx.security_negotiation_parameters.mac_mode",FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1347                 },
1348                 {
1349                         &hf_snp_mac_mode_bit0,
1350                         {"HMAC", "wmx.security_negotiation_parameters.mac_mode.bit0",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT0, NULL, HFILL}
1351                 },
1352                 {
1353                         &hf_snp_mac_mode_bit1,
1354                         {"CMAC", "wmx.security_negotiation_parameters.mac_mode.bit1",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT1, NULL, HFILL}
1355                 },
1356                 {
1357                         &hf_snp_mac_mode_bit1_rsvd,
1358                         {"Reserved", "wmx.security_negotiation_parameters.mac_mode.bit1_rsvd",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT1, NULL, HFILL}
1359                 },
1360                 {
1361                         &hf_snp_mac_mode_bit2,
1362                         {"64-bit Short-HMAC", "wmx.security_negotiation_parameters.mac_mode.bit2",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT2, NULL, HFILL}
1363                 },
1364                 {
1365                         &hf_snp_mac_mode_bit3,
1366                         {"80-bit Short-HMAC", "wmx.security_negotiation_parameters.mac_mode.bit3",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT3, NULL, HFILL}
1367                 },
1368                 {
1369                         &hf_snp_mac_mode_bit4,
1370                         {"96-bit Short-HMAC", "wmx.security_negotiation_parameters.mac_mode.bit4",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT4, NULL, HFILL}
1371                 },
1372                 {
1373                         &hf_snp_mac_mode_bit5,
1374                         {"CMAC", "wmx.security_negotiation_parameters.mac_mode.bit5",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT5, NULL, HFILL}
1375                 },
1376                 {
1377                         &hf_snp_mac_mode_reserved,
1378                         {"Reserved", "wmx.security_negotiation_parameters.mac_mode.reserved",FT_UINT8, BASE_HEX, NULL, SNP_MAC_MODE_RSV, NULL, HFILL}
1379                 },
1380                 {
1381                         &hf_snp_mac_mode_reserved1,
1382                         {"Reserved", "wmx.security_negotiation_parameters.mac_mode.reserved",FT_UINT8, BASE_HEX, NULL, SNP_MAC_MODE_RSV1, NULL, HFILL}
1383                 },
1384                 {       /* 11.8.4.4 */
1385                         &hf_snp_pn_window_size,
1386                         {"PN Window Size", "wmx.security_negotiation_parameters.pn_window_size",FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1387                 },
1388                 {       /* 11.8.4.5 */
1389                         &hf_snp_max_conc_transactions,
1390                         {"Maximum concurrent transactions (0 indicates no limit)", "wmx.security_negotiation_parameters.max_conc_transactions",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1391                 },
1392                 {       /* 11.8.4.6 */
1393                         &hf_snp_max_suppt_sec_assns,
1394                         {"Maximum number of security associations supported by the SS", "wmx.security_negotiation_parameters.max_suppt_sec_assns",FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1395                 },
1396                 {
1397                         &hf_snp_unknown_type,
1398                         {"Unknown Security Negotiation Parameter type", "wmx.security_negotiation_parameters.unknown.type",FT_BYTES, BASE_NONE, NULL, 0x0,      NULL, HFILL}
1399                 }
1400         };
1401
1402         static hf_register_info hf_pkm[] =
1403         {
1404                 {       /* 11.9.1 - type 6 */
1405                         &hf_pkm_msg_attr_display,
1406                         {"Display String", "wmx.pkm_msg.pkm_attr.display_string", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
1407                 },
1408                 {       /* 11.9.2 - type 7 */
1409                         &hf_pkm_msg_attr_auth_key,
1410                         {"Auth Key", "wmx.pkm_msg.pkm_attr.auth_key", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1411                 },
1412                 {       /* 11.9.3 - type 8 */
1413                         &hf_pkm_msg_attr_tek,
1414                         {"TEK", "wmx.pkm_msg.pkm_attr.tek", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1415                 },
1416                 {       /* 11.9.4 - type 9 */
1417                         &hf_pkm_msg_attr_key_life_time,
1418                         {"Key Lifetime", "wmx.pkm_msg.pkm_attr.key_life_time", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
1419                 },
1420                 {       /* 11.9.5 - type 10 */
1421                         &hf_pkm_msg_attr_key_seq_num,
1422                         {"Key Sequence Number", "wmx.pkm_msg.pkm_attr.key_seq_num", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1423                 },
1424                 {       /* 11.9.6 - type 11 */
1425                         &hf_pkm_msg_attr_hmac_digest,
1426                         {"HMAC-Digest", "wmx.pkm_msg.pkm_attr.hmac_digest", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1427                 },
1428                 {       /* 11.9.7 - type 12 */
1429                         &hf_pkm_msg_attr_said,
1430                         {"SAID", "wmx.pkm_msg.pkm_attr.said", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
1431                 },
1432 #if 0   /* not been used */
1433                 {       /* 11.9.8 - type 13 */
1434                         &hf_pkm_msg_attr_tek_param,
1435                         {"TEK Parameters", "wmx.pkm_msg.pkm_attr.tek_parameters", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1436                 },
1437 #endif
1438                 {       /* 11.9.9 - type 15 */
1439                         &hf_pkm_msg_attr_cbc_iv,
1440                         {"CBC IV", "wmx.pkm_msg.pkm_attr.cbc_iv", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1441                 },
1442                 {       /* 11.9.10 - type 16 */
1443                         &hf_pkm_msg_attr_error_code,
1444                         {"Error Code", "wmx.pkm_msg.pkm_attr.error_code", FT_UINT8, BASE_DEC, VALS(vals_pkm_attr_error_codes), 0x0, NULL, HFILL}
1445                 },
1446                 {       /* 11.9.11 - type 17 */
1447                         &hf_pkm_msg_attr_ca_certificate,
1448                         {"CA Certificate", "wmx.pkm_msg.pkm_attr.ca_certificate", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1449                 },
1450                 {       /* 11.9.12 - type 18 */
1451                         &hf_pkm_msg_attr_ss_certificate,
1452                         {"SS Certificate", "wmx.pkm_msg.pkm_attr.ss_certificate", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1453                 },
1454 #if 0   /* not been used */
1455                 {       /* 11.9.13 - type 19 */
1456                         &hf_pkm_msg_attr_security_capabilities,
1457                         {"Security Capabilities", "wmx.pkm_msg.pkm_attr.security_capabilities", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1458                 },
1459 #endif
1460                 {       /* 11.9.14 - type 20 */
1461                         &hf_pkm_msg_crypto_suite,
1462                         {"Cryptography", "wmx.pkm_msg.pkm_attr.crypto_suite", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1463                 },
1464                 {
1465                         &hf_pkm_msg_crypto_suite_msb,
1466                         {"Data Encryption Algorithm Identifiers", "wmx.pkm_msg.pkm_attr.crypto_suite.msb", FT_UINT8, BASE_DEC, VALS(vals_data_encryption_ids), 0x0, NULL, HFILL}
1467                 },
1468                 {
1469                         &hf_pkm_msg_crypto_suite_middle,
1470                         {"Data Authentication Algorithm Identifiers", "wmx.pkm_msg.pkm_attr.crypto_suite.middle", FT_UINT8, BASE_DEC, VALS(vals_data_authentication_ids), 0x0, NULL, HFILL}
1471                 },
1472                 {
1473                         &hf_pkm_msg_crypto_suite_lsb,
1474                         {"TEK Encryption Algorithm Identifiers", "wmx.pkm_msg.pkm_attr.crypto_suite.lsb", FT_UINT8, BASE_DEC, VALS(vals_tek_encryption_ids), 0x0, NULL, HFILL}
1475                 },
1476 #if 0   /* not been used */
1477                 {       /* 11.9.15 - type 21 */
1478                         &hf_pkm_msg_crypto_list,
1479                         {"Cryptographic-Suite List", "wmx.pkm_msg.pkm_attr.crypto_suite_list", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1480                 },
1481 #endif
1482 #if 0   /* deleted by 802.16E */
1483                 {       /* 11.9.16 - type 22 */
1484                         &hf_pkm_msg_version,
1485                         {"Reserved ", "wmx.pkm_msg.pkm_attr.version", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1486                 },
1487 #endif
1488 #if 0   /* not been used */
1489                 {       /* 11.9.17 - type 23 */
1490                         &hf_pkm_msg_sa_descriptor,
1491                         {"SA Descriptor", "wmx.pkm_msg.pkm_attr.sa_descriptor", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1492                 },
1493 #endif
1494                 {       /* 11.9.18 - type 24 */
1495                         &hf_pkm_sa_type,
1496                         {"SA Type", "wmx.pkm_msg.pkm_attr.sa_type", FT_UINT8, BASE_DEC, VALS(vs_sa_type), 0x0, NULL, HFILL}
1497                 },
1498 #if 0   /* not been used */
1499                 {       /* 11.9.?? - type 25 */
1500                         &hf_pkm_attr_security_negotiation_parameters,
1501                         {"Security Negotiation Parameters", "wmx.pkm_msg.pkm_attr.security_negotiation_parameters", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1502                 },
1503 #endif
1504 #if 0   /* not been used */
1505                 {       /* 11.9.19 - type 27 */
1506                         &hf_pkm_attr_config_settings,
1507                         {"PKM Configuration Settings", "wmx.pkm_msg.pkm_attr.config_settings", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1508                 },
1509 #endif
1510                 {       /* 11.9.19.1 */
1511                         &hf_pkm_config_settings_authorize_waitout,
1512                         {"Authorize Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.authorize_waitout", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1513                 },
1514                 {       /* 11.9.19.2 */
1515                         &hf_pkm_config_settings_reauthorize_waitout,
1516                         {"Reauthorize Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.reauthorize_waitout", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1517                 },
1518                 {       /* 11.9.19.3 */
1519                         &hf_pkm_config_settings_grace_time,
1520                         {"Authorization Grace Time (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.grace_time", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1521                 },
1522                 {       /* 11.9.19.4 */
1523                         &hf_pkm_config_settings_operational_waittime,
1524                         {"Operational Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.operational_wait_timeout", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1525                 },
1526                 {       /* 11.9.19.5 */
1527                         &hf_pkm_config_settings_rekey_wait_timeout,
1528                         {"Rekey Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.rekey_wait_timeout", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1529                 },
1530                 {       /* 11.9.19.6 */
1531                         &hf_pkm_config_settings_tek_grace_time,
1532                         {"TEK Grace Time (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.tek_grace_time", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1533                 },
1534                 {       /* 11.9.19.7 */
1535                         &hf_pkm_config_settings_authorize_reject_wait_timeout,
1536                         {"Authorize Reject Wait Timeout(in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.authorize_reject_wait_timeout", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1537                 },
1538                 {       /* 11.9.20 - type 29 */
1539                         &hf_pkm_attr_nonce,
1540                         {"Nonce", "wmx.pkm_msg.pkm_attr.nonce", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1541                 },
1542                 {       /* 11.9.21 - type 33 */
1543                         &hf_pkm_attr_ss_random,
1544                         {"SS_RANDOM", "wmx.pkm_msg.pkm_attr.ss_random", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1545                 },
1546                 {       /* 11.9.22 - type 34 */
1547                         &hf_pkm_attr_bs_random,
1548                         {"BS_RANDOM", "wmx.pkm_msg.pkm_attr.bs_random", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1549                 },
1550                 {       /* 11.9.23 - type 35 */
1551                         &hf_pkm_attr_pre_pak,
1552                         {"Pre-PAK", "wmx.pkm_msg.pkm_attr.pre_pak", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1553                 },
1554 #if 1   /* no definition */
1555                 {       /* 11.9.?? - type 36 */
1556                         &hf_pkm_attr_pak_ak_seq_number,
1557                         {"PAK/AK Sequence Number", "wmx.pkm_msg.pkm_attr.pak_ak_seq_number", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1558                 },
1559 #endif
1560                 {       /* 11.9.24 - type 37 */
1561                         &hf_pkm_attr_bs_certificate,
1562                         {"BS Certificate", "wmx.pkm_msg.pkm_attr.bs_certificate", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1563                 },
1564                 {       /* 11.9.25 - type 38 */
1565                         &hf_pkm_attr_sig_bs,
1566                         {"SigBS", "wmx.pkm_msg.pkm_attr.sig_bs",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1567                 },
1568                 {       /* 11.9.26 - type 39 */
1569                         &hf_pkm_attr_ms_mac_address,
1570                         {"MS-MAC Address", "wmx.pkm_msg.pkm_attr.ms_mac_address",FT_ETHER, BASE_HEX, NULL, 0x0, NULL, HFILL}
1571                 },
1572                 {       /* 11.9.27 - type 40 */
1573                         &hf_pkm_attr_cmac_digest,
1574                         {"CMAC Digest", "wmx.pkm_msg.pkm_attr.cmac_digest",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1575                 },
1576                 {
1577                         &hf_pkm_attr_cmac_digest_pn,
1578                         {"CMAC Packet Number counter, CMAC_PN_*", "wmx.pkm_msg.pkm_attr.cmac_digest.pn",FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
1579                 },
1580                 {
1581                         &hf_pkm_attr_cmac_digest_value,
1582                         {"CMAC Value", "wmx.pkm_msg.pkm_attr.cmac_digest.value",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1583                 },
1584                 {       /* 11.9.28 - type 41 */
1585                         &hf_pkm_attr_push_modes,
1586                         {"Key Push Modes", "wmx.pkm_msg.pkm_attr.key_push_modes",FT_UINT8, BASE_DEC, VALS(va_key_push_modes), 0x0, NULL, HFILL}
1587                 },
1588                 {       /* 11.9.29 - type 42 */
1589                         &hf_pkm_attr_key_push_counter,
1590                         {"Key Push Counter", "wmx.pkm_msg.pkm_attr.key_push_counter",FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1591                 },
1592                 {       /* 11.9.30 - type 43 */
1593                         &hf_pkm_attr_gkek,
1594                         {"GKEK", "wmx.pkm_msg.pkm_attr.gkek",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1595                 },
1596                 {       /* 11.9.31 - type 44 */
1597                         &hf_pkm_attr_sig_ss,
1598                         {"SigSS", "wmx.pkm_msg.pkm_attr.sig_ss",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1599                 },
1600                 {       /* 11.9.32 - type 45 */
1601                         &hf_pkm_attr_akid,
1602                         {"AKID", "wmx.pkm_msg.pkm_attr.akid",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1603                 },
1604                 {       /* 11.9.33 - type 28 */
1605                         &hf_pkm_attr_eap_payload,
1606                         {"EAP Payload", "wmx.pkm_msg.pkm_attr.eap_payload", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1607                 },
1608                 {       /* 11.9.34 - type 30 */
1609                         &hf_pkm_attr_auth_result_code,
1610                         {"Auth Result Code", "wmx.pkm_msg.pkm_attr.auth_result_code", FT_UINT8, BASE_DEC, VALS(vs_success_reject), 0x0, NULL, HFILL}
1611                 },
1612                 {       /* 11.9.35 - type 31 */
1613                         &hf_pkm_attr_sa_service_type,
1614                         {"SA Service Type", "wmx.pkm_msg.pkm_attr.sa_service_type", FT_UINT8, BASE_DEC, VALS(vs_sa_service_type), 0x0, NULL, HFILL}
1615                 },
1616 #if 0   /* same as 11.9.19 */
1617                 {       /* 11.9.36 - type 27 */
1618                         &hf_pkm_attr_config_settings,
1619                         {"PKMv2 Configuration Settings", "wmx.pkm_msg.pkm_attr.config_settings", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1620                 },
1621 #endif
1622                 {       /* 11.9.37 - type 32 */
1623                         &hf_pkm_attr_frame_number,
1624                         {"Frame Number", "wmx.pkm_msg.pkm_attr.frame_number", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
1625                 },
1626 #if 1   /* no definitions */
1627                 {       /* 11.9.?? - type 46 */
1628                         &hf_pkm_attr_associated_gkek_seq_number,
1629                         {"Associated GKEK Sequence Number", "wmx.pkm_msg.pkm_attr.associated_gkek_seq_number",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1630                 },
1631                 {       /* 11.9.?? - type 47 */
1632                         &hf_pkm_attr_gkek_params,
1633                         {"GKEK Parameters", "wmx.pkm_msg.pkm_attr.gkek_params",FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1634                 },
1635 #endif
1636                 {
1637                         &hf_pkm_msg_unknown_type,
1638                         {"Unknown Type", "wmx.pkm.unknown.type", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1639                 }
1640         };
1641
1642         /* WiMax Common TLV Encoding display */
1643         static hf_register_info hf_common_tlv[] =
1644         {
1645                 {
1646                         &hf_common_tlv_mac_version,
1647                         { "MAC Version", "wmx.common_tlv.mac_version", FT_UINT8, BASE_DEC, VALS(vals_dcd_mac_version), 0x0, NULL, HFILL}
1648                 },
1649                 {
1650                         &hf_common_tlv_vendor_id,
1651                         { "Vendor ID Encoding", "wmx.common_tlv.vendor_id_encoding", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1652                 },
1653                 {
1654                         &hf_common_tlv_vendor_specific_type,
1655                         { "Vendor Specific Type", "wmx.common_tlv.vendor_specific_type", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1656                 },
1657                 {
1658                         &hf_common_tlv_vendor_specific_length_size,
1659                         {
1660                                 "Vendor Specific Length Size", "wmx.common_tlv.vendor_specific_length_size",
1661                                 FT_UINT8, BASE_HEX, NULL, 0x0,
1662                                 NULL, HFILL
1663                         }
1664                 },
1665                 {
1666                         &hf_common_tlv_vendor_specific_length,
1667                         { "Vendor Specific Length", "wmx.common_tlv.vendor_specific_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1668                 },
1669                 {
1670                         &hf_common_tlv_vendor_specific_value,
1671                         { "Vendor Specific Value", "wmx.common_tlv.vendor_specific_value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1672                 },
1673                 {
1674                         &hf_common_tlv_unknown_type,
1675                         {"Unknown Common TLV Type", "wmx.common_tlv.unknown_type", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1676                 }
1677         };
1678
1679         if(proto_wimax_utility_decoders == -1)
1680         {
1681                 proto_wimax_utility_decoders = proto_register_protocol (
1682                                                         "WiMax Sub-TLV Messages", /* name */
1683                                                         "WiMax Sub-TLV (sub)", /* short name */
1684                                                         "wmx.sub" /* abbrev */
1685                                                         );
1686
1687                 proto_register_subtree_array(ett, array_length(ett));
1688                 proto_register_field_array(proto_mac_mgmt_msg_reg_req_decoder, hf_sfe, array_length(hf_sfe));
1689                 proto_register_field_array(proto_wimax_utility_decoders, hf_csper, array_length(hf_csper));
1690                 proto_register_field_array(proto_wimax_utility_decoders, hf_xmac, array_length(hf_xmac));
1691                 proto_register_field_array(proto_wimax_utility_decoders, hf_snp, array_length(hf_snp));
1692                 proto_register_field_array(proto_wimax_utility_decoders, hf_pkm, array_length(hf_pkm));
1693                 proto_register_field_array(proto_wimax_utility_decoders, hf_common_tlv, array_length(hf_common_tlv));
1694
1695                 eap_handle = find_dissector("eap");
1696         }
1697 }
1698
1699 /**************************************************************/
1700 /* wimax_error_parameter_set_decoder()                        */
1701 /* decode and display the WiMax Error Parameter Set           */
1702 /* parameter:                                                 */
1703 /*   tvb - pointer of the tvb of error_parameter_set          */
1704 /*   tree - pointer of Wireshark display tree                 */
1705 /*   pinfo - pointer of Wireshark packet information structure*/
1706 /**************************************************************/
1707 void wimax_error_parameter_set_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1708 {
1709         guint offset;
1710         guint tvb_len, tlv_len;
1711         gint  tlv_type;
1712         proto_item *ceps_item = NULL;
1713         proto_tree *ceps_tree = NULL;
1714         proto_tree *tlv_tree = NULL;
1715         tlv_info_t tlv_info;
1716
1717         /* get the tvb reported length */
1718         tvb_len = tvb_reported_length(tvb);
1719         offset = 0;
1720         /* display error parameter information */
1721         ceps_item = proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, tvb_len, "Error Parameter Set (%u bytes)", tvb_len);
1722         /* add CS Parameter Encoding Rules subtree */
1723         ceps_tree = proto_item_add_subtree(ceps_item, ett_wimax_error_parameter_set);
1724         /* do nothing if the TLV fields is not exist */
1725         if(!tvb_len)
1726                 return;
1727         /* report error if the packet size is less than 2 bytes (type+length) */
1728         if(tvb_len < 2)
1729         {       /* invalid tlv info */
1730                 if(check_col(pinfo->cinfo, COL_INFO))
1731                 {
1732                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Error Parameter Set");
1733                 }
1734                 return;
1735         }
1736         /* process the classifier error parameter set */
1737         while(offset < tvb_len)
1738         {       /* get the TLV information */
1739                 init_tlv_info(&tlv_info, tvb, offset);
1740                 /* get the TLV type */
1741                 tlv_type = get_tlv_type(&tlv_info);
1742                 /* get the TLV length */
1743                 tlv_len = get_tlv_length(&tlv_info);
1744                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
1745                 {       /* invalid tlv info */
1746                         if(check_col(pinfo->cinfo, COL_INFO))
1747                         {
1748                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "EPS TLV error");
1749                         }
1750                         proto_tree_add_item(ceps_tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
1751                         break;
1752                 }
1753 #ifdef DEBUG /* for debug only */
1754                 proto_tree_add_protocol_format(ceps_tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len+2+get_tlv_size_of_length(&tlv_info)), "EPS TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len, offset, tvb_len);
1755 #endif
1756                 /* update the offset */
1757                 offset += get_tlv_value_offset(&tlv_info);
1758                 /* parse the Classifier Error Parameter Set */
1759                 switch (tlv_type)
1760                 {
1761                         case CST_ERROR_SET_ERRORED_PARAM:
1762                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_error_parameter_set, ceps_tree, hf_cst_error_set_errored_param, tvb, offset, tlv_len, FALSE);
1763                                 proto_tree_add_item(tlv_tree, hf_cst_error_set_errored_param, tvb, offset, tlv_len, FALSE);
1764                         break;
1765                         case CST_ERROR_SET_ERROR_CODE:
1766                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_error_parameter_set, ceps_tree, hf_cst_error_set_error_code, tvb, offset, tlv_len, FALSE);
1767                                 proto_tree_add_item(tlv_tree, hf_cst_error_set_error_code, tvb, offset, tlv_len, FALSE);
1768                         break;
1769                         case CST_ERROR_SET_ERROR_MSG:
1770                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_error_parameter_set, ceps_tree, hf_cst_error_set_error_msg, tvb, offset, tlv_len, FALSE);
1771                                 proto_tree_add_item(tlv_tree, hf_cst_error_set_error_msg, tvb, offset, tlv_len, FALSE);
1772                         break;
1773                 }
1774                 offset += tlv_len;
1775         }
1776 }
1777
1778 /****************************************************************/
1779 /* wimax_convengence_service_parameter_encoding_rules_decoder() */
1780 /* decode and display the WiMax Convergence Service Parameter   */
1781 /*        Encoding Rules                                        */
1782 /* parameter:                                                   */
1783 /*   sfe_type - Service Flow Encodings type                     */
1784 /*   tvb - pointer of the tvb of service flow encodings         */
1785 /*   tree - pointer of Wireshark display tree                   */
1786 /*   pinfo - pointer of Wireshark packet information structure  */
1787 /****************************************************************/
1788 /* CS Parameter Encoding Rules handling function */
1789 void wimax_convengence_service_parameter_encoding_rules_decoder(guint sfe_type, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1790 {
1791         guint offset, tlv_offset;
1792         guint tvb_len, tlv_len, length;
1793         gint  tlv_type;
1794         proto_item *csper_item = NULL;
1795         proto_tree *csper_tree = NULL;
1796         proto_tree *tlv_tree = NULL;
1797         proto_tree *ti_tree = NULL;
1798         tlv_info_t tlv_info;
1799         gboolean ipv6 = ((sfe_type == SFE_CSPER_PACKET_IPV6) || (sfe_type == SFE_CSPER_PACKET_IPV6_802_3) || (sfe_type == SFE_CSPER_PACKET_IPV6_802_1Q));
1800
1801         /* sanity check */
1802         if((sfe_type < SFE_CSPER_ATM) || (sfe_type > SFE_CSPER_PACKET_IP_802_3_ECRTP_COMPRESSION))
1803                 return; /* invalid CS Parameter Encodings */
1804
1805         /* get the tvb reported length */
1806         tvb_len = tvb_reported_length(tvb);
1807         offset = 0;
1808         /* display SFE information */
1809         csper_item = proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, tvb_len, "Convergence Service Parameter Encoding Rules (%u bytes)", tvb_len);
1810         /* add CS Parameter Encoding Rules subtree */
1811         csper_tree = proto_item_add_subtree(csper_item, ett_wimax_cst_encoding_rules);
1812         /* do nothing if the TLV fields is not exist */
1813         if(!tvb_len)
1814                 return;
1815         /* report error if the packet size is less than 2 bytes (type+length) */
1816         if(tvb_len < 2)
1817         {       /* invalid tlv info */
1818                 if(check_col(pinfo->cinfo, COL_INFO))
1819                 {
1820                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Convergence Service Parameter Encoding Rules");
1821                 }
1822                 return;
1823         }
1824         /* process WiMax Service Flow Encodings */
1825         while(offset < tvb_len)
1826         {       /* get the TLV information */
1827                 init_tlv_info(&tlv_info, tvb, offset);
1828                 /* get the TLV type */
1829                 tlv_type = get_tlv_type(&tlv_info);
1830                 /* get the TLV length */
1831                 tlv_len = get_tlv_length(&tlv_info);
1832                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
1833                 {       /* invalid tlv info */
1834                         if(check_col(pinfo->cinfo, COL_INFO))
1835                         {
1836                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "CSPER TLV error");
1837                         }
1838                         proto_tree_add_item(csper_tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
1839                         break;
1840                 }
1841 #ifdef DEBUG /* for debug only */
1842                 proto_tree_add_protocol_format(csper_tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len+2+get_tlv_size_of_length(&tlv_info)), "CSPER TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len, offset, tvb_len);
1843 #endif
1844                 /* update the offset */
1845                 offset += get_tlv_value_offset(&tlv_info);
1846                 /* parse the CS parameter Encoding Rule TLV */
1847                 if(sfe_type == SFE_CSPER_ATM)
1848                 {       /* ATM CS Encodings */
1849                         switch (tlv_type)
1850                         {
1851                                 case CST_ATM_SWITCHING:
1852                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_csper_atm_switching_encoding, tvb, offset, tlv_len, FALSE);
1853                                         proto_tree_add_item(tlv_tree, hf_csper_atm_switching_encoding, tvb, offset, tlv_len, FALSE);
1854                                 break;
1855                                 case CST_ATM_CLASSIFIER:
1856                                         /* add TLV subtree */
1857                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_csper_atm_classifier, tvb, offset, tlv_len, FALSE);
1858                                         tlv_offset = offset;
1859                                         while(tlv_offset < (tlv_len + offset))
1860                                         {
1861                                                 /* get the TLV information */
1862                                                 init_tlv_info(&tlv_info, tvb, tlv_offset);
1863                                                 /* get the TLV type */
1864                                                 tlv_type = get_tlv_type(&tlv_info);
1865                                                 /* get the TLV length */
1866                                                 length = get_tlv_length(&tlv_info);
1867                                                 if(tlv_type == -1 || length > MAX_TLV_LEN || length < 1)
1868                                                 {       /* invalid tlv info */
1869                                                         if(check_col(pinfo->cinfo, COL_INFO))
1870                                                         {
1871                                                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "ATM Classifier TLV error");
1872                                                         }
1873                                                         proto_tree_add_item(tlv_tree, hf_cst_invalid_tlv, tvb, offset, (tlv_len - tlv_offset), FALSE);
1874                                                         break;
1875                                                 }
1876 #ifdef DEBUG /* for debug only */
1877                                                 proto_tree_add_protocol_format(csper_tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len+2+get_tlv_size_of_length(&tlv_info)), "ATM Classifier TLV Type: %u (%u bytes, offset=%u, tlv_len=%u)", tlv_type, length, offset, tlv_len);
1878 #endif
1879                                                 /* update the offset */
1880                                                 tlv_offset += get_tlv_value_offset(&tlv_info);
1881                                                 switch (tlv_type)
1882                                                 {
1883                                                         case ATM_VPI_CLASSIFIER:
1884                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_csper_atm_classifier_vpi, tvb, tlv_offset, length, FALSE);
1885                                                                 proto_tree_add_item(ti_tree, hf_csper_atm_classifier_vpi, tvb, tlv_offset, length, FALSE);
1886                                                         break;
1887                                                         case ATM_VCI_CLASSIFIER:
1888                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_csper_atm_classifier_vci, tvb, tlv_offset, length, FALSE);
1889                                                                 proto_tree_add_item(ti_tree, hf_csper_atm_classifier_vci, tvb, tlv_offset, length, FALSE);
1890                                                         break;
1891                                                         case ATM_CLASSIFIER_ID:
1892                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_csper_atm_classifier_id, tvb, tlv_offset, length, FALSE);
1893                                                                 proto_tree_add_item(ti_tree, hf_csper_atm_classifier_id, tvb, tlv_offset, length, FALSE);
1894                                                         break;
1895                                                         default:
1896                                                         break;
1897                                                 }
1898                                                 tlv_offset += length;
1899                                         }       /* end of while loop */
1900                                 break;
1901                                 case CST_ATM_CLASSIFIER_DSC_ACTION:
1902                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_cst_classifier_dsc_action, tvb, offset, tlv_len, FALSE);
1903                                         proto_tree_add_item(tlv_tree, hf_cst_classifier_dsc_action, tvb, offset, tlv_len, FALSE);
1904                                 break;
1905                                 case CST_ATM_CLASSIFIER_ERROR_PARAMETER_SET:
1906                                         /* call the error parameter set function */
1907                                         tlv_tree = add_protocol_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Classifier Error Parameter Set (%u byte(s))", tlv_len);
1908                                         wimax_error_parameter_set_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
1909                                 break;
1910                                 default:
1911                                         /* display the unknown ATM CS encoding in hex */
1912                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_csper_unknown_type, tvb, offset, tlv_len, FALSE);
1913                                         proto_tree_add_item(tlv_tree, hf_csper_unknown_type, tvb, offset, tlv_len, FALSE);
1914                                 break;
1915                         }
1916                 }
1917                 else
1918                 {
1919                         switch (tlv_type)
1920                         {
1921                                 case CST_CLASSIFIER_ACTION:
1922                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_cst_classifier_dsc_action, tvb, offset, tlv_len, FALSE);
1923                                         proto_tree_add_item(tlv_tree, hf_cst_classifier_dsc_action, tvb, offset, tlv_len, FALSE);
1924                                 break;
1925                                 case CST_CLASSIFIER_ERROR_PARAM_SET:
1926                                 case CST_PHS_ERROR_PARAM_SET:
1927                                         tlv_tree = add_protocol_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Classifier Error Parameter Set (%u byte(s))", tlv_len);
1928                                         /* call the error parameter set function */
1929                                         wimax_error_parameter_set_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
1930                                 break;
1931                                 case CST_PACKET_CLASSIFICATION_RULE:
1932                                 {
1933                                         /* add TLV subtree */
1934                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_cst_pkt_class_rule, tvb, offset, tlv_len, FALSE);
1935                                         tlv_offset = offset;
1936                                         while(tlv_offset < (tlv_len + offset))
1937                                         {
1938                                                 /* get the TLV information */
1939                                                 init_tlv_info(&tlv_info, tvb, tlv_offset);
1940                                                 /* get the TLV type */
1941                                                 tlv_type = get_tlv_type(&tlv_info);
1942                                                 /* get the TLV length */
1943                                                 length = get_tlv_length(&tlv_info);
1944                                                 if(tlv_type == -1 || length > MAX_TLV_LEN || length < 1)
1945                                                 {       /* invalid tlv info */
1946                                                         if(check_col(pinfo->cinfo, COL_INFO))
1947                                                         {
1948                                                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Packet Classification Rule TLV error");
1949                                                         }
1950                                                         proto_tree_add_item(tlv_tree, hf_cst_invalid_tlv, tvb, offset, (tlv_len - tlv_offset), FALSE);
1951                                                         break;
1952                                                 }
1953 #ifdef DEBUG /* for debug only */
1954                                                 proto_tree_add_protocol_format(csper_tree, proto_wimax_utility_decoders, tvb, tlv_offset, (length + get_tlv_value_offset(&tlv_info)), "Packet Classification Rule TLV Type: %u (%u bytes, offset=%u, tlv_len=%u)", tlv_type, length, tlv_offset, tlv_len);
1955 #endif
1956                                                 /* update the offset */
1957                                                 tlv_offset += get_tlv_value_offset(&tlv_info);
1958                                                 switch (tlv_type)
1959                                                 {
1960                                                         case CST_PKT_CLASS_RULE_PRIORITY:
1961                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_priority, tvb, tlv_offset, length, FALSE);
1962                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_priority, tvb, tlv_offset, length, FALSE);
1963                                                         break;
1964                                                         case CST_PKT_CLASS_RULE_RANGE_MASK:
1965                                                                 /* add TLV subtree */
1966                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_range_mask, tvb, tlv_offset, length, FALSE);
1967                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_tos_low, tvb,
1968                                                                 tlv_offset, 1, FALSE);
1969                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_tos_high, tvb,
1970                                                                 tlv_offset + 1, 1, FALSE);
1971                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_tos_mask, tvb,
1972                                                                 tlv_offset + 2, 1, FALSE);
1973                                                         break;
1974                                                         case CST_PKT_CLASS_RULE_PROTOCOL:
1975                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_protocol, tvb, tlv_offset, length, FALSE);
1976                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_protocol, tvb, tlv_offset, length, FALSE);
1977                                                         break;
1978                                                         case CST_PKT_CLASS_RULE_SRC_IP:
1979                                                                 /* add TLV subtree */
1980                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_ip_masked_src_address, tvb, tlv_offset, length, FALSE);
1981                                                                 if(ipv6)
1982                                                                 {
1983                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_src_ipv6, tvb, tlv_offset, 16, FALSE);
1984                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_mask_ipv6, tvb, tlv_offset + 16, 16, FALSE);
1985                                                                 }
1986                                                                 else
1987                                                                 {
1988                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_src_ipv4, tvb, tlv_offset, 4, FALSE);
1989                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_mask_ipv4, tvb, tlv_offset + 4, 4, FALSE);
1990                                                                 }
1991                                                         break;
1992                                                         case CST_PKT_CLASS_RULE_DST_IP:
1993                                                                 /* add TLV subtree */
1994                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_ip_masked_dest_address, tvb, tlv_offset, length, FALSE);
1995                                                                 if(ipv6)
1996                                                                 {
1997                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_dest_ipv6, tvb, tlv_offset, 16, FALSE);
1998                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_mask_ipv6, tvb, tlv_offset + 16, 16, FALSE);
1999                                                                 }
2000                                                                 else
2001                                                                 {
2002                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_dest_ipv4, tvb, tlv_offset, 4, FALSE);
2003                                                                         proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_mask_ipv4, tvb, tlv_offset + 4, 4, FALSE);
2004                                                                 }
2005                                                         break;
2006                                                         case CST_PKT_CLASS_RULE_SRCPORT_RANGE:
2007                                                                 /* add TLV subtree */
2008                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_prot_src_port_range, tvb, tlv_offset, length, FALSE);
2009                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_src_port_low, tvb, tlv_offset, 2, FALSE);
2010                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_src_port_high, tvb, tlv_offset + 2, 2, FALSE);
2011                                                         break;
2012                                                         case CST_PKT_CLASS_RULE_DSTPORT_RANGE:
2013                                                                 /* add TLV subtree */
2014                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_prot_dest_port_range, tvb, tlv_offset, length, FALSE);
2015                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_dest_port_low, tvb, tlv_offset, 2, FALSE);
2016                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_dest_port_high, tvb, tlv_offset + 2, 2, FALSE);
2017                                                         break;
2018                                                         case CST_PKT_CLASS_RULE_DST_MAC:
2019                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_dest_mac_address, tvb, tlv_offset, length, FALSE);
2020                                                                 /* add TLV subtree */
2021                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_dest_mac, tvb, tlv_offset, 6, FALSE);
2022                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_mask_mac, tvb, tlv_offset + 6, 6, FALSE);
2023                                                         break;
2024                                                         case CST_PKT_CLASS_RULE_SRC_MAC:
2025                                                                 /* add TLV subtree */
2026                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_src_mac_address, tvb, tlv_offset, length, FALSE);
2027                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_src_mac, tvb, tlv_offset, 6, FALSE);
2028                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_mask_mac, tvb, tlv_offset + 6, 6, FALSE);
2029                                                         break;
2030                                                         case CST_PKT_CLASS_RULE_ETHERTYPE:
2031                                                                 /* add TLV subtree */
2032                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_ethertype, tvb, tlv_offset, length, FALSE);
2033                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_etype, tvb, tlv_offset, 1, FALSE);
2034                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_eprot1, tvb, tlv_offset + 1, 1, FALSE);
2035                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_eprot2, tvb, tlv_offset + 2, 1, FALSE);
2036                                                         break;
2037                                                         case CST_PKT_CLASS_RULE_USER_PRIORITY:
2038                                                                 /* add TLV subtree */
2039                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_user_priority, tvb, tlv_offset, length, FALSE);
2040                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_pri_low, tvb, tlv_offset, 1, FALSE);
2041                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_pri_high, tvb, tlv_offset + 1, 1, FALSE);
2042                                                         break;
2043                                                         case CST_PKT_CLASS_RULE_VLAN_ID:
2044                                                                 /* add TLV subtree */
2045                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_vlan_id, tvb, tlv_offset, length, FALSE);
2046                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_vlan_id1, tvb, tlv_offset, 1, FALSE);
2047                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_vlan_id2, tvb, tlv_offset + 1, 1, FALSE);
2048                                                         break;
2049                                                         case CST_PKT_CLASS_RULE_PHSI:
2050                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_phsi, tvb, tlv_offset, length, FALSE);
2051                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_phsi, tvb, tlv_offset, length, FALSE);
2052                                                         break;
2053                                                         case CST_PKT_CLASS_RULE_INDEX:
2054                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_index, tvb, tlv_offset, length, FALSE);
2055                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_index, tvb, tlv_offset, length, FALSE);
2056                                                         break;
2057                                                         case CST_PKT_CLASS_RULE_IPv6_FLOW_LABEL:
2058 /*???                                                           if(ipv6)*/
2059                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_ipv6_flow_label, tvb, tlv_offset, length, FALSE);
2060                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_ipv6_flow_label, tvb, tlv_offset, length, FALSE);
2061                                                         break;
2062                                                         case CST_PKT_CLASS_RULE_VENDOR_SPEC:
2063                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_vendor_spec, tvb, tlv_offset, length, FALSE);
2064                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_vendor_spec, tvb, tlv_offset, length, FALSE);
2065                                                         break;
2066                                                         case CST_CLASSIFIER_ACTION_RULE:
2067                                                                 /* add TLV subtree */
2068                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_pkt_class_rule_classifier_action_rule, tvb, tlv_offset, length, FALSE);
2069                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_classifier_action_rule_bit0, tvb, tlv_offset, 1, FALSE);
2070                                                                 proto_tree_add_item(ti_tree, hf_cst_pkt_class_rule_classifier_action_rule_bit1, tvb, tlv_offset, 1, FALSE);
2071                                                         break;
2072                                                         case CST_PKT_CLASS_RULE_LARGE_CONTEXT_ID:
2073                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_large_context_id, tvb, tlv_offset, length, FALSE);
2074                                                                 proto_tree_add_item(ti_tree, hf_cst_large_context_id, tvb, tlv_offset, length, FALSE);
2075                                                         break;
2076                                                         case CST_PKT_CLASS_RULE_SHORT_FORMAT_CONTEXT_ID:
2077                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_short_format_context_id, tvb, tlv_offset, length, FALSE);
2078                                                                 proto_tree_add_item(ti_tree, hf_cst_short_format_context_id, tvb, tlv_offset, length, FALSE);
2079                                                         break;
2080                                                         default:
2081                                                         break;
2082                                                 }       /* end of switch */
2083                                                 tlv_offset += length;
2084                                         }       /* end of while loop */
2085                                         break;
2086                                 }
2087                                 case CST_PHS_DSC_ACTION:
2088                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_cst_phs_dsc_action, tvb, offset, tlv_len, FALSE);
2089                                         proto_tree_add_item(tlv_tree, hf_cst_phs_dsc_action, tvb, offset, tlv_len, FALSE);
2090                                 break;
2091                                 case CST_PHS_RULE:
2092                                 {
2093                                         /* add TLV subtree */
2094                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, csper_tree, hf_cst_phs_rule, tvb, offset, tlv_len, FALSE);
2095                                         tlv_offset = offset;
2096                                         while(tlv_offset < (tlv_len + offset))
2097                                         {
2098                                                 /* get the TLV information */
2099                                                 init_tlv_info(&tlv_info, tvb, tlv_offset);
2100                                                 /* get the TLV type */
2101                                                 tlv_type = get_tlv_type(&tlv_info);
2102                                                 /* get the TLV length */
2103                                                 length = get_tlv_length(&tlv_info);
2104                                                 if(tlv_type == -1 || length > MAX_TLV_LEN || length < 1)
2105                                                 {       /* invalid tlv info */
2106                                                         if(check_col(pinfo->cinfo, COL_INFO))
2107                                                         {
2108                                                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "PHS n Rule TLV error");
2109                                                         }
2110                                                         proto_tree_add_item(tlv_tree, hf_cst_invalid_tlv, tvb, offset, (tlv_len - tlv_offset), FALSE);
2111                                                         break;
2112                                                 }
2113 #ifdef DEBUG /* for debug only */
2114                                                 proto_tree_add_protocol_format(csper_tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len+2+get_tlv_size_of_length(&tlv_info)), "PHS Rule TLV Type: %u (%u bytes, offset=%u, tlv_len=%u)", tlv_type, length, offset, tlv_len);
2115 #endif
2116                                                 /* update the offset */
2117                                                 tlv_offset += get_tlv_value_offset(&tlv_info);
2118                                                 switch (tlv_type)
2119                                                 {
2120                                                         case CST_PHS_PHSI:
2121                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_phs_phsi, tvb, tlv_offset, length, FALSE);
2122                                                                 proto_tree_add_item(ti_tree, hf_cst_phs_phsi, tvb, tlv_offset, length, FALSE);
2123                                                         break;
2124                                                         case CST_PHS_PHSF:
2125                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_phs_phsf, tvb, tlv_offset, length, FALSE);
2126                                                                 proto_tree_add_item(ti_tree, hf_cst_phs_phsf, tvb, tlv_offset, length, FALSE);
2127                                                         break;
2128                                                         case CST_PHS_PHSM:
2129                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_phs_phsm, tvb, tlv_offset, length, FALSE);
2130                                                                 proto_tree_add_item(ti_tree, hf_cst_phs_phsm, tvb, tlv_offset, length, FALSE);
2131                                                         break;
2132                                                         case CST_PHS_PHSS:
2133                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_phs_phss, tvb, tlv_offset, length, FALSE);
2134                                                                 proto_tree_add_item(ti_tree, hf_cst_phs_phss, tvb, tlv_offset, length, FALSE);
2135                                                         break;
2136                                                         case CST_PHS_PHSV:
2137                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_phs_phsv, tvb, tlv_offset, length, FALSE);
2138                                                                 proto_tree_add_item(ti_tree, hf_cst_phs_phsv, tvb, tlv_offset, length, FALSE);
2139                                                         break;
2140                                                         case CST_PHS_VENDOR_SPEC:
2141                                                                 ti_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tlv_tree, hf_cst_phs_vendor_spec, tvb, tlv_offset, length, FALSE);
2142                                                                 proto_tree_add_item(ti_tree, hf_cst_phs_vendor_spec, tvb, tlv_offset, length, FALSE);
2143                                                         break;
2144                                                 }
2145                                                 tlv_offset += length;
2146                                         }
2147                                         break;
2148                                 }
2149                                 default:
2150                                         /* display the unknown csper type in hex */
2151                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_cst_encoding_rules, tree, hf_csper_unknown_type, tvb, offset, tlv_len, FALSE);
2152                                         proto_tree_add_item(tlv_tree, hf_csper_unknown_type, tvb, offset, tlv_len, FALSE);
2153                                 break;
2154                         }       /* end of switch */
2155                 }       /* end of if */
2156                 offset += tlv_len;
2157         }       /* end of while loop */
2158 }
2159
2160 /**************************************************************/
2161 /* wimax_service_flow_encodings_decoder()                     */
2162 /* decode and display the WiMax Service Flow Encodings        */
2163 /* parameter:                                                 */
2164 /*   tvb - pointer of the tvb of service flow encodings       */
2165 /*   tree - pointer of Wireshark display tree                 */
2166 /*   pinfo - pointer of Wireshark packet information structure*/
2167 /**************************************************************/
2168 void wimax_service_flow_encodings_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2169 {
2170         guint offset, i;
2171         guint tvb_len, tlv_len, tlv_value_offset, tlv_value;
2172         gint  tlv_type;
2173         guint value;
2174         proto_item *tlv_item = NULL;
2175         proto_tree *tlv_tree = NULL;
2176         tlv_info_t tlv_info;
2177
2178         /* get the tvb reported length */
2179         tvb_len = tvb_reported_length(tvb);
2180 #ifdef DEBUG /* for debug only */
2181         /* display dissector information */
2182         proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, 0, tvb_len, "WiMax Service Flow Encodings (%u bytes)", tvb_len);
2183 #endif
2184         /* process WiMax Service Flow Encodings */
2185         offset = 0;
2186         /* do nothing if the TLV fields is not exist */
2187         if(!tvb_len)
2188                 return;
2189         /* report error if the packet size is less than 2 bytes (type+length) */
2190         if(tvb_len < 2)
2191         {       /* invalid tlv info */
2192                 if(check_col(pinfo->cinfo, COL_INFO))
2193                 {
2194                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Service Flow Encodings");
2195                 }
2196                 return;
2197         }
2198         while(offset < tvb_len)
2199         {       /* get the TLV information */
2200                 init_tlv_info(&tlv_info, tvb, offset);
2201                 /* get the TLV type */
2202                 tlv_type = get_tlv_type(&tlv_info);
2203                 /* get the TLV length */
2204                 tlv_len = get_tlv_length(&tlv_info);
2205                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
2206                 {       /* invalid tlv info */
2207                         if(check_col(pinfo->cinfo, COL_INFO))
2208                         {
2209                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Service Flow Encodings TLV error");
2210                         }
2211                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
2212                         break;
2213                 }
2214                 /* get the TLV value offset */
2215                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
2216 #ifdef DEBUG /* for debug only */
2217                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Service Flow Encodings TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, tlv_len, offset, tvb_len);
2218 #endif
2219                 /* update the offset */
2220                 offset += tlv_value_offset;
2221                 /* parse the Service Flow Encodings TLV */
2222                 switch (tlv_type)
2223                 {
2224                         case SFE_SF_ID:
2225                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_sf_id, tvb, offset, tlv_len, FALSE);
2226                                 proto_tree_add_item(tlv_tree, hf_sfe_sf_id, tvb, offset, tlv_len, FALSE);
2227                         break;
2228                         case SFE_CID:
2229                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_cid, tvb, offset, tlv_len, FALSE);
2230                                 proto_tree_add_item(tlv_tree, hf_sfe_cid, tvb, offset, tlv_len, FALSE);
2231                         break;
2232                         case SFE_SERVICE_CLASS_NAME:
2233                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_service_class_name, tvb, offset, tlv_len, FALSE);
2234                                 proto_tree_add_item(tlv_tree, hf_sfe_service_class_name, tvb, offset, tlv_len, FALSE);
2235                         break;
2236                         case SFE_MBS_SERVICE:
2237                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_mbs_service, tvb, offset, tlv_len, FALSE);
2238                                 proto_tree_add_item(tlv_tree, hf_sfe_mbs_service, tvb, offset, tlv_len, FALSE);
2239                         break;
2240                         case SFE_QOS_PARAMS_SET:
2241                                 /* add TLV subtree */
2242                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_qos_params_set, tvb, offset, tlv_len, FALSE);
2243                                 proto_tree_add_item(tlv_tree, hf_sfe_set_provisioned, tvb, offset, 1, FALSE);
2244                                 proto_tree_add_item(tlv_tree, hf_sfe_set_admitted, tvb, offset, 1, FALSE);
2245                                 proto_tree_add_item(tlv_tree, hf_sfe_set_active, tvb, offset, 1, FALSE);
2246                                 proto_tree_add_item(tlv_tree, hf_sfe_set_rsvd, tvb, offset, 1, FALSE);
2247                         break;
2248                         case SFE_TRAFFIC_PRIORITY:
2249                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_traffic_priority, tvb, offset, tlv_len, FALSE);
2250                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_traffic_priority, tvb, offset, tlv_len, FALSE);
2251                                 proto_item_append_text(tlv_item, " (allowed values are 0-7)");
2252                         break;
2253                         case SFE_MAX_STR:
2254                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_max_str, tvb, offset, tlv_len, FALSE);
2255                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_max_str, tvb, offset, tlv_len, FALSE);
2256                                 proto_item_append_text(tlv_item, " bps");
2257                         break;
2258                         case SFE_MAX_TRAFFIC_BURST:
2259                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_max_traffic_burst, tvb, offset, tlv_len, FALSE);
2260                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_max_traffic_burst, tvb, offset, tlv_len, FALSE);
2261                                 proto_item_append_text(tlv_item, " bytes");
2262                         break;
2263                         case SFE_MIN_RTR:
2264                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_min_rtr, tvb, offset, tlv_len, FALSE);
2265                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_min_rtr, tvb, offset, tlv_len, FALSE);
2266                                 proto_item_append_text(tlv_item, " bps");
2267                         break;
2268                         case SFE_RESERVED_10:
2269                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_reserved_10, tvb, offset, tlv_len, FALSE);
2270                                 proto_tree_add_item(tlv_tree, hf_sfe_reserved_10, tvb, offset, tlv_len, FALSE);
2271                         break;
2272                         case SFE_UL_SCHEDULING:
2273                                 /* TODO: Find a way to get the correct service type from the TLV */
2274                                 tlv_value = tvb_get_guint8(tvb, offset);
2275                                 set_service_type( tlv_value );
2276                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_ul_grant_scheduling, tvb, offset, tlv_len, FALSE);
2277                                 proto_tree_add_item(tlv_tree, hf_sfe_ul_grant_scheduling, tvb, offset, tlv_len, FALSE);
2278                         break;
2279                         case SFE_TX_POLICY:
2280                                 /* add TLV subtree */
2281                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_req_tx_policy, tvb, offset, tlv_len, FALSE);
2282                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_broadcast_bwr, tvb, offset, 1, FALSE);
2283                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_multicast_bwr, tvb, offset, 1, FALSE);
2284                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_piggyback, tvb, offset, 1, FALSE);
2285                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_fragment, tvb, offset, 1, FALSE);
2286                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_headers, tvb, offset, 1, FALSE);
2287                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_packing, tvb, offset, 1, FALSE);
2288                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_crc, tvb, offset, 1, FALSE);
2289                                 proto_tree_add_item(tlv_tree, hf_sfe_policy_rsvd1, tvb, offset, 1, FALSE);
2290                         break;
2291                         case SFE_TOLERATED_JITTER:
2292                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_jitter, tvb, offset, tlv_len, FALSE);
2293                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_jitter, tvb, offset, tlv_len, FALSE);
2294                                 proto_item_append_text(tlv_item, " ms");
2295                         break;
2296                         case SFE_MAX_LATENCY:
2297                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_max_latency, tvb, offset, tlv_len, FALSE);
2298                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_max_latency, tvb, offset, tlv_len, FALSE);
2299                                 proto_item_append_text(tlv_item, " ms");
2300                         break;
2301                         case SFE_FIXED_LEN_SDU:
2302                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_fixed_len_sdu, tvb, offset, tlv_len, FALSE);
2303                                 proto_tree_add_item(tlv_tree, hf_sfe_fixed_len_sdu, tvb, offset, tlv_len, FALSE);
2304                         break;
2305                         case SFE_SDU_SIZE:
2306                                 /* save the SDU size */
2307                                 mac_sdu_length = tvb_get_guint8(tvb, offset);
2308                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_sdu_size, tvb, offset, tlv_len, FALSE);
2309                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_sdu_size, tvb, offset, tlv_len, FALSE);
2310                                 proto_item_append_text(tlv_item, " bytes");
2311                         break;
2312                         case SFE_TARGET_SAID:
2313                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_target_said, tvb, offset, tlv_len, FALSE);
2314                                 proto_tree_add_item(tlv_tree, hf_sfe_target_said, tvb, offset, tlv_len, FALSE);
2315                         break;
2316                         case SFE_ARQ_ENABLE:
2317                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_enable, tvb, offset, tlv_len, FALSE);
2318                                 proto_tree_add_item(tlv_tree, hf_sfe_arq_enable, tvb, offset, tlv_len, FALSE);
2319                         break;
2320                         case SFE_ARQ_WINDOW_SIZE:
2321                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_window_size, tvb, offset, tlv_len, FALSE);
2322                                 proto_tree_add_item(tlv_tree, hf_sfe_arq_window_size, tvb, offset, tlv_len, FALSE);
2323                         break;
2324                         case SFE_ARQ_TRANSMITTER_DELAY:
2325                                 if (include_cor2_changes)
2326                                 {
2327                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_transmitter_delay_cor2, tvb, offset, tlv_len, FALSE);
2328                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_transmitter_delay_cor2, tvb, offset, tlv_len, FALSE);
2329                                 }
2330                                 else
2331                                 {
2332                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_transmitter_delay, tvb, offset, tlv_len, FALSE);
2333                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_transmitter_delay, tvb, offset, tlv_len, FALSE);
2334                                 }
2335                         break;
2336                         case SFE_ARQ_RECEIVER_DELAY:
2337                                 if (include_cor2_changes)
2338                                 {
2339                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_receiver_delay_cor2, tvb, offset, tlv_len, FALSE);
2340                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_receiver_delay_cor2, tvb, offset, tlv_len, FALSE);
2341                                 }
2342                                 else
2343                                 {
2344                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_receiver_delay, tvb, offset, tlv_len, FALSE);
2345                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_receiver_delay, tvb, offset, tlv_len, FALSE);
2346                                 }
2347                         break;
2348                         case SFE_ARQ_BLOCK_LIFETIME:
2349                                 if (include_cor2_changes)
2350                                 {
2351                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_block_lifetime_cor2, tvb, offset, tlv_len, FALSE);
2352                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_block_lifetime_cor2, tvb, offset, tlv_len, FALSE);
2353                                 }
2354                                 else
2355                                 {
2356                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_block_lifetime, tvb, offset, tlv_len, FALSE);
2357                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_block_lifetime, tvb, offset, tlv_len, FALSE);
2358                                 }
2359                         break;
2360                         case SFE_ARQ_SYNC_LOSS_TIMEOUT:
2361                                 if (include_cor2_changes)
2362                                 {
2363                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_sync_loss_timeout_cor2, tvb, offset, tlv_len, FALSE);
2364                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_sync_loss_timeout_cor2, tvb, offset, tlv_len, FALSE);
2365                                 }
2366                                 else
2367                                 {
2368                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_sync_loss_timeout, tvb, offset, tlv_len, FALSE);
2369                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_sync_loss_timeout, tvb, offset, tlv_len, FALSE);
2370                                 }
2371                         break;
2372                         case SFE_ARQ_DELIVER_IN_ORDER:
2373                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_deliver_in_order, tvb, offset, tlv_len, FALSE);
2374                                 proto_tree_add_item(tlv_tree, hf_sfe_arq_deliver_in_order, tvb, offset, tlv_len, FALSE);
2375                         break;
2376                         case SFE_ARQ_RX_PURGE_TIMEOUT:
2377                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_rx_purge_timeout, tvb, offset, tlv_len, FALSE);
2378                                 proto_tree_add_item(tlv_tree, hf_sfe_arq_rx_purge_timeout, tvb, offset, tlv_len, FALSE);
2379                         break;
2380                         case SFE_ARQ_BLOCK_SIZE:
2381                                 if (include_cor2_changes)
2382                                 {
2383                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_block_size_cor2, tvb, offset, tlv_len, FALSE);
2384                                         tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_arq_block_size_cor2, tvb, offset, tlv_len, FALSE);
2385                                         /* add TLV subtree */
2386                                         tlv_tree = proto_item_add_subtree(tlv_item, ett_wimax_service_flow_encodings);
2387                                         value = tvb_get_guint8(tvb, offset);
2388                                         tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_arq_min_block_size, tvb, offset, 1, FALSE);
2389                                         /* Size is 2^((value & 0x0F) + 4)) */
2390                                         proto_item_append_text(tlv_item, " ( %d bytes )", 0x10 << (value & 0x0F));
2391                                         tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_arq_max_block_size, tvb, offset, 1, FALSE);
2392                                         if (value & 0xF0)
2393                                                 /* Size is 2^(((value & 0xF0) >> 4) + 4)) */
2394                                                 proto_item_append_text(tlv_item, " ( %d bytes )", 0x10 << ((value & 0xF0) >> 4));
2395                                 }
2396                                 else
2397                                 {
2398                                         tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_arq_block_size, tvb, offset, tlv_len, FALSE);
2399                                         proto_tree_add_item(tlv_tree, hf_sfe_arq_block_size, tvb, offset, tlv_len, FALSE);
2400                                 }
2401                         break;
2402                         case SFE_CS_SPECIFICATION:
2403                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_cs_specification, tvb, offset, tlv_len, FALSE);
2404                                 proto_tree_add_item(tlv_tree, hf_sfe_cs_specification, tvb, offset, tlv_len, FALSE);
2405                         break;
2406                         case SFE_TYPE_OF_DATA_DELIVERY_SERVICES:
2407                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_type_of_data_delivery_services, tvb, offset, tlv_len, FALSE);
2408                                 proto_tree_add_item(tlv_tree, hf_sfe_type_of_data_delivery_services, tvb, offset, tlv_len, FALSE);
2409                         break;
2410                         case SFE_SDU_INTER_ARRIVAL_INTERVAL:
2411                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_sdu_inter_arrival_interval, tvb, offset, tlv_len, FALSE);
2412                                 proto_tree_add_item(tlv_tree, hf_sfe_sdu_inter_arrival_interval, tvb, offset, tlv_len, FALSE);
2413                         break;
2414                         case SFE_TIME_BASE:
2415                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_time_base, tvb, offset, tlv_len, FALSE);
2416                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_time_base, tvb, offset, tlv_len, FALSE);
2417                                 proto_item_append_text(tlv_item, " ms");
2418                         break;
2419                         case SFE_PAGING_PREFERENCE:
2420                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_paging_preference, tvb, offset, tlv_len, FALSE);
2421                                 proto_tree_add_item(tlv_tree, hf_sfe_paging_preference, tvb, offset, tlv_len, FALSE);
2422                         break;
2423                         case SFE_MBS_ZONE_IDENTIFIER_ASSIGNMENT:
2424                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_mbs_zone_identifier_assignment, tvb, offset, tlv_len, FALSE);
2425                                 proto_tree_add_item(tlv_tree, hf_sfe_mbs_zone_identifier_assignment, tvb, offset, tlv_len, FALSE);
2426                         break;
2427                         case SFE_RESERVED_34:
2428                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_reserved_34, tvb, offset, tlv_len, FALSE);
2429                                 proto_tree_add_item(tlv_tree, hf_sfe_reserved_34, tvb, offset, tlv_len, FALSE);
2430                         break;
2431                         case SFE_GLOBAL_SERVICE_CLASS_NAME:
2432                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_global_service_class_name, tvb, offset, tlv_len, FALSE);
2433                                 proto_tree_add_item(tlv_tree, hf_sfe_global_service_class_name, tvb, offset, tlv_len, FALSE);
2434                         break;
2435 /* 36 reserved */
2436                         case SFE_RESERVED_36:
2437                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_reserved_36, tvb, offset, tlv_len, FALSE);
2438                                 proto_tree_add_item(tlv_tree, hf_sfe_reserved_36, tvb, offset, tlv_len, FALSE);
2439                         break;
2440
2441                         case SFE_SN_FEEDBACK_ENABLED:
2442                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_sn_feedback_enabled, tvb, offset, tlv_len, FALSE);
2443                                 proto_tree_add_item(tlv_tree, hf_sfe_sn_feedback_enabled, tvb, offset, tlv_len, FALSE);
2444                         break;
2445                         case SFE_FSN_SIZE:
2446                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_fsn_size, tvb, offset, tlv_len, FALSE);
2447                                 proto_tree_add_item(tlv_tree, hf_sfe_fsn_size, tvb, offset, tlv_len, FALSE);
2448                         break;
2449                         case SFE_CID_ALLOCATION_FOR_ACTIVE_BS:
2450                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_cid_alloc_for_active_bs_cid, tvb, offset, tlv_len, FALSE);
2451                                 for(i = 0; i < tlv_len; i+=2)
2452                                         proto_tree_add_item(tlv_tree, hf_sfe_cid_alloc_for_active_bs_cid, tvb, (offset+i), 2, FALSE);
2453                         break;
2454                         case SFE_UNSOLICITED_GRANT_INTERVAL:
2455                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_unsolicited_grant_interval, tvb, offset, tlv_len, FALSE);
2456                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_unsolicited_grant_interval, tvb, offset, tlv_len, FALSE);
2457                                 proto_item_append_text(tlv_item, " ms");
2458                         break;
2459                         case SFE_UNSOLOCITED_POLLING_INTERVAL:
2460                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_unsolicited_polling_interval, tvb, offset, tlv_len, FALSE);
2461                                 tlv_item = proto_tree_add_item(tlv_tree, hf_sfe_unsolicited_polling_interval, tvb, offset, tlv_len, FALSE);
2462                                 proto_item_append_text(tlv_item, " ms");
2463                         break;
2464                         case SFE_PDU_SN_EXT_SUBHEADER_HARQ_REORDER:
2465                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_pdu_sn_ext_subheader_reorder, tvb, offset, tlv_len, FALSE);
2466                                 proto_tree_add_item(tlv_tree, hf_sfe_pdu_sn_ext_subheader_reorder, tvb, offset, tlv_len, FALSE);
2467                         break;
2468                         case SFE_MBS_CONTENTS_ID:
2469                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_mbs_contents_ids, tvb, offset, tlv_len, FALSE);
2470                                 proto_tree_add_item(tlv_tree, hf_sfe_mbs_contents_ids, tvb, offset, tlv_len, FALSE);
2471                                 for(i = 0; i < tlv_len; i+=2)
2472                                         proto_tree_add_item(tlv_tree, hf_sfe_mbs_contents_ids_id, tvb, (offset+i), 2, FALSE);
2473                         break;
2474                         case SFE_HARQ_SERVICE_FLOWS:
2475                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_harq_service_flows, tvb, offset, tlv_len, FALSE);
2476                                 proto_tree_add_item(tlv_tree, hf_sfe_harq_service_flows, tvb, offset, tlv_len, FALSE);
2477                         break;
2478                         case SFE_AUTHORIZATION_TOKEN:
2479                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_authorization_token, tvb, offset, tlv_len, FALSE);
2480                                 proto_tree_add_item(tlv_tree, hf_sfe_authorization_token, tvb, offset, tlv_len, FALSE);
2481                         break;
2482                         case SFE_HARQ_CHANNEL_MAPPING:
2483                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_harq_channel_mapping_index, tvb, offset, tlv_len, FALSE);
2484                                 for(i = 0; i < tlv_len; i++)
2485                                         proto_tree_add_item(tlv_tree, hf_sfe_harq_channel_mapping_index, tvb, (offset+i), 1, FALSE);
2486                         break;
2487 /* 99 - 111 CS parameter encodings */
2488                         case SFE_CSPER_ATM:
2489                         case SFE_CSPER_PACKET_IPV4:
2490                         case SFE_CSPER_PACKET_IPV6:
2491                         case SFE_CSPER_PACKET_802_3:
2492                         case SFE_CSPER_PACKET_802_1Q:
2493                         case SFE_CSPER_PACKET_IPV4_802_3:
2494                         case SFE_CSPER_PACKET_IPV6_802_3:
2495                         case SFE_CSPER_PACKET_IPV4_802_1Q:
2496                         case SFE_CSPER_PACKET_IPV6_802_1Q:
2497                         case SFE_CSPER_PACKET_IP_ROCH_COMPRESSION:
2498                         case SFE_CSPER_PACKET_IP_ECRTP_COMPRESSION:
2499                         case SFE_CSPER_PACKET_IP_802_3_ROCH_COMPRESSION:
2500                         case SFE_CSPER_PACKET_IP_802_3_ECRTP_COMPRESSION:
2501                                 /* call CS Parameter Encoding Rules handling function */
2502                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "CS Parameter Encoding Rules (%u byte(s))", tlv_len);
2503                                 wimax_convengence_service_parameter_encoding_rules_decoder(tlv_type, tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2504                         break;
2505                         default:
2506                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_wimax_service_flow_encodings, tree, hf_sfe_unknown_type, tvb, offset, tlv_len, FALSE);
2507                                 /* display the unknown sfe type in hex */
2508                                 proto_tree_add_item(tlv_tree, hf_sfe_unknown_type, tvb, offset, tlv_len, FALSE);
2509                         break;
2510                 }       /* end of switch */
2511                 offset += tlv_len;
2512         }       /* end of while loop */
2513 }
2514
2515 /**************************************************************/
2516 /* wimax_hmac_tuple_decoder()                                 */
2517 /* decode and display the WiMax HMAC Tuple (Table 348)        */
2518 /* parameter:                                                 */
2519 /*   tree - pointer of Wireshark display tree                 */
2520 /*   tvb - pointer of the tvb which contains the HMAC Tuple   */
2521 /*   offset - the HMAC Tuple offset in the tvb                */
2522 /*   length - length of the HMAC Tuple                        */
2523 /**************************************************************/
2524 void wimax_hmac_tuple_decoder(proto_tree *tree, tvbuff_t *tvb, guint offset, guint length)
2525 {
2526         guint hmac_offset;
2527         proto_item *hmac_item = NULL;
2528         proto_tree *hmac_tree = NULL;
2529
2530         /* display decoder info (length should be 21 bytes) */
2531         hmac_item = proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, length, "HMAC Tuple (%u bytes)", length);
2532         /* add HMAC subtree */
2533         hmac_tree = proto_item_add_subtree(hmac_item, ett_wimax_hmac_tuple);
2534         /* init the local offset */
2535         hmac_offset = offset;
2536         /* decode and display HMAC Tuple */
2537         proto_tree_add_item(hmac_tree, hf_xmac_tuple_rsvd, tvb, hmac_offset, 1, FALSE);
2538         proto_tree_add_item(hmac_tree, hf_xmac_tuple_key_seq_num, tvb, hmac_offset, 1, FALSE);
2539         hmac_offset++;
2540         proto_tree_add_item(hmac_tree, hf_hmac_tuple_hmac_digest, tvb, hmac_offset, (length-1), FALSE);
2541 }
2542
2543 /**************************************************************/
2544 /* wimax_cmac_tuple_decoder()                                 */
2545 /* decode and display the WiMax CMAC Tuple (Table 348b)       */
2546 /* parameter:                                                 */
2547 /*   tree - pointer of Wireshark display tree                 */
2548 /*   tvb - pointer of the tvb which contains the CMAC Tuple   */
2549 /*   offset - the CMAC Tuple offset in the tvb                */
2550 /*   length - length of the CMAC Tuple                        */
2551 /**************************************************************/
2552 void wimax_cmac_tuple_decoder(proto_tree *tree, tvbuff_t *tvb, guint offset, guint length)
2553 {
2554         guint cmac_offset;
2555         proto_item *cmac_item = NULL;
2556         proto_tree *cmac_tree = NULL;
2557
2558         /* display decoder info (length should be 13 or 19 bytes) */
2559         cmac_item = proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, length, "CMAC Tuple (%u bytes)", length);
2560         /* add CMAC subtree */
2561         cmac_tree = proto_item_add_subtree(cmac_item, ett_wimax_cmac_tuple);
2562         /* init the local offset */
2563         cmac_offset = offset;
2564         /* decode and display CMAC Tuple */
2565         proto_tree_add_item(cmac_tree, hf_xmac_tuple_rsvd, tvb, cmac_offset, 1, FALSE);
2566         proto_tree_add_item(cmac_tree, hf_xmac_tuple_key_seq_num, tvb, cmac_offset, 1, FALSE);
2567         cmac_offset++;
2568         if(length > 13)
2569         {
2570                 proto_tree_add_item(cmac_tree, hf_cmac_tuple_bsid, tvb, cmac_offset, 6, FALSE);
2571                 cmac_offset += 6;
2572         }
2573         proto_tree_add_item(cmac_tree, hf_packet_number_counter, tvb, cmac_offset, 4, FALSE);
2574         cmac_offset += 4;
2575         proto_tree_add_item(cmac_tree, hf_cmac_tuple_cmac_value, tvb, cmac_offset, 8, FALSE);
2576 }
2577
2578 /******************************************************************/
2579 /* wimax_short_hmac_tuple_decoder()                               */
2580 /* decode and display the WiMax Short-HMAC Tuple (Table 348d)     */
2581 /* parameter:                                                     */
2582 /*   tree - pointer of Wireshark display tree                     */
2583 /*   tvb - pointer of the tvb which contains the Short-HMAC Tuple */
2584 /*   offset - the Short-HMAC Tuple offset in the tvb              */
2585 /*   length - length of the Short-HMAC Tuple                      */
2586 /******************************************************************/
2587 void wimax_short_hmac_tuple_decoder(proto_tree *tree, tvbuff_t *tvb, guint offset, guint length)
2588 {
2589         guint hmac_offset;
2590         proto_item *hmac_item = NULL;
2591         proto_tree *hmac_tree = NULL;
2592
2593         /* display decoder info (length should be at least 13 bytes ???) */
2594         hmac_item = proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, length, "Short-HMAC Tuple (%u bytes)", length);
2595         /* add Short-HMAC subtree */
2596         hmac_tree = proto_item_add_subtree(hmac_item, ett_wimax_short_hmac_tuple);
2597         /* init the local offset */
2598         hmac_offset = offset;
2599         /* decode and display Short-HMAC Tuple */
2600         proto_tree_add_item(hmac_tree, hf_xmac_tuple_rsvd, tvb, hmac_offset, 1, FALSE);
2601         proto_tree_add_item(hmac_tree, hf_xmac_tuple_key_seq_num, tvb, hmac_offset, 1, FALSE);
2602         hmac_offset++;
2603         proto_tree_add_item(hmac_tree, hf_packet_number_counter, tvb, hmac_offset, 4, FALSE);
2604         hmac_offset += 4;
2605         proto_tree_add_item(hmac_tree, hf_hmac_tuple_hmac_digest, tvb, hmac_offset, length - offset - 3, FALSE);
2606 }
2607
2608 /******************************************************************/
2609 /* wimax_security_negotiation_parameters_decoder()                */
2610 /* decode and display the WiMax Security Negotiation Parameters   */
2611 /* parameter:                                                     */
2612 /*   tvb - pointer of the tvb of service flow encodings           */
2613 /*   tree - pointer of Wireshark display tree                     */
2614 /*   pinfo - pointer of Wireshark packet information structure    */
2615 /******************************************************************/
2616 void wimax_security_negotiation_parameters_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2617 {
2618         guint offset;
2619         guint tvb_len, tlv_len, tlv_value_offset;
2620         gint  tlv_type;
2621         proto_tree *tlv_tree = NULL;
2622         tlv_info_t tlv_info;
2623
2624         /* get the tvb reported length */
2625         tvb_len = tvb_reported_length(tvb);
2626         /* do nothing if the TLV fields is not exist */
2627         if(!tvb_len)
2628                 return;
2629         /* report error if the packet size is less than 2 bytes (type+length) */
2630         if(tvb_len < 2)
2631         {       /* invalid tlv info */
2632                 if(check_col(pinfo->cinfo, COL_INFO))
2633                 {
2634                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Security Negotiation Parameters");
2635                 }
2636                 return;
2637         }
2638         /* process Security Negotiation Parameter TLVs */
2639         for(offset = 0; offset < tvb_len; )
2640         {
2641                 /* get the TLV information */
2642                 init_tlv_info(&tlv_info, tvb, offset);
2643                 /* get the TLV type */
2644                 tlv_type = get_tlv_type(&tlv_info);
2645                 /* get the TLV length */
2646                 tlv_len = get_tlv_length(&tlv_info);
2647                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
2648                 {       /* invalid tlv info */
2649                         if(check_col(pinfo->cinfo, COL_INFO))
2650                         {
2651                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Security Negotiation Params TLV error");
2652                         }
2653                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
2654                         break;
2655                 }
2656                 /* get the TLV value offset */
2657                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
2658 #ifdef DEBUG /* for debug only */
2659                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Security Negotiation Parameters Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
2660 #endif
2661                 /* update the offset */
2662                 offset += tlv_value_offset;
2663                 /* parse Security Negotiation Parameters TLVs */
2664                 switch (tlv_type)
2665                 {
2666                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_PKM_VERSION_SUPPORT:
2667                         /* add TLV subtree */
2668                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_pkm_version_support, tvb, offset, tlv_len, FALSE);
2669                         proto_tree_add_item(tlv_tree, hf_snp_pkm_version_support_bit0, tvb, offset, 1, FALSE);
2670                         proto_tree_add_item(tlv_tree, hf_snp_pkm_version_support_bit1, tvb, offset, 1, FALSE);
2671                         proto_tree_add_item(tlv_tree, hf_snp_pkm_version_support_reserved, tvb, offset, 1, FALSE);
2672                 break;
2673                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_AUTHORIZATION_POLICY_SUPPORT:
2674                         /* add TLV subtree */
2675                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_auth_policy_support, tvb, offset, tlv_len, FALSE);
2676                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit0, tvb, offset, 1, FALSE);
2677                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit1, tvb, offset, 1, FALSE);
2678                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit2, tvb, offset, 1, FALSE);
2679                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit3, tvb, offset, 1, FALSE);
2680                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit4, tvb, offset, 1, FALSE);
2681                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit5, tvb, offset, 1, FALSE);
2682                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit6, tvb, offset, 1, FALSE);
2683                         proto_tree_add_item(tlv_tree, hf_snp_auth_policy_support_bit7, tvb, offset, 1, FALSE);
2684                 break;
2685                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_MESSAGE_AUTHENTICATION_CODE:
2686                         /* add TLV subtree */
2687                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_mac_mode, tvb, offset, tlv_len, FALSE);
2688                         proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit0, tvb, offset, 1, FALSE);
2689                         if (include_cor2_changes)
2690                         {
2691                                 proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit1_rsvd, tvb, offset, 1, FALSE);
2692                         }
2693                         else
2694                         {
2695                                 proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit1, tvb, offset, 1, FALSE);
2696                         }
2697                         proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit2, tvb, offset, 1, FALSE);
2698                         proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit3, tvb, offset, 1, FALSE);
2699                         proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit4, tvb, offset, 1, FALSE);
2700                         if (include_cor2_changes)
2701                         {
2702                                 proto_tree_add_item(tlv_tree, hf_snp_mac_mode_bit5, tvb, offset, 1, FALSE);
2703                                 proto_tree_add_item(tlv_tree, hf_snp_mac_mode_reserved1, tvb, offset, 1, FALSE);
2704                         }
2705                         else
2706                         {
2707                                 proto_tree_add_item(tlv_tree, hf_snp_mac_mode_reserved, tvb, offset, 1, FALSE);
2708                         }
2709                 break;
2710                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_PN_WINDOW_SIZE:
2711                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_pn_window_size, tvb, offset, tlv_len, FALSE);
2712                         proto_tree_add_item(tlv_tree, hf_snp_pn_window_size, tvb, offset, tlv_len, FALSE);
2713                 break;
2714                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_PKM_FLOW_CONTROL:
2715                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_max_conc_transactions, tvb, offset, tlv_len, FALSE);
2716                         proto_tree_add_item(tlv_tree, hf_snp_max_conc_transactions, tvb, offset, 1, FALSE);
2717                 break;
2718                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_MAX_SUPPT_SECURITY_ASSNS:
2719                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_max_suppt_sec_assns, tvb, offset, tlv_len, FALSE);
2720                         proto_tree_add_item(tlv_tree, hf_snp_max_suppt_sec_assns, tvb, offset, 1, FALSE);
2721                 break;
2722                 default:
2723                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_unknown_type, tvb, offset, tlv_len, FALSE);
2724                         proto_tree_add_item(tlv_tree, hf_snp_unknown_type, tvb, offset, tlv_len, FALSE);
2725                 break;
2726                 }
2727                 offset += tlv_len;
2728         }
2729 }
2730
2731 /******************************************************************/
2732 /* wimax_cryptographic_suite_list_decoder()                       */
2733 /* decode and display the WiMax Cryptographic Suite List           */
2734 /* parameter:                                                     */
2735 /*   tvb - pointer of the tvb of service flow encodings           */
2736 /*   tree - pointer of Wireshark display tree                     */
2737 /*   pinfo - pointer of Wireshark packet information structure    */
2738 /******************************************************************/
2739 void wimax_cryptographic_suite_list_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2740 {
2741         guint offset;
2742         guint tvb_len, tlv_len, tlv_value_offset;
2743         gint  tlv_type;
2744         proto_tree *tlv_tree = NULL;
2745         tlv_info_t tlv_info;
2746
2747         /* get the tvb reported length */
2748         tvb_len = tvb_reported_length(tvb);
2749         /* do nothing if the TLV fields is not exist */
2750         if(!tvb_len)
2751                 return;
2752         /* report error if the packet size is less than 2 bytes (type+length) */
2753         if(tvb_len < 2)
2754         {       /* invalid tlv info */
2755                 if(check_col(pinfo->cinfo, COL_INFO))
2756                 {
2757                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Crypto Suite List");
2758                 }
2759                 return;
2760         }
2761         /* process Cryptographic Suite List (11.9.15) */
2762         for(offset = 0; offset < tvb_len; )
2763         {       /* get the TLV information */
2764                 init_tlv_info(&tlv_info, tvb, offset);
2765                 /* get the TLV type */
2766                 tlv_type = get_tlv_type(&tlv_info);
2767                 /* get the TLV length */
2768                 tlv_len = get_tlv_length(&tlv_info);
2769                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
2770                 {       /* invalid tlv info */
2771                         if(check_col(pinfo->cinfo, COL_INFO))
2772                         {
2773                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Crypto Suite List TLV error");
2774                         }
2775                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
2776                         break;
2777                 }
2778                 /* get the TLV value offset */
2779                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
2780 #ifdef DEBUG /* for debug only */
2781                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Cryptographic Suite List TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
2782 #endif
2783                 /* update the offset for the TLV value */
2784                 offset += tlv_value_offset;
2785                 /* parse Cryptographic Suite List */
2786                 switch (tlv_type)
2787                 {
2788                         case PKM_ATTR_CRYPTO_SUITE:
2789                                 /* add subtree */
2790                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_cryptographic_suite_list_decoder, tree, hf_pkm_msg_crypto_suite, tvb, offset, tlv_len, FALSE);
2791                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_msb, tvb, offset, 1, FALSE);
2792                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_middle, tvb, offset+1, 1, FALSE);
2793                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_lsb, tvb, offset+2, 1, FALSE);
2794                         break;
2795                         default:
2796                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_cryptographic_suite_list_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
2797                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
2798                         break;
2799                 }
2800                 offset += tlv_len;
2801         }       /* end of TLV process while loop */
2802 }
2803
2804 /******************************************************************/
2805 /* wimax_pkm_tlv_encoded_attributes_decoder()                     */
2806 /* decode and display the WiMax PKM message TLV Encoded Attributes*/
2807 /* parameter:                                                     */
2808 /*   tvb - pointer of the tvb of service flow encodings           */
2809 /*   tree - pointer of Wireshark display tree                     */
2810 /*   pinfo - pointer of Wireshark packet information structure    */
2811 /******************************************************************/
2812 void wimax_pkm_tlv_encoded_attributes_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2813 {
2814         guint offset;
2815         guint tvb_len, tlv_len, tlv_value_offset;
2816         gint  tlv_type;
2817         proto_tree *tlv_tree = NULL;
2818         tlv_info_t tlv_info;
2819
2820         /* get the tvb reported length */
2821         tvb_len = tvb_reported_length(tvb);
2822         /* do nothing if the TLV fields is not exist */
2823         if(!tvb_len)
2824                 return;
2825         /* report error if the packet size is less than 2 bytes (type+length) */
2826         if(tvb_len < 2)
2827         {       /* invalid tlv info */
2828                 if(check_col(pinfo->cinfo, COL_INFO))
2829                 {
2830                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid PKM TLV");
2831                 }
2832                 return;
2833         }
2834         /* process PKM message TLV Encoded Attributes (11.9) */
2835         for(offset = 0; offset < tvb_len; )
2836         {
2837                 /* get the TLV information */
2838                 init_tlv_info(&tlv_info, tvb, offset);
2839                 /* get the TLV type */
2840                 tlv_type = get_tlv_type(&tlv_info);
2841                 /* get the TLV length */
2842                 tlv_len = get_tlv_length(&tlv_info);
2843                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
2844                 {       /* invalid tlv info */
2845                         if(check_col(pinfo->cinfo, COL_INFO))
2846                         {
2847                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "PKM TLV error");
2848                         }
2849                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
2850                         break;
2851                 }
2852                 /* get the TLV value offset */
2853                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
2854 #ifdef DEBUG /* for debug only */
2855                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "PKM TLV Encoded Attributes TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
2856 #endif
2857                 /* update the offset for the TLV value */
2858                 offset += tlv_value_offset;
2859                 /* parse PKM TLV Encoded Attributes (table 370) */
2860                 switch (tlv_type)
2861                 {
2862                         case PKM_ATTR_DISPLAY_STRING:
2863                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_display, tvb, offset, tlv_len, FALSE);
2864                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_display, tvb, offset, tlv_len, FALSE);
2865                         break;
2866                         case PKM_ATTR_AUTH_KEY:
2867                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_auth_key, tvb, offset, tlv_len, FALSE);
2868                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_auth_key, tvb, offset, tlv_len, FALSE);
2869                         break;
2870                         case PKM_ATTR_TEK:
2871                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
2872                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
2873                         break;
2874                         case PKM_ATTR_KEY_LIFE_TIME:
2875                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_key_life_time, tvb, offset, tlv_len, FALSE);
2876                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_life_time, tvb, offset, tlv_len, FALSE);
2877                         break;
2878                         case PKM_ATTR_KEY_SEQ_NUM:
2879                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_key_seq_num, tvb, offset, tlv_len, FALSE);
2880                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_seq_num, tvb, offset, tlv_len, FALSE);
2881                         break;
2882                         case PKM_ATTR_HMAC_DIGEST:
2883                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_hmac_digest, tvb, offset, tlv_len, FALSE);
2884                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_hmac_digest, tvb, offset, tlv_len, FALSE);
2885                         break;
2886                         case PKM_ATTR_SAID:
2887                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
2888                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
2889                         break;
2890                         case PKM_ATTR_TEK_PARAM:
2891                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "TEK Parameters (%u bytes)", tlv_len);
2892                                 /* add subtree */
2893                                 wimax_tek_parameters_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2894                         break;
2895                         case PKM_ATTR_CBC_IV:
2896                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_cbc_iv, tvb, offset, tlv_len, FALSE);
2897                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_cbc_iv, tvb, offset, tlv_len, FALSE);
2898                         break;
2899                         case PKM_ATTR_ERROR_CODE:
2900                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_error_code, tvb, offset, tlv_len, FALSE);
2901                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_error_code, tvb, offset, tlv_len, FALSE);
2902                         break;
2903                         case PKM_ATTR_CA_CERTIFICATE:
2904                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_ca_certificate, tvb, offset, tlv_len, FALSE);
2905                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_ca_certificate, tvb, offset, tlv_len, FALSE);
2906                         break;
2907                         case PKM_ATTR_SS_CERTIFICATE:
2908                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_ss_certificate, tvb, offset, tlv_len, FALSE);
2909                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_ss_certificate, tvb, offset, tlv_len, FALSE);
2910                         break;
2911                         case PKM_ATTR_SECURITY_CAPABILITIES:
2912                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Security Capabilities (%u bytes)", tlv_len);
2913                                 /* add subtree */
2914                                 wimax_security_capabilities_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2915                         break;
2916                         case PKM_ATTR_CRYPTO_SUITE:
2917                                 /* add subtree */
2918                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_crypto_suite, tvb, offset, tlv_len, FALSE);
2919                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_msb, tvb, offset, 1, FALSE);
2920                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_middle, tvb, offset+1, 1, FALSE);
2921                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_lsb, tvb, offset+2, 1, FALSE);
2922                         break;
2923                         case PKM_ATTR_CRYPTO_LIST:
2924                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Cryptographic-Suite List (%u bytes)", tlv_len);
2925                                 /* add subtree */
2926                                 wimax_cryptographic_suite_list_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2927                         break;
2928 #if 0 /* rserved by IEE 802.16E */
2929                         case PKM_ATTR_VERSION:
2930                                 proto_tree_add_item(tree, hf_pkm_msg_version, tvb, offset, tlv_len, FALSE);
2931                         break;
2932 #endif
2933                         case PKM_ATTR_SA_DESCRIPTOR:
2934                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "SA-Descriptor (%u bytes)", tlv_len);
2935                                 /* add subtree */
2936                                 wimax_sa_descriptor_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2937                         break;
2938                         case PKM_ATTR_SA_TYPE:
2939                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
2940                                 proto_tree_add_item(tlv_tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
2941                         break;
2942                         case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETERS:
2943                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Security Negotiation Parameters (%u bytes)", tlv_len);
2944                                 /* add subtree */
2945                                 wimax_security_negotiation_parameters_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2946                         break;
2947                         case PKM_ATTR_PKM_CONFIG_SETTINGS:
2948                                 /* add subtree */
2949                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "PKM Configuration Settings (%u bytes)", tlv_len);
2950                                 wimax_pkm_configuration_settings_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2951                         break;
2952                         case PKM_ATTR_PKM_EAP_PAYLOAD:
2953                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_eap_payload, tvb, offset, tlv_len, FALSE);
2954                                 if (eap_handle)
2955                                         call_dissector(eap_handle, tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2956                                 else
2957                                         proto_tree_add_item(tlv_tree, hf_pkm_attr_eap_payload, tvb, offset, tlv_len, FALSE);
2958                         break;
2959                         case PKM_ATTR_PKM_NONCE:
2960                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_nonce, tvb, offset, tlv_len, FALSE);
2961                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_nonce, tvb, offset, tlv_len, FALSE);
2962                         break;
2963                         case PKM_ATTR_AUTH_RESULT_CODE:
2964                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_auth_result_code, tvb, offset, tlv_len, FALSE);
2965                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_auth_result_code, tvb, offset, tlv_len, FALSE);
2966                         break;
2967                         case PKM_ATTR_SA_SERVICE_TYPE:
2968                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
2969                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
2970                         break;
2971                         case PKM_ATTR_FRAME_NUMBER:
2972                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_frame_number, tvb, offset, tlv_len, FALSE);
2973                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_frame_number, tvb, offset, tlv_len, FALSE);
2974                         break;
2975                         case PKM_ATTR_SS_RANDOM:
2976                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_ss_random, tvb, offset, tlv_len, FALSE);
2977                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_ss_random, tvb, offset, tlv_len, FALSE);
2978                         break;
2979                         case PKM_ATTR_BS_RANDOM:
2980                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_bs_random, tvb, offset, tlv_len, FALSE);
2981                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_bs_random, tvb, offset, tlv_len, FALSE);
2982                         break;
2983                         case PKM_ATTR_PRE_PAK:
2984                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_pre_pak, tvb, offset, tlv_len, FALSE);
2985                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_pre_pak, tvb, offset, tlv_len, FALSE);
2986                         break;
2987                         case PKM_ATTR_BS_CERTIFICATE:
2988                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_bs_certificate, tvb, offset, tlv_len, FALSE);
2989                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_bs_certificate, tvb, offset, tlv_len, FALSE);
2990                         break;
2991                         case PKM_ATTR_SIG_BS:
2992                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_sig_bs, tvb, offset, tlv_len, FALSE);
2993                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sig_bs, tvb, offset, tlv_len, FALSE);
2994                         break;
2995                         case PKM_ATTR_MS_MAC_ADDRESS:
2996                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_ms_mac_address, tvb, offset, tlv_len, FALSE);
2997                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_ms_mac_address, tvb, offset, tlv_len, FALSE);
2998                         break;
2999                         case PKM_ATTR_CMAC_DIGEST:
3000                                 /* add TLV subtree */
3001                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_cmac_digest, tvb, offset, tlv_len, FALSE);
3002                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_cmac_digest_pn, tvb, offset, 4, FALSE);
3003                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_cmac_digest_value, tvb, (offset + 4), 8, FALSE);
3004                         break;
3005                         case PKM_ATTR_KEY_PUSH_MODES:
3006                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_push_modes, tvb, offset, tlv_len, FALSE);
3007                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_push_modes, tvb, offset, tlv_len, FALSE);
3008                         break;
3009                         case PKM_ATTR_KEY_PUSH_COUNTER:
3010                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_key_push_counter, tvb, offset, tlv_len, FALSE);
3011                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_key_push_counter, tvb, offset, tlv_len, FALSE);
3012                         break;
3013                         case PKM_ATTR_GKEK:
3014                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_gkek, tvb, offset, tlv_len, FALSE);
3015                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_gkek, tvb, offset, tlv_len, FALSE);
3016                         break;
3017                         case PKM_ATTR_SIG_SS:
3018                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_sig_ss, tvb, offset, tlv_len, FALSE);
3019                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sig_ss, tvb, offset, tlv_len, FALSE);
3020                         break;
3021                         case PKM_ATTR_AKID:
3022                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_akid, tvb, offset, tlv_len, FALSE);
3023                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_akid, tvb, offset, tlv_len, FALSE);
3024                         break;
3025                         default:
3026                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3027                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3028                         break;
3029                 }
3030                 offset += tlv_len;
3031         }       /* end of TLV process while loop */
3032 }
3033
3034 /******************************************************************/
3035 /* wimax_tek_parameters_decoder()                                 */
3036 /* decode and display the WiMax TEK Parameters subattributes      */
3037 /* parameter:                                                     */
3038 /*   tvb - pointer of the tvb of service flow encodings           */
3039 /*   tree - pointer of Wireshark display tree                     */
3040 /*   pinfo - pointer of Wireshark packet information structure    */
3041 /******************************************************************/
3042 void wimax_tek_parameters_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3043 {
3044         guint offset;
3045         guint tvb_len, tlv_len, tlv_value_offset;
3046         gint  tlv_type;
3047         proto_tree *tlv_tree = NULL;
3048         tlv_info_t tlv_info;
3049
3050         /* get the tvb reported length */
3051         tvb_len = tvb_reported_length(tvb);
3052         /* do nothing if the TLV fields is not exist */
3053         if(!tvb_len)
3054                 return;
3055         /* report error if the packet size is less than 2 bytes (type+length) */
3056         if(tvb_len < 2)
3057         {       /* invalid tlv info */
3058                 if(check_col(pinfo->cinfo, COL_INFO))
3059                 {
3060                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid TEK Params");
3061                 }
3062                 return;
3063         }
3064         /* process PKM Message TEK Parameters (11.9.8) */
3065         for(offset = 0; offset < tvb_len; )
3066         {
3067                 /* get the TLV information */
3068                 init_tlv_info(&tlv_info, tvb, offset);
3069                 /* get the TLV type */
3070                 tlv_type = get_tlv_type(&tlv_info);
3071                 /* get the TLV length */
3072                 tlv_len = get_tlv_length(&tlv_info);
3073                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3074                 {       /* invalid tlv info */
3075                         if(check_col(pinfo->cinfo, COL_INFO))
3076                         {
3077                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "TEK Param TLV error");
3078                         }
3079                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3080                         break;
3081                 }
3082                 /* get the TLV value offset */
3083                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3084 #ifdef DEBUG /* for debug only */
3085                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "TEK Parameters Subattributes TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
3086 #endif
3087                 /* update the offset for the TLV value */
3088                 offset += tlv_value_offset;
3089                 /* parse TEK Parameters Subattributes (table 372) */
3090                 switch (tlv_type)
3091                 {
3092                         case PKM_ATTR_TEK:
3093                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
3094                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
3095                         break;
3096                         case PKM_ATTR_KEY_LIFE_TIME:
3097                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_key_life_time, tvb, offset, tlv_len, FALSE);
3098                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_life_time, tvb, offset, tlv_len, FALSE);
3099                         break;
3100                         case PKM_ATTR_KEY_SEQ_NUM:
3101                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_key_seq_num, tvb, offset, tlv_len, FALSE);
3102                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_seq_num, tvb, offset, tlv_len, FALSE);
3103                         break;
3104                         case PKM_ATTR_CBC_IV:
3105                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_cbc_iv, tvb, offset, tlv_len, FALSE);
3106                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_cbc_iv, tvb, offset, tlv_len, FALSE);
3107                         break;
3108                         case PKM_ATTR_ASSOCIATED_GKEK_SEQ_NUM:
3109                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_associated_gkek_seq_number, tvb, offset, tlv_len, FALSE);
3110                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_associated_gkek_seq_number, tvb, offset, tlv_len, FALSE);
3111                         break;
3112                         default:
3113                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3114                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3115                         break;
3116                 }
3117                 offset += tlv_len;
3118         }       /* end of TLV process while loop */
3119 }
3120
3121 /******************************************************************/
3122 /* wimax_pkm_configuration_settings_decoder()                     */
3123 /* decode and display the WiMax PKM Configuration Settings        */
3124 /* parameter:                                                     */
3125 /*   tvb - pointer of the tvb of service flow encodings           */
3126 /*   tree - pointer of Wireshark display tree                     */
3127 /*   pinfo - pointer of Wireshark packet information structure    */
3128 /******************************************************************/
3129 void wimax_pkm_configuration_settings_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3130 {
3131         guint offset;
3132         guint tvb_len, tlv_len, tlv_value_offset;
3133         gint  tlv_type;
3134         proto_tree *tlv_tree;
3135         tlv_info_t tlv_info;
3136
3137         /* get the tvb reported length */
3138         tvb_len = tvb_reported_length(tvb);
3139         /* do nothing if the TLV fields is not exist */
3140         if(!tvb_len)
3141                 return;
3142         /* report error if the packet size is less than 2 bytes (type+length) */
3143         if(tvb_len < 2)
3144         {       /* invalid tlv info */
3145                 if(check_col(pinfo->cinfo, COL_INFO))
3146                 {
3147                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid PKM Config Settings");
3148                 }
3149                 return;
3150         }
3151         /* process PKM Configuration Settings (11.9.19) */
3152         for(offset = 0; offset < tvb_len; )
3153         {
3154                 /* get the TLV information */
3155                 init_tlv_info(&tlv_info, tvb, offset);
3156                 /* get the TLV type */
3157                 tlv_type = get_tlv_type(&tlv_info);
3158                 /* get the TLV length */
3159                 tlv_len = get_tlv_length(&tlv_info);
3160                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3161                 {       /* invalid tlv info */
3162                         if(check_col(pinfo->cinfo, COL_INFO))
3163                         {
3164                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "PKM Config Settings TLV error");
3165                         }
3166                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3167                         break;
3168                 }
3169                 /* get the TLV value offset */
3170                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3171 #ifdef DEBUG /* for debug only */
3172                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "PKM Configuration Settings TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
3173 #endif
3174                 /* update the offset for the TLV value */
3175                 offset += tlv_value_offset;
3176                 /* parse PKM Configuration Settings (11.9.19.1 - 11.9.19.7 */
3177                 switch (tlv_type)
3178                 {
3179                         case PKM_ATTR_PKM_CONFIG_SETTINGS_AUTHORIZE_WAIT_TIMEOUT:
3180                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_authorize_waitout, tvb, offset, tlv_len, FALSE);
3181                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_authorize_waitout, tvb, offset, tlv_len, FALSE);
3182                         break;
3183                         case PKM_ATTR_PKM_CONFIG_SETTINGS_REAUTHORIZE_WAIT_TIMEOUT:
3184                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_reauthorize_waitout, tvb, offset, tlv_len, FALSE);
3185                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_reauthorize_waitout, tvb, offset, tlv_len, FALSE);
3186                         break;
3187                         case PKM_ATTR_PKM_CONFIG_SETTINGS_AUTHORIZATION_GRACE_TIME:
3188                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_grace_time, tvb, offset, tlv_len, FALSE);
3189                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_grace_time, tvb, offset, tlv_len, FALSE);
3190                         break;
3191                         case PKM_ATTR_PKM_CONFIG_SETTINGS_OPERATIONAL_WAIT_TIMEOUT:
3192                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_operational_waittime, tvb, offset, tlv_len, FALSE);
3193                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_operational_waittime, tvb, offset, tlv_len, FALSE);
3194                         break;
3195                         case PKM_ATTR_PKM_CONFIG_SETTINGS_REKEY_WAIT_TIMEOUT:
3196                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_rekey_wait_timeout, tvb, offset, tlv_len, FALSE);
3197                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_rekey_wait_timeout, tvb, offset, tlv_len, FALSE);
3198                         break;
3199                         case PKM_ATTR_PKM_CONFIG_SETTINGS_TEK_GRACE_TIME:
3200                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_tek_grace_time, tvb, offset, tlv_len, FALSE);
3201                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_tek_grace_time, tvb, offset, tlv_len, FALSE);
3202                         break;
3203                         case PKM_ATTR_PKM_CONFIG_SETTINGS_AUTHORIZE_REJECT_WAIT_TIMEOUT:
3204                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_authorize_reject_wait_timeout, tvb, offset, tlv_len, FALSE);
3205                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_authorize_reject_wait_timeout, tvb, offset, tlv_len, FALSE);
3206                         break;
3207                         default:
3208                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_config_settings_authorize_reject_wait_timeout, tvb, offset, tlv_len, FALSE);
3209                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3210                         break;
3211                 }
3212                 offset += tlv_len;
3213         }       /* end of TLV process while loop */
3214 }
3215
3216 /******************************************************************/
3217 /* wimax_sa_descriptor_decoder()                                  */
3218 /* decode and display the WiMax PKM message SA-Descriptor         */
3219 /* parameter:                                                     */
3220 /*   tvb - pointer of the tvb of service flow encodings           */
3221 /*   tree - pointer of Wireshark display tree                     */
3222 /*   pinfo - pointer of Wireshark packet information structure    */
3223 /******************************************************************/
3224 void wimax_sa_descriptor_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3225 {
3226         guint offset;
3227         guint tvb_len, tlv_len, tlv_value_offset;
3228         gint  tlv_type;
3229         proto_tree *tlv_tree = NULL;
3230         tlv_info_t tlv_info;
3231
3232         /* get the tvb reported length */
3233         tvb_len = tvb_reported_length(tvb);
3234         /* do nothing if the TLV fields is not exist */
3235         if(!tvb_len)
3236                 return;
3237         /* report error if the packet size is less than 2 bytes (type+length) */
3238         if(tvb_len < 2)
3239         {       /* invalid tlv info */
3240                 if(check_col(pinfo->cinfo, COL_INFO))
3241                 {
3242                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid SA-Descriptor");
3243                 }
3244                 return;
3245         }
3246         /* process SA-Descriptor (11.9.17) */
3247         for(offset = 0; offset < tvb_len; )
3248         {
3249                 /* get the TLV information */
3250                 init_tlv_info(&tlv_info, tvb, offset);
3251                 /* get the TLV type */
3252                 tlv_type = get_tlv_type(&tlv_info);
3253                 /* get the TLV length */
3254                 tlv_len = get_tlv_length(&tlv_info);
3255                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3256                 {       /* invalid tlv info */
3257                         if(check_col(pinfo->cinfo, COL_INFO))
3258                         {
3259                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "SA-Descriptor TLV error");
3260                         }
3261                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3262                         break;
3263                 }
3264                 /* get the TLV value offset */
3265                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3266 #ifdef DEBUG /* for debug only */
3267                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "SA-Descriptor TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
3268 #endif
3269                 /* update the offset for the TLV value */
3270                 offset += tlv_value_offset;
3271                 /* parse SA-Descriptor (table 380) */
3272                 switch (tlv_type)
3273                 {
3274                         case PKM_ATTR_SAID:
3275                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
3276                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
3277                         break;
3278                         case PKM_ATTR_SA_TYPE:
3279                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
3280                                 proto_tree_add_item(tlv_tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
3281                         break;
3282                         case PKM_ATTR_SA_SERVICE_TYPE:
3283                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
3284                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
3285                         break;
3286                         case PKM_ATTR_CRYPTO_SUITE:
3287                                 /* add subtree */
3288                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_msg_crypto_suite, tvb, offset, tlv_len, FALSE);
3289                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_msb, tvb, offset, 1, FALSE);
3290                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_middle, tvb, offset+1, 1, FALSE);
3291                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_lsb, tvb, offset+2, 1, FALSE);
3292                         break;
3293                         default:
3294                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3295                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3296                         break;
3297                 }
3298                 offset += tlv_len;
3299         }       /* end of TLV process while loop */
3300 }
3301
3302 /******************************************************************/
3303 /* wimax_security_capabilities_decoder()                          */
3304 /* decode and display the WiMax Security Capabilities             */
3305 /* parameter:                                                     */
3306 /*   tvb - pointer of the tvb of service flow encodings           */
3307 /*   tree - pointer of Wireshark display tree                     */
3308 /*   pinfo - pointer of Wireshark packet information structure    */
3309 /******************************************************************/
3310 void wimax_security_capabilities_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3311 {
3312         guint offset;
3313         guint tvb_len, tlv_len, tlv_value_offset;
3314         gint  tlv_type;
3315         proto_tree *tlv_tree = NULL;
3316         tlv_info_t tlv_info;
3317
3318         /* get the tvb reported length */
3319         tvb_len = tvb_reported_length(tvb);
3320         /* do nothing if the TLV fields is not exist */
3321         if(!tvb_len)
3322                 return;
3323         /* report error if the packet size is less than 2 bytes (type+length) */
3324         if(tvb_len < 2)
3325         {       /* invalid tlv info */
3326                 if(check_col(pinfo->cinfo, COL_INFO))
3327                 {
3328                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Security Capabilities");
3329                 }
3330                 return;
3331         }
3332         /* process Security Capabilities (11.9.13) */
3333         for(offset = 0; offset < tvb_len; )
3334         {
3335                 /* get the TLV information */
3336                 init_tlv_info(&tlv_info, tvb, offset);
3337                 /* get the TLV type */
3338                 tlv_type = get_tlv_type(&tlv_info);
3339                 /* get the TLV length */
3340                 tlv_len = get_tlv_length(&tlv_info);
3341                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3342                 {       /* invalid tlv info */
3343                         if(check_col(pinfo->cinfo, COL_INFO))
3344                         {
3345                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Security Capabilities TLV error");
3346                         }
3347                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3348                         break;
3349                 }
3350                 /* get the TLV value offset */
3351                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3352 #ifdef DEBUG /* for debug only */
3353                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Security Capabilities TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
3354 #endif
3355                 /* update the offset for the TLV value */
3356                 offset += tlv_value_offset;
3357                 /* parse Security Capabilities (table 374) */
3358                 switch (tlv_type)
3359                 {
3360                         case PKM_ATTR_CRYPTO_LIST:
3361                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_security_capabilities_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Cryptographic-Suite List (%u bytes)", tlv_len);
3362                                 /* add subtree */
3363                                 wimax_cryptographic_suite_list_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
3364                         break;
3365                         default:
3366                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_security_capabilities_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, FALSE);
3367                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3368                         break;
3369                 }
3370                 offset += tlv_len;
3371         }       /* end of TLV process while loop */
3372 }
3373
3374 /******************************************************************/
3375 /* wimax_vendor_specific_information_decoder()                    */
3376 /* decode and display the WiMax Vendor-Specific Information       */
3377 /* parameter:                                                     */
3378 /*   tvb - pointer of the tvb of service flow encodings           */
3379 /*   tree - pointer of Wireshark display tree                     */
3380 /*   pinfo - pointer of Wireshark packet information structure    */
3381 /******************************************************************/
3382 void wimax_vendor_specific_information_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3383 {
3384         proto_tree *tlv_tree = NULL;
3385         guint offset;
3386         guint tvb_len, tlv_len, tlv_value_offset;
3387         gint  tlv_type;
3388         tlv_info_t tlv_info;
3389
3390         /* get the tvb reported length */
3391         tvb_len = tvb_reported_length(tvb);
3392         /* do nothing if the TLV fields is not exist */
3393         if(!tvb_len)
3394                 return;
3395         /* report error if the packet size is less than 2 bytes (type+length) */
3396         if(tvb_len < 2)
3397         {       /* invalid tlv info */
3398                 if(check_col(pinfo->cinfo, COL_INFO))
3399                 {
3400                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Vendor Specific Info");
3401                 }
3402                 proto_tree_add_text(tree, tvb, 0, tvb_len, "Invalid TLV info");
3403                 return;
3404         }
3405         /* process Vendor Specific Information (11.1.6) */
3406         for(offset = 0; offset < tvb_len; )
3407         {
3408                 /* get the TLV information */
3409                 init_tlv_info(&tlv_info, tvb, offset);
3410                 /* get the TLV type */
3411                 tlv_type = get_tlv_type(&tlv_info);
3412                 /* get the TLV length */
3413                 tlv_len = get_tlv_length(&tlv_info);
3414                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3415                 {       /* invalid tlv info */
3416                         if(check_col(pinfo->cinfo, COL_INFO))
3417                         {
3418                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Vendor Specific Info TLV error");
3419                         }
3420                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3421                         break;
3422                 }
3423                 /* get the TLV value offset */
3424                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3425 #ifdef DEBUG /* for debug only */
3426                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Vendor Specific Info TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
3427 #endif
3428                 /* parse Vendor Specific Information (11.1.6) */
3429                 if(tlv_type == VENDOR_ID_ENCODING)
3430                 {
3431                         /* decode and display the Vendor ID Encoding */
3432                         tlv_tree = add_tlv_subtree(&tlv_info, ett_vendor_id_encoding_decoder, tree, hf_common_tlv_vendor_id, tvb, (offset + tlv_value_offset), tlv_len, FALSE);
3433                         proto_tree_add_item(tlv_tree, hf_common_tlv_vendor_id, tvb, (offset + tlv_value_offset), tlv_len, FALSE);
3434                 }
3435                 else
3436                 {
3437                         /* decode and display the Vendor Specific Info */
3438                         proto_tree_add_item(tree, hf_common_tlv_vendor_specific_type, tvb, offset, 1, FALSE);
3439                         if(get_tlv_length_type(&tlv_info) == 0)
3440                         {       /* single byte TLV length */
3441                                 proto_tree_add_item(tree, hf_common_tlv_vendor_specific_length, tvb, (offset + 1), 1, FALSE);
3442                         }
3443                         else
3444                         {       /* multiple bytes TLV length */
3445                                 /* display the length of the TLV length with MSB */
3446                                 proto_tree_add_item(tree, hf_common_tlv_vendor_specific_length_size, tvb, (offset + 1), 1, FALSE);
3447                                 if(get_tlv_size_of_length(&tlv_info))
3448                                 {       /* display the multiple byte TLV length */
3449                                         proto_tree_add_text(tree, tvb, (offset + 2), get_tlv_size_of_length(&tlv_info), "Vendor Specific Length: %u", get_tlv_size_of_length(&tlv_info));
3450                                 }
3451                                 else
3452                                 {       /* length = 0 */
3453                                         continue;
3454                                 }
3455                         }
3456                         proto_tree_add_item(tree, hf_common_tlv_vendor_specific_value, tvb, (offset + tlv_value_offset), tlv_len, FALSE);
3457                 }
3458                 /* update the offset */
3459                 offset += tlv_value_offset + tlv_len;
3460         }
3461 }
3462
3463 /******************************************************************/
3464 /* wimax_common_tlv_encoding_decoder()                            */
3465 /* decode and display the WiMax Common TLV Encoding (Table 346)   */
3466 /* parameter:                                                     */
3467 /*   tvb - pointer of the tvb of service flow encodings           */
3468 /*   tree - pointer of Wireshark display tree                     */
3469 /*   pinfo - pointer of Wireshark packet information structure    */
3470 /******************************************************************/
3471 guint wimax_common_tlv_encoding_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3472 {
3473         guint offset, value;
3474         guint tvb_len, tlv_len, tlv_value_offset;
3475         gint  tlv_type;
3476         proto_tree *tlv_tree = NULL;
3477         tlv_info_t tlv_info;
3478         gfloat current_power;
3479
3480         /* get the tvb reported length */
3481         tvb_len = tvb_reported_length(tvb);
3482         /* do nothing if the TLV fields is not exist */
3483         if(!tvb_len)
3484                 return 0;
3485         /* report error if the packet size is less than 2 bytes (type+length) */
3486         if(tvb_len < 2)
3487         {       /* invalid tlv info */
3488                 if(check_col(pinfo->cinfo, COL_INFO))
3489                 {
3490                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Common TLV encoding");
3491                 }
3492                 proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, 0, tvb_len, FALSE);
3493                 return 0;
3494         }
3495         /* process Common TLV Encoding (11.1) */
3496         for(offset = 0; offset < tvb_len; )
3497         {
3498                 /* get the TLV information */
3499                 init_tlv_info(&tlv_info, tvb, offset);
3500                 /* get the TLV type */
3501                 tlv_type = get_tlv_type(&tlv_info);
3502                 /* get the TLV length */
3503                 tlv_len = get_tlv_length(&tlv_info);
3504                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3505                 {       /* invalid tlv info */
3506                         if(check_col(pinfo->cinfo, COL_INFO))
3507                         {
3508                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Common TLV encoding TLV error");
3509                         }
3510                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3511                         break;
3512                 }
3513                 /* get the TLV value offset */
3514                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3515 #ifdef DEBUG /* for debug only */
3516                 proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Common TLV Encoding TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len);
3517 #endif
3518                 /* update the offset for the TLV value */
3519                 offset += tlv_value_offset;
3520                 /* parse Common TLV Encoding (table 346) */
3521                 switch (tlv_type)
3522                 {
3523                         case VENDOR_SPECIFIC_INFO:
3524                                 /* display Vendor-Specific Information */
3525                                 /* add subtree */
3526                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Vendor-Specific Information (%u bytes)", tlv_len);
3527                                 /* decode and display the Vendor-Specific Information */
3528                                 wimax_vendor_specific_information_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
3529                         break;
3530                         case VENDOR_ID_ENCODING:
3531                                 /* display Vendor ID Encoding */
3532                                 /* add subtree */
3533                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Vendor ID Encoding (%u bytes)", tlv_len);
3534                                 /* decode and display the Vendor ID Encoding */
3535                                 proto_tree_add_item(tlv_tree, hf_common_tlv_vendor_id, tvb, offset, tlv_len, FALSE);
3536                         break;
3537                         case DSx_UPLINK_FLOW:
3538                                 /* display Uplink Service Flow Encodings info */
3539                                 /* add subtree */
3540                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_ul_service_flow_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Uplink Service Flow Encodings (%u bytes)", tlv_len);
3541                                 /* decode and display the UL Service Flow Encodings */
3542                                 wimax_service_flow_encodings_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
3543                         break;
3544                         case DSx_DOWNLINK_FLOW:
3545                                 /* display Downlink Service Flow Encodings info */
3546                                 /* add subtree */
3547                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_dl_service_flow_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Downlink Service Flow Encodings (%u bytes)", tlv_len);
3548                                 /* decode and display the DL Service Flow Encodings */
3549                                 wimax_service_flow_encodings_decoder(tvb_new_subset(tvb,offset, tlv_len, tlv_len), pinfo, tlv_tree);
3550                         break;
3551                         case CURRENT_TX_POWER:
3552                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_dl_service_flow_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Current Transmitted Power (%u byte(s))", tlv_len);
3553                                 value = tvb_get_guint8(tvb, offset);
3554                                 current_power = (gfloat)(value - 128) / 2;
3555                                 proto_tree_add_text(tlv_tree, tvb, offset, 1, "Current Transmitted Power: %.2f dBm (Value: 0x%x)", (gdouble)current_power, value);
3556                         break;
3557                         case MAC_VERSION_ENCODING:
3558                                 /* display MAC Version Encoding */
3559                                 /* add subtree */
3560                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "MAC Version Encoding (%u byte)", tlv_len);
3561                                 /* decode and display the MAC Version Encoding */
3562                                 proto_tree_add_item(tlv_tree, hf_common_tlv_mac_version, tvb, offset, tlv_len, FALSE);
3563                         break;
3564                         case HMAC_TUPLE:        /* Table 348d */
3565                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "HMAC Tuple (%u byte(s))", tlv_len);
3566                                 /* decode and display the HMAC Tuple */
3567                                 wimax_hmac_tuple_decoder(tlv_tree, tvb, offset, tlv_len);
3568                         break;
3569                         case CMAC_TUPLE:        /* Table 348b */
3570                                 tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "HMAC Tuple (%u byte(s))", tlv_len);
3571                                 /* decode and display the CMAC Tuple */
3572                                 wimax_cmac_tuple_decoder(tlv_tree, tvb, offset, tlv_len);
3573                         break;
3574                         default:
3575                                 /* Back to calling routine to finish decoding. */
3576                                 return offset - tlv_value_offset;  /* Ret amount decoded. */
3577                         break;
3578                 }
3579                 offset += tlv_len;
3580         }       /* end of while loop */
3581         return offset;
3582 }