Higlight the Header bytes.
[metze/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 #include "config.h"
27
28 #include <glib.h>
29
30 #include <epan/packet.h>
31 #include <epan/prefs.h>
32 #include <epan/reassemble.h>
33
34 #include <epan/sminmpec.h>
35
36 #define UDP_PORT_CAPWAP_CONTROL 5246
37 #define UDP_PORT_CAPWAP_DATA 5247
38
39 static guint global_capwap_control_udp_port = UDP_PORT_CAPWAP_CONTROL;
40 static guint global_capwap_data_udp_port = UDP_PORT_CAPWAP_DATA;
41 static gboolean global_capwap_draft_8_cisco = FALSE;
42 static gboolean global_capwap_reassemble = TRUE;
43 static gboolean global_capwap_swap_frame_control = TRUE;
44
45 static GHashTable *capwap_fragment_table = NULL;
46 static GHashTable *capwap_reassembled_table = NULL;
47
48 /* TODO LIST !
49 * add decryption of DLTS Message
50 * add support of all Messages Element Type
51 */
52
53 /* Forward declaration we need below */
54 void proto_reg_handoff_capwap(void);
55
56 /* Initialize the protocol and registered fields */
57 static int proto_capwap = -1;
58
59 static int hf_capwap_preamble = -1;
60 static int hf_capwap_preamble_version = -1;
61 static int hf_capwap_preamble_type = -1;
62 static int hf_capwap_preamble_reserved = -1;
63
64 static int hf_capwap_header = -1;
65 static int hf_capwap_header_hlen = -1;
66 static int hf_capwap_header_rid = -1;
67 static int hf_capwap_header_wbid = -1;
68
69 static int hf_capwap_header_flags = -1;
70 static int hf_capwap_header_flags_t = -1;
71 static int hf_capwap_header_flags_f = -1;
72 static int hf_capwap_header_flags_l = -1;
73 static int hf_capwap_header_flags_w = -1;
74 static int hf_capwap_header_flags_m = -1;
75 static int hf_capwap_header_flags_k = -1;
76 static int hf_capwap_header_flags_r = -1;
77
78 static int hf_capwap_header_fragment_id = -1;
79 static int hf_capwap_header_fragment_offset = -1;
80 static int hf_capwap_header_reserved = -1;
81
82 static int hf_capwap_header_mac_length = -1;
83 static int hf_capwap_header_mac_eui48 = -1;
84 static int hf_capwap_header_mac_eui64 = -1;
85 static int hf_capwap_header_mac_data = -1;
86
87 static int hf_capwap_header_wireless_length = -1;
88 static int hf_capwap_header_wireless_data = -1;
89
90 static int hf_capwap_header_wireless_data_ieee80211_fi = -1;
91 static int hf_capwap_header_wireless_data_ieee80211_fi_rssi = -1;
92 static int hf_capwap_header_wireless_data_ieee80211_fi_snr = -1;
93 static int hf_capwap_header_wireless_data_ieee80211_fi_data_rate = -1;
94 static int hf_capwap_header_wireless_data_ieee80211_dest_wlan = -1;
95 static int hf_capwap_header_wireless_data_ieee80211_dw_wlan_id_bitmap = -1;
96 static int hf_capwap_header_wireless_data_ieee80211_dw_reserved = -1;
97 static int hf_capwap_header_padding = -1;
98
99 static int hf_capwap_control_header = -1;
100 static int hf_capwap_control_header_msg_type = -1;
101 static int hf_capwap_control_header_msg_type_enterprise_nbr = -1;
102 static int hf_capwap_control_header_msg_type_enterprise_specific = -1;
103 static int hf_capwap_control_header_seq_number = -1;
104 static int hf_capwap_control_header_flags = -1;
105 static int hf_capwap_control_header_msg_element_length = -1;
106
107 static int hf_capwap_message_element = -1;
108 static int hf_capwap_msg_element_type = -1;
109 static int hf_capwap_msg_element_length = -1;
110 static int hf_capwap_msg_element_value = -1;
111
112 static int hf_capwap_msg_element_type_ac_descriptor_stations = -1;
113 static int hf_capwap_msg_element_type_ac_descriptor_limit = -1;
114 static int hf_capwap_msg_element_type_ac_descriptor_active_wtp = -1;
115 static int hf_capwap_msg_element_type_ac_descriptor_max_wtp = -1;
116 /* AC Descriptor Security Flags... */
117 static int hf_capwap_msg_element_type_ac_descriptor_security = -1;
118 static int hf_capwap_msg_element_type_ac_descriptor_security_s = -1;
119 static int hf_capwap_msg_element_type_ac_descriptor_security_x = -1;
120 static int hf_capwap_msg_element_type_ac_descriptor_security_r = -1;
121 static int hf_capwap_msg_element_type_ac_descriptor_rmac_field = -1;
122 static int hf_capwap_msg_element_type_ac_descriptor_reserved = -1;
123 /* AC Descriptor DTLS Policy Flags... */
124 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy = -1;
125 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy_d = -1;
126 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy_c = -1;
127 static int hf_capwap_msg_element_type_ac_descriptor_dtls_policy_r = -1;
128
129 static int hf_capwap_msg_element_type_ac_information_vendor = -1;
130 static int hf_capwap_msg_element_type_ac_information_type = -1;
131 static int hf_capwap_msg_element_type_ac_information_length = -1;
132 static int hf_capwap_msg_element_type_ac_information_value = -1;
133 static int hf_capwap_msg_element_type_ac_information_hardware_version = -1;
134 static int hf_capwap_msg_element_type_ac_information_software_version = -1;
135
136 static int hf_capwap_msg_element_type_ac_name = -1;
137 static int hf_capwap_msg_element_type_ac_name_with_priority = -1;
138
139 static int hf_capwap_msg_element_type_ac_ipv4_list = -1;
140 static int hf_capwap_msg_element_type_ac_ipv6_list = -1;
141
142 static int hf_capwap_msg_element_type_capwap_control_ipv4 = -1;
143 static int hf_capwap_msg_element_type_capwap_control_ipv6 = -1;
144 static int hf_capwap_msg_element_type_capwap_control_wtp_count = -1;
145
146 static int hf_capwap_msg_element_type_capwap_timers_discovery = -1;
147 static int hf_capwap_msg_element_type_capwap_timers_echo_request = -1;
148
149 static int hf_capwap_msg_element_type_decryption_error_report_period_radio_id = -1;
150 static int hf_capwap_msg_element_type_decryption_error_report_period_interval = -1;
151
152 static int hf_capwap_msg_element_type_discovery_type = -1;
153
154 static int hf_capwap_msg_element_type_location_data = -1;
155
156 static int hf_capwap_msg_element_type_maximum_message_length = -1;
157
158 static int hf_capwap_msg_element_type_idle_timeout = -1;
159 static int hf_capwap_msg_element_type_radio_admin_id = -1;
160 static int hf_capwap_msg_element_type_radio_admin_state = -1;
161
162 static int hf_capwap_msg_element_type_radio_op_state_radio_id = -1;
163 static int hf_capwap_msg_element_type_radio_op_state_radio_state = -1;
164 static int hf_capwap_msg_element_type_radio_op_state_radio_cause = -1;
165 static int hf_capwap_msg_element_type_result_code = -1;
166
167 static int hf_capwap_msg_element_type_session_id = -1;
168
169 static int hf_capwap_msg_element_type_statistics_timer = -1;
170
171 static int hf_capwap_msg_element_type_vsp_vendor_identifier = -1;
172 static int hf_capwap_msg_element_type_vsp_vendor_element_id = -1;
173 static int hf_capwap_msg_element_type_vsp_vendor_data = -1;
174
175 static int hf_capwap_msg_element_type_wtp_board_data_vendor = -1;
176 static int hf_capwap_msg_element_type_wtp_board_data_type = -1;
177 static int hf_capwap_msg_element_type_wtp_board_data_length = -1;
178 static int hf_capwap_msg_element_type_wtp_board_data_value = -1;
179 static int hf_capwap_msg_element_type_wtp_board_data_wtp_model_number  = -1;
180 static int hf_capwap_msg_element_type_wtp_board_data_wtp_serial_number  = -1;
181 static int hf_capwap_msg_element_type_wtp_board_data_wtp_board_id  = -1;
182 static int hf_capwap_msg_element_type_wtp_board_data_wtp_board_revision  = -1;
183 static int hf_capwap_msg_element_type_wtp_board_data_base_mac_address  = -1;
184
185 static int hf_capwap_msg_element_type_wtp_descriptor_max_radios = -1;
186 static int hf_capwap_msg_element_type_wtp_descriptor_radio_in_use = -1;
187 static int hf_capwap_msg_element_type_wtp_descriptor_number_encrypt = -1;
188 static int hf_capwap_msg_element_type_wtp_descriptor_encrypt_reserved = -1;
189 static int hf_capwap_msg_element_type_wtp_descriptor_encrypt_wbid = -1;
190 static int hf_capwap_msg_element_type_wtp_descriptor_encrypt_capabilities = -1;
191 static int hf_capwap_msg_element_type_wtp_descriptor_vendor = -1;
192 static int hf_capwap_msg_element_type_wtp_descriptor_type = -1;
193 static int hf_capwap_msg_element_type_wtp_descriptor_length = -1;
194 static int hf_capwap_msg_element_type_wtp_descriptor_value = -1;
195 static int hf_capwap_msg_element_type_wtp_descriptor_hardware_version = -1;
196 static int hf_capwap_msg_element_type_wtp_descriptor_active_software_version = -1;
197 static int hf_capwap_msg_element_type_wtp_descriptor_boot_version = -1;
198 static int hf_capwap_msg_element_type_wtp_descriptor_other_software_version = -1;
199
200 static int hf_capwap_msg_element_type_wtp_fallback = -1;
201 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode = -1;
202 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_n = -1;
203 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_e = -1;
204 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_l = -1;
205 static int hf_capwap_msg_element_type_wtp_frame_tunnel_mode_r = -1;
206
207 static int hf_capwap_msg_element_type_wtp_mac_type = -1;
208
209 static int hf_capwap_msg_element_type_wtp_name = -1;
210
211 static int hf_capwap_msg_element_type_wtp_reboot_statistics_reboot_count = -1;
212 static int hf_capwap_msg_element_type_wtp_reboot_statistics_ac_initiated_count = -1;
213 static int hf_capwap_msg_element_type_wtp_reboot_statistics_link_failure_count = -1;
214 static int hf_capwap_msg_element_type_wtp_reboot_statistics_sw_failure_count = -1;
215 static int hf_capwap_msg_element_type_wtp_reboot_statistics_hw_failure_count = -1;
216 static int hf_capwap_msg_element_type_wtp_reboot_statistics_other_failure_count = -1;
217 static int hf_capwap_msg_element_type_wtp_reboot_statistics_unknown_failure_count = -1;
218 static int hf_capwap_msg_element_type_wtp_reboot_statistics_last_failure_type = -1;
219
220 static int hf_capwap_msg_element_type_ieee80211_rate_set_radio_id = -1;
221 static int hf_capwap_msg_element_type_ieee80211_rate_set_rate_set = -1;
222
223 static int hf_capwap_msg_element_type_ieee80211_station_session_key_mac = -1;
224 static int hf_capwap_msg_element_type_ieee80211_station_session_key_flags = -1;
225 static int hf_capwap_msg_element_type_ieee80211_station_session_key_flags_a = -1;
226 static int hf_capwap_msg_element_type_ieee80211_station_session_key_flags_c = -1;
227 static int hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_tsc = -1;
228 static int hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_rsc = -1;
229 static int hf_capwap_msg_element_type_ieee80211_station_session_key_key = -1;
230
231 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_id = -1;
232 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_reserved = -1;
233 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_n = -1;
234 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_g = -1;
235 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_a = -1;
236 static int hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_b = -1;
237
238 static int hf_msg_fragments = -1;
239 static int hf_msg_fragment = -1;
240 static int hf_msg_fragment_overlap = -1;
241 static int hf_msg_fragment_overlap_conflicts = -1;
242 static int hf_msg_fragment_multiple_tails = -1;
243 static int hf_msg_fragment_too_long_fragment = -1;
244 static int hf_msg_fragment_error = -1;
245 static int hf_msg_fragment_count = -1;
246 static int hf_msg_reassembled_in = -1;
247 static int hf_msg_reassembled_length = -1;
248
249 static dissector_handle_t dtls_handle;
250 static dissector_handle_t ieee8023_handle;
251 static dissector_handle_t ieee80211_handle;
252 static dissector_handle_t ieee80211_bsfc_handle;
253 static dissector_handle_t data_handle;
254
255 /* Initialize the subtree pointers */
256 static gint ett_capwap = -1;
257
258 static gint ett_msg_fragment = -1;
259 static gint ett_msg_fragments = -1;
260
261 /* ************************************************************************* */
262 /*                  Fragment items                                           */
263 /* ************************************************************************* */
264
265 static const fragment_items capwap_frag_items = {
266   /* Fragment subtrees */
267   &ett_msg_fragment,
268   &ett_msg_fragments,
269   /* Fragment fields */
270   &hf_msg_fragments,
271   &hf_msg_fragment,
272   &hf_msg_fragment_overlap,
273   &hf_msg_fragment_overlap_conflicts,
274   &hf_msg_fragment_multiple_tails,
275   &hf_msg_fragment_too_long_fragment,
276   &hf_msg_fragment_error,
277   &hf_msg_fragment_count,
278   /* Reassembled in field */
279   &hf_msg_reassembled_in,
280   /* Reassembled length field */
281   &hf_msg_reassembled_length,
282   /* Reassembled data field */
283   NULL,
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_NA);
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_item(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_item(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_item(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_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_NA);
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_ASCII|ENC_NA);
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_ASCII|ENC_NA);
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_NA);
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         /* RFC 5415  HLEN:  A 5-bit field containing the length of the CAPWAP transport header in 4-byte words */
1207         /* As we display the preamble separately reduce the length by 1 */ 
1208         ti = proto_tree_add_item(capwap_control_tree, hf_capwap_header, tvb, offset+plen, ((tvb_get_bits8(tvb, (offset+plen)*8, 5))*4)-1, ENC_NA);
1209         capwap_header_tree = proto_item_add_subtree(ti, ett_capwap);
1210
1211         /* Header Length : 5 Bits */
1212         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_hlen, tvb, offset+plen, 1, tvb_get_bits8(tvb, (offset+plen)*8, 5));
1213         /* Radio ID : 5 Bits */
1214         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_rid, tvb, offset+plen, 1, tvb_get_bits8(tvb, (offset+plen)*8+5, 5));
1215
1216         /* Wireless Binding ID : 5 Bits */
1217         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_wbid, tvb, offset+plen, 1, tvb_get_bits8(tvb, (offset+plen)*8+10, 5));
1218
1219         /* WBid of Payload (for CAPWAP Data Packet) */
1220         *payload_wbid = tvb_get_bits8(tvb, (offset+plen)*8+10, 5);
1221         plen++;
1222
1223         /* Flags : 9 Bits */
1224         flags = tvb_get_bits16(tvb, (offset+plen)*8+7, 9, ENC_BIG_ENDIAN);
1225         ti_flag = proto_tree_add_uint_format(capwap_header_tree, hf_capwap_header_flags, tvb, offset+plen, 1, 0, "Header flags");
1226         capwap_header_flags_tree = proto_item_add_subtree(ti_flag, ett_capwap);
1227
1228         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_t, tvb, offset+plen, 1, flags);
1229         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_f, tvb, offset+plen, 1, flags);
1230         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_l, tvb, offset+plen, 1, flags);
1231         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_w, tvb, offset+plen, 1, flags);
1232         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_m, tvb, offset+plen, 1, flags);
1233         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_k, tvb, offset+plen, 1, flags);
1234         proto_tree_add_boolean(capwap_header_flags_tree, hf_capwap_header_flags_r, tvb, offset+plen, 1, flags);
1235
1236         /* Fragment ??*/
1237         *fragment_is = ((flags & 0x80) == 0x80) ? TRUE : FALSE;
1238         *fragment_more = ((flags &0x40) == 0x40) ? FALSE : TRUE;
1239
1240         /* Type of Payload (for CAPWAP Data Packet) */
1241         *payload_type = tvb_get_bits8(tvb, (offset+plen)*8+7,1);
1242
1243         plen += 2;
1244
1245         /* Fragment ID : 16 Bits */
1246         proto_tree_add_item(capwap_header_tree, hf_capwap_header_fragment_id, tvb, offset+plen, 2, ENC_BIG_ENDIAN);
1247         *fragment_id = (guint32)tvb_get_ntohs(tvb, offset+plen);
1248         plen += 2;
1249
1250         /* Fragment offset : 13 Bits */
1251         /* FIXME: Use _item and mask in hf element */
1252         proto_tree_add_uint(capwap_header_tree, hf_capwap_header_fragment_offset, tvb, offset+plen, 2, tvb_get_bits16(tvb, (offset+plen)*8, 13, ENC_BIG_ENDIAN));
1253         *fragment_offset = 8 * (guint32)tvb_get_bits16(tvb, (offset+plen)*8, 13, ENC_BIG_ENDIAN);
1254
1255         /* Reserved 3 Bits */
1256         /* FIXME: Use _item and mask in hf element */
1257         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));
1258         plen += 2;
1259         /* Optionnal Headers */
1260         if (flags & 0x10 /* Radio MAC address */) {
1261                 maclength=tvb_get_guint8(tvb, offset+plen);
1262                 proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_length, tvb, offset+plen, 1, ENC_BIG_ENDIAN);
1263                 plen += 1;
1264                 if (maclength == 6) {
1265                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_eui48, tvb, offset+plen, maclength, ENC_NA);
1266
1267                 } else if (maclength == 8) {
1268                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_eui64, tvb, offset+plen, maclength, ENC_BIG_ENDIAN);
1269                 } else {
1270                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_mac_data, tvb, offset+plen, maclength, ENC_NA);
1271                 }
1272                 plen += maclength;
1273                 /* 4 Bytes Alignment ? */
1274                 align = 4-((offset+plen)%4);
1275                 if (align != 4)
1276                 {
1277                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_padding, tvb, offset+plen, align, ENC_NA);
1278                         plen += align;
1279                 }
1280         }
1281         if (flags & 0x20 /* Wireless specific information */) {
1282                 wirelesslength=tvb_get_guint8(tvb, offset+plen);
1283
1284                 /* in Draft 8, the WBid is add in Wireless Specific Information*/
1285                 if (global_capwap_draft_8_cisco == 1)
1286                 {
1287                         plen += 1;
1288                         wirelesslength = 4;
1289                 }
1290                 proto_tree_add_item(capwap_header_tree, hf_capwap_header_wireless_length, tvb, offset+plen, 1, ENC_BIG_ENDIAN);
1291                 plen += 1;
1292                 proto_tree_add_item(capwap_header_tree, hf_capwap_header_wireless_data, tvb, offset+plen, wirelesslength, ENC_NA);
1293
1294                 /* Optional Wireless Specific Information for ieee80211 (wbid = 1) Section 4 of RFC5416 */
1295                 if (*payload_wbid == 1)
1296                 {
1297                         dissect_capwap_data_message_bindings_ieee80211(tvb, capwap_header_tree, offset+plen, pinfo);
1298                 }
1299
1300                 plen += wirelesslength;
1301                 /* 4 Bytes Alignment ? */
1302                 align = 4-((offset+plen)%4);
1303                 if (align != 4)
1304                 {
1305                         proto_tree_add_item(capwap_header_tree, hf_capwap_header_padding, tvb, offset+plen, align, ENC_NA);
1306                         plen += align;
1307                 }
1308         }
1309         return plen;
1310 }
1311
1312 /* Returns the number of bytes consumed by this option. */
1313 static int
1314 dissect_capwap_preamble(tvbuff_t *tvb, proto_tree *capwap_control_tree, guint offset, guint8 *type_header)
1315 {
1316         guint plen = 0;
1317         proto_item *ti;
1318         proto_tree *capwap_preamble_tree;
1319
1320         ti = proto_tree_add_item(capwap_control_tree, hf_capwap_preamble, tvb, offset+plen, -1, ENC_NA);
1321         capwap_preamble_tree = proto_item_add_subtree(ti, ett_capwap);
1322
1323         proto_tree_add_uint(capwap_preamble_tree, hf_capwap_preamble_version, tvb, offset+plen, 1, hi_nibble(tvb_get_guint8(tvb, offset+plen)));
1324         proto_tree_add_uint(capwap_preamble_tree, hf_capwap_preamble_type, tvb, offset+plen, 1, lo_nibble(tvb_get_guint8(tvb, offset+plen)));
1325         *type_header = lo_nibble(tvb_get_guint8(tvb, offset+plen));
1326         plen++;
1327         /* DTLS Header ? */
1328         if (*type_header == 1) {
1329                 proto_tree_add_item(capwap_preamble_tree, hf_capwap_preamble_reserved, tvb, offset+plen, 3, ENC_BIG_ENDIAN);
1330                 plen +=3;
1331         }
1332         proto_item_set_len(ti, plen);
1333         return plen;
1334 }
1335
1336 /* Code to actually dissect the packets */
1337 static int
1338 dissect_capwap_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1339 {
1340         /* Set up structures needed to add the protocol subtree and manage it */
1341         proto_item *ti;
1342         proto_tree *capwap_control_tree;
1343         guint offset = 0;
1344         tvbuff_t *next_tvb = NULL;
1345         guint8 type_header;
1346         guint8 payload_type;
1347         guint8 payload_wbid;
1348         gboolean fragment_is;
1349         gboolean fragment_more;
1350         guint32 fragment_id;
1351         guint32 fragment_offset;
1352         fragment_data *frag_msg = NULL;
1353         gboolean save_fragmented;
1354
1355         /* Make entries in Protocol column and Info column on summary display */
1356         col_set_str(pinfo->cinfo, COL_PROTOCOL, "CAPWAP");
1357         col_set_str(pinfo->cinfo, COL_INFO, "CAPWAP-Control");
1358
1359         ti = proto_tree_add_item(tree, proto_capwap, tvb, 0, -1, ENC_NA);
1360         capwap_control_tree = proto_item_add_subtree(ti, ett_capwap);
1361
1362         /* CAPWAP Preamble */
1363         offset += dissect_capwap_preamble(tvb, capwap_control_tree, offset, &type_header);
1364
1365         if (type_header == 1) {
1366                 next_tvb = tvb_new_subset_remaining (tvb, offset);
1367                 call_dissector(dtls_handle, next_tvb, pinfo, tree);
1368                 return offset;
1369         }
1370
1371         /* CAPWAP Header */
1372         offset += dissect_capwap_header(tvb, capwap_control_tree, offset, pinfo, &payload_type, &payload_wbid, &fragment_is, &fragment_more, &fragment_id, &fragment_offset );
1373
1374         /* CAPWAP Reassemble */
1375         save_fragmented = pinfo->fragmented;
1376
1377         if (global_capwap_reassemble && fragment_is)
1378         {
1379                 const int len_rem = tvb_length_remaining(tvb, offset);
1380                 if (len_rem <= 0)
1381                         return offset;
1382
1383                 pinfo->fragmented = TRUE;
1384
1385                 frag_msg = fragment_add_check(tvb, offset, pinfo,fragment_id,
1386                                               capwap_fragment_table,
1387                                               capwap_reassembled_table,
1388                                               fragment_offset,
1389                                               len_rem,
1390                                               fragment_more);
1391
1392                 next_tvb = process_reassembled_data(tvb, offset, pinfo,
1393                                                     "Reassembled CAPWAP", frag_msg,
1394                                                     &capwap_frag_items, NULL, tree);
1395
1396                 if (next_tvb == NULL)
1397                 { /* make a new subset */
1398                         next_tvb = tvb_new_subset_remaining(tvb, offset);
1399                         call_dissector(data_handle, next_tvb, pinfo, tree);
1400                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Fragment ID: %u, Fragment Offset: %u)", fragment_id, fragment_offset);
1401                 }
1402                 else
1403                 {
1404                         /* CAPWAP Control Header */
1405                         offset = dissect_capwap_control_header(next_tvb, capwap_control_tree, 0, pinfo);
1406
1407                         /* CAPWAP Message Element */
1408                         offset += dissect_capwap_message_element(next_tvb, capwap_control_tree, offset);
1409                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Reassembled, Fragment ID: %u)", fragment_id);
1410                 }
1411         }
1412         else
1413         {
1414                 /* CAPWAP Control Header */
1415                 offset += dissect_capwap_control_header(tvb, capwap_control_tree, offset, pinfo);
1416
1417                 /* CAPWAP Message Element */
1418                 offset += dissect_capwap_message_element(tvb, capwap_control_tree, offset);
1419         }
1420         pinfo->fragmented = save_fragmented;
1421         return offset;
1422 }
1423
1424 /* Code to actually dissect the packets */
1425 static void
1426 dissect_capwap_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1427 {
1428         /* Set up structures needed to add the protocol subtree and manage it */
1429         proto_item *ti;
1430         proto_tree *capwap_data_tree;
1431         guint offset = 0;
1432         tvbuff_t *next_tvb;
1433         guint8 type_header;
1434         guint8 payload_type;
1435         guint8 payload_wbid;
1436         gboolean fragment_is;
1437         gboolean fragment_more;
1438         guint32 fragment_id;
1439         guint32 fragment_offset;
1440         fragment_data *frag_msg = NULL;
1441         gboolean save_fragmented;
1442
1443         /* Make entries in Protocol column and Info column on summary display */
1444         col_set_str(pinfo->cinfo, COL_PROTOCOL, "CAPWAP");
1445         col_set_str(pinfo->cinfo, COL_INFO, "CAPWAP-Data");
1446
1447         ti = proto_tree_add_item(tree, proto_capwap, tvb, 0, -1, ENC_NA);
1448         capwap_data_tree = proto_item_add_subtree(ti, ett_capwap);
1449
1450         /* CAPWAP Preamble */
1451         offset += dissect_capwap_preamble(tvb, capwap_data_tree, offset, &type_header);
1452
1453         if (type_header == 1) {
1454                 next_tvb = tvb_new_subset_remaining (tvb, offset);
1455                 call_dissector(dtls_handle, next_tvb, pinfo, tree);
1456                 return;
1457         }
1458
1459         /* CAPWAP Header */
1460         offset += dissect_capwap_header(tvb, capwap_data_tree, offset, pinfo, &payload_type, &payload_wbid, &fragment_is, &fragment_more, &fragment_id, &fragment_offset);
1461
1462         /* CAPWAP Reassemble */
1463         save_fragmented = pinfo->fragmented;
1464
1465         if (global_capwap_reassemble && fragment_is)
1466         {
1467                 gint len_rem = tvb_length_remaining(tvb, offset);
1468                 if (len_rem <= 0)
1469                         return;
1470
1471                 pinfo->fragmented = TRUE;
1472
1473                 frag_msg = fragment_add_check(tvb, offset, pinfo,fragment_id,
1474                                               capwap_fragment_table,
1475                                               capwap_reassembled_table,
1476                                               fragment_offset,
1477                                               len_rem,
1478                                               fragment_more);
1479
1480                 next_tvb = process_reassembled_data(tvb, offset, pinfo,
1481                                                     "Reassembled CAPWAP", frag_msg,
1482                                                     &capwap_frag_items, NULL, tree);
1483
1484                 if (next_tvb == NULL)
1485                 { /* make a new subset */
1486                         next_tvb = tvb_new_subset_remaining(tvb, offset);
1487                         call_dissector(data_handle,next_tvb, pinfo, tree);
1488                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Fragment ID: %u, Fragment Offset: %u)", fragment_id, fragment_offset);
1489                 }
1490                 else
1491                 {
1492                         col_append_fstr(pinfo->cinfo, COL_INFO, " (Reassembled, Fragment ID: %u)", fragment_id);
1493                 }
1494         }
1495         else
1496         {
1497                 next_tvb = tvb_new_subset_remaining (tvb, offset);
1498         }
1499
1500         /* CAPWAP Data Payload */
1501         if (payload_type == 0) {
1502                 /* IEEE 802.3 Frame */
1503                 call_dissector(ieee8023_handle, next_tvb, pinfo, tree);
1504         } else {
1505                 switch (payload_wbid) {
1506                 case 0: /* Reserved - Cisco seems to use this instead of 1 */
1507                         /* It seems that just calling ieee80211_handle is not
1508                          * quite enough to get this right, so call data_handle
1509                          * for now:
1510                          */
1511                         call_dissector(data_handle, next_tvb, pinfo, tree);
1512                         break;
1513                 case 1: /* IEEE 802.11 */
1514                         call_dissector(global_capwap_swap_frame_control ? ieee80211_bsfc_handle : ieee80211_handle, next_tvb, pinfo, tree);
1515                         break;
1516                 default: /* Unknown Data */
1517                         call_dissector(data_handle, next_tvb, pinfo, tree);
1518                         break;
1519                 }
1520         }
1521         pinfo->fragmented = save_fragmented;
1522 }
1523
1524
1525 void
1526 proto_register_capwap_control(void)
1527 {
1528         module_t *capwap_module;
1529
1530         static hf_register_info hf[] = {
1531                 /* Preamble */
1532                 { &hf_capwap_preamble,
1533                 { "Preamble",   "capwap.preamble",
1534                         FT_NONE, BASE_NONE, NULL, 0x0,
1535                         NULL, HFILL }},
1536                 { &hf_capwap_preamble_version,
1537                 { "Version",           "capwap.preamble.version",
1538                         FT_UINT8, BASE_DEC, NULL, 0x0,
1539                         "Version of CAPWAP", HFILL }},
1540                 { &hf_capwap_preamble_type,
1541                 { "Type",           "capwap.preamble.type",
1542                         FT_UINT8, BASE_DEC, VALS(type_header_vals), 0x0,
1543                         "Type of Payload", HFILL }},
1544                 { &hf_capwap_preamble_reserved,
1545                 { "Reserved",           "capwap.preamble.reserved",
1546                         FT_UINT24, BASE_DEC, NULL, 0x0,
1547                         NULL, HFILL }},
1548                 /* CAPWAP Header */
1549                 { &hf_capwap_header,
1550                 { "Header",     "capwap.header",
1551                         FT_NONE, BASE_NONE, NULL, 0x0,
1552                         NULL, HFILL }},
1553                 { &hf_capwap_header_hlen,
1554                 { "Header Length",      "capwap.header.length",
1555                         FT_UINT8, BASE_DEC, NULL, 0x0,
1556                         NULL, HFILL }},
1557                 { &hf_capwap_header_rid,
1558                 { "Radio ID",   "capwap.header.rid",
1559                         FT_UINT8, BASE_DEC, NULL, 0x0,
1560                         NULL, HFILL }},
1561                 { &hf_capwap_header_wbid,
1562                 { "Wireless Binding ID",        "capwap.header.wbid",
1563                         FT_UINT8, BASE_DEC, VALS(type_wbid), 0x0,
1564                         NULL, HFILL }},
1565                 { &hf_capwap_header_flags,
1566                 { "Header Flags",       "capwap.header.flags",
1567                         FT_UINT8, BASE_DEC, NULL, 0x0,
1568                         NULL, HFILL }},
1569                 { &hf_capwap_header_flags_t,
1570                 { "Payload Type",       "capwap.header.flags.t",
1571                         FT_BOOLEAN, 9, TFS(&flag_type_t), 0x100,
1572                         NULL, HFILL }},
1573                 { &hf_capwap_header_flags_f,
1574                 { "Fragment",   "capwap.header.flags.f",
1575                         FT_BOOLEAN, 9, TFS(&flag_type_f), 0x80,
1576                         NULL, HFILL }},
1577                 { &hf_capwap_header_flags_l,
1578                 { "Last Fragment",      "capwap.header.flags.l",
1579                         FT_BOOLEAN, 9, TFS(&flag_type_l), 0x40,
1580                         NULL, HFILL }},
1581                 { &hf_capwap_header_flags_w,
1582                 { "Wireless header",    "capwap.header.flags.w",
1583                         FT_BOOLEAN, 9, TFS(&flag_type_w), 0x20,
1584                         NULL, HFILL }},
1585                 { &hf_capwap_header_flags_m,
1586                 { "Radio MAC header",   "capwap.header.flags.m",
1587                         FT_BOOLEAN, 9, TFS(&flag_type_m), 0x10,
1588                         NULL, HFILL }},
1589                 { &hf_capwap_header_flags_k,
1590                 { "Keep-Alive", "capwap.header.flags.k",
1591                         FT_BOOLEAN, 9, TFS(&flag_type_k), 0x08,
1592                         NULL, HFILL }},
1593                 { &hf_capwap_header_flags_r,
1594                 { "Reserved",   "capwap.header.flags.r",
1595                         FT_BOOLEAN, 9, TFS(&tfs_set_notset), 0x07,
1596                         NULL, HFILL }},
1597                 { &hf_capwap_header_fragment_id,
1598                 { "Fragment ID",        "capwap.header.fragment.id",
1599                         FT_UINT16, BASE_DEC, NULL, 0x00,
1600                         NULL, HFILL }},
1601                 { &hf_capwap_header_fragment_offset,
1602                 { "Fragment Offset",    "capwap.header.fragment.offset",
1603                         FT_UINT16, BASE_DEC, NULL, 0x00,
1604                         NULL, HFILL }},
1605                 { &hf_capwap_header_reserved,
1606                 { "Reserved",   "capwap.header.fragment.reserved",
1607                         FT_UINT8, BASE_DEC, NULL, 0x00,
1608                         NULL, HFILL }},
1609                 { &hf_capwap_header_mac_length,
1610                 { "MAC length", "capwap.header.mac.length",
1611                         FT_UINT8, BASE_DEC, NULL, 0x00,
1612                         NULL, HFILL }},
1613                 { &hf_capwap_header_mac_eui48,
1614                 { "MAC address",        "capwap.header.mac.eui48",
1615                         FT_ETHER, BASE_NONE, NULL, 0x00,
1616                         NULL, HFILL }},
1617                 { &hf_capwap_header_mac_eui64,
1618                 { "MAC address",        "capwap.header.mac.eui64",
1619                         FT_EUI64, BASE_NONE, NULL, 0x00,
1620                         NULL, HFILL }},
1621                 { &hf_capwap_header_mac_data,
1622                 { "MAC address",        "capwap.header.mac.data",
1623                         FT_BYTES, BASE_NONE, NULL, 0x00,
1624                         NULL, HFILL }},
1625                 { &hf_capwap_header_wireless_length,
1626                 { "Wireless length",    "capwap.header.wireless.length",
1627                         FT_UINT8, BASE_DEC, NULL, 0x00,
1628                         NULL, HFILL }},
1629                 { &hf_capwap_header_wireless_data,
1630                 { "Wireless data",      "capwap.header.wireless.data",
1631                         FT_BYTES, BASE_NONE, NULL, 0x00,
1632                         NULL, HFILL }},
1633                 { &hf_capwap_header_wireless_data_ieee80211_fi,
1634                 { "Wireless data ieee80211 Frame Info", "capwap.header.wireless.data.ieee80211.fi",
1635                         FT_BYTES, BASE_NONE, NULL, 0x00,
1636                         NULL, HFILL }},
1637                 { &hf_capwap_header_wireless_data_ieee80211_fi_rssi,
1638                 { "Wireless data ieee80211 RSSI (dBm)", "capwap.header.wireless.data.ieee80211.fi.rssi",
1639                         FT_UINT8, BASE_DEC, NULL, 0x00,
1640                         NULL, HFILL }},
1641                 { &hf_capwap_header_wireless_data_ieee80211_fi_snr,
1642                 { "Wireless data ieee80211 SNR (dB)",   "capwap.header.wireless.data.ieee80211.fi.snr",
1643                         FT_UINT8, BASE_DEC, NULL, 0x00,
1644                         NULL, HFILL }},
1645                 { &hf_capwap_header_wireless_data_ieee80211_fi_data_rate,
1646                 { "Wireless data ieee80211 Data Rate (Mbps)",   "capwap.header.wireless.data.ieee80211.fi.data_rate",
1647                         FT_UINT16, BASE_DEC, NULL, 0x00,
1648                         NULL, HFILL }},
1649                 { &hf_capwap_header_wireless_data_ieee80211_dest_wlan,
1650                 { "Wireless data ieee80211 Destination WLANs",  "capwap.header.wireless.data.ieee80211.dw",
1651                         FT_BYTES, BASE_NONE, NULL, 0x00,
1652                         NULL, HFILL }},
1653                 { &hf_capwap_header_wireless_data_ieee80211_dw_wlan_id_bitmap,
1654                 { "Wireless data ieee80211 Destination Wlan Id bitmap",
1655                 "capwap.header.wireless.data.ieee80211.dw.wlan_id_bitmap",
1656                         FT_UINT16, BASE_DEC, NULL, 0x00,
1657                         NULL, HFILL }},
1658                 { &hf_capwap_header_wireless_data_ieee80211_dw_reserved,
1659                 { "Wireless data ieee80211 Destination Wlan reserved",  "capwap.header.wireless.data.ieee80211.dw.reserved",
1660                         FT_UINT16, BASE_DEC, NULL, 0x00,
1661                         NULL, HFILL }},
1662                 { &hf_capwap_header_padding,
1663                 { "Padding for 4 Byte Alignement",      "capwap.header.padding",
1664                         FT_BYTES, BASE_NONE, NULL, 0x00,
1665                         NULL, HFILL }},
1666
1667                 /* CAPWAP Control Header Message */
1668
1669                 { &hf_capwap_control_header,
1670                 { "Control Header",     "capwap.control.header",
1671                         FT_NONE, BASE_NONE, NULL, 0x00,
1672                         NULL, HFILL }},
1673                 { &hf_capwap_control_header_msg_type,
1674                 { "Message Type",       "capwap.control.header.message_type",
1675                         FT_UINT32, BASE_DEC, NULL, 0x00,
1676                         NULL, HFILL }},
1677                 { &hf_capwap_control_header_msg_type_enterprise_nbr,
1678                 { "Message Type (Enterprise Number)",   "capwap.control.header.message_type.enterprise_number",
1679                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1680                         NULL, HFILL }},
1681                 { &hf_capwap_control_header_msg_type_enterprise_specific,
1682                 { "Message Type (Enterprise Specific)", "capwap.control.header.message_type.enterprise_specific",
1683                         FT_UINT8, BASE_DEC, VALS(message_type), 0x00,
1684                         NULL, HFILL }},
1685                 { &hf_capwap_control_header_seq_number,
1686                 { "Sequence Number",    "capwap.control.header.sequence_number",
1687                         FT_UINT8, BASE_DEC, NULL, 0x00,
1688                         NULL, HFILL }},
1689                 { &hf_capwap_control_header_msg_element_length,
1690                 { "Message Element Length",     "capwap.control.header.message_element_length",
1691                         FT_UINT16, BASE_DEC, NULL, 0x00,
1692                         NULL, HFILL }},
1693                 { &hf_capwap_control_header_flags,
1694                 { "Flags",      "capwap.control.header.flags",
1695                         FT_UINT8, BASE_DEC, NULL, 0x00,
1696                         NULL, HFILL }},
1697
1698                 /* CAPWAP Protocol Message Elements */
1699
1700                 { &hf_capwap_message_element,
1701                 { "Message Element",    "capwap.message_element",
1702                         FT_NONE, BASE_NONE, NULL, 0x00,
1703                         NULL, HFILL }},
1704                 { &hf_capwap_msg_element_type,
1705                 { "Type",       "capwap.message_element.type",
1706                         FT_UINT16, BASE_DEC, VALS(message_element_type_vals), 0x00,
1707                         "CAPWAP Message Element type", HFILL }},
1708                 { &hf_capwap_msg_element_length,
1709                 { "Length",     "capwap.message_element.length",
1710                         FT_UINT16, BASE_DEC, NULL, 0x00,
1711                         "CAPWAP Message Element length", HFILL }},
1712                 { &hf_capwap_msg_element_value,
1713                 { "Value",      "capwap.message_element.value",
1714                         FT_BYTES, BASE_NONE, NULL, 0x00,
1715                         "CAPWAP Message Element value", HFILL }},
1716
1717                 /* CAPWAP Protocol Message Element Type */
1718
1719                 /* AC Descriptor */
1720                 { &hf_capwap_msg_element_type_ac_descriptor_stations,
1721                 { "Stations",   "capwap.control.message_element.ac_descriptor.stations",
1722                         FT_UINT16, BASE_DEC, NULL, 0x00,
1723                         NULL, HFILL }},
1724                 { &hf_capwap_msg_element_type_ac_descriptor_limit,
1725                 { "Limit Stations",     "capwap.control.message_element.ac_descriptor.limit",
1726                         FT_UINT16, BASE_DEC, NULL, 0x00,
1727                         NULL, HFILL }},
1728                 { &hf_capwap_msg_element_type_ac_descriptor_active_wtp,
1729                 { "Active WTPs",        "capwap.control.message_element.ac_descriptor.active_wtp",
1730                         FT_UINT16, BASE_DEC, NULL, 0x00,
1731                         NULL, HFILL }},
1732                 { &hf_capwap_msg_element_type_ac_descriptor_max_wtp,
1733                 { "Max WTPs",   "capwap.control.message_element.ac_descriptor.max_wtp",
1734                         FT_UINT16, BASE_DEC, NULL, 0x00,
1735                         NULL, HFILL }},
1736                 /* AC Descriptor Security Flags... */
1737                 { &hf_capwap_msg_element_type_ac_descriptor_security,
1738                 { "Security Flags",     "capwap.control.message_element.ac_descriptor.security",
1739                         FT_NONE, BASE_NONE, NULL, 0x0,
1740                         NULL, HFILL }},
1741                 { &hf_capwap_msg_element_type_ac_descriptor_security_s,
1742                 { "AC supports the pre-shared", "capwap.control.message_element.ac_descriptor.security.s",
1743                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x04,
1744                         NULL, HFILL }},
1745                 { &hf_capwap_msg_element_type_ac_descriptor_security_x,
1746                 { "AC supports X.509 Certificate",      "capwap.control.message_element.ac_descriptor.security.x",
1747                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
1748                         NULL, HFILL }},
1749                 { &hf_capwap_msg_element_type_ac_descriptor_security_r,
1750                 { "Reserved",   "capwap.control.message_element.ac_descriptor.security.r",
1751                         FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0xF9,
1752                         NULL, HFILL }},
1753
1754                 { &hf_capwap_msg_element_type_ac_descriptor_rmac_field,
1755                 { "R-MAC Field",        "capwap.control.message_element.ac_descriptor.rmac_field",
1756                         FT_UINT8, BASE_DEC, VALS(rmac_field_vals), 0x00,
1757                         NULL, HFILL }},
1758                 { &hf_capwap_msg_element_type_ac_descriptor_reserved,
1759                 { "Reserved",   "capwap.control.message_element.ac_descriptor.reserved",
1760                         FT_UINT8, BASE_DEC, NULL, 0x00,
1761                         NULL, HFILL }},
1762                 /* AC Descriptor DTLS Policy Flags... */
1763                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy,
1764                 { "DTLS Policy Flags",  "capwap.control.message_element.ac_descriptor.dtls_policy",
1765                         FT_NONE, BASE_NONE, NULL, 0x0,
1766                         NULL, HFILL }},
1767                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy_d,
1768                 { "DTLS-Enabled Data Channel Supported", "capwap.control.message_element.ac_descriptor.dtls_policy.d",
1769                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x04,
1770                         NULL, HFILL }},
1771                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy_c,
1772                 { "Clear Text Data Channel Supported",  "capwap.control.message_element.ac_descriptor.dtls_policy.c",
1773                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
1774                         NULL, HFILL }},
1775                 { &hf_capwap_msg_element_type_ac_descriptor_dtls_policy_r,
1776                 { "Reserved",   "capwap.control.message_element.ac_descriptor.dtls_policy.r",
1777                         FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0xF9,
1778                         NULL, HFILL }},
1779
1780                 { &hf_capwap_msg_element_type_ac_information_vendor,
1781                 { "AC Information Vendor",      "capwap.control.message_element.ac_information.vendor",
1782                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1783                         NULL, HFILL }},
1784                 { &hf_capwap_msg_element_type_ac_information_type,
1785                 { "AC Information Type",        "capwap.control.message_element.ac_information.type",
1786                         FT_UINT16, BASE_DEC, VALS(ac_information_type_vals), 0x00,
1787                         NULL, HFILL }},
1788                 { &hf_capwap_msg_element_type_ac_information_length,
1789                 { "AC Information Length",      "capwap.control.message_element.ac_information.length",
1790                         FT_UINT16, BASE_DEC, NULL, 0x0,
1791                         NULL, HFILL }},
1792
1793                 { &hf_capwap_msg_element_type_ac_information_value,
1794                 { "AC Information Value",       "capwap.control.message_element.ac_information.value",
1795                         FT_BYTES, BASE_NONE, NULL, 0x0,
1796                         NULL, HFILL }},
1797                 { &hf_capwap_msg_element_type_ac_information_hardware_version,
1798                 { "AC Hardware Version",        "capwap.control.message_element.ac_information.hardware_version",
1799                         FT_STRING, BASE_NONE, NULL, 0x0,
1800                         NULL, HFILL }},
1801                 { &hf_capwap_msg_element_type_ac_information_software_version,
1802                 { "AC Software Version",        "capwap.control.message_element.ac_information.software_version",
1803                         FT_STRING, BASE_NONE, NULL, 0x0,
1804                         NULL, HFILL }},
1805                 { &hf_capwap_msg_element_type_ac_ipv4_list,
1806                 { "AC IPv4 List",       "capwap.control.message_element.message_element.ac_ipv4_list",
1807                         FT_IPv4, BASE_NONE, NULL, 0x00,
1808                         NULL, HFILL }},
1809                 { &hf_capwap_msg_element_type_ac_ipv6_list,
1810                 { "AC IPv6 List",       "capwap.control.message_element.message_element.ac_ipv6_list",
1811                         FT_IPv6, BASE_NONE, NULL, 0x00,
1812                         NULL, HFILL }},
1813                 /* CAPWAP Control IPvX Address*/
1814                 { &hf_capwap_msg_element_type_capwap_control_ipv4,
1815                 { "CAPWAP Control IP Address",  "capwap.control.message_element.message_element.capwap_control_ipv4",
1816                         FT_IPv4, BASE_NONE, NULL, 0x00,
1817                         NULL, HFILL }},
1818                 { &hf_capwap_msg_element_type_capwap_control_ipv6,
1819                 { "CAPWAP Control IP Address",  "capwap.control.message_element.message_element.capwap_control_ipv6",
1820                         FT_IPv6, BASE_NONE, NULL, 0x00,
1821                         NULL, HFILL }},
1822                 { &hf_capwap_msg_element_type_capwap_control_wtp_count,
1823                 { "CAPWAP Control WTP Count",   "capwap.control.message_element.capwap_control_wtp_count",
1824                         FT_UINT16, BASE_DEC, NULL, 0x00,
1825                         NULL, HFILL }},
1826                 { &hf_capwap_msg_element_type_capwap_timers_discovery,
1827                 { "CAPWAP Timers Discovery (Sec)",      "capwap.control.message_element.capwap_timers_discovery",
1828                         FT_UINT8, BASE_DEC, NULL, 0x00,
1829                         NULL, HFILL }},
1830                 { &hf_capwap_msg_element_type_capwap_timers_echo_request,
1831                 { "CAPWAP Timers Echo Request (Sec)",   "capwap.control.message_element.capwap_timers_echo_request",
1832                         FT_UINT8, BASE_DEC, NULL, 0x00,
1833                         NULL, HFILL }},
1834                 { &hf_capwap_msg_element_type_decryption_error_report_period_radio_id,
1835                 { "Decryption Error Report Period Radio ID",    "capwap.control.message_element.decryption_error_report_period.radio_id",
1836                         FT_UINT8, BASE_DEC, NULL, 0x00,
1837                         NULL, HFILL }},
1838                 { &hf_capwap_msg_element_type_decryption_error_report_period_interval,
1839                 { "Decryption Error Report Report Interval (Sec)",      "capwap.control.message_element.decryption_error_report_period.interval",
1840                         FT_UINT16, BASE_DEC, NULL, 0x00,
1841                         NULL, HFILL }},
1842                 { &hf_capwap_msg_element_type_ac_name,
1843                 { "AC Name",    "capwap.control.message_element.ac_name",
1844                         FT_STRING, BASE_NONE, NULL, 0x00,
1845                         NULL, HFILL }},
1846                 { &hf_capwap_msg_element_type_ac_name_with_priority,
1847                 { "AC Name Priority",   "capwap.control.message_element.ac_name_with_priority",
1848                         FT_UINT8, BASE_DEC, NULL, 0x00,
1849                         NULL, HFILL }},
1850
1851                 { &hf_capwap_msg_element_type_discovery_type,
1852                 { "Discovery Type",     "capwap.control.message_element.discovery_type",
1853                         FT_UINT8, BASE_DEC, VALS(discovery_type_vals), 0x00,
1854                         NULL, HFILL }},
1855
1856                 { &hf_capwap_msg_element_type_idle_timeout,
1857                 { "Idle Timeout (Sec)", "capwap.control.message_element.idle_timeout",
1858                         FT_UINT32, BASE_DEC, NULL, 0x00,
1859                         NULL, HFILL }},
1860                 { &hf_capwap_msg_element_type_location_data,
1861                 { "Location Data",      "capwap.control.message_element.location_data",
1862                         FT_STRING, BASE_NONE, NULL, 0x00,
1863                         NULL, HFILL }},
1864                 { &hf_capwap_msg_element_type_maximum_message_length,
1865                 { "Maximum Message Length",     "capwap.control.message_element.maximum_message_length",
1866                         FT_UINT16, BASE_DEC, NULL, 0x00,
1867                         NULL, HFILL }},
1868
1869                 { &hf_capwap_msg_element_type_radio_admin_id,
1870                 { "Radio Administrative ID",    "capwap.control.message_element.radio_admin.id",
1871                         FT_UINT8, BASE_DEC, NULL, 0x00,
1872                         NULL, HFILL }},
1873                 { &hf_capwap_msg_element_type_radio_admin_state,
1874                 { "Radio Administrative State", "capwap.control.message_element.radio_admin.state",
1875                         FT_UINT8, BASE_DEC, VALS(radio_admin_state_vals), 0x00,
1876                         NULL, HFILL }},
1877                 { &hf_capwap_msg_element_type_radio_op_state_radio_id,
1878                 { "Radio Operational ID",       "capwap.control.message_element.radio_op_state.radio_id",
1879                         FT_UINT8, BASE_DEC, NULL, 0x00,
1880                         NULL, HFILL }},
1881                 { &hf_capwap_msg_element_type_radio_op_state_radio_state,
1882                 { "Radio Operational State",    "capwap.control.message_element.radio_op_state.radio_state",
1883                         FT_UINT8, BASE_DEC, VALS(radio_op_state_vals), 0x00,
1884                         NULL, HFILL }},
1885                 { &hf_capwap_msg_element_type_radio_op_state_radio_cause,
1886                 { "Radio Operational Cause",    "capwap.control.message_element.radio_op_state.radio_cause",
1887                         FT_UINT8, BASE_DEC, VALS(radio_op_cause_vals), 0x00,
1888                         NULL, HFILL }},
1889                 { &hf_capwap_msg_element_type_result_code,
1890                 { "Result Code",        "capwap.control.message_element.result_code",
1891                         FT_UINT32, BASE_DEC, VALS(result_code_vals), 0x00,
1892                         NULL, HFILL }},
1893                 { &hf_capwap_msg_element_type_session_id,
1894                 { "Session ID", "capwap.control.message_element.session_id",
1895                         FT_BYTES, BASE_NONE, NULL, 0x00,
1896                         NULL, HFILL }},
1897                 { &hf_capwap_msg_element_type_statistics_timer,
1898                 { "Statistics Timer (Sec)",     "capwap.control.message_element.statistics_timer",
1899                         FT_UINT16, BASE_DEC, NULL, 0x00,
1900                         NULL, HFILL }},
1901                 { &hf_capwap_msg_element_type_vsp_vendor_identifier,
1902                 { "Vendor Identifier",  "capwap.control.message_element.vsp.vendor_identifier",
1903                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1904                         NULL, HFILL }},
1905                 { &hf_capwap_msg_element_type_vsp_vendor_element_id,
1906                 { "Vendor Element ID",  "capwap.control.message_element.vsp.vendor_element_id",
1907                         FT_UINT16, BASE_DEC, NULL, 0x00,
1908                         NULL, HFILL }},
1909                 { &hf_capwap_msg_element_type_vsp_vendor_data,
1910                 { "Vendor Data",        "capwap.control.message_element.vsp.vendor_data",
1911                         FT_BYTES, BASE_NONE, NULL, 0x00,
1912                         NULL, HFILL }},
1913
1914                 { &hf_capwap_msg_element_type_wtp_board_data_vendor,
1915                 { "WTP Board Data Vendor",      "capwap.control.message_element.wtp_board_data.vendor",
1916                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1917                         NULL, HFILL }},
1918                 { &hf_capwap_msg_element_type_wtp_board_data_type,
1919                 { "Board Data Type",    "capwap.control.message_element.wtp_board_data.type",
1920                         FT_UINT16, BASE_DEC, VALS(board_data_type_vals), 0x00,
1921                         NULL, HFILL }},
1922                 { &hf_capwap_msg_element_type_wtp_board_data_length,
1923                 { "Board Data Length",  "capwap.control.message_element.wtp_board_data.length",
1924                         FT_UINT16, BASE_DEC, NULL, 0x00,
1925                         NULL, HFILL }},
1926                 { &hf_capwap_msg_element_type_wtp_board_data_value,
1927                 { "Board Data Value",   "capwap.control.message_element.wtp_board_data.value",
1928                         FT_BYTES, BASE_NONE, NULL, 0x00,
1929                         NULL, HFILL }},
1930
1931                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_model_number,
1932                 { "WTP Model Number",   "capwap.control.message_element.wtp_board_data.wtp_model_number",
1933                         FT_STRING, BASE_NONE, NULL, 0x00,
1934                         NULL, HFILL }},
1935                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_serial_number,
1936                 { "WTP Serial Number",  "capwap.control.message_element.wtp_board_data.wtp_serial_number",
1937                         FT_STRING, BASE_NONE, NULL, 0x00,
1938                         NULL, HFILL }},
1939                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_board_id,
1940                 { "WTP Board ID",       "capwap.control.message_element.wtp_board_data.wtp_board_id",
1941                         FT_STRING, BASE_NONE, NULL, 0x0,
1942                         NULL, HFILL }},
1943                 { &hf_capwap_msg_element_type_wtp_board_data_wtp_board_revision,
1944                 { "WTP Board Revision", "capwap.control.message_element.wtp_board_data.wtp_board_revision",
1945                         FT_STRING, BASE_NONE, NULL, 0x0,
1946                         NULL, HFILL }},
1947                 { &hf_capwap_msg_element_type_wtp_board_data_base_mac_address,
1948                 { "Base Mac Address",   "capwap.control.message_element.wtp_board_data.base_mac_address",
1949                         FT_ETHER, BASE_NONE, NULL, 0x0,
1950                         NULL, HFILL }},
1951
1952                 { &hf_capwap_msg_element_type_wtp_descriptor_max_radios,
1953                 { "Max Radios", "capwap.control.message_element.wtp_descriptor.max_radios",
1954                         FT_UINT8, BASE_DEC, NULL, 0x00,
1955                         NULL, HFILL }},
1956                 { &hf_capwap_msg_element_type_wtp_descriptor_radio_in_use,
1957                 { "Radio in use",       "capwap.control.message_element.wtp_descriptor.radio_in_use",
1958                         FT_UINT8, BASE_DEC, NULL, 0x00,
1959                         NULL, HFILL }},
1960                 { &hf_capwap_msg_element_type_wtp_descriptor_number_encrypt,
1961                 { "Encryption Capabilities (Number)",   "capwap.control.message_element.wtp_descriptor.number_encrypt",
1962                         FT_UINT8, BASE_DEC, NULL, 0x00,
1963                         NULL, HFILL }},
1964                 { &hf_capwap_msg_element_type_wtp_descriptor_encrypt_reserved,
1965                 { "Reserved (Encrypt)", "capwap.control.message_element.wtp_descriptor.encrypt_reserved",
1966                         FT_UINT8, BASE_DEC, NULL, 0x00,
1967                         NULL, HFILL }},
1968                 { &hf_capwap_msg_element_type_wtp_descriptor_encrypt_wbid,
1969                 { "Encrypt WBID",       "capwap.control.message_element.wtp_descriptor.encrypt_wbid",
1970                         FT_UINT8, BASE_DEC, VALS(type_wbid), 0x00,
1971                         NULL, HFILL }},
1972                 { &hf_capwap_msg_element_type_wtp_descriptor_encrypt_capabilities,
1973                 { "Encryption Capabilities",    "capwap.control.message_element.wtp_descriptor.encrypt_capabilities",
1974                         FT_UINT16, BASE_DEC, NULL, 0x00,
1975                         NULL, HFILL }},
1976                 { &hf_capwap_msg_element_type_wtp_descriptor_vendor,
1977                 { "WTP Descriptor Vendor",      "capwap.control.message_element.wtp_descriptor.vendor",
1978                         FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
1979                         NULL, HFILL }},
1980                 { &hf_capwap_msg_element_type_wtp_descriptor_type,
1981                 { "Descriptor Type",    "capwap.control.message_element.wtp_descriptor.type",
1982                         FT_UINT16, BASE_DEC, VALS(wtp_descriptor_type_vals), 0x0,
1983                         NULL, HFILL }},
1984                 { &hf_capwap_msg_element_type_wtp_descriptor_length,
1985                 { "Descriptor Length",  "capwap.control.message_element.wtp_descriptor.length",
1986                         FT_UINT16, BASE_DEC, NULL, 0x0,
1987                         NULL, HFILL }},
1988                 { &hf_capwap_msg_element_type_wtp_descriptor_value,
1989                 { "Descriptor Value",   "capwap.control.message_element.wtp_descriptor.value",
1990                         FT_BYTES, BASE_NONE, NULL, 0x0,
1991                         NULL, HFILL }},
1992                 { &hf_capwap_msg_element_type_wtp_descriptor_hardware_version,
1993                 { "WTP Hardware Version",       "capwap.control.message_element.wtp_descriptor.hardware_version",
1994                         FT_STRING, BASE_NONE, NULL, 0x0,
1995                         NULL, HFILL }},
1996                 { &hf_capwap_msg_element_type_wtp_descriptor_active_software_version,
1997                 { "WTP Active Software Version",        "capwap.control.message_element.wtp_descriptor.active_software_version",
1998                         FT_STRING, BASE_NONE, NULL, 0x0,
1999                         NULL, HFILL }},
2000                 { &hf_capwap_msg_element_type_wtp_descriptor_boot_version,
2001                 { "WTP Boot Version",   "capwap.control.message_element.wtp_descriptor.boot_version",
2002                         FT_STRING, BASE_NONE, NULL, 0x0,
2003                         NULL, HFILL }},
2004                 { &hf_capwap_msg_element_type_wtp_descriptor_other_software_version,
2005                 { "WTP Other Software Version", "capwap.control.message_element.wtp_descriptor.other_software_version",
2006                         FT_STRING, BASE_NONE, NULL, 0x0,
2007                         NULL, HFILL }},
2008                 { &hf_capwap_msg_element_type_wtp_fallback,
2009                 { "WTP Fallback",       "capwap.control.message_element.wtp_fallback",
2010                         FT_UINT8, BASE_DEC, VALS(wtp_fallback_vals), 0x0,
2011                         NULL, HFILL }},
2012
2013                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode,
2014                 { "WTP Frame Tunnel Mode",      "capwap.control.message_element.wtp_frame_tunnel_mode",
2015                         FT_NONE, BASE_NONE, NULL, 0x0,
2016                         NULL, HFILL }},
2017                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_n,
2018                 { "Native Frame Tunnel Mode",   "capwap.control.message_element.wtp_frame_tunnel_mode.n",
2019                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x08,
2020                         NULL, HFILL }},
2021                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_e,
2022                 { "802.3 Frame Tunnel Mode",    "capwap.control.message_element.wtp_frame_tunnel_mode.e",
2023                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x04,
2024                         NULL, HFILL }},
2025                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_l,
2026                 { "Local Bridging",     "capwap.control.message_element.wtp_frame_tunnel_mode.l",
2027                         FT_BOOLEAN, 8, TFS(&tfs_true_false), 0x02,
2028                         NULL, HFILL }},
2029                 { &hf_capwap_msg_element_type_wtp_frame_tunnel_mode_r,
2030                 { "Reserved",   "capwap.control.message_element.wtp_frame_tunnel_mode.r",
2031                         FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0xF1,
2032                         NULL, HFILL }},
2033
2034                 { &hf_capwap_msg_element_type_wtp_mac_type,
2035                         { "WTP MAC Type",           "capwap.control.message_element.wtp_mac_type",
2036                         FT_UINT8, BASE_DEC, VALS(wtp_mac_vals), 0x0,
2037                         "The MAC mode of operation supported by the WTP", HFILL }},
2038                 { &hf_capwap_msg_element_type_wtp_name,
2039                         { "WTP Name",           "capwap.control.message_element.wtp_name",
2040                         FT_STRING, BASE_NONE, NULL, 0x0,
2041                         NULL, HFILL }},
2042                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_reboot_count,
2043                         { "Reboot  Count",           "capwap.control.message_element.wtp_reboot_statistics.reboot_count",
2044                         FT_UINT16, BASE_DEC, NULL, 0x0,
2045                         "The number of reboots that have occurred due to a WTP crash", HFILL }},
2046                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_ac_initiated_count,
2047                         { "AC Initiated Count",           "capwap.control.message_element.wtp_reboot_statistics.ac_initiated_count",
2048                         FT_UINT16, BASE_DEC, NULL, 0x0,
2049                         "The number of reboots that have occurred at the request of a CAPWAP protocol message", HFILL }},
2050                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_link_failure_count,
2051                         { "Link Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.link_failure_count",
2052                         FT_UINT16, BASE_DEC, NULL, 0x0,
2053                         "The number of times that a CAPWAP protocol connection with an AC has failed due to link failure", HFILL }},
2054                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_sw_failure_count,
2055                         { "SW Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.sw_failure_count",
2056                         FT_UINT16, BASE_DEC, NULL, 0x0,
2057                         "The number of times that a CAPWAP protocol connection with an AC has failed due to software-related reasons", HFILL }},
2058                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_hw_failure_count,
2059                         { "HW Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.hw_failure_count",
2060                         FT_UINT16, BASE_DEC, NULL, 0x0,
2061                         "The number of times that a CAPWAP protocol connection with an AC has failed due to hardware-related reasons", HFILL }},
2062                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_other_failure_count,
2063                         { "Other Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.other_failure_count",
2064                         FT_UINT16, BASE_DEC, NULL, 0x0,
2065                         "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 }},
2066                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_unknown_failure_count,
2067                         { "Unknown Failure Count",           "capwap.control.message_element.wtp_reboot_statistics.unknown_failure_count",
2068                         FT_UINT16, BASE_DEC, NULL, 0x0,
2069                         "The number of times that a CAPWAP protocol connection with an AC has failed for unknown reasons", HFILL }},
2070                 { &hf_capwap_msg_element_type_wtp_reboot_statistics_last_failure_type,
2071                         { "Last Failure Type",           "capwap.control.message_element.wtp_reboot_statistics.last_failure_type",
2072                         FT_UINT8, BASE_DEC, VALS(last_failure_type_vals), 0x0,
2073                         "The failure type of the most recent WTP failure", HFILL }},
2074
2075                 { &hf_capwap_msg_element_type_ieee80211_rate_set_radio_id,
2076                         { "Radio ID",           "capwap.control.message_element.ieee80211_rate_set.radio_id",
2077                         FT_UINT8, BASE_DEC, NULL, 0x0,
2078                         NULL, HFILL }},
2079                 { &hf_capwap_msg_element_type_ieee80211_rate_set_rate_set,
2080                         { "Rate Set",           "capwap.control.message_element.ieee80211_rate_set.rate_set",
2081                         FT_BYTES, BASE_NONE, NULL, 0x0,
2082                         NULL, HFILL }},
2083                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_mac,
2084                         { "Mac Address",           "capwap.control.message_element.ieee80211_station_session_key.mac",
2085                         FT_ETHER, BASE_NONE, NULL, 0x0,
2086                         "The station's MAC Address", HFILL }},
2087                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_flags,
2088                         { "Flags",           "capwap.control.message_element.ieee80211_station_session_key.flags",
2089                         FT_UINT16, BASE_DEC, NULL, 0x3FFF,
2090                         NULL, HFILL }},
2091                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_flags_a,
2092                         { "Flag A",           "capwap.control.message_element.ieee80211_station_session_key.flags_a",
2093                         FT_BOOLEAN, 1, NULL, 0x2000,
2094                         NULL, HFILL }},
2095                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_flags_c,
2096                         { "Flag C",           "capwap.control.message_element.ieee80211_station_session_key.flags_c",
2097                         FT_BOOLEAN, 1, NULL, 0x1000,
2098                         NULL, HFILL }},
2099                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_tsc,
2100                         { "Pairwise TSC",           "capwap.control.message_element.ieee80211_station_session_key.pairwire_tsc",
2101                         FT_BYTES, BASE_NONE, NULL, 0x0,
2102                         "Transmit Sequence Counter (TSC)", HFILL }},
2103                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_pairwire_rsc,
2104                         { "Pairwise RSC",           "capwap.control.message_element.ieee80211_station_session_key.pairwire_rsc",
2105                         FT_BYTES, BASE_NONE, NULL, 0x0,
2106                         "Receive Sequence Counter (TSC)", HFILL }},
2107                 { &hf_capwap_msg_element_type_ieee80211_station_session_key_key,
2108                         { "Key",           "capwap.control.message_element.ieee80211_station_session_key.key",
2109                         FT_BYTES, BASE_NONE, NULL, 0x0,
2110                         NULL, HFILL }},
2111                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_id,
2112                         { "Radio ID",           "capwap.control.message_element.ieee80211__wtp_radio_info.radio_id",
2113                         FT_UINT8, BASE_DEC, NULL, 0x0,
2114                         NULL, HFILL }},
2115                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_reserved,
2116                         { "Radio Type Reserved",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_reserved",
2117                         FT_BYTES, BASE_NONE, NULL, 0x0,
2118                         NULL, HFILL }},
2119                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_n,
2120                         { "Radio Type 802.11n",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_n",
2121                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0008,
2122                         NULL, HFILL }},
2123                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_g,
2124                         { "Radio Type 802.11g",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_g",
2125                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0004,
2126                         NULL, HFILL }},
2127                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_a,
2128                         { "Radio Type 802.11a",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_a",
2129                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0002,
2130                         NULL, HFILL }},
2131                 { &hf_capwap_msg_element_type_ieee80211_wtp_radio_info_radio_type_b,
2132                         { "Radio Type 802.11g",           "capwap.control.message_element.ieee80211_wtp_info_radio.radio_type_b",
2133                         FT_BOOLEAN, 4, TFS(&tfs_true_false), 0x0001,
2134                         NULL, HFILL }},
2135
2136                 /* Fragment entries */
2137                 { &hf_msg_fragments,
2138                         { "Message fragments", "capwap.fragments", FT_NONE, BASE_NONE,
2139                         NULL, 0x00, NULL, HFILL } },
2140                 { &hf_msg_fragment,
2141                         { "Message fragment", "capwap.fragment", FT_FRAMENUM, BASE_NONE,
2142                         NULL, 0x00, NULL, HFILL } },
2143                 { &hf_msg_fragment_overlap,
2144                         { "Message fragment overlap", "capwap.fragment.overlap", FT_BOOLEAN,
2145                         BASE_NONE, NULL, 0x00, NULL, HFILL } },
2146                 { &hf_msg_fragment_overlap_conflicts,
2147                         { "Message fragment overlapping with conflicting data",
2148                         "capwap.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL,
2149                         0x00, NULL, HFILL } },
2150                 { &hf_msg_fragment_multiple_tails,
2151                         { "Message has multiple tail fragments",
2152                         "capwap.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
2153                         NULL, 0x00, NULL, HFILL } },
2154                 { &hf_msg_fragment_too_long_fragment,
2155                         { "Message fragment too long", "capwap.fragment.too_long_fragment",
2156                         FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } },
2157                 { &hf_msg_fragment_error,
2158                         { "Message defragmentation error", "capwap.fragment.error", FT_FRAMENUM,
2159                         BASE_NONE, NULL, 0x00, NULL, HFILL } },
2160                 { &hf_msg_fragment_count,
2161                         { "Message fragment count", "capwap.fragment.count", FT_UINT32, BASE_DEC,
2162                         NULL, 0x00, NULL, HFILL } },
2163                 { &hf_msg_reassembled_in,
2164                         { "Reassembled in", "capwap.reassembled.in", FT_FRAMENUM, BASE_NONE,
2165                         NULL, 0x00, NULL, HFILL } },
2166                 { &hf_msg_reassembled_length,
2167                         { "Reassembled CAPWAP length", "capwap.reassembled.length", FT_UINT32, BASE_DEC,
2168                         NULL, 0x00, NULL, HFILL } }
2169         };
2170
2171         /* Setup protocol subtree array */
2172         static gint *ett[] = {
2173                 &ett_capwap,
2174                 &ett_msg_fragment,
2175                 &ett_msg_fragments
2176         };
2177
2178         /* Register the protocol name and description */
2179         proto_capwap = proto_register_protocol("Control And Provisioning of Wireless Access Points", "CAPWAP", "capwap");
2180
2181         /* Required function calls to register the header fields and subtrees used */
2182         proto_register_field_array(proto_capwap, hf, array_length(hf));
2183
2184         proto_register_subtree_array(ett, array_length(ett));
2185
2186         register_init_routine(&capwap_reassemble_init);
2187
2188         /* Register preferences module (See Section 2.6 for more on preferences) */
2189         capwap_module = prefs_register_protocol(proto_capwap, proto_reg_handoff_capwap);
2190
2191         prefs_register_uint_preference(capwap_module, "udp.port.control", "CAPWAP Control UDP Port",
2192              "Set the port for CAPWAP Control messages (if other than the default of 5246)",
2193              10, &global_capwap_control_udp_port);
2194
2195         prefs_register_uint_preference(capwap_module, "udp.port.data", "CAPWAP Data UDP Port",
2196              "Set the port for CAPWAP Data messages (if other than the default of 5247)",
2197              10, &global_capwap_data_udp_port);
2198
2199         prefs_register_bool_preference(capwap_module, "draft_8_cisco", "Cisco Wireless Controller Support",
2200              "Enable support of Cisco Wireless Controller (based on old 8 draft revision).",
2201              &global_capwap_draft_8_cisco);
2202
2203         prefs_register_bool_preference(capwap_module, "reassemble", "Reassemble fragmented CAPWAP packets",
2204              "Reassemble fragmented CAPWAP packets.",
2205              &global_capwap_reassemble);
2206
2207         prefs_register_bool_preference(capwap_module, "swap_fc", "Swap Frame Control",
2208              "Swap frame control bytes (needed for some APs).",
2209              &global_capwap_swap_frame_control);
2210
2211 }
2212
2213 void
2214 proto_reg_handoff_capwap(void)
2215 {
2216         static gboolean inited = FALSE;
2217         static dissector_handle_t capwap_control_handle, capwap_data_handle;
2218         static guint capwap_control_udp_port, capwap_data_udp_port;
2219
2220         if (!inited) {
2221                 capwap_control_handle = new_create_dissector_handle(dissect_capwap_control, proto_capwap);
2222                 capwap_data_handle    = create_dissector_handle(dissect_capwap_data, proto_capwap);
2223                 dtls_handle           = find_dissector("dtls");
2224                 ieee8023_handle       = find_dissector("eth_withoutfcs");
2225                 ieee80211_handle      = find_dissector("wlan");
2226                 ieee80211_bsfc_handle = find_dissector("wlan_bsfc");
2227                 data_handle           = find_dissector("data");
2228
2229                 inited = TRUE;
2230         } else {
2231                 dissector_delete_uint("udp.port", capwap_control_udp_port, capwap_control_handle);
2232                 dissector_delete_uint("udp.port", capwap_data_udp_port, capwap_data_handle);
2233         }
2234         dissector_add_uint("udp.port", global_capwap_control_udp_port, capwap_control_handle);
2235         dissector_add_uint("udp.port", global_capwap_data_udp_port, capwap_data_handle);
2236
2237         capwap_control_udp_port = global_capwap_control_udp_port;
2238         capwap_data_udp_port    = global_capwap_data_udp_port;
2239 }
2240