From cfreeer (bug 2540):
[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, "Reserved"},
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 /* WiMax Service Flow Encodings display */
578 static hf_register_info hf_sfe[] =
579 {
580         {       /* 1 Service Flow ID */
581                 &hf_sfe_sf_id,
582                 {"Service Flow ID", "wmx.sfe.sf_id", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}
583         },
584         {       /* 2 CID */
585                 &hf_sfe_cid,
586                 {"CID", "wmx.sfe.cid", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
587         },
588         {       /* 3 Service Class Name */
589                 &hf_sfe_service_class_name,
590                 {"Service Class Name", "wmx.sfe.service_class_name", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL}
591         },
592         {       /* 4 MBS Service */
593                 &hf_sfe_mbs_service,
594                 {"MBS Service", "wmx.sfe.mbs_service", FT_UINT8, BASE_DEC, VALS(vals_mbs_service), 0x0, "", HFILL}
595         },
596         {       /* 5 QoS Parameter Set Type */
597                 &hf_sfe_qos_params_set,
598                 {"QoS Parameter Set Type", "wmx.sfe.qos_params_set", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
599         },
600         {       /* 5.1 */
601                 &hf_sfe_set_provisioned,
602                 {"Provisioned Set", "wmx.sfe.qos_params_set.provisioned", FT_BOOLEAN, 8, NULL, SFE_QOS_PARAMS_SET_PROVISIONED_SET, "", HFILL}
603         },
604         {       /* 5.2 */
605                 &hf_sfe_set_admitted,
606                 {"Admitted Set", "wmx.sfe.qos_params_set.admitted", FT_BOOLEAN, 8, NULL, SFE_QOS_PARAMS_SET_ADMITTED_SET, "", HFILL}
607         },
608         {       /* 5.3 */
609                 &hf_sfe_set_active,
610                 {"Active Set", "wmx.sfe.qos_params_set.active", FT_BOOLEAN, 8, NULL, SFE_QOS_PARAMS_SET_ACTIVE_SET, "", HFILL}
611         },
612         {       /* 5.4 */
613                 &hf_sfe_set_rsvd,
614                 {"Reserved", "wmx.sfe.qos_params_set.rsvd", FT_UINT8, BASE_HEX, NULL, SFE_QOS_PARAMS_SET_RESERVED, "", HFILL}
615         },
616         {       /* 6 Traffic Priority */
617                 &hf_sfe_traffic_priority,
618                 {"Traffic Priority", "wmx.sfe.traffic_priority", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
619         },
620         {       /* 7 Maximum Sustained Traffic Rate */
621                 &hf_sfe_max_str,
622                 {"Maximum Sustained Traffic Rate", "wmx.sfe.msr", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
623         },
624         {       /* 8 Maximum Traffic Burst */
625                 &hf_sfe_max_traffic_burst,
626                 {"Maximum Traffic Burst", "wmx.sfe.max_traffic_burst", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
627         },
628         {       /* 9 Minimum Reserved Traffic Rate */
629                 &hf_sfe_min_rtr,
630                 {"Minimum Reserved Traffic Rate", "wmx.sfe.mrr", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
631         },
632         {
633                 /* 10 Reserved */
634                 &hf_sfe_reserved_10,
635                 {"Reserved", "wmx.sfe.reserved_10", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
636         },
637 #if 0
638         {       /* 10 reserved by 16E */
639                 &hf_sfe_mtr,
640                 {"Minimum tolerable traffic rate", "wmx.sfe.mtr", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}
641         },
642 #endif
643         {       /* 11 Service Flow Scheduling Type */
644                 &hf_sfe_ul_grant_scheduling,
645                 {"Uplink Grant Scheduling Type", "wmx.sfe.uplink_grant_scheduling", FT_UINT8, BASE_DEC, VALS(vals_ul_grant_scheduling), 0x0, "", HFILL}
646         },
647         {       /* 12 Request/Transmission Policy */
648                 &hf_sfe_req_tx_policy,
649                 {"Request/Transmission Policy", "wmx.sfe.req_tx_policy", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}
650         },
651         {       /* 12.1 */
652                 &hf_sfe_policy_broadcast_bwr,
653                 {"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, "", HFILL}
654         },
655         {       /* 12.2 */
656                 &hf_sfe_policy_multicast_bwr,
657                 {"The Service Flow Shall Not Use Multicast Bandwidth Request Opportunities", "wmx.sfe.policy.bit1", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_MULTICAST_BWR, "", HFILL}
658         },
659         {       /* 12.3 */
660                 &hf_sfe_policy_piggyback,
661                 {"The Service Flow Shall Not Piggyback Requests With Data", "wmx.sfe.policy.piggyback", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_PIGGYBACK, "", HFILL}
662         },
663         {       /* 12.4 */
664                 &hf_sfe_policy_fragment,
665                 {"The Service Flow Shall Not Fragment Data", "wmx.sfe.policy.fragment", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_FRAGMENT_DATA, "", HFILL}
666         },
667         {       /* 12.5 */
668                 &hf_sfe_policy_headers,
669                 {"The Service Flow Shall Not Suppress Payload Headers", "wmx.sfe.policy.headers", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_PAYLOAD_HEADER, "", HFILL}
670         },
671         {       /* 12.6 */
672                 &hf_sfe_policy_packing,
673                 {"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, "", HFILL}
674         },
675         {       /* 12.7 */
676                 &hf_sfe_policy_crc,
677                 {"The Service Flow Shall Not Include CRC In The MAC PDU", "wmx.sfe.policy.crc", FT_BOOLEAN, 8, NULL, SFE_REQ_TX_POLICY_CRC, "", HFILL}
678         },
679         {       /* 12.8 */
680                 &hf_sfe_policy_rsvd1,
681                 {"Reserved", "wmx.sfe.policy.rsvd1", FT_UINT8, BASE_HEX, NULL, SFE_REQ_TX_POLICY_RESERVED, "", HFILL}
682         },
683         {       /* 13 Tolerated Jitter */
684                 &hf_sfe_jitter,
685                 {"Tolerated Jitter", "wmx.sfe.jitter", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
686         },
687         {       /* 14 Maximum Latency */
688                 &hf_sfe_max_latency,
689                 {"Maximum Latency", "wmx.sfe.max_latency", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
690         },
691         {       /* 15 Fixed/Variable Length SDU */
692                 &hf_sfe_fixed_len_sdu,
693                 {"Fixed/Variable Length SDU", "wmx.sfe.fixed_len_sdu", FT_UINT8, BASE_DEC, VALS(vals_fixed_len_sdu), 0x0, "", HFILL}
694         },
695         {       /* 16 SDU Size */
696                 &hf_sfe_sdu_size,
697                 {"SDU Size", "wmx.sfe.sdu_size", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
698         },
699         {       /* 17 SAID Onto Which SF Is Mapped */
700                 &hf_sfe_target_said,
701                 {"SAID Onto Which SF Is Mapped", "wmx.sfe.target_said", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}
702         },
703         {       /* 18 ARQ Enable */
704                 &hf_sfe_arq_enable,
705                 {"ARQ Enable", "wmx.arq.enable", FT_UINT8, BASE_DEC, VALS(vals_arq_enable), 0x0, "", HFILL}
706         },
707         {       /* 19 ARQ Window Size */
708                 &hf_sfe_arq_window_size,
709                 {"ARQ Window Size", "wmx.arq.window_size", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
710         },
711         {       /* 20 ARQ Transmitter Delay */
712                 &hf_sfe_arq_transmitter_delay,
713                 {"ARQ Transmitter Delay (10us granularity)", "wmx.arq.transmitter_delay", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
714         },
715         {       /* 21 ARQ Receiver Delay */
716                 &hf_sfe_arq_receiver_delay,
717                 {"ARQ Receiver Delay (10us granularity)", "wmx.arq.receiver_delay", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
718         },
719         {       /* 22 ARQ Block Lifetime */
720                 &hf_sfe_arq_block_lifetime,
721                 {"ARQ Block Lifetime (10us granularity)", "wmx.arq.block_lifetime", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
722         },
723         {       /* 23 ARQ Sync Loss Timeout */
724                 &hf_sfe_arq_sync_loss_timeout,
725                 {"ARQ Sync Loss Timeout (10us granularity)", "wmx.arq.sync_loss_timeout", FT_UINT16, BASE_DEC, VALS(&vals_arq_sync_loss_timeout), 0x0, "", HFILL}
726         },
727         {       /* 20 ARQ Transmitter Delay */
728                 &hf_sfe_arq_transmitter_delay_cor2,
729                 {"ARQ Transmitter Delay (100us granularity)", "wmx.arq.transmitter_delay", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
730         },
731         {       /* 21 ARQ Receiver Delay */
732                 &hf_sfe_arq_receiver_delay_cor2,
733                 {"ARQ Receiver Delay (100us granularity)", "wmx.arq.receiver_delay", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
734         },
735         {       /* 22 ARQ Block Lifetime */
736                 &hf_sfe_arq_block_lifetime_cor2,
737                 {"ARQ Block Lifetime (100us granularity)", "wmx.arq.block_lifetime", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
738         },
739         {       /* 23 ARQ Sync Loss Timeout */
740                 &hf_sfe_arq_sync_loss_timeout_cor2,
741                 {"ARQ Sync Loss Timeout (100us granularity)", "wmx.arq.sync_loss_timeout", FT_UINT16, BASE_DEC, VALS(&vals_arq_sync_loss_timeout), 0x0, "", HFILL}
742         },
743         {       /* 24 ARQ Deliver In Order */
744                 &hf_sfe_arq_deliver_in_order,
745                 {"ARQ Deliver In Order", "wmx.arq.deliver_in_order", FT_UINT8, BASE_DEC, VALS(&vals_arq_deliver_in_order), 0x0, "", HFILL}
746         },
747         {       /* 25 ARQ Purge Timeout */
748                 &hf_sfe_arq_rx_purge_timeout,
749                 {"ARQ RX Purge Timeout (100us granularity)", "wmx.arq.rx_purge_timeout", FT_UINT16, BASE_DEC, VALS(&vals_arq_rx_purge_timeout), 0x0, "", HFILL}
750         },
751         {       /* 26 ARQ Block Size */
752                 &hf_sfe_arq_block_size,
753                 {"ARQ Block Size", "wmx.arq.block_size", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
754         },
755         {       /* 26 ARQ Block Size */
756                 &hf_sfe_arq_block_size_cor2,
757                 {"ARQ Block Size", "wmx.arq.block_size", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
758         },
759         {       /* 26 ARQ Block Size for Corrigendum 2 */
760                 &hf_sfe_arq_min_block_size,
761                 {"ARQ Minumum Block Size", "wmx.arq.min_block_size", FT_UINT8, BASE_DEC, NULL, 0x0F, "", HFILL}
762         },
763         {       /* 26 ARQ Block Size for Corrigendum 2 */
764                 &hf_sfe_arq_max_block_size,
765                 {"ARQ Maximum Block Size", "wmx.arq.max_block_size", FT_UINT8, BASE_DEC, NULL, 0xF0, "", HFILL}
766         },
767 /* 27 reserved */
768         {       /* 28 CS Specification */
769                 &hf_sfe_cs_specification,
770                 {"CS Specification", "wmx.sfe.cs_specification", FT_UINT8, BASE_DEC, VALS(vals_cs_specification), 0x0, "", HFILL}
771         },
772         {       /* 29 Type of Data Delivery Services */
773                 &hf_sfe_type_of_data_delivery_services,
774                 {"Type of Data Delivery Services", "wmx.sfe.type_of_data_delivery_services", FT_UINT8, BASE_DEC, VALS(vals_type_of_data_delivery_services), 0x0, "", HFILL}
775         },
776         {       /* 30 SDU Inter-Arrival Interval */
777                 &hf_sfe_sdu_inter_arrival_interval,
778                 {"SDU Inter-Arrival Interval (in the resolution of 0.5 ms)", "wmx.sfe.sdu_inter_arrival_interval", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
779         },
780         {       /* 31 Time Base */
781                 &hf_sfe_time_base,
782                 {"Time Base", "wmx.sfe.time_base", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
783         },
784         {       /* 32 Paging Preference */
785                 &hf_sfe_paging_preference,
786                 {"Paging Preference", "wmx.sfe.paging_preference", FT_UINT8, BASE_DEC, VALS(vals_paging_preference), 0x0, "", HFILL}
787         },
788         {       /* 33 MBS Zone Identifier */
789                 &hf_sfe_mbs_zone_identifier_assignment,
790                 {"MBS Zone Identifier", "wmx.sfe.mbs_zone_identifier", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
791         },
792         {       /* 34 Traffic Indication Preference */
793                 &hf_sfe_reserved_34,
794                 {"Reserved", "wmx.sfe.reserved_34", FT_UINT8, BASE_DEC, NULL /*VALS(vals_traffic_indication_preference)*/, 0x0, "", HFILL}
795         },
796         {       /* 35 Global Service Class Name */
797                 &hf_sfe_global_service_class_name,
798                 {"Global Service Class Name", "wmx.sfe.global_service_class_name", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL}
799         },
800 /* 36 reserved by 16E */
801                 /* 36 Reserved */
802         {
803                 &hf_sfe_reserved_36,
804                 {"Reserved", "wmx.sfe.reserved_36", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
805         },
806         {       /* 37 SN Feedback Enable */
807                 &hf_sfe_sn_feedback_enabled,
808                 {"SN Feedback", "wmx.sfe.sn_feedback_enabled", FT_UINT8, BASE_DEC, VALS(vals_sn_fb_enable), 0x0, "", HFILL}
809         },
810         {       /* 38 FSN Size */
811                 &hf_sfe_fsn_size,
812                 {"FSN Size", "wmx.sfe.fsn_size", FT_UINT8, BASE_DEC, VALS(vals_fsn_size), 0x0, "", HFILL}
813         },
814         {       /* 39 CID allocation for Active BSs */
815                 &hf_sfe_cid_alloc_for_active_bs,
816                 {"CID Allocation For Active BSs", "wmx.sfe.cid_alloc_for_active_bs", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
817         },
818         {       /* 39.1 */
819                 &hf_sfe_cid_alloc_for_active_bs_cid,
820                 {"CID", "wmx.sfe.cid_alloc_for_active_bs_cid", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
821         },
822         {       /* 40 Unsolicited Grant Interval */
823                 &hf_sfe_unsolicited_grant_interval,
824                 {"Unsolicited Grant Interval", "wmx.sfe.unsolicited_grant_interval", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
825         },
826         {       /* 41 Unsolicited Polling Interval */
827                 &hf_sfe_unsolicited_polling_interval,
828                 {"Unsolicited Polling Interval", "wmx.sfe.unsolicited_polling_interval", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
829         },
830         {       /* 42 PDU SN extended subheader for HARQ reordering */
831                 &hf_sfe_pdu_sn_ext_subheader_reorder,
832                 {"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, "", HFILL}
833         },
834         {       /* 43 MBS contents ID */
835                 &hf_sfe_mbs_contents_ids,
836                 {"MBS contents IDs", "wmx.sfe.mbs_contents_ids", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
837         },
838         {       /* 43.1 */
839                 &hf_sfe_mbs_contents_ids_id,
840                 {"MBS Contents ID", "wmx.sfe.mbs_contents_ids_id", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
841         },
842         {       /* 44 HARQ Service Flows */
843                 &hf_sfe_harq_service_flows,
844                 {"HARQ Service Flows", "wmx.sfe.harq_service_flows", FT_UINT8, BASE_DEC, VALS(vals_harq), 0x0, "", HFILL}
845         },
846         {       /* 45 Authorization Token */
847                 &hf_sfe_authorization_token,
848                 {"Authorization Token", "wmx.sfe.authorization_token", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
849         },
850         {       /* 46 HARQ Channel Mapping */
851                 &hf_sfe_harq_channel_mapping,
852                 {"HARQ Channel Mapping", "wmx.sfe.harq_channel_mapping", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
853         },
854         {       /* 46.1 HARQ Channel Index*/
855                 &hf_sfe_harq_channel_mapping_index,
856                 {"HARQ Channel Index", "wmx.sfe.harq_channel_mapping.index", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
857         },
858 /* unknown types */
859         {       /* unknown SFE types */
860                 &hf_sfe_unknown_type,
861                 {"Unknown SFE TLV type", "wmx.sfe.unknown_type", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
862         }
863 };
864
865 /* bit masks */
866 /* 11.13.19.3.4.17 */
867 #define CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_BIT0 0x80
868 #define CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_RSV  0x7F
869
870 /* WiMax Convergence Service Parameter Encoding Rules display */
871 static hf_register_info hf_csper[] =
872 {       /* 99 - 111 CS parameter encoding rules */
873         {       /* Classifier DSC Action */
874                 &hf_cst_classifier_dsc_action,
875                 {"Classifier DSC Action", "wmx.cst.classifier_action", FT_UINT8, BASE_DEC, VALS(vals_cst_classifier_action), 0x0, "", HFILL}
876         },
877         {       /* Errored Parameter */
878                 &hf_cst_error_set_errored_param,
879                 {"Errored Parameter", "wmx.cst.error_set.errored_param", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
880         },
881         {       /* Error Code */
882                 &hf_cst_error_set_error_code,
883                 {"Error Code", "wmx.cst.error_set.error_code", FT_UINT8, BASE_HEX, VALS(vals_cc), 0x0, "", HFILL}
884         },
885         {       /* Error Message */
886                 &hf_cst_error_set_error_msg,
887                 {"Error Message", "wmx.cst.error_set.error_msg", FT_STRINGZ, BASE_NONE, NULL, 0x0, "", HFILL}
888         },
889         {       /* Packet Classification Rule */
890                 &hf_cst_pkt_class_rule,
891                 {"Packet Classification Rule", "wmx.cst.pkt_class_rule", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
892         },
893         {       /* Classification Rule Priority */
894                 &hf_cst_pkt_class_rule_priority,
895                 {"Classification Rule Priority", "wmx.cst.pkt_class_rule.priority", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
896         },
897         {       /* ToS/Differentiated Services Codepoint (DSCP) Range And Mask */
898                 &hf_cst_pkt_class_rule_range_mask,
899                 {"ToS/Differentiated Services Codepoint (DSCP) Range And Mask", "wmx.cst.pkt_class_rule.range_mask", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
900         },
901         {       /* ToS-Low */
902                 &hf_cst_pkt_class_rule_tos_low,
903                 {"ToS-Low", "wmx.cst.pkt_class_rule.tos-low", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
904         },
905         {       /* ToS-High */
906                 &hf_cst_pkt_class_rule_tos_high,
907                 {"ToS-High", "wmx.cst.pkt_class_rule.tos-high", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
908         },
909         {       /* ToS-Mask */
910                 &hf_cst_pkt_class_rule_tos_mask,
911                 {"ToS-Mask", "wmx.cst.pkt_class_rule.tos-mask", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
912         },
913         {       /* Protocol */
914                 &hf_cst_pkt_class_rule_protocol,
915                 {"Protocol", "wmx.cst.pkt_class_rule.protocol", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
916         },
917 #if 0 /* Removed by the changes of 802.16E 2005 */
918         {       /* Protocol */
919                 &hf_cst_pkt_class_rule_protocol,
920                 {"Protocol", "wmx.cst.pkt_class_rule.protocol", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
921         },
922         {       /* Protocol Number */
923                 &hf_cst_pkt_class_rule_protocol_number,
924                 {"Protocol Number", "wmx.cst.pkt_class_rule.protocol.number", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
925         },
926 #endif
927         {       /* IP Masked Source Address */
928                 &hf_cst_pkt_class_rule_ip_masked_src_address,
929                 {"IP Masked Source Address", "wmx.cst.pkt_class_rule.ip_masked_src_address", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
930         },
931         {       /* IP Masked Destination Address */
932                 &hf_cst_pkt_class_rule_ip_masked_dest_address,
933                 {"IP Masked Destination Address", "wmx.cst.pkt_class_rule.ip_masked_dest_address", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
934         },
935         {       /* IPv4 Source Address */
936                 &hf_cst_pkt_class_rule_src_ipv4,
937                 {"IPv4 Source Address", "wmx.cst.pkt_class_rule.src_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL}
938         },
939         {       /* IPv4 Destination Address */
940                 &hf_cst_pkt_class_rule_dest_ipv4,
941                 {"IPv4 Destination Address", "wmx.cst.pkt_class_rule.dst_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL}
942         },
943         {       /* IPv4 Mask */
944                 &hf_cst_pkt_class_rule_mask_ipv4,
945                 {"IPv4 Mask", "wmx.cst.pkt_class_rule.mask_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL}
946         },
947         {       /* IPv6 Source Address */
948                 &hf_cst_pkt_class_rule_src_ipv6,
949                 {"IPv6 Source Address", "wmx.cst.pkt_class_rule.src_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, "", HFILL}
950         },
951         {       /* IPv6 Destination Address */
952                 &hf_cst_pkt_class_rule_dest_ipv6,
953                 {"IPv6 Destination Address", "wmx.cst.pkt_class_rule.dst_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, "", HFILL}
954         },
955         {       /* IPv6 Mask */
956                 &hf_cst_pkt_class_rule_mask_ipv6,
957                 {"IPv6 Mask", "wmx.cst.pkt_class_rule.mask_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0, "", HFILL}
958         },
959         {       /* Protocol Source Port Range */
960                 &hf_cst_pkt_class_rule_prot_src_port_range,
961                 {"Protocol Source Port Range", "wmx.cst.pkt_class_rule.prot_src_port_range", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
962         },
963         {       /* Src-Port Low */
964                 &hf_cst_pkt_class_rule_src_port_low,
965                 {"Src-Port Low", "wmx.cst.pkt_class_rule.src_port_low", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
966         },
967         {       /* Src-Port High */
968                 &hf_cst_pkt_class_rule_src_port_high,
969                 {"Src-Port High", "wmx.cst.pkt_class_rule.src_port_high", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
970         },
971         {       /* Protocol Destination Port Range */
972                 &hf_cst_pkt_class_rule_prot_dest_port_range,
973                 {"Protocol Destination Port Range", "wmx.cst.pkt_class_rule.prot_dest_port_range", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
974         },
975         {       /* Dst-Port Low */
976                 &hf_cst_pkt_class_rule_dest_port_low,
977                 {"Dst-Port Low", "wmx.cst.pkt_class_rule.dst_port_low", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
978         },
979         {       /* Dst-Port High */
980                 &hf_cst_pkt_class_rule_dest_port_high,
981                 {"Dst-Port High", "wmx.cst.pkt_class_rule.dst_port_high", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
982         },
983         {       /* 802.3/Ethernet Destination MAC Address */
984                 &hf_cst_pkt_class_rule_dest_mac_address,
985                 {"802.3/Ethernet Destination MAC Address", "wmx.cst.pkt_class_rule.dest_mac_address", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
986         },
987         {       /* Destination MAC Address */
988                 &hf_cst_pkt_class_rule_dest_mac,
989                 {"Destination MAC Address", "wmx.cst.pkt_class_rule.dst_mac", FT_ETHER, BASE_NONE, NULL, 0x0, "", HFILL}
990         },
991         {       /* 802.3/Ethernet Source MAC Address */
992                 &hf_cst_pkt_class_rule_src_mac_address,
993                 {"802.3/Ethernet Source MAC Address", "wmx.cst.pkt_class_rule.src_mac_address", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
994         },
995         {       /* Source MAC Address */
996                 &hf_cst_pkt_class_rule_src_mac,
997                 {"Source MAC Address", "wmx.cst.pkt_class_rule.src_mac", FT_ETHER, BASE_NONE, NULL, 0x0, "", HFILL}
998         },
999         {       /* MAC Address Mask */
1000                 &hf_cst_pkt_class_rule_mask_mac,
1001                 {"MAC Address Mask", "wmx.cst.pkt_class_rule.mask_mac", FT_ETHER, BASE_NONE, NULL, 0x0, "", HFILL}
1002         },
1003         {       /* Ethertype/IEEE Std 802.2-1998 SAP */
1004                 &hf_cst_pkt_class_rule_ethertype,
1005                 {"Ethertype/IEEE Std 802.2-1998 SAP", "wmx.cst.pkt_class_rule.ethertype", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1006         },
1007         {       /* Ethertype */
1008                 &hf_cst_pkt_class_rule_etype,
1009                 {"Ethertype", "wmx.cst.pkt_class_rule.ethertype", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1010         },
1011         {       /* Eprot1 */
1012                 &hf_cst_pkt_class_rule_eprot1,
1013                 {"Eprot1", "wmx.cst.pkt_class_rule.eprot1", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1014         },
1015         {       /* Eprot2 */
1016                 &hf_cst_pkt_class_rule_eprot2,
1017                 {"Eprot2", "wmx.cst.pkt_class_rule.eprot2", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1018         },
1019         {       /* IEEE Std 802.1D-1998 User_Priority */
1020                 &hf_cst_pkt_class_rule_user_priority,
1021                 {"IEEE Std 802.1D-1998 User_Priority", "wmx.cst.pkt_class_rule.user_priority", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1022         },
1023         {
1024                 &hf_cst_pkt_class_rule_pri_low,
1025                 {"Pri-Low", "wmx.cst.pkt_class_rule.pri-low", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1026         },
1027         {
1028                 &hf_cst_pkt_class_rule_pri_high,
1029                 {"Pri-High", "wmx.cst.pkt_class_rule.pri-high", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1030         },
1031         {       /* IEEE Std 802.1Q-1998 VLAN_ID */
1032                 &hf_cst_pkt_class_rule_vlan_id,
1033                 {"IEEE Std 802.1Q-1998 VLAN_ID", "wmx.cst.pkt_class_rule.vlan_id", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1034         },
1035         {       /* Vlan_Id1 */
1036                 &hf_cst_pkt_class_rule_vlan_id1,
1037                 {"Vlan_Id1", "wmx.cst.pkt_class_rule.vlan_id1", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1038         },
1039         {       /* Vlan_Id2 */
1040                 &hf_cst_pkt_class_rule_vlan_id2,
1041                 {"Vlan_Id2", "wmx.cst.pkt_class_rule.vlan_id2", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1042         },
1043         {       /* Associated PHSI */
1044                 &hf_cst_pkt_class_rule_phsi,
1045                 {"Associated PHSI", "wmx.cst.pkt_class_rule.phsi", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1046         },
1047         {       /* Packet Classifier Rule Index */
1048                 &hf_cst_pkt_class_rule_index,
1049                 {"Packet Classifier Rule Index (PCRI)", "wmx.cst.pkt_class_rule.index", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1050         },
1051         {       /* Large Context ID for ROHC/ECRTP Compressed Packet or ROHC Feedback Packet */
1052                 &hf_cst_large_context_id,
1053                 {"Large Context ID", "wmx.cst.large_context_id", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1054         },
1055         {       /* Short-Format Context ID for ROHC/ECRTP Compressed Packet or ROHC Feedback Packet */
1056                 &hf_cst_short_format_context_id,
1057                 {"Short-Format Context ID", "wmx.cst.short_format_context_id", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1058         },
1059         {       /* Vendor-Specific Classifier Parameters */
1060                 &hf_cst_pkt_class_rule_vendor_spec,
1061                 {"Vendor-Specific Classifier Parameters", "wmx.cst.pkt_class_rule.vendor_spec", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1062         },
1063         {       /* Classifier Action Rule */
1064                 &hf_cst_pkt_class_rule_classifier_action_rule,
1065                 {"Classifier Action Rule", "wmx.cst.pkt_class_rule.classifier.action.rule", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1066         },
1067         {
1068                 &hf_cst_pkt_class_rule_classifier_action_rule_bit0,
1069                 {"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, "", HFILL}
1070         },
1071         {
1072                 &hf_cst_pkt_class_rule_classifier_action_rule_bit1,
1073                 {"Reserved", "wmx.cst.pkt_class_rule.classifier.action.rule.reserved", FT_UINT8, BASE_HEX, NULL, CST_PKT_CLASS_RULE_CLASSIFIER_ACTION_RULE_RSV, "", HFILL}
1074         },
1075         {       /* PHS DSC action */
1076                 &hf_cst_phs_dsc_action,
1077                 {"PHS DSC action", "wmx.cst.phs_dsc_action", FT_UINT8, BASE_DEC, VALS(vals_cst_phs_dsc_action), 0x0, "", HFILL}
1078         },
1079         {       /* PHS Rule */
1080                 &hf_cst_phs_rule,
1081                 {"PHS Rule", "wmx.cst.phs_rule", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1082         },
1083         {       /* PHS Rule 1 */
1084                 &hf_cst_phs_phsi,
1085                 {"PHSI", "wmx.cst.phs_rule.phsi", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1086         },
1087         {       /* PHS Rule 2 */
1088                 &hf_cst_phs_phsf,
1089                 {"PHSF", "wmx.cst.phs_rule.phsf", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1090         },
1091         {       /* PHS Rule 3 */
1092                 &hf_cst_phs_phsm,
1093                 {"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_HEX, NULL, 0x0, "", HFILL}
1094         },
1095         {       /* PHS Rule 4 */
1096                 &hf_cst_phs_phss,
1097                 {"PHSS", "wmx.cst.phs_rule.phss", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1098         },
1099         {       /* PHS Rule 5 */
1100                 &hf_cst_phs_phsv,
1101                 {"PHSV", "wmx.cst.phs_rule.phsv", FT_UINT8, BASE_DEC, VALS(vals_verify), 0x0, "", HFILL}
1102         },
1103         {       /* PHS Rule 143 */
1104                 &hf_cst_phs_vendor_spec,
1105                 {"Vendor-Specific PHS Parameters", "wmx.cst.phs.vendor_spec", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1106         },
1107         {       /* IPv6 Flow Label */
1108                 &hf_cst_pkt_class_rule_ipv6_flow_label,
1109                 {"IPv6 Flow Label", "wmx.cst.pkt_class_rule.ipv6_flow_label", FT_UINT24, BASE_HEX, NULL, 0x0, "", HFILL}
1110         },
1111         {       /* ATM Switching Encoding */
1112                 &hf_csper_atm_switching_encoding,
1113                 {"ATM Switching Encoding", "wmx.csper.atm_switching_encoding", FT_UINT8, BASE_DEC, VALS(vals_atm_switching_encodings), 0x0, "", HFILL}
1114         },
1115         {       /* ATM Classifier TLV */
1116                 &hf_csper_atm_classifier,
1117                 {"ATM Classifier TLV", "wmx.csper.atm_classifier", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1118         },
1119         {       /* ATM VPI Classifier */
1120                 &hf_csper_atm_classifier_vpi,
1121                 {"VPI Classifier", "wmx.csper.atm_classifier_vpi", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}
1122         },
1123         {       /* ATM VCI Classifier */
1124                 &hf_csper_atm_classifier_vci,
1125                 {"VCI Classifier", "wmx.csper.atm_classifier_vci", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}
1126         },
1127         {       /* ATM Classifier ID */
1128                 &hf_csper_atm_classifier_id,
1129                 {"Classifier ID", "wmx.csper.atm_classifier_tlv", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1130         },
1131 /* unknown types */
1132         {       /* unknown CSPER types */
1133                 &hf_csper_unknown_type,
1134                 {"Unknown CSPER TLV type", "wmx.csper.unknown_type", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1135         },
1136         {
1137                 &hf_cst_invalid_tlv,
1138                 {"Invalid TLV", "wmx.cst.invalid_tlv", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1139         }
1140 };
1141
1142 /* bit masks */
1143 /* 11.1.2 (table 348) */
1144 #define XMAC_TUPLE_RESERVED        0xF0
1145 #define XMAC_TUPLE_KEY_SEQ_NUM     0x0F
1146
1147 /* WiMax HMAC/CMAC/Short-HMAC Tuples display */
1148 static hf_register_info hf_xmac[] =
1149 {
1150         {
1151                 &hf_xmac_tuple_rsvd,
1152                 {"Reserved", "wmx.xmac_tuple.reserved", FT_UINT8, BASE_HEX, NULL, XMAC_TUPLE_RESERVED, "", HFILL}
1153         },
1154         {
1155                 &hf_xmac_tuple_key_seq_num,
1156                 {"Key Sequence Number", "wmx.xmac_tuple.key_sn", FT_UINT8, BASE_DEC, NULL, XMAC_TUPLE_KEY_SEQ_NUM, "", HFILL}
1157         },
1158         {
1159                 &hf_hmac_tuple_hmac_digest,
1160                 {"HMAC Digest", "wmx.xmac_tuple.hmac_digest", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1161         },
1162         {
1163                 &hf_cmac_tuple_bsid,
1164                 {"BSID", "wmx.cmac_tuple.bsid", FT_ETHER, BASE_HEX, NULL, 0x0, "", HFILL}
1165         },
1166         {
1167                 &hf_cmac_tuple_cmac_value,
1168                 {"CMAC Value", "wmx.cmac_tuple.cmac.value", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1169         },
1170         {
1171                 &hf_packet_number_counter,
1172                 {"Packet Number Counter", "wmx.xmac_tuple.packet_number_count", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1173         }
1174 };
1175
1176 /* WiMax Security Negotiation Parameters display */
1177 static gint hf_snp_pkm_version_support = -1;
1178 static gint hf_snp_pkm_version_support_bit0 = -1;
1179 static gint hf_snp_pkm_version_support_bit1 = -1;
1180 static gint hf_snp_pkm_version_support_reserved = -1;
1181 static gint hf_snp_auth_policy_support = -1;
1182 static gint hf_snp_auth_policy_support_bit0 = -1;
1183 static gint hf_snp_auth_policy_support_bit1 = -1;
1184 static gint hf_snp_auth_policy_support_bit2 = -1;
1185 static gint hf_snp_auth_policy_support_bit3 = -1;
1186 static gint hf_snp_auth_policy_support_bit4 = -1;
1187 static gint hf_snp_auth_policy_support_bit5 = -1;
1188 static gint hf_snp_auth_policy_support_bit6 = -1;
1189 static gint hf_snp_auth_policy_support_bit7 = -1;
1190 static gint hf_snp_mac_mode = -1;
1191 static gint hf_snp_mac_mode_bit0 = -1;
1192 static gint hf_snp_mac_mode_bit1 = -1;
1193 static gint hf_snp_mac_mode_bit1_rsvd = -1;
1194 static gint hf_snp_mac_mode_bit2 = -1;
1195 static gint hf_snp_mac_mode_bit3 = -1;
1196 static gint hf_snp_mac_mode_bit4 = -1;
1197 static gint hf_snp_mac_mode_bit5 = -1;
1198 static gint hf_snp_mac_mode_reserved = -1;
1199 static gint hf_snp_mac_mode_reserved1 = -1;
1200 static gint hf_snp_pn_window_size = -1;
1201 static gint hf_snp_max_conc_transactions = -1;
1202 static gint hf_snp_max_suppt_sec_assns = -1;
1203 static gint hf_snp_unknown_type = -1;
1204
1205 /* bit masks */
1206 /* 11.8.4.1 */
1207 #define SNP_PKM_VERSION_SUPPORT_BIT0 0x01
1208 #define SNP_PKM_VERSION_SUPPORT_BIT1 0x02
1209 #define SNP_PKM_VERSION_SUPPORT_RSV  0xFC
1210 /* 11.8.4.2 */
1211 #define SNP_AUTH_POLICY_SUPPORT_BIT0 0x01
1212 #define SNP_AUTH_POLICY_SUPPORT_BIT1 0x02
1213 #define SNP_AUTH_POLICY_SUPPORT_BIT2 0x04
1214 #define SNP_AUTH_POLICY_SUPPORT_BIT3 0x08
1215 #define SNP_AUTH_POLICY_SUPPORT_BIT4 0x10
1216 #define SNP_AUTH_POLICY_SUPPORT_BIT5 0x20
1217 #define SNP_AUTH_POLICY_SUPPORT_BIT6 0x40
1218 #define SNP_AUTH_POLICY_SUPPORT_BIT7 0x80
1219 /* 11.8.4.3 */
1220 #define SNP_MAC_MODE_BIT0 0x01
1221 #define SNP_MAC_MODE_BIT1 0x02
1222 #define SNP_MAC_MODE_BIT2 0x04
1223 #define SNP_MAC_MODE_BIT3 0x08
1224 #define SNP_MAC_MODE_BIT4 0x10
1225 #define SNP_MAC_MODE_BIT5 0x20
1226 #define SNP_MAC_MODE_RSV  0xE0
1227 #define SNP_MAC_MODE_RSV1 0xC0
1228
1229 static hf_register_info hf_snp[] =
1230 {
1231         {       /* 11.8.4.1 */
1232                 &hf_snp_pkm_version_support,
1233                 {"PKM Version Support", "wmx.security_negotiation_parameters.pkm_version_support",FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1234         },
1235         {
1236                 &hf_snp_pkm_version_support_bit0,
1237                 {"PKM version 1", "wmx.security_negotiation_parameters.pkm_version_support.bit0",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_PKM_VERSION_SUPPORT_BIT0, "", HFILL}
1238         },
1239         {
1240                 &hf_snp_pkm_version_support_bit1,
1241                 {"PKM version 2", "wmx.security_negotiation_parameters.pkm_version_support.bit1",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_PKM_VERSION_SUPPORT_BIT1, "", HFILL}
1242         },
1243         {
1244                 &hf_snp_pkm_version_support_reserved,
1245                 {"Reserved", "wmx.security_negotiation_parameters.pkm_version_support.reserved",FT_UINT8, BASE_HEX, NULL, SNP_PKM_VERSION_SUPPORT_RSV, "", HFILL}
1246         },
1247         {       /* 11.8.4.2 */
1248                 &hf_snp_auth_policy_support,
1249                 {"Authorization Policy Support", "wmx.security_negotiation_parameters.auth_policy_support",FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1250         },
1251         {
1252                 &hf_snp_auth_policy_support_bit0,
1253                 {"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, "", HFILL}
1254         },
1255         {
1256                 &hf_snp_auth_policy_support_bit1,
1257                 {"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, "", HFILL}
1258         },
1259         {
1260                 &hf_snp_auth_policy_support_bit2,
1261                 {"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, "", HFILL}
1262         },
1263         {
1264                 &hf_snp_auth_policy_support_bit3,
1265                 {"Reserved", "wmx.security_negotiation_parameters.auth_policy_support.bit3",FT_UINT8, BASE_HEX, NULL, SNP_AUTH_POLICY_SUPPORT_BIT3, "", HFILL}
1266         },
1267         {
1268                 &hf_snp_auth_policy_support_bit4,
1269                 {"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, "", HFILL}
1270         },
1271         {
1272                 &hf_snp_auth_policy_support_bit5,
1273                 {"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, "", HFILL}
1274         },
1275         {
1276                 &hf_snp_auth_policy_support_bit6,
1277                 {"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, "", HFILL}
1278         },
1279         {
1280                 &hf_snp_auth_policy_support_bit7,
1281                 {"Reserved", "wmx.security_negotiation_parameters.auth_policy_support.bit7",FT_UINT8, BASE_HEX, NULL, SNP_AUTH_POLICY_SUPPORT_BIT7, "", HFILL}
1282         },
1283         {       /* 11.8.4.3 */
1284                 &hf_snp_mac_mode,
1285                 {"MAC (Message Authentication Code) Mode", "wmx.security_negotiation_parameters.mac_mode",FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1286         },
1287         {
1288                 &hf_snp_mac_mode_bit0,
1289                 {"HMAC", "wmx.security_negotiation_parameters.mac_mode.bit0",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT0, "", HFILL}
1290         },
1291         {
1292                 &hf_snp_mac_mode_bit1,
1293                 {"CMAC", "wmx.security_negotiation_parameters.mac_mode.bit1",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT1, "", HFILL}
1294         },
1295         {
1296                 &hf_snp_mac_mode_bit1_rsvd,
1297                 {"Reserved", "wmx.security_negotiation_parameters.mac_mode.bit1_rsvd",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT1, "", HFILL}
1298         },
1299         {
1300                 &hf_snp_mac_mode_bit2,
1301                 {"64-bit Short-HMAC", "wmx.security_negotiation_parameters.mac_mode.bit2",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT2, "", HFILL}
1302         },
1303         {
1304                 &hf_snp_mac_mode_bit3,
1305                 {"80-bit Short-HMAC", "wmx.security_negotiation_parameters.mac_mode.bit3",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT3, "", HFILL}
1306         },
1307         {
1308                 &hf_snp_mac_mode_bit4,
1309                 {"96-bit Short-HMAC", "wmx.security_negotiation_parameters.mac_mode.bit4",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT4, "", HFILL}
1310         },
1311         {
1312                 &hf_snp_mac_mode_bit5,
1313                 {"CMAC", "wmx.security_negotiation_parameters.mac_mode.bit5",FT_BOOLEAN, 8, TFS(&tfs_supported), SNP_MAC_MODE_BIT5, "", HFILL}
1314         },
1315         {
1316                 &hf_snp_mac_mode_reserved,
1317                 {"Reserved", "wmx.security_negotiation_parameters.mac_mode.reserved",FT_UINT8, BASE_HEX, NULL, SNP_MAC_MODE_RSV, "", HFILL}
1318         },
1319         {
1320                 &hf_snp_mac_mode_reserved1,
1321                 {"Reserved", "wmx.security_negotiation_parameters.mac_mode.reserved",FT_UINT8, BASE_HEX, NULL, SNP_MAC_MODE_RSV1, "", HFILL}
1322         },
1323         {       /* 11.8.4.4 */
1324                 &hf_snp_pn_window_size,
1325                 {"PN Window Size", "wmx.security_negotiation_parameters.pn_window_size",FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1326         },
1327         {       /* 11.8.4.5 */
1328                 &hf_snp_max_conc_transactions,
1329                 {"Maximum concurrent transactions (0 indicates no limit)", "wmx.security_negotiation_parameters.max_conc_transactions",FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1330         },
1331         {       /* 11.8.4.6 */
1332                 &hf_snp_max_suppt_sec_assns,
1333                 {"Maximum number of security associations supported by the SS", "wmx.security_negotiation_parameters.max_suppt_sec_assns",FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1334         },
1335         {
1336                 &hf_snp_unknown_type,
1337                 {"Unknown Security Negotiation Parameter type", "wmx.security_negotiation_parameters.unknown.type",FT_BYTES, BASE_HEX, NULL, 0x0,       "", HFILL}
1338         }
1339 };
1340
1341 /* PKM display */
1342 static gint hf_pkm_msg_unknown_type = -1;
1343 static gint hf_pkm_msg_attr_display = -1;
1344 static gint hf_pkm_config_settings_authorize_waitout = -1;
1345 static gint hf_pkm_config_settings_reauthorize_waitout = -1;
1346 static gint hf_pkm_config_settings_grace_time = -1;
1347 static gint hf_pkm_config_settings_operational_waittime = -1;
1348 static gint hf_pkm_msg_attr_auth_key = -1;
1349 static gint hf_pkm_msg_attr_tek = -1;
1350 static gint hf_pkm_msg_attr_key_life_time = -1;
1351 static gint hf_pkm_msg_attr_key_seq_num = -1;
1352 static gint hf_pkm_msg_attr_hmac_digest = -1;
1353 static gint hf_pkm_msg_attr_said = -1;
1354 static gint hf_pkm_msg_attr_cbc_iv = -1;
1355 static gint hf_pkm_msg_attr_error_code = -1;
1356 static gint hf_pkm_msg_attr_ca_certificate = -1;
1357 static gint hf_pkm_msg_attr_ss_certificate = -1;
1358 static gint hf_pkm_attr_auth_result_code = -1;
1359 static gint hf_pkm_attr_sa_service_type = -1;
1360 static gint hf_pkm_attr_frame_number = -1;
1361 static gint hf_pkm_attr_ss_random = -1;
1362 static gint hf_pkm_attr_bs_random = -1;
1363 static gint hf_pkm_attr_pre_pak = -1;
1364 static gint hf_pkm_attr_bs_certificate = -1;
1365 static gint hf_pkm_attr_sig_bs = -1;
1366 static gint hf_pkm_attr_ms_mac_address = -1;
1367 static gint hf_pkm_attr_cmac_digest = -1;
1368 static gint hf_pkm_attr_cmac_digest_pn = -1;
1369 static gint hf_pkm_attr_cmac_digest_value = -1;
1370 static gint hf_pkm_attr_eap_payload = -1;
1371 static gint hf_pkm_attr_nonce = -1;
1372 static gint hf_pkm_sa_type = -1;
1373 static gint hf_pkm_msg_crypto_suite = -1;
1374 static gint hf_pkm_msg_crypto_suite_msb = -1;
1375 static gint hf_pkm_msg_crypto_suite_middle = -1;
1376 static gint hf_pkm_msg_crypto_suite_lsb = -1;
1377 /*static gint hf_pkm_msg_version = -1;*/
1378 static gint hf_pkm_attr_push_modes = -1;
1379 static gint hf_pkm_attr_key_push_counter = -1;
1380 static gint hf_pkm_attr_gkek = -1;
1381 static gint hf_pkm_attr_sig_ss = -1;
1382 static gint hf_pkm_attr_akid = -1;
1383 static gint hf_pkm_config_settings_rekey_wait_timeout = -1;
1384 static gint hf_pkm_config_settings_tek_grace_time = -1;
1385 static gint hf_pkm_config_settings_authorize_reject_wait_timeout = -1;
1386
1387 static gint hf_pkm_attr_pak_ak_seq_number = -1;
1388 static gint hf_pkm_attr_associated_gkek_seq_number = -1;
1389 static gint hf_pkm_attr_gkek_params = -1;
1390
1391 static hf_register_info hf_pkm[] =
1392 {
1393         {       /* 11.9.1 - type 6 */
1394                 &hf_pkm_msg_attr_display,
1395                 {"Display String", "wmx.pkm_msg.pkm_attr.display_string", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL}
1396         },
1397         {       /* 11.9.2 - type 7 */
1398                 &hf_pkm_msg_attr_auth_key,
1399                 {"Auth Key", "wmx.pkm_msg.pkm_attr.auth_key", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1400         },
1401         {       /* 11.9.3 - type 8 */
1402                 &hf_pkm_msg_attr_tek,
1403                 {"TEK", "wmx.pkm_msg.pkm_attr.tek", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1404         },
1405         {       /* 11.9.4 - type 9 */
1406                 &hf_pkm_msg_attr_key_life_time,
1407                 {"Key Lifetime", "wmx.pkm_msg.pkm_attr.key_life_time", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}
1408         },
1409         {       /* 11.9.5 - type 10 */
1410                 &hf_pkm_msg_attr_key_seq_num,
1411                 {"Key Sequence Number", "wmx.pkm_msg.pkm_attr.key_seq_num", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}
1412         },
1413         {       /* 11.9.6 - type 11 */
1414                 &hf_pkm_msg_attr_hmac_digest,
1415                 {"HMAC-Digest", "wmx.pkm_msg.pkm_attr.hmac_digest", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1416         },
1417         {       /* 11.9.7 - type 12 */
1418                 &hf_pkm_msg_attr_said,
1419                 {"SAID", "wmx.pkm_msg.pkm_attr.said", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL}
1420         },
1421 #if 0   /* not been used */
1422         {       /* 11.9.8 - type 13 */
1423                 &hf_pkm_msg_attr_tek_param,
1424                 {"TEK Parameters", "wmx.pkm_msg.pkm_attr.tek_parameters", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1425         },
1426 #endif
1427         {       /* 11.9.9 - type 15 */
1428                 &hf_pkm_msg_attr_cbc_iv,
1429                 {"CBC IV", "wmx.pkm_msg.pkm_attr.cbc_iv", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1430         },
1431         {       /* 11.9.10 - type 16 */
1432                 &hf_pkm_msg_attr_error_code,
1433                 {"Error Code", "wmx.pkm_msg.pkm_attr.error_code", FT_UINT8, BASE_DEC, VALS(vals_pkm_attr_error_codes), 0x0, "", HFILL}
1434         },
1435         {       /* 11.9.11 - type 17 */
1436                 &hf_pkm_msg_attr_ca_certificate,
1437                 {"CA Certificate", "wmx.pkm_msg.pkm_attr.ca_certificate", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1438         },
1439         {       /* 11.9.12 - type 18 */
1440                 &hf_pkm_msg_attr_ss_certificate,
1441                 {"SS Certificate", "wmx.pkm_msg.pkm_attr.ss_certificate", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1442         },
1443 #if 0   /* not been used */
1444         {       /* 11.9.13 - type 19 */
1445                 &hf_pkm_msg_attr_security_capabilities,
1446                 {"Security Capabilities", "wmx.pkm_msg.pkm_attr.security_capabilities", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1447         },
1448 #endif
1449         {       /* 11.9.14 - type 20 */
1450                 &hf_pkm_msg_crypto_suite,
1451                 {"Cryptography", "wmx.pkm_msg.pkm_attr.crypto_suite", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1452         },
1453         {
1454                 &hf_pkm_msg_crypto_suite_msb,
1455                 {"Data Encryption Algorithm Identifiers", "wmx.pkm_msg.pkm_attr.crypto_suite.msb", FT_UINT8, BASE_DEC, VALS(vals_data_encryption_ids), 0x0, "", HFILL}
1456         },
1457         {
1458                 &hf_pkm_msg_crypto_suite_middle,
1459                 {"Data Authentication Algorithm Identifiers", "wmx.pkm_msg.pkm_attr.crypto_suite.middle", FT_UINT8, BASE_DEC, VALS(vals_data_authentication_ids), 0x0, "", HFILL}
1460         },
1461         {
1462                 &hf_pkm_msg_crypto_suite_lsb,
1463                 {"TEK Encryption Algorithm Identifiers", "wmx.pkm_msg.pkm_attr.crypto_suite.lsb", FT_UINT8, BASE_DEC, VALS(vals_tek_encryption_ids), 0x0, "", HFILL}
1464         },
1465 #if 0   /* not been used */
1466         {       /* 11.9.15 - type 21 */
1467                 &hf_pkm_msg_crypto_list,
1468                 {"Cryptographic-Suite List", "wmx.pkm_msg.pkm_attr.crypto_suite_list", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1469         },
1470 #endif
1471 #if 0   /* deleted by 802.16E */
1472         {       /* 11.9.16 - type 22 */
1473                 &hf_pkm_msg_version,
1474                 {"Reserved ", "wmx.pkm_msg.pkm_attr.version", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1475         },
1476 #endif
1477 #if 0   /* not been used */
1478         {       /* 11.9.17 - type 23 */
1479                 &hf_pkm_msg_sa_descriptor,
1480                 {"SA Descriptor", "wmx.pkm_msg.pkm_attr.sa_descriptor", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1481         },
1482 #endif
1483         {       /* 11.9.18 - type 24 */
1484                 &hf_pkm_sa_type,
1485                 {"SA Type", "wmx.pkm_msg.pkm_attr.sa_type", FT_UINT8, BASE_DEC, VALS(vs_sa_type), 0x0, "", HFILL}
1486         },
1487 #if 0   /* not been used */
1488         {       /* 11.9.?? - type 25 */
1489                 &hf_pkm_attr_security_negotiation_parameters,
1490                 {"Security Negotiation Parameters", "wmx.pkm_msg.pkm_attr.security_negotiation_parameters", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1491         },
1492 #endif
1493 #if 0   /* not been used */
1494         {       /* 11.9.19 - type 27 */
1495                 &hf_pkm_attr_config_settings,
1496                 {"PKM Configuration Settings", "wmx.pkm_msg.pkm_attr.config_settings", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1497         },
1498 #endif
1499         {       /* 11.9.19.1 */
1500                 &hf_pkm_config_settings_authorize_waitout,
1501                 {"Authorize Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.authorize_waitout", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1502         },
1503         {       /* 11.9.19.2 */
1504                 &hf_pkm_config_settings_reauthorize_waitout,
1505                 {"Reauthorize Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.reauthorize_waitout", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1506         },
1507         {       /* 11.9.19.3 */
1508                 &hf_pkm_config_settings_grace_time,
1509                 {"Authorization Grace Time (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.grace_time", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1510         },
1511         {       /* 11.9.19.4 */
1512                 &hf_pkm_config_settings_operational_waittime,
1513                 {"Operational Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.operational_wait_timeout", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1514         },
1515         {       /* 11.9.19.5 */
1516                 &hf_pkm_config_settings_rekey_wait_timeout,
1517                 {"Rekey Wait Timeout (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.rekey_wait_timeout", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1518         },
1519         {       /* 11.9.19.6 */
1520                 &hf_pkm_config_settings_tek_grace_time,
1521                 {"TEK Grace Time (in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.tek_grace_time", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1522         },
1523         {       /* 11.9.19.7 */
1524                 &hf_pkm_config_settings_authorize_reject_wait_timeout,
1525                 {"Authorize Reject Wait Timeout(in seconds)", "wmx.pkm_msg.pkm_attr.config_settings.authorize_reject_wait_timeout", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL}
1526         },
1527         {       /* 11.9.20 - type 29 */
1528                 &hf_pkm_attr_nonce,
1529                 {"Nonce", "wmx.pkm_msg.pkm_attr.nonce", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1530         },
1531         {       /* 11.9.21 - type 33 */
1532                 &hf_pkm_attr_ss_random,
1533                 {"SS_RANDOM", "wmx.pkm_msg.pkm_attr.ss_random", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1534         },
1535         {       /* 11.9.22 - type 34 */
1536                 &hf_pkm_attr_bs_random,
1537                 {"BS_RANDOM", "wmx.pkm_msg.pkm_attr.bs_random", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1538         },
1539         {       /* 11.9.23 - type 35 */
1540                 &hf_pkm_attr_pre_pak,
1541                 {"Pre-PAK", "wmx.pkm_msg.pkm_attr.pre_pak", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1542         },
1543 #if 1   /* no definition */
1544         {       /* 11.9.?? - type 36 */
1545                 &hf_pkm_attr_pak_ak_seq_number,
1546                 {"PAK/AK Sequence Number", "wmx.pkm_msg.pkm_attr.pak_ak_seq_number", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1547         },
1548 #endif
1549         {       /* 11.9.24 - type 37 */
1550                 &hf_pkm_attr_bs_certificate,
1551                 {"BS Certificate", "wmx.pkm_msg.pkm_attr.bs_certificate", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1552         },
1553         {       /* 11.9.25 - type 38 */
1554                 &hf_pkm_attr_sig_bs,
1555                 {"SigBS", "wmx.pkm_msg.pkm_attr.sig_bs",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1556         },
1557         {       /* 11.9.26 - type 39 */
1558                 &hf_pkm_attr_ms_mac_address,
1559                 {"MS-MAC Address", "wmx.pkm_msg.pkm_attr.ms_mac_address",FT_ETHER, BASE_HEX, NULL, 0x0, "", HFILL}
1560         },
1561         {       /* 11.9.27 - type 40 */
1562                 &hf_pkm_attr_cmac_digest,
1563                 {"CMAC Digest", "wmx.pkm_msg.pkm_attr.cmac_digest",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1564         },
1565         {
1566                 &hf_pkm_attr_cmac_digest_pn,
1567                 {"CMAC Packet Number counter, CMAC_PN_*", "wmx.pkm_msg.pkm_attr.cmac_digest.pn",FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL}
1568         },
1569         {
1570                 &hf_pkm_attr_cmac_digest_value,
1571                 {"CMAC Value", "wmx.pkm_msg.pkm_attr.cmac_digest.value",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1572         },
1573         {       /* 11.9.28 - type 41 */
1574                 &hf_pkm_attr_push_modes,
1575                 {"Key Push Modes", "wmx.pkm_msg.pkm_attr.key_push_modes",FT_UINT8, BASE_DEC, VALS(va_key_push_modes), 0x0, "", HFILL}
1576         },
1577         {       /* 11.9.29 - type 42 */
1578                 &hf_pkm_attr_key_push_counter,
1579                 {"Key Push Counter", "wmx.pkm_msg.pkm_attr.key_push_counter",FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1580         },
1581         {       /* 11.9.30 - type 43 */
1582                 &hf_pkm_attr_gkek,
1583                 {"GKEK", "wmx.pkm_msg.pkm_attr.gkek",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1584         },
1585         {       /* 11.9.31 - type 44 */
1586                 &hf_pkm_attr_sig_ss,
1587                 {"SigSS", "wmx.pkm_msg.pkm_attr.sig_ss",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1588         },
1589         {       /* 11.9.32 - type 45 */
1590                 &hf_pkm_attr_akid,
1591                 {"AKID", "wmx.pkm_msg.pkm_attr.akid",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1592         },
1593         {       /* 11.9.33 - type 28 */
1594                 &hf_pkm_attr_eap_payload,
1595                 {"EAP Payload", "wmx.pkm_msg.pkm_attr.eap_payload", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1596         },
1597         {       /* 11.9.34 - type 30 */
1598                 &hf_pkm_attr_auth_result_code,
1599                 {"Auth Result Code", "wmx.pkm_msg.pkm_attr.auth_result_code", FT_UINT8, BASE_DEC, VALS(vs_success_reject), 0x0, "", HFILL}
1600         },
1601         {       /* 11.9.35 - type 31 */
1602                 &hf_pkm_attr_sa_service_type,
1603                 {"SA Service Type", "wmx.pkm_msg.pkm_attr.sa_service_type", FT_UINT8, BASE_DEC, VALS(vs_sa_service_type), 0x0, "", HFILL}
1604         },
1605 #if 0   /* same as 11.9.19 */
1606         {       /* 11.9.36 - type 27 */
1607                 &hf_pkm_attr_config_settings,
1608                 {"PKMv2 Configuration Settings", "wmx.pkm_msg.pkm_attr.config_settings", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1609         },
1610 #endif
1611         {       /* 11.9.37 - type 32 */
1612                 &hf_pkm_attr_frame_number,
1613                 {"Frame Number", "wmx.pkm_msg.pkm_attr.frame_number", FT_UINT24, BASE_DEC, NULL, 0x0, "", HFILL}
1614         },
1615 #if 1   /* no definitions */
1616         {       /* 11.9.?? - type 46 */
1617                 &hf_pkm_attr_associated_gkek_seq_number,
1618                 {"Associated GKEK Sequence Number", "wmx.pkm_msg.pkm_attr.associated_gkek_seq_number",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1619         },
1620         {       /* 11.9.?? - type 47 */
1621                 &hf_pkm_attr_gkek_params,
1622                 {"GKEK Parameters", "wmx.pkm_msg.pkm_attr.gkek_params",FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1623         },
1624 #endif
1625         {
1626                 &hf_pkm_msg_unknown_type,
1627                 {"Unknown Type", "wmx.pkm.unknown.type", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1628         }
1629 };
1630
1631 static gint hf_common_tlv_unknown_type = -1;
1632 static gint hf_common_tlv_mac_version = -1;
1633 static gint hf_common_tlv_vendor_id = -1;
1634 static gint hf_common_tlv_vendor_specific_type = -1;
1635 static gint hf_common_tlv_vendor_specific_length = -1;
1636 static gint hf_common_tlv_vendor_specific_length_size = -1;
1637 static gint hf_common_tlv_vendor_specific_value = -1;
1638
1639 /* WiMax Common TLV Encoding display */
1640 static hf_register_info hf_common_tlv[] =
1641 {
1642         {
1643                 &hf_common_tlv_mac_version,
1644                 { "MAC Version", "wmx.common_tlv.mac_version", FT_UINT8, BASE_DEC, VALS(vals_dcd_mac_version), 0x0, "", HFILL}
1645         },
1646         {
1647                 &hf_common_tlv_vendor_id,
1648                 { "Vendor ID Encoding", "wmx.common_tlv.vendor_id_encoding", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1649         },
1650         {
1651                 &hf_common_tlv_vendor_specific_type,
1652                 { "Vendor Specific Type", "wmx.common_tlv.vendor_specific_type", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL}
1653         },
1654         {
1655                 &hf_common_tlv_vendor_specific_length_size,
1656                 {
1657                         "Vendor Specific Length Size", "wmx.common_tlv.vendor_specific_length_size",
1658                         FT_UINT8, BASE_HEX, NULL, 0x0,
1659                         "", HFILL
1660                 }
1661         },
1662         {
1663                 &hf_common_tlv_vendor_specific_length,
1664                 { "Vendor Specific Length", "wmx.common_tlv.vendor_specific_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL}
1665         },
1666         {
1667                 &hf_common_tlv_vendor_specific_value,
1668                 { "Vendor Specific Value", "wmx.common_tlv.vendor_specific_value", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1669         },
1670         {
1671                 &hf_common_tlv_unknown_type,
1672                 {"Unknown Common TLV Type", "wmx.common_tlv.unknown_type", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL}
1673         }
1674 };
1675
1676 /* Register WiMax Utility Routines */
1677 void proto_register_wimax_utility_decoders(void)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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(pinfo->cinfo)
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                         proto_tree_add_item(tlv_tree, hf_snp_max_conc_transactions, tvb, offset, 1, FALSE);
2716                 break;
2717                 case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETER_SUB_MAX_SUPPT_SECURITY_ASSNS:
2718                         proto_tree_add_item(tlv_tree, hf_snp_max_suppt_sec_assns, tvb, offset, 1, FALSE);
2719                 break;
2720                 default:
2721                         tlv_tree = add_tlv_subtree(&tlv_info, ett_security_negotiation_parameters, tree, hf_snp_unknown_type, tvb, offset, tlv_len, FALSE);
2722                         proto_tree_add_item(tlv_tree, hf_snp_unknown_type, tvb, offset, tlv_len, FALSE);
2723                 break;
2724                 }
2725                 offset += tlv_len;
2726         }
2727 }
2728
2729 /******************************************************************/
2730 /* wimax_cryptographic_suite_list_decoder()                       */
2731 /* decode and display the WiMax Cryptographic Suite List           */
2732 /* parameter:                                                     */
2733 /*   tvb - pointer of the tvb of service flow encodings           */
2734 /*   tree - pointer of Wireshark display tree                     */
2735 /*   pinfo - pointer of Wireshark packet information structure    */
2736 /******************************************************************/
2737 void wimax_cryptographic_suite_list_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2738 {
2739         guint offset;
2740         guint tvb_len, tlv_len, tlv_value_offset;
2741         gint  tlv_type;
2742         proto_tree *tlv_tree = NULL;
2743         tlv_info_t tlv_info;
2744
2745         /* get the tvb reported length */
2746         tvb_len = tvb_reported_length(tvb);
2747         /* do nothing if the TLV fields is not exist */
2748         if(!tvb_len)
2749                 return;
2750         /* report error if the packet size is less than 2 bytes (type+length) */
2751         if(tvb_len < 2)
2752         {       /* invalid tlv info */
2753                 if(pinfo->cinfo)
2754                 {
2755                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Crypto Suite List");
2756                 }
2757                 return;
2758         }
2759         /* process Cryptographic Suite List (11.9.15) */
2760         for(offset = 0; offset < tvb_len; )
2761         {       /* get the TLV information */
2762                 init_tlv_info(&tlv_info, tvb, offset);
2763                 /* get the TLV type */
2764                 tlv_type = get_tlv_type(&tlv_info);
2765                 /* get the TLV length */
2766                 tlv_len = get_tlv_length(&tlv_info);
2767                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
2768                 {       /* invalid tlv info */
2769                         if(pinfo->cinfo)
2770                         {
2771                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Crypto Suite List TLV error");
2772                         }
2773                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
2774                         break;
2775                 }
2776                 /* get the TLV value offset */
2777                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
2778 #ifdef DEBUG /* for debug only */
2779                 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);
2780 #endif
2781                 /* update the offset for the TLV value */
2782                 offset += tlv_value_offset;
2783                 /* parse Cryptographic Suite List */
2784                 switch (tlv_type)
2785                 {
2786                         case PKM_ATTR_CRYPTO_SUITE:
2787                                 /* add subtree */
2788                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_cryptographic_suite_list_decoder, tree, hf_pkm_msg_crypto_suite, tvb, offset, tlv_len, FALSE);
2789                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_msb, tvb, offset, 1, FALSE);
2790                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_middle, tvb, offset+1, 1, FALSE);
2791                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_lsb, tvb, offset+2, 1, FALSE);
2792                         break;
2793                         default:
2794                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_cryptographic_suite_list_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
2795                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
2796                         break;
2797                 }
2798                 offset += tlv_len;
2799         }       /* end of TLV process while loop */
2800 }
2801
2802 /******************************************************************/
2803 /* wimax_pkm_tlv_encoded_attributes_decoder()                     */
2804 /* decode and display the WiMax PKM message TLV Encoded Attributes*/
2805 /* parameter:                                                     */
2806 /*   tvb - pointer of the tvb of service flow encodings           */
2807 /*   tree - pointer of Wireshark display tree                     */
2808 /*   pinfo - pointer of Wireshark packet information structure    */
2809 /******************************************************************/
2810 void wimax_pkm_tlv_encoded_attributes_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2811 {
2812         guint offset;
2813         guint tvb_len, tlv_len, tlv_value_offset;
2814         gint  tlv_type;
2815         proto_tree *tlv_tree = NULL;
2816         tlv_info_t tlv_info;
2817
2818         /* get the tvb reported length */
2819         tvb_len = tvb_reported_length(tvb);
2820         /* do nothing if the TLV fields is not exist */
2821         if(!tvb_len)
2822                 return;
2823         /* report error if the packet size is less than 2 bytes (type+length) */
2824         if(tvb_len < 2)
2825         {       /* invalid tlv info */
2826                 if(pinfo->cinfo)
2827                 {
2828                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid PKM TLV");
2829                 }
2830                 return;
2831         }
2832         /* process PKM message TLV Encoded Attributes (11.9) */
2833         for(offset = 0; offset < tvb_len; )
2834         {
2835                 /* get the TLV information */
2836                 init_tlv_info(&tlv_info, tvb, offset);
2837                 /* get the TLV type */
2838                 tlv_type = get_tlv_type(&tlv_info);
2839                 /* get the TLV length */
2840                 tlv_len = get_tlv_length(&tlv_info);
2841                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
2842                 {       /* invalid tlv info */
2843                         if(pinfo->cinfo)
2844                         {
2845                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "PKM TLV error");
2846                         }
2847                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
2848                         break;
2849                 }
2850                 /* get the TLV value offset */
2851                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
2852 #ifdef DEBUG /* for debug only */
2853                 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);
2854 #endif
2855                 /* update the offset for the TLV value */
2856                 offset += tlv_value_offset;
2857                 /* parse PKM TLV Encoded Attributes (table 370) */
2858                 switch (tlv_type)
2859                 {
2860                         case PKM_ATTR_DISPLAY_STRING:
2861                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_display, tvb, offset, tlv_len, FALSE);
2862                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_display, tvb, offset, tlv_len, FALSE);
2863                         break;
2864                         case PKM_ATTR_AUTH_KEY:
2865                                 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);
2866                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_auth_key, tvb, offset, tlv_len, FALSE);
2867                         break;
2868                         case PKM_ATTR_TEK:
2869                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
2870                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
2871                         break;
2872                         case PKM_ATTR_KEY_LIFE_TIME:
2873                                 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);
2874                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_life_time, tvb, offset, tlv_len, FALSE);
2875                         break;
2876                         case PKM_ATTR_KEY_SEQ_NUM:
2877                                 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);
2878                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_seq_num, tvb, offset, tlv_len, FALSE);
2879                         break;
2880                         case PKM_ATTR_HMAC_DIGEST:
2881                                 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);
2882                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_hmac_digest, tvb, offset, tlv_len, FALSE);
2883                         break;
2884                         case PKM_ATTR_SAID:
2885                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
2886                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
2887                         break;
2888                         case PKM_ATTR_TEK_PARAM:
2889                                 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);
2890                                 /* add subtree */
2891                                 wimax_tek_parameters_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2892                         break;
2893                         case PKM_ATTR_CBC_IV:
2894                                 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);
2895                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_cbc_iv, tvb, offset, tlv_len, FALSE);
2896                         break;
2897                         case PKM_ATTR_ERROR_CODE:
2898                                 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);
2899                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_error_code, tvb, offset, tlv_len, FALSE);
2900                         break;
2901                         case PKM_ATTR_CA_CERTIFICATE:
2902                                 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);
2903                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_ca_certificate, tvb, offset, tlv_len, FALSE);
2904                         break;
2905                         case PKM_ATTR_SS_CERTIFICATE:
2906                                 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);
2907                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_ss_certificate, tvb, offset, tlv_len, FALSE);
2908                         break;
2909                         case PKM_ATTR_SECURITY_CAPABILITIES:
2910                                 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);
2911                                 /* add subtree */
2912                                 wimax_security_capabilities_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2913                         break;
2914                         case PKM_ATTR_CRYPTO_SUITE:
2915                                 /* add subtree */
2916                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_crypto_suite, tvb, offset, tlv_len, FALSE);
2917                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_msb, tvb, offset, 1, FALSE);
2918                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_middle, tvb, offset+1, 1, FALSE);
2919                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_lsb, tvb, offset+2, 1, FALSE);
2920                         break;
2921                         case PKM_ATTR_CRYPTO_LIST:
2922                                 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);
2923                                 /* add subtree */
2924                                 wimax_cryptographic_suite_list_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2925                         break;
2926 #if 0 /* rserved by IEE 802.16E */
2927                         case PKM_ATTR_VERSION:
2928                                 proto_tree_add_item(tree, hf_pkm_msg_version, tvb, offset, tlv_len, FALSE);
2929                         break;
2930 #endif
2931                         case PKM_ATTR_SA_DESCRIPTOR:
2932                                 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);
2933                                 /* add subtree */
2934                                 wimax_sa_descriptor_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2935                         break;
2936                         case PKM_ATTR_SA_TYPE:
2937                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
2938                                 proto_tree_add_item(tlv_tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
2939                         break;
2940                         case PKM_ATTR_SECURITY_NEGOTIATION_PARAMETERS:
2941                                 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);
2942                                 /* add subtree */
2943                                 wimax_security_negotiation_parameters_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2944                         break;
2945                         case PKM_ATTR_PKM_CONFIG_SETTINGS:
2946                                 /* add subtree */
2947                                 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);
2948                                 wimax_pkm_configuration_settings_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2949                         break;
2950                         case PKM_ATTR_PKM_EAP_PAYLOAD:
2951                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_eap_payload, tvb, offset, tlv_len, FALSE);
2952                                 if (eap_handle)
2953                                         call_dissector(eap_handle, tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
2954                                 else
2955                                         proto_tree_add_item(tlv_tree, hf_pkm_attr_eap_payload, tvb, offset, tlv_len, FALSE);
2956                         break;
2957                         case PKM_ATTR_PKM_NONCE:
2958                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_nonce, tvb, offset, tlv_len, FALSE);
2959                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_nonce, tvb, offset, tlv_len, FALSE);
2960                         break;
2961                         case PKM_ATTR_AUTH_RESULT_CODE:
2962                                 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);
2963                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_auth_result_code, tvb, offset, tlv_len, FALSE);
2964                         break;
2965                         case PKM_ATTR_SA_SERVICE_TYPE:
2966                                 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);
2967                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
2968                         break;
2969                         case PKM_ATTR_FRAME_NUMBER:
2970                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_frame_number, tvb, offset, tlv_len, FALSE);
2971                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_frame_number, tvb, offset, tlv_len, FALSE);
2972                         break;
2973                         case PKM_ATTR_SS_RANDOM:
2974                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_ss_random, tvb, offset, tlv_len, FALSE);
2975                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_ss_random, tvb, offset, tlv_len, FALSE);
2976                         break;
2977                         case PKM_ATTR_BS_RANDOM:
2978                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_bs_random, tvb, offset, tlv_len, FALSE);
2979                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_bs_random, tvb, offset, tlv_len, FALSE);
2980                         break;
2981                         case PKM_ATTR_PRE_PAK:
2982                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_pre_pak, tvb, offset, tlv_len, FALSE);
2983                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_pre_pak, tvb, offset, tlv_len, FALSE);
2984                         break;
2985                         case PKM_ATTR_BS_CERTIFICATE:
2986                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_bs_certificate, tvb, offset, tlv_len, FALSE);
2987                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_bs_certificate, tvb, offset, tlv_len, FALSE);
2988                         break;
2989                         case PKM_ATTR_SIG_BS:
2990                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_sig_bs, tvb, offset, tlv_len, FALSE);
2991                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sig_bs, tvb, offset, tlv_len, FALSE);
2992                         break;
2993                         case PKM_ATTR_MS_MAC_ADDRESS:
2994                                 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);
2995                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_ms_mac_address, tvb, offset, tlv_len, FALSE);
2996                         break;
2997                         case PKM_ATTR_CMAC_DIGEST:
2998                                 /* add TLV subtree */
2999                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_cmac_digest, tvb, offset, tlv_len, FALSE);
3000                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_cmac_digest_pn, tvb, offset, 4, FALSE);
3001                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_cmac_digest_value, tvb, (offset + 4), 8, FALSE);
3002                         break;
3003                         case PKM_ATTR_KEY_PUSH_MODES:
3004                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_push_modes, tvb, offset, tlv_len, FALSE);
3005                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_push_modes, tvb, offset, tlv_len, FALSE);
3006                         break;
3007                         case PKM_ATTR_KEY_PUSH_COUNTER:
3008                                 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);
3009                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_key_push_counter, tvb, offset, tlv_len, FALSE);
3010                         break;
3011                         case PKM_ATTR_GKEK:
3012                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_gkek, tvb, offset, tlv_len, FALSE);
3013                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_gkek, tvb, offset, tlv_len, FALSE);
3014                         break;
3015                         case PKM_ATTR_SIG_SS:
3016                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_sig_ss, tvb, offset, tlv_len, FALSE);
3017                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sig_ss, tvb, offset, tlv_len, FALSE);
3018                         break;
3019                         case PKM_ATTR_AKID:
3020                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_attr_akid, tvb, offset, tlv_len, FALSE);
3021                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_akid, tvb, offset, tlv_len, FALSE);
3022                         break;
3023                         default:
3024                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3025                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3026                         break;
3027                 }
3028                 offset += tlv_len;
3029         }       /* end of TLV process while loop */
3030 }
3031
3032 /******************************************************************/
3033 /* wimax_tek_parameters_decoder()                                 */
3034 /* decode and display the WiMax TEK Parameters subattributes      */
3035 /* parameter:                                                     */
3036 /*   tvb - pointer of the tvb of service flow encodings           */
3037 /*   tree - pointer of Wireshark display tree                     */
3038 /*   pinfo - pointer of Wireshark packet information structure    */
3039 /******************************************************************/
3040 void wimax_tek_parameters_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3041 {
3042         guint offset;
3043         guint tvb_len, tlv_len, tlv_value_offset;
3044         gint  tlv_type;
3045         proto_tree *tlv_tree = NULL;
3046         tlv_info_t tlv_info;
3047
3048         /* get the tvb reported length */
3049         tvb_len = tvb_reported_length(tvb);
3050         /* do nothing if the TLV fields is not exist */
3051         if(!tvb_len)
3052                 return;
3053         /* report error if the packet size is less than 2 bytes (type+length) */
3054         if(tvb_len < 2)
3055         {       /* invalid tlv info */
3056                 if(pinfo->cinfo)
3057                 {
3058                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid TEK Params");
3059                 }
3060                 return;
3061         }
3062         /* process PKM Message TEK Parameters (11.9.8) */
3063         for(offset = 0; offset < tvb_len; )
3064         {
3065                 /* get the TLV information */
3066                 init_tlv_info(&tlv_info, tvb, offset);
3067                 /* get the TLV type */
3068                 tlv_type = get_tlv_type(&tlv_info);
3069                 /* get the TLV length */
3070                 tlv_len = get_tlv_length(&tlv_info);
3071                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3072                 {       /* invalid tlv info */
3073                         if(pinfo->cinfo)
3074                         {
3075                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "TEK Param TLV error");
3076                         }
3077                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3078                         break;
3079                 }
3080                 /* get the TLV value offset */
3081                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3082 #ifdef DEBUG /* for debug only */
3083                 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);
3084 #endif
3085                 /* update the offset for the TLV value */
3086                 offset += tlv_value_offset;
3087                 /* parse TEK Parameters Subattributes (table 372) */
3088                 switch (tlv_type)
3089                 {
3090                         case PKM_ATTR_TEK:
3091                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
3092                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_tek, tvb, offset, tlv_len, FALSE);
3093                         break;
3094                         case PKM_ATTR_KEY_LIFE_TIME:
3095                                 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);
3096                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_life_time, tvb, offset, tlv_len, FALSE);
3097                         break;
3098                         case PKM_ATTR_KEY_SEQ_NUM:
3099                                 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);
3100                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_key_seq_num, tvb, offset, tlv_len, FALSE);
3101                         break;
3102                         case PKM_ATTR_CBC_IV:
3103                                 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);
3104                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_cbc_iv, tvb, offset, tlv_len, FALSE);
3105                         break;
3106                         case PKM_ATTR_ASSOCIATED_GKEK_SEQ_NUM:
3107                                 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);
3108                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_associated_gkek_seq_number, tvb, offset, tlv_len, FALSE);
3109                         break;
3110                         default:
3111                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_pkm_tlv_encoded_attributes_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3112                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3113                         break;
3114                 }
3115                 offset += tlv_len;
3116         }       /* end of TLV process while loop */
3117 }
3118
3119 /******************************************************************/
3120 /* wimax_pkm_configuration_settings_decoder()                     */
3121 /* decode and display the WiMax PKM Configuration Settings        */
3122 /* parameter:                                                     */
3123 /*   tvb - pointer of the tvb of service flow encodings           */
3124 /*   tree - pointer of Wireshark display tree                     */
3125 /*   pinfo - pointer of Wireshark packet information structure    */
3126 /******************************************************************/
3127 void wimax_pkm_configuration_settings_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3128 {
3129         guint offset;
3130         guint tvb_len, tlv_len, tlv_value_offset;
3131         gint  tlv_type;
3132         proto_tree *tlv_tree;
3133         tlv_info_t tlv_info;
3134
3135         /* get the tvb reported length */
3136         tvb_len = tvb_reported_length(tvb);
3137         /* do nothing if the TLV fields is not exist */
3138         if(!tvb_len)
3139                 return;
3140         /* report error if the packet size is less than 2 bytes (type+length) */
3141         if(tvb_len < 2)
3142         {       /* invalid tlv info */
3143                 if(pinfo->cinfo)
3144                 {
3145                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid PKM Config Settings");
3146                 }
3147                 return;
3148         }
3149         /* process PKM Configuration Settings (11.9.19) */
3150         for(offset = 0; offset < tvb_len; )
3151         {
3152                 /* get the TLV information */
3153                 init_tlv_info(&tlv_info, tvb, offset);
3154                 /* get the TLV type */
3155                 tlv_type = get_tlv_type(&tlv_info);
3156                 /* get the TLV length */
3157                 tlv_len = get_tlv_length(&tlv_info);
3158                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3159                 {       /* invalid tlv info */
3160                         if(pinfo->cinfo)
3161                         {
3162                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "PKM Config Settings TLV error");
3163                         }
3164                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3165                         break;
3166                 }
3167                 /* get the TLV value offset */
3168                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3169 #ifdef DEBUG /* for debug only */
3170                 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);
3171 #endif
3172                 /* update the offset for the TLV value */
3173                 offset += tlv_value_offset;
3174                 /* parse PKM Configuration Settings (11.9.19.1 - 11.9.19.7 */
3175                 switch (tlv_type)
3176                 {
3177                         case PKM_ATTR_PKM_CONFIG_SETTINGS_AUTHORIZE_WAIT_TIMEOUT:
3178                                 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);
3179                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_authorize_waitout, tvb, offset, tlv_len, FALSE);
3180                         break;
3181                         case PKM_ATTR_PKM_CONFIG_SETTINGS_REAUTHORIZE_WAIT_TIMEOUT:
3182                                 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);
3183                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_reauthorize_waitout, tvb, offset, tlv_len, FALSE);
3184                         break;
3185                         case PKM_ATTR_PKM_CONFIG_SETTINGS_AUTHORIZATION_GRACE_TIME:
3186                                 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);
3187                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_grace_time, tvb, offset, tlv_len, FALSE);
3188                         break;
3189                         case PKM_ATTR_PKM_CONFIG_SETTINGS_OPERATIONAL_WAIT_TIMEOUT:
3190                                 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);
3191                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_operational_waittime, tvb, offset, tlv_len, FALSE);
3192                         break;
3193                         case PKM_ATTR_PKM_CONFIG_SETTINGS_REKEY_WAIT_TIMEOUT:
3194                                 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);
3195                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_rekey_wait_timeout, tvb, offset, tlv_len, FALSE);
3196                         break;
3197                         case PKM_ATTR_PKM_CONFIG_SETTINGS_TEK_GRACE_TIME:
3198                                 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);
3199                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_tek_grace_time, tvb, offset, tlv_len, FALSE);
3200                         break;
3201                         case PKM_ATTR_PKM_CONFIG_SETTINGS_AUTHORIZE_REJECT_WAIT_TIMEOUT:
3202                                 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);
3203                                 proto_tree_add_item(tlv_tree, hf_pkm_config_settings_authorize_reject_wait_timeout, tvb, offset, tlv_len, FALSE);
3204                         break;
3205                         default:
3206                                 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);
3207                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3208                         break;
3209                 }
3210                 offset += tlv_len;
3211         }       /* end of TLV process while loop */
3212 }
3213
3214 /******************************************************************/
3215 /* wimax_sa_descriptor_decoder()                                  */
3216 /* decode and display the WiMax PKM message SA-Descriptor         */
3217 /* parameter:                                                     */
3218 /*   tvb - pointer of the tvb of service flow encodings           */
3219 /*   tree - pointer of Wireshark display tree                     */
3220 /*   pinfo - pointer of Wireshark packet information structure    */
3221 /******************************************************************/
3222 void wimax_sa_descriptor_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3223 {
3224         guint offset;
3225         guint tvb_len, tlv_len, tlv_value_offset;
3226         gint  tlv_type;
3227         proto_tree *tlv_tree = NULL;
3228         tlv_info_t tlv_info;
3229
3230         /* get the tvb reported length */
3231         tvb_len = tvb_reported_length(tvb);
3232         /* do nothing if the TLV fields is not exist */
3233         if(!tvb_len)
3234                 return;
3235         /* report error if the packet size is less than 2 bytes (type+length) */
3236         if(tvb_len < 2)
3237         {       /* invalid tlv info */
3238                 if(pinfo->cinfo)
3239                 {
3240                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid SA-Descriptor");
3241                 }
3242                 return;
3243         }
3244         /* process SA-Descriptor (11.9.17) */
3245         for(offset = 0; offset < tvb_len; )
3246         {
3247                 /* get the TLV information */
3248                 init_tlv_info(&tlv_info, tvb, offset);
3249                 /* get the TLV type */
3250                 tlv_type = get_tlv_type(&tlv_info);
3251                 /* get the TLV length */
3252                 tlv_len = get_tlv_length(&tlv_info);
3253                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3254                 {       /* invalid tlv info */
3255                         if(pinfo->cinfo)
3256                         {
3257                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "SA-Descriptor TLV error");
3258                         }
3259                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3260                         break;
3261                 }
3262                 /* get the TLV value offset */
3263                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3264 #ifdef DEBUG /* for debug only */
3265                 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);
3266 #endif
3267                 /* update the offset for the TLV value */
3268                 offset += tlv_value_offset;
3269                 /* parse SA-Descriptor (table 380) */
3270                 switch (tlv_type)
3271                 {
3272                         case PKM_ATTR_SAID:
3273                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
3274                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_attr_said, tvb, offset, tlv_len, FALSE);
3275                         break;
3276                         case PKM_ATTR_SA_TYPE:
3277                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
3278                                 proto_tree_add_item(tlv_tree, hf_pkm_sa_type, tvb, offset, tlv_len, FALSE);
3279                         break;
3280                         case PKM_ATTR_SA_SERVICE_TYPE:
3281                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
3282                                 proto_tree_add_item(tlv_tree, hf_pkm_attr_sa_service_type, tvb, offset, tlv_len, FALSE);
3283                         break;
3284                         case PKM_ATTR_CRYPTO_SUITE:
3285                                 /* add subtree */
3286                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_msg_crypto_suite, tvb, offset, tlv_len, FALSE);
3287                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_msb, tvb, offset, 1, FALSE);
3288                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_middle, tvb, offset+1, 1, FALSE);
3289                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_crypto_suite_lsb, tvb, offset+2, 1, FALSE);
3290                         break;
3291                         default:
3292                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_sa_descriptor_decoder, tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3293                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3294                         break;
3295                 }
3296                 offset += tlv_len;
3297         }       /* end of TLV process while loop */
3298 }
3299
3300 /******************************************************************/
3301 /* wimax_security_capabilities_decoder()                          */
3302 /* decode and display the WiMax Security Capabilities             */
3303 /* parameter:                                                     */
3304 /*   tvb - pointer of the tvb of service flow encodings           */
3305 /*   tree - pointer of Wireshark display tree                     */
3306 /*   pinfo - pointer of Wireshark packet information structure    */
3307 /******************************************************************/
3308 void wimax_security_capabilities_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3309 {
3310         guint offset;
3311         guint tvb_len, tlv_len, tlv_value_offset;
3312         gint  tlv_type;
3313         proto_tree *tlv_tree = NULL;
3314         tlv_info_t tlv_info;
3315
3316         /* get the tvb reported length */
3317         tvb_len = tvb_reported_length(tvb);
3318         /* do nothing if the TLV fields is not exist */
3319         if(!tvb_len)
3320                 return;
3321         /* report error if the packet size is less than 2 bytes (type+length) */
3322         if(tvb_len < 2)
3323         {       /* invalid tlv info */
3324                 if(pinfo->cinfo)
3325                 {
3326                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Security Capabilities");
3327                 }
3328                 return;
3329         }
3330         /* process Security Capabilities (11.9.13) */
3331         for(offset = 0; offset < tvb_len; )
3332         {
3333                 /* get the TLV information */
3334                 init_tlv_info(&tlv_info, tvb, offset);
3335                 /* get the TLV type */
3336                 tlv_type = get_tlv_type(&tlv_info);
3337                 /* get the TLV length */
3338                 tlv_len = get_tlv_length(&tlv_info);
3339                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3340                 {       /* invalid tlv info */
3341                         if(pinfo->cinfo)
3342                         {
3343                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Security Capabilities TLV error");
3344                         }
3345                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3346                         break;
3347                 }
3348                 /* get the TLV value offset */
3349                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3350 #ifdef DEBUG /* for debug only */
3351                 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);
3352 #endif
3353                 /* update the offset for the TLV value */
3354                 offset += tlv_value_offset;
3355                 /* parse Security Capabilities (table 374) */
3356                 switch (tlv_type)
3357                 {
3358                         case PKM_ATTR_CRYPTO_LIST:
3359                                 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);
3360                                 /* add subtree */
3361                                 wimax_cryptographic_suite_list_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
3362                         break;
3363                         default:
3364                                 tlv_tree = add_tlv_subtree(&tlv_info, ett_security_capabilities_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, FALSE);
3365                                 proto_tree_add_item(tlv_tree, hf_pkm_msg_unknown_type, tvb, offset, tlv_len, FALSE);
3366                         break;
3367                 }
3368                 offset += tlv_len;
3369         }       /* end of TLV process while loop */
3370 }
3371
3372 /******************************************************************/
3373 /* wimax_vendor_specific_information_decoder()                    */
3374 /* decode and display the WiMax Vendor-Specific Information       */
3375 /* parameter:                                                     */
3376 /*   tvb - pointer of the tvb of service flow encodings           */
3377 /*   tree - pointer of Wireshark display tree                     */
3378 /*   pinfo - pointer of Wireshark packet information structure    */
3379 /******************************************************************/
3380 void wimax_vendor_specific_information_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3381 {
3382         proto_tree *tlv_tree = NULL;
3383         guint offset;
3384         guint tvb_len, tlv_len, tlv_value_offset;
3385         gint  tlv_type;
3386         tlv_info_t tlv_info;
3387
3388         /* get the tvb reported length */
3389         tvb_len = tvb_reported_length(tvb);
3390         /* do nothing if the TLV fields is not exist */
3391         if(!tvb_len)
3392                 return;
3393         /* report error if the packet size is less than 2 bytes (type+length) */
3394         if(tvb_len < 2)
3395         {       /* invalid tlv info */
3396                 if(pinfo->cinfo)
3397                 {
3398                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Vendor Specific Info");
3399                 }
3400                 proto_tree_add_text(tree, tvb, 0, tvb_len, "Invalid TLV info");
3401                 return;
3402         }
3403         /* process Vendor Specific Information (11.1.6) */
3404         for(offset = 0; offset < tvb_len; )
3405         {
3406                 /* get the TLV information */
3407                 init_tlv_info(&tlv_info, tvb, offset);
3408                 /* get the TLV type */
3409                 tlv_type = get_tlv_type(&tlv_info);
3410                 /* get the TLV length */
3411                 tlv_len = get_tlv_length(&tlv_info);
3412                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3413                 {       /* invalid tlv info */
3414                         if(pinfo->cinfo)
3415                         {
3416                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Vendor Specific Info TLV error");
3417                         }
3418                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3419                         break;
3420                 }
3421                 /* get the TLV value offset */
3422                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3423 #ifdef DEBUG /* for debug only */
3424                 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);
3425 #endif
3426                 /* parse Vendor Specific Information (11.1.6) */
3427                 if(tlv_type == VENDOR_ID_ENCODING)
3428                 {
3429                         /* decode and display the Vendor ID Encoding */
3430                         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);
3431                         proto_tree_add_item(tlv_tree, hf_common_tlv_vendor_id, tvb, (offset + tlv_value_offset), tlv_len, FALSE);
3432                 }
3433                 else
3434                 {
3435                         /* decode and display the Vendor Specific Info */
3436                         proto_tree_add_item(tree, hf_common_tlv_vendor_specific_type, tvb, offset, 1, FALSE);
3437                         if(get_tlv_length_type(&tlv_info) == 0)
3438                         {       /* single byte TLV length */
3439                                 proto_tree_add_item(tree, hf_common_tlv_vendor_specific_length, tvb, (offset + 1), 1, FALSE);
3440                         }
3441                         else
3442                         {       /* multiple bytes TLV length */
3443                                 /* display the length of the TLV length with MSB */
3444                                 proto_tree_add_item(tree, hf_common_tlv_vendor_specific_length_size, tvb, (offset + 1), 1, FALSE);
3445                                 if(get_tlv_size_of_length(&tlv_info))
3446                                 {       /* display the multiple byte TLV length */
3447                                         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));
3448                                 }
3449                                 else
3450                                 {       /* length = 0 */
3451                                         continue;
3452                                 }
3453                         }
3454                         proto_tree_add_item(tree, hf_common_tlv_vendor_specific_value, tvb, (offset + tlv_value_offset), tlv_len, FALSE);
3455                 }
3456                 /* update the offset */
3457                 offset += tlv_value_offset + tlv_len;
3458         }
3459 }
3460
3461 /******************************************************************/
3462 /* wimax_common_tlv_encoding_decoder()                            */
3463 /* decode and display the WiMax Common TLV Encoding (Table 346)   */
3464 /* parameter:                                                     */
3465 /*   tvb - pointer of the tvb of service flow encodings           */
3466 /*   tree - pointer of Wireshark display tree                     */
3467 /*   pinfo - pointer of Wireshark packet information structure    */
3468 /******************************************************************/
3469 guint wimax_common_tlv_encoding_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3470 {
3471         guint offset, value;
3472         guint tvb_len, tlv_len, tlv_value_offset;
3473         gint  tlv_type;
3474         proto_tree *tlv_tree = NULL;
3475         tlv_info_t tlv_info;
3476         gfloat current_power;
3477
3478         /* get the tvb reported length */
3479         tvb_len = tvb_reported_length(tvb);
3480         /* do nothing if the TLV fields is not exist */
3481         if(!tvb_len)
3482                 return 0;
3483         /* report error if the packet size is less than 2 bytes (type+length) */
3484         if(tvb_len < 2)
3485         {       /* invalid tlv info */
3486                 if(pinfo->cinfo)
3487                 {
3488                         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Common TLV encoding");
3489                 }
3490                 proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, 0, tvb_len, FALSE);
3491                 return 0;
3492         }
3493         /* process Common TLV Encoding (11.1) */
3494         for(offset = 0; offset < tvb_len; )
3495         {
3496                 /* get the TLV information */
3497                 init_tlv_info(&tlv_info, tvb, offset);
3498                 /* get the TLV type */
3499                 tlv_type = get_tlv_type(&tlv_info);
3500                 /* get the TLV length */
3501                 tlv_len = get_tlv_length(&tlv_info);
3502                 if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1)
3503                 {       /* invalid tlv info */
3504                         if(pinfo->cinfo)
3505                         {
3506                                 col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Common TLV encoding TLV error");
3507                         }
3508                         proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE);
3509                         break;
3510                 }
3511                 /* get the TLV value offset */
3512                 tlv_value_offset = get_tlv_value_offset(&tlv_info);
3513 #ifdef DEBUG /* for debug only */
3514                 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);
3515 #endif
3516                 /* update the offset for the TLV value */
3517                 offset += tlv_value_offset;
3518                 /* parse Common TLV Encoding (table 346) */
3519                 switch (tlv_type)
3520                 {
3521                         case VENDOR_SPECIFIC_INFO:
3522                                 /* display Vendor-Specific Information */
3523                                 /* add subtree */
3524                                 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);
3525                                 /* decode and display the Vendor-Specific Information */
3526                                 wimax_vendor_specific_information_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
3527                         break;
3528                         case VENDOR_ID_ENCODING:
3529                                 /* display Vendor ID Encoding */
3530                                 /* add subtree */
3531                                 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);
3532                                 /* decode and display the Vendor ID Encoding */
3533                                 proto_tree_add_item(tlv_tree, hf_common_tlv_vendor_id, tvb, offset, tlv_len, FALSE);
3534                         break;
3535                         case DSx_UPLINK_FLOW:
3536                                 /* display Uplink Service Flow Encodings info */
3537                                 /* add subtree */
3538                                 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);
3539                                 /* decode and display the UL Service Flow Encodings */
3540                                 wimax_service_flow_encodings_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree);
3541                         break;
3542                         case DSx_DOWNLINK_FLOW:
3543                                 /* display Downlink Service Flow Encodings info */
3544                                 /* add subtree */
3545                                 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);
3546                                 /* decode and display the DL Service Flow Encodings */
3547                                 wimax_service_flow_encodings_decoder(tvb_new_subset(tvb,offset, tlv_len, tlv_len), pinfo, tlv_tree);
3548                         break;
3549                         case CURRENT_TX_POWER:
3550                                 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);
3551                                 value = tvb_get_guint8(tvb, offset);
3552                                 current_power = (gfloat)(value - 128) / 2;
3553                                 proto_tree_add_text(tlv_tree, tvb, offset, 1, "Current Transmitted Power: %.2f dBm (Value: 0x%x)", (gdouble)current_power, value);
3554                         break;
3555                         case MAC_VERSION_ENCODING:
3556                                 /* display MAC Version Encoding */
3557                                 /* add subtree */
3558                                 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);
3559                                 /* decode and display the MAC Version Encoding */
3560                                 proto_tree_add_item(tlv_tree, hf_common_tlv_mac_version, tvb, offset, tlv_len, FALSE);
3561                         break;
3562                         case HMAC_TUPLE:        /* Table 348d */
3563                                 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);
3564                                 /* decode and display the HMAC Tuple */
3565                                 wimax_hmac_tuple_decoder(tlv_tree, tvb, offset, tlv_len);
3566                         break;
3567                         case CMAC_TUPLE:        /* Table 348b */
3568                                 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);
3569                                 /* decode and display the CMAC Tuple */
3570                                 wimax_cmac_tuple_decoder(tlv_tree, tvb, offset, tlv_len);
3571                         break;
3572                         default:
3573                                 /* Back to calling routine to finish decoding. */
3574                                 return offset - tlv_value_offset;  /* Ret amount decoded. */
3575                         break;
3576                 }
3577                 offset += tlv_len;
3578         }       /* end of while loop */
3579         return offset;
3580 }