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