Use ENC_NA as encoding for proto_tree_add_item() calls which directly reference an...
[obnox/wireshark/wip.git] / epan / dissectors / packet-capwap.c
1 /* packet-capwap.c
2  * Routines for CAPWAP dissection (RFC 5415 / RFC5416)
3  * Copyright 2009,  Alexis La Goutte <alexis.lagoutte at gmail dot com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <stdlib.h>
31
32 #include <epan/packet.h>
33 #include <epan/prefs.h>
34 #include <epan/reassemble.h>
35
36 #include <epan/sminmpec.h>
37
38 #define UDP_PORT_CAPWAP_CONTROL 5246
39 #define UDP_PORT_CAPWAP_DATA 5247
40
41 static guint global_capwap_control_udp_port = UDP_PORT_CAPWAP_CONTROL;
42 static guint global_capwap_data_udp_port = UDP_PORT_CAPWAP_DATA;
43 static gboolean global_capwap_draft_8_cisco = FALSE;
44 static gboolean global_capwap_reassemble = TRUE;
45 static gboolean global_capwap_swap_frame_control = TRUE;
46
47 static GHashTable *capwap_fragment_table = NULL;
48 static GHashTable *capwap_reassembled_table = NULL;
49
50 /* TODO LIST !
51 * add decryption of DLTS Message
52 * add support of all Messages Element Type
53 */
54
55 /* Forward declaration we need below */
56 void proto_reg_handoff_capwap(void);
57
58 /* Initialize the protocol and registered fields */
59 static int proto_capwap = -1;
60
61 static int hf_capwap_preamble = -1;
62 static int hf_capwap_preamble_version = -1;
63 static int hf_capwap_preamble_type = -1;
64 static int hf_capwap_preamble_reserved = -1;
65
66 static int hf_capwap_header = -1;
67 static int hf_capwap_header_hlen = -1;
68 static int hf_capwap_header_rid = -1;
69 static int hf_capwap_header_wbid = -1;
70
71 static int hf_capwap_header_flags = -1;
72 static int hf_capwap_header_flags_t = -1;
73 static int hf_capwap_header_flags_f = -1;
74 static int hf_capwap_header_flags_l = -1;
75 static int hf_capwap_header_flags_w = -1;
76 static int hf_capwap_header_flags_m = -1;
77 static int hf_capwap_header_flags_k = -1;
78 static int hf_capwap_header_flags_r = -1;
79
80 static int hf_capwap_header_fragment_id = -1;
81 static int hf_capwap_header_fragment_offset = -1;
82 static int hf_capwap_header_reserved = -1;
83
84 static int hf_capwap_header_mac_length = -1;
85 static int hf_capwap_header_mac_eui48 = -1;
86 static int hf_capwap_header_mac_eui64 = -1;
87 static int hf_capwap_header_mac_data = -1;
88
89 static int hf_capwap_header_wireless_length = -1;
90 static int hf_capwap_header_wireless_data = -1;
91
92 static int hf_capwap_header_wireless_data_ieee80211_fi = -1;
93 static int hf_capwap_header_wireless_data_ieee80211_fi_rssi = -1;
94 static int hf_capwap_header_wireless_data_ieee80211_fi_snr = -1;
95 static int hf_capwap_header_wireless_data_ieee80211_fi_data_rate = -1;
96 static int hf_capwap_header_wireless_data_ieee80211_dest_wlan = -1;
97 static int hf_capwap_header_wireless_data_ieee80211_dw_wlan_id_bitmap = -1;
98 static int hf_capwap_header_wireless_data_ieee80211_dw_reserved = -1;
99 static int hf_capwap_header_padding = -1;
100
101 static int hf_capwap_control_header = -1;
102 static int hf_capwap_control_header_msg_type = -1;
103 static int hf_capwap_control_header_msg_type_enterprise_nbr = -1;
104 static int hf_capwap_control_header_msg_type_enterprise_specific = -1;
105 static int hf_capwap_control_header_seq_number = -1;
106 static int hf_capwap_control_header_flags = -1;
107 static int hf_capwap_control_header_msg_element_length = -1;
108
109 static int hf_capwap_message_element = -1;
110 static int hf_capwap_msg_element_type = -1;
111 static int hf_capwap_msg_element_length = -1;
112 static int hf_capwap_msg_element_value = -1;
113
114 static int hf_capwap_msg_element_type_ac_descriptor_stations = -1;
115 static int hf_capwap_msg_element_type_ac_descriptor_limit = -1;
116 static int hf_capwap_msg_element_type_ac_descriptor_active_wtp = -1;
117 static int hf_capwap_msg_element_type_ac_descriptor_max_wtp = -1;
118 /* AC Descriptor Security Flags... */
119 static int hf_capwap_msg_element_type_ac_descriptor_security = -1;
120 static int hf_capwap_msg_element_type_ac_descriptor_security_s = -1;
121 static int hf_capwap_msg_element_type_ac_descriptor_security_x = -1;
122 static int hf_capwap_msg_element_type_ac_descriptor_security_r = -1;
123 static int hf_capwap_msg_element_type_ac_descriptor_rmac_field = -1;
124 static int hf_capwap_msg_element_type_ac_descriptor_reserved = -1;
125 /* AC Descriptor DTLS Policy Flags... */
126 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy = -1;
127 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy_d = -1;
128 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy_c = -1;
129 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy_r = -1;
130
131 static int hf_capwap_msg_element_type_ac_information_vendor = -1;
132 static int hf_capwap_msg_element_type_ac_information_type = -1;
133 static int hf_capwap_msg_element_type_ac_information_length = -1;
134 static int hf_capwap_msg_element_type_ac_information_value = -1;
135 static int hf_capwap_msg_element_type_ac_information_hardware_version = -1;
136 static int hf_capwap_msg_element_type_ac_information_software_version = -1;
137
138 static int hf_capwap_msg_element_type_ac_name = -1;
139 static int hf_capwap_msg_element_type_ac_name_with_priority = -1;
140
141 static int hf_capwap_msg_element_type_ac_ipv4_list = -1;
142 static int hf_capwap_msg_element_type_ac_ipv6_list = -1;
143
144 static int hf_capwap_msg_element_type_capwap_control_ipv4 = -1;
145 static int hf_capwap_msg_element_type_capwap_control_ipv6 = -1;
146 static int hf_capwap_msg_element_type_capwap_control_wtp_count = -1;
147
148 static int hf_capwap_msg_element_type_capwap_timers_discovery = -1;
149 static int hf_capwap_msg_element_type_capwap_timers_echo_request = -1;
150
151 static int hf_capwap_msg_element_type_decryption_error_report_period_radio_id = -1;
152 static int hf_capwap_msg_element_type_decryption_error_report_period_interval = -1;
153
154 static int hf_capwap_msg_element_type_discovery_type = -1;
155
156 static int hf_capwap_msg_element_type_location_data = -1;
157
158 static int hf_capwap_msg_element_type_maximum_message_length = -1;
159
160 static int hf_capwap_msg_element_type_idle_timeout = -1;
161 static int hf_capwap_msg_element_type_radio_admin_id = -1;
162 static int hf_capwap_msg_element_type_radio_admin_state = -1;
163
164 static int hf_capwap_msg_element_type_radio_op_state_radio_id = -1;
165 static int hf_capwap_msg_element_type_radio_op_state_radio_state = -1;
166 static int hf_capwap_msg_element_type_radio_op_state_radio_cause = -1;
167 static int hf_capwap_msg_element_type_result_code = -1;
168
169 static int hf_capwap_msg_element_type_session_id = -1;
170
171 static int hf_capwap_msg_element_type_statistics_timer = -1;
172
173 static int hf_capwap_msg_element_type_vsp_vendor_identifier = -1;
174 static int hf_capwap_msg_element_type_vsp_vendor_element_id = -1;
175 static int hf_capwap_msg_element_type_vsp_vendor_data = -1;
176
177 static int hf_capwap_msg_element_type_wtp_board_data_vendor = -1;
178 static int hf_capwap_msg_element_type_wtp_board_data_type = -1;
179 static int hf_capwap_msg_element_type_wtp_board_data_length = -1;
180 static int hf_capwap_msg_element_type_wtp_board_data_value = -1;
181 static int hf_capwap_msg_element_type_wtp_board_data_wtp_model_number  = -1;
182 static int hf_capwap_msg_element_type_wtp_board_data_wtp_serial_number  = -1;
183 static int hf_capwap_msg_element_type_wtp_board_data_wtp_board_id  = -1;
184 static int hf_capwap_msg_element_type_wtp_board_data_wtp_board_revision  = -1;
185 static int hf_capwap_msg_element_type_wtp_board_data_base_mac_address  = -1;
186
187 static int hf_capwap_msg_element_type_wtp_descriptor_max_radios = -1;
188 static int hf_capwap_msg_element_type_wtp_descriptor_radio_in_use = -1;
189 static int hf_capwap_msg_element_type_wtp_descriptor_number_encrypt = -1;
190 static int hf_capwap_msg_element_type_wtp_descriptor_encrypt_reserved = -1;
191 static int hf_capwap_msg_element_type_wtp_descriptor_encrypt_wbid = -1;
192 static int hf_capwap_msg_element_type_wtp_descriptor_encrypt_capabilities = -1;
193 static int hf_capwap_msg_element_type_wtp_descriptor_vendor = -1;
194 static int hf_capwap_msg_element_type_wtp_descriptor_type = -1;
195 static int hf_capwap_msg_element_type_wtp_descriptor_length = -1;
196 static int hf_capwap_msg_element_type_wtp_descriptor_value = -1;
197 static int hf_capwap_msg_element_type_wtp_descriptor_hardware_version = -1;
198 static int hf_capwap_msg_element_type_wtp_descriptor_active_software_version = -1;
199 static int hf_capwap_msg_element_type_wtp_descriptor_boot_version = -1;
200 static int hf_capwap_msg_element_type_wtp_descriptor_other_software_version = -1;
201
202 static int hf_capwap_msg_element_type_wtp_fallback = -1;
203 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode = -1;
204 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_n = -1;
205 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_e = -1;
206 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_l = -1;
207 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_r = -1;
208
209 static int hf_capwap_msg_element_type_wtp_mac_type = -1;
210
211 static int hf_capwap_msg_element_type_wtp_name = -1;
212
213 static int hf_capwap_msg_element_type_wtp_reboot_statistics_reboot_count = -1;
214 static int hf_capwap_msg_element_type_wtp_reboot_statistics_ac_initiated_count = -1;
215 static int hf_capwap_msg_element_type_wtp_reboot_statistics_link_failure_count = -1;
216 static int hf_capwap_msg_element_type_wtp_reboot_statistics_sw_failure_count = -1;
217 static int hf_capwap_msg_element_type_wtp_reboot_statistics_hw_failure_count = -1;
218 static int hf_capwap_msg_element_type_wtp_reboot_statistics_other_failure_count = -1;
219 static int hf_capwap_msg_element_type_wtp_reboot_statistics_unknown_failure_count = -1;
220 static int hf_capwap_msg_element_type_wtp_reboot_statistics_last_failure_type = -1;
221
222 static int hf_capwap_msg_element_type_ieee80211_rate_set_radio_id = -1;
223 static int hf_capwap_msg_element_type_ieee80211_rate_set_rate_set = -1;
224
225 static int hf_capwap_msg_element_type_ieee80211_station_session_key_mac = -1;
226 static int hf_capwap_msg_element_type_ieee80211_station_session_key_flags = -1;
227 static int hf_capwap_msg_element_type_ieee80211_station_session_key_flags_a = -1;
228 static int hf_capwap_msg_element_type_ieee80211_station_session_key_flags_c = -1;
229 static int hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_tsc = -1;
230 static int hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_rsc = -1;
231 static int hf_capwap_msg_element_type_ieee80211_station_session_key_key = -1;
232
233 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_id = -1;
234 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_reserved = -1;
235 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_n = -1;
236 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_g = -1;
237 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_a = -1;
238 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_b = -1;
239
240 static int hf_msg_fragments = -1;
241 static int hf_msg_fragment = -1;
242 static int hf_msg_fragment_overlap = -1;
243 static int hf_msg_fragment_overlap_conflicts = -1;
244 static int hf_msg_fragment_multiple_tails = -1;
245 static int hf_msg_fragment_too_long_fragment = -1;
246 static int hf_msg_fragment_error = -1;
247 static int hf_msg_fragment_count = -1;
248 static int hf_msg_reassembled_in = -1;
249 static int hf_msg_reassembled_length = -1;
250
251 static dissector_handle_t dtls_handle;
252 static dissector_handle_t ieee8023_handle;
253 static dissector_handle_t ieee80211_handle;
254 static dissector_handle_t ieee80211_bsfc_handle;
255 static dissector_handle_t data_handle;
256
257 /* Initialize the subtree pointers */
258 static gint ett_capwap = -1;
259
260 static gint ett_msg_fragment = -1;
261 static gint ett_msg_fragments = -1;
262
263 /* ************************************************************************* */
264 /*                  Fragment items                                           */
265 /* ************************************************************************* */
266
267 static const fragment_items capwap_frag_items = {
268   /* Fragment subtrees */
269   &ett_msg_fragment,
270   &ett_msg_fragments,
271   /* Fragment fields */
272   &hf_msg_fragments,
273   &hf_msg_fragment,
274   &hf_msg_fragment_overlap,
275   &hf_msg_fragment_overlap_conflicts,
276   &hf_msg_fragment_multiple_tails,
277   &hf_msg_fragment_too_long_fragment,
278   &hf_msg_fragment_error,
279   &hf_msg_fragment_count,
280   /* Reassembled in field */
281   &hf_msg_reassembled_in,
282   /* Reassembled length field */
283   &hf_msg_reassembled_length,
284   /* Tag */
285   "Message fragments"
286 };
287
288 /* ************************************************************************* */
289 /*                  Header Type                                              */
290 /* ************************************************************************* */
291 static const value_string type_header_vals[] = {
292   { 0, "CAPWAP Header" },
293   { 1, "CAPWAP DTLS Header" },
294   { 0,     NULL     }
295 };
296 /* ************************************************************************* */
297 /*                   Wireless Binding IDentifier (WBID)                      */
298 /* ************************************************************************* */
299 static const value_string type_wbid[] = {
300   { 0, "Reserved" },
301   { 1, "IEEE 802.11" },
302   { 2, "IEEE 802.16" }, /* From old RFC Draft... */
303   { 3, "EPCGlobal" },
304   { 0,     NULL     }
305 };
306 /* ************************************************************************* */
307 /*                 flag Type Transported (payload)                           */
308 /* ************************************************************************* */
309 static const true_false_string flag_type_t = {
310   "Native frame format (see Wireless Binding ID field)",
311   "IEEE 802.3 frame"
312 };
313 /* ************************************************************************* */
314 /*                 flag Type Fragment                                        */
315 /* ************************************************************************* */
316 static const true_false_string flag_type_f = {
317   "Fragmented",
318   "Don't Fragment"
319 };
320 /* ************************************************************************* */
321 /*                 flag Type Last Fragment                                   */
322 /* ************************************************************************* */
323 static const true_false_string flag_type_l = {
324   "This is the last fragment",
325   "More fragments follow"
326  };
327 /* ************************************************************************* */
328 /*                 flag Type Wireless                                        */
329 /* ************************************************************************* */
330 static const true_false_string flag_type_w = {
331   "Wireless Specific Information is present",
332   "No Wireless Specific Information"
333  };
334 /* ************************************************************************* */
335 /*                 flag Type Radio Mac                                       */
336 /* ************************************************************************* */
337 static const true_false_string flag_type_m = {
338   "Radio MAC Address is present",
339   "No Radio MAC Address"
340  };
341 /* ************************************************************************* */
342 /*                 flag Type Keep Alive                                      */
343 /* ************************************************************************* */
344 static const true_false_string flag_type_k = {
345   "Keep-Alive Packet",
346   "No Keep-Alive"
347  };
348 /* ************************************************************************* */
349 /*                  Message Type Value                                       */
350 /* ************************************************************************* */
351 static const value_string message_type[] = {
352   { 1, "Discovery Request" },
353   { 2, "Discovery Response" },
354   { 3, "Join Request" },
355   { 4, "Join Response" },
356   { 5, "Configuration Status Request" },
357   { 6, "Configuration Status Response" },
358   { 7, "Configuration Update Request" },
359   { 8, "Configuration Update Response" },
360   { 9, "WTP Event Request" },
361   { 10, "WTP Event Response" },
362   { 11, "Change State Request" },
363   { 12, "Change State Response" },
364   { 13, "Echo Request" },
365   { 14, "Echo Response" },
366   { 15, "Image Data Request" },
367   { 16, "Image Data Response" },
368   { 17, "Reset Request" },
369   { 18, "Reset Response" },
370   { 19, "Primary Discovery Request" },
371   { 20, "Primary Discovery Response" },
372   { 21, "Data Transfer Request" },
373   { 22, "Data Transfer Response" },
374   { 23, "Clear Configuration Request" },
375   { 24, "Clear Configuration Response" },
376   { 25, "Station Configuration Request" },
377   { 26, "Station Configuration Response" },
378   { 0,     NULL     }
379 };
380 /* ************************************************************************* */
381 /*                      Message Element Type                                 */
382 /* ************************************************************************* */
383 #define TYPE_AC_DESCRIPTOR                        1
384 #define TYPE_AC_IPV4_LIST                         2
385 #define TYPE_AC_IPV6_LIST                         3
386 #define TYPE_AC_NAME                              4
387 #define TYPE_AC_NAME_W_PRIORITY                   5
388 #define TYPE_AC_TIMESTAMP                         6
389 #define TYPE_ADD_MAC_ACL_ENTRY                    7
390 #define TYPE_ADD_STATION                          8
391 #define TYPE_RESERVED_9                           9
392 #define TYPE_CAPWAP_CONTROL_IPV4_ADDRESS          10
393 #define TYPE_CAPWAP_CONTROL_IPV6_ADDRESS          11
394 #define TYPE_CAPWAP_TIMERS                        12
395 #define TYPE_DATA_TRANSFER_DATA                   13
396 #define TYPE_DATA_TRANSFER_MODE                   14
397 #define TYPE_DESCRYPTION_ERROR_REPORT             15
398 #define TYPE_DECRYPTION_ERROR_REPORT_PERIOD       16
399 #define TYPE_DELETE_MAC_ENTRY                     17
400 #define TYPE_DELETE_STATION                       18
401 #define TYPE_RESERVED_19                          19
402 #define TYPE_DISCOVERY_TYPE                       20
403 #define TYPE_DUPLICATE_IPV4_ADDRESS               21
404 #define TYPE_DUPLICATE_IPV6_ADDRESS               22
405 #define TYPE_IDLE_TIMEOUT                         23
406 #define TYPE_IMAGE_DATA                           24
407 #define TYPE_IMAGE_IDENTIFIER                     25
408 #define TYPE_IMAGE_INFORMATION                    26
409 #define TYPE_INITIATE_DOWNLOAD                    27
410 #define TYPE_LOCATION_DATA                        28
411 #define TYPE_MAXIMUM_MESSAGE_LENGTH               29
412 #define TYPE_CAPWAP_LOCAL_IPV4_ADDRESS            30
413 #define TYPE_RADIO_ADMINISTRATIVE_STATE           31
414 #define TYPE_RADIO_OPERATIONAL_STATE              32
415 #define TYPE_RESULT_CODE                          33
416 #define TYPE_RETURNED_MESSAGE_ELEMENT             34
417 #define TYPE_SESSION_ID                           35
418 #define TYPE_STATISTICS_TIMER                     36
419 #define TYPE_VENDOR_SPECIFIC_PAYLOAD              37
420 #define TYPE_WTP_BOARD_DATA                       38
421 #define TYPE_WTP_DESCRIPTOR                       39
422 #define TYPE_WTP_FALLBACK                         40
423 #define TYPE_WTP_FRAME_TUNNEL_MODE                41
424 #define TYPE_RESERVED_42                          42
425 #define TYPE_RESERVED_43                          43
426 #define TYPE_WTP_MAC_TYPE                         44
427 #define TYPE_WTP_NAME                             45
428 #define TYPE_RESERVED_46                          46
429 #define TYPE_WTP_RADIO_STATISTICS                 47
430 #define TYPE_WTP_REBOOT_STATISTICS                48
431 #define TYPE_WTP_STATIC_IP_ADDRESS_INFORMATION    49
432 #define TYPE_CAPWAP_LOCAL_IPV6_ADDRESS            50
433 #define TYPE_CAPWAP_TRANSPORT_PROTOCOL            51
434 #define TYPE_MTU_DISCOVERY_PADDING                52
435 #define TYPE_ECN_SUPPORT                          53
436
437 #define IEEE80211_ADD_WLAN                        1024
438 #define IEEE80211_ANTENNA                         1025
439 #define IEEE80211_ASSIGNED_WTP_BSSID              1026
440 #define IEEE80211_DELETE_WLAN                     1027
441 #define IEEE80211_DIRECT_SEQUENCE_CONTROL         1028
442 #define IEEE80211_INFORMATION_ELEMENT             1029
443 #define IEEE80211_MAC_OPERATION                   1030
444 #define IEEE80211_MIC_COUNTERMEASURES             1031
445 #define IEEE80211_MULTI_DOMAIN_CAPABILITY         1032
446 #define IEEE80211_OFDM_CONTROL                    1033
447 #define IEEE80211_RATE_SET                        1034
448 #define IEEE80211_RSNA_ERROR_REPORT_FROM_STATION  1035
449 #define IEEE80211_STATION                         1036
450 #define IEEE80211_STATION_QOS_PROFILE             1037
451 #define IEEE80211_STATION_SESSION_KEY             1038
452 #define IEEE80211_STATISTICS                      1039
453 #define IEEE80211_SUPPORTED_RATES                 1040
454 #define IEEE80211_TX_POWER                        1041
455 #define IEEE80211_TX_POWER_LEVEl                  1042
456 #define IEEE80211_UPDATE_STATION_QOS              1043
457 #define IEEE80211_UPDATE_WLAN                     1044
458 #define IEEE80211_WTP_QUALITY_OF_SERVICE          1045
459 #define IEEE80211_WTP_RADIO_CONFIGURATION         1046
460 #define IEEE80211_WTP_RADIO_FAIL_ALARM_INDICATION 1047
461 #define IEEE80211_WTP_RADIO_INFORMATION           1048
462
463 /* ************************************************************************* */
464 /*                      Message Element Type Value                           */
465 /* ************************************************************************* */
466 static const value_string message_element_type_vals[] = {
467   { TYPE_AC_DESCRIPTOR, "AC Descriptor" },
468   { TYPE_AC_IPV4_LIST, "AC IPv4 List" },
469   { TYPE_AC_IPV6_LIST, "AC IPv6 List" },
470   { TYPE_AC_NAME, "AC Name" },
471   { TYPE_AC_NAME_W_PRIORITY, "AC Name With Priority" },
472   { TYPE_AC_TIMESTAMP, "AC Timestamp" },
473   { TYPE_ADD_MAC_ACL_ENTRY, "Add MAC ACL Entry" },
474   { TYPE_ADD_STATION, "Add Station" },
475   { TYPE_RESERVED_9, "Reserved" },
476   { TYPE_CAPWAP_CONTROL_IPV4_ADDRESS, "CAPWAP Control IPv4 Address" },
477   { TYPE_CAPWAP_CONTROL_IPV6_ADDRESS, "CAPWAP Control IPv6 Address" },
478   { TYPE_CAPWAP_TIMERS, "CAPWAP Timers" },
479   { TYPE_DATA_TRANSFER_DATA, "Data Transfer Data" },
480   { TYPE_DATA_TRANSFER_MODE, "Data Transfer Mode" },
481   { TYPE_DESCRYPTION_ERROR_REPORT, "Decryption Error Report" },
482   { TYPE_DECRYPTION_ERROR_REPORT_PERIOD, "Decryption Error Report Period" },
483   { TYPE_DELETE_MAC_ENTRY, "Delete MAC ACL Entry" },
484   { TYPE_DELETE_STATION, "Delete Station" },
485   { TYPE_RESERVED_19, "Reserved" },
486   { TYPE_DISCOVERY_TYPE, "Discovery Type" },
487   { TYPE_DUPLICATE_IPV4_ADDRESS, "Duplicate IPv4 Address" },
488   { TYPE_DUPLICATE_IPV6_ADDRESS, "Duplicate IPv6 Address" },
489   { TYPE_IDLE_TIMEOUT, "Idle Timeout" },
490   { TYPE_IMAGE_DATA, "Image Data" },
491   { TYPE_IMAGE_IDENTIFIER, "Image Identifier" },
492   { TYPE_IMAGE_INFORMATION, "Image Information" },
493   { TYPE_INITIATE_DOWNLOAD, "Initiate Download" },
494   { TYPE_LOCATION_DATA, "Location Data" },
495   { TYPE_MAXIMUM_MESSAGE_LENGTH, "Maximum Message Length" },
496   { TYPE_CAPWAP_LOCAL_IPV4_ADDRESS, "CAPWAP Local IPv4 Address" },
497   { TYPE_RADIO_ADMINISTRATIVE_STATE, "Radio Administrative State " },
498   { TYPE_RADIO_OPERATIONAL_STATE, "Radio Operational State" },
499   { TYPE_RESULT_CODE, "Result Code" },
500   { TYPE_RETURNED_MESSAGE_ELEMENT, "Returned Message Element" },
501   { TYPE_SESSION_ID, "Session ID" },
502   { TYPE_STATISTICS_TIMER, "Statistics Timer" },
503   { TYPE_VENDOR_SPECIFIC_PAYLOAD, "Vendor Specific Payload" },
504   { TYPE_WTP_BOARD_DATA, "WTP Board Data" },
505   { TYPE_WTP_DESCRIPTOR, "WTP Descriptor" },
506   { TYPE_WTP_FALLBACK, "WTP Fallback " },
507   { TYPE_WTP_FRAME_TUNNEL_MODE, "WTP Frame Tunnel Mode " },
508   { TYPE_RESERVED_42, "Reserved" },
509   { TYPE_RESERVED_43, "Reserved" },
510   { TYPE_WTP_MAC_TYPE, "WTP MAC Type" },
511   { TYPE_WTP_NAME, "WTP Name" },
512   { TYPE_RESERVED_46, "Unused/Reserved" },
513   { TYPE_WTP_RADIO_STATISTICS, "WTP Radio Statistics" },
514   { TYPE_WTP_REBOOT_STATISTICS, "WTP Reboot Statistics" },
515   { TYPE_WTP_STATIC_IP_ADDRESS_INFORMATION, "WTP Static IP Address Information" },
516   { TYPE_CAPWAP_LOCAL_IPV6_ADDRESS, "CAPWAP Local IPv6 Address" },
517   { TYPE_CAPWAP_TRANSPORT_PROTOCOL, "CAPWAP Transport Protocol" },
518   { TYPE_MTU_DISCOVERY_PADDING, "MTU Discovery Padding" },
519   { TYPE_ECN_SUPPORT, "ECN Support" },
520
521   { IEEE80211_ADD_WLAN, "IEEE 802.11 Add WLAN" },
522   { IEEE80211_ANTENNA, "IEEE 802.11 Antenna" },
523   { IEEE80211_ASSIGNED_WTP_BSSID, "IEEE 802.11 Assigned WTP BSSID" },
524   { IEEE80211_DELETE_WLAN, "IEEE 802.11 Delete WLAN" },
525   { IEEE80211_DIRECT_SEQUENCE_CONTROL, "IEEE 802.11 Direct Sequence Control" },
526   { IEEE80211_INFORMATION_ELEMENT, "IEEE 802.11 Information Element" },
527   { IEEE80211_MAC_OPERATION, "IEEE 802.11 MAC Operation" },
528   { IEEE80211_MIC_COUNTERMEASURES, "IEEE 802.11 MIC Countermeasures" },
529   { IEEE80211_MULTI_DOMAIN_CAPABILITY, "IEEE 802.11 Multi-Domain Capability" },
530   { IEEE80211_OFDM_CONTROL, "IEEE 802.11 OFDM Control" },
531   { IEEE80211_RATE_SET, "IEEE 802.11 Rate Set" },
532   { IEEE80211_RSNA_ERROR_REPORT_FROM_STATION, "IEEE 802.11 RSNA Error Report From Station" },
533   { IEEE80211_STATION, "IEEE 802.11 Station" },
534   { IEEE80211_STATION_QOS_PROFILE, "IEEE 802.11 Station QoS Profile" },
535   { IEEE80211_STATION_SESSION_KEY, "IEEE 802.11 Station Session Key" },
536   { IEEE80211_STATISTICS, "IEEE 802.11 Statistics" },
537   { IEEE80211_SUPPORTED_RATES, "IEEE 802.11 Supported Rates" },
538   { IEEE80211_TX_POWER, "IEEE 802.11 Tx Power" },
539   { IEEE80211_TX_POWER_LEVEl, "IEEE 802.11 Tx Power Level" },
540   { IEEE80211_UPDATE_STATION_QOS, "IEEE 802.11 Update Station QoS" },
541   { IEEE80211_UPDATE_WLAN, "IEEE 802.11 Update WLAN" },
542   { IEEE80211_WTP_QUALITY_OF_SERVICE, "IEEE 802.11 WTP Quality of Service" },
543   { IEEE80211_WTP_RADIO_CONFIGURATION, "IEEE 802.11 WTP Radio Configuration" },
544   { IEEE80211_WTP_RADIO_FAIL_ALARM_INDICATION, "IEEE 802.11 WTP Radio Fail Alarm Indication" },
545   { IEEE80211_WTP_RADIO_INFORMATION, "IEEE 802.11 WTP Radio Information" },
546   { 0,     NULL     }
547 };
548 /* ************************************************************************* */
549 /*                      Discovery Type                                       */
550 /* ************************************************************************* */
551 static const value_string discovery_type_vals[] = {
552   { 0, "Unknown" },
553   { 1, "Static Configuration" },
554   { 2, "DHCP" },
555   { 3, "DNS" },
556   { 4, "AC Referral" },
557   { 0,     NULL     }
558 };
559 /* ************************************************************************* */
560 /*                      Radio Administrative State                           */
561 /* ************************************************************************* */
562 static const value_string radio_admin_state_vals[] = {
563   { 1, "Enabled" },
564   { 2, "Disabled" },
565   { 0,     NULL     }
566 };
567 /* ************************************************************************* */
568 /*                      Radio Operational State                              */
569 /* ************************************************************************* */
570 static const value_string radio_op_state_vals[] = {
571   { 0, "Reserved" },
572   { 1, "Enabled" },
573   { 2, "Disabled" },
574   { 0,     NULL     }
575 };
576 /* ************************************************************************* */
577 /*                      Radio Operational Cause                              */
578 /* ************************************************************************* */
579 static const value_string radio_op_cause_vals[] = {
580   { 0, "Normal" },
581   { 1, "Radio Failure" },
582   { 2, "Software Failure" },
583   { 3, "Administratively Set" },
584   { 0,     NULL     }
585 };
586 /* ************************************************************************* */
587 /*                      Result Code                                          */
588 /* ************************************************************************* */
589 static const value_string result_code_vals[] = {
590   { 0 , "Success" },
591   { 1 , "Failure (AC List Message Element MUST Be Present)" },
592   { 2 , "Success (NAT Detected)" },
593   { 3 , "Join Failure (Unspecified)" },
594   { 4 , "Join Failure (Resource Depletion)" },
595   { 5 , "Join Failure (Unknown Source)" },
596   { 6 , "Join Failure (Incorrect Data)" },
597   { 7 , "Join Failure (Session ID Already in Use)" },
598   { 8 , "Join Failure (WTP Hardware Not Supported)" },
599   { 9 , "Join Failure (Binding Not Supported)" },
600   { 10, "Reset Failure (Unable to Reset)" },
601   { 11, "Reset Failure (Firmware Write Error)" },
602   { 12, "Configuration Failure (Unable to Apply Requested Configuration - Service Provided Anyhow)" },
603   { 13, "Configuration Failure (Unable to Apply Requested Configuration - Service Not Provided)" },
604   { 14, "Image Data Error (Invalid Checksum)" },
605   { 15, "Image Data Error (Invalid Data Length)" },
606   { 16, "Image Data Error (Other Error)" },
607   { 17, "Image Data Error (Image Already Present)" },
608   { 18, "Message Unexpected (Invalid in Current State)" },
609   { 19, "Message Unexpected (Unrecognized Request)" },
610   { 20, "Failure - Missing Mandatory Message Element" },
611   { 21, "Failure - Unrecognized Message Element" },
612   { 22, "Data Transfer Error (No Information to Transfer)" },
613   { 0 ,     NULL     }
614 };
615 /* ************************************************************************* */
616 /*                      Radio MAC Address Field                              */
617 /* ************************************************************************* */
618 static const value_string rmac_field_vals[] = {
619   { 0, "Reserved" },
620   { 1, "Supported" },
621   { 2, "Not Supported" },
622   { 0,     NULL     }
623 };
624 /* ************************************************************************* */
625 /*                      Board Data Type Value                                */
626 /* ************************************************************************* */
627 #define BOARD_DATA_WTP_MODEL_NUMBER 0
628 #define BOARD_DATA_WTP_SERIAL_NUMBER 1
629 #define BOARD_DATA_BOARD_ID 2
630 #define BOARD_DATA_BOARD_REVISION 3
631 #define BOARD_DATA_BASE_MAC_ADDRESS 4
632
633 static const value_string board_data_type_vals[] = {
634   { BOARD_DATA_WTP_MODEL_NUMBER, "WTP Model Number" },
635   { BOARD_DATA_WTP_SERIAL_NUMBER, "WTP Serial Number" },
636   { BOARD_DATA_BOARD_ID, "Board ID" },
637   { BOARD_DATA_BOARD_REVISION, "Board Revision" },
638   { BOARD_DATA_BASE_MAC_ADDRESS, "Base MAC Address" },
639   { 0,     NULL     }
640 };
641 /* ************************************************************************* */
642 /*                      Descriptor WTP Type Value                            */
643 /* ************************************************************************* */
644 #define WTP_DESCRIPTOR_HARDWARE_VERSION 0
645 #define WTP_DESCRIPTOR_ACTIVE_SOFTWARE_VERSION 1
646 #define WTP_DESCRIPTOR_BOOT_VERSION 2
647 #define WTP_DESCRIPTOR_OTHER_SOFTWARE_VERSION 3
648
649 static const value_string wtp_descriptor_type_vals[] = {
650   { WTP_DESCRIPTOR_HARDWARE_VERSION, "WTP Hardware Version" },
651   { WTP_DESCRIPTOR_ACTIVE_SOFTWARE_VERSION, "WTP Active Software Version" },
652   { WTP_DESCRIPTOR_BOOT_VERSION, "WTP Boot Version" },
653   { WTP_DESCRIPTOR_OTHER_SOFTWARE_VERSION, "WTP Other Software Version" },
654   { 0,     NULL     }
655 };
656 /* ************************************************************************* */
657 /*                      AC Information Type Value                            */
658 /* ************************************************************************* */
659 #define AC_INFORMATION_HARDWARE_VERSION 4
660 #define AC_INFORMATION_SOFTWARE_VERSION 5
661
662 static const value_string ac_information_type_vals[] = {
663   { AC_INFORMATION_HARDWARE_VERSION, "AC Hardware Version" },
664   { AC_INFORMATION_SOFTWARE_VERSION, "AC  Software Version" },
665   { 0,     NULL     }
666 };
667 /* ************************************************************************* */
668 /*                      WTP MAC Type                                         */
669 /* ************************************************************************* */
670 static const value_string wtp_mac_vals[] = {
671   { 0, "Local MAC" },
672   { 1, "Split MAC" },
673   { 2, "Both (Local and Split MAC)" },
674   { 0,     NULL     }
675 };
676 /* ************************************************************************* */
677 /*                      WTP Fallback                                         */
678 /* ************************************************************************* */
679 static const value_string wtp_fallback_vals[] = {
680   { 0, "Reserved" },
681   { 1, "Enabled" },
682   { 2, "Disabled" },
683   { 0,     NULL     }
684 };
685 /* ************************************************************************* */
686 /*                     Last Failure Type                                     */
687 /* ************************************************************************* */
688 static const value_string last_failure_type_vals[] = {
689   { 0, "Not Supported" },
690   { 1, "AC Initiated" },
691   { 2, "Link Failure" },
692   { 3, "Software Failure" },
693   { 4, "Hardware Failure" },
694   { 5, "Other Failure" },
695   { 255, "Unknown (e.g., WTP doesn't keep track of info)" },
696   { 0,     NULL     }
697 };
698
699 static void capwap_reassemble_init(void)
700 {
701         fragment_table_init(&capwap_fragment_table);
702         reassembled_table_init(&capwap_reassembled_table);
703 }
704
705 static void
706 dissect_capwap_data_message_bindings_ieee80211(tvbuff_t *tvb, proto_tree *data_message_binding_tree, guint offset, packet_info *pinfo)
707 {
708         proto_item *data_message_binding_item;
709         proto_tree *sub_data_message_binding_tree;
710
711         if (global_capwap_data_udp_port == pinfo->destport)
712         {
713            /* (WTP -> AC) IEEE 802.11 Frame Info */
714            data_message_binding_item = proto_tree_add_item(data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_fi,tvb, offset, 4, ENC_NA);
715            sub_data_message_binding_tree = proto_item_add_subtree(data_message_binding_item, ett_capwap);
716
717            proto_tree_add_item(sub_data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_fi_rssi,tvb, offset, 1, ENC_BIG_ENDIAN);
718
719            proto_tree_add_item(sub_data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_fi_snr,tvb, offset+1, 1, ENC_BIG_ENDIAN);
720
721            proto_tree_add_item(sub_data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_fi_data_rate,tvb, offset+2, 2, ENC_BIG_ENDIAN);
722         }
723         else
724         {
725            /* (AC -> WTP) IEEE 802.11 Destination Wlans */
726            data_message_binding_item = proto_tree_add_item(data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_dest_wlan,tvb, offset, 4, ENC_NA);
727            sub_data_message_binding_tree = proto_item_add_subtree(data_message_binding_item, ett_capwap);
728
729            proto_tree_add_item(sub_data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_dw_wlan_id_bitmap,tvb, offset, 2, ENC_BIG_ENDIAN);
730
731            proto_tree_add_item(sub_data_message_binding_tree, hf_capwap_header_wireless_data_ieee80211_dw_reserved,tvb, offset+2, 2, ENC_BIG_ENDIAN);
732         }
733 }
734
735 static void
736 dissect_capwap_encryption_capabilities(tvbuff_t *tvb, proto_tree *encryption_capabilities_tree, guint offset)
737 {
738         guint wbid,encryption_capabilities = 0;
739         proto_item *encryption_capabilities_item;
740         proto_tree *sub_encryption_capabilities_tree;
741
742         encryption_capabilities = tvb_get_ntohs(tvb, offset+1);
743         wbid = tvb_get_bits8(tvb, offset*8+3,5);
744
745         encryption_capabilities_item = proto_tree_add_text(encryption_capabilities_tree, tvb, offset, 3, "Encryption Capabilities: (WBID=%d) %d", wbid, encryption_capabilities);
746         sub_encryption_capabilities_tree = proto_item_add_subtree(encryption_capabilities_item, ett_capwap);
747
748         proto_tree_add_uint(sub_encryption_capabilities_tree,hf_capwap_msg_element_type_wtp_descriptor_encrypt_reserved, tvb, offset, 1, tvb_get_bits8(tvb, offset*8,3));
749
750         proto_tree_add_uint(sub_encryption_capabilities_tree,hf_capwap_msg_element_type_wtp_descriptor_encrypt_wbid, tvb, offset, 1, wbid);
751
752         proto_tree_add_item(sub_encryption_capabilities_tree, hf_capwap_msg_element_type_wtp_descriptor_encrypt_capabilities, tvb, offset+1, 2, ENC_BIG_ENDIAN);
753 }
754
755 /* Returns the number of bytes consumed by this option. */
756 static int
757 dissect_capwap_ac_information(tvbuff_t *tvb, proto_tree *ac_information_type_tree, guint offset)
758 {
759         guint optlen,ac_information_type = 0;
760         proto_item *ac_information_type_item;
761         proto_tree *sub_ac_information_type_tree;
762
763         ac_information_type = tvb_get_ntohs(tvb, offset+4);
764         optlen = tvb_get_ntohs(tvb, offset+6);
765         ac_information_type_item = proto_tree_add_text(ac_information_type_tree, tvb, offset, 4+2+2+optlen, "AC Information Type: (t=%d,l=%d) %s", ac_information_type, optlen, val_to_str(ac_information_type,ac_information_type_vals,"Unknown AC Information Type (%02d)") );
766         sub_ac_information_type_tree = proto_item_add_subtree(ac_information_type_item, ett_capwap);
767
768         proto_tree_add_item(sub_ac_information_type_tree, hf_capwap_msg_element_type_ac_information_vendor, tvb, offset, 4, ENC_BIG_ENDIAN);
769
770         proto_tree_add_item(sub_ac_information_type_tree, hf_capwap_msg_element_type_ac_information_type, tvb, offset+4, 2, ENC_BIG_ENDIAN);
771
772         proto_tree_add_item(sub_ac_information_type_tree, hf_capwap_msg_element_type_ac_information_length, tvb, offset+6, 2, ENC_BIG_ENDIAN);
773
774         proto_tree_add_item(sub_ac_information_type_tree, hf_capwap_msg_element_type_ac_information_value, tvb, offset+8, optlen, ENC_NA);
775         switch (ac_information_type) {
776         case AC_INFORMATION_HARDWARE_VERSION:
777                 proto_tree_add_item(sub_ac_information_type_tree, hf_capwap_msg_element_type_ac_information_hardware_version, tvb, offset+8, optlen, ENC_BIG_ENDIAN);
778                 break;
779
780         case AC_INFORMATION_SOFTWARE_VERSION:
781                 proto_tree_add_item(sub_ac_information_type_tree, hf_capwap_msg_element_type_ac_information_software_version, tvb, offset+8, optlen, ENC_BIG_ENDIAN);
782                 break;
783
784         default:
785                 /* No Default Action */
786                 break;
787         }
788         return 4+2+2+optlen;
789 }
790
791 /* Returns the number of bytes consumed by this option. */
792 static int
793 dissect_capwap_wtp_descriptor(tvbuff_t *tvb, proto_tree *wtp_descriptor_type_tree, guint offset)
794 {
795         guint optlen,wtp_descriptor_type = 0;
796         proto_item *wtp_descriptor_type_item;
797         proto_tree *sub_wtp_descriptor_type_tree;
798
799         wtp_descriptor_type = tvb_get_ntohs(tvb, offset+4);
800         optlen = tvb_get_ntohs(tvb, offset+6);
801         wtp_descriptor_type_item = proto_tree_add_text(wtp_descriptor_type_tree, tvb, offset, 4+2+2+optlen, "WTP Descriptor Type: (t=%d,l=%d) %s", wtp_descriptor_type, optlen, val_to_str(wtp_descriptor_type,wtp_descriptor_type_vals,"Unknown WTP Descriptor Type (%02d)") );
802         sub_wtp_descriptor_type_tree = proto_item_add_subtree(wtp_descriptor_type_item, ett_capwap);
803
804         proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_vendor, tvb, offset, 4, ENC_BIG_ENDIAN);
805
806         proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_type, tvb, offset+4, 2, ENC_BIG_ENDIAN);
807
808         proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_length, tvb, offset+6, 2, ENC_BIG_ENDIAN);
809
810         proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_value, tvb, offset+8, optlen, ENC_NA);
811
812         switch (wtp_descriptor_type) {
813         case WTP_DESCRIPTOR_HARDWARE_VERSION:
814                 proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_hardware_version, tvb, offset+8, optlen, ENC_BIG_ENDIAN);
815                 break;
816
817         case WTP_DESCRIPTOR_ACTIVE_SOFTWARE_VERSION:
818                 proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_active_software_version, tvb, offset+8, optlen, ENC_BIG_ENDIAN);
819                 break;
820
821         case WTP_DESCRIPTOR_BOOT_VERSION:
822                 proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_boot_version, tvb, offset+8, optlen, ENC_BIG_ENDIAN);
823                 break;
824
825         case WTP_DESCRIPTOR_OTHER_SOFTWARE_VERSION:
826                 proto_tree_add_item(sub_wtp_descriptor_type_tree, hf_capwap_msg_element_type_wtp_descriptor_other_software_version, tvb, offset+8, optlen, ENC_BIG_ENDIAN);
827                 break;
828
829         default:
830                 /* No Default Action */
831                 break;
832         }
833
834         return 4+2+2+optlen;
835 }
836
837 /* Returns the number of bytes consumed by this option. */
838 static int
839 dissect_capwap_board_data(tvbuff_t *tvb, proto_tree *board_data_type_tree, guint offset)
840 {
841         guint optlen,board_data_type = 0;
842         proto_item *board_data_type_item;
843         proto_tree *sub_board_data_type_tree;
844
845         board_data_type = tvb_get_ntohs(tvb, offset);
846         optlen = tvb_get_ntohs(tvb, offset+2);
847         board_data_type_item = proto_tree_add_text(board_data_type_tree, tvb, offset, 2+2+optlen, "Board Data Type: (t=%d,l=%d) %s", board_data_type, optlen, val_to_str(board_data_type,board_data_type_vals,"Unknown Board Data Type (%02d)") );
848         sub_board_data_type_tree = proto_item_add_subtree(board_data_type_item, ett_capwap);
849
850         proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_type,tvb, offset, 2, ENC_BIG_ENDIAN);
851
852         proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
853
854         proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_value, tvb, offset+4, optlen, ENC_NA);
855         switch (board_data_type) {
856         case BOARD_DATA_WTP_MODEL_NUMBER:
857                 proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_wtp_model_number, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
858                 break;
859
860         case BOARD_DATA_WTP_SERIAL_NUMBER:
861                 proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_wtp_serial_number, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
862                 break;
863
864         case BOARD_DATA_BOARD_ID:
865                 proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_wtp_board_id, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
866                 break;
867
868         case BOARD_DATA_BOARD_REVISION:
869                 proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_wtp_board_revision, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
870                 break;
871
872         case BOARD_DATA_BASE_MAC_ADDRESS:
873                 proto_tree_add_item(sub_board_data_type_tree, hf_capwap_msg_element_type_wtp_board_data_base_mac_address, tvb, offset+4, 6, ENC_BIG_ENDIAN);
874                 break;
875
876         default:
877                 /* No Default Action */
878                 break;
879         }
880
881         return 2+2+optlen;
882 }
883
884 /* Returns the number of bytes consumed by this option. */
885 static int
886 dissect_capwap_message_element_type(tvbuff_t *tvb, proto_tree *msg_element_type_tree, guint offset)
887 {
888         guint optlen, offset_end, number_encrypt, i, msg_element_type = 0;
889         proto_item *msg_element_type_item, *msg_element_type_item_flag;
890         proto_tree *sub_msg_element_type_tree, *sub_msg_element_type_flag_tree;
891
892         msg_element_type = tvb_get_ntohs(tvb, offset);
893         optlen = tvb_get_ntohs(tvb, offset+2);
894         msg_element_type_item = proto_tree_add_text(msg_element_type_tree, tvb, offset, 2+2+optlen, "Type: (t=%d,l=%d) %s", msg_element_type, optlen, val_to_str(msg_element_type,message_element_type_vals,"Unknown Message Element Type (%02d)") );
895         sub_msg_element_type_tree = proto_item_add_subtree(msg_element_type_item, ett_capwap);
896
897         proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type,tvb, offset, 2, ENC_BIG_ENDIAN);
898
899         proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
900
901         proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_value, tvb, offset+4, optlen, ENC_NA);
902
903         switch (msg_element_type) {
904         case TYPE_AC_DESCRIPTOR: /* AC Descriptor (1) */
905                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_stations, tvb, offset+4, 2, ENC_BIG_ENDIAN);
906                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_limit, tvb, offset+6, 2, ENC_BIG_ENDIAN);
907                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_active_wtp, tvb, offset+8, 2, ENC_BIG_ENDIAN);
908                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_max_wtp, tvb, offset+10, 2, ENC_BIG_ENDIAN);
909
910                 /* AC Descriptor Security Flags... */
911                 msg_element_type_item_flag = proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_security, tvb, offset+12, 1, ENC_NA);
912                 sub_msg_element_type_flag_tree = proto_item_add_subtree(msg_element_type_item_flag, ett_capwap);
913
914                 proto_tree_add_boolean(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_ac_descriptor_security_r, tvb, offset+12, 1, ENC_BIG_ENDIAN);
915                 proto_tree_add_boolean(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_ac_descriptor_security_s, tvb, offset+12, 1, ENC_BIG_ENDIAN);
916                 proto_tree_add_boolean(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_ac_descriptor_security_x, tvb, offset+12, 1, ENC_BIG_ENDIAN);
917
918                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_rmac_field, tvb, offset+13, 1, ENC_BIG_ENDIAN);
919                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_reserved, tvb, offset+14, 1, ENC_BIG_ENDIAN);
920
921                 /* AC Descriptor DTLS Flags... */
922                 msg_element_type_item_flag = proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_descriptor_dtls_policy, tvb, offset+15, 1, ENC_NA);
923                 sub_msg_element_type_flag_tree = proto_item_add_subtree(msg_element_type_item_flag, ett_capwap);
924
925                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_ac_descriptor_dtls_policy_r, tvb, offset+15, 1, ENC_BIG_ENDIAN);
926                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_ac_descriptor_dtls_policy_d, tvb, offset+15, 1, ENC_BIG_ENDIAN);
927                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_ac_descriptor_dtls_policy_c, tvb, offset+15, 1, ENC_BIG_ENDIAN);
928
929                 offset_end = offset + optlen -4;
930                 offset += 4 + 12;
931                 while (offset < offset_end) {
932                         offset += dissect_capwap_ac_information(tvb, sub_msg_element_type_tree, offset);
933                 }
934                 break;
935
936         case TYPE_AC_IPV4_LIST: /* AC IPv4 List (2) */
937                 offset_end = offset + 4 + optlen;
938                 offset += 4;
939
940                 if (optlen%4 == 0)
941                 {
942                         while (offset_end-offset > 0)
943                         {
944                                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_ipv4_list, tvb, offset, 4, ENC_BIG_ENDIAN);
945                                 offset += 4;
946                         }
947
948                 }
949                 break;
950         case TYPE_AC_IPV6_LIST: /* AC IPv6 List (3) */
951                 offset_end = offset + 4 + optlen;
952                 offset += 4;
953
954                 if (optlen%16 == 0)
955                 {
956                         while (offset_end-offset > 0)
957                         {
958                                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_ipv6_list, tvb, offset, 16, ENC_BIG_ENDIAN);
959                                 offset += 16;
960                         }
961
962                 }
963                 break;
964         case TYPE_AC_NAME: /* AC Name (4) */
965                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_name, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
966                 break;
967
968         case TYPE_AC_NAME_W_PRIORITY: /* AC Name With Priority (5) */
969                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_name_with_priority, tvb, offset+1, 1, ENC_BIG_ENDIAN);
970                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ac_name, tvb, offset+5, optlen-1, ENC_BIG_ENDIAN);
971                 break;
972
973         case TYPE_CAPWAP_CONTROL_IPV4_ADDRESS: /* CAPWAP Control IPv4 Address (10) */
974                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_capwap_control_ipv4, tvb, offset+4, 4, ENC_BIG_ENDIAN);
975                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_capwap_control_wtp_count, tvb, offset+8, 2, ENC_BIG_ENDIAN);
976                 break;
977
978         case TYPE_CAPWAP_CONTROL_IPV6_ADDRESS: /* CAPWAP Control IPv6 Address (11) */
979                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_capwap_control_ipv6, tvb, offset+4, 16, ENC_BIG_ENDIAN);
980                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_capwap_control_wtp_count, tvb, offset+20, 2, ENC_BIG_ENDIAN);
981                 break;
982
983         case TYPE_CAPWAP_TIMERS: /* CAPWAP Timers (12) */
984                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_capwap_timers_discovery, tvb, offset+4, 1, ENC_BIG_ENDIAN);
985                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_capwap_timers_echo_request, tvb, offset+5, 1, ENC_BIG_ENDIAN);
986                 break;
987
988         case TYPE_DECRYPTION_ERROR_REPORT_PERIOD: /* Decryption Error Report Period (16) */
989                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_decryption_error_report_period_radio_id, tvb, offset+4, 1, ENC_BIG_ENDIAN);
990                 proto_tree_add_item(sub_msg_element_type_tree,hf_capwap_msg_element_type_decryption_error_report_period_interval, tvb, offset+5, 2, ENC_BIG_ENDIAN);
991                 break;
992
993         case TYPE_DISCOVERY_TYPE: /* Discovery Type (20) */
994                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_discovery_type, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
995                 break;
996         case TYPE_IDLE_TIMEOUT: /* Idle Timeout (23) */
997                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_idle_timeout, tvb, offset+4, 4, ENC_BIG_ENDIAN);
998                 break;
999
1000         case TYPE_LOCATION_DATA: /* Location Data (28) */
1001                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_location_data, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
1002                 break;
1003
1004         case TYPE_MAXIMUM_MESSAGE_LENGTH: /* Maximum Message Length (29) */
1005                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_maximum_message_length, tvb, offset+4, 2, ENC_BIG_ENDIAN);
1006                 break;
1007
1008         case TYPE_RADIO_ADMINISTRATIVE_STATE: /* Radio Administrative State (31) */
1009                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_radio_admin_id, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1010                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_radio_admin_state, tvb, offset+5, 1, ENC_BIG_ENDIAN);
1011
1012                 break;
1013
1014         case TYPE_RADIO_OPERATIONAL_STATE: /* Radio Operational State (32) */
1015                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_radio_op_state_radio_id, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1016                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_radio_op_state_radio_state, tvb, offset+5, 1, ENC_BIG_ENDIAN);
1017                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_radio_op_state_radio_cause, tvb, offset+6, 1, ENC_BIG_ENDIAN);
1018                 break;
1019
1020         case TYPE_RESULT_CODE: /* Result Code (33) */
1021                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_result_code, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
1022
1023                 break;
1024
1025         case TYPE_SESSION_ID: /* Session ID (35) */
1026                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_session_id, tvb, offset+4, optlen, ENC_NA);
1027                 break;
1028
1029         case TYPE_STATISTICS_TIMER: /* Statistics Timer (36) */
1030                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_statistics_timer, tvb, offset+4, 2, ENC_BIG_ENDIAN);
1031                 break;
1032
1033         case TYPE_VENDOR_SPECIFIC_PAYLOAD: /* Vendor Specific Payload (37) */
1034                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_vsp_vendor_identifier, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1035                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_vsp_vendor_element_id, tvb, offset+8, 2, ENC_BIG_ENDIAN);
1036                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_vsp_vendor_data, tvb, offset+10, optlen-6, ENC_NA);
1037                 break;
1038
1039         case TYPE_WTP_BOARD_DATA: /* WTP Board Data (38) */
1040                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_board_data_vendor, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1041                 offset += 8;
1042                 offset_end = offset + optlen -4;
1043                 while (offset < offset_end) {
1044                         offset += dissect_capwap_board_data(tvb, sub_msg_element_type_tree, offset);
1045                 }
1046                 break;
1047
1048         case TYPE_WTP_DESCRIPTOR: /* WTP Descriptor (39) */
1049                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_descriptor_max_radios, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1050                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_descriptor_radio_in_use, tvb, offset+5, 1, ENC_BIG_ENDIAN);
1051                 if (global_capwap_draft_8_cisco == 0)
1052                 {
1053                         number_encrypt = tvb_get_guint8(tvb,offset+6);
1054                         msg_element_type_item_flag = proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_descriptor_number_encrypt, tvb, offset+6, 1, ENC_BIG_ENDIAN);
1055                         sub_msg_element_type_flag_tree = proto_item_add_subtree(msg_element_type_item_flag, ett_capwap);
1056                         for (i=0; i < number_encrypt; i++) {
1057                                 dissect_capwap_encryption_capabilities(tvb, sub_msg_element_type_flag_tree, offset+4+3+i*3);
1058                         }
1059                         offset_end = offset + optlen -4;
1060                         offset += 4 + 3 + number_encrypt * 3;
1061                 }
1062                 else
1063                 {
1064                         /*in Draft 8, there is only one "encryption_capabilities*/
1065                         proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_descriptor_encrypt_capabilities, tvb, offset+6, 2, ENC_BIG_ENDIAN);
1066                         offset_end = offset + optlen -4;
1067                         offset += 6 + 2;
1068                 }
1069                 while (offset < offset_end) {
1070                         offset += dissect_capwap_wtp_descriptor(tvb, sub_msg_element_type_tree, offset);
1071                 }
1072                 break;
1073
1074         case TYPE_WTP_FALLBACK: /* WTP Fallback (40) */
1075                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_fallback, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1076                 break;
1077
1078         case TYPE_WTP_FRAME_TUNNEL_MODE: /* WTP Frame Tunnel Mode (41) */
1079                 msg_element_type_item_flag = proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_frame_tunnel_mode, tvb, offset+4, 1, ENC_NA);
1080                 sub_msg_element_type_flag_tree = proto_item_add_subtree(msg_element_type_item_flag, ett_capwap);
1081
1082                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_wtp_frame_tunnel_mode_n, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1083                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_wtp_frame_tunnel_mode_e, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1084                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_wtp_frame_tunnel_mode_l, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1085                 proto_tree_add_item(sub_msg_element_type_flag_tree, hf_capwap_msg_element_type_wtp_frame_tunnel_mode_r, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1086                 break;
1087
1088         case TYPE_WTP_MAC_TYPE: /* WTP MAC Type (44) */
1089                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_mac_type, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
1090                 break;
1091
1092         case TYPE_WTP_NAME: /* WTP Name (45) */
1093                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_name, tvb, offset+4, optlen, ENC_BIG_ENDIAN);
1094                 break;
1095
1096         case TYPE_WTP_REBOOT_STATISTICS: /* WTP Reboot Statistics (48) */
1097                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_reboot_count, tvb, offset+4, 2, ENC_BIG_ENDIAN);
1098                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_ac_initiated_count, tvb, offset+6, 2, ENC_BIG_ENDIAN);
1099                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_link_failure_count, tvb, offset+8, 2, ENC_BIG_ENDIAN);
1100                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_sw_failure_count, tvb, offset+10, 2, ENC_BIG_ENDIAN);
1101                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_hw_failure_count, tvb, offset+12, 2, ENC_BIG_ENDIAN);
1102                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_other_failure_count, tvb, offset+14, 2, ENC_BIG_ENDIAN);
1103                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_unknown_failure_count, tvb, offset+16, 2, ENC_BIG_ENDIAN);
1104                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_wtp_reboot_statistics_last_failure_type, tvb, offset+18, 1, ENC_BIG_ENDIAN);
1105                 break;
1106
1107         case IEEE80211_RATE_SET: /* ieee80211 Rate Set (1034) */
1108                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_rate_set_radio_id, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1109                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_rate_set_rate_set, tvb, offset+5, optlen-1, ENC_NA);
1110                 break;
1111
1112         case IEEE80211_STATION_SESSION_KEY: /* ieee80211 Station Session Key (1038) */
1113                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_mac, tvb, offset+4, 6, ENC_BIG_ENDIAN);
1114                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_flags, tvb, offset+10, 2, ENC_BIG_ENDIAN);
1115                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_flags_a, tvb, offset+10, 2, ENC_BIG_ENDIAN);
1116                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_flags_c, tvb, offset+10, 2, ENC_BIG_ENDIAN);
1117                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_tsc, tvb, offset+12, 6, ENC_NA);
1118                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_rsc, tvb, offset+18, 6, ENC_NA);
1119                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_station_session_key_key, tvb, offset+24, optlen-24, ENC_NA);
1120                 break;
1121
1122         case IEEE80211_WTP_RADIO_INFORMATION: /* ieee80211 WTP Radio Information (1048) */
1123                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_id, tvb, offset+4, 1, ENC_BIG_ENDIAN);
1124                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_reserved, tvb, offset+5, 3, ENC_NA);
1125                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_n, tvb, offset+8, 1, ENC_BIG_ENDIAN);
1126                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_g, tvb, offset+8, 1, ENC_BIG_ENDIAN);
1127                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_a, tvb, offset+8, 1, ENC_BIG_ENDIAN);
1128                 proto_tree_add_item(sub_msg_element_type_tree, hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_b, tvb, offset+8, 1, ENC_BIG_ENDIAN);
1129                 break;
1130
1131         default:
1132                 /* No Default Action */
1133                 break;
1134         }
1135
1136         return 2+2+optlen;
1137 }
1138
1139 /* Returns the number of bytes consumed by this option. */
1140 static int
1141 dissect_capwap_message_element(tvbuff_t *tvb, proto_tree *capwap_control_tree, guint offset)
1142 {
1143         guint plen = 0, offset_end;
1144         proto_item *ti;
1145         proto_tree *capwap_message_element_tree;
1146
1147         ti = proto_tree_add_item(capwap_control_tree, hf_capwap_message_element, tvb, offset, tvb_reported_length(tvb) - offset, ENC_NA);
1148         capwap_message_element_tree = proto_item_add_subtree(ti, ett_capwap);
1149
1150         offset_end = tvb_reported_length(tvb);
1151
1152         while (offset+plen < offset_end) {
1153                 plen += dissect_capwap_message_element_type(tvb, capwap_message_element_tree, offset+plen);
1154         }
1155
1156         return plen;
1157 }
1158
1159 /* Returns the number of bytes consumed by this option. */
1160 static int
1161 dissect_capwap_control_header(tvbuff_t *tvb, proto_tree *capwap_control_tree, guint offset, packet_info *pinfo)
1162 {
1163         guint plen = 0;
1164         proto_item *ti, *ti_flag;
1165         proto_tree *capwap_control_header_tree;
1166         proto_tree *capwap_control_msg_type_tree;
1167
1168         ti = proto_tree_add_item(capwap_control_tree, hf_capwap_control_header, tvb, offset, 8, ENC_NA);
1169         capwap_control_header_tree = proto_item_add_subtree(ti, ett_capwap);
1170
1171         /* Message Type 32 bits */
1172         ti_flag = proto_tree_add_item(capwap_control_header_tree, hf_capwap_control_header_msg_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1173         capwap_control_msg_type_tree = proto_item_add_subtree(ti_flag, ett_capwap);
1174
1175         proto_tree_add_item(capwap_control_msg_type_tree, hf_capwap_control_header_msg_type_enterprise_nbr, tvb, offset, 3, ENC_BIG_ENDIAN);
1176         proto_tree_add_item(capwap_control_msg_type_tree, hf_capwap_control_header_msg_type_enterprise_specific, tvb, offset+3, 1, ENC_BIG_ENDIAN);
1177
1178         col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",val_to_str(tvb_get_guint8(tvb, offset+3),message_type,"Unknown Message Type (0x%02x)"));
1179
1180         plen += 4;
1181         /* Sequence 8 bits */
1182         proto_tree_add_item(capwap_control_header_tree, hf_capwap_control_header_seq_number, tvb, offset+plen, 1, ENC_BIG_ENDIAN);
1183         plen += 1;
1184
1185         /* Message Element Length 16 bits */
1186         proto_tree_add_item(capwap_control_header_tree, hf_capwap_control_header_msg_element_length, tvb, offset+plen, 2, ENC_BIG_ENDIAN);
1187         plen += 2;
1188         /* Flags 8 bits */
1189         proto_tree_add_item(capwap_control_header_tree, hf_capwap_control_header_flags, tvb, offset+plen, 1, ENC_BIG_ENDIAN);
1190         plen += 1;
1191         return plen;
1192 }
1193
1194 /* Returns the number of bytes consumed by this option. */
1195 static int
1196 dissect_capwap_header(tvbuff_t *tvb, proto_tree *capwap_control_tree, guint offset, packet_info *pinfo, guint8 *payload_type, guint8 *payload_wbid, gboolean *fragment_is, gboolean *fragment_more, guint32 *fragment_id, guint32 *fragment_offset)
1197 {
1198         guint plen = 0;
1199         proto_item *ti, *ti_flag;
1200         proto_tree *capwap_header_tree;
1201         proto_tree *capwap_header_flags_tree;
1202         guint flags = 0;
1203         guint8 maclength, wirelesslength;
1204         guint align = 0;
1205
1206         ti = proto_tree_add_item(capwap_control_tree, hf_capwap_header, tvb, offset+plen, tvb_get_bits8(tvb, (offset+plen)*8, 5), ENC_NA);
1207         capwap_header_tree = proto_item_add_subtree(ti, ett_capwap);
1208
1209         /* Header Length : 5 Bits */
1210         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_hlen, tvb, offset+plen, 1, tvb_get_bits8(tvb, (offset+plen)*8, 5));
1211         /* Radio ID : 5 Bits */
1212         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_rid, tvb, offset+plen, 1, tvb_get_bits8(tvb, (offset+plen)*8+5, 5));
1213
1214         /* Wireless Binding ID : 5 Bits */
1215         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_wbid, tvb, offset+plen, 1, tvb_get_bits8(tvb, (offset+plen)*8+10, 5));
1216
1217         /* WBid of Payload (for CAPWAP Data Packet) */
1218         *payload_wbid = tvb_get_bits8(tvb, (offset+plen)*8+10, 5);
1219         plen++;
1220
1221         /* Flags : 9 Bits */
1222         flags = tvb_get_bits16(tvb, (offset+plen)*8+7, 9, 0);
1223         ti_flag = proto_tree_add_uint_format(capwap_header_tree, hf_capwap_header_flags, tvb, offset+plen, 1, 0, "Header flags");
1224         capwap_header_flags_tree = proto_item_add_subtree(ti_flag, ett_capwap);
1225
1226         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_t, tvb, offset+plen, 1, flags);
1227         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_f, tvb, offset+plen, 1, flags);
1228         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_l, tvb, offset+plen, 1, flags);
1229         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_w, tvb, offset+plen, 1, flags);
1230         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_m, tvb, offset+plen, 1, flags);
1231         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_k, tvb, offset+plen, 1, flags);
1232         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_r, tvb, offset+plen, 1, flags);
1233
1234         /* Fragment ??*/
1235         *fragment_is = ((flags & 0x80) == 0x80) ? TRUE : FALSE;
1236         *fragment_more = ((flags &0x40) == 0x40) ? FALSE : TRUE;
1237
1238         /* Type of Payload (for CAPWAP Data Packet) */
1239         *payload_type = tvb_get_bits8(tvb, (offset+plen)*8+7,1);
1240
1241         plen += 2;
1242
1243         /* Fragment ID : 16 Bits */
1244         proto_tree_add_item(capwap_header_tree, hf_capwap_header_fragment_id, tvb, offset+plen, 2, ENC_BIG_ENDIAN);
1245         *fragment_id = (guint32)tvb_get_ntohs(tvb, offset+plen);
1246         plen += 2;
1247
1248         /* Fragment offset : 13 Bits */
1249         /* FIXME: Use _item and mask in hf element */
1250         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_fragment_offset, tvb, offset+plen, 2, tvb_get_bits16(tvb, (offset+plen)*8, 13, 0));
1251         *fragment_offset = 8 * (guint32)tvb_get_bits16(tvb, (offset+plen)*8, 13, 0);
1252
1253         /* Reserved 3 Bits */
1254         /* FIXME: Use _item and mask in hf element */
1255         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_reserved, tvb, offset+plen+1, 1, tvb_get_bits8(tvb, (offset+plen)*8+13, 3));
1256         plen += 2;
1257         /* Optionnal Headers */
1258         if (flags & 0x10 /* Radio MAC address */) {
1259                 maclength=tvb_get_guint8(tvb, offset+plen);
1260                 proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_length, tvb, offset+plen, 1, ENC_BIG_ENDIAN);
1261                 plen += 1;
1262                 if (maclength == 6) {
1263                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_eui48, tvb, offset+plen, maclength, ENC_BIG_ENDIAN);
1264
1265                 } else if (maclength == 8) {
1266                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_eui64, tvb, offset+plen, maclength, ENC_BIG_ENDIAN);
1267                 } else {
1268                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_data, tvb, offset+plen, maclength, ENC_NA);
1269                 }
1270                 plen += maclength;
1271                 /* 4 Bytes Alignment ? */
1272                 align = 4-((offset+plen)%4);
1273                 if (align != 4)
1274                 {
1275                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_padding, tvb, offset+plen, align, ENC_NA);
1276                         plen += align;
1277                 }
1278         }
1279         if (flags & 0x20 /* Wireless specific information */) {
1280                 wirelesslength=tvb_get_guint8(tvb, offset+plen);
1281
1282                 /* in Draft 8, the WBid is add in Wireless Specific Information*/
1283                 if (global_capwap_draft_8_cisco == 1)
1284                 {
1285                         plen += 1;
1286                         wirelesslength = 4;
1287                 }
1288                 proto_tree_add_item(capwap_header_tree, hf_capwap_header_wireless_length, tvb, offset+plen, 1, ENC_BIG_ENDIAN);
1289                 plen += 1;
1290                 proto_tree_add_item(capwap_header_tree, hf_capwap_header_wireless_data, tvb, offset+plen, wirelesslength, ENC_NA);
1291
1292                 /* Optional Wireless Specific Information for ieee80211 (wbid = 1) Section 4 of RFC5416 */
1293                 if (*payload_wbid == 1)
1294                 {
1295                         dissect_capwap_data_message_bindings_ieee80211(tvb, capwap_header_tree, offset+plen, pinfo);
1296                 }
1297
1298                 plen += wirelesslength;
1299                 /* 4 Bytes Alignment ? */
1300                 align = 4-((offset+plen)%4);
1301                 if (align != 4)
1302                 {
1303                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_padding, tvb, offset+plen, align, ENC_NA);
1304                         plen += align;
1305                 }
1306         }
1307         return plen;
1308 }
1309
1310 /* Returns the number of bytes consumed by this option. */
1311 static int
1312 dissect_capwap_preamble(tvbuff_t *tvb, proto_tree *capwap_control_tree, guint offset, guint8 *type_header)
1313 {
1314         guint plen = 0;
1315         proto_item *ti;
1316         proto_tree *capwap_preamble_tree;
1317
1318         ti = proto_tree_add_item(capwap_control_tree, hf_capwap_preamble, tvb, offset+plen, -1, ENC_NA);
1319         capwap_preamble_tree = proto_item_add_subtree(ti, ett_capwap);
1320
1321         proto_tree_add_uint(capwap_preamble_tree, hf_capwap_preamble_version, tvb, offset+plen, 1, hi_nibble(tvb_get_guint8(tvb, offset+plen)));
1322         proto_tree_add_uint(capwap_preamble_tree, hf_capwap_preamble_type, tvb, offset+plen, 1, lo_nibble(tvb_get_guint8(tvb, offset+plen)));
1323         *type_header = lo_nibble(tvb_get_guint8(tvb, offset+plen));
1324         plen++;
1325         /* DTLS Header ? */
1326         if (*type_header == 1) {
1327                 proto_tree_add_item(capwap_preamble_tree, hf_capwap_preamble_reserved, tvb, offset+plen, 3, ENC_BIG_ENDIAN);
1328                 plen +=3;
1329         }
1330         proto_item_set_len(ti, plen);
1331         return plen;
1332 }
1333
1334 /* Code to actually dissect the packets */
1335 static void
1336 dissect_capwap_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1337 {
1338         /* Set up structures needed to add the protocol subtree and manage it */
1339         proto_item *ti;
1340         proto_tree *capwap_control_tree;
1341         guint offset = 0;
1342         tvbuff_t *next_tvb = NULL;
1343         guint8 type_header;
1344         guint8 payload_type;
1345         guint8 payload_wbid;
1346         gboolean fragment_is;
1347         gboolean fragment_more;
1348         guint32 fragment_id;
1349         guint32 fragment_offset;
1350         fragment_data *frag_msg = NULL;
1351         gboolean save_fragmented;
1352
1353         /* Make entries in Protocol column and Info column on summary display */
1354         col_set_str(pinfo->cinfo, COL_PROTOCOL, "CAPWAP");
1355         col_set_str(pinfo->cinfo, COL_INFO, "CAPWAP-Control");
1356
1357         ti = proto_tree_add_item(tree, proto_capwap, tvb, 0, -1, ENC_BIG_ENDIAN);
1358         capwap_control_tree = proto_item_add_subtree(ti, ett_capwap);
1359
1360         /* CAPWAP Preamble */
1361         offset += dissect_capwap_preamble(tvb, capwap_control_tree, offset, &type_header);
1362
1363         if (type_header == 1) {
1364                 next_tvb = tvb_new_subset_remaining (tvb, offset);
1365                 call_dissector(dtls_handle, next_tvb, pinfo, tree);
1366                 return;
1367         }
1368
1369         /* CAPWAP Header */
1370         offset += dissect_capwap_header(tvb, capwap_control_tree, offset, pinfo, &payload_type, &payload_wbid, &fragment_is, &fragment_more, &fragment_id, &fragment_offset );
1371
1372         /* CAPWAP Reassemble */
1373         save_fragmented = pinfo->fragmented;
1374
1375         if (global_capwap_reassemble && fragment_is)
1376         {
1377                 pinfo->fragmented = TRUE;
1378
1379                 frag_msg = fragment_add_check(tvb, offset, pinfo,fragment_id,
1380                                               capwap_fragment_table,
1381                                               capwap_reassembled_table,
1382                                               fragment_offset,
1383                                               tvb_length_remaining(tvb, offset),
1384                                               fragment_more);
1385
1386                 next_tvb = process_reassembled_data(tvb, offset, pinfo,
1387                                                     "Reassembled CAPWAP", frag_msg,
1388                                                     &capwap_frag_items, NULL, tree);
1389
1390                 if (next_tvb == NULL)
1391                 { /* make a new subset */
1392                         next_tvb = tvb_new_subset_remaining(tvb, offset);
1393                         call_dissector(data_handle, next_tvb, pinfo, tree);
1394                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Fragment ID: %u, Fragment Offset: %u)", fragment_id, fragment_offset);
1395                 }
1396                 else
1397                 {
1398                         /* CAPWAP Control Header */
1399                         offset = dissect_capwap_control_header(next_tvb, capwap_control_tree, 0, pinfo);
1400
1401                         /* CAPWAP Message Element */
1402                         offset += dissect_capwap_message_element(next_tvb, capwap_control_tree, offset);
1403                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Reassembled, Fragment ID: %u)", fragment_id);
1404                 }
1405         }
1406         else
1407         {
1408                 /* CAPWAP Control Header */
1409                 offset += dissect_capwap_control_header(tvb, capwap_control_tree, offset, pinfo);
1410
1411                 /* CAPWAP Message Element */
1412                 offset += dissect_capwap_message_element(tvb, capwap_control_tree, offset);
1413         }
1414         pinfo->fragmented = save_fragmented;
1415 }
1416
1417 /* Code to actually dissect the packets */
1418 static void
1419 dissect_capwap_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1420 {
1421         /* Set up structures needed to add the protocol subtree and manage it */
1422         proto_item *ti;
1423         proto_tree *capwap_data_tree;
1424         guint offset = 0;
1425         tvbuff_t *next_tvb;
1426         guint8 type_header;
1427         guint8 payload_type;
1428         guint8 payload_wbid;
1429         gboolean fragment_is;
1430         gboolean fragment_more;
1431         guint32 fragment_id;
1432         guint32 fragment_offset;
1433         fragment_data *frag_msg = NULL;
1434         gboolean save_fragmented;
1435
1436         /* Make entries in Protocol column and Info column on summary display */
1437         col_set_str(pinfo->cinfo, COL_PROTOCOL, "CAPWAP");
1438         col_set_str(pinfo->cinfo, COL_INFO, "CAPWAP-Data");
1439
1440         ti = proto_tree_add_item(tree, proto_capwap, tvb, 0, -1, ENC_BIG_ENDIAN);
1441         capwap_data_tree = proto_item_add_subtree(ti, ett_capwap);
1442
1443         /* CAPWAP Preamble */
1444         offset += dissect_capwap_preamble(tvb, capwap_data_tree, offset, &type_header);
1445
1446         if (type_header == 1) {
1447                 next_tvb = tvb_new_subset_remaining (tvb, offset);
1448                 call_dissector(dtls_handle, next_tvb, pinfo, tree);
1449                 return;
1450         }
1451
1452         /* CAPWAP Header */
1453         offset += dissect_capwap_header(tvb, capwap_data_tree, offset, pinfo, &payload_type, &payload_wbid, &fragment_is, &fragment_more, &fragment_id, &fragment_offset);
1454
1455         /* CAPWAP Reassemble */
1456         save_fragmented = pinfo->fragmented;
1457
1458         if (global_capwap_reassemble && fragment_is)
1459         {
1460                 pinfo->fragmented = TRUE;
1461
1462                 frag_msg = fragment_add_check(tvb, offset, pinfo,fragment_id,
1463                                               capwap_fragment_table,
1464                                               capwap_reassembled_table,
1465                                               fragment_offset,
1466                                               tvb_length_remaining(tvb, offset),
1467                                               fragment_more);
1468
1469                 next_tvb = process_reassembled_data(tvb, offset, pinfo,
1470                                                     "Reassembled CAPWAP", frag_msg,
1471                                                     &capwap_frag_items, NULL, tree);
1472
1473                 if (next_tvb == NULL)
1474                 { /* make a new subset */
1475                         next_tvb = tvb_new_subset_remaining(tvb, offset);
1476                         call_dissector(data_handle,next_tvb, pinfo, tree);
1477                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Fragment ID: %u, Fragment Offset: %u)", fragment_id, fragment_offset);
1478                 }
1479                 else
1480                 {
1481                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Reassembled, Fragment ID: %u)", fragment_id);
1482                 }
1483         }
1484         else
1485         {
1486                 next_tvb = tvb_new_subset_remaining (tvb, offset);
1487         }
1488
1489         /* CAPWAP Data Payload */
1490         if (payload_type == 0) {
1491                 /* IEEE 802.3 Frame */
1492                 call_dissector(ieee8023_handle, next_tvb, pinfo, tree);
1493         } else {
1494                 switch (payload_wbid) {
1495                 case 0: /* Reserved - Cisco seems to use this instead of 1 */
1496                         /* It seems that just calling ieee80211_handle is not
1497                          * quite enough to get this right, so call data_handle
1498                          * for now:
1499                          */
1500                         call_dissector(data_handle, next_tvb, pinfo, tree);
1501                         break;
1502                 case 1: /* IEEE 802.11 */
1503                         call_dissector(global_capwap_swap_frame_control ? ieee80211_bsfc_handle : ieee80211_handle, next_tvb, pinfo, tree);
1504                         break;
1505                 default: /* Unknown Data */
1506                         call_dissector(data_handle, next_tvb, pinfo, tree);
1507                         break;
1508                 }
1509         }
1510         pinfo->fragmented = save_fragmented;
1511 }
1512
1513
1514 void
1515 proto_register_capwap_control(void)
1516 {
1517         module_t *capwap_module;
1518
1519         static hf_register_info hf[] = {
1520                 /* Preamble */
1521                 { &hf_capwap_preamble,
1522                 { "Preamble",   "capwap.preamble",
1523                         FT_NONE, BASE_NONE, NULL, 0x0,
1524                         NULL, HFILL }},
1525                 { &hf_capwap_preamble_version,
1526                 { "Version",           "capwap.preamble.version",
1527                         FT_UINT8, BASE_DEC, NULL, 0x0,
1528                         "Version of CAPWAP", HFILL }},
1529                 { &hf_capwap_preamble_type,
1530                 { "Type",           "capwap.preamble.type",
1531                         FT_UINT8, BASE_DEC, VALS(type_header_vals), 0x0,
1532                         "Type of Payload", HFILL }},
1533                 { &hf_capwap_preamble_reserved,
1534                 { "Reserved",           "capwap.preamble.reserved",
1535                         FT_UINT24, BASE_DEC, NULL, 0x0,
1536                         NULL, HFILL }},
1537                 /* CAPWAP Header */
1538                 { &hf_capwap_header,
1539                 { "Header",     "capwap.header",
1540                         FT_NONE, BASE_NONE, NULL, 0x0,
1541                         NULL, HFILL }},
1542                 { &hf_capwap_header_hlen,
1543                 { "Header Length",      "capwap.header.length",
1544                         FT_UINT8, BASE_DEC, NULL, 0x0,
1545                         NULL, HFILL }},
1546                 { &hf_capwap_header_rid,
1547                 { "Radio ID",   "capwap.header.rid",
1548                         FT_UINT8, BASE_DEC, NULL, 0x0,
1549                         NULL, HFILL }},
1550                 { &hf_capwap_header_wbid,
1551                 { "Wireless Binding ID",        "capwap.header.wbid",
1552                         FT_UINT8, BASE_DEC, VALS(type_wbid), 0x0,
1553                         NULL, HFILL }},
1554                 { &hf_capwap_header_flags,
1555                 { "Header Flags",       "capwap.header.flags",
1556                         FT_UINT8, BASE_DEC, NULL, 0x0,
1557                         NULL, HFILL }},
1558                 { &hf_capwap_header_flags_t,
1559                 { "Payload Type",       "capwap.header.flags.t",
1560                         FT_BOOLEAN, 9, TFS(&flag_type_t), 0x100,
1561                         NULL, HFILL }},
1562                 { &hf_capwap_header_flags_f,
1563                 { "Fragment",   "capwap.header.flags.f",
1564                         FT_BOOLEAN, 9, TFS(&flag_type_f), 0x80,
1565                         NULL, HFILL }},
1566                 { &hf_capwap_header_flags_l,
1567                 { "Last Fragment",      "capwap.header.flags.l",
1568                         FT_BOOLEAN, 9, TFS(&flag_type_l), 0x40,
1569                         NULL, HFILL }},
1570                 { &hf_capwap_header_flags_w,
1571                 { "Wireless header",    "capwap.header.flags.w",
1572                         FT_BOOLEAN, 9, TFS(&flag_type_w), 0x20,
1573                         NULL, HFILL }},
1574                 { &hf_capwap_header_flags_m,
1575                 { "Radio MAC header",   "capwap.header.flags.m",
1576                         FT_BOOLEAN, 9, TFS(&flag_type_m), 0x10,
1577                         NULL, HFILL }},
1578                 { &hf_capwap_header_flags_k,
1579                 { "Keep-Alive", "capwap.header.flags.k",
1580                         FT_BOOLEAN, 9, TFS(&flag_type_k), 0x08,
1581                         NULL, HFILL }},
1582                 { &hf_capwap_header_flags_r,
1583                 { "Reserved",   "capwap.header.flags.r",
1584                         FT_BOOLEAN, 9, TFS(&tfs_set_notset), 0x07,
1585                         NULL, HFILL }},
1586                 { &hf_capwap_header_fragment_id,
1587                 { "Fragment ID",        "capwap.header.fragment.id",
1588                         FT_UINT16, BASE_DEC, NULL, 0x00,
1589                         NULL, HFILL }},
1590                 { &hf_capwap_header_fragment_offset,
1591                 { "Fragment Offset",    "capwap.header.fragment.offset",
1592                         FT_UINT16, BASE_DEC, NULL, 0x00,
1593                         NULL, HFILL }},
1594                 { &hf_capwap_header_reserved,
1595                 { "Reserved",   "capwap.header.fragment.reserved",
1596                         FT_UINT8, BASE_DEC, NULL, 0x00,
1597                         NULL, HFILL }},
1598                 { &hf_capwap_header_mac_length,
1599                 { "MAC length", "capwap.header.mac.length",
1600                         FT_UINT8, BASE_DEC, NULL, 0x00,
1601                         NULL, HFILL }},
1602                 { &hf_capwap_header_mac_eui48,
1603                 { "MAC address",        "capwap.header.mac.eui48",
1604                         FT_ETHER, BASE_NONE, NULL, 0x00,
1605                         NULL, HFILL }},
1606                 { &hf_capwap_header_mac_eui64,
1607                 { "MAC address",        "capwap.header.mac.eui64",
1608                         FT_EUI64, BASE_NONE, NULL, 0x00,
1609                         NULL, HFILL }},
1610                 { &hf_capwap_header_mac_data,
1611                 { "MAC address",        "capwap.header.mac.data",
1612                         FT_BYTES, BASE_NONE, NULL, 0x00,
1613                         NULL, HFILL }},
1614                 { &hf_capwap_header_wireless_length,
1615                 { "Wireless length",    "capwap.header.wireless.length",
1616                         FT_UINT8, BASE_DEC, NULL, 0x00,
1617                         NULL, HFILL }},
1618                 { &hf_capwap_header_wireless_data,
1619                 { "Wireless data",      "capwap.header.wireless.data",
1620                         FT_BYTES, BASE_NONE, NULL, 0x00,
1621                         NULL, HFILL }},
1622                 { &hf_capwap_header_wireless_data_ieee80211_fi,
1623                 { "Wireless data ieee80211 Frame Info", "capwap.header.wireless.data.ieee80211.fi",
1624                         FT_BYTES, BASE_NONE, NULL, 0x00,
1625                         NULL, HFILL }},
1626                 { &hf_capwap_header_wireless_data_ieee80211_fi_rssi,
1627                 { "Wireless data ieee80211 RSSI (dBm)", "capwap.header.wireless.data.ieee80211.fi.rssi",
1628                         FT_UINT8, BASE_DEC, NULL, 0x00,
1629                         NULL, HFILL }},
1630                 { &hf_capwap_header_wireless_data_ieee80211_fi_snr,
1631                 { "Wireless data ieee80211 SNR (dB)",   "capwap.header.wireless.data.ieee80211.fi.snr",
1632                         FT_UINT8, BASE_DEC, NULL, 0x00,
1633                         NULL, HFILL }},
1634                 { &hf_capwap_header_wireless_data_ieee80211_fi_data_rate,
1635                 { "Wireless data ieee80211 Data Rate (Mbps)",   "capwap.header.wireless.data.ieee80211.fi.data_rate",
1636                         FT_UINT16, BASE_DEC, NULL, 0x00,
1637                         NULL, HFILL }},
1638                 { &hf_capwap_header_wireless_data_ieee80211_dest_wlan,
1639                 { "Wireless data ieee80211 Destination WLANs",  "capwap.header.wireless.data.ieee80211.dw",
1640                         FT_BYTES, BASE_NONE, NULL, 0x00,
1641                         NULL, HFILL }},
1642                 { &hf_capwap_header_wireless_data_ieee80211_dw_wlan_id_bitmap,
1643                 { "Wireless data ieee80211 Destination Wlan Id bitmap",
1644                 "capwap.header.wireless.data.ieee80211.dw.wlan_id_bitmap",
1645                         FT_UINT16, BASE_DEC, NULL, 0x00,
1646                         NULL, HFILL }},
1647                 { &hf_capwap_header_wireless_data_ieee80211_dw_reserved,
1648                 { "Wireless data ieee80211 Destination Wlan reserved",  "capwap.header.wireless.data.ieee80211.dw.reserved",
1649                         FT_UINT16, BASE_DEC, NULL, 0x00,
1650                         NULL, HFILL }},
1651                 { &hf_capwap_header_padding,
1652                 { "Padding for 4 Byte Alignement",      "capwap.header.padding",
1653                         FT_BYTES, BASE_NONE, NULL, 0x00,
1654                         NULL, HFILL }},
1655
1656                 /* CAPWAP Control Header Message */
1657
1658                 { &hf_capwap_control_header,
1659                 { "Control Header",     "capwap.control.header",
1660                         FT_NONE, BASE_NONE, NULL, 0x00,
1661                         NULL, HFILL }},
1662                 { &hf_capwap_control_header_msg_type,
1663                 { "Message Type",       "capwap.control.header.message_type",
1664                         FT_UINT32, BASE_DEC, NULL, 0x00,
1665                         NULL, HFILL }},
1666                 { &hf_capwap_control_header_msg_type_enterprise_nbr,
1667                 { "Message Type (Enterprise Number)",   "capwap.control.header.message_type.enterprise_number",
1668                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1669                         NULL, HFILL }},
1670                 { &hf_capwap_control_header_msg_type_enterprise_specific,
1671                 { "Message Type (Enterprise Specific)", "capwap.control.header.message_type.enterprise_specific",
1672                         FT_UINT8, BASE_DEC, VALS(message_type), 0x00,
1673                         NULL, HFILL }},
1674                 { &hf_capwap_control_header_seq_number,
1675                 { "Sequence Number",    "capwap.control.header.sequence_number",
1676                         FT_UINT8, BASE_DEC, NULL, 0x00,
1677                         NULL, HFILL }},
1678                 { &hf_capwap_control_header_msg_element_length,
1679                 { "Message Element Length",     "capwap.control.header.message_element_length",
1680                         FT_UINT16, BASE_DEC, NULL, 0x00,
1681                         NULL, HFILL }},
1682                 { &hf_capwap_control_header_flags,
1683                 { "Flags",      "capwap.control.header.flags",
1684                         FT_UINT8, BASE_DEC, NULL, 0x00,
1685                         NULL, HFILL }},
1686
1687                 /* CAPWAP Protocol Message Elements */
1688
1689                 { &hf_capwap_message_element,
1690                 { "Message Element",    "capwap.message_element",
1691                         FT_NONE, BASE_NONE, NULL, 0x00,
1692                         NULL, HFILL }},
1693                 { &hf_capwap_msg_element_type,
1694                 { "Type",       "capwap.message_element.type",
1695                         FT_UINT16, BASE_DEC, VALS(message_element_type_vals), 0x00,
1696                         "CAPWAP Message Element type", HFILL }},
1697                 { &hf_capwap_msg_element_length,
1698                 { "Length",     "capwap.message_element.length",
1699                         FT_UINT16, BASE_DEC, NULL, 0x00,
1700                         "CAPWAP Message Element length", HFILL }},
1701                 { &hf_capwap_msg_element_value,
1702                 { "Value",      "capwap.message_element.value",
1703                         FT_BYTES, BASE_NONE, NULL, 0x00,
1704                         "CAPWAP Message Element value", HFILL }},
1705
1706                 /* CAPWAP Protocol Message Element Type */
1707
1708                 /* AC Descriptor */
1709                 { &hf_capwap_msg_element_type_ac_descriptor_stations,
1710                 { "Stations",   "capwap.control.message_element.ac_descriptor.stations",
1711                         FT_UINT16, BASE_DEC, NULL, 0x00,
1712                         NULL, HFILL }},
1713                 { &hf_capwap_msg_element_type_ac_descriptor_limit,
1714                 { "Limit Stations",     "capwap.control.message_element.ac_descriptor.limit",
1715                         FT_UINT16, BASE_DEC, NULL, 0x00,
1716                         NULL, HFILL }},
1717                 { &hf_capwap_msg_element_type_ac_descriptor_active_wtp,
1718                 { "Active WTPs",        "capwap.control.message_element.ac_descriptor.active_wtp",
1719                         FT_UINT16, BASE_DEC, NULL, 0x00,
1720                         NULL, HFILL }},
1721                 { &hf_capwap_msg_element_type_ac_descriptor_max_wtp,
1722                 { "Max WTPs",   "capwap.control.message_element.ac_descriptor.max_wtp",
1723                         FT_UINT16, BASE_DEC, NULL, 0x00,
1724                         NULL, HFILL }},
1725                 /* AC Descriptor Security Flags... */
1726                 { &hf_capwap_msg_element_type_ac_descriptor_security,
1727                 { "Security Flags",     "capwap.control.message_element.ac_descriptor.security",
1728                         FT_NONE, BASE_NONE, NULL, 0x0,
1729                         NULL, HFILL }},
1730                 { &hf_capwap_msg_element_type_ac_descriptor_security_s,
1731                 { "AC supports the pre-shared", "capwap.control.message_element.ac_descriptor.security.s",
1732                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x04,
1733                         NULL, HFILL }},
1734                 { &hf_capwap_msg_element_type_ac_descriptor_security_x,
1735                 { "AC supports X.509 Certificate",      "capwap.control.message_element.ac_descriptor.security.x",
1736                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
1737                         NULL, HFILL }},
1738                 { &hf_capwap_msg_element_type_ac_descriptor_security_r,
1739                 { "Reserved",   "capwap.control.message_element.ac_descriptor.security.r",
1740                         FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0xF9,
1741                         NULL, HFILL }},
1742
1743                 { &hf_capwap_msg_element_type_ac_descriptor_rmac_field,
1744                 { "R-MAC Field",        "capwap.control.message_element.ac_descriptor.rmac_field",
1745                         FT_UINT8, BASE_DEC, VALS(rmac_field_vals), 0x00,
1746                         NULL, HFILL }},
1747                 { &hf_capwap_msg_element_type_ac_descriptor_reserved,
1748                 { "Reserved",   "capwap.control.message_element.ac_descriptor.reserved",
1749                         FT_UINT8, BASE_DEC, NULL, 0x00,
1750                         NULL, HFILL }},
1751                 /* AC Descriptor DTLS Policy Flags... */
1752                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy,
1753                 { "DTLS Policy Flags",  "capwap.control.message_element.ac_descriptor.dtls_policy",
1754                         FT_NONE, BASE_NONE, NULL, 0x0,
1755                         NULL, HFILL }},
1756                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy_d,
1757                 { "DTLS-Enabled Data Channel Supported", "capwap.control.message_element.ac_descriptor.dtls_policy.d",
1758                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x04,
1759                         NULL, HFILL }},
1760                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy_c,
1761                 { "Clear Text Data Channel Supported",  "capwap.control.message_element.ac_descriptor.dtls_policy.c",
1762                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
1763                         NULL, HFILL }},
1764                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy_r,
1765                 { "Reserved",   "capwap.control.message_element.ac_descriptor.dtls_policy.r",
1766                         FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0xF9,
1767                         NULL, HFILL }},
1768
1769                 { &hf_capwap_msg_element_type_ac_information_vendor,
1770                 { "AC Information Vendor",      "capwap.control.message_element.ac_information.vendor",
1771                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1772                         NULL, HFILL }},
1773                 { &hf_capwap_msg_element_type_ac_information_type,
1774                 { "AC Information Type",        "capwap.control.message_element.ac_information.type",
1775                         FT_UINT16, BASE_DEC, VALS(ac_information_type_vals), 0x00,
1776                         NULL, HFILL }},
1777                 { &hf_capwap_msg_element_type_ac_information_length,
1778                 { "AC Information Length",      "capwap.control.message_element.ac_information.length",
1779                         FT_UINT16, BASE_DEC, NULL, 0x0,
1780                         NULL, HFILL }},
1781
1782                 { &hf_capwap_msg_element_type_ac_information_value,
1783                 { "AC Information Value",       "capwap.control.message_element.ac_information.value",
1784                         FT_BYTES, BASE_NONE, NULL, 0x0,
1785                         NULL, HFILL }},
1786                 { &hf_capwap_msg_element_type_ac_information_hardware_version,
1787                 { "AC Hardware Version",        "capwap.control.message_element.ac_information.hardware_version",
1788                         FT_STRING, BASE_NONE, NULL, 0x0,
1789                         NULL, HFILL }},
1790                 { &hf_capwap_msg_element_type_ac_information_software_version,
1791                 { "AC Software Version",        "capwap.control.message_element.ac_information.software_version",
1792                         FT_STRING, BASE_NONE, NULL, 0x0,
1793                         NULL, HFILL }},
1794                 { &hf_capwap_msg_element_type_ac_ipv4_list,
1795                 { "AC IPv4 List",       "capwap.control.message_element.message_element.ac_ipv4_list",
1796                         FT_IPv4, BASE_NONE, NULL, 0x00,
1797                         NULL, HFILL }},
1798                 { &hf_capwap_msg_element_type_ac_ipv6_list,
1799                 { "AC IPv6 List",       "capwap.control.message_element.message_element.ac_ipv6_list",
1800                         FT_IPv6, BASE_NONE, NULL, 0x00,
1801                         NULL, HFILL }},
1802                 /* CAPWAP Control IPvX Address*/
1803                 { &hf_capwap_msg_element_type_capwap_control_ipv4,
1804                 { "CAPWAP Control IP Address",  "capwap.control.message_element.message_element.capwap_control_ipv4",
1805                         FT_IPv4, BASE_NONE, NULL, 0x00,
1806                         NULL, HFILL }},
1807                 { &hf_capwap_msg_element_type_capwap_control_ipv6,
1808                 { "CAPWAP Control IP Address",  "capwap.control.message_element.message_element.capwap_control_ipv6",
1809                         FT_IPv6, BASE_NONE, NULL, 0x00,
1810                         NULL, HFILL }},
1811                 { &hf_capwap_msg_element_type_capwap_control_wtp_count,
1812                 { "CAPWAP Control WTP Count",   "capwap.control.message_element.capwap_control_wtp_count",
1813                         FT_UINT16, BASE_DEC, NULL, 0x00,
1814                         NULL, HFILL }},
1815                 { &hf_capwap_msg_element_type_capwap_timers_discovery,
1816                 { "CAPWAP Timers Discovery (Sec)",      "capwap.control.message_element.capwap_timers_discovery",
1817                         FT_UINT8, BASE_DEC, NULL, 0x00,
1818                         NULL, HFILL }},
1819                 { &hf_capwap_msg_element_type_capwap_timers_echo_request,
1820                 { "CAPWAP Timers Echo Request (Sec)",   "capwap.control.message_element.capwap_timers_echo_request",
1821                         FT_UINT8, BASE_DEC, NULL, 0x00,
1822                         NULL, HFILL }},
1823                 { &hf_capwap_msg_element_type_decryption_error_report_period_radio_id,
1824                 { "Decryption Error Report Period Radio ID",    "capwap.control.message_element.decryption_error_report_period.radio_id",
1825                         FT_UINT8, BASE_DEC, NULL, 0x00,
1826                         NULL, HFILL }},
1827                 { &hf_capwap_msg_element_type_decryption_error_report_period_interval,
1828                 { "Decryption Error Report Report Interval (Sec)",      "capwap.control.message_element.decryption_error_report_period.interval",
1829                         FT_UINT16, BASE_DEC, NULL, 0x00,
1830                         NULL, HFILL }},
1831                 { &hf_capwap_msg_element_type_ac_name,
1832                 { "AC Name",    "capwap.control.message_element.ac_name",
1833                         FT_STRING, BASE_NONE, NULL, 0x00,
1834                         NULL, HFILL }},
1835                 { &hf_capwap_msg_element_type_ac_name_with_priority,
1836                 { "AC Name Priority",   "capwap.control.message_element.ac_name_with_priority",
1837                         FT_UINT8, BASE_DEC, NULL, 0x00,
1838                         NULL, HFILL }},
1839
1840                 { &hf_capwap_msg_element_type_discovery_type,
1841                 { "Discovery Type",     "capwap.control.message_element.discovery_type",
1842                         FT_UINT8, BASE_DEC, VALS(discovery_type_vals), 0x00,
1843                         NULL, HFILL }},
1844
1845                 { &hf_capwap_msg_element_type_idle_timeout,
1846                 { "Idle Timeout (Sec)", "capwap.control.message_element.idle_timeout",
1847                         FT_UINT32, BASE_DEC, NULL, 0x00,
1848                         NULL, HFILL }},
1849                 { &hf_capwap_msg_element_type_location_data,
1850                 { "Location Data",      "capwap.control.message_element.location_data",
1851                         FT_STRING, BASE_NONE, NULL, 0x00,
1852                         NULL, HFILL }},
1853                 { &hf_capwap_msg_element_type_maximum_message_length,
1854                 { "Maximum Message Length",     "capwap.control.message_element.maximum_message_length",
1855                         FT_UINT16, BASE_DEC, NULL, 0x00,
1856                         NULL, HFILL }},
1857
1858                 { &hf_capwap_msg_element_type_radio_admin_id,
1859                 { "Radio Administrative ID",    "capwap.control.message_element.radio_admin.id",
1860                         FT_UINT8, BASE_DEC, NULL, 0x00,
1861                         NULL, HFILL }},
1862                 { &hf_capwap_msg_element_type_radio_admin_state,
1863                 { "Radio Administrative State", "capwap.control.message_element.radio_admin.state",
1864                         FT_UINT8, BASE_DEC, VALS(radio_admin_state_vals), 0x00,
1865                         NULL, HFILL }},
1866                 { &hf_capwap_msg_element_type_radio_op_state_radio_id,
1867                 { "Radio Operational ID",       "capwap.control.message_element.radio_op_state.radio_id",
1868                         FT_UINT8, BASE_DEC, NULL, 0x00,
1869                         NULL, HFILL }},
1870                 { &hf_capwap_msg_element_type_radio_op_state_radio_state,
1871                 { "Radio Operational State",    "capwap.control.message_element.radio_op_state.radio_state",
1872                         FT_UINT8, BASE_DEC, VALS(radio_op_state_vals), 0x00,
1873                         NULL, HFILL }},
1874                 { &hf_capwap_msg_element_type_radio_op_state_radio_cause,
1875                 { "Radio Operational Cause",    "capwap.control.message_element.radio_op_state.radio_cause",
1876                         FT_UINT8, BASE_DEC, VALS(radio_op_cause_vals), 0x00,
1877                         NULL, HFILL }},
1878                 { &hf_capwap_msg_element_type_result_code,
1879                 { "Result Code",        "capwap.control.message_element.result_code",
1880                         FT_UINT32, BASE_DEC, VALS(result_code_vals), 0x00,
1881                         NULL, HFILL }},
1882                 { &hf_capwap_msg_element_type_session_id,
1883                 { "Session ID", "capwap.control.message_element.session_id",
1884                         FT_BYTES, BASE_NONE, NULL, 0x00,
1885                         NULL, HFILL }},
1886                 { &hf_capwap_msg_element_type_statistics_timer,
1887                 { "Statistics Timer (Sec)",     "capwap.control.message_element.statistics_timer",
1888                         FT_UINT16, BASE_DEC, NULL, 0x00,
1889                         NULL, HFILL }},
1890                 { &hf_capwap_msg_element_type_vsp_vendor_identifier,
1891                 { "Vendor Identifier",  "capwap.control.message_element.vsp.vendor_identifier",
1892                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1893                         NULL, HFILL }},
1894                 { &hf_capwap_msg_element_type_vsp_vendor_element_id,
1895                 { "Vendor Element ID",  "capwap.control.message_element.vsp.vendor_element_id",
1896                         FT_UINT16, BASE_DEC, NULL, 0x00,
1897                         NULL, HFILL }},
1898                 { &hf_capwap_msg_element_type_vsp_vendor_data,
1899                 { "Vendor Data",        "capwap.control.message_element.vsp.vendor_data",
1900                         FT_BYTES, BASE_NONE, NULL, 0x00,
1901                         NULL, HFILL }},
1902
1903                 { &hf_capwap_msg_element_type_wtp_board_data_vendor,
1904                 { "WTP Board Data Vendor",      "capwap.control.message_element.wtp_board_data.vendor",
1905                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1906                         NULL, HFILL }},
1907                 { &hf_capwap_msg_element_type_wtp_board_data_type,
1908                 { "Board Data Type",    "capwap.control.message_element.wtp_board_data.type",
1909                         FT_UINT16, BASE_DEC, VALS(board_data_type_vals), 0x00,
1910                         NULL, HFILL }},
1911                 { &hf_capwap_msg_element_type_wtp_board_data_length,
1912                 { "Board Data Length",  "capwap.control.message_element.wtp_board_data.length",
1913                         FT_UINT16, BASE_DEC, NULL, 0x00,
1914                         NULL, HFILL }},
1915                 { &hf_capwap_msg_element_type_wtp_board_data_value,
1916                 { "Board Data Value",   "capwap.control.message_element.wtp_board_data.value",
1917                         FT_BYTES, BASE_NONE, NULL, 0x00,
1918                         NULL, HFILL }},
1919
1920                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_model_number,
1921                 { "WTP Model Number",   "capwap.control.message_element.wtp_board_data.wtp_model_number",
1922                         FT_STRING, BASE_NONE, NULL, 0x00,
1923                         NULL, HFILL }},
1924                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_serial_number,
1925                 { "WTP Serial Number",  "capwap.control.message_element.wtp_board_data.wtp_serial_number",
1926                         FT_STRING, BASE_NONE, NULL, 0x00,
1927                         NULL, HFILL }},
1928                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_board_id,
1929                 { "WTP Board ID",       "capwap.control.message_element.wtp_board_data.wtp_board_id",
1930                         FT_STRING, BASE_NONE, NULL, 0x0,
1931                         NULL, HFILL }},
1932                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_board_revision,
1933                 { "WTP Board Revision", "capwap.control.message_element.wtp_board_data.wtp_board_revision",
1934                         FT_STRING, BASE_NONE, NULL, 0x0,
1935                         NULL, HFILL }},
1936                 { &hf_capwap_msg_element_type_wtp_board_data_base_mac_address,
1937                 { "Base Mac Address",   "capwap.control.message_element.wtp_board_data.base_mac_address",
1938                         FT_ETHER, BASE_NONE, NULL, 0x0,
1939                         NULL, HFILL }},
1940
1941                 { &hf_capwap_msg_element_type_wtp_descriptor_max_radios,
1942                 { "Max Radios", "capwap.control.message_element.wtp_descriptor.max_radios",
1943                         FT_UINT8, BASE_DEC, NULL, 0x00,
1944                         NULL, HFILL }},
1945                 { &hf_capwap_msg_element_type_wtp_descriptor_radio_in_use,
1946                 { "Radio in use",       "capwap.control.message_element.wtp_descriptor.radio_in_use",
1947                         FT_UINT8, BASE_DEC, NULL, 0x00,
1948                         NULL, HFILL }},
1949                 { &hf_capwap_msg_element_type_wtp_descriptor_number_encrypt,
1950                 { "Encryption Capabilities (Number)",   "capwap.control.message_element.wtp_descriptor.number_encrypt",
1951                         FT_UINT8, BASE_DEC, NULL, 0x00,
1952                         NULL, HFILL }},
1953                 { &hf_capwap_msg_element_type_wtp_descriptor_encrypt_reserved,
1954                 { "Reserved (Encrypt)", "capwap.control.message_element.wtp_descriptor.encrypt_reserved",
1955                         FT_UINT8, BASE_DEC, NULL, 0x00,
1956                         NULL, HFILL }},
1957                 { &hf_capwap_msg_element_type_wtp_descriptor_encrypt_wbid,
1958                 { "Encrypt WBID",       "capwap.control.message_element.wtp_descriptor.encrypt_wbid",
1959                         FT_UINT8, BASE_DEC, VALS(type_wbid), 0x00,
1960                         NULL, HFILL }},
1961                 { &hf_capwap_msg_element_type_wtp_descriptor_encrypt_capabilities,
1962                 { "Encryption Capabilities",    "capwap.control.message_element.wtp_descriptor.encrypt_capabilities",
1963                         FT_UINT16, BASE_DEC, NULL, 0x00,
1964                         NULL, HFILL }},
1965                 { &hf_capwap_msg_element_type_wtp_descriptor_vendor,
1966                 { "WTP Descriptor Vendor",      "capwap.control.message_element.wtp_descriptor.vendor",
1967                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1968                         NULL, HFILL }},
1969                 { &hf_capwap_msg_element_type_wtp_descriptor_type,
1970                 { "Descriptor Type",    "capwap.control.message_element.wtp_descriptor.type",
1971                         FT_UINT16, BASE_DEC, VALS(wtp_descriptor_type_vals), 0x0,
1972                         NULL, HFILL }},
1973                 { &hf_capwap_msg_element_type_wtp_descriptor_length,
1974                 { "Descriptor Length",  "capwap.control.message_element.wtp_descriptor.length",
1975                         FT_UINT16, BASE_DEC, NULL, 0x0,
1976                         NULL, HFILL }},
1977                 { &hf_capwap_msg_element_type_wtp_descriptor_value,
1978                 { "Descriptor Value",   "capwap.control.message_element.wtp_descriptor.value",
1979                         FT_BYTES, BASE_NONE, NULL, 0x0,
1980                         NULL, HFILL }},
1981                 { &hf_capwap_msg_element_type_wtp_descriptor_hardware_version,
1982                 { "WTP Hardware Version",       "capwap.control.message_element.wtp_descriptor.hardware_version",
1983                         FT_STRING, BASE_NONE, NULL, 0x0,
1984                         NULL, HFILL }},
1985                 { &hf_capwap_msg_element_type_wtp_descriptor_active_software_version,
1986                 { "WTP Active Software Version",        "capwap.control.message_element.wtp_descriptor.active_software_version",
1987                         FT_STRING, BASE_NONE, NULL, 0x0,
1988                         NULL, HFILL }},
1989                 { &hf_capwap_msg_element_type_wtp_descriptor_boot_version,
1990                 { "WTP Boot Version",   "capwap.control.message_element.wtp_descriptor.boot_version",
1991                         FT_STRING, BASE_NONE, NULL, 0x0,
1992                         NULL, HFILL }},
1993                 { &hf_capwap_msg_element_type_wtp_descriptor_other_software_version,
1994                 { "WTP Other Software Version", "capwap.control.message_element.wtp_descriptor.other_software_version",
1995                         FT_STRING, BASE_NONE, NULL, 0x0,
1996                         NULL, HFILL }},
1997                 { &hf_capwap_msg_element_type_wtp_fallback,
1998                 { "WTP Fallback",       "capwap.control.message_element.wtp_fallback",
1999                         FT_UINT8, BASE_DEC, VALS(wtp_fallback_vals), 0x0,
2000                         NULL, HFILL }},
2001
2002                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode,
2003                 { "WTP Frame Tunnel Mode",      "capwap.control.message_element.wtp_frame_tunnel_mode",
2004                         FT_NONE, BASE_NONE, NULL, 0x0,
2005                         NULL, HFILL }},
2006                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_n,
2007                 { "Native Frame Tunnel Mode",   "capwap.control.message_element.wtp_frame_tunnel_mode.n",
2008                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x08,
2009                         NULL, HFILL }},
2010                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_e,
2011                 { "802.3 Frame Tunnel Mode",    "capwap.control.message_element.wtp_frame_tunnel_mode.e",
2012                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x04,
2013                         NULL, HFILL }},
2014                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_l,
2015                 { "Local Bridging",     "capwap.control.message_element.wtp_frame_tunnel_mode.l",
2016                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
2017                         NULL, HFILL }},
2018                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_r,
2019                 { "Reserved",   "capwap.control.message_element.wtp_frame_tunnel_mode.r",
2020                         FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0xF1,
2021                         NULL, HFILL }},
2022
2023                 { &hf_capwap_msg_element_type_wtp_mac_type,
2024                         { "WTP MAC Type",           "capwap.control.message_element.wtp_mac_type",
2025                         FT_UINT8, BASE_DEC, VALS(wtp_mac_vals), 0x0,
2026                         "The MAC mode of operation supported by the WTP", HFILL }},
2027                 { &hf_capwap_msg_element_type_wtp_name,
2028                         { "WTP Name",           "capwap.control.message_element.wtp_name",
2029                         FT_STRING, BASE_NONE, NULL, 0x0,
2030                         NULL, HFILL }},
2031                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_reboot_count,
2032                         { "Reboot  Count",           "capwap.control.message_element.wtp_reboot_statistics.reboot_count",
2033                         FT_UINT16, BASE_DEC, NULL, 0x0,
2034                         "The number of reboots that have occurred due to a WTP crash", HFILL }},
2035                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_ac_initiated_count,
2036                         { "AC Initiated Count",           "capwap.control.message_element.wtp_reboot_statistics.ac_initiated_count",
2037                         FT_UINT16, BASE_DEC, NULL, 0x0,
2038                         "The number of reboots that have occurred at the request of a CAPWAP protocol message", HFILL }},
2039                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_link_failure_count,
2040                         { "Link Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.link_failure_count",
2041                         FT_UINT16, BASE_DEC, NULL, 0x0,
2042                         "The number of times that a CAPWAP protocol connection with an AC has failed due to link failure", HFILL }},
2043                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_sw_failure_count,
2044                         { "SW Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.sw_failure_count",
2045                         FT_UINT16, BASE_DEC, NULL, 0x0,
2046                         "The number of times that a CAPWAP protocol connection with an AC has failed due to software-related reasons", HFILL }},
2047                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_hw_failure_count,
2048                         { "HW Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.hw_failure_count",
2049                         FT_UINT16, BASE_DEC, NULL, 0x0,
2050                         "The number of times that a CAPWAP protocol connection with an AC has failed due to hardware-related reasons", HFILL }},
2051                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_other_failure_count,
2052                         { "Other Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.other_failure_count",
2053                         FT_UINT16, BASE_DEC, NULL, 0x0,
2054                         "The number of times that a CAPWAP protocol connection with an AC has failed due to known reasons, other than AC initiated, link, SW or HW failure", HFILL }},
2055                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_unknown_failure_count,
2056                         { "Unknown Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.unknown_failure_count",
2057                         FT_UINT16, BASE_DEC, NULL, 0x0,
2058                         "The number of times that a CAPWAP protocol connection with an AC has failed for unknown reasons", HFILL }},
2059                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_last_failure_type,
2060                         { "Last Failure Type",           "capwap.control.message_element.wtp_reboot_statistics.last_failure_type",
2061                         FT_UINT8, BASE_DEC, VALS(last_failure_type_vals), 0x0,
2062                         "The failure type of the most recent WTP failure", HFILL }},
2063
2064                 { &hf_capwap_msg_element_type_ieee80211_rate_set_radio_id,
2065                         { "Radio ID",           "capwap.control.message_element.ieee80211_rate_set.radio_id",
2066                         FT_UINT8, BASE_DEC, NULL, 0x0,
2067                         NULL, HFILL }},
2068                 { &hf_capwap_msg_element_type_ieee80211_rate_set_rate_set,
2069                         { "Rate Set",           "capwap.control.message_element.ieee80211_rate_set.rate_set",
2070                         FT_BYTES, BASE_NONE, NULL, 0x0,
2071                         NULL, HFILL }},
2072                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_mac,
2073                         { "Mac Address",           "capwap.control.message_element.ieee80211_station_session_key.mac",
2074                         FT_ETHER, BASE_NONE, NULL, 0x0,
2075                         "The station's MAC Address", HFILL }},
2076                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_flags,
2077                         { "Flags",           "capwap.control.message_element.ieee80211_station_session_key.flags",
2078                         FT_UINT16, BASE_DEC, NULL, 0x3FFF,
2079                         NULL, HFILL }},
2080                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_flags_a,
2081                         { "Flag A",           "capwap.control.message_element.ieee80211_station_session_key.flags_a",
2082                         FT_BOOLEAN, 1, NULL, 0x2000,
2083                         NULL, HFILL }},
2084                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_flags_c,
2085                         { "Flag C",           "capwap.control.message_element.ieee80211_station_session_key.flags_c",
2086                         FT_BOOLEAN, 1, NULL, 0x1000,
2087                         NULL, HFILL }},
2088                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_tsc,
2089                         { "Pairwise TSC",           "capwap.control.message_element.ieee80211_station_session_key.pairwire_tsc",
2090                         FT_BYTES, BASE_NONE, NULL, 0x0,
2091                         "Transmit Sequence Counter (TSC)", HFILL }},
2092                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_rsc,
2093                         { "Pairwise RSC",           "capwap.control.message_element.ieee80211_station_session_key.pairwire_rsc",
2094                         FT_BYTES, BASE_NONE, NULL, 0x0,
2095                         "Receive Sequence Counter (TSC)", HFILL }},
2096                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_key,
2097                         { "Key",           "capwap.control.message_element.ieee80211_station_session_key.key",
2098                         FT_BYTES, BASE_NONE, NULL, 0x0,
2099                         NULL, HFILL }},
2100                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_id,
2101                         { "Radio ID",           "capwap.control.message_element.ieee80211__wtp_radio_info.radio_id",
2102                         FT_UINT8, BASE_DEC, NULL, 0x0,
2103                         NULL, HFILL }},
2104                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_reserved,
2105                         { "Radio Type Reserved",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_reserved",
2106                         FT_BYTES, BASE_NONE, NULL, 0x0,
2107                         NULL, HFILL }},
2108                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_n,
2109                         { "Radio Type 802.11n",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_n",
2110                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0008,
2111                         NULL, HFILL }},
2112                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_g,
2113                         { "Radio Type 802.11g",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_g",
2114                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0004,
2115                         NULL, HFILL }},
2116                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_a,
2117                         { "Radio Type 802.11a",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_a",
2118                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0002,
2119                         NULL, HFILL }},
2120                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_b,
2121                         { "Radio Type 802.11g",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_b",
2122                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0001,
2123                         NULL, HFILL }},
2124
2125                 /* Fragment entries */
2126                 { &hf_msg_fragments,
2127                         { "Message fragments", "capwap.fragments", FT_NONE, BASE_NONE,
2128                         NULL, 0x00, NULL, HFILL } },
2129                 { &hf_msg_fragment,
2130                         { "Message fragment", "capwap.fragment", FT_FRAMENUM, BASE_NONE,
2131                         NULL, 0x00, NULL, HFILL } },
2132                 { &hf_msg_fragment_overlap,
2133                         { "Message fragment overlap", "capwap.fragment.overlap", FT_BOOLEAN,
2134                         BASE_NONE, NULL, 0x00, NULL, HFILL } },
2135                 { &hf_msg_fragment_overlap_conflicts,
2136                         { "Message fragment overlapping with conflicting data",
2137                         "capwap.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL,
2138                         0x00, NULL, HFILL } },
2139                 { &hf_msg_fragment_multiple_tails,
2140                         { "Message has multiple tail fragments",
2141                         "capwap.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
2142                         NULL, 0x00, NULL, HFILL } },
2143                 { &hf_msg_fragment_too_long_fragment,
2144                         { "Message fragment too long", "capwap.fragment.too_long_fragment",
2145                         FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
2146                 { &hf_msg_fragment_error,
2147                         { "Message defragmentation error", "capwap.fragment.error", FT_FRAMENUM,
2148                         BASE_NONE, NULL, 0x00, NULL, HFILL } },
2149                 { &hf_msg_fragment_count,
2150                         { "Message fragment count", "capwap.fragment.count", FT_UINT32, BASE_DEC,
2151                         NULL, 0x00, NULL, HFILL } },
2152                 { &hf_msg_reassembled_in,
2153                         { "Reassembled in", "capwap.reassembled.in", FT_FRAMENUM, BASE_NONE,
2154                         NULL, 0x00, NULL, HFILL } },
2155                 { &hf_msg_reassembled_length,
2156                         { "Reassembled CAPWAP length", "capwap.reassembled.length", FT_UINT32, BASE_DEC,
2157                         NULL, 0x00, NULL, HFILL } }
2158         };
2159
2160         /* Setup protocol subtree array */
2161         static gint *ett[] = {
2162                 &ett_capwap,
2163                 &ett_msg_fragment,
2164                 &ett_msg_fragments
2165         };
2166
2167         /* Register the protocol name and description */
2168         proto_capwap = proto_register_protocol("Control And Provisioning of Wireless Access Points", "CAPWAP", "capwap");
2169
2170         /* Required function calls to register the header fields and subtrees used */
2171         proto_register_field_array(proto_capwap, hf, array_length(hf));
2172
2173         proto_register_subtree_array(ett, array_length(ett));
2174
2175         register_init_routine(&capwap_reassemble_init);
2176
2177         /* Register preferences module (See Section 2.6 for more on preferences) */
2178         capwap_module = prefs_register_protocol(proto_capwap, proto_reg_handoff_capwap);
2179
2180         prefs_register_uint_preference(capwap_module, "udp.port.control", "CAPWAP Control UDP Port",
2181              "Set the port for CAPWAP Control messages (if other than the default of 5246)",
2182              10, &global_capwap_control_udp_port);
2183
2184         prefs_register_uint_preference(capwap_module, "udp.port.data", "CAPWAP Data UDP Port",
2185              "Set the port for CAPWAP Data messages (if other than the default of 5247)",
2186              10, &global_capwap_data_udp_port);
2187
2188         prefs_register_bool_preference(capwap_module, "draft_8_cisco", "Cisco Wireless Controller Support",
2189              "Enable support of Cisco Wireless Controller (based on old 8 draft revision).",
2190              &global_capwap_draft_8_cisco);
2191
2192         prefs_register_bool_preference(capwap_module, "reassemble", "Reassemble fragmented CAPWAP packets",
2193              "Reassemble fragmented CAPWAP packets.",
2194              &global_capwap_reassemble);
2195
2196         prefs_register_bool_preference(capwap_module, "swap_fc", "Swap Frame Control",
2197              "Swap frame control bytes (needed for some APs).",
2198              &global_capwap_swap_frame_control);
2199
2200 }
2201
2202 void
2203 proto_reg_handoff_capwap(void)
2204 {
2205         static gboolean inited = FALSE;
2206         static dissector_handle_t capwap_control_handle, capwap_data_handle;
2207         static guint capwap_control_udp_port, capwap_data_udp_port;
2208
2209         if (!inited) {
2210                 capwap_control_handle = create_dissector_handle(dissect_capwap_control, proto_capwap);
2211                 capwap_data_handle    = create_dissector_handle(dissect_capwap_data, proto_capwap);
2212                 dtls_handle           = find_dissector("dtls");
2213                 ieee8023_handle       = find_dissector("eth_withoutfcs");
2214                 ieee80211_handle      = find_dissector("wlan");
2215                 ieee80211_bsfc_handle = find_dissector("wlan_bsfc");
2216                 data_handle           = find_dissector("data");
2217
2218                 inited = TRUE;
2219         } else {
2220                 dissector_delete_uint("udp.port", capwap_control_udp_port, capwap_control_handle);
2221                 dissector_delete_uint("udp.port", capwap_data_udp_port, capwap_data_handle);
2222         }
2223         dissector_add_uint("udp.port", global_capwap_control_udp_port, capwap_control_handle);
2224         dissector_add_uint("udp.port", global_capwap_data_udp_port, capwap_data_handle);
2225
2226         capwap_control_udp_port = global_capwap_control_udp_port;
2227         capwap_data_udp_port    = global_capwap_data_udp_port;
2228 }
2229