From Jerry Kotland:
[obnox/wireshark/wip.git] / epan / dissectors / packet-ieee80211.c
1 /* packet-ieee80211.c
2  * Routines for Wireless LAN (IEEE 802.11) dissection
3  * Copyright 2000, Axis Communications AB
4  * Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * Copied from README.developer
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  *
28  * Credits:
29  *
30  * The following people helped me by pointing out bugs etc. Thank you!
31  *
32  * Marco Molteni
33  * Lena-Marie Nilsson
34  * Magnus Hultman-Persson
35  */
36
37 /*
38  * 09/12/2003 - Added dissection of country information tag
39  *
40  * Ritchie<at>tipsybottle.com
41  *
42  * 03/22/2004 - Added dissection of RSN IE
43  * Jouni Malinen <jkmaline@cc.hut.fi>
44  *
45  * 10/24/2005 - Add dissection for 802.11e
46  * Zhu Yi <yi.zhu@intel.com>
47  *
48  * Dutin Johnson - 802.11n and portions of 802.11k and 802.11ma
49  * dustin@dustinj.us & dustin.johnson@cacetech.com
50  *
51  * 04/21/2008 - Added dissection for 802.11p 
52  * Arada Systems <http://www.aradasystems.com>
53  */
54
55 #ifdef HAVE_CONFIG_H
56 # include "config.h"
57 #endif
58
59 #include <stdio.h>
60 #include <stdlib.h>
61
62 #include <string.h>
63 #include <glib.h>
64 #include <math.h>
65 #include <epan/bitswap.h>
66 #include <epan/proto.h>
67 #include <epan/packet.h>
68 #include <epan/addr_resolv.h>
69 #include <epan/strutil.h>
70 #include <epan/prefs.h>
71 #include <epan/reassemble.h>
72 #include "packet-ipx.h"
73 #include "packet-llc.h"
74 #include "packet-ieee80211.h"
75 #include <epan/etypes.h>
76 #include <epan/greproto.h>
77 #include <epan/oui.h>
78 #include <epan/crc32.h>
79 #include <epan/tap.h>
80 #include <epan/emem.h>
81 #include <epan/crypt/wep-wpadefs.h>
82
83 #include <ctype.h>
84 #include "isprint.h"
85
86 #include "packet-wps.h"
87
88 #ifndef roundup2
89 #define roundup2(x, y)  (((x)+((y)-1))&(~((y)-1)))  /* if y is powers of two */
90 #endif
91
92 /* Defragment fragmented 802.11 datagrams */
93 static gboolean wlan_defragment = TRUE;
94
95 /* call subdissector for retransmitted frames */
96 static gboolean wlan_subdissector = TRUE;
97
98 /* Check for the presence of the 802.11 FCS */
99 static gboolean wlan_check_fcs = FALSE;
100
101 /* Ignore vendor-specific HT elements */
102 static gboolean wlan_ignore_draft_ht = FALSE;
103
104 /* Ignore the WEP bit; assume packet is decrypted */
105 #define WLAN_IGNORE_WEP_NO     0
106 #define WLAN_IGNORE_WEP_WO_IV  1
107 #define WLAN_IGNORE_WEP_W_IV   2
108 static gint wlan_ignore_wep = WLAN_IGNORE_WEP_NO;
109
110 /* Tables for reassembly of fragments. */
111 static GHashTable *wlan_fragment_table = NULL;
112 static GHashTable *wlan_reassembled_table = NULL;
113
114 /* Statistical data */
115 static struct _wlan_stats wlan_stats;
116
117 /* Stuff for the WEP decoder */
118 static gboolean enable_decryption = FALSE;
119 static void init_wepkeys(void);
120
121 #ifndef HAVE_AIRPDCAP
122 static gint num_wepkeys = 0;
123 static guint8 **wep_keys = NULL;
124 static int *wep_keylens = NULL;
125 static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len);
126 static int wep_decrypt(guint8 *buf, guint32 len, int key_override);
127 #else
128 /* Davide Schiera (2006-11-26): created function to decrypt WEP and WPA/WPA2  */
129 static tvbuff_t *try_decrypt(tvbuff_t *tvb, guint32 offset, guint32 len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer);
130 #endif
131
132 static int weak_iv(guchar *iv);
133 #define SSWAP(a,b) {guint8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;}
134
135 /* #define USE_ENV */
136 /* When this is set, an unlimited number of WEP keys can be set in the
137    environment:
138
139    WIRESHARK_WEPKEYNUM=##
140    WIRESHARK_WEPKEY1=aa:bb:cc:dd:...
141    WIRESHARK_WEPKEY2=aa:bab:cc:dd:ee:...
142
143    ... you get the idea.
144
145    otherwise you're limited to specifying four keys in the preference system.
146  */
147
148 #ifndef USE_ENV
149 static char *wep_keystr[MAX_ENCRYPTION_KEYS];
150 #endif
151
152 typedef struct mimo_control
153   {
154     guint8 nc;
155     guint8 nr;
156     gboolean chan_width;
157     guint8 grouping;
158     guint8 coefficient_size;
159     guint8 codebook_info;
160     guint8 remaining_matrix_segment;
161   } mimo_control_t;
162
163 mimo_control_t get_mimo_control (tvbuff_t *tvb, int offset);
164 int add_mimo_csi_matrices_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl);
165 int add_mimo_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl);
166 int add_mimo_compressed_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl);
167
168 /* ************************************************************************* */
169 /*                          Miscellaneous Constants                          */
170 /* ************************************************************************* */
171 #define SHORT_STR 256
172
173 /* ************************************************************************* */
174 /*  Define some very useful macros that are used to analyze frame types etc. */
175 /* ************************************************************************* */
176
177 /*
178  * Fetch the frame control field and swap it if needed.  "fcf" and "tvb"
179  * must be valid variables.
180  */
181 #define FETCH_FCF(off) (wlan_broken_fc ? \
182   BSWAP16(tvb_get_letohs(tvb, off)) : \
183   tvb_get_letohs(tvb, off))
184
185 /*
186  * Extract the protocol version from the frame control field
187  */
188 #define FCF_PROT_VERSION(x)  ((x) & 0x3)
189
190 /*
191  * Extract the frame type from the frame control field.
192  */
193 #define FCF_FRAME_TYPE(x)    (((x) & 0xC) >> 2)
194
195 /*
196  * Extract the frame subtype from the frame control field.
197  */
198 #define FCF_FRAME_SUBTYPE(x) (((x) & 0xF0) >> 4)
199
200 /*
201  * Convert the frame type and subtype from the frame control field into
202  * one of the MGT_, CTRL_, or DATA_ values.
203  */
204 #define COMPOSE_FRAME_TYPE(x) (((x & 0x0C)<< 2)+FCF_FRAME_SUBTYPE(x))  /* Create key to (sub)type */
205
206 /*
207  * The subtype field of a data frame is, in effect, composed of 4 flag
208  * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
209  * any data), and QoS.
210  */
211 #define DATA_FRAME_IS_CF_ACK(x)  ((x) & 0x01)
212 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
213 #define DATA_FRAME_IS_NULL(x)    ((x) & 0x04)
214 #define DATA_FRAME_IS_QOS(x)     ((x) & 0x08)
215
216 /*
217  * Extract the flags from the frame control field.
218  */
219 #define FCF_FLAGS(x)           (((x) & 0xFF00) >> 8)
220
221 /*
222  * Bits from the flags field.
223  */
224 #define FLAG_TO_DS            0x01
225 #define FLAG_FROM_DS          0x02
226 #define FLAG_MORE_FRAGMENTS   0x04
227 #define FLAG_RETRY            0x08
228 #define FLAG_POWER_MGT        0x10
229 #define FLAG_MORE_DATA        0x20
230 #define FLAG_PROTECTED        0x40
231 #define FLAG_ORDER            0x80
232
233 /*
234  * Test bits in the flags field.
235  */
236 /*
237  * XXX - Only HAVE_FRAGMENTS, IS_PROTECTED, and IS_STRICTLY_ORDERED
238  * are in use.  Should the rest be removed?
239  */
240 #define IS_TO_DS(x)            ((x) & FLAG_TO_DS)
241 #define IS_FROM_DS(x)          ((x) & FLAG_FROM_DS)
242 #define HAVE_FRAGMENTS(x)      ((x) & FLAG_MORE_FRAGMENTS)
243 #define IS_RETRY(x)            ((x) & FLAG_RETRY)
244 #define POWER_MGT_STATUS(x)    ((x) & FLAG_POWER_MGT)
245 #define HAS_MORE_DATA(x)       ((x) & FLAG_MORE_DATA)
246 #define IS_PROTECTED(x)        ((x) & FLAG_PROTECTED)
247 #define IS_STRICTLY_ORDERED(x) ((x) & FLAG_ORDER)
248
249 /*
250  * Extract subfields from the flags field.
251  */
252 #define FLAGS_DS_STATUS(x)          ((x) & (FLAG_FROM_DS|FLAG_TO_DS))
253
254 /*
255  * Extract an indication of the types of addresses in a data frame from
256  * the frame control field.
257  */
258 #define FCF_ADDR_SELECTOR(x) ((x) & ((FLAG_TO_DS|FLAG_FROM_DS) << 8))
259
260 #define DATA_ADDR_T1         0
261 #define DATA_ADDR_T2         (FLAG_FROM_DS << 8)
262 #define DATA_ADDR_T3         (FLAG_TO_DS << 8)
263 #define DATA_ADDR_T4         ((FLAG_TO_DS|FLAG_FROM_DS) << 8)
264
265 /*
266  * Extract the fragment number and sequence number from the sequence
267  * control field.
268  */
269 #define SEQCTL_FRAGMENT_NUMBER(x) ((x) & 0x000F)
270 #define SEQCTL_SEQUENCE_NUMBER(x) (((x) & 0xFFF0) >> 4)
271
272 /*
273  * Extract subfields from the QoS control field.
274  */
275 #define QOS_TID(x)            ((x) & 0x000F)
276 #define QOS_PRIORITY(x)       ((x) & 0x0007)
277 #define QOS_EOSP(x)           (((x) & 0x0010) >> 4) /* end of service period */
278 #define QOS_ACK_POLICY(x)     (((x) & 0x0060) >> 5)
279 #define QOS_AMSDU_PRESENT(x)  (((x) & 0x0080) >> 6)
280 #define QOS_FIELD_CONTENT(x)  (((x) & 0xFF00) >> 8)
281
282 #define QOS_FLAG_EOSP    0x10
283
284 /*
285  * Extract subfields from the result of QOS_FIELD_CONTENT().
286  */
287 #define QOS_PS_BUF_STATE(x)  (((x) & 0x02) >> 1)
288 #define QOS_PS_BUF_AC(x)     (((x) & 0x0C) >> 2)
289 #define QOS_PS_BUF_LOAD(x)   (((x) & 0xF0) >> 4)
290
291 /*
292  * Extract subfields from the HT Control field.
293  * .11n D-1.10 & D-2.0, 7.1.3.5a, 32 bits.
294  */
295 #define HTC_LAC(htc)           ((htc) & 0xFF)
296 #define HTC_LAC_MAI(htc)       (((htc) >> 2) & 0xF)
297 #define HTC_IS_ASELI(htc)      (HTC_LAC_MAI(htc) == 0xE)
298 #define HTC_LAC_MAI_MRQ(htc)   ((HTC_LAC_MAI(htc))  & 0x1)
299 #define HTC_LAC_MAI_MSI(htc)   ((HTC_LAC_MAI(htc) >> 1) & 0x7)
300 #define HTC_LAC_MFSI(htc)      (((htc) >> 4) & 0x7)
301 #define HTC_LAC_ASEL_CMD(htc)  (((htc) >> 9) & 0x7)
302 #define HTC_LAC_ASEL_DATA(htc) (((htc) >> 12) & 0xF)
303 #define HTC_LAC_MFB(htc)       (((htc) >> 9) & 0x7F)
304 #define HTC_CAL_POS(htc)       (((htc) >> 16) & 0x3)
305 #define HTC_CAL_SEQ(htc)       (((htc) >> 18) & 0x3)
306 #define HTC_CSI_STEERING(htc)  (((htc) >> 22) & 0x3)
307 #define HTC_NDP_ANN(htc)       (((htc) >> 24) & 0x1)
308 #define HTC_AC_CONSTRAINT(htc) (((htc) >> 30) & 0x1)
309 #define HTC_RDG_MORE_PPDU(htc) (((htc) >> 31) & 0x1)
310
311 /*
312  * Extract the association ID from the value in an association ID field.
313  */
314 #define ASSOC_ID(x)            ((x) & 0x3FFF)
315
316 /*
317  * Extract subfields from the key octet in WEP-encrypted frames.
318  */
319 #define KEY_OCTET_WEP_KEY(x)   (((x) & 0xC0) >> 6)
320
321 /*
322  * Extract subfields from TS Info field.
323  */
324 #define TSI_TYPE(x)      (((x) & 0x000001) >> 0)
325 #define TSI_TSID(x)      (((x) & 0x00001E) >> 1)
326 #define TSI_DIR(x)       (((x) & 0x000060) >> 5)
327 #define TSI_ACCESS(x)    (((x) & 0x000180) >> 7)
328 #define TSI_AGG(x)       (((x) & 0x000200) >> 9)
329 #define TSI_APSD(x)      (((x) & 0x000400) >> 10)
330 #define TSI_UP(x)        (((x) & 0x003800) >> 11)
331 #define TSI_ACK(x)       (((x) & 0x00C000) >> 14)
332 #define TSI_SCHED(x)     (((x) & 0x010000) >> 16)
333 #define TSI_RESERVED(x)  (((x) & 0xFE0000) >> 17)
334
335 #define KEY_EXTIV    0x20
336 #define EXTIV_LEN    8
337
338
339 /* ************************************************************************* */
340 /*              Constants used to identify cooked frame types                */
341 /* ************************************************************************* */
342 #define MGT_FRAME            0x00  /* Frame type is management */
343 #define CONTROL_FRAME        0x01  /* Frame type is control */
344 #define DATA_FRAME           0x02  /* Frame type is Data */
345
346 #define DATA_SHORT_HDR_LEN     24
347 #define DATA_LONG_HDR_LEN      30
348 #define MGT_FRAME_HDR_LEN      24  /* Length of Managment frame-headers */
349
350 /*
351  * COMPOSE_FRAME_TYPE() values for management frames.
352  */
353 #define MGT_ASSOC_REQ          0x00  /* association request        */
354 #define MGT_ASSOC_RESP         0x01  /* association response       */
355 #define MGT_REASSOC_REQ        0x02  /* reassociation request      */
356 #define MGT_REASSOC_RESP       0x03  /* reassociation response     */
357 #define MGT_PROBE_REQ          0x04  /* Probe request              */
358 #define MGT_PROBE_RESP         0x05  /* Probe response             */
359 #define MGT_MEASUREMENT_PILOT  0x06  /* Measurement Pilot          */
360 #define MGT_BEACON             0x08  /* Beacon frame               */
361 #define MGT_ATIM               0x09  /* ATIM                       */
362 #define MGT_DISASS             0x0A  /* Disassociation             */
363 #define MGT_AUTHENTICATION     0x0B  /* Authentication             */
364 #define MGT_DEAUTHENTICATION   0x0C  /* Deauthentication           */
365 #define MGT_ACTION             0x0D  /* Action                     */
366 #define MGT_ACTION_NO_ACK      0x0E  /* Action No Ack              */
367 #define MGT_ARUBA_WLAN         0x0F  /* Aruba WLAN Specific        */
368
369 /*
370  * COMPOSE_FRAME_TYPE() values for control frames.
371  */
372 #define CTRL_CONTROL_WRAPPER 0x17  /* Control Wrapper        */
373 #define CTRL_BLOCK_ACK_REQ   0x18  /* Block ack Request        */
374 #define CTRL_BLOCK_ACK       0x19  /* Block ack          */
375 #define CTRL_PS_POLL         0x1A  /* power-save poll               */
376 #define CTRL_RTS             0x1B  /* request to send               */
377 #define CTRL_CTS             0x1C  /* clear to send                 */
378 #define CTRL_ACKNOWLEDGEMENT 0x1D  /* acknowledgement               */
379 #define CTRL_CFP_END         0x1E  /* contention-free period end    */
380 #define CTRL_CFP_ENDACK      0x1F  /* contention-free period end/ack */
381
382 /*
383  * COMPOSE_FRAME_TYPE() values for data frames.
384  */
385 #define DATA                        0x20  /* Data                       */
386 #define DATA_CF_ACK                 0x21  /* Data + CF-Ack              */
387 #define DATA_CF_POLL                0x22  /* Data + CF-Poll             */
388 #define DATA_CF_ACK_POLL            0x23  /* Data + CF-Ack + CF-Poll    */
389 #define DATA_NULL_FUNCTION          0x24  /* Null function (no data)    */
390 #define DATA_CF_ACK_NOD             0x25  /* CF-Ack (no data)           */
391 #define DATA_CF_POLL_NOD            0x26  /* CF-Poll (No data)          */
392 #define DATA_CF_ACK_POLL_NOD        0x27  /* CF-Ack + CF-Poll (no data) */
393
394 #define DATA_QOS_DATA               0x28  /* QoS Data                   */
395 #define DATA_QOS_DATA_CF_ACK        0x29  /* QoS Data + CF-Ack        */
396 #define DATA_QOS_DATA_CF_POLL       0x2A  /* QoS Data + CF-Poll      */
397 #define DATA_QOS_DATA_CF_ACK_POLL   0x2B  /* QoS Data + CF-Ack + CF-Poll    */
398 #define DATA_QOS_NULL               0x2C  /* QoS Null        */
399 #define DATA_QOS_CF_POLL_NOD        0x2E  /* QoS CF-Poll (No Data)      */
400 #define DATA_QOS_CF_ACK_POLL_NOD    0x2F  /* QoS CF-Ack + CF-Poll (No Data) */
401
402
403 /* ************************************************************************* */
404 /*          Macros used to extract information about fixed fields            */
405 /* ************************************************************************* */
406 #define ESS_SET(x)  ((x) & 0x0001)
407 #define IBSS_SET(x) ((x) & 0x0002)
408
409
410
411 /* ************************************************************************* */
412 /*        Logical field codes (dissector's encoding of fixed fields)         */
413 /* ************************************************************************* */
414 #define FIELD_TIMESTAMP                 0x01  /* 64-bit timestamp                       */
415 #define FIELD_BEACON_INTERVAL           0x02  /* 16-bit beacon interval                 */
416 #define FIELD_CAP_INFO                  0x03  /* Add capability information tree        */
417 #define FIELD_AUTH_ALG                  0x04  /* Authentication algorithm used          */
418 #define FIELD_AUTH_TRANS_SEQ            0x05  /* Authentication sequence number         */
419 #define FIELD_CURRENT_AP_ADDR           0x06
420 #define FIELD_LISTEN_IVAL               0x07
421 #define FIELD_REASON_CODE               0x08
422 #define FIELD_ASSOC_ID                  0x09
423 #define FIELD_STATUS_CODE               0x0A
424 #define FIELD_CATEGORY_CODE             0x0B  /* Management action category */
425 #define FIELD_ACTION_CODE               0x0C  /* Management action code */
426 #define FIELD_DIALOG_TOKEN              0x0D  /* Management action dialog token */
427 #define FIELD_WME_ACTION_CODE           0x0E  /* Management notification action code */
428 #define FIELD_WME_DIALOG_TOKEN          0x0F  /* Management notification dialog token */
429 #define FIELD_WME_STATUS_CODE           0x10  /* Management notification setup response status code */
430 #define FIELD_QOS_ACTION_CODE           0x11
431 #define FIELD_QOS_TS_INFO               0x12
432 #define FIELD_DLS_ACTION_CODE           0x13
433 #define FIELD_DST_MAC_ADDR              0X14  /* DLS destination MAC address */
434 #define FIELD_SRC_MAC_ADDR              0X15  /* DLS source MAC address */
435 #define FIELD_DLS_TIMEOUT               0X16  /* DLS timeout value */
436 #define FIELD_SCHEDULE_INFO             0X17  /* Schedule Info field */
437 #define FIELD_ACTION                    0X18  /* Action field */
438 #define FIELD_BLOCK_ACK_ACTION_CODE     0x19
439 #define FIELD_QOS_INFO_AP               0x1A
440 #define FIELD_QOS_INFO_STA              0x1B
441 #define FIELD_BLOCK_ACK_PARAM           0x1C
442 #define FIELD_BLOCK_ACK_TIMEOUT         0x1D
443 #define FIELD_BLOCK_ACK_SSC             0x1E
444 #define FIELD_DELBA_PARAM_SET           0x1F
445 #define FIELD_MAX_REG_PWR               0x20
446 #define FIELD_MEASUREMENT_PILOT_INT     0x21
447 #define FIELD_COUNTRY_STR               0x22
448 #define FIELD_MAX_TX_PWR                0x23
449 #define FIELD_TX_PWR_USED               0x24
450 #define FIELD_TRANSCEIVER_NOISE_FLOOR   0x25
451 #define FIELD_DS_PARAM_SET              0x26
452 #define FIELD_CHANNEL_WIDTH             0x27
453 #define FIELD_SM_PWR_CNTRL              0x28
454 #define FIELD_PCO_PHASE_CNTRL           0x29
455 #define FIELD_PSMP_PARAM_SET            0x2A
456 #define FIELD_PSMP_STA_INFO             0x2B
457 #define FIELD_MIMO_CNTRL                0x2C
458 #define FIELD_ANT_SELECTION             0x2D
459 #define FIELD_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT 0x2E
460 #define FIELD_HT_INFORMATION            0x2F
461 #define FIELD_HT_ACTION_CODE            0x30
462
463 /* ************************************************************************* */
464 /*        Logical field codes (IEEE 802.11 encoding of tags)                 */
465 /* ************************************************************************* */
466 #define TAG_SSID                  0x00
467 #define TAG_SUPP_RATES            0x01
468 #define TAG_FH_PARAMETER          0x02
469 #define TAG_DS_PARAMETER          0x03
470 #define TAG_CF_PARAMETER          0x04
471 #define TAG_TIM                   0x05
472 #define TAG_IBSS_PARAMETER        0x06
473 #define TAG_COUNTRY_INFO          0x07
474 #define TAG_FH_HOPPING_PARAMETER  0x08
475 #define TAG_FH_HOPPING_TABLE      0x09
476 #define TAG_REQUEST               0x0A
477 #define TAG_QBSS_LOAD             0x0B
478 #define TAG_EDCA_PARAM_SET        0x0C
479 #define TAG_TSPEC                 0x0D
480 #define TAG_TCLAS                 0x0E
481 #define TAG_SCHEDULE              0x0F
482 #define TAG_CHALLENGE_TEXT        0x10
483 #define TAG_POWER_CONSTRAINT      0x20
484 #define TAG_POWER_CAPABILITY      0x21
485 #define TAG_TPC_REQUEST           0x22
486 #define TAG_TPC_REPORT            0x23
487 #define TAG_SUPPORTED_CHANNELS    0x24
488 #define TAG_CHANNEL_SWITCH_ANN    0x25
489 #define TAG_MEASURE_REQ           0x26
490 #define TAG_MEASURE_REP           0x27
491 #define TAG_QUIET                 0x28
492 #define TAG_IBSS_DFS              0x29
493 #define TAG_ERP_INFO              0x2A
494 #define TAG_TS_DELAY              0x2B
495 #define TAG_TCLAS_PROCESS         0x2C
496 #define TAG_HT_CAPABILITY         0x2D  /* IEEE Stc 802.11n/D2.0 */
497 #define TAG_QOS_CAPABILITY        0x2E
498 #define TAG_ERP_INFO_OLD          0x2F  /* IEEE Std 802.11g/D4.0 */
499 #define TAG_RSN_IE                0x30
500 /* Reserved 49 */
501 #define TAG_EXT_SUPP_RATES        0x32
502 #define TAG_NEIGHBOR_REPORT       0x34
503 #define TAG_HT_INFO               0x3D  /* IEEE Stc 802.11n/D2.0 */
504 #define TAG_SECONDARY_CHANNEL_OFFSET 0x3E  /* IEEE Stc 802.11n/D1.10/D2.0 */
505 #define TAG_WSIE                         0x45   /* tag of the Wave Service Information (802.11p) */
506 #define TAG_20_40_BSS_CO_EX          0x48   /* IEEE P802.11n/D6.0 */
507 #define TAG_20_40_BSS_INTOL_CH_REP   0x49   /* IEEE P802.11n/D6.0 */
508 #define TAG_OVERLAP_BSS_SCAN_PAR     0x49   /* IEEE P802.11n/D6.0 */
509 #define TAG_EXTENDED_CAPABILITIES    0X7F   /* IEEE Stc 802.11n/D1.10/D2.0 */
510 #define TAG_AGERE_PROPRIETARY        0x80
511 #define TAG_CISCO_UNKNOWN_1          0x85  /* Cisco Compatible eXtensions */
512 #define TAG_CISCO_UNKNOWN_2          0x88  /* Cisco Compatible eXtensions? */
513 #define TAG_CISCO_UNKNOWN_3          0x95  /* Cisco Compatible eXtensions */
514 #define TAG_VENDOR_SPECIFIC_IE       0xDD
515 #define TAG_SYMBOL_PROPRIETARY       0xAD
516 #if 0 /* Not yet assigned tag numbers by ANA */
517 #define TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT    0xFF
518 #define TAG_SUPPORTED_REGULATORY_CLASSES            0xFE
519 #endif
520
521 #define WPA_OUI     (const guint8 *) "\x00\x50\xF2"
522 #define RSN_OUI     (const guint8 *) "\x00\x0F\xAC"
523 #define WME_OUI     (const guint8 *) "\x00\x50\xF2"
524 #define PRE_11N_OUI (const guint8 *) "\x00\x90\x4c" /* 802.11n pre 1 oui */
525
526 #define PMKID_LEN 16
527
528 /* ************************************************************************* */
529 /*              Wireless Access in Vehicular Environment  IEEE 802.11p       */
530 /* ************************************************************************* */
531 #define WAVE_ACID       0x0001
532 #define WAVE_ACM        0x0002
533 #define WAVE_ACF        0x0004
534 #define WAVE_PRIORITY   0x0008
535 #define WAVE_CHANNEL    0x0010
536 #define WAVE_IPV6ADDR   0x0020
537 #define WAVE_PEERMAC    0x0040
538
539
540
541 /* ************************************************************************* */
542 /*                         Frame types, and their names                      */
543 /* ************************************************************************* */
544 static const value_string frame_type_subtype_vals[] = {
545   {MGT_ASSOC_REQ,        "Association Request"},
546   {MGT_ASSOC_RESP,       "Association Response"},
547   {MGT_REASSOC_REQ,      "Reassociation Request"},
548   {MGT_REASSOC_RESP,     "Reassociation Response"},
549   {MGT_PROBE_REQ,        "Probe Request"},
550   {MGT_PROBE_RESP,       "Probe Response"},
551   {MGT_MEASUREMENT_PILOT,"Measurement Pilot"},
552   {MGT_BEACON,           "Beacon frame"},
553   {MGT_ATIM,             "ATIM"},
554   {MGT_DISASS,           "Disassociate"},
555   {MGT_AUTHENTICATION,   "Authentication"},
556   {MGT_DEAUTHENTICATION, "Deauthentication"},
557   {MGT_ACTION,           "Action"},
558   {MGT_ACTION_NO_ACK,    "Action No Ack"},
559   {MGT_ARUBA_WLAN,       "Aruba Management"},
560
561   {CTRL_CONTROL_WRAPPER, "Control Wrapper"},
562   {CTRL_BLOCK_ACK_REQ,   "802.11 Block Ack Req"},
563   {CTRL_BLOCK_ACK,       "802.11 Block Ack"},
564   {CTRL_PS_POLL,         "Power-Save poll"},
565   {CTRL_RTS,             "Request-to-send"},
566   {CTRL_CTS,             "Clear-to-send"},
567   {CTRL_ACKNOWLEDGEMENT, "Acknowledgement"},
568   {CTRL_CFP_END,         "CF-End (Control-frame)"},
569   {CTRL_CFP_ENDACK,      "CF-End + CF-Ack (Control-frame)"},
570
571   {DATA,                      "Data"},
572   {DATA_CF_ACK,               "Data + CF-Ack"},
573   {DATA_CF_POLL,              "Data + CF-Poll"},
574   {DATA_CF_ACK_POLL,          "Data + CF-Ack + CF-Poll"},
575   {DATA_NULL_FUNCTION,        "Null function (No data)"},
576   {DATA_CF_ACK_NOD,           "Acknowledgement (No data)"},
577   {DATA_CF_POLL_NOD,          "CF-Poll (No data)"},
578   {DATA_CF_ACK_POLL_NOD,      "CF-Ack/Poll (No data)"},
579   {DATA_QOS_DATA,             "QoS Data"},
580   {DATA_QOS_DATA_CF_ACK,      "QoS Data + CF-Acknowledgment"},
581   {DATA_QOS_DATA_CF_POLL,     "QoS Data + CF-Poll"},
582   {DATA_QOS_DATA_CF_ACK_POLL, "QoS Data + CF-Ack + CF-Poll"},
583   {DATA_QOS_NULL,             "QoS Null function (No data)"},
584   {DATA_QOS_CF_POLL_NOD,      "QoS CF-Poll (No Data)"},
585   {DATA_QOS_CF_ACK_POLL_NOD,  "QoS CF-Ack + CF-Poll (No data)"},
586   {0,                         NULL}
587 };
588
589 /* ************************************************************************* */
590 /*                             802.1D Tag Names                              */
591 /* ************************************************************************* */
592 static const char *qos_tags[8] = {
593   "Best Effort",
594   "Background",
595   "Spare",
596   "Excellent Effort",
597   "Controlled Load",
598   "Video",
599   "Voice",
600   "Network Control"
601 };
602
603 /* ************************************************************************* */
604 /*                 WME Access Category Names (by 802.1D Tag)                 */
605 /* ************************************************************************* */
606 static const char *qos_acs[8] = {
607   "Best Effort",
608   "Background",
609   "Background",
610   "Video",
611   "Video",
612   "Video",
613   "Voice",
614   "Voice"
615 };
616
617 /* ************************************************************************* */
618 /*                   WME Access Category Names (by WME ACI)                  */
619 /* ************************************************************************* */
620 static const char *wme_acs[4] = {
621   "Best Effort",
622   "Background",
623   "Video",
624   "Voice",
625 };
626
627 /* ************************************************************************* */
628 /*                  Aruba Management Type                                    */
629 /* ************************************************************************* */
630 static const value_string aruba_mgt_typevals[] = {
631   { 0x0001,       "Hello" },
632   { 0x0002,       "Probe" },
633   { 0x0003,       "MTU" },
634   { 0x0004,       "Ageout" },
635   { 0x0005,       "Heartbeat" },
636   { 0x0006,       "Deauth" },
637   { 0x0007,       "Disassoc" },
638   { 0x0008,       "Probe response" },
639   { 0x0009,       "Tunnel update" },
640   { 0x000A,       "Laser beam active" },
641   { 0x000B,       "Client IP" },
642   { 0x000C,       "Laser beam active v2" },
643   { 0x000D,       "AP statistics" },
644   { 0,            NULL }
645 };
646
647 /*** Begin: Action Fixed Parameter ***/
648 #define CAT_SPECTRUM_MGMT      0
649 #define CAT_QOS                1
650 #define CAT_DLS                2
651 #define CAT_BLOCK_ACK          3
652
653 #define CAT_RADIO_MEASUREMENT   6
654 #define CAT_HT                  7
655 #define CAT_MGMT_NOTIFICATION   17
656 #define CAT_VENDOR_SPECIFIC     127
657
658 #define SM_ACTION_MEASUREMENT_REQUEST   0
659 #define SM_ACTION_MEASUREMENT_REPORT    1
660 #define SM_ACTION_TPC_REQUEST           2
661 #define SM_ACTION_TPC_REPORT            3
662 #define SM_ACTION_CHAN_SWITCH_ANNC      4
663 #define SM_ACTION_EXT_CHAN_SWITCH_ANNC  5
664
665 #define SM_ACTION_ADDTS_REQUEST     0
666 #define SM_ACTION_ADDTS_RESPONSE    1
667 #define SM_ACTION_DELTS             2
668 #define SM_ACTION_QOS_SCHEDULE      3
669
670 #define SM_ACTION_DLS_REQUEST       0
671 #define SM_ACTION_DLS_RESPONSE      1
672 #define SM_ACTION_DLS_TEARDOWN      2
673
674 #define BA_ADD_BLOCK_ACK_REQUEST    0
675 #define BA_ADD_BLOCK_ACK_RESPONSE   1
676 #define BA_DELETE_BLOCK_ACK         2
677
678 #define HT_ACTION_NOTIFY_CHAN_WIDTH           0
679 #define HT_ACTION_SM_PWR_SAVE                 1
680 #define HT_ACTION_PSMP_ACTION                 2
681 #define HT_ACTION_SET_PCO_PHASE               3
682 #define HT_ACTION_MIMO_CSI                    4
683 #define HT_ACTION_MIMO_BEAMFORMING            5
684 #define HT_ACTION_MIMO_COMPRESSED_BEAMFORMING 6
685 #define HT_ACTION_ANT_SEL_FEEDBACK            7
686 #define HT_ACTION_HT_INFO_EXCHANGE            8
687 /* Vendor actions */
688 /* MARVELL */
689 #define MRVL_ACTION_MESH_MANAGEMENT     1
690
691 #define MRVL_MESH_MGMT_ACTION_RREQ      0
692 #define MRVL_MESH_MGMT_ACTION_RREP      1
693 #define MRVL_MESH_MGMT_ACTION_RERR      2
694 #define MRVL_MESH_MGMT_ACTION_PLDM      3
695
696 /*** End: Action Fixed Parameter ***/
697
698 static int proto_wlan = -1;
699 static int proto_aggregate = -1;
700 static packet_info * g_pinfo;
701
702 static int proto_radio = -1;
703 static int proto_wlancap = -1;
704 static int proto_prism = -1;
705
706 /* ************************************************************************* */
707 /*                Header field info values for radio information             */
708 /* ************************************************************************* */
709 static int hf_mactime = -1;
710 static int hf_hosttime = -1;
711 static int hf_data_rate = -1;
712 static int hf_channel = -1;
713 static int hf_channel_frequency = -1;
714 static int hf_normrssi_antsignal = -1;
715 static int hf_dbm_antsignal = -1;
716 static int hf_rawrssi_antsignal = -1;
717 static int hf_normrssi_antnoise = -1;
718 static int hf_dbm_antnoise = -1;
719 static int hf_rawrssi_antnoise = -1;
720 static int hf_signal_strength = -1;
721
722 /* Prism radio header */
723 static int hf_prism_msgcode = -1;
724 static int hf_prism_msglen = -1;
725 static int hf_prism_rssi_data = -1;
726 static int hf_prism_sq_data = -1;
727 static int hf_prism_signal_data = -1;
728 static int hf_prism_noise_data = -1;
729 static int hf_prism_rate_data = -1;
730 static int hf_prism_istx_data = -1;
731 static int hf_prism_frmlen_data = -1;
732
733 /* AVS WLANCAP radio header */
734 static int hf_wlan_magic = -1;
735 static int hf_wlan_version = -1;
736 static int hf_wlan_length = -1;
737 static int hf_wlan_phytype = -1;
738 static int hf_wlan_antenna = -1;
739 static int hf_wlan_priority = -1;
740 static int hf_wlan_ssi_type = -1;
741 static int hf_wlan_ssi_signal = -1;
742 static int hf_wlan_ssi_noise = -1;
743 static int hf_wlan_preamble = -1;
744 static int hf_wlan_encoding = -1;
745 static int hf_wlan_sequence = -1;
746 static int hf_wlan_drops = -1;
747 static int hf_wlan_receiver_addr = -1;
748 static int hf_wlan_padding = -1;
749
750 /* ************************************************************************* */
751 /*                Header field info values for FC-field                      */
752 /* ************************************************************************* */
753 static int hf_fc_field = -1;
754 static int hf_fc_proto_version = -1;
755 static int hf_fc_frame_type = -1;
756 static int hf_fc_frame_subtype = -1;
757 static int hf_fc_frame_type_subtype = -1;
758
759 static int hf_fc_flags = -1;
760 static int hf_fc_to_ds = -1;
761 static int hf_fc_from_ds = -1;
762 static int hf_fc_data_ds = -1;
763
764 static int hf_fc_more_frag = -1;
765 static int hf_fc_retry = -1;
766 static int hf_fc_pwr_mgt = -1;
767 static int hf_fc_more_data = -1;
768 static int hf_fc_protected = -1;
769 static int hf_fc_order = -1;
770
771 typedef struct retransmit_key {
772         guint8  bssid[6];
773         guint8  src[6];
774         guint16 seq_control;
775         guint   fnum;
776 } retransmit_key;
777
778 static GHashTable *fc_analyse_retransmit_table = NULL;
779 static GHashTable *fc_first_frame_table = NULL;
780
781 static int hf_fc_analysis_retransmission = -1;
782 static int hf_fc_analysis_retransmission_frame = -1;
783
784 /* ************************************************************************* */
785 /*                   Header values for Duration/ID field                     */
786 /* ************************************************************************* */
787 static int hf_did_duration = -1;
788 static int hf_assoc_id = -1;
789
790
791 /* ************************************************************************* */
792 /*         Header values for different address-fields (all 4 of them)        */
793 /* ************************************************************************* */
794 static int hf_addr_da = -1;  /* Destination address subfield */
795 static int hf_addr_sa = -1;  /* Source address subfield */
796 static int hf_addr_ra = -1;  /* Receiver address subfield */
797 static int hf_addr_ta = -1;  /* Transmitter address subfield */
798 static int hf_addr_addr1 = -1;
799 static int hf_addr_bssid = -1;  /* address is bssid */
800
801 static int hf_addr = -1;  /* Source or destination address subfield */
802
803
804 /* ************************************************************************* */
805 /*                Header values for QoS control field                        */
806 /* ************************************************************************* */
807 static int hf_qos_priority = -1;
808 static int hf_qos_ack_policy = -1;
809 static int hf_qos_amsdu_present = -1;
810 static int hf_qos_eosp = -1;
811 static int hf_qos_field_content = -1;
812 /*static int hf_qos_txop_limit = -1;*/
813 /*  FIXME: hf_ values not defined
814 static int hf_qos_buf_state = -1;
815 static int hf_qos_buf_ac = -1;
816 static int hf_qos_buf_load = -1;
817 */
818 /*static int hf_qos_txop_dur_req = -1;
819 static int hf_qos_queue_size = -1;*/
820
821 /* ************************************************************************* */
822 /*                Header values for HT control field (+HTC)                  */
823 /* ************************************************************************* */
824 /* 802.11nD-1.10 & 802.11nD-2.0 7.1.3.5a */
825 static int hf_htc = -1;
826 static int hf_htc_lac = -1;
827 static int hf_htc_lac_reserved = -1;
828 static int hf_htc_lac_trq = -1;
829 static int hf_htc_lac_mai_aseli = -1;
830 static int hf_htc_lac_mai_mrq = -1;
831 static int hf_htc_lac_mai_msi = -1;
832 static int hf_htc_lac_mai_reserved = -1;
833 static int hf_htc_lac_mfsi = -1;
834 static int hf_htc_lac_mfb = -1;
835 static int hf_htc_lac_asel_command = -1;
836 static int hf_htc_lac_asel_data = -1;
837 static int hf_htc_cal_pos = -1;
838 static int hf_htc_cal_seq = -1;
839 static int hf_htc_reserved1 = -1;
840 static int hf_htc_csi_steering = -1;
841 static int hf_htc_ndp_announcement = -1;
842 static int hf_htc_reserved2 = -1;
843 static int hf_htc_ac_constraint = -1;
844 static int hf_htc_rdg_more_ppdu = -1;
845
846 /* ************************************************************************* */
847 /*                Header values for sequence number field                    */
848 /* ************************************************************************* */
849 static int hf_frag_number = -1;
850 static int hf_seq_number = -1;
851
852 /* ************************************************************************* */
853 /*                   Header values for Frame Check field                     */
854 /* ************************************************************************* */
855 static int hf_fcs = -1;
856 static int hf_fcs_good = -1;
857 static int hf_fcs_bad = -1;
858
859 /* ************************************************************************* */
860 /*                   Header values for reassembly                            */
861 /* ************************************************************************* */
862 static int hf_fragments = -1;
863 static int hf_fragment = -1;
864 static int hf_fragment_overlap = -1;
865 static int hf_fragment_overlap_conflict = -1;
866 static int hf_fragment_multiple_tails = -1;
867 static int hf_fragment_too_long_fragment = -1;
868 static int hf_fragment_error = -1;
869 static int hf_reassembled_in = -1;
870
871
872 static int proto_wlan_mgt = -1;
873
874 /* ************************************************************************* */
875 /*                   Header values for WAVE                                  */
876 /* ************************************************************************* */
877 static int hf_pst_timingquality = -1;
878 static int hf_pst_providercount = -1;
879 static int hf_pst_length = -1;
880 static int hf_pst_contents = -1;
881
882 static int hf_pst_acid =        -1;
883 static int hf_pst_acm_length =  -1;
884 static int hf_pst_acm = -1;
885 static int hf_pst_acm_contents =-1;
886 static int hf_pst_acf =         -1;
887 static int hf_pst_priority =    -1;
888 static int hf_pst_ipv6addr =    -1;
889 static int hf_pst_serviceport = -1;
890 static int hf_pst_addressing =  -1;
891 static int hf_pst_macaddr =     -1;
892 static int hf_pst_channel =     -1;
893
894 static int hf_chan_noc = -1;
895 static int hf_chan_length = -1;
896 static int hf_chan_content =    -1;
897 static int hf_chan_channel =    -1;
898 static int hf_chan_adapt   =    -1;
899 static int hf_chan_rate    =    -1;
900 static int hf_chan_tx_pow  =    -1;
901
902 /* ************************************************************************* */
903 /*                      Fixed fields found in mgt frames                     */
904 /* ************************************************************************* */
905 static int ff_auth_alg = -1;  /* Authentication algorithm field            */
906 static int ff_auth_seq = -1;  /* Authentication transaction sequence       */
907 static int ff_current_ap = -1;  /* Current AP MAC address                    */
908 static int ff_listen_ival = -1;  /* Listen interval fixed field               */
909 static int ff_timestamp = -1;  /* 64 bit timestamp                          */
910 static int ff_beacon_interval = -1;  /* 16 bit Beacon interval            */
911 static int ff_assoc_id = -1;  /* 16 bit AID field                          */
912 static int ff_reason = -1;  /* 16 bit reason code                        */
913 static int ff_status_code = -1;  /* Status code                               */
914 static int ff_category_code = -1;  /* 8 bit Category code */
915 static int ff_action_code = -1;    /* 8 bit Action code */
916 static int ff_dialog_token = -1;  /* 8 bit Dialog token */
917 static int ff_wme_action_code = -1;  /* Management notification action code */
918 static int ff_wme_status_code = -1;  /* Management notification setup response status code */
919 static int ff_qos_action_code = -1;
920 static int ff_dls_action_code = -1;
921 static int ff_dst_mac_addr = -1;  /* DLS destination MAC addressi */
922 static int ff_src_mac_addr = -1;  /* DLS source MAC addressi */
923 static int ff_dls_timeout = -1;    /* DLS timeout value */
924
925 /* Vendor specific */
926 static int ff_marvell_action_type = -1;
927 static int ff_marvell_mesh_mgt_action_code = -1;
928 static int ff_mesh_mgt_length = -1;     /* Mesh Management length */
929 static int ff_mesh_mgt_mode = -1;       /* Mesh Management mode */
930 static int ff_mesh_mgt_ttl = -1;        /* Mesh Management TTL */
931 static int ff_mesh_mgt_dstcount = -1;   /* Mesh Management dst count */
932 static int ff_mesh_mgt_hopcount = -1;   /* Mesh Management hop count */
933 static int ff_mesh_mgt_rreqid = -1;     /* Mesh Management RREQ ID */
934 static int ff_mesh_mgt_sa = -1;         /* Mesh Management src addr */
935 static int ff_mesh_mgt_ssn = -1;        /* Mesh Management src sequence number */
936 static int ff_mesh_mgt_metric = -1;     /* Mesh Management metric */
937 static int ff_mesh_mgt_flags = -1;      /* Mesh Management RREQ flags */
938 static int ff_mesh_mgt_da = -1;         /* Mesh Management dst addr */
939 static int ff_mesh_mgt_dsn = -1;        /* Mesh Management dst sequence number */
940 static int ff_mesh_mgt_lifetime = -1;   /* Mesh Management lifetime */
941
942
943 /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
944 static int ff_ba_action = -1;
945 /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
946
947 /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
948 static int ff_block_ack_params = -1;
949 static int ff_block_ack_params_amsdu_permitted = -1;
950 static int ff_block_ack_params_policy = -1;
951 static int ff_block_ack_params_tid = -1;
952 static int ff_block_ack_params_buffer_size = -1;
953 /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
954
955 /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
956 static int ff_block_ack_timeout = -1;
957 /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
958
959 /*** Begin: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
960 static int ff_block_ack_ssc = -1;
961 static int ff_block_ack_ssc_fragment = -1;
962 static int ff_block_ack_ssc_sequence = -1;
963 /*** End: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
964
965 /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
966 static int ff_delba_param = -1;
967 static int ff_delba_param_reserved = -1;
968 static int ff_delba_param_init = -1;
969 static int ff_delba_param_tid = -1;
970 /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
971
972 /*** Begin: Max Regulation Power Fixed Field - Dustin Johnson ***/
973 static int ff_max_reg_pwr = -1;
974 /*** End: Max Regulation Power Fixed Field - Dustin Johnson ***/
975
976 /*** Begin: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
977 static int ff_measurement_pilot_int = -1;
978 /*** End: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
979
980 /*** Begin: Country String Fixed Field - Dustin Johnson ***/
981 static int ff_country_str = -1;
982 /*** End: Country String Fixed Field - Dustin Johnson ***/
983
984 /*** Begin: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
985 static int ff_max_tx_pwr = -1;
986 /*** End: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
987
988 /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
989 static int ff_tx_pwr_used = -1;
990 /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
991
992 /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
993 static int ff_transceiver_noise_floor = -1;
994 /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
995
996 /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
997 static int ff_channel_width = -1;
998 /*** End: Channel Width Fixed Field - Dustin Johnson ***/
999
1000 /*** Begin: QoS Information AP Fixed Field - Dustin Johnson ***/
1001 static int ff_qos_info_ap = -1;
1002 static int ff_qos_info_ap_edca_param_set_counter = -1;
1003 static int ff_qos_info_ap_q_ack = -1;
1004 static int ff_qos_info_ap_queue_req = -1;
1005 static int ff_qos_info_ap_txop_request = -1;
1006 static int ff_qos_info_ap_reserved = -1;
1007 /*** End: QoS Information AP Fixed Field - Dustin Johnson ***/
1008
1009 /*** Begin: QoS Information STA Fixed Field - Dustin Johnson ***/
1010 static int ff_qos_info_sta = -1;
1011 static int ff_qos_info_sta_ac_vo = -1;
1012 static int ff_qos_info_sta_ac_vi = -1;
1013 static int ff_qos_info_sta_ac_bk = -1;
1014 static int ff_qos_info_sta_ac_be = -1;
1015 static int ff_qos_info_sta_q_ack = -1;
1016 static int ff_qos_info_sta_max_sp_len = -1;
1017 static int ff_qos_info_sta_more_data_ack = -1;
1018 /*** End: QoS Information STA Fixed Field - Dustin Johnson ***/
1019
1020 /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1021 static int ff_sm_pwr_save = -1;
1022 static int ff_sm_pwr_save_enabled = -1;
1023 static int ff_sm_pwr_save_sm_mode = -1;
1024 static int ff_sm_pwr_save_reserved = -1;
1025 /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1026
1027 /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
1028 static int ff_pco_phase_cntrl = -1;
1029 /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
1030
1031 /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1032 static int ff_psmp_param_set = -1;
1033 static int ff_psmp_param_set_n_sta = -1;
1034 static int ff_psmp_param_set_more_psmp = -1;
1035 static int ff_psmp_param_set_psmp_sequence_duration = -1;
1036 /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1037
1038 /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
1039 static int ff_mimo_cntrl_nc_index = -1;
1040 static int ff_mimo_cntrl_nr_index = -1;
1041 static int ff_mimo_cntrl_channel_width = -1;
1042 static int ff_mimo_cntrl_grouping = -1;
1043 static int ff_mimo_cntrl_coefficient_size = -1;
1044 static int ff_mimo_cntrl_codebook_info = -1;
1045 static int ff_mimo_cntrl_remaining_matrix_segment = -1;
1046 static int ff_mimo_cntrl_reserved = -1;
1047 static int ff_mimo_cntrl_sounding_timestamp = -1;
1048 /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
1049
1050 /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
1051 static int ff_ant_selection = -1;
1052 static int ff_ant_selection_0 = -1;
1053 static int ff_ant_selection_1 = -1;
1054 static int ff_ant_selection_2 = -1;
1055 static int ff_ant_selection_3 = -1;
1056 static int ff_ant_selection_4 = -1;
1057 static int ff_ant_selection_5 = -1;
1058 static int ff_ant_selection_6 = -1;
1059 static int ff_ant_selection_7 = -1;
1060 /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
1061
1062 /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1063 static int ff_ext_channel_switch_announcement = -1;
1064 /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1065
1066 /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
1067 static int ff_ht_info = -1;
1068 static int ff_ht_info_information_request = -1;
1069 static int ff_ht_info_40_mhz_intolerant = -1;
1070 static int ff_ht_info_sta_chan_width = -1;
1071 static int ff_ht_info_reserved = -1;
1072 /*** End: HT Information Fixed Field - Dustin Johnson ***/
1073
1074 /*** Begin: HT Action Fixed Field - Dustin Johnson ***/
1075 static int ff_ht_action = -1;
1076 /*** End: HT Action Fixed Field - Dustin Johnson ***/
1077
1078 /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
1079 static int ff_psmp_sta_info = -1;
1080 static int ff_psmp_sta_info_dtt_start_offset = -1;
1081 static int ff_psmp_sta_info_dtt_duration = -1;
1082 static int ff_psmp_sta_info_sta_id = -1;
1083 static int ff_psmp_sta_info_utt_start_offset = -1;
1084 static int ff_psmp_sta_info_utt_duration = -1;
1085 static int ff_psmp_sta_info_reserved_small= -1;
1086 static int ff_psmp_sta_info_reserved_large = -1;
1087 static int ff_psmp_sta_info_psmp_multicast_id = -1;
1088 /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
1089
1090 /*** Begin: MIMO CSI Matrices Report - Dustin Johnson ***/
1091 static int ff_mimo_csi_snr = -1;
1092 /*** End: MIMO CSI Matrices Report - Dustin Johnson ***/
1093
1094 /* ************************************************************************* */
1095 /*            Flags found in the capability field (fixed field)              */
1096 /* ************************************************************************* */
1097 static int ff_capture = -1;
1098 static int ff_cf_ess = -1;
1099 static int ff_cf_ibss = -1;
1100 static int ff_cf_sta_poll = -1; /* CF pollable status for a STA            */
1101 static int ff_cf_ap_poll = -1;  /* CF pollable status for an AP            */
1102 static int ff_cf_privacy = -1;
1103 static int ff_cf_preamble = -1;
1104 static int ff_cf_pbcc = -1;
1105 static int ff_cf_agility = -1;
1106 static int ff_short_slot_time = -1;
1107 static int ff_dsss_ofdm = -1;
1108 static int ff_cf_spec_man = -1;
1109 static int ff_cf_apsd = -1;
1110 static int ff_cf_del_blk_ack = -1;
1111 static int ff_cf_imm_blk_ack = -1;
1112
1113 /* ************************************************************************* */
1114 /*                       A-MSDU fields                                             */
1115 /* ************************************************************************* */
1116 static int amsdu_msdu_header_text = -1;
1117
1118
1119 /* ************************************************************************* */
1120 /*                       Tagged value format fields                          */
1121 /* ************************************************************************* */
1122 static int tag_number = -1;
1123 static int tag_length = -1;
1124 static int tag_interpretation = -1;
1125 static int tag_oui = -1;
1126
1127
1128 static int tim_length = -1;
1129 static int tim_dtim_count = -1;
1130 static int tim_dtim_period = -1;
1131 static int tim_bmapctl = -1;
1132
1133
1134 static int hf_fixed_parameters = -1;  /* Protocol payload for management frames */
1135 static int hf_tagged_parameters = -1;  /* Fixed payload item */
1136 static int hf_tagged_ssid = -1;
1137 static int hf_wep_iv = -1;
1138 static int hf_wep_iv_weak = -1;
1139 static int hf_tkip_extiv = -1;
1140 static int hf_ccmp_extiv = -1;
1141 static int hf_wep_key = -1;
1142 static int hf_wep_icv = -1;
1143
1144 /*** Begin: Block Ack Request/Block Ack  - Dustin Johnson***/
1145 static int hf_block_ack_request_control = -1;
1146 static int hf_block_ack_control = -1;
1147 static int hf_block_ack_control_ack_policy = -1;
1148 static int hf_block_ack_control_multi_tid = -1;
1149 static int hf_block_ack_control_compressed_bitmap = -1;
1150 static int hf_block_ack_control_reserved = -1;
1151
1152 static int hf_block_ack_control_basic_tid_info = -1;
1153 static int hf_block_ack_control_compressed_tid_info = -1;
1154 static int hf_block_ack_control_multi_tid_info = -1;
1155
1156 static int hf_tag_measure_request_measurement_mode = -1;
1157 static int hf_tag_measure_request_bssid = -1;
1158 static int hf_tag_measure_request_reporting_condition = -1;
1159 static int hf_tag_measure_request_threshold_offset_unsigned = -1;
1160 static int hf_tag_measure_request_threshold_offset_signed = -1;
1161
1162 static int hf_tag_measure_request_report_mac = -1;
1163
1164 static int hf_tag_measure_request_group_id = -1;
1165
1166 static int hf_block_ack_multi_tid_info = -1;
1167 static int hf_block_ack_request_type = -1;
1168 static int hf_block_ack_multi_tid_reserved = -1;
1169 static int hf_block_ack_multi_tid_value = -1;
1170 static int hf_block_ack_type = -1;
1171 /*** End: Block Ack Request/Block Ack  - Dustin Johnson***/
1172
1173 static int ht_cap = -1;
1174 static int ht_vs_cap = -1;
1175 static int ht_ldpc_coding = -1;
1176 static int ht_chan_width = -1;
1177 static int ht_sm_pwsave = -1;
1178 static int ht_green = -1;
1179 static int ht_short20 = -1;
1180 static int ht_short40 = -1;
1181 static int ht_tx_stbc = -1;
1182 static int ht_rx_stbc = -1;
1183 static int ht_delayed_block_ack = -1;
1184 static int ht_max_amsdu = -1;
1185 static int ht_dss_cck_40 = -1;
1186 static int ht_psmp = -1;
1187 static int ht_40_mhz_intolerant = -1;
1188 static int ht_l_sig = -1;
1189
1190 static int ampduparam = -1;
1191 static int ampduparam_vs = -1;
1192 static int ampduparam_mpdu = -1;
1193 static int ampduparam_mpdu_start_spacing = -1;
1194 static int ampduparam_reserved = -1;
1195
1196 static int mcsset = -1;
1197 static int mcsset_vs = -1;
1198 static int mcsset_rx_bitmask_0to7 = -1;
1199 static int mcsset_rx_bitmask_8to15 = -1;
1200 static int mcsset_rx_bitmask_16to23 = -1;
1201 static int mcsset_rx_bitmask_24to31 = -1;
1202 static int mcsset_rx_bitmask_32 = -1;
1203 static int mcsset_rx_bitmask_33to38 = -1;
1204 static int mcsset_rx_bitmask_39to52 = -1;
1205 static int mcsset_rx_bitmask_53to76 = -1;
1206 static int mcsset_highest_data_rate = -1;
1207 static int mcsset_tx_mcs_set_defined = -1;
1208 static int mcsset_tx_rx_mcs_set_not_equal = -1;
1209 static int mcsset_tx_max_spatial_streams = -1;
1210 static int mcsset_tx_unequal_modulation = -1;
1211
1212 static int htex_cap = -1;
1213 static int htex_vs_cap = -1;
1214 static int htex_pco = -1;
1215 static int htex_transtime = -1;
1216 static int htex_mcs = -1;
1217 static int htex_htc_support = -1;
1218 static int htex_rd_responder = -1;
1219
1220 static int txbf = -1;
1221 static int txbf_vs = -1;
1222 static int txbf_cap = -1;
1223 static int txbf_rcv_ssc = -1;
1224 static int txbf_tx_ssc = -1;
1225 static int txbf_rcv_ndp = -1;
1226 static int txbf_tx_ndp = -1;
1227 static int txbf_impl_txbf = -1;
1228 static int txbf_calib = -1;
1229 static int txbf_expl_csi = -1;
1230 static int txbf_expl_uncomp_fm = -1;
1231 static int txbf_expl_comp_fm = -1;
1232 static int txbf_expl_bf_csi = -1;
1233 static int txbf_expl_uncomp_fm_feed = -1;
1234 static int txbf_expl_comp_fm_feed = -1;
1235 static int txbf_csi_num_bf_ant = -1;
1236 static int txbf_min_group = -1;
1237 static int txbf_uncomp_sm_bf_ant = -1;
1238 static int txbf_comp_sm_bf_ant = -1;
1239 static int txbf_csi_max_rows_bf = -1;
1240 static int txbf_chan_est = -1;
1241 static int txbf_resrv = -1;
1242
1243 /*** Begin: 802.11n D1.10 - HT Information IE  ***/
1244 static int ht_info_primary_channel = -1;
1245
1246 static int ht_info_delimiter1 = -1;
1247 static int ht_info_secondary_channel_offset = -1;
1248 static int ht_info_channel_width = -1;
1249 static int ht_info_rifs_mode = -1;
1250 static int ht_info_psmp_stas_only = -1;
1251 static int ht_info_service_interval_granularity = -1;
1252
1253 static int ht_info_delimiter2 = -1;
1254 static int ht_info_operating_mode = -1;
1255 static int ht_info_non_greenfield_sta_present = -1;
1256 static int ht_info_transmit_burst_limit = -1;
1257 static int ht_info_obss_non_ht_stas_present = -1;
1258 static int ht_info_reserved_1 = -1;
1259
1260 static int ht_info_delimiter3 = -1;
1261 static int ht_info_reserved_2 = -1;
1262 static int ht_info_dual_beacon = -1;
1263 static int ht_info_dual_cts_protection = -1;
1264 static int ht_info_secondary_beacon = -1;
1265 static int ht_info_lsig_txop_protection_full_support = -1;
1266 static int ht_info_pco_active = -1;
1267 static int ht_info_pco_phase = -1;
1268 static int ht_info_reserved_3 = -1;
1269 /*** End: 802.11n D1.10 - HT Information IE  ***/
1270
1271 /*** Begin: 802.11n D1.10 - Secondary Channel Offset Tag  - Dustin Johnson***/
1272 static int hf_tag_secondary_channel_offset = -1;
1273 /*** End: 802.11n D1.10 - Secondary Channel Offset Tag  - Dustin Johnson***/
1274
1275 /*** Begin: Power Capability Tag - Dustin Johnson ***/
1276 static int hf_tag_power_capability_min = -1;
1277 static int hf_tag_power_capability_max = -1;
1278 /*** End: Power Capability Tag - Dustin Johnson ***/
1279
1280 static int hf_tag_tpc_report_trsmt_pow = -1;
1281 static int hf_tag_tpc_report_link_mrg = -1;
1282
1283 /*** Begin: Power Capability Tag - Dustin Johnson ***/
1284 static int hf_tag_supported_channels = -1;
1285 static int hf_tag_supported_channels_first = -1;
1286 static int hf_tag_supported_channels_range = -1;
1287 /*** End: Power Capability Tag - Dustin Johnson ***/
1288
1289 /*** Begin: Measurement Request Tag  - Dustin Johnson***/
1290 static int hf_tag_measure_request_measurement_token = -1;
1291 static int hf_tag_measure_request_mode = -1;
1292 static int hf_tag_measure_request_mode_reserved1 = -1;
1293 static int hf_tag_measure_request_mode_enable = -1;
1294 static int hf_tag_measure_request_mode_request = -1;
1295 static int hf_tag_measure_request_mode_report = -1;
1296 static int hf_tag_measure_request_mode_reserved2 = -1;
1297 static int hf_tag_measure_request_type = -1;
1298
1299 static int hf_tag_measure_request_channel_number = -1;
1300 static int hf_tag_measure_request_start_time = -1;
1301 static int hf_tag_measure_request_duration = -1;
1302
1303 static int hf_tag_measure_request_regulatory_class = -1;
1304 static int hf_tag_measure_request_randomization_interval = -1;
1305 /*** End: Measurement Request Tag  - Dustin Johnson***/
1306
1307 /*** Begin: Measurement Report Tag  - Dustin Johnson***/
1308 static int hf_tag_measure_report_measurement_token = -1;
1309 static int hf_tag_measure_report_mode = -1;
1310 static int hf_tag_measure_report_mode_late = -1;
1311 static int hf_tag_measure_report_mode_incapable = -1;
1312 static int hf_tag_measure_report_mode_refused = -1;
1313 static int hf_tag_measure_report_mode_reserved = -1;
1314 static int hf_tag_measure_report_type = -1;
1315 static int hf_tag_measure_report_channel_number = -1;
1316 static int hf_tag_measure_report_start_time = -1;
1317 static int hf_tag_measure_report_duration = -1;
1318
1319 static int hf_tag_measure_basic_map_field = -1;
1320 static int hf_tag_measure_map_field_bss = -1;
1321 static int hf_tag_measure_map_field_odfm = -1;
1322 static int hf_tag_measure_map_field_unident_signal = -1;
1323 static int hf_tag_measure_map_field_radar = -1;
1324 static int hf_tag_measure_map_field_unmeasured = -1;
1325 static int hf_tag_measure_map_field_reserved = -1;
1326
1327 static int hf_tag_measure_cca_busy_fraction = -1;
1328
1329 static int hf_tag_measure_rpi_histogram_report = -1;
1330 static int hf_tag_measure_rpi_histogram_report_0 = -1;
1331 static int hf_tag_measure_rpi_histogram_report_1 = -1;
1332 static int hf_tag_measure_rpi_histogram_report_2 = -1;
1333 static int hf_tag_measure_rpi_histogram_report_3 = -1;
1334 static int hf_tag_measure_rpi_histogram_report_4 = -1;
1335 static int hf_tag_measure_rpi_histogram_report_5 = -1;
1336 static int hf_tag_measure_rpi_histogram_report_6 = -1;
1337 static int hf_tag_measure_rpi_histogram_report_7 = -1;
1338
1339 static int hf_tag_measure_report_regulatory_class = -1;
1340 static int hf_tag_measure_report_channel_load = -1;
1341 static int hf_tag_measure_report_frame_info = -1;
1342 static int hf_tag_measure_report_frame_info_phy_type = -1;
1343 static int hf_tag_measure_report_frame_info_frame_type = -1;
1344 static int hf_tag_measure_report_rcpi = -1;
1345 static int hf_tag_measure_report_rsni = -1;
1346 static int hf_tag_measure_report_bssid = -1;
1347 static int hf_tag_measure_report_ant_id = -1;
1348 static int hf_tag_measure_report_parent_tsf = -1;
1349 /*** End: Measurement Report Tag  - Dustin Johnson***/
1350
1351 /*** Begin: Extended Capabilities Tag - Dustin Johnson ***/
1352 static int hf_tag_extended_capabilities = -1;
1353 static int hf_tag_extended_capabilities_b0 = -1;
1354 static int hf_tag_extended_capabilities_b1 = -1;
1355 static int hf_tag_extended_capabilities_b2 = -1;
1356 static int hf_tag_extended_capabilities_b3 = -1;
1357 /*** End: Extended Capabilities Tag - Dustin Johnson ***/
1358
1359 /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
1360 static int hf_tag_neighbor_report_bssid = -1;
1361 static int hf_tag_neighbor_report_bssid_info = -1;
1362 static int hf_tag_neighbor_report_bssid_info_reachability = -1;
1363 static int hf_tag_neighbor_report_bssid_info_security = -1;
1364 static int hf_tag_neighbor_report_bssid_info_key_scope = -1;
1365 /*static int hf_tag_neighbor_report_bssid_info_capability = -1; */ /* TODO Make this the parent tree item */
1366 static int hf_tag_neighbor_report_bssid_info_capability_spec_mng = -1;
1367 static int hf_tag_neighbor_report_bssid_info_capability_qos = -1;
1368 static int hf_tag_neighbor_report_bssid_info_capability_apsd = -1;
1369 static int hf_tag_neighbor_report_bssid_info_capability_radio_msnt = -1;
1370 static int hf_tag_neighbor_report_bssid_info_capability_dback = -1;
1371 static int hf_tag_neighbor_report_bssid_info_capability_iback = -1;
1372 static int hf_tag_neighbor_report_bssid_info_mobility_domain = -1;
1373 static int hf_tag_neighbor_report_bssid_info_high_throughput = -1;
1374 static int hf_tag_neighbor_report_bssid_info_reserved = -1;
1375 static int hf_tag_neighbor_report_reg_class = -1;
1376 static int hf_tag_neighbor_report_channel_number = -1;
1377 static int hf_tag_neighbor_report_phy_type = -1;
1378 /*** End: Neighbor Report Tag - Dustin Johnson ***/
1379
1380 /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
1381 static int hf_tag_ext_channel_switch_announcement_switch_mode = -1;
1382 static int hf_tag_ext_channel_switch_announcement_new_reg_class = -1;
1383 static int hf_tag_ext_channel_switch_announcement_new_chan_number = -1;
1384 static int hf_tag_ext_channel_switch_announcement_switch_count = -1;
1385 /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
1386
1387 /*** Begin: Supported Regulatory Classes Tag - Dustin Johnson ***/
1388 static int hf_tag_supported_reg_classes_current = -1;
1389 static int hf_tag_supported_reg_classes_alternate = -1;
1390 /*** End: Supported Regulatory Classes Tag - Dustin Johnson ***/
1391
1392 /* 802.11n 7.3.2.48 */
1393 static int hta_cap = -1;
1394 static int hta_ext_chan_offset = -1;
1395 static int hta_rec_tx_width = -1;
1396 static int hta_rifs_mode = -1;
1397 static int hta_controlled_access = -1;
1398 static int hta_service_interval = -1;
1399 static int hta_operating_mode = -1;
1400 static int hta_non_gf_devices = -1;
1401 static int hta_basic_stbc_mcs = -1;
1402 static int hta_dual_stbc_protection = -1;
1403 static int hta_secondary_beacon = -1;
1404 static int hta_lsig_txop_protection = -1;
1405 static int hta_pco_active = -1;
1406 static int hta_pco_phase = -1;
1407
1408
1409 static int antsel = -1;
1410 static int antsel_vs = -1;
1411 static int antsel_b0 = -1;
1412 static int antsel_b1 = -1;
1413 static int antsel_b2 = -1;
1414 static int antsel_b3 = -1;
1415 static int antsel_b4 = -1;
1416 static int antsel_b5 = -1;
1417 static int antsel_b6 = -1;
1418 static int antsel_b7 = -1;
1419
1420 static int rsn_cap = -1;
1421 static int rsn_cap_preauth = -1;
1422 static int rsn_cap_no_pairwise = -1;
1423 static int rsn_cap_ptksa_replay_counter = -1;
1424 static int rsn_cap_gtksa_replay_counter = -1;
1425
1426 static int hf_aironet_ie_type = -1;
1427 static int hf_aironet_ie_version = -1;
1428 static int hf_aironet_ie_data = -1;
1429 static int hf_aironet_ie_qos_unk1 = -1;
1430 static int hf_aironet_ie_qos_paramset = -1;
1431 static int hf_aironet_ie_qos_val = -1;
1432
1433 static int hf_marvell_ie_type = -1;
1434 static int hf_marvell_ie_mesh_subtype = -1;
1435 static int hf_marvell_ie_mesh_version = -1;
1436 static int hf_marvell_ie_mesh_active_proto_id = -1;
1437 static int hf_marvell_ie_mesh_active_metric_id = -1;
1438 static int hf_marvell_ie_mesh_cap = -1;
1439 static int hf_marvell_ie_data = -1;
1440
1441 /*QBSS - Version 1,2,802.11e*/
1442
1443 static int hf_qbss2_cal = -1;
1444 static int hf_qbss2_gl = -1;
1445 static int hf_qbss_cu = -1;
1446 static int hf_qbss2_cu = -1;
1447 static int hf_qbss_scount = -1;
1448 static int hf_qbss2_scount = -1;
1449 static int hf_qbss_version = -1;
1450 static int hf_qbss_adc = -1;
1451
1452 static int hf_ts_info = -1;
1453 static int hf_tsinfo_type = -1;
1454 static int hf_tsinfo_tsid = -1;
1455 static int hf_tsinfo_dir = -1;
1456 static int hf_tsinfo_access = -1;
1457 static int hf_tsinfo_agg = -1;
1458 static int hf_tsinfo_apsd = -1;
1459 static int hf_tsinfo_up = -1;
1460 static int hf_tsinfo_ack = -1;
1461 static int hf_tsinfo_sched = -1;
1462 static int tspec_nor_msdu = -1;
1463 static int tspec_max_msdu = -1;
1464 static int tspec_min_srv = -1;
1465 static int tspec_max_srv = -1;
1466 static int tspec_inact_int = -1;
1467 static int tspec_susp_int = -1;
1468 static int tspec_srv_start = -1;
1469 static int tspec_min_data = -1;
1470 static int tspec_mean_data = -1;
1471 static int tspec_peak_data = -1;
1472 static int tspec_burst_size = -1;
1473 static int tspec_delay_bound = -1;
1474 static int tspec_min_phy = -1;
1475 static int tspec_surplus = -1;
1476 static int tspec_medium = -1;
1477 static int ts_delay = -1;
1478 static int hf_class_type = -1;
1479 static int hf_class_mask = -1;
1480 static int hf_ether_type = -1;
1481 static int hf_tclas_process = -1;
1482 static int hf_sched_info = -1;
1483 static int hf_sched_srv_start = -1;
1484 static int hf_sched_srv_int = -1;
1485 static int hf_sched_spec_int = -1;
1486 static int hf_action = -1;
1487 static int cf_version = -1;
1488 static int cf_ipv4_src = -1;
1489 static int cf_ipv4_dst = -1;
1490 static int cf_src_port = -1;
1491 static int cf_dst_port = -1;
1492 static int cf_dscp = -1;
1493 static int cf_protocol = -1;
1494 static int cf_ipv6_src = -1;
1495 static int cf_ipv6_dst = -1;
1496 static int cf_flow = -1;
1497 static int cf_tag_type = -1;
1498 static int cf_aruba = -1;
1499 static int cf_aruba_hb_seq = -1;
1500 static int cf_aruba_mtu = -1;
1501
1502 /* ************************************************************************* */
1503 /*                               Protocol trees                              */
1504 /* ************************************************************************* */
1505 static gint ett_80211 = -1;
1506 static gint ett_proto_flags = -1;
1507 static gint ett_cap_tree = -1;
1508 static gint ett_fc_tree = -1;
1509 static gint ett_cntrl_wrapper_fc = -1;
1510 static gint ett_cntrl_wrapper_payload = -1;
1511 static gint ett_fragments = -1;
1512 static gint ett_fragment = -1;
1513 static gint ett_block_ack = -1;
1514
1515
1516 static gint ett_80211_mgt = -1;
1517 static gint ett_fixed_parameters = -1;
1518 static gint ett_tagged_parameters = -1;
1519 static gint ett_qos_parameters = -1;
1520 static gint ett_qos_ps_buf_state = -1;
1521 static gint ett_wep_parameters = -1;
1522
1523 static gint ett_rsn_cap_tree = -1;
1524
1525 static gint ett_ht_cap_tree = -1;
1526 static gint ett_ampduparam_tree = -1;
1527 static gint ett_mcsset_tree = -1;
1528 static gint ett_mcsbit_tree = -1;
1529 static gint ett_htex_cap_tree = -1;
1530 static gint ett_txbf_tree = -1;
1531 static gint ett_antsel_tree = -1;
1532 static gint ett_hta_cap_tree = -1;
1533 static gint ett_hta_cap1_tree = -1;
1534 static gint ett_hta_cap2_tree = -1;
1535 static gint ett_htc_tree = -1;
1536
1537 /*** Start: 802.11n D1.10 - HT Information IE - Dustin Johnson ***/
1538 static gint ett_ht_info_delimiter1_tree = -1;
1539 static gint ett_ht_info_delimiter2_tree = -1;
1540 static gint ett_ht_info_delimiter3_tree = -1;
1541 /*** End: 802.11n D1.10 - HT Information IE  - Dustin Johnson ***/
1542
1543 /*** Start: 802.11n D1.10 - Tag Measure Request IE - Dustin Johnson ***/
1544 static gint ett_tag_measure_request_tree = -1;
1545 /*** End: 802.11n D1.10 - Tag Measure Request IE  - Dustin Johnson ***/
1546
1547 static gint ett_tag_ex_cap = -1;
1548
1549 /*** Begin: Supported Channels Tag - Dustin Johnson ***/
1550 static gint ett_tag_supported_channels = -1;
1551 /*** End: Supported Channels Tag - Dustin Johnson ***/
1552
1553 /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
1554 static gint ett_tag_neighbor_report_bssid_info_tree = -1;
1555 static gint ett_tag_neighbor_report_bssid_info_capability_tree = -1;
1556 static gint ett_tag_neighbor_report_sub_tag_tree = -1;
1557 /*** End: Neighbor Report Tag - Dustin Johnson ***/
1558
1559 /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
1560 static gint ett_ff_ba_param_tree = -1;
1561 static gint ett_ff_ba_ssc_tree = -1;
1562 /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
1563
1564 /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
1565 static gint ett_ff_delba_param_tree = -1;
1566 /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
1567
1568 /*** Begin: QoS Information AP/STA Fixed Field - Dustin Johnson ***/
1569 static gint ett_ff_qos_info = -1;
1570 /*** End: QoS Information AP/STA Fixed Field - Dustin Johnson ***/
1571
1572 /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1573 static gint ett_ff_sm_pwr_save = -1;
1574 /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1575
1576 /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1577 static gint ett_ff_psmp_param_set = -1;
1578 /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1579
1580 /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
1581 static gint ett_ff_mimo_cntrl = -1;
1582 /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
1583
1584 /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
1585 static gint ett_ff_ant_sel = -1;
1586 /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
1587
1588 /*** Begin: MIMO Reports - Dustin Johnson ***/
1589 static gint ett_mimo_report = -1;
1590 /*** End: MIMO Reports - Dustin Johnson ***/
1591
1592 /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1593 static gint ett_ff_chan_switch_announce = -1;
1594 /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1595
1596 /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
1597 static gint ett_ff_ht_info = -1;
1598 /*** End: HT Information Fixed Field - Dustin Johnson ***/
1599
1600 /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
1601 static gint ett_ff_psmp_sta_info = -1;
1602 /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
1603
1604 /*** Begin: A-MSDU Dissection - Dustin Johnson ***/
1605 static gint ett_msdu_aggregation_parent_tree = -1;
1606 static gint ett_msdu_aggregation_subframe_tree = -1;
1607 /*** End: A-MSDU Dissection - Dustin Johnson ***/
1608
1609 /***  Begin: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
1610 static gint ett_pst_tree = -1;
1611 static gint ett_pst_cap_tree = -1;
1612 static gint ett_chan_noc_tree = -1;
1613 static gint ett_wave_chnl_tree = -1;
1614
1615 /***  End: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
1616
1617 static gint ett_80211_mgt_ie = -1;
1618 static gint ett_tsinfo_tree = -1;
1619 static gint ett_sched_tree = -1;
1620
1621 static gint ett_fcs = -1;
1622
1623 static gint ett_radio = -1;
1624
1625 static const fragment_items frag_items = {
1626   &ett_fragment,
1627   &ett_fragments,
1628   &hf_fragments,
1629   &hf_fragment,
1630   &hf_fragment_overlap,
1631   &hf_fragment_overlap_conflict,
1632   &hf_fragment_multiple_tails,
1633   &hf_fragment_too_long_fragment,
1634   &hf_fragment_error,
1635   &hf_reassembled_in,
1636   "fragments"
1637 };
1638
1639 static enum_val_t wlan_ignore_wep_options[] = {
1640   { "no",         "No",               WLAN_IGNORE_WEP_NO    },
1641   { "without_iv", "Yes - without IV", WLAN_IGNORE_WEP_WO_IV },
1642   { "with_iv",    "Yes - with IV",    WLAN_IGNORE_WEP_W_IV  },
1643   { NULL,         NULL,               0                     }
1644 };
1645
1646 static dissector_handle_t ieee80211_handle;
1647 static dissector_handle_t llc_handle;
1648 static dissector_handle_t ipx_handle;
1649 static dissector_handle_t eth_withoutfcs_handle;
1650 static dissector_handle_t data_handle;
1651 static dissector_handle_t wlancap_handle;
1652
1653 static int wlan_tap = -1;
1654
1655 /*     Davide Schiera (2006-11-22): including AirPDcap project                */
1656 #ifdef HAVE_AIRPDCAP
1657 #include <epan/crypt/airpdcap_ws.h>
1658 AIRPDCAP_CONTEXT airpdcap_ctx;
1659 #else
1660 int airpdcap_ctx;
1661 #endif
1662 /* Davide Schiera (2006-11-22) ---------------------------------------------- */
1663
1664
1665 /* ************************************************************************* */
1666 /*            Return the length of the current header (in bytes)             */
1667 /* ************************************************************************* */
1668 static int
1669 find_header_length (guint16 fcf, guint16 ctrl_fcf, gboolean is_ht)
1670 {
1671   int len;
1672   guint16 cw_fcf;
1673
1674   switch (FCF_FRAME_TYPE (fcf)) {
1675
1676   case MGT_FRAME:
1677     if (is_ht && IS_STRICTLY_ORDERED(FCF_FLAGS(fcf)))
1678       return MGT_FRAME_HDR_LEN + 4;
1679
1680     return MGT_FRAME_HDR_LEN;
1681
1682   case CONTROL_FRAME:
1683     if (COMPOSE_FRAME_TYPE(fcf) == CTRL_CONTROL_WRAPPER) {
1684       len = 6;
1685       cw_fcf = ctrl_fcf;
1686     } else {
1687       len = 0;
1688       cw_fcf = fcf;
1689     }
1690     switch (COMPOSE_FRAME_TYPE (cw_fcf)) {
1691
1692     case CTRL_CTS:
1693     case CTRL_ACKNOWLEDGEMENT:
1694       return len + 10;
1695
1696     case CTRL_RTS:
1697     case CTRL_PS_POLL:
1698     case CTRL_CFP_END:
1699     case CTRL_CFP_ENDACK:
1700     case CTRL_BLOCK_ACK_REQ:
1701     case CTRL_BLOCK_ACK:
1702       return len + 16;
1703     }
1704     return len + 4;  /* XXX */
1705
1706   case DATA_FRAME:
1707     len = (FCF_ADDR_SELECTOR(fcf) ==
1708       DATA_ADDR_T4) ? DATA_LONG_HDR_LEN : DATA_SHORT_HDR_LEN;
1709
1710     if (DATA_FRAME_IS_QOS(COMPOSE_FRAME_TYPE(fcf))) {
1711       len += 2;
1712       if (is_ht && IS_STRICTLY_ORDERED(FCF_FLAGS(fcf))) {
1713         len += 4;
1714       }
1715     }
1716
1717     return len;
1718
1719   default:
1720     return 4;  /* XXX */
1721   }
1722 }
1723
1724 mimo_control_t get_mimo_control (tvbuff_t *tvb, int offset)
1725 {
1726   guint16 mimo;
1727   mimo_control_t output;
1728
1729   mimo = tvb_get_letohs (tvb, offset);
1730
1731   output.nc = (mimo & 0x0003) + 1;
1732   output.nr = ((mimo & 0x000C) >> 2) + 1;
1733   output.chan_width = (mimo & 0x0010) >> 4;
1734   output.coefficient_size = 4; /* XXX - Is this a good default? */
1735
1736   switch ((mimo & 0x0060) >> 5)
1737     {
1738       case 0:
1739         output.grouping = 1;
1740         break;
1741
1742       case 1:
1743         output.grouping = 2;
1744         break;
1745
1746       case 2:
1747         output.grouping = 4;
1748         break;
1749
1750       default:
1751         output.grouping = 1;
1752         break;
1753     }
1754
1755   switch ((mimo & 0x0180) >> 7)
1756     {
1757       case 0:
1758         output.coefficient_size = 4;
1759         break;
1760
1761       case 1:
1762         output.coefficient_size = 5;
1763         break;
1764
1765       case 2:
1766         output.coefficient_size = 6;
1767         break;
1768
1769       case 3:
1770         output.coefficient_size = 8;
1771         break;
1772     }
1773
1774   output.codebook_info = (mimo & 0x0600) >> 9;
1775   output.remaining_matrix_segment = (mimo & 0x3800) >> 11;
1776
1777   return output;
1778 }
1779
1780 int get_mimo_na (guint8 nr, guint8 nc)
1781 {
1782   if (nr == 2 && nc == 1){
1783     return 2;
1784   }else if (nr == 2 && nc == 2){
1785     return 2;
1786   }else if (nr == 3 && nc == 1){
1787     return 4;
1788   }else if (nr == 3 && nc == 2){
1789     return 6;
1790   }else if (nr == 3 && nc == 3){
1791     return 6;
1792   }else if (nr == 4 && nc == 1){
1793     return 6;
1794   }else if (nr == 4 && nc == 2){
1795     return 10;
1796   }else if (nr == 4 && nc == 3){
1797     return 12;
1798   }else if (nr == 4 && nc == 4){
1799     return 12;
1800   }else{
1801     return 0;
1802   }
1803 }
1804
1805 int get_mimo_ns (gboolean chan_width, guint8 output_grouping)
1806 {
1807   int ns = 0;
1808
1809   if (chan_width)
1810   {
1811       switch (output_grouping)
1812       {
1813         case 1:
1814           ns = 114;
1815           break;
1816
1817           case 2:
1818             ns = 58;
1819             break;
1820
1821           case 4:
1822             ns = 30;
1823             break;
1824
1825           default:
1826             ns = 0;
1827       }
1828   } else {
1829     switch (output_grouping)
1830     {
1831       case 1:
1832         ns = 56;
1833         break;
1834
1835       case 2:
1836         ns = 30;
1837         break;
1838
1839       case 4:
1840         ns = 16;
1841         break;
1842
1843       default:
1844         ns = 0;
1845     }
1846   }
1847
1848   return ns;
1849 }
1850
1851 int add_mimo_csi_matrices_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl)
1852 {
1853   proto_item *snr_item;
1854   proto_tree *snr_tree;
1855   int csi_matrix_size, start_offset;
1856   int ns, i;
1857
1858   start_offset = offset;
1859   snr_item = proto_tree_add_text(tree, tvb, offset, mimo_cntrl.nc, "Signal to Noise Ratio");
1860   snr_tree = proto_item_add_subtree (snr_item, ett_mimo_report);
1861
1862   for (i=1; i <= mimo_cntrl.nr; i++)
1863   {
1864     guint8 snr;
1865
1866     snr = tvb_get_guint8(tvb, offset);
1867     proto_tree_add_uint_format(snr_tree, ff_mimo_csi_snr, tvb, offset, 1, snr, "Channel %d - Signal to Noise Ratio: 0x%02X", i, snr);
1868     offset++;
1869   }
1870
1871   ns = get_mimo_ns(mimo_cntrl.chan_width, mimo_cntrl.grouping);
1872   csi_matrix_size = ns*(3+(2*mimo_cntrl.nc*mimo_cntrl.nr*mimo_cntrl.coefficient_size));
1873   csi_matrix_size = roundup2(csi_matrix_size, 8) / 8;
1874   proto_tree_add_text(tree, tvb, offset, csi_matrix_size, "CSI Matrices");
1875   offset += csi_matrix_size;
1876   return offset - start_offset;
1877 }
1878
1879 int add_mimo_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl)
1880 {
1881   proto_item *snr_item;
1882   proto_tree *snr_tree;
1883   int csi_matrix_size, start_offset;
1884   int ns, i;
1885
1886   start_offset = offset;
1887   snr_item = proto_tree_add_text(tree, tvb, offset, mimo_cntrl.nc, "Signal to Noise Ratio");
1888   snr_tree = proto_item_add_subtree (snr_item, ett_mimo_report);
1889
1890   for (i=1; i <= mimo_cntrl.nc; i++)
1891   {
1892     guint8 snr;
1893
1894     snr = tvb_get_guint8(tvb, offset);
1895     proto_tree_add_uint_format(snr_tree, ff_mimo_csi_snr, tvb, offset, 1, snr, "Stream %d - Signal to Noise Ratio: 0x%02X", i, snr);
1896     offset++;
1897   }
1898
1899   ns = get_mimo_ns(mimo_cntrl.chan_width, mimo_cntrl.grouping);
1900   csi_matrix_size = ns*(2*mimo_cntrl.nc*mimo_cntrl.nr*mimo_cntrl.coefficient_size);
1901   csi_matrix_size = roundup2(csi_matrix_size, 8) / 8;
1902   proto_tree_add_text(tree, tvb, offset, csi_matrix_size, "Beamforming Feedback Matrices");
1903   offset += csi_matrix_size;
1904   return offset - start_offset;
1905 }
1906
1907 int add_mimo_compressed_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl)
1908 {
1909   proto_item *snr_item;
1910   proto_tree *snr_tree;
1911   int csi_matrix_size, start_offset;
1912   int ns, na, i;
1913
1914   start_offset = offset;
1915   snr_item = proto_tree_add_text(tree, tvb, offset, mimo_cntrl.nc, "Signal to Noise Ratio");
1916   snr_tree = proto_item_add_subtree (snr_item, ett_mimo_report);
1917
1918   for (i=1; i <= mimo_cntrl.nc; i++)
1919   {
1920     guint8 snr;
1921
1922     snr = tvb_get_guint8(tvb, offset);
1923     proto_tree_add_uint_format(snr_tree, ff_mimo_csi_snr, tvb, offset, 1, snr, "Stream %d - Signal to Noise Ratio: 0x%02X", i, snr);
1924     offset++;
1925   }
1926
1927   na = get_mimo_na(mimo_cntrl.nr, mimo_cntrl.nc);
1928   ns = get_mimo_ns(mimo_cntrl.chan_width, mimo_cntrl.grouping);
1929   csi_matrix_size = ns*(na*((mimo_cntrl.codebook_info+1)*2 + 2)/2);
1930   csi_matrix_size = roundup2(csi_matrix_size, 8) / 8;
1931   proto_tree_add_text(tree, tvb, offset, csi_matrix_size, "Compressed Beamforming Feedback Matrices");
1932   offset += csi_matrix_size;
1933   return offset - start_offset;
1934 }
1935
1936 /* ************************************************************************* */
1937 /*          This is the capture function used to update packet counts        */
1938 /* ************************************************************************* */
1939 static void
1940 capture_ieee80211_common (const guchar * pd, int offset, int len,
1941         packet_counts * ld, gboolean fixed_length_header,
1942         gboolean datapad, gboolean is_ht)
1943 {
1944   guint16 fcf, hdr_length;
1945
1946   if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
1947     ld->other++;
1948     return;
1949   }
1950
1951   fcf = pletohs (&pd[offset]);
1952
1953   if (IS_PROTECTED(FCF_FLAGS(fcf)) && wlan_ignore_wep == WLAN_IGNORE_WEP_NO) {
1954     ld->other++;
1955     return;
1956   }
1957
1958   switch (COMPOSE_FRAME_TYPE (fcf)) {
1959
1960     case DATA:          /* We got a data frame */
1961     case DATA_CF_ACK:   /* Data with ACK */
1962     case DATA_CF_POLL:
1963     case DATA_CF_ACK_POLL:
1964     case DATA_QOS_DATA:
1965     {
1966       if (fixed_length_header)
1967         hdr_length = DATA_LONG_HDR_LEN;
1968       else
1969         hdr_length = find_header_length (fcf, 0, is_ht);
1970       if (datapad)
1971         hdr_length = roundup2(hdr_length, 4);
1972       /* I guess some bridges take Netware Ethernet_802_3 frames,
1973          which are 802.3 frames (with a length field rather than
1974          a type field, but with no 802.2 header in the payload),
1975          and just stick the payload into an 802.11 frame.  I've seen
1976          captures that show frames of that sort.
1977
1978          This means we have to do the same check for Netware 802.3 -
1979          or, if you will, "Netware 802.11" - that we do in the
1980          Ethernet dissector, i.e. checking for 0xffff as the first
1981          four bytes of the payload and, if we find it, treating it
1982          as an IPX frame. */
1983       if (!BYTES_ARE_IN_FRAME(offset+hdr_length, len, 2)) {
1984         ld->other++;
1985         return;
1986       }
1987       if (pd[offset+hdr_length] == 0xff && pd[offset+hdr_length+1] == 0xff) {
1988         capture_ipx (ld);
1989       }
1990       else {
1991         capture_llc (pd, offset + hdr_length, len, ld);
1992       }
1993       break;
1994     }
1995
1996     default:
1997       ld->other++;
1998       break;
1999   }
2000 }
2001
2002 /*
2003  * Handle 802.11 with a variable-length link-layer header.
2004  */
2005 void
2006 capture_ieee80211 (const guchar * pd, int offset, int len, packet_counts * ld)
2007 {
2008   capture_ieee80211_common (pd, offset, len, ld, FALSE, FALSE, FALSE);
2009 }
2010
2011 /*
2012  * Handle 802.11 with a variable-length link-layer header and data padding.
2013  */
2014 void
2015 capture_ieee80211_datapad (const guchar * pd, int offset, int len,
2016                            packet_counts * ld)
2017 {
2018   capture_ieee80211_common (pd, offset, len, ld, FALSE, TRUE, FALSE);
2019 }
2020
2021 /*
2022  * Handle 802.11 with a fixed-length link-layer header (padded to the
2023  * maximum length).
2024  */
2025 void
2026 capture_ieee80211_fixed (const guchar * pd, int offset, int len, packet_counts * ld)
2027 {
2028   capture_ieee80211_common (pd, offset, len, ld, TRUE, FALSE, FALSE);
2029 }
2030
2031 /*
2032  * Handle an HT 802.11 with a variable-length link-layer header.
2033  */
2034 void
2035 capture_ieee80211_ht (const guchar * pd, int offset, int len, packet_counts * ld)
2036 {
2037   capture_ieee80211_common (pd, offset, len, ld, FALSE, FALSE, TRUE);
2038 }
2039
2040 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000
2041 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001
2042 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002
2043
2044 /*
2045  * Prism II-based wlan devices have a monitoring mode that sticks
2046  * a proprietary header on each packet with lots of good
2047  * information.  This file is responsible for decoding that
2048  * data.
2049  *
2050  * Support by Tim Newsham
2051  *
2052  * A value from the header.
2053  *
2054  * It appears from looking at the linux-wlan-ng and Prism II HostAP
2055  * drivers, and various patches to the orinoco_cs drivers to add
2056  * Prism headers, that:
2057  *
2058  *      the "did" identifies what the value is (i.e., what it's the value
2059  *      of);
2060  *
2061  *      "status" is 0 if the value is present or 1 if it's absent;
2062  *
2063  *      "len" is the length of the value (always 4, in that code);
2064  *
2065  *      "data" is the value of the data (or 0 if not present).
2066  *
2067  * Note: all of those values are in the *host* byte order of the machine
2068  * on which the capture was written.
2069  */
2070 struct val_80211 {
2071     unsigned int did;
2072     unsigned short status, len;
2073     unsigned int data;
2074 };
2075
2076 /*
2077  * Header attached during Prism monitor mode.
2078  *
2079  * At least according to one paper I've seen, the Prism 2.5 chip set
2080  * provides:
2081  *
2082  *      RSSI (receive signal strength indication) is "the total power
2083  *      received by the radio hardware while receiving the frame,
2084  *      including signal, interfereence, and background noise";
2085  *
2086  *      "silence value" is "the total power observed just before the
2087  *      start of the frame".
2088  *
2089  * None of the drivers I looked at supply the "rssi" or "sq" value,
2090  * but they do supply "signal" and "noise" values, along with a "rate"
2091  * value that's 1/5 of the raw value from what is presumably a raw
2092  * HFA384x frame descriptor, with the comment "set to 802.11 units",
2093  * which presumably means the units are 500 Kb/s.
2094  *
2095  * I infer from the current NetBSD "wi" driver that "signal" and "noise"
2096  * are adjusted dBm values, with the dBm value having 100 added to it
2097  * for the Prism II cards (although the NetBSD code has an XXX comment
2098  * for the #define for WI_PRISM_DBM_OFFSET) and 149 (with no XXX comment)
2099  * for the Orinoco cards.
2100  *
2101  * XXX - what about other drivers that supply Prism headers, such as
2102  * old versions of the MadWifi driver?
2103  */
2104 struct prism_hdr {
2105     unsigned int msgcode, msglen;
2106     char devname[16];
2107     struct val_80211 hosttime, mactime, channel, rssi, sq, signal,
2108         noise, rate, istx, frmlen;
2109 };
2110
2111 void
2112 capture_prism(const guchar *pd, int offset, int len, packet_counts *ld)
2113 {
2114   guint32 cookie;
2115
2116   if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32))) {
2117     ld->other++;
2118     return;
2119   }
2120
2121   /* Some captures with DLT_PRISM have the AVS WLAN header */
2122   cookie = pntohl(pd);
2123   if ((cookie == WLANCAP_MAGIC_COOKIE_V1) ||
2124       (cookie == WLANCAP_MAGIC_COOKIE_V2)) {
2125     capture_wlancap(pd, offset, len, ld);
2126     return;
2127   }
2128
2129   /* Prism header */
2130   if (!BYTES_ARE_IN_FRAME(offset, len, (int)sizeof(struct prism_hdr))) {
2131     ld->other++;
2132     return;
2133   }
2134   offset += sizeof(struct prism_hdr);
2135
2136   /* 802.11 header follows */
2137   capture_ieee80211(pd, offset, len, ld);
2138 }
2139
2140 void
2141 capture_wlancap(const guchar *pd, int offset, int len, packet_counts *ld)
2142 {
2143   guint32 length;
2144
2145   if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32)*2)) {
2146     ld->other++;
2147     return;
2148   }
2149
2150   length = pntohl(pd+sizeof(guint32));
2151
2152   if (!BYTES_ARE_IN_FRAME(offset, len, length)) {
2153     ld->other++;
2154     return;
2155   }
2156
2157   offset += length;
2158
2159   /* 802.11 header follows */
2160   capture_ieee80211(pd, offset, len, ld);
2161 }
2162
2163 /* ************************************************************************* */
2164 /*          Add the subtree used to store the fixed parameters               */
2165 /* ************************************************************************* */
2166 static proto_tree *
2167 get_fixed_parameter_tree (proto_tree * tree, tvbuff_t *tvb, int start, int size)
2168 {
2169   proto_item *fixed_fields;
2170   fixed_fields =
2171     proto_tree_add_uint_format (tree, hf_fixed_parameters, tvb, start,
2172         size, size, "Fixed parameters (%d bytes)",
2173         size);
2174
2175   return proto_item_add_subtree (fixed_fields, ett_fixed_parameters);
2176 }
2177
2178
2179 /* ************************************************************************* */
2180 /*            Add the subtree used to store tagged parameters                */
2181 /* ************************************************************************* */
2182 static proto_tree *
2183 get_tagged_parameter_tree (proto_tree * tree, tvbuff_t *tvb, int start, int size)
2184 {
2185   proto_item *tagged_fields;
2186
2187   tagged_fields = proto_tree_add_uint_format (tree, hf_tagged_parameters,
2188     tvb,
2189     start,
2190     size,
2191     size,
2192     "Tagged parameters (%d bytes)",
2193     size);
2194
2195   return proto_item_add_subtree (tagged_fields, ett_tagged_parameters);
2196 }
2197
2198
2199 /* ************************************************************************* */
2200 /*              Dissect and add fixed mgmt fields to protocol tree           */
2201 /* ************************************************************************* */
2202 static guint
2203 add_fixed_field(proto_tree * tree, tvbuff_t * tvb, int offset, int lfcode)
2204 {
2205   const guint8 *dataptr;
2206   char out_buff[SHORT_STR];
2207   guint16 capability;
2208   proto_item *cap_item;
2209   static proto_tree *cap_tree;
2210   double temp_double;
2211   guint length = 0;
2212
2213   switch (lfcode)
2214   {
2215     case FIELD_TIMESTAMP:
2216       dataptr = tvb_get_ptr (tvb, offset, 8);
2217       memset (out_buff, 0, SHORT_STR);
2218       g_snprintf (out_buff, SHORT_STR, "0x%02X%02X%02X%02X%02X%02X%02X%02X",
2219         dataptr[7],
2220         dataptr[6],
2221         dataptr[5],
2222         dataptr[4],
2223         dataptr[3],
2224         dataptr[2],
2225         dataptr[1],
2226         dataptr[0]);
2227
2228       proto_tree_add_string (tree, ff_timestamp, tvb, offset, 8, out_buff);
2229       length += 8;
2230       break;
2231
2232     case FIELD_BEACON_INTERVAL:
2233       {
2234         capability = tvb_get_letohs (tvb, offset);
2235         temp_double = (double)capability;
2236         temp_double = temp_double * 1024 / 1000000;
2237         proto_tree_add_double_format (tree, ff_beacon_interval, tvb, offset, 2,
2238           temp_double,"Beacon Interval: %f [Seconds]", temp_double);
2239         if (check_col (g_pinfo->cinfo, COL_INFO)) {
2240           col_append_fstr(g_pinfo->cinfo, COL_INFO, ", BI=%d", capability);
2241         }
2242         length += 2;
2243         break;
2244       }
2245
2246     case FIELD_CAP_INFO:
2247       {
2248         capability = tvb_get_letohs (tvb, offset);
2249
2250         cap_item = proto_tree_add_uint_format (tree, ff_capture,
2251           tvb, offset, 2, capability,
2252           "Capability Information: 0x%04X", capability);
2253         cap_tree = proto_item_add_subtree (cap_item, ett_cap_tree);
2254         proto_tree_add_boolean (cap_tree, ff_cf_ess, tvb, offset, 2, capability);
2255         proto_tree_add_boolean (cap_tree, ff_cf_ibss, tvb, offset, 2, capability);
2256         if (ESS_SET (capability) != 0)  /* This is an AP */
2257           proto_tree_add_uint (cap_tree, ff_cf_ap_poll, tvb, offset, 2,
2258             capability);
2259         else      /* This is a STA */
2260         proto_tree_add_uint (cap_tree, ff_cf_sta_poll, tvb, offset, 2,
2261           capability);
2262
2263         proto_tree_add_boolean (cap_tree, ff_cf_privacy, tvb, offset, 2,
2264           capability);
2265         proto_tree_add_boolean (cap_tree, ff_cf_preamble, tvb, offset, 2,
2266           capability);
2267         proto_tree_add_boolean (cap_tree, ff_cf_pbcc, tvb, offset, 2,
2268           capability);
2269         proto_tree_add_boolean (cap_tree, ff_cf_agility, tvb, offset, 2,
2270           capability);
2271         proto_tree_add_boolean (cap_tree, ff_cf_spec_man, tvb, offset, 2,
2272           capability);
2273         proto_tree_add_boolean (cap_tree, ff_short_slot_time, tvb, offset, 2,
2274           capability);
2275         proto_tree_add_boolean (cap_tree, ff_cf_apsd, tvb, offset, 2,
2276           capability);
2277         proto_tree_add_boolean (cap_tree, ff_dsss_ofdm, tvb, offset, 2,
2278           capability);
2279         proto_tree_add_boolean (cap_tree, ff_cf_del_blk_ack, tvb, offset, 2,
2280           capability);
2281         proto_tree_add_boolean (cap_tree, ff_cf_imm_blk_ack, tvb, offset, 2,
2282           capability);
2283         length += 2;
2284         break;
2285       }
2286     case FIELD_AUTH_ALG:
2287       proto_tree_add_item (tree, ff_auth_alg, tvb, offset, 2, TRUE);
2288       length += 2;
2289       break;
2290
2291     case FIELD_AUTH_TRANS_SEQ:
2292       proto_tree_add_item (tree, ff_auth_seq, tvb, offset, 2, TRUE);
2293       length += 2;
2294       break;
2295
2296     case FIELD_CURRENT_AP_ADDR:
2297       proto_tree_add_item (tree, ff_current_ap, tvb, offset, 6, FALSE);
2298       length += 6;
2299       break;
2300
2301     case FIELD_LISTEN_IVAL:
2302       proto_tree_add_item (tree, ff_listen_ival, tvb, offset, 2, TRUE);
2303       length += 2;
2304       break;
2305
2306     case FIELD_REASON_CODE:
2307       proto_tree_add_item (tree, ff_reason, tvb, offset, 2, TRUE);
2308       length += 2;
2309       break;
2310
2311     case FIELD_ASSOC_ID:
2312       proto_tree_add_uint(tree, ff_assoc_id, tvb, offset, 2,
2313         ASSOC_ID(tvb_get_letohs(tvb,offset)));
2314       /* proto_tree_add_item (tree, ff_assoc_id, tvb, offset, 2, TRUE); */
2315       length += 2;
2316       break;
2317
2318     case FIELD_STATUS_CODE:
2319       proto_tree_add_item (tree, ff_status_code, tvb, offset, 2, TRUE);
2320       length += 2;
2321       break;
2322
2323     case FIELD_CATEGORY_CODE:
2324       proto_tree_add_item (tree, ff_category_code, tvb, offset, 1, TRUE);
2325       length += 1;
2326       break;
2327
2328     case FIELD_ACTION_CODE:
2329       proto_tree_add_item (tree, ff_action_code, tvb, offset, 1, TRUE);
2330       length += 1;
2331       break;
2332
2333     case FIELD_DIALOG_TOKEN:
2334       proto_tree_add_item (tree, ff_dialog_token, tvb, offset, 1, TRUE);
2335       length += 1;
2336       break;
2337
2338     case FIELD_WME_ACTION_CODE:
2339       proto_tree_add_item (tree, ff_wme_action_code, tvb, offset, 1, TRUE);
2340       length += 1;
2341       break;
2342
2343     case FIELD_WME_STATUS_CODE:
2344       proto_tree_add_item (tree, ff_wme_status_code, tvb, offset, 1, TRUE);
2345       length += 1;
2346       break;
2347
2348     case FIELD_QOS_ACTION_CODE:
2349       proto_tree_add_item (tree, ff_qos_action_code, tvb, offset, 1, TRUE);
2350       length += 1;
2351       break;
2352
2353     /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
2354     case FIELD_BLOCK_ACK_ACTION_CODE:
2355       proto_tree_add_item (tree, ff_ba_action, tvb, offset, 1, TRUE);
2356       length += 1;
2357       break;
2358     /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
2359
2360     /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
2361     case FIELD_BLOCK_ACK_PARAM:
2362       {
2363         guint16 params;
2364         proto_item *param_item;
2365         proto_tree *param_tree;
2366
2367         params = tvb_get_letohs (tvb, offset);
2368
2369         param_item = proto_tree_add_uint(tree, ff_block_ack_params, tvb, offset, 2, params);
2370         param_tree = proto_item_add_subtree (param_item, ett_ff_ba_param_tree);
2371
2372         proto_tree_add_boolean(param_tree, ff_block_ack_params_amsdu_permitted, tvb, offset, 1, params);
2373         proto_tree_add_boolean(param_tree, ff_block_ack_params_policy, tvb, offset, 1, params);
2374         proto_tree_add_uint(param_tree, ff_block_ack_params_tid, tvb, offset, 1, params);
2375         proto_tree_add_uint(param_tree, ff_block_ack_params_buffer_size, tvb, offset, 2, params);
2376         length += 2;
2377         break;
2378       }
2379     /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
2380
2381     /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
2382     case FIELD_BLOCK_ACK_TIMEOUT:
2383       {
2384         guint16 timeout;
2385
2386         timeout = tvb_get_letohs (tvb, offset);
2387         proto_tree_add_uint(tree, ff_block_ack_timeout, tvb, offset, 2, timeout);
2388         length += 2;
2389         break;
2390       }
2391     /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
2392
2393     /*** Begin: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
2394     case FIELD_BLOCK_ACK_SSC:
2395       {
2396         guint16 ssc;
2397         proto_item *ssc_item;
2398         proto_tree *ssc_tree;
2399
2400         ssc = tvb_get_letohs (tvb, offset);
2401         ssc_item = proto_tree_add_uint(tree, ff_block_ack_ssc, tvb, offset, 2, ssc);
2402         ssc_tree = proto_item_add_subtree (ssc_item, ett_ff_ba_ssc_tree);
2403         proto_tree_add_uint(ssc_tree, ff_block_ack_ssc_fragment, tvb, offset, 1, ssc);
2404         proto_tree_add_uint(ssc_tree, ff_block_ack_ssc_sequence, tvb, offset, 2, ssc);
2405         length += 2;
2406         break;
2407       }
2408     /*** End: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
2409
2410     case FIELD_QOS_TS_INFO:
2411       {
2412         proto_item *tsinfo_item;
2413         proto_tree *tsinfo_tree;
2414         guint32 tsi;
2415
2416         tsinfo_item = proto_tree_add_item(tree, hf_ts_info, tvb,
2417           offset, 3, TRUE);
2418         tsinfo_tree = proto_item_add_subtree(tsinfo_item, ett_tsinfo_tree);
2419         tsi = tvb_get_letoh24(tvb, offset);
2420         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_type, tvb,
2421           offset, 3, TSI_TYPE (tsi));
2422         if (TSI_TSID (tsi) < 8)
2423         {
2424           proto_tree_add_text(tsinfo_tree, tvb, offset, 3,
2425             "TSID: %u (< 8 is invalid)", TSI_TSID (tsi));
2426         }
2427         else
2428         {
2429           proto_tree_add_uint(tsinfo_tree, hf_tsinfo_tsid, tvb,
2430             offset, 3, TSI_TSID (tsi));
2431         }
2432         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_dir, tvb,
2433           offset, 3, TSI_DIR (tsi));
2434         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_access, tvb,
2435           offset, 3, TSI_ACCESS (tsi));
2436         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_agg, tvb,
2437           offset, 3, TSI_AGG (tsi));
2438         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_apsd, tvb,
2439           offset, 3, TSI_APSD (tsi));
2440         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_up, tvb,
2441           offset, 3, TSI_UP (tsi));
2442         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_ack, tvb,
2443           offset, 3, TSI_ACK (tsi));
2444         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_sched, tvb,
2445           offset, 3, TSI_SCHED (tsi));
2446         length += 3;
2447         break;
2448       }
2449
2450     case FIELD_DLS_ACTION_CODE:
2451       proto_tree_add_item (tree, ff_dls_action_code, tvb, offset, 1, TRUE);
2452       length += 1;
2453       break;
2454
2455     case FIELD_DST_MAC_ADDR:
2456       proto_tree_add_item (tree, ff_dst_mac_addr, tvb, offset, 6, TRUE);
2457       length += 6;
2458       break;
2459
2460     case FIELD_SRC_MAC_ADDR:
2461       proto_tree_add_item (tree, ff_src_mac_addr, tvb, offset, 6, TRUE);
2462       length += 6;
2463       break;
2464
2465     case FIELD_DLS_TIMEOUT:
2466       proto_tree_add_item (tree, ff_dls_timeout, tvb, offset, 2, TRUE);
2467       length += 2;
2468       break;
2469
2470     /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
2471     case FIELD_DELBA_PARAM_SET:
2472       {
2473         guint16 params;
2474         proto_item *param_item;
2475         proto_tree *param_tree;
2476
2477         params = tvb_get_letohs (tvb, offset);
2478
2479         param_item = proto_tree_add_uint(tree, ff_delba_param, tvb, offset, 2, params);
2480         param_tree = proto_item_add_subtree (param_item, ett_ff_ba_param_tree);
2481
2482         proto_tree_add_uint(param_tree, ff_delba_param_reserved, tvb, offset, 2, params);
2483         proto_tree_add_boolean(param_tree, ff_delba_param_init, tvb, offset+1, 1, params);
2484         proto_tree_add_uint(param_tree, ff_delba_param_tid, tvb, offset+1, 1, params);
2485         length +=2;
2486         break;
2487       }
2488     /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
2489
2490     /*** Begin: Max Regulation Power Fixed Field - Dustin Johnson ***/
2491     case FIELD_MAX_REG_PWR:
2492       proto_tree_add_uint(tree, ff_max_reg_pwr, tvb, offset, 2, tvb_get_letohs (tvb, offset));
2493       length +=2;
2494       break;
2495     /*** End: Max Regulation Power Fixed Field - Dustin Johnson ***/
2496
2497     /*** Begin: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
2498     case FIELD_MEASUREMENT_PILOT_INT:
2499       proto_tree_add_uint(tree, ff_measurement_pilot_int, tvb, offset, 2, tvb_get_letohs (tvb, offset));
2500       length +=2;
2501       break;
2502     /*** End: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
2503
2504     /*** Begin: Country String Fixed Field - Dustin Johnson ***/
2505     case FIELD_COUNTRY_STR:
2506       {
2507         guint8 *country_string;
2508
2509         country_string = tvb_get_ephemeral_string(tvb, offset, 3);
2510         proto_tree_add_string (tree, ff_country_str, tvb, offset, 3, (char *) country_string);
2511         break;
2512       }
2513     /*** End: Country String Fixed Field - Dustin Johnson ***/
2514
2515     /*** Begin: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
2516     case FIELD_MAX_TX_PWR:
2517       proto_tree_add_uint(tree, ff_max_tx_pwr, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2518       length +=1;
2519       break;
2520     /*** End: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
2521
2522     /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
2523     case FIELD_TX_PWR_USED:
2524       proto_tree_add_uint(tree, ff_tx_pwr_used, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2525       length +=1;
2526       break;
2527     /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
2528
2529     /*** Begin: Transceiver Noise Floor Fixed Field - Dustin Johnson ***/
2530     case FIELD_TRANSCEIVER_NOISE_FLOOR:
2531       proto_tree_add_uint(tree, ff_transceiver_noise_floor, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2532       length +=1;
2533       break;
2534     /*** End: Transceiver Noise Floor Fixed Field - Dustin Johnson ***/
2535
2536     /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
2537     case FIELD_CHANNEL_WIDTH:
2538       proto_tree_add_item(tree, ff_channel_width, tvb, offset, 1, TRUE);
2539       length +=1;
2540       break;
2541     /*** End: Channel Width Fixed Field - Dustin Johnson ***/
2542
2543     /*** Begin: QoS Information AP Fixed Field - Dustin Johnson ***/
2544     case FIELD_QOS_INFO_AP:
2545       {
2546         guint8 info;
2547         proto_item *info_item;
2548         proto_tree *info_tree;
2549
2550         info = tvb_get_guint8 (tvb, offset);
2551
2552         info_item = proto_tree_add_uint(tree, ff_qos_info_ap, tvb, offset, 1, info);
2553         info_tree = proto_item_add_subtree (info_item, ett_ff_qos_info);
2554
2555         proto_tree_add_uint(info_tree, ff_qos_info_ap_edca_param_set_counter, tvb, offset, 1, info);
2556         proto_tree_add_uint(info_tree, ff_qos_info_ap_q_ack, tvb, offset, 1, info);
2557         proto_tree_add_boolean(info_tree, ff_qos_info_ap_queue_req, tvb, offset, 1, info);
2558         proto_tree_add_boolean(info_tree, ff_qos_info_ap_txop_request, tvb, offset, 1, info);
2559         proto_tree_add_boolean(info_tree, ff_qos_info_ap_reserved, tvb, offset, 1, info);
2560         length +=1;
2561         break;
2562       }
2563     /*** End: QoS Information AP Fixed Field - Dustin Johnson ***/
2564
2565     /*** Begin: QoS Information STA Fixed Field - Dustin Johnson ***/
2566     case FIELD_QOS_INFO_STA:
2567       {
2568         guint8 info;
2569         proto_item *info_item;
2570         proto_tree *info_tree;
2571
2572         info = tvb_get_guint8 (tvb, offset);
2573
2574         info_item = proto_tree_add_uint(tree, ff_qos_info_sta, tvb, offset, 1, info);
2575         info_tree = proto_item_add_subtree (info_item, ett_ff_qos_info);
2576
2577         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_vo, tvb, offset, 1, info);
2578         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_vi, tvb, offset, 1, info);
2579         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_bk, tvb, offset, 1, info);
2580         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_be, tvb, offset, 1, info);
2581         proto_tree_add_boolean(info_tree, ff_qos_info_sta_q_ack, tvb, offset, 1, info);
2582         proto_tree_add_uint(info_tree, ff_qos_info_sta_max_sp_len, tvb, offset, 1, info);
2583         proto_tree_add_boolean(info_tree, ff_qos_info_sta_more_data_ack, tvb, offset, 1, info);
2584
2585         length +=1;
2586         break;
2587       }
2588     /*** End: QoS Information STA Fixed Field - Dustin Johnson ***/
2589
2590     /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
2591     case FIELD_SM_PWR_CNTRL:
2592       {
2593         guint8 info;
2594         proto_item *info_item;
2595         proto_tree *info_tree;
2596
2597         info = tvb_get_guint8 (tvb, offset);
2598
2599         info_item = proto_tree_add_uint(tree, ff_sm_pwr_save, tvb, offset, 1, info);
2600         info_tree = proto_item_add_subtree (info_item, ett_ff_sm_pwr_save);
2601
2602         proto_tree_add_boolean(info_tree, ff_sm_pwr_save_enabled, tvb, offset, 1, info);
2603         proto_tree_add_boolean(info_tree, ff_sm_pwr_save_sm_mode, tvb, offset, 1, info);
2604         proto_tree_add_uint(info_tree, ff_sm_pwr_save_reserved, tvb, offset, 1, info);
2605         length +=1;
2606         break;
2607       }
2608     /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
2609
2610     /*** Begin: PCO Phase Control Fixed Field - Dustin Johnson ***/
2611     case FIELD_PCO_PHASE_CNTRL:
2612         proto_tree_add_item(tree, ff_pco_phase_cntrl, tvb, offset, 1, TRUE);
2613         length +=1;
2614         break;
2615     /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
2616
2617     /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
2618     case FIELD_PSMP_PARAM_SET:
2619       {
2620         guint16 params;
2621         proto_item *param_item;
2622         proto_tree *param_tree;
2623
2624         params = tvb_get_letohs (tvb, offset);
2625
2626         param_item = proto_tree_add_uint(tree, ff_psmp_param_set, tvb, offset, 2, params);
2627         param_tree = proto_item_add_subtree (param_item, ett_ff_psmp_param_set);
2628
2629         proto_tree_add_uint(param_tree, ff_psmp_param_set_n_sta, tvb, offset, 1, params & 0x000F);
2630         proto_tree_add_boolean(param_tree, ff_psmp_param_set_more_psmp, tvb, offset, 1, (params & 0x0010) >> 4);
2631         proto_tree_add_uint_format(param_tree, ff_psmp_param_set_psmp_sequence_duration, tvb, offset, 2,
2632           (params & 0xFFE0) >> 5, "PSMP Sequence Duration: %u [us]", ((params & 0xFFE0) >> 5) * 8);
2633         length +=2;
2634         break;
2635       }
2636     /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
2637
2638     /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
2639     case FIELD_MIMO_CNTRL:
2640       {
2641         guint16 mimo;
2642         guint32 time;
2643         proto_item *mimo_item;
2644         proto_tree *mimo_tree;
2645
2646         mimo = tvb_get_letohs (tvb, offset);
2647
2648         mimo_item = proto_tree_add_text(tree, tvb, offset, 2, "MIMO Control");
2649         mimo_tree = proto_item_add_subtree (mimo_item, ett_ff_mimo_cntrl);
2650
2651         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_nc_index, tvb, offset, 1, mimo);
2652         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_nr_index, tvb, offset, 1, mimo);
2653         proto_tree_add_boolean(mimo_tree, ff_mimo_cntrl_channel_width, tvb, offset, 1, mimo);
2654         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_grouping, tvb, offset, 1, mimo);
2655         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_coefficient_size, tvb, offset, 2, mimo);
2656         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_codebook_info, tvb, offset+1, 1, mimo);
2657         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_remaining_matrix_segment, tvb, offset+1, 1, mimo);
2658         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_reserved, tvb, offset+1, 1, mimo);
2659
2660         offset+=2;
2661         time = tvb_get_letohl (tvb, offset);
2662         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_sounding_timestamp, tvb, offset, 4, time);
2663         length +=6;
2664         break;
2665       }
2666     /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
2667
2668     /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
2669     case FIELD_ANT_SELECTION:
2670       {
2671         guint8 ant;
2672         proto_item *ant_item;
2673         proto_tree *ant_tree;
2674
2675         ant = tvb_get_guint8 (tvb, offset);
2676
2677         ant_item = proto_tree_add_uint(tree, ff_ant_selection, tvb, offset, 1, ant);
2678         ant_tree = proto_item_add_subtree (ant_item, ett_ff_ant_sel);
2679
2680         proto_tree_add_uint(ant_tree, ff_ant_selection_0, tvb, offset, 1, ant);
2681         proto_tree_add_uint(ant_tree, ff_ant_selection_1, tvb, offset, 1, ant);
2682         proto_tree_add_uint(ant_tree, ff_ant_selection_2, tvb, offset, 1, ant);
2683         proto_tree_add_uint(ant_tree, ff_ant_selection_3, tvb, offset, 1, ant);
2684         proto_tree_add_uint(ant_tree, ff_ant_selection_4, tvb, offset, 1, ant);
2685         proto_tree_add_uint(ant_tree, ff_ant_selection_5, tvb, offset, 1, ant);
2686         proto_tree_add_uint(ant_tree, ff_ant_selection_6, tvb, offset, 1, ant);
2687         proto_tree_add_uint(ant_tree, ff_ant_selection_7, tvb, offset, 1, ant);
2688
2689         length +=1;
2690         break;
2691       }
2692     /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
2693
2694     /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
2695     case FIELD_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT:
2696       {
2697         guint32 ext_chan;
2698         proto_item *chan_item;
2699         proto_tree *chan_tree;
2700
2701         ext_chan = tvb_get_letohl (tvb, offset);
2702
2703         chan_item = proto_tree_add_uint(tree, ff_ext_channel_switch_announcement, tvb, offset, 1, ext_chan);
2704         chan_tree = proto_item_add_subtree (chan_item, ett_ff_chan_switch_announce);
2705
2706         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_switch_mode, tvb, offset++, 1, (ext_chan & 0x000000FF));
2707         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_new_reg_class, tvb, offset++, 1, (ext_chan & 0x0000FF00) >> 8);
2708         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_new_chan_number, tvb, offset++, 1, (ext_chan & 0x00FF0000) >> 16);
2709         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_switch_count, tvb, offset++, 1, (ext_chan & 0xFF000000) >> 24);
2710         length += 4;
2711         break;
2712       }
2713     /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
2714
2715     /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
2716     case FIELD_HT_INFORMATION:
2717       {
2718         guint8 info;
2719         proto_item *ht_item;
2720         proto_tree *ht_tree;
2721
2722         info = tvb_get_guint8 (tvb, offset);
2723
2724         ht_item = proto_tree_add_uint(tree, ff_ht_info, tvb, offset, 1, info);
2725         ht_tree = proto_item_add_subtree (ht_item, ett_ff_ht_info);
2726
2727         proto_tree_add_boolean(ht_tree, ff_ht_info_information_request, tvb, offset, 1, info);
2728         proto_tree_add_boolean(ht_tree, ff_ht_info_40_mhz_intolerant, tvb, offset, 1, info);
2729         proto_tree_add_boolean(ht_tree, ff_ht_info_sta_chan_width, tvb, offset, 1, info);
2730         proto_tree_add_uint(ht_tree, ff_ht_info_reserved, tvb, offset, 1, info);
2731         length += 1;
2732         break;
2733       }
2734       /*** End: HT Information Fixed Field - Dustin Johnson ***/
2735
2736     /*** Begin: HT Action Fixed Field - Dustin Johnson ***/
2737     case FIELD_HT_ACTION_CODE:
2738         proto_tree_add_uint(tree, ff_ht_action, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2739         length +=1;
2740         break;
2741     /*** End: HT Action Fixed Field - Dustin Johnson ***/
2742
2743     /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
2744     case FIELD_PSMP_STA_INFO:
2745       {
2746         #define BROADCAST 0
2747         #define MULTICAST 1
2748         #define INDIVIDUALLY_ADDRESSED 2
2749
2750         guint64 info_large;
2751         guint32 info_medium;
2752         guint16 info_small;
2753         guint8 type;
2754         proto_item *psmp_item;
2755         proto_tree *psmp_tree;
2756
2757         info_medium = tvb_get_letohl (tvb, offset);
2758         type = info_medium & 0x3;
2759
2760         psmp_item = proto_tree_add_uint(tree, ff_psmp_sta_info, tvb, offset, 8, type);
2761         psmp_tree = proto_item_add_subtree (psmp_item, ett_ff_psmp_sta_info);
2762
2763         switch (type)
2764           {
2765             case BROADCAST:
2766               {
2767                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_start_offset, tvb, offset, 2, (info_medium & 0x00001FFC) >> 2);
2768                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_duration, tvb, offset+1, 2, (info_medium & 0x001FE000) >> 13);
2769                 info_large = tvb_get_letoh64 (tvb, offset);
2770                 proto_tree_add_uint64(psmp_tree, ff_psmp_sta_info_reserved_large, tvb, offset, 6, (info_large & G_GINT64_CONSTANT(0xFFFFFFFFFFE00000)) >> 21);
2771                 break;
2772               }
2773
2774             case MULTICAST:
2775               {
2776                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_start_offset, tvb, offset, 2, (info_medium & 0x00001FFC) >> 2);
2777                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_duration, tvb, offset+1, 2, (info_medium & 0x001FE000) >> 13);
2778                 info_large = tvb_get_letoh64 (tvb, offset);
2779                 proto_tree_add_uint64(psmp_tree, ff_psmp_sta_info_psmp_multicast_id, tvb, offset, 6, (info_large & G_GINT64_CONSTANT(0xFFFFFFFFFFE00000)) >> 21);
2780                 break;
2781               }
2782
2783             case INDIVIDUALLY_ADDRESSED:
2784               {
2785                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_start_offset, tvb, offset, 2, (info_medium & 0x00001FFC) >> 2);
2786                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_duration, tvb, offset+1, 2, (info_medium & 0x001FE000) >> 13);
2787                 offset+=2;
2788                 info_medium = tvb_get_letohl (tvb, offset);
2789                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_sta_id, tvb, offset, 3, (info_medium & 0x001FFFE0) >> 5);
2790                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_utt_start_offset, tvb, offset+2, 2, (info_medium & 0xFFE00000) >> 21);
2791                 offset+=4;
2792                 info_small = tvb_get_letohs (tvb, offset);
2793                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_utt_duration, tvb, offset, 2, info_small & 0x03FF);
2794                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_reserved_small, tvb, offset+1, 1, (info_small & 0xFC00) >> 10);
2795                 break;
2796               }
2797           }
2798         length +=8;
2799         break;
2800       }
2801     /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
2802
2803     case FIELD_SCHEDULE_INFO:
2804       {
2805         proto_item *sched_item;
2806         proto_tree *sched_tree;
2807         guint16 sched;
2808
2809         sched_item = proto_tree_add_item(tree, hf_sched_info,
2810           tvb, offset, 2, TRUE);
2811         sched_tree = proto_item_add_subtree(sched_item, ett_sched_tree);
2812         sched = tvb_get_letohs(tvb, offset);
2813         proto_tree_add_uint(sched_tree, hf_tsinfo_agg, tvb, offset,
2814           2, sched & 0x0001);
2815         if (sched & 0x0001)
2816         {
2817           proto_tree_add_uint(sched_tree, hf_tsinfo_tsid, tvb, offset,
2818             2, (sched & 0x001E) >> 1);
2819           proto_tree_add_uint(sched_tree, hf_tsinfo_dir, tvb, offset,
2820             2, (sched & 0x0060) >> 5);
2821         }
2822
2823         length += 2;
2824         break;
2825       }
2826
2827     case FIELD_ACTION:
2828       {
2829         proto_item *action_item;
2830         proto_tree *action_tree;
2831
2832         action_item = proto_tree_add_item(tree, hf_action, tvb, offset, 1, TRUE);
2833         action_tree = proto_item_add_subtree(action_item, ett_sched_tree);
2834
2835         switch (tvb_get_guint8(tvb, offset))
2836           {
2837             case CAT_SPECTRUM_MGMT:
2838               {
2839                 switch (tvb_get_guint8(tvb, offset+1))
2840                   {
2841                     case SM_ACTION_MEASUREMENT_REQUEST:
2842                     case SM_ACTION_MEASUREMENT_REPORT:
2843                     case SM_ACTION_TPC_REQUEST:
2844                     case SM_ACTION_TPC_REPORT:
2845                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2846                       add_fixed_field(action_tree, tvb, offset+1, FIELD_ACTION_CODE);
2847                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DIALOG_TOKEN);
2848                       length += 3;  /* Size of fixed fields */
2849                       break;
2850
2851                     case SM_ACTION_CHAN_SWITCH_ANNC:
2852                     case SM_ACTION_EXT_CHAN_SWITCH_ANNC:
2853                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2854                       add_fixed_field(action_tree, tvb, offset+1, FIELD_ACTION_CODE);
2855                       length += 2;  /* Size of fixed fields */
2856                       break;
2857
2858                     default:
2859                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2860                       add_fixed_field(action_tree, tvb, offset+1, FIELD_ACTION_CODE);
2861                       length += 2;  /* Size of fixed fields */
2862                       break;
2863                   }
2864                 break;
2865               }
2866
2867             case CAT_QOS:
2868               {
2869                 switch (tvb_get_guint8(tvb, offset+1))
2870                   {
2871                     case SM_ACTION_ADDTS_REQUEST:
2872                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2873                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2874                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DIALOG_TOKEN);
2875                       length += 3;
2876                       break;
2877
2878                     case SM_ACTION_ADDTS_RESPONSE:
2879                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2880                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2881                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DIALOG_TOKEN);
2882                       add_fixed_field(action_tree, tvb, offset+3, FIELD_STATUS_CODE);
2883                       length += 5;
2884                       break;
2885
2886                     case SM_ACTION_DELTS:
2887                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2888                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2889                       add_fixed_field(action_tree, tvb, offset+2, FIELD_QOS_TS_INFO);
2890                       add_fixed_field(action_tree, tvb, offset+5, FIELD_REASON_CODE);
2891                       length += 7;
2892                       break;
2893
2894                     case SM_ACTION_QOS_SCHEDULE:
2895                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2896                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2897                       length += 2;
2898                       break;
2899
2900                     default:
2901                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2902                       length += 2;  /* Size of fixed fields */
2903                       break;
2904                   }
2905                 break;
2906               }
2907
2908             case CAT_DLS:
2909               {
2910                 switch (tvb_get_guint8(tvb, offset+1))
2911                   {
2912                     case SM_ACTION_DLS_REQUEST:
2913                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2914                       add_fixed_field(action_tree, tvb, offset+1, FIELD_DLS_ACTION_CODE);
2915                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DST_MAC_ADDR);
2916                       add_fixed_field(action_tree, tvb, offset+8, FIELD_SRC_MAC_ADDR);
2917                       add_fixed_field(action_tree, tvb, offset+14, FIELD_CAP_INFO);
2918                       add_fixed_field(action_tree, tvb, offset+16, FIELD_DLS_TIMEOUT);
2919                       length += 18;
2920                       break;
2921
2922                     case SM_ACTION_DLS_RESPONSE:
2923                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2924                       add_fixed_field(action_tree, tvb, offset+1, FIELD_DLS_ACTION_CODE);
2925                       add_fixed_field(action_tree, tvb, offset+2, FIELD_STATUS_CODE);
2926                       add_fixed_field(action_tree, tvb, offset+4, FIELD_DST_MAC_ADDR);
2927                       add_fixed_field(action_tree, tvb, offset+10, FIELD_SRC_MAC_ADDR);
2928                       length += 16;
2929                       if (!ff_status_code)
2930                         add_fixed_field(action_tree, tvb, offset+16, FIELD_CAP_INFO);
2931                       break;
2932
2933                     case SM_ACTION_DLS_TEARDOWN:
2934                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2935                       add_fixed_field(action_tree, tvb, offset+1, FIELD_DLS_ACTION_CODE);
2936                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DST_MAC_ADDR);
2937                       add_fixed_field(action_tree, tvb, offset+8, FIELD_SRC_MAC_ADDR);
2938                       add_fixed_field(action_tree, tvb, offset+14, FIELD_REASON_CODE);
2939                       length += 16;
2940                       break;
2941
2942                     default:
2943                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2944                       length += 2;  /* Size of fixed fields */
2945                       break;
2946                   }
2947                 break;
2948               }
2949
2950             case CAT_BLOCK_ACK:
2951               {
2952                 switch (tvb_get_guint8(tvb, offset+1))
2953                   {
2954                     case BA_ADD_BLOCK_ACK_REQUEST:
2955                       {
2956                         guint start = 0;
2957                         start = offset;
2958
2959                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2960                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_ACTION_CODE);
2961                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_DIALOG_TOKEN);
2962                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_PARAM);
2963                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_TIMEOUT);
2964                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
2965                         length = offset - start;  /* Size of fixed fields */
2966                         break;
2967                       }
2968                     case BA_ADD_BLOCK_ACK_RESPONSE:
2969                       {
2970                         guint start = 0;
2971                         start = offset;
2972
2973                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2974                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_ACTION_CODE);
2975                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_DIALOG_TOKEN);
2976                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_STATUS_CODE);
2977                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_PARAM);
2978                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_TIMEOUT);
2979                         length = offset - start;  /* Size of fixed fields */
2980                         break;
2981                       }
2982                     case BA_DELETE_BLOCK_ACK:
2983                       {
2984                         guint start = 0;
2985                         start = offset;
2986
2987                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2988                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_ACTION_CODE);
2989                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_DELBA_PARAM_SET);
2990                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_REASON_CODE);
2991                         length = offset - start;  /* Size of fixed fields */
2992                         break;
2993                       }
2994                   }
2995                 break;
2996               }
2997
2998             case CAT_MGMT_NOTIFICATION:  /* Management notification frame */
2999               {
3000                 guint start = 0;
3001                 start = offset;
3002
3003                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3004                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_WME_ACTION_CODE);
3005                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_DIALOG_TOKEN);
3006                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_WME_STATUS_CODE);
3007                 length = offset - start;  /* Size of fixed fields */
3008                 break;
3009               }
3010
3011           case CAT_VENDOR_SPECIFIC:/* Vendor Specific Category */
3012                   {
3013                           guint start = 0;
3014                           guint32 oui;
3015                           const guint8 *tag_data_ptr;
3016                           guint8 octet;
3017
3018                           start = offset;
3019
3020               offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3021                           oui = tvb_get_ntoh24(tvb, offset);
3022                           tag_data_ptr = tvb_get_ptr(tvb, offset, 3);
3023                           proto_tree_add_bytes_format (action_tree, tag_oui, tvb, offset, 3,
3024                                   tag_data_ptr, "Vendor: %s", get_manuf_name(tag_data_ptr));
3025                           offset+=3;
3026                           switch(oui){
3027                                   case OUI_MARVELL:
3028                                           octet = tvb_get_guint8(tvb, offset);
3029                                           proto_tree_add_item (action_tree, ff_marvell_action_type, tvb, offset, 1, TRUE);
3030                                           offset++;
3031                                           switch (octet){
3032                                                   case MRVL_ACTION_MESH_MANAGEMENT:
3033                                                           octet = tvb_get_guint8(tvb, offset);
3034                                                           proto_tree_add_item (action_tree, ff_marvell_mesh_mgt_action_code, tvb, offset, 1, TRUE);
3035                                                           offset++;
3036                                                           switch (octet){
3037                                                                   case MRVL_MESH_MGMT_ACTION_RREQ:
3038                                                                           proto_tree_add_item (action_tree, ff_mesh_mgt_length, tvb, offset, 1, TRUE);
3039                                                                           offset++;
3040                                                                           proto_tree_add_item (action_tree, ff_mesh_mgt_mode, tvb, offset, 1, TRUE);
3041                                                                           offset++;
3042                                                                           proto_tree_add_item (tree, ff_mesh_mgt_hopcount, tvb, offset, 1, TRUE);
3043                                                                           offset++;
3044                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ttl, tvb, offset, 1, TRUE);
3045                                                                           offset++;
3046                                                                           proto_tree_add_item (tree, ff_mesh_mgt_rreqid, tvb, offset, 4, TRUE);
3047                                                                           offset+= 4;
3048                                                                           proto_tree_add_item (tree, ff_mesh_mgt_sa, tvb, offset, 6, FALSE);
3049                                                                           offset+= 6;
3050                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ssn, tvb, offset, 4, TRUE);
3051                                                                           offset+= 4;
3052                                                                           proto_tree_add_item (tree, ff_mesh_mgt_lifetime, tvb, offset, 4, TRUE);
3053                                                                           offset+= 4;
3054                                                                           proto_tree_add_item (tree, ff_mesh_mgt_metric, tvb, offset, 4, TRUE);
3055                                                                           offset+= 4;
3056                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dstcount, tvb, offset, 1, TRUE);
3057                                                                           offset++;
3058                                                                           proto_tree_add_item (tree, ff_mesh_mgt_flags, tvb, offset, 1, TRUE);
3059                                                                           offset++;
3060                                                                           proto_tree_add_item (tree, ff_mesh_mgt_da, tvb, offset, 6, FALSE);
3061                                                                           offset+= 6;
3062                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dsn, tvb, offset, 4, TRUE);
3063                                                                           offset+= 4;
3064                                                                           length = offset - start;  /* Size of fixed fields */
3065                                                                           break;
3066                                                                   case MRVL_MESH_MGMT_ACTION_RREP:
3067                                                                           proto_tree_add_item (tree, ff_mesh_mgt_length, tvb, offset, 1, TRUE);
3068                                                                           offset++;
3069                                                                           proto_tree_add_item (tree, ff_mesh_mgt_mode, tvb, offset, 1, TRUE);
3070                                                                           offset++;
3071                                                                           proto_tree_add_item (tree, ff_mesh_mgt_hopcount, tvb, offset, 1, TRUE);
3072                                                                           offset++;
3073                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ttl, tvb, offset, 1, TRUE);
3074                                                                           offset++;
3075                                                                           proto_tree_add_item (tree, ff_mesh_mgt_da, tvb, offset, 6, FALSE);
3076                                                                           offset+= 6;
3077                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dsn, tvb, offset, 4, TRUE);
3078                                                                           offset+= 4;
3079                                                                           proto_tree_add_item (tree, ff_mesh_mgt_lifetime, tvb, offset, 4, TRUE);
3080                                                                           offset+= 4;
3081                                                                           proto_tree_add_item (tree, ff_mesh_mgt_metric, tvb, offset, 4, TRUE);
3082                                                                           offset+= 4;
3083                                                                           proto_tree_add_item (tree, ff_mesh_mgt_sa, tvb, offset, 6, FALSE);
3084                                                                           offset+= 6;
3085                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ssn, tvb, offset, 4, TRUE);
3086                                                                           offset+= 4;
3087                                                                           length = offset - start;  /* Size of fixed fields */
3088                                                                           break;
3089                                                                   case MRVL_MESH_MGMT_ACTION_RERR:
3090                                                                           proto_tree_add_item (tree, ff_mesh_mgt_length, tvb, offset, 1, TRUE);
3091                                                                           offset++;
3092                                                                           proto_tree_add_item (tree, ff_mesh_mgt_mode, tvb, offset, 1, TRUE);
3093                                                                           offset++;
3094                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dstcount, tvb, offset, 1, TRUE);
3095                                                                           offset++;
3096                                                                           proto_tree_add_item (tree, ff_mesh_mgt_da, tvb, offset, 6, FALSE);
3097                                                                           offset+= 6;
3098                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dsn, tvb, offset, 4, TRUE);
3099                                                                           offset+= 4;
3100                                                                           length = offset - start;  /* Size of fixed fields */
3101                                                                           break;
3102                                                                   default:
3103                                                                           break;
3104                                                           }
3105                                                           break;
3106                                                   default:
3107                                                           break;
3108                                           }
3109                                           break;
3110                                   default:
3111                                           /* Don't know how to handle this vendor */
3112                                           break;
3113                           }/* switch(oui) */
3114                           break;
3115                   }/* Case vendor specific */
3116
3117             case CAT_HT:
3118               {
3119                 guint start = 0;
3120                 start = offset;
3121
3122                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3123                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_HT_ACTION_CODE);
3124                 switch (tvb_get_guint8(tvb, offset-1))
3125                   {
3126                     case HT_ACTION_NOTIFY_CHAN_WIDTH:
3127                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_CHANNEL_WIDTH);
3128                       break;
3129
3130                     case HT_ACTION_SM_PWR_SAVE:
3131                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_SM_PWR_CNTRL);
3132                       break;
3133
3134                     case HT_ACTION_PSMP_ACTION:
3135                       {
3136                         guint8 n_sta, i;
3137
3138                         n_sta = tvb_get_guint8(tvb, offset);
3139                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_PSMP_PARAM_SET);
3140
3141                         for (i=0; i< (n_sta & 0x0F); i++)
3142                           offset += add_fixed_field(action_tree, tvb, offset, FIELD_PSMP_STA_INFO);
3143
3144                         break;
3145                       }
3146
3147                     case HT_ACTION_SET_PCO_PHASE:
3148                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_PCO_PHASE_CNTRL);
3149                       break;
3150
3151                     case HT_ACTION_MIMO_CSI:
3152                       {
3153                         mimo_control_t mimo_cntrl;
3154                         mimo_cntrl = get_mimo_control (tvb, offset);
3155                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_MIMO_CNTRL);
3156                         offset += add_mimo_csi_matrices_report (action_tree, tvb, offset, mimo_cntrl);
3157                         break;
3158                       }
3159
3160                     case HT_ACTION_MIMO_BEAMFORMING:
3161                       {
3162                         mimo_control_t mimo_cntrl;
3163                         mimo_cntrl = get_mimo_control (tvb, offset);
3164                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_MIMO_CNTRL);
3165                         offset += add_mimo_beamforming_feedback_report (action_tree, tvb, offset, mimo_cntrl);
3166                         break;
3167                       }
3168
3169                     case HT_ACTION_MIMO_COMPRESSED_BEAMFORMING:
3170                       {
3171                         mimo_control_t mimo_cntrl;
3172                         mimo_cntrl = get_mimo_control (tvb, offset);
3173                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_MIMO_CNTRL);
3174                         offset += add_mimo_compressed_beamforming_feedback_report (action_tree, tvb, offset, mimo_cntrl);
3175                         break;
3176                       }
3177
3178                     case HT_ACTION_ANT_SEL_FEEDBACK:
3179                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_ANT_SELECTION);
3180                       break;
3181
3182                     case HT_ACTION_HT_INFO_EXCHANGE:
3183                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_HT_INFORMATION);
3184                       break;
3185
3186                     default:
3187                       /* Unknown */
3188                       break;
3189                   }
3190                 length = offset - start;
3191                 break;
3192               }
3193
3194             default:
3195               add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3196               length += 1;  /* Size of fixed fields */
3197               break;
3198           }
3199       }
3200   }
3201   return length;
3202 }
3203
3204 static const value_string wpa_cipher_vals[] =
3205 {
3206   {0, "NONE"},
3207   {1, "WEP (40-bit)"},
3208   {2, "TKIP"},
3209   {3, "AES (OCB)"},
3210   {4, "AES (CCM)"},
3211   {5, "WEP (104-bit)"},
3212   {0, NULL}
3213 };
3214
3215 static const value_string wpa_keymgmt_vals[] =
3216 {
3217   {0, "NONE"},
3218   {1, "WPA"},
3219   {2, "PSK"},
3220   {0, NULL}
3221 };
3222
3223
3224 static void
3225 dissect_vendor_ie_wpawme(proto_item * item, proto_tree * tree, tvbuff_t * tag_tvb)
3226 {
3227   gint tag_off = 0;
3228   gint tag_len = tvb_length(tag_tvb);
3229   gchar out_buff[SHORT_STR];
3230   guint i, byte1, byte2;
3231
3232   /* Wi-Fi Protected Access (WPA) Information Element */
3233   if (tag_off + 6 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WPA_OUI"\x01", 4)) {
3234     g_snprintf(out_buff, SHORT_STR, "WPA IE, type %u, version %u",
3235     tvb_get_guint8(tag_tvb, tag_off + 3), tvb_get_letohs(tag_tvb, tag_off + 4));
3236     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 6, out_buff);
3237     tag_off += 6;
3238     if (tag_off + 4 <= tag_len) {
3239       /* multicast cipher suite */
3240       if (!tvb_memeql(tag_tvb, tag_off, WPA_OUI, 3)) {
3241         g_snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s",
3242         val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3), wpa_cipher_vals,
3243           "UNKNOWN"));
3244         proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3245           out_buff);
3246         tag_off += 4;
3247         /* unicast cipher suites */
3248         if (tag_off + 2 <= tag_len) {
3249           g_snprintf(out_buff, SHORT_STR,
3250             "# of unicast cipher suites: %u", tvb_get_letohs(tag_tvb, tag_off));
3251           proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3252             out_buff);
3253           tag_off += 2;
3254           i = 1;
3255           while (tag_off + 4 <= tag_len) {
3256             if (!tvb_memeql(tag_tvb, tag_off, WPA_OUI, 3)) {
3257               g_snprintf(out_buff, SHORT_STR,
3258                 "Unicast cipher suite %u: %s", i,
3259                 val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3260                 wpa_cipher_vals, "UNKNOWN"));
3261               proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3262                 out_buff);
3263               tag_off += 4;
3264               i ++;
3265             }
3266             else
3267               break;
3268           }
3269           /* authenticated key management suites */
3270           if (tag_off + 2 <= tag_len) {
3271             g_snprintf(out_buff, SHORT_STR,
3272               "# of auth key management suites: %u", tvb_get_letohs(tag_tvb, tag_off));
3273             proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3274               out_buff);
3275             tag_off += 2;
3276             i = 1;
3277             while (tag_off + 4 <= tag_len) {
3278               if (!tvb_memeql(tag_tvb, tag_off, WPA_OUI, 3)) {
3279                 g_snprintf(out_buff, SHORT_STR,
3280                   "auth key management suite %u: %s", i,
3281                   val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3282                   wpa_keymgmt_vals, "UNKNOWN"));
3283                 proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3284                   out_buff);
3285                 tag_off += 4;
3286                 i ++;
3287               }
3288               else
3289                 break;
3290             }
3291           }
3292         }
3293       }
3294     }
3295     if (tag_off < tag_len)
3296       proto_tree_add_string(tree, tag_interpretation, tag_tvb,
3297         tag_off, tag_len - tag_off, "Not interpreted");
3298       proto_item_append_text(item, ": WPA");
3299   } else if (tag_off + 7 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WME_OUI"\x02\x00", 5)) {
3300     /* Wireless Multimedia Enhancements (WME) Information Element */
3301     g_snprintf(out_buff, SHORT_STR,
3302       "WME IE: type %u, subtype %u, version %u, parameter set %u",
3303       tvb_get_guint8(tag_tvb, tag_off+3), tvb_get_guint8(tag_tvb, tag_off+4),
3304       tvb_get_guint8(tag_tvb, tag_off+5), tvb_get_guint8(tag_tvb, tag_off+6));
3305     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 7,
3306       out_buff);
3307     proto_item_append_text(item, ": WME");
3308   } else if (tag_off + 24 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WME_OUI"\x02\x01", 5)) {
3309     /* Wireless Multimedia Enhancements (WME) Parameter Element */
3310     g_snprintf(out_buff, SHORT_STR,
3311       "WME PE: type %u, subtype %u, version %u, parameter set %u",
3312       tvb_get_guint8(tag_tvb, tag_off+3), tvb_get_guint8(tag_tvb, tag_off+4),
3313       tvb_get_guint8(tag_tvb, tag_off+5), tvb_get_guint8(tag_tvb, tag_off+6));
3314     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 7,
3315       out_buff);
3316     tag_off += 8;
3317     for (i = 0; i < 4; i++) {
3318       byte1 = tvb_get_guint8(tag_tvb, tag_off);
3319       byte2 = tvb_get_guint8(tag_tvb, tag_off + 1);
3320       g_snprintf(out_buff, SHORT_STR,
3321         "WME AC Parameters: ACI %u (%s), Admission Control %sMandatory, AIFSN %u, ECWmin %u, ECWmax %u, TXOP %u",
3322          (byte1 & 0x60) >> 5, wme_acs[(byte1 & 0x60) >> 5],
3323          (byte1 & 0x10) ? "" : "not ", byte1 & 0x0f,
3324          byte2 & 0x0f, byte2 & 0xf0 >> 4,
3325          tvb_get_letohs(tag_tvb, tag_off + 2));
3326       proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3327         out_buff);
3328       tag_off += 4;
3329     }
3330     proto_item_append_text(item, ": WME");
3331   } else if (tag_off + 56 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WME_OUI"\x02\x02", 5)) {
3332     /* Wireless Multimedia Enhancements (WME) TSPEC Element */
3333     guint16 ts_info, msdu_size, surplus_bandwidth;
3334     const char *direction[] = { "Uplink", "Downlink", "Reserved", "Bi-directional" };
3335     const value_string fields[] = {
3336       {13, "Minimum Service Interval"},
3337       {17, "Maximum Service Interval"},
3338       {21, "Inactivity Interval"},
3339       {25, "Suspension Interval"},
3340       {29, "Service Start Time"},
3341       {33, "Minimum Data Rate"},
3342       {37, "Mean Data Rate"},
3343       {41, "Peak Data Rate"},
3344       {45, "Maximum Burst Size"},
3345       {49, "Delay Bound"},
3346       {53, "Minimum PHY Rate"},
3347       {0, NULL}
3348     };
3349     const char *field;
3350
3351     g_snprintf(out_buff, SHORT_STR,
3352       "WME TSPEC: type %u, subtype %u, version %u",
3353       tvb_get_guint8(tag_tvb, tag_off+3), tvb_get_guint8(tag_tvb, tag_off+4),
3354       tvb_get_guint8(tag_tvb, tag_off+5));
3355     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 6,
3356       out_buff);
3357     tag_off += 6;
3358
3359     ts_info = tvb_get_letohs(tag_tvb, tag_off);
3360     byte1 = (ts_info >> 11) & 0x7;
3361     g_snprintf(out_buff, SHORT_STR,
3362       "WME TS Info: Priority %u (%s) (%s), Contention-based access %sset, %s",
3363       byte1, qos_tags[byte1], qos_acs[byte1],
3364       (ts_info & 0x0080) ? "" : "not ",
3365       direction[(ts_info >> 5) & 0x3]);
3366     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 3,
3367       out_buff);
3368     tag_off += 3;
3369
3370     msdu_size = tvb_get_letohs(tag_tvb, tag_off);
3371     g_snprintf(out_buff, SHORT_STR,
3372       "WME TSPEC: %s MSDU Size %u",
3373       (msdu_size & 0x8000) ? "Fixed" : "Nominal", msdu_size & 0x7fff);
3374     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3375       out_buff);
3376     tag_off += 2;
3377
3378     g_snprintf(out_buff, SHORT_STR,
3379       "WME TSPEC: Maximum MSDU Size %u", tvb_get_letohs(tag_tvb, tag_off));
3380     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3381       out_buff);
3382     tag_off += 2;
3383
3384     while ((field = val_to_str(tag_off, fields, "Unknown"))) {
3385       g_snprintf(out_buff, SHORT_STR,
3386         "WME TSPEC: %s %u", field, tvb_get_letohl(tag_tvb, tag_off));
3387       proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3388         out_buff);
3389       tag_off += 4;
3390       if (tag_off == 57)
3391         break;
3392     }
3393
3394     surplus_bandwidth = tvb_get_letohs(tag_tvb, tag_off);
3395     g_snprintf(out_buff, SHORT_STR,
3396       "WME TSPEC: Surplus Bandwidth Allowance Factor %u.%u",
3397       (surplus_bandwidth >> 13) & 0x7, (surplus_bandwidth & 0x1fff));
3398     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3399       out_buff);
3400     tag_off += 2;
3401
3402     g_snprintf(out_buff, SHORT_STR,
3403       "WME TSPEC: Medium Time %u", tvb_get_letohs(tag_tvb, tag_off));
3404     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3405       out_buff);
3406     tag_off += 2;
3407     proto_item_append_text(item, ": WME");
3408   } else if (tag_off + 6 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WPA_OUI"\x04", 4)) {
3409     dissect_wps_tlvs(item, tag_tvb, tag_off+4, tag_len-4, NULL);
3410     proto_item_append_text(item, ": WPS");
3411   }
3412 }
3413
3414 static void
3415 dissect_vendor_ie_rsn(proto_item * item, proto_tree * tree, tvbuff_t * tag_tvb)
3416 {
3417   guint tag_off = 0;
3418   guint tag_len = tvb_length(tag_tvb);
3419   guint pmkid_len = tag_len - 4;
3420   char out_buff[SHORT_STR], valid_str[SHORT_STR] = "";
3421
3422   if (tag_len >= 4 && !tvb_memeql(tag_tvb, tag_off, RSN_OUI"\x04", 4)) {
3423     /* IEEE 802.11i / Key Data Encapsulation / Data Type=4 - PMKID.
3424      * This is only used within EAPOL-Key frame Key Data. */
3425     if (pmkid_len != PMKID_LEN) {
3426       g_snprintf(valid_str, SHORT_STR,
3427         "(invalid PMKID len=%d, expected 16) ", pmkid_len);
3428     }
3429     g_snprintf(out_buff, SHORT_STR, "RSN PMKID: %s%s", valid_str,
3430       tvb_bytes_to_str(tag_tvb, 4, pmkid_len));
3431     proto_tree_add_string(tree, tag_interpretation, tag_tvb, 0,
3432       tag_len, out_buff);
3433   }
3434   proto_item_append_text(item, ": RSN");
3435 }
3436
3437 typedef enum {
3438   MARVELL_IE_MESH = 4
3439 } marvell_ie_type_t;
3440
3441 static void
3442 dissect_vendor_ie_marvell(proto_item * item _U_, proto_tree * ietree,
3443                           tvbuff_t * tvb, int offset, guint32 tag_len)
3444 {
3445   guint8 type;
3446
3447   type = tvb_get_guint8(tvb, offset);
3448   proto_tree_add_item (ietree, hf_marvell_ie_type, tvb, offset, 1, TRUE);
3449   offset += 1;
3450
3451   switch (type) {
3452   case MARVELL_IE_MESH:
3453     proto_tree_add_item (ietree, hf_marvell_ie_mesh_subtype, tvb,
3454                          offset++, 1, TRUE );
3455     proto_tree_add_item (ietree, hf_marvell_ie_mesh_version, tvb,
3456                          offset++, 1, TRUE );
3457     proto_tree_add_item (ietree, hf_marvell_ie_mesh_active_proto_id, tvb,
3458                          offset++, 1, TRUE );
3459     proto_tree_add_item (ietree, hf_marvell_ie_mesh_active_metric_id, tvb,
3460                          offset++, 1, TRUE );
3461     proto_tree_add_item (ietree, hf_marvell_ie_mesh_cap, tvb,
3462                          offset++, 1, TRUE );
3463     break;
3464
3465   default:
3466     proto_tree_add_item(ietree, hf_marvell_ie_data, tvb, offset,
3467       tag_len - 1, FALSE);
3468     break;
3469   }
3470 }
3471
3472 typedef enum {
3473   AIRONET_IE_VERSION = 3,
3474   AIRONET_IE_QOS,
3475   AIRONET_IE_QBSS_V2 = 14
3476 } aironet_ie_type_t;
3477
3478 static const value_string aironet_ie_type_vals[] = {
3479   { AIRONET_IE_VERSION,   "CCX version"},
3480   { AIRONET_IE_QOS,       "Qos"},
3481   { AIRONET_IE_QBSS_V2,   "QBSS V2 - CCA"},
3482   { 0,                    NULL }
3483 };
3484
3485 static void
3486 dissect_vendor_ie_aironet(proto_item * aironet_item, proto_tree * ietree,
3487   tvbuff_t * tvb, int offset, guint32 tag_len)
3488 {
3489   guint8  type;
3490   int i;
3491   gboolean dont_change = FALSE; /* Don't change the IE item text to default */
3492
3493   type = tvb_get_guint8(tvb, offset);
3494   proto_tree_add_item (ietree, hf_aironet_ie_type, tvb, offset, 1, TRUE);
3495   offset += 1;
3496
3497   switch (type) {
3498   case AIRONET_IE_VERSION:
3499     proto_tree_add_item (ietree, hf_aironet_ie_version, tvb, offset, 1, TRUE);
3500     proto_item_append_text(aironet_item, ": Aironet CCX version = %d",
3501     tvb_get_guint8(tvb, offset));
3502     dont_change = TRUE;
3503     break;
3504   case AIRONET_IE_QOS:
3505     proto_tree_add_item (ietree, hf_aironet_ie_qos_unk1, tvb, offset, 1, TRUE);
3506     offset += 1;
3507     proto_tree_add_item (ietree, hf_aironet_ie_qos_paramset, tvb, offset, 1, TRUE);
3508     offset += 1;
3509
3510     /* XXX: just copied over from WME. Maybe "Best Effort" and "Background"
3511      *  need to be swapped. Also, the "TXOP" may be TXOP - or not.
3512      */
3513     for (i = 0; i < 4; i++) {
3514       guint8 byte1, byte2;
3515       guint16 txop;
3516       byte1 = tvb_get_guint8(tvb, offset);
3517       byte2 = tvb_get_guint8(tvb, offset + 1);
3518       txop = tvb_get_letohs(tvb, offset + 2);
3519       proto_tree_add_bytes_format(ietree, hf_aironet_ie_qos_val, tvb, offset, 4,
3520         tvb_get_ptr(tvb, offset, 4),
3521           "CCX QoS Parameters??: ACI %u (%s), Admission Control %sMandatory, AIFSN %u, ECWmin %u, ECWmax %u, TXOP %u",
3522         (byte1 & 0x60) >> 5, wme_acs[(byte1 & 0x60) >> 5],
3523         (byte1 & 0x10) ? "" : "not ", byte1 & 0x0f,
3524         byte2 & 0x0f, (byte2 & 0xf0) >> 4,
3525         txop);
3526       offset += 4;
3527     }
3528     break;
3529   case AIRONET_IE_QBSS_V2:
3530     /* Extract Values */
3531     proto_tree_add_item (ietree, hf_qbss2_scount, tvb, offset, 2, TRUE);
3532     proto_tree_add_item (ietree, hf_qbss2_cu, tvb, offset + 2, 1, FALSE);
3533     proto_tree_add_item (ietree, hf_qbss2_cal, tvb, offset + 3, 1, FALSE);
3534     proto_tree_add_item (ietree, hf_qbss2_gl, tvb, offset + 4, 1, FALSE);
3535     break;
3536   default:
3537     proto_tree_add_item(ietree, hf_aironet_ie_data, tvb, offset,
3538       tag_len - 1, FALSE);
3539     break;
3540   }
3541   if (!dont_change) {
3542     proto_item_append_text(aironet_item, ": Aironet %s",
3543       val_to_str(type, aironet_ie_type_vals, "Unknown"));
3544   }
3545 }
3546
3547 static void
3548 dissect_rsn_ie(proto_tree * tree, tvbuff_t * tag_tvb)
3549 {
3550   guint tag_off = 0;
3551   guint tag_len = tvb_length(tag_tvb);
3552   guint16 rsn_capab;
3553   char out_buff[SHORT_STR];
3554   int i, count;
3555   proto_item *cap_item;
3556   proto_tree *cap_tree;
3557
3558   if (tag_off + 2 > tag_len) {
3559     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, tag_len,
3560         "Not interpreted");
3561     return;
3562   }
3563
3564   g_snprintf(out_buff, SHORT_STR, "RSN IE, version %u",
3565      tvb_get_letohs(tag_tvb, tag_off));
3566   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3567
3568   tag_off += 2;
3569
3570   if (tag_off + 4 > tag_len)
3571     goto done;
3572
3573   /* multicast cipher suite */
3574   if (!tvb_memeql(tag_tvb, tag_off, RSN_OUI, 3)) {
3575     g_snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s",
3576        val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3577          wpa_cipher_vals, "UNKNOWN"));
3578     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4, out_buff);
3579     tag_off += 4;
3580   }
3581
3582   if (tag_off + 2 > tag_len)
3583     goto done;
3584
3585   /* unicast cipher suites */
3586   count = tvb_get_letohs(tag_tvb, tag_off);
3587   g_snprintf(out_buff, SHORT_STR, "# of unicast cipher suites: %u", count);
3588   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3589   tag_off += 2;
3590   i = 1;
3591   while (tag_off + 4 <= tag_len && i <= count) {
3592     if (tvb_memeql(tag_tvb, tag_off, RSN_OUI, 3) != 0)
3593       goto done;
3594     g_snprintf(out_buff, SHORT_STR, "Unicast cipher suite %u: %s",
3595        i, val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3596          wpa_cipher_vals, "UNKNOWN"));
3597     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4, out_buff);
3598     tag_off += 4;
3599     i++;
3600   }
3601
3602   if (i <= count || tag_off + 2 > tag_len)
3603     goto done;
3604
3605   /* authenticated key management suites */
3606   count = tvb_get_letohs(tag_tvb, tag_off);
3607   g_snprintf(out_buff, SHORT_STR, "# of auth key management suites: %u", count);
3608   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3609   tag_off += 2;
3610   i = 1;
3611   while (tag_off + 4 <= tag_len && i <= count) {
3612     if (tvb_memeql(tag_tvb, tag_off, RSN_OUI, 3) != 0)
3613       goto done;
3614     g_snprintf(out_buff, SHORT_STR, "auth key management suite %u: %s",
3615        i, val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3616          wpa_keymgmt_vals, "UNKNOWN"));
3617     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4, out_buff);
3618     tag_off += 4;
3619     i++;
3620   }
3621
3622   if (i <= count || tag_off + 2 > tag_len)
3623     goto done;
3624
3625   rsn_capab = tvb_get_letohs(tag_tvb, tag_off);
3626   g_snprintf(out_buff, SHORT_STR, "RSN Capabilities 0x%04x", rsn_capab);
3627   cap_item = proto_tree_add_uint_format(tree, rsn_cap, tag_tvb,
3628           tag_off, 2, rsn_capab,
3629           "RSN Capabilities: 0x%04X", rsn_capab);
3630   cap_tree = proto_item_add_subtree(cap_item, ett_rsn_cap_tree);
3631   proto_tree_add_boolean(cap_tree, rsn_cap_preauth, tag_tvb, tag_off, 2,
3632        rsn_capab);
3633   proto_tree_add_boolean(cap_tree, rsn_cap_no_pairwise, tag_tvb, tag_off, 2,
3634        rsn_capab);
3635   proto_tree_add_uint(cap_tree, rsn_cap_ptksa_replay_counter, tag_tvb, tag_off, 2,
3636           rsn_capab);
3637   proto_tree_add_uint(cap_tree, rsn_cap_gtksa_replay_counter, tag_tvb, tag_off, 2,
3638           rsn_capab);
3639   tag_off += 2;
3640
3641   if (tag_off + 2 > tag_len)
3642     goto done;
3643
3644   count = tvb_get_letohs(tag_tvb, tag_off);
3645   g_snprintf(out_buff, SHORT_STR, "# of PMKIDs: %u", count);
3646   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3647   tag_off += 2;
3648
3649   /* PMKID List (16 * n octets) */
3650   for (i = 0; i < count; i++) {
3651     if (tag_off + PMKID_LEN > tag_len)
3652       break;
3653     g_snprintf(out_buff, SHORT_STR, "PMKID %u: %s", i,
3654         tvb_bytes_to_str(tag_tvb, tag_off, PMKID_LEN));
3655     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off,
3656         PMKID_LEN, out_buff);
3657     tag_off += PMKID_LEN;
3658   }
3659
3660 done:
3661   if (tag_off < tag_len)
3662     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off,
3663         tag_len - tag_off, "Not interpreted");
3664 }
3665
3666 static void
3667 dissect_mcs_set(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean basic, gboolean vs) {
3668   proto_item *ti;
3669   proto_tree *mcs_tree, *bit_tree;
3670   guint16 capability;
3671
3672   /* 16 byte Supported MCS set */
3673   ti = proto_tree_add_string(tree, vs ? mcsset_vs : mcsset, tvb, offset, 16,
3674       basic ? "Basic MCS Set" : "MCS Set");
3675   mcs_tree = proto_item_add_subtree(ti, ett_mcsset_tree);
3676
3677   /* Rx MCS Bitmask */
3678   ti = proto_tree_add_string(mcs_tree, tag_interpretation, tvb, offset,
3679       10, "Rx Modulation and Coding Scheme (One bit per modulation)");
3680   bit_tree = proto_item_add_subtree(ti, ett_mcsbit_tree);
3681
3682   /* Bits 0 - 31 */
3683   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_0to7, tvb, offset, 4, TRUE);
3684   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_8to15, tvb, offset, 4, TRUE);
3685   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_16to23, tvb, offset, 4, TRUE);
3686   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_24to31, tvb, offset, 4, TRUE);
3687
3688   /* Bits 32 - 52 */
3689   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_32, tvb, offset + 4, 4, TRUE);
3690   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_33to38, tvb, offset + 4, 4, TRUE);
3691   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_39to52, tvb, offset + 4, 4, TRUE);
3692
3693   /* Bits 53 - 76 */
3694   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_53to76, tvb, offset + 6, 4, TRUE);
3695
3696   capability = tvb_get_letohs (tvb, offset+10);
3697   proto_tree_add_uint_format(mcs_tree, mcsset_highest_data_rate, tvb, offset + 10, 2,
3698       capability, "Highest Supported Data Rate: 0x%04X", capability);
3699   capability = tvb_get_letohs (tvb, offset+12);
3700   proto_tree_add_boolean(mcs_tree, mcsset_tx_mcs_set_defined, tvb, offset + 12, 1,
3701       capability);
3702   proto_tree_add_boolean(mcs_tree, mcsset_tx_rx_mcs_set_not_equal, tvb, offset + 12, 1,
3703       capability);
3704   proto_tree_add_uint(mcs_tree, mcsset_tx_max_spatial_streams, tvb, offset + 12, 1,
3705       capability);
3706   proto_tree_add_boolean(mcs_tree, mcsset_tx_unequal_modulation, tvb, offset + 12, 1,
3707       capability);
3708 }
3709
3710 /*  802.11n D1.10 - HT Information IE  */
3711 static void
3712 dissect_ht_info_ie_1_1(proto_tree * tree, tvbuff_t * tvb, int offset,
3713          guint32 tag_len)
3714 {
3715   proto_item *cap_item;
3716   proto_tree *cap_tree;
3717   guint32 tag_val_init_off = 0;
3718   guint16 info = 0;
3719
3720   tag_val_init_off = offset;
3721   cap_tree = tree;
3722
3723   if (tag_len < 22) {
3724     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
3725               "HT Information IE content length must be at least 22 bytes");
3726     return;
3727   }
3728
3729   info = tvb_get_guint8 (tvb, offset);
3730   proto_tree_add_item(cap_tree, ht_info_primary_channel, tvb, offset, 1, TRUE);
3731
3732   info = tvb_get_guint8 (tvb, ++offset);
3733   cap_item = proto_tree_add_uint_format(tree, ht_info_delimiter1, tvb,
3734                     offset, 1, info,
3735                     "HT Information Subset (1 of 3): 0x%02X", info);
3736   cap_tree = proto_item_add_subtree(cap_item, ett_ht_info_delimiter1_tree);
3737   proto_tree_add_uint(cap_tree, ht_info_secondary_channel_offset, tvb, offset, 1,
3738              info);
3739   proto_tree_add_boolean(cap_tree, ht_info_channel_width, tvb, offset, 1,
3740              info);
3741   proto_tree_add_boolean(cap_tree, ht_info_rifs_mode, tvb, offset, 1,
3742              info);
3743   proto_tree_add_boolean(cap_tree, ht_info_psmp_stas_only, tvb, offset, 1,
3744              info);
3745   proto_tree_add_uint(cap_tree, ht_info_service_interval_granularity, tvb, offset, 1,
3746              info);
3747
3748   info = tvb_get_letohs (tvb, ++offset);
3749   cap_item = proto_tree_add_uint_format(tree, ht_info_delimiter2, tvb,
3750                     offset, 2, info,
3751                     "HT Information Subset (2 of 3): 0x%04X", info);
3752   cap_tree = proto_item_add_subtree(cap_item, ett_ht_info_delimiter2_tree);
3753   proto_tree_add_uint(cap_tree, ht_info_operating_mode, tvb, offset, 1,
3754              info);
3755   proto_tree_add_boolean(cap_tree, ht_info_non_greenfield_sta_present, tvb, offset, 1,
3756              info);
3757   proto_tree_add_boolean(cap_tree, ht_info_transmit_burst_limit, tvb, offset, 1,
3758              info);
3759   proto_tree_add_boolean(cap_tree, ht_info_obss_non_ht_stas_present, tvb, offset, 1,
3760              info);
3761   proto_tree_add_uint(cap_tree, ht_info_reserved_1, tvb, offset, 2,
3762              info);
3763
3764   offset += 2;
3765   info = tvb_get_letohs (tvb, offset);
3766   cap_item = proto_tree_add_uint_format(tree, ht_info_delimiter3, tvb,
3767                     offset, 2, info,
3768                     "HT Information Subset (3 of 3): 0x%04X", info);
3769   cap_tree = proto_item_add_subtree(cap_item, ett_ht_info_delimiter3_tree);
3770   proto_tree_add_uint(cap_tree, ht_info_reserved_2, tvb, offset, 1,
3771              info);
3772   proto_tree_add_boolean(cap_tree, ht_info_dual_beacon, tvb, offset, 1,
3773              info);
3774   proto_tree_add_boolean(cap_tree, ht_info_dual_cts_protection, tvb, offset, 1,
3775              info);
3776   proto_tree_add_boolean(cap_tree, ht_info_secondary_beacon, tvb, offset+1, 1,
3777              info);
3778   proto_tree_add_boolean(cap_tree, ht_info_lsig_txop_protection_full_support, tvb, offset+1, 1,
3779              info);
3780   proto_tree_add_boolean(cap_tree, ht_info_pco_active, tvb, offset+1, 1,
3781              info);
3782   proto_tree_add_boolean(cap_tree, ht_info_pco_phase, tvb, offset+1, 1,
3783              info);
3784   proto_tree_add_uint(cap_tree, ht_info_reserved_3, tvb, offset+1, 1,
3785              info);
3786
3787   offset += 2;
3788   cap_tree = tree;
3789
3790   dissect_mcs_set(cap_tree, tvb, offset, TRUE, FALSE);
3791   offset += 16;
3792
3793   if (tag_val_init_off - offset < tag_len){
3794     proto_tree_add_string(cap_tree, tag_interpretation, tvb, offset,
3795        tag_len + tag_val_init_off - offset, "Unparsed Extra Data");
3796   }
3797 }
3798
3799 /***  WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
3800 static void
3801 dissect_wsie_ie(proto_tree * tree, tvbuff_t * tvb, int offset, guint32 tag_len _U_)
3802 {
3803         proto_item *pst_item, *cap_item, *chan_noc_item, *chnl_item;
3804         proto_tree *pst_tree, *cap_tree, *chan_noc_tree, *chnl_tree;
3805
3806         guint8 providercount, pst_contents, pst_acm_length;
3807         int i;
3808         guint16 pst_length = 0;
3809         guint16 chan_noc;
3810         guint8 chan_length = 0;
3811         int local_offset;
3812
3813         proto_tree_add_item(tree, hf_pst_timingquality, tvb, offset, 2, TRUE);
3814         offset+=2;
3815
3816         providercount = tvb_get_guint8 (tvb, offset);
3817         pst_item = proto_tree_add_item(tree, hf_pst_providercount, tvb, offset, 1, TRUE);
3818         pst_tree = proto_item_add_subtree(pst_item,ett_pst_tree);
3819         offset++;
3820
3821         for (i=0;i<providercount;i++) {
3822
3823                 local_offset = offset;
3824                 cap_item = proto_tree_add_text (pst_tree, tvb, local_offset, pst_length, "Capabilities of Provider :%u", i+1);
3825                 cap_tree = proto_item_add_subtree(cap_item, ett_pst_cap_tree);
3826
3827                 pst_length = tvb_get_letohl(tvb, local_offset);
3828                 proto_tree_add_item(cap_tree, hf_pst_length, tvb, local_offset, 2, TRUE);
3829                 local_offset+=2;
3830
3831                 pst_contents = tvb_get_guint8 (tvb, local_offset);
3832                 proto_tree_add_item(cap_tree, hf_pst_contents, tvb, local_offset, 1, TRUE);
3833                 local_offset++;
3834
3835                 if (pst_contents & WAVE_ACID) {
3836                         proto_tree_add_item(cap_tree, hf_pst_acid, tvb, local_offset, 1, TRUE);
3837                         local_offset++;
3838                 }
3839
3840                 if (pst_contents & WAVE_ACM) {
3841                         pst_acm_length = tvb_get_guint8 (tvb, local_offset);
3842                         proto_tree_add_item(cap_tree, hf_pst_acm_length, tvb, local_offset, 1, TRUE);
3843                         local_offset++;
3844                         proto_tree_add_item(cap_tree, hf_pst_acm, tvb, local_offset, pst_acm_length, FALSE);
3845                 }
3846                 if (pst_contents & WAVE_ACF) {
3847                         local_offset +=32;
3848                 }
3849                 if (pst_contents & WAVE_PRIORITY) {
3850                         proto_tree_add_item(cap_tree, hf_pst_priority, tvb, local_offset, 1, TRUE);
3851                         local_offset++;
3852                 }
3853                 if (pst_contents & WAVE_IPV6ADDR) {
3854                         proto_tree_add_item(cap_tree, hf_pst_ipv6addr, tvb, local_offset, 16, FALSE);
3855                         local_offset +=16;
3856                         proto_tree_add_item(cap_tree, hf_pst_serviceport, tvb, local_offset, 2, FALSE);
3857                         local_offset +=2;
3858                         proto_tree_add_item(cap_tree, hf_pst_addressing, tvb, local_offset, 1, FALSE);
3859                         local_offset++;
3860                 }
3861                 if (pst_contents & WAVE_PEERMAC) {
3862                         proto_tree_add_item(cap_tree, hf_pst_macaddr, tvb, local_offset, 6, FALSE);
3863                         local_offset +=6;
3864                 }
3865                 if (pst_contents & WAVE_CHANNEL) {
3866                         proto_tree_add_item(cap_tree, hf_pst_channel, tvb, local_offset, 1, FALSE);
3867                         local_offset++;
3868                 }
3869
3870                 offset = offset + pst_length;
3871         }
3872
3873         chan_noc = tvb_get_guint8 (tvb, offset);
3874         chan_noc_item = proto_tree_add_item(tree, hf_chan_noc, tvb, offset, 1, TRUE);
3875         chan_noc_tree = proto_item_add_subtree(chan_noc_item,ett_chan_noc_tree);
3876         offset++;
3877
3878         if (chan_noc != 0){
3879                 for (i=0;i<chan_noc;i++) {
3880                         chan_length = tvb_get_guint8 (tvb, offset);
3881                         chnl_item = proto_tree_add_text (chan_noc_tree, tvb, offset, chan_length, "Channel :%u Information ", i+1);
3882                         chnl_tree = proto_item_add_subtree(chnl_item, ett_wave_chnl_tree);
3883                         proto_tree_add_item(chnl_tree, hf_chan_length, tvb, offset, 1, TRUE);
3884                         proto_tree_add_item(chnl_tree, hf_chan_content, tvb, offset+1, 1, TRUE);
3885                         proto_tree_add_item(chnl_tree, hf_chan_channel, tvb, offset+2, 1, TRUE);
3886                         proto_tree_add_item(chnl_tree, hf_chan_adapt, tvb, offset+3, 1, TRUE);
3887                         proto_tree_add_item(chnl_tree, hf_chan_rate, tvb, offset+4, 1, TRUE);
3888                         proto_tree_add_item(chnl_tree, hf_chan_tx_pow, tvb, offset+5, 1, TRUE);
3889                         offset = offset + chan_length;
3890                 }
3891         }
3892 }
3893
3894 /*** Begin: Secondary Channel Offset Tag - Dustin Johnson ***/
3895 static void secondary_channel_offset_ie(proto_tree * tree, tvbuff_t * tvb, int offset, guint32 tag_len)
3896 {
3897   int tag_offset;
3898
3899   if (tag_len != 1)
3900   {
3901     proto_tree_add_text (tree, tvb, offset, tag_len, "Secondary Channel Offset: Error: Tag length must be at least 1 byte long");
3902     return;
3903   }
3904
3905   tag_offset = offset;
3906   proto_tree_add_uint(tree, hf_tag_secondary_channel_offset, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
3907
3908   offset++;
3909   if ((tag_len - (offset-tag_offset)) > 0)
3910   {
3911     proto_tree_add_text (tree, tvb, offset, tag_len - (offset-tag_offset), "Unknown Data");
3912     return;
3913   }
3914 }
3915 /*** End: Secondary Channel Offset Tag - Dustin Johnson ***/
3916
3917 static void
3918 dissect_ht_capability_ie(proto_tree * tree, tvbuff_t * tvb, int offset,
3919          guint32 tag_len, gboolean vs)
3920 {
3921   proto_item *cap_item;
3922   proto_tree *cap_tree;
3923   guint16 capability;
3924   guint32 txbfcap;
3925   guint32 tag_val_off = 0;
3926
3927   if (tag_val_off + 2 > tag_len) {
3928     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
3929         "Not interpreted");
3930     return;
3931   }
3932
3933   if (tag_len != 26) {
3934     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
3935               "HT Capabilities IE content length must be exactly 26 bytes");
3936     return;
3937   }
3938
3939   if (wlan_ignore_draft_ht && vs)
3940     return;
3941
3942   /* 2 byte HT Capabilities  Info*/
3943   capability = tvb_get_letohs (tvb, offset);
3944   cap_item = proto_tree_add_item(tree, vs ? ht_vs_cap : ht_cap, tvb,
3945                     offset, 2, TRUE);
3946   cap_tree = proto_item_add_subtree(cap_item, ett_ht_cap_tree);
3947   proto_tree_add_boolean(cap_tree, ht_ldpc_coding, tvb, offset, 1,
3948              capability);
3949   proto_tree_add_boolean(cap_tree, ht_chan_width, tvb, offset, 1,
3950              capability);
3951   proto_tree_add_uint(cap_tree, ht_sm_pwsave, tvb, offset, 1,
3952              capability);
3953   proto_tree_add_boolean(cap_tree, ht_green, tvb, offset, 1,
3954              capability);
3955   proto_tree_add_boolean(cap_tree, ht_short20, tvb, offset, 1,
3956              capability);
3957   proto_tree_add_boolean(cap_tree, ht_short40, tvb, offset, 1,
3958              capability);
3959   proto_tree_add_boolean(cap_tree, ht_tx_stbc, tvb, offset, 1,
3960              capability);
3961   proto_tree_add_uint(cap_tree, ht_rx_stbc, tvb, offset+1, 1,
3962              capability);
3963   proto_tree_add_boolean(cap_tree, ht_delayed_block_ack, tvb, offset+1, 1,
3964              capability);
3965   proto_tree_add_boolean(cap_tree, ht_max_amsdu, tvb, offset+1, 1,
3966              capability);
3967   proto_tree_add_boolean(cap_tree, ht_dss_cck_40, tvb, offset+1, 1,
3968              capability);
3969   proto_tree_add_boolean(cap_tree, ht_psmp, tvb, offset+1, 1,
3970              capability);
3971   proto_tree_add_boolean(cap_tree, ht_40_mhz_intolerant, tvb, offset+1, 1,
3972              capability);
3973   proto_tree_add_boolean(cap_tree, ht_l_sig, tvb, offset+1, 1,
3974              capability);
3975
3976   offset += 2;
3977   tag_val_off += 2;
3978
3979   /* 1 byte A-MPDU Parameters */
3980   capability = tvb_get_guint8 (tvb, offset);
3981   cap_item = proto_tree_add_item(tree, vs ? ampduparam_vs : ampduparam, tvb,
3982                     offset, 1, TRUE);
3983   cap_tree = proto_item_add_subtree(cap_item, ett_ampduparam_tree);
3984   proto_tree_add_uint_format(cap_tree, ampduparam_mpdu, tvb, offset, 1, capability, decode_numeric_bitfield(capability, 0x03, 8,"Maximum Rx A-MPDU Length: %%04.0Lf [Bytes]"), pow(2,13+(capability & 0x3))-1);
3985   proto_tree_add_uint(cap_tree, ampduparam_mpdu_start_spacing, tvb, offset, 1, capability);
3986   proto_tree_add_uint(cap_tree, ampduparam_reserved, tvb, offset, 1, capability);
3987   offset += 1;
3988   tag_val_off += 1;
3989
3990   /* 16 byte MCS set */
3991   dissect_mcs_set(tree, tvb, offset, FALSE, vs);
3992   offset += 16;
3993   tag_val_off += 16;
3994
3995   /* 2 byte HT Extended Capabilities */
3996   capability = tvb_get_letohs (tvb, offset);
3997   cap_item = proto_tree_add_item(tree, vs ? htex_vs_cap : htex_cap, tvb,
3998                     offset, 2, TRUE);
3999   cap_tree = proto_item_add_subtree(cap_item, ett_htex_cap_tree);
4000   proto_tree_add_boolean(cap_tree, htex_pco, tvb, offset, 1,
4001              capability);
4002   proto_tree_add_uint(cap_tree, htex_transtime, tvb, offset, 1,
4003              capability);
4004   proto_tree_add_uint(cap_tree, htex_mcs, tvb, offset+1, 1,
4005              capability);
4006   proto_tree_add_boolean(cap_tree, htex_htc_support, tvb, offset+1, 1,
4007              capability);
4008   proto_tree_add_boolean(cap_tree, htex_rd_responder, tvb, offset+1, 1,
4009              capability);
4010
4011   offset += 2;
4012   tag_val_off += 2;
4013
4014   /* 4 byte TxBF capabilities */
4015   txbfcap = tvb_get_letohl (tvb, offset);
4016   cap_item = proto_tree_add_item(tree, vs ? txbf_vs : txbf, tvb,
4017                     offset, 4, TRUE);
4018   cap_tree = proto_item_add_subtree(cap_item, ett_txbf_tree);
4019   proto_tree_add_boolean(cap_tree, txbf_cap, tvb, offset, 1,
4020              txbfcap);
4021   proto_tree_add_boolean(cap_tree, txbf_rcv_ssc, tvb, offset, 1,
4022              txbfcap);
4023   proto_tree_add_boolean(cap_tree, txbf_tx_ssc, tvb, offset, 1,
4024              txbfcap);
4025   proto_tree_add_boolean(cap_tree, txbf_rcv_ndp, tvb, offset, 1,
4026              txbfcap);
4027   proto_tree_add_boolean(cap_tree, txbf_tx_ndp, tvb, offset, 1,
4028              txbfcap);
4029   proto_tree_add_boolean(cap_tree, txbf_impl_txbf, tvb, offset, 1,
4030              txbfcap);
4031   proto_tree_add_uint(cap_tree, txbf_calib, tvb, offset, 1,
4032              txbfcap);
4033   proto_tree_add_boolean(cap_tree, txbf_expl_csi, tvb, offset+1, 1,
4034              txbfcap);
4035   proto_tree_add_boolean(cap_tree, txbf_expl_uncomp_fm, tvb, offset+1, 1,
4036              txbfcap);
4037   proto_tree_add_boolean(cap_tree, txbf_expl_comp_fm, tvb, offset+1, 1,
4038              txbfcap);
4039   proto_tree_add_uint(cap_tree, txbf_expl_bf_csi, tvb, offset+1, 1,
4040              txbfcap);
4041   proto_tree_add_uint(cap_tree, txbf_expl_uncomp_fm_feed, tvb, offset+1, 1,
4042              txbfcap);
4043   proto_tree_add_uint(cap_tree, txbf_expl_comp_fm_feed, tvb, offset+1, 2,
4044              txbfcap);
4045   proto_tree_add_uint(cap_tree, txbf_min_group, tvb, offset+2, 1,
4046              txbfcap);
4047   proto_tree_add_uint(cap_tree, txbf_csi_num_bf_ant, tvb, offset+2, 1,
4048              txbfcap);
4049   proto_tree_add_uint(cap_tree, txbf_uncomp_sm_bf_ant, tvb, offset+2, 1,
4050              txbfcap);
4051   proto_tree_add_uint(cap_tree, txbf_comp_sm_bf_ant, tvb, offset+2, 2,
4052              txbfcap);
4053   proto_tree_add_uint(cap_tree, txbf_csi_max_rows_bf, tvb, offset+3, 1,
4054              txbfcap);
4055   proto_tree_add_uint(cap_tree, txbf_chan_est, tvb, offset+3, 1,
4056              txbfcap);
4057   proto_tree_add_uint(cap_tree, txbf_resrv, tvb, offset+3, 1,
4058              txbfcap);
4059
4060   offset += 4;
4061   tag_val_off += 4;
4062
4063   /* 1 byte Antenna Selection (ASEL) capabilities */
4064   capability = tvb_get_guint8 (tvb, offset);
4065   cap_item = proto_tree_add_item(tree, vs ? antsel_vs : antsel, tvb,
4066                     offset, 1, TRUE);
4067   cap_tree = proto_item_add_subtree(cap_item, ett_antsel_tree);
4068   proto_tree_add_boolean(cap_tree, antsel_b0, tvb, offset, 1,
4069              capability);
4070   proto_tree_add_boolean(cap_tree, antsel_b1, tvb, offset, 1,
4071              capability);
4072   proto_tree_add_boolean(cap_tree, antsel_b2, tvb, offset, 1,
4073              capability);
4074   proto_tree_add_boolean(cap_tree, antsel_b3, tvb, offset, 1,
4075              capability);
4076   proto_tree_add_boolean(cap_tree, antsel_b4, tvb, offset, 1,
4077              capability);
4078   proto_tree_add_boolean(cap_tree, antsel_b5, tvb, offset, 1,
4079              capability);
4080   proto_tree_add_boolean(cap_tree, antsel_b6, tvb, offset, 1,
4081              capability);
4082   proto_tree_add_uint(cap_tree, antsel_b7, tvb, offset, 1,
4083              capability);
4084
4085   offset += 1;
4086   tag_val_off += 1;
4087
4088   if (tag_val_off < tag_len)
4089     proto_tree_add_string(tree, tag_interpretation, tvb, offset,
4090         tag_len - tag_val_off, "Not interpreted");
4091 }
4092
4093 static void
4094 dissect_ht_info_ie_1_0(proto_tree * tree, tvbuff_t * tvb, int offset,
4095          guint32 tag_len)
4096 {
4097   proto_item *cap_item;
4098   proto_tree *cap_tree;
4099   guint16 capability;
4100   guint32 tag_val_off = 0;
4101   gchar out_buff[SHORT_STR];
4102
4103   if (tag_val_off + 2 > tag_len) {
4104     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
4105         "Not interpreted");
4106     return;
4107   }
4108
4109   if (tag_len < 22) {
4110     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
4111               "HT Additional Capabilities IE content length must be 22");
4112     return;
4113   }
4114
4115   if (wlan_ignore_draft_ht)
4116     return;
4117
4118   g_snprintf(out_buff, SHORT_STR, "Control Channel %d",
4119              tvb_get_guint8(tvb, offset));
4120   proto_tree_add_string(tree, tag_interpretation, tvb, offset, 1, out_buff);
4121   offset += 1;
4122   tag_val_off += 1;
4123
4124   /* 1 byte HT additional capabilities */
4125   capability = tvb_get_guint8 (tvb, offset);
4126   cap_item = proto_tree_add_uint_format(tree, hta_cap, tvb,
4127                     offset, 1, capability,
4128                     "HT Additional Capabilities: 0x%04X", capability);
4129   cap_tree = proto_item_add_subtree(cap_item, ett_hta_cap_tree);
4130   proto_tree_add_uint(cap_tree, hta_ext_chan_offset, tvb, offset, 1,
4131              capability);
4132   proto_tree_add_boolean(cap_tree, hta_rec_tx_width, tvb, offset, 1,
4133              capability);
4134   proto_tree_add_boolean(cap_tree, hta_rifs_mode, tvb, offset, 1,
4135              capability);
4136   proto_tree_add_boolean(cap_tree, hta_controlled_access, tvb, offset, 1,
4137              capability);
4138   proto_tree_add_uint(cap_tree, hta_service_interval, tvb, offset, 1,
4139              capability);
4140   offset += 1;
4141   tag_val_off += 1;
4142
4143   /* 2 byte HT additional capabilities */
4144   capability = tvb_get_letohs (tvb, offset);
4145   cap_item = proto_tree_add_uint_format(tree, hta_cap, tvb,
4146                     offset, 2, capability,
4147                     "HT Additional Capabilities: 0x%04X", capability);
4148   cap_tree = proto_item_add_subtree(cap_item, ett_hta_cap1_tree);
4149   proto_tree_add_uint(cap_tree, hta_operating_mode, tvb, offset, 2,
4150              capability);
4151   proto_tree_add_boolean(cap_tree, hta_non_gf_devices, tvb, offset, 2,
4152              capability);
4153
4154   offset += 2;
4155   tag_val_off += 2;
4156
4157   /* 2 byte HT additional capabilities */
4158   capability = tvb_get_letohs (tvb, offset);
4159   cap_item = proto_tree_add_uint_format(tree, hta_cap, tvb,
4160                     offset, 2, capability,
4161                     "HT Additional Capabilities: 0x%04X", capability);
4162   cap_tree = proto_item_add_subtree(cap_item, ett_hta_cap2_tree);
4163   proto_tree_add_uint(cap_tree, hta_basic_stbc_mcs, tvb, offset, 2,
4164              capability);
4165   proto_tree_add_boolean(cap_tree, hta_dual_stbc_protection, tvb, offset, 2,
4166              capability);
4167   proto_tree_add_boolean(cap_tree, hta_secondary_beacon, tvb, offset, 2,
4168              capability);
4169   proto_tree_add_boolean(cap_tree, hta_lsig_txop_protection, tvb, offset, 2,
4170              capability);
4171   proto_tree_add_boolean(cap_tree, hta_pco_active, tvb, offset, 2,
4172              capability);
4173   proto_tree_add_boolean(cap_tree, hta_pco_phase, tvb, offset, 2,
4174              capability);
4175   offset += 2;
4176   tag_val_off += 2;
4177
4178   /* 16 byte Supported MCS set */
4179   dissect_mcs_set(tree, tvb, offset, FALSE, TRUE);
4180   offset += 16;
4181   tag_val_off += 16;
4182
4183    if (tag_val_off < tag_len)
4184      proto_tree_add_string(tree, tag_interpretation, tvb, offset,
4185                tag_len - tag_val_off, "Not interpreted");
4186 }
4187
4188 /* 802.11n-D1.10 and 802.11n-D2.0, 7.1.3.5a */
4189
4190 /*
4191  * 7.1.3.1.10 says:
4192  * "The Order field is 1 bit in length and is set to 1 in any non-QoS Data
4193  * frame that contains an MSDU, or fragment thereof, which is being
4194  * transferred using the StrictlyOrdered service class. The presence of the
4195  * HT Control field in frames is indicated by setting the Order field to 1
4196  * in any Data type or Management type frame that  is transmitted with a
4197  * value of HT_GF or HT_MM for the FORMAT parameter of the TXVECTOR except
4198  * a non-QoS Data frame or a Control Wrapper frame. The Order field is set
4199  * to 0 in all other frames. All non-HT QoS STAs set the Order field to 0."
4200  *
4201  * ...so does this mean that we can check for the presence of +HTC by
4202  * looking for QoS frames with the Order bit set, or do we need extra
4203  * information from the PHY (which would be monumentally silly)?
4204  *
4205  * At any rate, it doesn't look like any equipment we have produces
4206  * +HTC frames, so the code is completely untested.
4207  */
4208
4209 static void
4210 dissect_ht_control(proto_tree *tree, tvbuff_t * tvb, int offset)
4211 {
4212   proto_item *ti;
4213   proto_tree *htc_tree, *lac_subtree;
4214   guint16 htc;
4215
4216   htc = tvb_get_letohs(tvb, offset);
4217
4218   ti = proto_tree_add_item(tree, hf_htc, tvb, offset, 4, TRUE);
4219   htc_tree = proto_item_add_subtree(ti, ett_htc_tree);
4220
4221   /* Start: Link Adaptation Control */
4222   ti = proto_tree_add_item(htc_tree, hf_htc_lac, tvb, offset, 2, TRUE);
4223   lac_subtree = proto_item_add_subtree(ti, ett_htc_tree);
4224   proto_tree_add_item(lac_subtree, hf_htc_lac_reserved, tvb, offset, 1, htc);
4225   proto_tree_add_item(lac_subtree, hf_htc_lac_trq, tvb, offset, 1, TRUE);
4226
4227   if (HTC_IS_ASELI(htc)) {
4228     proto_tree_add_uint(lac_subtree, hf_htc_lac_mai_aseli, tvb, offset, 1, htc);
4229   } else {
4230     proto_tree_add_item(lac_subtree, hf_htc_lac_mai_mrq, tvb, offset, 1, TRUE);
4231     if (HTC_LAC_MAI_MRQ(htc)){
4232       proto_tree_add_uint(lac_subtree, hf_htc_lac_mai_msi, tvb, offset, 1, htc);
4233     } else {
4234       proto_tree_add_uint(lac_subtree, hf_htc_lac_mai_reserved, tvb, offset, 1, htc);
4235     }
4236   }
4237
4238   proto_tree_add_uint(lac_subtree, hf_htc_lac_mfsi, tvb, offset, 2, htc);
4239   offset++;
4240
4241   if (HTC_IS_ASELI(htc)) {
4242     proto_tree_add_uint(lac_subtree, hf_htc_lac_asel_command, tvb, offset, 1, htc);
4243     proto_tree_add_uint(lac_subtree, hf_htc_lac_asel_data, tvb, offset, 1, htc);
4244   } else {
4245     proto_tree_add_uint(lac_subtree, hf_htc_lac_mfb, tvb, offset, 1, htc);
4246   }
4247   /* End: Link Adaptation Control */
4248
4249   offset++;
4250   htc = tvb_get_letohs(tvb, offset);
4251
4252   proto_tree_add_uint(htc_tree, hf_htc_cal_pos, tvb, offset, 1, htc);
4253   proto_tree_add_uint(htc_tree, hf_htc_cal_seq, tvb, offset, 1, htc);
4254   proto_tree_add_uint(htc_tree, hf_htc_reserved1, tvb, offset, 1, htc);
4255   proto_tree_add_uint(htc_tree, hf_htc_csi_steering, tvb, offset, 1, htc);
4256
4257   offset++;
4258   proto_tree_add_boolean(htc_tree, hf_htc_ndp_announcement, tvb, offset, 1, htc);
4259   proto_tree_add_uint(htc_tree, hf_htc_reserved2, tvb, offset, 1, htc);
4260   proto_tree_add_boolean(htc_tree, hf_htc_ac_constraint, tvb, offset, 1, htc);
4261   proto_tree_add_boolean(htc_tree, hf_htc_rdg_more_ppdu, tvb, offset, 1, htc);
4262 }
4263
4264 static void
4265 dissect_frame_control(proto_tree * tree, tvbuff_t * tvb, gboolean wlan_broken_fc,
4266                       guint32 offset)
4267 {
4268   guint16 fcf, flags, frame_type_subtype;
4269   proto_tree *fc_tree, *flag_tree;
4270   proto_item *fc_item, *flag_item, *hidden_item;
4271
4272   fcf = FETCH_FCF(offset);
4273
4274   flags = FCF_FLAGS(fcf);
4275   frame_type_subtype = COMPOSE_FRAME_TYPE(fcf);
4276
4277   proto_tree_add_uint (tree, hf_fc_frame_type_subtype,
4278     tvb, wlan_broken_fc?offset+1:offset, 1,
4279     frame_type_subtype);
4280
4281   fc_item = proto_tree_add_uint_format (tree, hf_fc_field, tvb,
4282     offset, 2, fcf, "Frame Control: 0x%04X (%s)",
4283     fcf, wlan_broken_fc?"Swapped":"Normal");
4284
4285   fc_tree = proto_item_add_subtree (fc_item, ett_fc_tree);
4286
4287   proto_tree_add_uint (fc_tree, hf_fc_proto_version, tvb, wlan_broken_fc?offset+1:offset, 1,
4288     FCF_PROT_VERSION (fcf));
4289
4290   proto_tree_add_uint (fc_tree, hf_fc_frame_type, tvb, wlan_broken_fc?offset+1:offset, 1,
4291     FCF_FRAME_TYPE (fcf));
4292
4293   proto_tree_add_uint (fc_tree, hf_fc_frame_subtype, tvb, wlan_broken_fc?offset+1:offset, 1,
4294     FCF_FRAME_SUBTYPE (fcf));
4295
4296   flag_item = proto_tree_add_uint_format (fc_tree, hf_fc_flags, tvb,
4297     wlan_broken_fc?offset:offset+1, 1,
4298     flags, "Flags: 0x%X", flags);
4299
4300   flag_tree = proto_item_add_subtree (flag_item, ett_proto_flags);
4301   proto_tree_add_uint (flag_tree, hf_fc_data_ds, tvb, wlan_broken_fc?offset:offset+1, 1,
4302     FLAGS_DS_STATUS (flags));
4303   hidden_item = proto_tree_add_boolean (flag_tree, hf_fc_to_ds, tvb, offset+1, 1, flags);
4304   PROTO_ITEM_SET_HIDDEN(hidden_item);
4305   hidden_item = proto_tree_add_boolean (flag_tree, hf_fc_from_ds, tvb, offset+1, 1, flags);
4306   PROTO_ITEM_SET_HIDDEN(hidden_item);
4307   proto_tree_add_boolean (flag_tree, hf_fc_more_frag, tvb, wlan_broken_fc?offset:offset+1, 1,
4308     flags);
4309   proto_tree_add_boolean (flag_tree, hf_fc_retry, tvb, wlan_broken_fc?offset:offset+1, 1,
4310     flags);
4311   proto_tree_add_boolean (flag_tree, hf_fc_pwr_mgt, tvb, wlan_broken_fc?offset:offset+1, 1,
4312     flags);
4313   proto_tree_add_boolean (flag_tree, hf_fc_more_data, tvb, wlan_broken_fc?offset:offset+1, 1,
4314     flags);
4315   proto_tree_add_boolean (flag_tree, hf_fc_protected, tvb, wlan_broken_fc?offset:offset+1, 1,
4316     flags);
4317   proto_tree_add_boolean (flag_tree, hf_fc_order, tvb, wlan_broken_fc?offset:offset+1, 1,
4318     flags);
4319 }
4320
4321 static void
4322 dissect_vendor_ie_ht(proto_item * item, proto_tree * tree, tvbuff_t * tag_tvb)
4323 {
4324   gint tag_len = tvb_length(tag_tvb);
4325   gchar out_buff[SHORT_STR];
4326
4327   g_snprintf(out_buff, SHORT_STR, "802.11n (Pre) OUI");
4328   proto_tree_add_string(tree, tag_interpretation, tag_tvb, 0, 3, out_buff);
4329   /* 802.11n OUI  Information Element */
4330   if (4 <= tag_len && !tvb_memeql(tag_tvb, 0, PRE_11N_OUI"\x33", 4)) {
4331     g_snprintf(out_buff, SHORT_STR, "802.11n (Pre) HT information");
4332     proto_tree_add_string(tree, tag_interpretation, tag_tvb, 3, 1, out_buff);
4333
4334     dissect_ht_capability_ie(tree, tag_tvb, 4, tag_len - 4, TRUE);
4335     proto_item_append_text(item, ": HT Capabilities (802.11n D1.10)");
4336   }
4337   else {
4338     if (4 <= tag_len && !tvb_memeql(tag_tvb, 0, PRE_11N_OUI"\x34", 4)) {
4339       g_snprintf(out_buff, SHORT_STR, "HT additional information (802.11n D1.00)");
4340       proto_tree_add_string(tree, tag_interpretation, tag_tvb, 3, 1, out_buff);
4341
4342       dissect_ht_info_ie_1_0(tree, tag_tvb, 4, tag_len - 4);
4343       proto_item_append_text(item, ": HT Additional Capabilities (802.11n D1.00)");
4344     }
4345     else {
4346         g_snprintf(out_buff, SHORT_STR, "Unknown type");
4347         proto_tree_add_string(tree, tag_interpretation, tag_tvb, 3, 1, out_buff);
4348         proto_item_append_text(item, ": 802.11n (pre) Unknown type");
4349         proto_tree_add_string(tree, tag_interpretation, tag_tvb, 4,
4350                   tag_len - 4, "Not interpreted");
4351     }
4352   }
4353 }
4354
4355
4356 /* ************************************************************************* */
4357 /*           Dissect and add tagged (optional) fields to proto tree          */
4358 /* ************************************************************************* */
4359
4360 static const value_string tag_num_vals[] = {
4361   { TAG_SSID,                 "SSID parameter set" },
4362   { TAG_SUPP_RATES,           "Supported Rates" },
4363   { TAG_FH_PARAMETER,         "FH Parameter set" },
4364   { TAG_DS_PARAMETER,         "DS Parameter set" },
4365   { TAG_CF_PARAMETER,         "CF Parameter set" },
4366   { TAG_TIM,                  "Traffic Indication Map (TIM)" },
4367   { TAG_IBSS_PARAMETER,       "IBSS Parameter set" },
4368   { TAG_COUNTRY_INFO,         "Country Information" },
4369   { TAG_FH_HOPPING_PARAMETER, "Hopping Pattern Parameters" },
4370   { TAG_CHALLENGE_TEXT,       "Challenge text" },
4371   { TAG_ERP_INFO,             "ERP Information" },
4372   { TAG_ERP_INFO_OLD,         "ERP Information" },
4373   { TAG_RSN_IE,               "RSN Information" },
4374   { TAG_EXT_SUPP_RATES,       "Extended Supported Rates" },
4375   { TAG_CISCO_UNKNOWN_1,      "Cisco Unknown 1 + Device Name" },
4376   { TAG_CISCO_UNKNOWN_2,      "Cisco Unknown 2" },
4377   { TAG_CISCO_UNKNOWN_3,      "Cisco Unknown 3" },
4378   { TAG_VENDOR_SPECIFIC_IE,   "Vendor Specific" },
4379   { TAG_SYMBOL_PROPRIETARY,   "Symbol Proprietary"},
4380   { TAG_AGERE_PROPRIETARY,    "Agere Proprietary"},
4381   { TAG_REQUEST,              "Request"},
4382   { TAG_QBSS_LOAD,            "QBSS Load Element"},
4383   { TAG_EDCA_PARAM_SET,       "EDCA Parameter Set"},
4384   { TAG_TSPEC,                "Traffic Specification"},
4385   { TAG_TCLAS,                "Traffic Classification"},
4386   { TAG_SCHEDULE,             "Schedule"},
4387   { TAG_TS_DELAY,             "TS Delay"},
4388   { TAG_TCLAS_PROCESS,        "TCLAS Processing"},
4389   { TAG_HT_CAPABILITY,        "HT Capabilities (802.11n D1.10)"},
4390   { TAG_NEIGHBOR_REPORT,      "Neighbor Report"},
4391   { TAG_HT_INFO,              "HT Information (802.11n D1.10)"},
4392   { TAG_SECONDARY_CHANNEL_OFFSET, "Secondary Channel Offset (802.11n D1.10)"},
4393   { TAG_WSIE,                     "Wave Service Information"}, /* www.aradasystems.com */
4394   { TAG_20_40_BSS_CO_EX,          "20/40 BSS Coexistence"},
4395   { TAG_20_40_BSS_INTOL_CH_REP,   "20/40 BSS Intolerant Channel Report"},   /* IEEE P802.11n/D6.0 */
4396   { TAG_OVERLAP_BSS_SCAN_PAR,     "Overlapping BSS Scan Parameters"},       /* IEEE P802.11n/D6.0 */
4397   { TAG_QOS_CAPABILITY,           "QoS Capability"},
4398   { TAG_POWER_CONSTRAINT,         "Power Constraint"},
4399   { TAG_POWER_CAPABILITY,         "Power Capability"},
4400   { TAG_TPC_REQUEST,              "TPC Request"},
4401   { TAG_TPC_REPORT,               "TPC Report"},
4402   { TAG_SUPPORTED_CHANNELS,       "Supported Channels"},
4403   { TAG_CHANNEL_SWITCH_ANN,       "Channel Switch Announcement"},
4404   { TAG_MEASURE_REQ,              "Measurement Request"},
4405   { TAG_MEASURE_REP,              "Measurement Report"},
4406   { TAG_QUIET,                    "Quiet"},
4407   { TAG_IBSS_DFS,                 "IBSS DFS"},
4408   { TAG_EXTENDED_CAPABILITIES,    "Extended Capabilities"},
4409   #if 0 /*Not yet assigned tag numbers by ANA */
4410   { TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT, "Extended Channel Switch Announcement"},
4411   { TAG_SUPPORTED_REGULATORY_CLASSES, "Supported Regulatory Classes"},
4412   #endif
4413   { 0,                        NULL }
4414 };
4415
4416 static const value_string environment_vals[] = {
4417   { 0x20, "Any" },
4418   { 0x4f, "Outdoor" },
4419   { 0x49, "Indoor" },
4420   { 0,    NULL }
4421 };
4422
4423 static int beacon_padding = 0; /* beacon padding bug */
4424 static int
4425 add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int offset)
4426 {
4427   guint32 oui;
4428   tvbuff_t *tag_tvb;
4429   const guint8 *tag_data_ptr;
4430   guint32 tag_no, tag_len;
4431   unsigned int i;
4432   int n, ret;
4433   char out_buff[SHORT_STR];
4434   char print_buff[SHORT_STR];
4435   proto_tree * orig_tree=tree;
4436   proto_item *ti, *en;
4437   guint8 tag_len_len; /* The length of the length parameter in bytes*/
4438
4439   tag_no = tvb_get_guint8(tvb, offset);
4440   if(tag_no == TAG_WSIE){
4441           tag_len_len = 2;
4442           tag_len = tvb_get_letohl(tvb, offset + 1);
4443   }else{
4444           tag_len_len = 1;
4445           tag_len = tvb_get_guint8(tvb, offset + 1);
4446   }
4447
4448   ti=proto_tree_add_text(orig_tree,tvb,offset,tag_len+1+tag_len_len,"%s",
4449                          val_to_str(tag_no, tag_num_vals,
4450                          (tag_no >= 17 && tag_no <= 31) ?
4451                          "Reserved for challenge text" : "Reserved tag number" ));
4452   tree=proto_item_add_subtree(ti,ett_80211_mgt_ie);
4453
4454   proto_tree_add_uint_format (tree, tag_number, tvb, offset, 1, tag_no,
4455             "Tag Number: %u (%s)",
4456             tag_no,
4457             val_to_str(tag_no, tag_num_vals,
4458                        (tag_no >= 17 && tag_no <= 31) ?
4459                        "Reserved for challenge text" :
4460                        "Reserved tag number"));
4461   proto_tree_add_uint (tree, (tag_no==TAG_TIM ? tim_length : tag_length), tvb, offset + 1, tag_len_len, tag_len);
4462
4463   switch (tag_no)
4464   {
4465
4466     case TAG_SSID:
4467       if(beacon_padding == 0) /* padding bug */
4468       {
4469         guint8 *ssid; /* The SSID may consist of arbitrary bytes */
4470
4471         ssid = tvb_get_ephemeral_string(tvb, offset + 2, tag_len);
4472 #ifdef HAVE_AIRPDCAP
4473         AirPDcapSetLastSSID(&airpdcap_ctx, (CHAR *) ssid, tag_len);
4474 #endif
4475         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4476                                tag_len, (char *) ssid);
4477         if (check_col (pinfo->cinfo, COL_INFO)) {
4478           if (tag_len > 0) {
4479             col_append_fstr(pinfo->cinfo, COL_INFO, ", SSID=\"%s\"",
4480                             format_text(ssid, tag_len));
4481           } else {
4482             col_append_str(pinfo->cinfo, COL_INFO, ", SSID=Broadcast");
4483           }
4484         }
4485         if (tag_len > 0) {
4486           proto_item_append_text(ti, ": \"%s\"",
4487                                  format_text(ssid, tag_len));
4488           memcpy(wlan_stats.ssid, ssid, MAX_SSID_LEN);
4489           wlan_stats.ssid_len = tag_len;
4490         } else {
4491           proto_item_append_text(ti, ": Broadcast");
4492         }
4493         en = proto_tree_add_string_format (tree, hf_tagged_ssid, tvb, offset + 2,
4494                                            tag_len, format_text(ssid, tag_len), 
4495                                            "SSID: %s", format_text(ssid, tag_len));
4496         PROTO_ITEM_SET_HIDDEN (en);
4497         beacon_padding++; /* padding bug */
4498       }
4499       break;
4500
4501     case TAG_SUPP_RATES:
4502     case TAG_EXT_SUPP_RATES:
4503       if (tag_len < 1)
4504       {
4505         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4506             "Tag length %u too short, must be greater than 0", tag_len);
4507         break;
4508       }
4509
4510       tag_data_ptr = tvb_get_ptr (tvb, offset + 2, tag_len);
4511       for (i = 0, n = 0; i < tag_len && n < SHORT_STR; i++) {
4512         if (tag_data_ptr[i] == 0xFF){
4513           proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2 + i,
4514                1, "BSS requires support for mandatory features of HT PHY (IEEE 802.11 - Clause 20)");
4515         } else {
4516           ret = g_snprintf (print_buff + n, SHORT_STR - n, "%2.1f%s ",
4517                           (tag_data_ptr[i] & 0x7F) * 0.5,
4518                           (tag_data_ptr[i] & 0x80) ? "(B)" : "");
4519           if (ret == -1 || ret >= SHORT_STR - n) {
4520             /* Some versions of snprintf return -1 if they'd truncate
4521                the output. Others return <buf_size> or greater.  */
4522             break;
4523           }
4524           n += ret;
4525         }
4526       }
4527       g_snprintf (out_buff, SHORT_STR, "Supported rates: %s [Mbit/sec]", print_buff);
4528       out_buff[SHORT_STR-1] = '\0';
4529       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4530            tag_len, out_buff);
4531       proto_item_append_text(ti, ": %s", print_buff);
4532       break;
4533
4534     case TAG_FH_PARAMETER:
4535       if (tag_len < 5)
4536       {
4537         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 5",
4538                              tag_len);
4539         break;
4540       }
4541       g_snprintf (out_buff, SHORT_STR,
4542           "Dwell time 0x%04X, Hop Set %2d, Hop Pattern %2d, Hop Index %2d",
4543           tvb_get_letohs(tvb, offset + 2),
4544           tvb_get_guint8(tvb, offset + 4),
4545           tvb_get_guint8(tvb, offset + 5),
4546           tvb_get_guint8(tvb, offset + 6));
4547       out_buff[SHORT_STR-1] = '\0';
4548       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4549                              tag_len, out_buff);
4550       break;
4551
4552     case TAG_DS_PARAMETER:
4553       if (tag_len < 1)
4554       {
4555         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 1",
4556                              tag_len);
4557         break;
4558       }
4559       g_snprintf (out_buff, SHORT_STR, "Current Channel: %u",
4560                 tvb_get_guint8(tvb, offset + 2));
4561       out_buff[SHORT_STR-1] = '\0';
4562       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4563                              tag_len, out_buff);
4564       proto_item_append_text(ti, ": %s", out_buff);
4565       wlan_stats.channel = tvb_get_guint8(tvb, offset + 2);
4566       break;
4567
4568     case TAG_CF_PARAMETER:
4569       if (tag_len < 6)
4570       {
4571         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 6",
4572                              tag_len);
4573         break;
4574       }
4575       g_snprintf (out_buff, SHORT_STR, "CFP count: %u",
4576                 tvb_get_guint8(tvb, offset + 2));
4577       out_buff[SHORT_STR-1] = '\0';
4578       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2,
4579                                    1, out_buff, "%s", out_buff);
4580       g_snprintf (out_buff, SHORT_STR, "CFP period: %u",
4581                 tvb_get_guint8(tvb, offset + 3));
4582       out_buff[SHORT_STR-1] = '\0';
4583       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 3,
4584                                    1, out_buff, "%s", out_buff);
4585       g_snprintf (out_buff, SHORT_STR, "CFP max duration: %u",
4586                 tvb_get_letohs(tvb, offset + 4));
4587       out_buff[SHORT_STR-1] = '\0';
4588       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 4,
4589                                    2, out_buff, "%s", out_buff);
4590       g_snprintf (out_buff, SHORT_STR, "CFP Remaining: %u",
4591                 tvb_get_letohs(tvb, offset + 6));
4592       out_buff[SHORT_STR-1] = '\0';
4593       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 6,
4594                                    2, out_buff, "%s", out_buff);
4595       proto_item_append_text(ti, ": CFP count %u, CFP period %u, CFP max duration %u, "
4596                              "CFP Remaining %u",
4597                              tvb_get_guint8(tvb, offset + 2),
4598                              tvb_get_guint8(tvb, offset + 3),
4599                              tvb_get_letohs(tvb, offset + 4),
4600                              tvb_get_letohs(tvb, offset + 6));
4601       break;
4602
4603     case TAG_TIM:
4604       if (tag_len < 4)
4605       {
4606         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 4",
4607                              tag_len);
4608         break;
4609       }
4610       {
4611         guint8 bmapctl;
4612         guint8 bmapoff;
4613         guint8 bmaplen;
4614         const guint8* bmap;
4615
4616         proto_tree_add_item(tree, tim_dtim_count, tvb,
4617                             offset + 2, 1, TRUE);
4618         proto_tree_add_item(tree, tim_dtim_period, tvb,
4619                             offset + 3, 1, TRUE);
4620         proto_item_append_text(ti, ": DTIM %u of %u bitmap",
4621                                tvb_get_guint8(tvb, offset + 2),
4622                                tvb_get_guint8(tvb, offset + 3));
4623
4624         bmapctl = tvb_get_guint8(tvb, offset + 4);
4625         bmapoff = bmapctl>>1;
4626         proto_tree_add_uint_format(tree, tim_bmapctl, tvb,
4627                             offset + 4, 1, bmapctl,
4628                             "Bitmap Control: 0x%02X (mcast:%u, bitmap offset %u)",
4629                             bmapctl, bmapctl&1, bmapoff);
4630
4631         bmaplen = tag_len - 3;
4632         bmap = tvb_get_ptr(tvb, offset + 5, bmaplen);
4633         if (bmaplen==1 && 0==bmap[0] && !(bmapctl&1)) {
4634           proto_item_append_text(ti, " empty");
4635         } else {
4636           if (bmapctl&1) {
4637             proto_item_append_text(ti, " mcast");
4638           }
4639         }
4640         if (bmaplen>1 || bmap[0]) {
4641           int len=g_snprintf (out_buff, SHORT_STR,
4642                             "Bitmap: traffic for AID's:");
4643           int i=0;
4644           for (i=0;i<bmaplen*8;i++) {
4645             if (bmap[i/8] & (1<<(i%8))) {
4646               int aid=i+2*bmapoff*8;
4647               len+=g_snprintf (out_buff+len, SHORT_STR-len," %u", aid);
4648               proto_item_append_text(ti, " %u", aid);
4649               if (len>=SHORT_STR) {
4650                 break;
4651               }
4652             }
4653           }
4654           out_buff[SHORT_STR-1] = '\0';
4655           proto_tree_add_string_format (tree, tag_interpretation, tvb, offset + 5,
4656                bmaplen, out_buff, "%s", out_buff);
4657         }
4658       }
4659       break;
4660
4661     case TAG_IBSS_PARAMETER:
4662       if (tag_len < 2)
4663       {
4664         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 2",
4665                              tag_len);
4666         break;
4667       }
4668       g_snprintf (out_buff, SHORT_STR, "ATIM window 0x%X",
4669                 tvb_get_letohs(tvb, offset + 2));
4670       out_buff[SHORT_STR-1] = '\0';
4671       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4672            tag_len, out_buff);
4673       proto_item_append_text(ti, ": %s", out_buff);
4674       break;
4675
4676     case TAG_COUNTRY_INFO: /* IEEE 802.11d-2001 and IEEE 802.11j-2004 */
4677       {
4678         guint8 ccode[2+1];
4679
4680         if (tag_len < 3)
4681         {
4682           proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 3",
4683                                tag_len);
4684           break;
4685         }
4686         tvb_memcpy(tvb, ccode, offset + 2, 2);
4687         ccode[2] = '\0';
4688         g_snprintf (out_buff, SHORT_STR, "Country Code: %s, %s Environment",
4689                  format_text(ccode, 2),
4690                  val_to_str(tvb_get_guint8(tvb, offset + 4), environment_vals,"Unknown (0x%02x)"));
4691         out_buff[SHORT_STR-1] = '\0';
4692         proto_item_append_text(ti, ": %s", out_buff);
4693         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,3, out_buff);
4694
4695         for (i = 3; (i + 3) <= tag_len; i += 3)
4696         {
4697           guint8 val1, val2, val3;
4698           val1 = tvb_get_guint8(tvb, offset + 2 + i);
4699           val2 = tvb_get_guint8(tvb, offset + 3 + i);
4700           val3 = tvb_get_guint8(tvb, offset + 4 + i);
4701
4702           if (val1 <= 200) {  /* 802.11d */
4703             proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2+i,3, out_buff,
4704                                        "  Start Channel: %u, Channels: %u, Max TX Power: %d dBm",
4705                                        val1, val2, (gint) val3);
4706           } else {  /* 802.11j */
4707             proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2+i,3, out_buff,
4708                                        "  Reg Extension Id: %u, Regulatory Class: %u, Coverage Class: %u",
4709                                        val1, val2, val3);
4710           }
4711         }
4712       }
4713       break;
4714
4715     case TAG_QBSS_LOAD:
4716       if (tag_len < 4 || tag_len >5)
4717       {
4718         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Wrong QBSS Tag Length %u", tag_len);
4719         break;
4720       }
4721
4722       if (tag_len == 4)
4723       {
4724         /* QBSS Version 1 */
4725         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 1,
4726           tag_len, "Cisco QBSS Version 1 - non CCA");
4727
4728         /* Extract Values */
4729         proto_tree_add_uint (tree, hf_qbss_version, tvb, offset + 2, tag_len, 1);
4730         proto_tree_add_item (tree, hf_qbss_scount, tvb, offset + 2, 2, TRUE);
4731         proto_tree_add_item (tree, hf_qbss_cu, tvb, offset + 4, 1, FALSE);
4732         proto_tree_add_item (tree, hf_qbss_adc, tvb, offset + 5, 1, FALSE);
4733       }
4734       else if (tag_len == 5)
4735       {
4736          /* QBSS Version 2 */
4737          proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4738            tag_len, "802.11e CCA Version");
4739
4740          /* Extract Values */
4741          proto_tree_add_uint (tree, hf_qbss_version, tvb, offset + 2, tag_len, 2);
4742          proto_tree_add_item (tree, hf_qbss_scount, tvb, offset + 2, 2, TRUE);
4743          proto_tree_add_item (tree, hf_qbss_cu, tvb, offset + 4, 1, FALSE);
4744          proto_tree_add_item (tree, hf_qbss_adc, tvb, offset + 5, 2, TRUE);
4745       }
4746       break;
4747
4748     case TAG_FH_HOPPING_PARAMETER:
4749       if (tag_len < 2)
4750       {
4751         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 2",
4752                              tag_len);
4753         break;
4754       }
4755       g_snprintf (out_buff, SHORT_STR, "Prime Radix: %u, Number of Channels: %u",
4756                 tvb_get_guint8(tvb, offset + 2),
4757                 tvb_get_guint8(tvb, offset + 3));
4758       out_buff[SHORT_STR-1] = '\0';
4759       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, tag_len, out_buff);
4760       proto_item_append_text(ti, ": %s", out_buff);
4761       break;
4762
4763     case TAG_TSPEC:
4764       if (tag_len != 55)
4765       {
4766         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4767             "TSPEC tag length %u != 55", tag_len);
4768         break;
4769       }
4770       add_fixed_field(tree, tvb, offset + 2, FIELD_QOS_TS_INFO);
4771       proto_tree_add_item(tree, tspec_nor_msdu, tvb, offset + 5, 2, TRUE);
4772       proto_tree_add_item(tree, tspec_max_msdu, tvb, offset + 7, 2, TRUE);
4773       proto_tree_add_item(tree, tspec_min_srv, tvb, offset + 9, 4, TRUE);
4774       proto_tree_add_item(tree, tspec_max_srv, tvb, offset + 13, 4, TRUE);
4775       proto_tree_add_item(tree, tspec_inact_int, tvb, offset + 17, 4, TRUE);
4776       proto_tree_add_item(tree, tspec_susp_int, tvb, offset + 21, 4, TRUE);
4777       proto_tree_add_item(tree, tspec_srv_start, tvb, offset + 25, 4, TRUE);
4778       proto_tree_add_item(tree, tspec_min_data, tvb, offset + 29, 4, TRUE);
4779       proto_tree_add_item(tree, tspec_mean_data, tvb, offset + 33, 4, TRUE);
4780       proto_tree_add_item(tree, tspec_peak_data, tvb, offset + 37, 4, TRUE);
4781       proto_tree_add_item(tree, tspec_burst_size, tvb, offset + 41, 4, TRUE);
4782       proto_tree_add_item(tree, tspec_delay_bound, tvb, offset + 45, 4, TRUE);
4783       proto_tree_add_item(tree, tspec_min_phy, tvb, offset + 49, 4, TRUE);
4784       proto_tree_add_item(tree, tspec_surplus, tvb, offset + 53, 2, TRUE);
4785       proto_tree_add_item(tree, tspec_medium, tvb, offset + 55, 2, TRUE);
4786       break;
4787
4788     case TAG_TS_DELAY:
4789       if (tag_len != 4)
4790       {
4791         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4792             "TS_DELAY tag length %u != 4", tag_len);
4793         break;
4794       }
4795       proto_tree_add_item(tree, ts_delay, tvb, offset + 2, 4, TRUE);
4796       break;
4797
4798     case TAG_TCLAS:
4799       if (tag_len < 6)
4800       {
4801         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4802             "TCLAS element is too small %u", tag_len);
4803         break;
4804       }
4805       {
4806       guint8 type;
4807       guint8 version;
4808
4809       type = tvb_get_guint8(tvb, offset + 2);
4810       proto_tree_add_item(tree, hf_tsinfo_up, tvb, offset + 2, 1, TRUE);
4811       proto_tree_add_item(tree, hf_class_type, tvb, offset + 3, 1, TRUE);
4812       proto_tree_add_item(tree, hf_class_mask, tvb, offset + 4, 1, TRUE);
4813       switch (type)
4814         {
4815           case 0:
4816             proto_tree_add_item(tree, ff_src_mac_addr, tvb, offset + 5,
4817                     6, TRUE);
4818             proto_tree_add_item(tree, ff_dst_mac_addr, tvb, offset + 11,
4819                     6, TRUE);
4820             proto_tree_add_item(tree, hf_ether_type, tvb, offset + 17,
4821                     2, TRUE);
4822             break;
4823
4824           case 1:
4825             version = tvb_get_guint8(tvb, offset + 5);
4826             proto_tree_add_item(tree, cf_version, tvb, offset + 5, 1, TRUE);
4827             if (version == 4)
4828             {
4829               proto_tree_add_item(tree, cf_ipv4_src, tvb, offset + 6,
4830                 4, FALSE);
4831               proto_tree_add_item(tree, cf_ipv4_dst, tvb, offset + 10,
4832                 4, FALSE);
4833               proto_tree_add_item(tree, cf_src_port, tvb, offset + 14,
4834                 2, FALSE);
4835               proto_tree_add_item(tree, cf_dst_port, tvb, offset + 16,
4836                 2, FALSE);
4837               proto_tree_add_item(tree, cf_dscp, tvb, offset + 18,
4838                 1, FALSE);
4839               proto_tree_add_item(tree, cf_protocol, tvb, offset + 19,
4840                 1, FALSE);
4841             }
4842             else if (version == 6)
4843             {
4844               proto_tree_add_item(tree, cf_ipv6_src, tvb, offset + 6,
4845                 16, FALSE);
4846               proto_tree_add_item(tree, cf_ipv6_dst, tvb, offset + 22,
4847                 16, FALSE);
4848               proto_tree_add_item(tree, cf_src_port, tvb, offset + 38,
4849                 2, FALSE);
4850               proto_tree_add_item(tree, cf_dst_port, tvb, offset + 40,
4851                 2, FALSE);
4852               proto_tree_add_item(tree, cf_flow, tvb, offset + 42,
4853                 3, FALSE);
4854             }
4855             break;
4856
4857           case 2:
4858             proto_tree_add_item(tree, cf_tag_type, tvb, offset + 5,
4859                     2, TRUE);
4860             break;
4861
4862           default:
4863             break;
4864         }
4865       }
4866       break;
4867
4868     case TAG_TCLAS_PROCESS:
4869       if (tag_len != 1)
4870       {
4871         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4872             "TCLAS_PROCESS element length %u != 1", tag_len);
4873         break;
4874       }
4875       proto_tree_add_item(tree, hf_tclas_process, tvb, offset + 2, 1, TRUE);
4876       break;
4877
4878     case TAG_SCHEDULE:
4879       if (tag_len != 14)
4880       {
4881         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4882             "TCLAS_PROCESS element length %u != 14", tag_len);
4883         break;
4884       }
4885       add_fixed_field(tree, tvb, offset + 2, FIELD_SCHEDULE_INFO);
4886       proto_tree_add_item(tree, hf_sched_srv_start, tvb, offset + 4, 4, TRUE);
4887       proto_tree_add_item(tree, hf_sched_srv_int, tvb, offset + 8, 4, TRUE);
4888       proto_tree_add_item(tree, hf_sched_spec_int, tvb, offset + 12, 2, TRUE);
4889       break;
4890
4891     case TAG_CHALLENGE_TEXT:
4892       g_snprintf (out_buff, SHORT_STR, "Challenge text: %s",
4893                 tvb_bytes_to_str(tvb, offset + 2, tag_len));
4894       out_buff[SHORT_STR-1] = '\0';
4895       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4896            tag_len, out_buff);
4897       break;
4898
4899     case TAG_ERP_INFO:
4900     case TAG_ERP_INFO_OLD:
4901       {
4902         guint8 erp_info;
4903
4904         if (tag_len < 1)
4905         {
4906           proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 1",
4907                                tag_len);
4908           break;
4909         }
4910         erp_info = tvb_get_guint8 (tvb, offset + 2);
4911         g_snprintf (print_buff, SHORT_STR, "%sNon-ERP STAs, %suse protection, %s preambles",
4912                   erp_info & 0x01 ? "" : "no ",
4913                   erp_info & 0x02 ? "" : "do not ",
4914                   /* 802.11g, 7.3.2.13: 1 means "one or more ... STAs
4915                    * are not short preamble capable" */
4916                   erp_info & 0x04 ? "long": "short or long");
4917         print_buff[SHORT_STR-1] = '\0';
4918         g_snprintf (out_buff, SHORT_STR,
4919                   "ERP info: 0x%x (%s)",erp_info,print_buff);
4920         out_buff[SHORT_STR-1] = '\0';
4921         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4922                                tag_len, out_buff);
4923         proto_item_append_text(ti, ": %s", print_buff);
4924       }
4925       break;
4926
4927     case TAG_CISCO_UNKNOWN_1:
4928       /* From WCS manual:
4929        * If Aironet IE support is enabled, the access point sends an Aironet
4930        * IE 0x85 (which contains the access point name, load, number of
4931        * associated clients, and so on) in the beacon and probe responses of
4932        * this WLAN, and the controller sends Aironet IEs 0x85 and 0x95
4933        * (which contains the management IP address of the controller and
4934        * the IP address of the access point) in the reassociation response
4935        * if it receives Aironet IE 0x85 in the reassociation request.
4936        */
4937
4938       /* The Name of the sending device starts at offset 10 and is up to
4939          15 or 16 bytes in length, \0 padded */
4940       if (tag_len < 26)
4941       {
4942         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 26",
4943                              tag_len);
4944         break;
4945       }
4946       /* A cisco AP transmits the first 15 bytes of the AP name, probably
4947          followed by '\0' for ASCII termination */
4948       g_snprintf (out_buff, SHORT_STR, "%.16s",
4949                 tvb_format_stringzpad(tvb, offset + 12, 16));
4950       out_buff[SHORT_STR-1] = '\0';
4951       proto_tree_add_string_format (tree, tag_interpretation, tvb, offset + 2,
4952            tag_len, "", "Tag interpretation: Unknown + Name: %s #Clients: %u",
4953            out_buff,
4954            /* Total number off associated clients and repeater access points */
4955            tvb_get_guint8(tvb, offset + 28));
4956       if (check_col (pinfo->cinfo, COL_INFO)) {
4957           col_append_fstr(pinfo->cinfo, COL_INFO, ", Name=\"%s\"", out_buff);
4958       }
4959       break;
4960
4961 /* Std 802.11-2007
4962  * 7.3.2.26 Vendor Specific information element 
4963  * The
4964  * information element is in the format shown in Figure 7-75 and requires that the first 3 octets of the
4965  * information field contain the OUI of the entity that has defined the content of the particular Vendor Specific
4966  * information element. The length of the information field (n) is 3 >= n =< 255. The OUI field shall be a public
4967  * OUI assigned by the IEEE. It is 3 octets in length. The length of the vendor-specific content is n-3 octets.
4968  *
4969  *          Element ID Length OUI Vendor-specific content
4970  * Octets   1          1      3    n-3
4971  */
4972
4973     case TAG_VENDOR_SPECIFIC_IE:
4974       tvb_ensure_bytes_exist (tvb, offset + 2, tag_len);
4975       if (tag_len >= 3) {
4976         oui = tvb_get_ntoh24(tvb, offset + 2);
4977         tag_tvb = tvb_new_subset(tvb, offset + 2, tag_len, tag_len);
4978         tag_data_ptr = tvb_get_ptr(tag_tvb, 0, 3);
4979         proto_tree_add_bytes_format (tree, tag_oui, tvb, offset + 2, 3,
4980           tag_data_ptr, "Vendor: %s", get_manuf_name(tag_data_ptr));
4981         proto_item_append_text(ti, ": %s", get_manuf_name(tag_data_ptr));
4982
4983 #define WPAWME_OUI  0x0050F2
4984 #define RSNOUI_VAL  0x000FAC
4985 #define PRE11N_OUI  0x00904c
4986
4987       switch (oui) {
4988         case WPAWME_OUI:
4989           dissect_vendor_ie_wpawme(ti, tree, tag_tvb);
4990           break;
4991         case RSNOUI_VAL:
4992           dissect_vendor_ie_rsn(ti, tree, tag_tvb);
4993           break;
4994         case OUI_CISCOWL:  /* Cisco Wireless (Aironet) */
4995           dissect_vendor_ie_aironet(ti, tree, tvb, offset + 5, tag_len - 3);
4996           break;
4997         case PRE11N_OUI:
4998           dissect_vendor_ie_ht(ti, tree, tag_tvb);
4999           break;
5000         case OUI_MARVELL:
5001           dissect_vendor_ie_marvell(ti, tree, tvb, offset + 5, tag_len - 3);
5002           break;
5003         default:
5004           proto_tree_add_string (tree, tag_interpretation, tvb, offset + 5,
5005             tag_len - 3, "Not interpreted");
5006           break;
5007         }
5008
5009       }
5010       break;
5011
5012     case TAG_RSN_IE:
5013       tag_tvb = tvb_new_subset(tvb, offset + 2, tag_len, tag_len);
5014       dissect_rsn_ie(tree, tag_tvb);
5015       break;
5016
5017     case TAG_HT_CAPABILITY:
5018       dissect_ht_capability_ie(tree, tvb, offset + 2, tag_len, FALSE);
5019       break;
5020
5021     case TAG_HT_INFO:
5022       dissect_ht_info_ie_1_1(tree, tvb, offset + 2, tag_len);
5023       break;
5024     /*** Begin: Secondary Channel Offset Tag - Dustin Johnson ***/
5025     case TAG_SECONDARY_CHANNEL_OFFSET:
5026       secondary_channel_offset_ie(tree, tvb, offset + 2, tag_len);
5027       break;
5028     /*** End: Secondary Channel Offset Tag - Dustin Johnson ***/
5029
5030     /***  Begin: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
5031         case TAG_WSIE:
5032                 dissect_wsie_ie(tree, tvb, offset + 3, tag_len);
5033                 break;
5034     /***  End: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
5035
5036         /*** Begin: Power Capability Tag - Dustin Johnson ***/
5037     case TAG_POWER_CAPABILITY:
5038       {
5039         offset += 2;
5040         if (tag_len != 2)
5041         {
5042           proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5043             "Power Capability: Error: Tag length must be exactly 2 bytes long");
5044         }
5045
5046         proto_tree_add_item(tree, hf_tag_power_capability_min, tvb, offset, 1, TRUE);
5047         proto_tree_add_item(tree, hf_tag_power_capability_max, tvb, offset+1, 1, TRUE);
5048         break;
5049       }
5050     /*** End: Power Capability Tag - Dustin Johnson ***/
5051           /* 
5052            * 7.3.2.18 TPC Report element
5053            *
5054            */
5055         case TAG_TPC_REPORT:
5056                 if(tag_len !=2)
5057                 proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5058                     "TPC Report: Error: Tag length must be 2 bytes long");
5059                 /* Transmit Power field
5060                  * The field is coded as a signed integer in units of decibels relative to 1 mW
5061                  */
5062                 offset += 2;
5063                 proto_tree_add_item(tree, hf_tag_tpc_report_trsmt_pow, tvb, offset, 1, TRUE);
5064                 offset++;
5065                 /* Link Margin */
5066                 proto_tree_add_item(tree, hf_tag_tpc_report_link_mrg, tvb, offset, 1, TRUE);
5067                 offset++;
5068                 break;
5069     /*** Begin: Supported Channels Tag - Dustin Johnson ***/
5070     case TAG_SUPPORTED_CHANNELS:
5071       {
5072         proto_item *chan_item;
5073         proto_tree *chan_tree;
5074         guint8 i;
5075
5076         offset += 2;
5077         if (tag_len > 8) /* XXX Is this a sane limit? */
5078         {
5079           proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5080             "Supported Channels: Error: Tag length too long");
5081         } else if (tag_len % 2 == 1) {
5082           proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5083             "Supported Channels: Error: Tag length must be even");
5084         }
5085
5086         for (i=0; i<(tag_len/2); i++)
5087         {
5088           chan_item = proto_tree_add_uint_format(tree, hf_tag_supported_channels, tvb, offset, 2, i,
5089             "Supported Channels Set #%d", i);
5090           chan_tree = proto_item_add_subtree(chan_item , ett_tag_supported_channels);
5091           proto_tree_add_item(chan_tree, hf_tag_supported_channels_first, tvb, offset++, 1, TRUE);
5092           proto_tree_add_item(chan_tree, hf_tag_supported_channels_range, tvb, offset++, 1, TRUE);
5093         }
5094         break;
5095       }
5096     /*** End: Supported Channels Tag - Dustin Johnson ***/
5097
5098     /*** Begin: Measure Request Tag - Dustin Johnson ***/
5099     case TAG_MEASURE_REQ:
5100       if (tag_len < 3)
5101       {
5102         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5103             "Measurement Request: Error: Tag length must be at least 3 bytes long");
5104       } else {
5105         guint8 info, request_type;
5106         guint tag_offset;
5107         proto_item *parent_item;
5108         proto_tree *sub_tree;
5109
5110         offset += 2;
5111         tag_offset = offset;
5112         info = tvb_get_guint8 (tvb, offset);
5113         proto_tree_add_uint_format(tree, hf_tag_measure_request_measurement_token, tvb,
5114             offset, 1, info, "Measurement Token: 0x%02X", info);
5115
5116         info = tvb_get_guint8 (tvb, ++offset);
5117         parent_item = proto_tree_add_uint_format(tree, hf_tag_measure_request_mode, tvb,
5118             offset, 1, info, "Measurement Request Mode: 0x%02X", info);
5119         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5120         proto_tree_add_uint(sub_tree, hf_tag_measure_request_mode_reserved1, tvb, offset, 1, info);
5121         proto_tree_add_boolean(sub_tree, hf_tag_measure_request_mode_enable, tvb, offset, 1, info);
5122         proto_tree_add_boolean(sub_tree, hf_tag_measure_request_mode_request, tvb, offset, 1, info);
5123         proto_tree_add_boolean(sub_tree, hf_tag_measure_request_mode_report, tvb, offset, 1, info);
5124         proto_tree_add_uint(sub_tree, hf_tag_measure_request_mode_reserved2, tvb, offset, 1, info);
5125
5126         request_type = tvb_get_guint8 (tvb, ++offset);
5127         parent_item = proto_tree_add_uint(tree, hf_tag_measure_request_type, tvb, offset, 1, request_type);
5128         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5129
5130         offset++;
5131         switch (request_type) {
5132           case 0: /* Basic Request */
5133           case 1: /* Clear channel assessment (CCA) request */
5134           case 2: /* Receive power indication (RPI) histogram request */
5135           {
5136             guint8 channel_number;
5137             guint64 start_time;
5138             guint16 duration;
5139
5140             channel_number = tvb_get_guint8 (tvb, offset);
5141             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5142
5143             start_time = tvb_get_letoh64 (tvb, offset);
5144             proto_tree_add_uint64_format(sub_tree, hf_tag_measure_request_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
5145
5146             offset += 8;
5147             duration = tvb_get_letohs (tvb, offset);
5148             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_duration, tvb, offset, 2, duration, "Measurement Duration: 0x%04X TU (1 TU = 1024 us)", duration);
5149             break;
5150           }
5151           case 3: /* Channel Load Request */
5152           case 4: /* Noise Histogram Request */
5153           {
5154             guint8 regulatory_class, channel_number;
5155             guint16 rand_interval, duration;
5156
5157             regulatory_class = tvb_get_guint8 (tvb, offset);
5158             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_regulatory_class, tvb, offset, 1, regulatory_class, "Regulatory Class: 0x%02X", regulatory_class);
5159
5160             offset++;
5161             channel_number = tvb_get_guint8 (tvb, offset);
5162             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5163
5164             offset++;
5165             rand_interval = tvb_get_letohs (tvb, offset);
5166             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_randomization_interval, tvb, offset, 2, rand_interval, "Randomization Interval: 0x%02X TU (1 TU = 1024 us)", rand_interval);
5167
5168             offset += 2;
5169             duration = tvb_get_letohs (tvb, offset);
5170             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_duration, tvb, offset, 2, duration, "Measurement Duration: 0x%04X TU (1 TU = 1024 us)", duration);
5171             break;
5172           }
5173           case 5: /* Beacon Request */
5174           {
5175             guint8 regulatory_class, channel_number, measurement_mode, reporting_condition, threshold_offset;
5176             guint16 rand_interval, duration;
5177             const guint8 *bssid = NULL;
5178
5179             regulatory_class = tvb_get_guint8 (tvb, offset);
5180             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_regulatory_class, tvb, offset, 1, regulatory_class, "Regulatory Class: 0x%02X", regulatory_class);
5181
5182             offset++;
5183             channel_number = tvb_get_guint8 (tvb, offset);
5184             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5185
5186             offset++;
5187             rand_interval = tvb_get_letohs (tvb, offset);
5188             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_randomization_interval, tvb, offset, 2, rand_interval, "Randomization Interval: 0x%02X TU (1 TU = 1024 us)", rand_interval);
5189
5190             offset += 2;
5191             duration = tvb_get_letohs (tvb, offset);
5192             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_duration, tvb, offset, 2, duration, "Measurement Duration: 0x%04X TU (1 TU = 1024 us)", duration);
5193
5194             offset+=2;
5195             measurement_mode = tvb_get_guint8 (tvb, offset);
5196             proto_tree_add_uint(sub_tree, hf_tag_measure_request_measurement_mode, tvb, offset, 1, measurement_mode);
5197
5198             offset++;
5199             bssid = tvb_get_ptr (tvb, offset, 6);
5200             proto_tree_add_ether(sub_tree, hf_tag_measure_request_bssid, tvb, offset, 6, bssid);
5201
5202             offset+=6;
5203             reporting_condition = tvb_get_guint8 (tvb, offset);
5204             proto_tree_add_uint(sub_tree, hf_tag_measure_request_reporting_condition, tvb, offset, 1, reporting_condition);
5205
5206             offset++;
5207             threshold_offset = tvb_get_guint8 (tvb, offset);
5208             if (reporting_condition == 0) {
5209               /* XXX ? */
5210             } else if (reporting_condition >= 1 && reporting_condition <= 4){ /* Unsigned dBm */
5211               proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_threshold_offset_unsigned, tvb, offset, 1, threshold_offset, "Threshold/Offset: 0x%02X dBm", threshold_offset);
5212             } else if (reporting_condition == 5 || reporting_condition == 6 || reporting_condition == 9){ /* Signed dBm */
5213               proto_tree_add_int_format(sub_tree, hf_tag_measure_request_threshold_offset_signed, tvb, offset, 1, threshold_offset, "Threshold/Offset: 0x%02X dBm", threshold_offset);
5214             } else if (reporting_condition == 7 || reporting_condition == 8 || reporting_condition == 10){ /* Signed dB */
5215               proto_tree_add_int_format(sub_tree, hf_tag_measure_request_threshold_offset_signed, tvb, offset, 1, threshold_offset, "Threshold/Offset: 0x%02X dB", threshold_offset);
5216             } else {
5217               /* Not Defined */
5218             }
5219             offset++;
5220
5221             add_tagged_field (pinfo, sub_tree, tvb, offset);
5222
5223             break;
5224           }
5225           case 6: /* Frame Request */
5226           {
5227             guint8 regulatory_class, channel_number;
5228             guint16 rand_interval, duration;
5229             const guint8 *mac = NULL;
5230
5231             regulatory_class = tvb_get_guint8 (tvb, offset);
5232             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_regulatory_class, tvb, offset, 1, regulatory_class, "Regulatory Class: 0x%02X", regulatory_class);
5233
5234             offset++;
5235             channel_number = tvb_get_guint8 (tvb, offset);
5236             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5237
5238             offset++;
5239             rand_interval = tvb_get_letohs (tvb, offset);
5240             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_randomization_interval, tvb, offset, 2, rand_interval, "Randomization Interval: 0x%02X TU (1 TU = 1024 us)", rand_interval);
5241
5242             offset += 2;
5243             duration = tvb_get_letohs (tvb, offset);
5244             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_duration, tvb, offset, 2, duration, "Measurement Duration: 0x%04X TU (1 TU = 1024 us)", duration);
5245
5246             offset += 2;
5247             if (tag_len >= ((offset-tag_offset)+6)){
5248               mac = tvb_get_ptr (tvb, offset, 6);
5249               proto_tree_add_ether(sub_tree, hf_tag_measure_request_bssid, tvb, offset, 6, mac);
5250             }
5251             break;
5252           }
5253           case 7: /* BSTA Statistics Request */
5254           {
5255             guint8 group_id;
5256             guint16 rand_interval, duration;
5257
5258             offset++;
5259             rand_interval = tvb_get_letohs (tvb, offset);
5260             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_randomization_interval, tvb, offset, 2, rand_interval, "Randomization Interval: 0x%02X TU (1 TU = 1024 us)", rand_interval);
5261
5262             offset += 2;
5263             duration = tvb_get_letohs (tvb, offset);
5264             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_duration, tvb, offset, 2, duration, "Measurement Duration: 0x%04X TU (1 TU = 1024 us)", duration);
5265
5266             offset++;
5267             group_id = tvb_get_guint8 (tvb, offset);
5268             proto_tree_add_uint(sub_tree, hf_tag_measure_request_group_id, tvb, offset, 1, group_id);
5269             break;
5270           }
5271           case 8: /* Location Configuration Indication (LCI) Request */
5272             /* TODO */
5273           case 9: /* Transmit Stream Measurement Request */
5274             /* TODO */
5275           case 255: /* Measurement Pause Request*/
5276             /* TODO */
5277           default: /* unknown */
5278             proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Undissected Data");
5279             break;
5280         }
5281       }
5282
5283       break;
5284     /* End: Measure Request Tag - Dustin Johnson */
5285     /* Begin: Measure Report Tag - Dustin Johnson */
5286         /* 7.3.2.22 Measurement Report element
5287          * The Length field is variable and depends on the length of the 
5288          * Measurement Report field. The minimum value of the Length field is 3.
5289          */
5290     case TAG_MEASURE_REP:
5291       if (tag_len < 3)
5292       {
5293         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5294             "Measurement Report: Error: Tag length must be at least 3 bytes long");
5295       } else {
5296         guint8 info, report_type, channel_number;
5297         guint16 duration;
5298         guint64 start_time;
5299         proto_item *parent_item;
5300         proto_tree *sub_tree;
5301         guint tag_offset;
5302
5303         offset += 2;
5304         tag_offset = offset;
5305         info = tvb_get_guint8 (tvb, offset);
5306         proto_tree_add_uint_format(tree, hf_tag_measure_report_measurement_token, tvb,
5307             offset, 1, info, "Measurement Token: 0x%02X", info);
5308
5309         offset++;
5310         info = tvb_get_guint8 (tvb, offset);
5311         parent_item = proto_tree_add_uint_format(tree, hf_tag_measure_report_mode, tvb,
5312             offset, 1, info, "Measurement Report Mode: 0x%02X", info);
5313         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5314         proto_tree_add_boolean(sub_tree, hf_tag_measure_report_mode_late, tvb, offset, 1, info);
5315         proto_tree_add_boolean(sub_tree, hf_tag_measure_report_mode_incapable, tvb, offset, 1, info);
5316         proto_tree_add_boolean(sub_tree, hf_tag_measure_report_mode_refused, tvb, offset, 1, info);
5317         proto_tree_add_uint(sub_tree, hf_tag_measure_report_mode_reserved, tvb, offset, 1, info);
5318
5319         offset++;
5320         report_type = tvb_get_guint8 (tvb, offset);
5321         parent_item = proto_tree_add_uint(tree, hf_tag_measure_report_type, tvb, offset, 1, report_type);
5322         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5323         offset++;
5324
5325         if (tag_len == 3)
5326             break;
5327         switch (report_type) {
5328           case 0: /* Basic Report */
5329           {
5330             proto_tree *sub_tree_map_field;
5331
5332             channel_number = tvb_get_guint8 (tvb, offset);
5333             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5334
5335             offset++;
5336             start_time = tvb_get_letoh64 (tvb, offset);
5337             proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "x", start_time);
5338
5339             offset += 8;
5340             duration = tvb_get_letohs (tvb, offset);
5341             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_duration, tvb, offset, 2, duration, "Measurement Duration in TUs (1TU = 1024 us): 0x%04X", duration);
5342
5343             offset+=2;
5344             info = tvb_get_guint8 (tvb, offset);
5345             parent_item = proto_tree_add_uint_format(tree, hf_tag_measure_basic_map_field, tvb,
5346                               offset, 1, info, "Map Field: 0x%02X", info);
5347             sub_tree_map_field = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5348             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_bss, tvb, offset, 1, info);
5349             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_odfm, tvb, offset, 1, info);
5350             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_unident_signal, tvb, offset, 1, info);
5351             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_radar, tvb, offset, 1, info);
5352             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_unmeasured, tvb, offset, 1, info);
5353             proto_tree_add_uint(sub_tree_map_field, hf_tag_measure_map_field_reserved, tvb, offset, 1, info);
5354             break;
5355           }
5356           case 1: /* Clear channel assessment (CCA) report */
5357             channel_number = tvb_get_guint8 (tvb, offset);
5358             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5359
5360             offset++;
5361             start_time = tvb_get_letoh64 (tvb, offset);
5362             proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
5363
5364             offset += 8;
5365             duration = tvb_get_letohs (tvb, offset);
5366             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_duration, tvb, offset, 2, duration, "Measurement Duration in TUs (1TU = 1024 us): 0x%04X", duration);
5367
5368             offset+=2;
5369             info = tvb_get_guint8 (tvb, offset);
5370             proto_tree_add_uint_format(sub_tree, hf_tag_measure_cca_busy_fraction, tvb, offset, 1, info, "CCA Busy Fraction: 0x%02X", info);
5371             break;
5372           case 2: /* Receive power indication (RPI) histogram report */
5373             channel_number = tvb_get_guint8 (tvb, offset);
5374             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5375
5376             offset++;
5377             start_time = tvb_get_letoh64 (tvb, offset);
5378             proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
5379
5380             offset += 8;
5381             duration = tvb_get_letohs (tvb, offset);
5382             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_duration, tvb, offset, 2, duration, "Measurement Duration in TUs (1TU = 1024 us): 0x%04X", duration);
5383
5384             offset+=2;
5385             parent_item = proto_tree_add_string(sub_tree, hf_tag_measure_rpi_histogram_report, tvb,
5386                               offset, 8, "RPI Histogram Report");
5387             sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5388             info = tvb_get_guint8 (tvb, offset);
5389             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_0, tvb, offset, 1, info, "RPI 0 Density: 0x%02X", info);
5390             info = tvb_get_guint8 (tvb, ++offset);
5391             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_1, tvb, offset, 1, info, "RPI 1 Density: 0x%02X", info);
5392             info = tvb_get_guint8 (tvb, ++offset);
5393             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_2, tvb, offset, 1, info, "RPI 2 Density: 0x%02X", info);
5394             info = tvb_get_guint8 (tvb, ++offset);
5395             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_3, tvb, offset, 1, info, "RPI 3 Density: 0x%02X", info);
5396             info = tvb_get_guint8 (tvb, ++offset);
5397             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_4, tvb, offset, 1, info, "RPI 4 Density: 0x%02X", info);
5398             info = tvb_get_guint8 (tvb, ++offset);
5399             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_5, tvb, offset, 1, info, "RPI 5 Density: 0x%02X", info);
5400             info = tvb_get_guint8 (tvb, ++offset);
5401             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_6, tvb, offset, 1, info, "RPI 6 Density: 0x%02X", info);
5402             info = tvb_get_guint8 (tvb, ++offset);
5403             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_7, tvb, offset, 1, info, "RPI 7 Density: 0x%02X", info);
5404             break;
5405           case 3: /* Channel Load Report */
5406           {
5407             guint8 regulatory_class, channel_load;
5408
5409             regulatory_class = tvb_get_guint8 (tvb, offset);
5410             proto_tree_add_uint(sub_tree, hf_tag_measure_report_regulatory_class, tvb, offset, 1, regulatory_class);
5411
5412             offset++;
5413             channel_number = tvb_get_guint8 (tvb, offset);
5414             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5415
5416             offset++;
5417             start_time = tvb_get_letoh64 (tvb, offset);
5418             proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
5419
5420             offset += 8;
5421             duration = tvb_get_letohs (tvb, offset);
5422             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_duration, tvb, offset, 2, duration, "Measurement Duration in TUs (1TU = 1024 us): 0x%04X", duration);
5423
5424             offset+=2;
5425             channel_load = tvb_get_guint8 (tvb, offset);
5426             proto_tree_add_uint(sub_tree, hf_tag_measure_report_channel_load, tvb, offset, 1, channel_load);
5427             break;
5428           }
5429           case 4: /* Noise Histogram Report */
5430             /* TODO */
5431             proto_tree_add_text (sub_tree, tvb, offset, tag_len - (offset - tag_offset), "Undissected Data");
5432             break;
5433           case 5: /* Beacon Report */
5434           {
5435             guint8 regulatory_class, reported_frame_info, rcpi, rsni, ant_id;
5436             guint32 parent_tsf;
5437             proto_tree *sub_tree_frame_info;
5438             const guint8 *bssid = NULL;
5439
5440             regulatory_class = tvb_get_guint8 (tvb, offset);
5441             proto_tree_add_uint(sub_tree, hf_tag_measure_report_regulatory_class, tvb, offset, 1, regulatory_class);
5442
5443             offset++;
5444             channel_number = tvb_get_guint8 (tvb, offset);
5445             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_channel_number, tvb, offset, 1, channel_number, "Measurement Channel Number: 0x%02X", channel_number);
5446
5447             offset++;
5448             start_time = tvb_get_letoh64 (tvb, offset);
5449             proto_tree_add_uint64_format(sub_tree, hf_tag_measure_report_start_time, tvb, offset, 8, start_time, "Measurement Start Time: 0x%016" G_GINT64_MODIFIER "X", start_time);
5450
5451             offset += 8;
5452             duration = tvb_get_letohs (tvb, offset);
5453             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_duration, tvb, offset, 2, duration, "Measurement Duration in TUs (1TU = 1024 us): 0x%04X", duration);
5454
5455             offset+=2;
5456             reported_frame_info = tvb_get_guint8 (tvb, offset);
5457             parent_item = proto_tree_add_uint(sub_tree, hf_tag_measure_report_frame_info, tvb, offset, 1, reported_frame_info);
5458             sub_tree_frame_info = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5459             proto_tree_add_uint(sub_tree_frame_info, hf_tag_measure_report_frame_info_phy_type, tvb, offset, 1, reported_frame_info);
5460             proto_tree_add_uint(sub_tree_frame_info, hf_tag_measure_report_frame_info_frame_type, tvb, offset, 1, reported_frame_info);
5461
5462             offset++;
5463             rcpi = tvb_get_guint8 (tvb, offset);
5464             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_rcpi, tvb, offset, 1, rcpi, "Received Channel Power Indicator (RCPI): 0x%02X dBm", rcpi);
5465
5466             offset++;
5467             rsni = tvb_get_guint8 (tvb, offset);
5468             proto_tree_add_uint_format(sub_tree, hf_tag_measure_report_rsni, tvb, offset, 1, rsni, "Received Signal to Noise Indicator (RSNI): 0x%02X dB", rsni);
5469
5470             offset++;
5471             bssid = tvb_get_ptr (tvb, offset, 6);
5472             proto_tree_add_ether(sub_tree, hf_tag_measure_request_bssid, tvb, offset, 6, bssid);
5473
5474             offset+=6;
5475             ant_id = tvb_get_guint8 (tvb, offset);
5476             proto_tree_add_uint(sub_tree, hf_tag_measure_report_ant_id, tvb, offset, 1, ant_id);
5477
5478             offset++;
5479             parent_tsf = tvb_get_letohl (tvb, offset);
5480             proto_tree_add_uint(sub_tree, hf_tag_measure_report_parent_tsf, tvb, offset, 4, parent_tsf);
5481
5482             offset+=4;
5483             /* TODO - Must determine frame type and dissect this */
5484             if (tag_len > (offset - tag_offset))
5485             {
5486               proto_tree_add_text (sub_tree, tvb, offset, tag_len - (offset - tag_offset), "Reported Frame Body");
5487             }
5488             break;
5489           }
5490           case 6: /* Frame Report */
5491             /* TODO */
5492           case 7: /* BSTA Statistics Report */
5493             /* TODO */
5494           case 8: /* Location Configuration Information Report element */
5495             /* TODO */
5496           case 9: /* Transmit Stream Measurement Report */
5497             /* TODO */
5498           default: /* unknown */
5499             proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Undissected Data");
5500             break;
5501         }
5502       }
5503
5504       break;
5505     /*** End: Measure Report Tag - Dustin Johnson ***/
5506     /*** Begin: Extended Capabilities Tag - Dustin Johnson ***/
5507     /* The Capabilities field is a bit field indicating the capabilities being advertised 
5508          * by the STA transmitting the information element
5509          */
5510     case TAG_EXTENDED_CAPABILITIES:
5511     {
5512       guint tag_offset;
5513       guint8 info_exchange;
5514           proto_item *ti;
5515           proto_tree *ex_cap_tree;
5516
5517       if (tag_len < 1)
5518       {
5519         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5520             "Extended Capabilities: Error: Tag length must be at least 1 byte long");
5521         break;
5522       }
5523       offset+=2;
5524       tag_offset = offset;
5525
5526       info_exchange = tvb_get_guint8 (tvb, offset);
5527           ti = proto_tree_add_item (tree, hf_tag_extended_capabilities, tvb, offset, 1, FALSE);
5528           ex_cap_tree = proto_item_add_subtree (ti, ett_tag_ex_cap);
5529           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b0, tvb, offset, 1, FALSE);
5530           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b1, tvb, offset, 1, FALSE);
5531           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b2, tvb, offset, 1, FALSE);
5532           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b3, tvb, offset, 1, FALSE);
5533
5534       if (tag_len > (offset - tag_offset))
5535       {
5536         proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Unknown Data");
5537         break;
5538       }
5539       break;
5540     }
5541     /*** End: Extended Capabilities Tag - Dustin Johnson ***/
5542     /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
5543     case TAG_NEIGHBOR_REPORT:
5544     {
5545       #define SUB_TAG_TSF_INFO                 0x01
5546       #define SUB_TAG_MEASUREMENT_PILOT_INFO   0x02
5547       #define SUB_TAG_HT_CAPABILITIES          0x03
5548       #define SUB_TAG_HT_INFO                  0x04
5549       #define SUB_TAG_SEC_CHANNEL_OFFSET       0x05
5550       #define SUB_TAG_VENDOR_SPECIFIC          0xDD
5551
5552
5553       guint tag_offset;
5554       guint8 sub_tag_id;
5555       guint32 bssid_info, info, sub_tag_length;
5556       const guint8 *bssid = NULL;
5557       proto_item *parent_item;
5558       proto_tree *bssid_info_subtree, *sub_tag_tree;
5559       tvbuff_t *volatile sub_tag_tvb = NULL;
5560
5561       if (tag_len < 13)
5562       {
5563         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5564             "Neighbor Report: Error: Tag length must be at least 13 bytes long");
5565         break;
5566       }
5567       offset+=2;
5568       tag_offset = offset;
5569
5570       bssid = tvb_get_ptr (tvb, offset, 6);
5571       proto_tree_add_ether(tree, hf_tag_neighbor_report_bssid, tvb, offset, 6, bssid);
5572
5573       /*** Begin: BSSID Information ***/
5574       offset+=6;
5575       bssid_info = tvb_get_letohl (tvb, offset);
5576       parent_item = proto_tree_add_uint_format(tree, hf_tag_neighbor_report_bssid_info, tvb, offset, 4, bssid_info, "BSSID Information: 0x%08X", bssid_info);
5577       bssid_info_subtree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_bssid_info_tree);
5578
5579       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_reachability, tvb, offset, 1, bssid_info);
5580       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_security, tvb, offset, 1, bssid_info);
5581       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_key_scope, tvb, offset, 1, bssid_info);
5582       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_spec_mng, tvb, offset, 1, bssid_info);
5583       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_qos, tvb, offset, 1, bssid_info);
5584       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_apsd, tvb, offset, 1, bssid_info);
5585       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_radio_msnt, tvb, offset, 1, bssid_info);
5586       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_dback, tvb, offset+1, 1, bssid_info);
5587       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_iback, tvb, offset+1, 1, bssid_info);
5588       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_mobility_domain, tvb, offset+1, 1, bssid_info);
5589       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_high_throughput, tvb, offset+1, 1, bssid_info);
5590       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_reserved, tvb, offset+1, 3, (bssid_info & 0xfffff000) >> 12);
5591       /*** End: BSSID Information ***/
5592
5593       offset+=4;
5594       info = tvb_get_guint8 (tvb, offset);
5595       proto_tree_add_uint_format(tree, hf_tag_neighbor_report_reg_class, tvb, offset, 1, info, "Regulatory Class: 0x%02X", info);
5596
5597       offset++;
5598       info = tvb_get_guint8 (tvb, offset);
5599       proto_tree_add_uint_format(tree, hf_tag_neighbor_report_channel_number, tvb, offset, 1, info, "Channel Number: 0x%02X", info);
5600
5601       offset++;
5602       info = tvb_get_guint8 (tvb, offset);
5603       proto_tree_add_uint_format(tree, hf_tag_neighbor_report_phy_type, tvb, offset, 1, info, "PHY Type: 0x%02X", info);
5604
5605       offset++;
5606       sub_tag_id = tvb_get_guint8 (tvb, offset);
5607       offset++;
5608       sub_tag_length = tvb_get_guint8 (tvb, offset);
5609
5610       offset++;
5611       sub_tag_tvb = tvb_new_subset(tvb, offset, sub_tag_length, -1);
5612
5613       switch (sub_tag_id) {
5614         case SUB_TAG_TSF_INFO:
5615           /* TODO */
5616           break;
5617         case SUB_TAG_MEASUREMENT_PILOT_INFO:
5618           /* TODO */
5619           break;
5620         case SUB_TAG_HT_CAPABILITIES:
5621           parent_item = proto_tree_add_text (tree, tvb, offset, sub_tag_length, "HT Capabilities");
5622           sub_tag_tree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_sub_tag_tree);
5623           dissect_ht_capability_ie(sub_tag_tree, sub_tag_tvb, 0, sub_tag_length, FALSE);
5624           break;
5625         case SUB_TAG_HT_INFO:
5626           parent_item = proto_tree_add_text (tree, tvb, offset, sub_tag_length, "HT Information");
5627           sub_tag_tree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_sub_tag_tree);
5628           dissect_ht_info_ie_1_1(sub_tag_tree, sub_tag_tvb, 0, sub_tag_length);
5629           break;
5630         case SUB_TAG_SEC_CHANNEL_OFFSET:
5631           parent_item = proto_tree_add_text (tree, tvb, offset, sub_tag_length, "Secondary Channel Offset");
5632           sub_tag_tree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_sub_tag_tree);
5633           secondary_channel_offset_ie(sub_tag_tree, sub_tag_tvb, 0, sub_tag_length);
5634           break;
5635         case SUB_TAG_VENDOR_SPECIFIC:
5636         default:
5637           break;
5638       }
5639
5640       offset += sub_tag_length;
5641
5642       if (tag_len > (offset - tag_offset))
5643       {
5644         proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Unknown Data");
5645         break;
5646       }
5647       break;
5648     }
5649     /*** End: Neighbor Report Tag - Dustin Johnson ***/
5650 #if 0 /*Not yet assigned tag numbers by ANA */
5651     /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
5652     case TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT:
5653     {
5654       guint tag_offset;
5655
5656       if (tag_len != 4)
5657       {
5658         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5659             "Extended Channel Switch Announcement: Error: Tag length must be exactly 4 bytes long");
5660         break;
5661       }
5662
5663       offset+=2;
5664       tag_offset = offset;
5665
5666       offset+= add_fixed_field(tree, tvb, offset, FIELD_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT);
5667
5668       if (tag_len > (offset - tag_offset))
5669       {
5670         proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Unknown Data");
5671         break;
5672       }
5673       break;
5674     }
5675     /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
5676 #endif
5677 #if 0 /*Not yet assigned tag numbers by ANA */
5678     /*** Begin: Supported Regulatory Classes Tag - Dustin Johnson ***/
5679     case TAG_SUPPORTED_REGULATORY_CLASSES:
5680     {
5681       guint tag_offset;
5682       guint8 current_field;
5683
5684       if (tag_len < 2) {
5685         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5686             "Supported Regulatory Classes: Error: Tag length must be at least 2 bytes long");
5687         break;
5688       } else if (tag_len > 32) {
5689         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5690             "Supported Regulatory Classes: Error: Tag length must be no more than 32 bytes long");
5691         break;
5692       }
5693
5694       offset+=2;
5695       tag_offset = offset;
5696
5697       current_field = tvb_get_guint8 (tvb, offset);
5698       proto_tree_add_uint(tree, hf_tag_supported_reg_classes_current, tvb, offset, 1, current_field);
5699
5700       offset++;
5701       /* Partially taken from the ssid section */
5702       tag_data_ptr = tvb_get_ptr (tvb, offset, tag_len);
5703       for (i = 0, n = 0; i < tag_len && n < SHORT_STR; i++) {
5704         ret = g_snprintf (print_buff + n, SHORT_STR - n, (i == tag_len-1)?"%d":"%d, ", tag_data_ptr[i]);
5705         if (ret == -1 || ret >= SHORT_STR - n) {
5706           /* Some versions of snprintf return -1 if they'd truncate
5707              the output. Others return <buf_size> or greater.  */
5708           break;
5709         }
5710         n += ret;
5711       }
5712       print_buff[SHORT_STR-1] = '\0';
5713       proto_tree_add_string (tree, hf_tag_supported_reg_classes_alternate, tvb, offset, tag_len, print_buff);
5714
5715       break;
5716     }
5717     /*** End: Supported Regulatory Classes Tag - Dustin Johnson ***/
5718 #endif
5719     default:
5720       tvb_ensure_bytes_exist (tvb, offset + 2, tag_len);
5721       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 1 + tag_len_len,
5722           tag_len, "Not interpreted");
5723       proto_item_append_text(ti, ": Tag %u Len %u", tag_no, tag_len);
5724       break;
5725   }
5726
5727   return tag_len + 1 + tag_len_len;
5728 }
5729
5730 void
5731 ieee_80211_add_tagged_parameters (tvbuff_t * tvb, int offset, packet_info * pinfo,
5732   proto_tree * tree, int tagged_parameters_len)
5733 {
5734   int next_len;
5735
5736   beacon_padding = 0; /* this is for the beacon padding confused with ssid fix */
5737   while (tagged_parameters_len > 0) {
5738     if ((next_len=add_tagged_field (pinfo, tree, tvb, offset))==0)
5739       break;
5740     if (next_len > tagged_parameters_len) {
5741       /* XXX - flag this as an error? */
5742       next_len = tagged_parameters_len;
5743     }
5744     offset += next_len;
5745     tagged_parameters_len -= next_len;
5746   }
5747 }
5748
5749 /* ************************************************************************* */
5750 /*                     Dissect 802.11 management frame                       */
5751 /* ************************************************************************* */
5752 static void
5753 dissect_ieee80211_mgt (guint16 fcf, tvbuff_t * tvb, packet_info * pinfo,
5754     proto_tree * tree)
5755 {
5756   proto_item *ti = NULL;
5757   proto_tree *mgt_tree;
5758   proto_tree *fixed_tree;
5759   proto_tree *tagged_tree;
5760   int offset = 0;
5761   int tagged_parameter_tree_len;
5762
5763   g_pinfo = pinfo;
5764
5765   CHECK_DISPLAY_AS_X(data_handle,proto_wlan_mgt, tvb, pinfo, tree);
5766
5767   ti = proto_tree_add_item (tree, proto_wlan_mgt, tvb, 0, -1, FALSE);
5768   mgt_tree = proto_item_add_subtree (ti, ett_80211_mgt);
5769
5770   switch (COMPOSE_FRAME_TYPE(fcf))
5771   {
5772
5773     case MGT_ASSOC_REQ:
5774       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 4);
5775       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5776       add_fixed_field(fixed_tree, tvb, 2, FIELD_LISTEN_IVAL);
5777       offset = 4;  /* Size of fixed fields */
5778
5779       tagged_parameter_tree_len =
5780           tvb_reported_length_remaining(tvb, offset);
5781       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5782                  tagged_parameter_tree_len);
5783       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5784           tagged_parameter_tree_len);
5785       break;
5786
5787
5788     case MGT_ASSOC_RESP:
5789       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 6);
5790       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5791       add_fixed_field(fixed_tree, tvb, 2, FIELD_STATUS_CODE);
5792       add_fixed_field(fixed_tree, tvb, 4, FIELD_ASSOC_ID);
5793       offset = 6;  /* Size of fixed fields */
5794
5795       tagged_parameter_tree_len =
5796           tvb_reported_length_remaining(tvb, offset);
5797       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5798                  tagged_parameter_tree_len);
5799       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5800           tagged_parameter_tree_len);
5801       break;
5802
5803
5804     case MGT_REASSOC_REQ:
5805       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 10);
5806       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5807       add_fixed_field(fixed_tree, tvb, 2, FIELD_LISTEN_IVAL);
5808       add_fixed_field(fixed_tree, tvb, 4, FIELD_CURRENT_AP_ADDR);
5809       offset = 10;  /* Size of fixed fields */
5810
5811       tagged_parameter_tree_len =
5812           tvb_reported_length_remaining(tvb, offset);
5813       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5814                  tagged_parameter_tree_len);
5815       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5816           tagged_parameter_tree_len);
5817       break;
5818
5819     case MGT_REASSOC_RESP:
5820       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 6);
5821       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5822       add_fixed_field(fixed_tree, tvb, 2, FIELD_STATUS_CODE);
5823       add_fixed_field(fixed_tree, tvb, 4, FIELD_ASSOC_ID);
5824       offset = 6;  /* Size of fixed fields */
5825
5826       tagged_parameter_tree_len =
5827           tvb_reported_length_remaining(tvb, offset);
5828       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5829                  tagged_parameter_tree_len);
5830       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5831           tagged_parameter_tree_len);
5832       break;
5833
5834
5835     case MGT_PROBE_REQ:
5836       offset = 0;
5837       tagged_parameter_tree_len =
5838           tvb_reported_length_remaining(tvb, offset);
5839       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5840                  tagged_parameter_tree_len);
5841       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5842           tagged_parameter_tree_len);
5843       break;
5844
5845     case MGT_PROBE_RESP:
5846     {
5847       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 12);
5848       add_fixed_field(fixed_tree, tvb, 0, FIELD_TIMESTAMP);
5849       add_fixed_field(fixed_tree, tvb, 8, FIELD_BEACON_INTERVAL);
5850       add_fixed_field(fixed_tree, tvb, 10, FIELD_CAP_INFO);
5851       offset = 12;  /* Size of fixed fields */
5852
5853       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5854       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset, tagged_parameter_tree_len);
5855       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree, tagged_parameter_tree_len);
5856       break;
5857     }
5858     case MGT_MEASUREMENT_PILOT:
5859     {
5860       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 12);
5861       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_TIMESTAMP);
5862       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_MEASUREMENT_PILOT_INT);
5863       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_BEACON_INTERVAL);
5864       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_CAP_INFO);
5865       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_COUNTRY_STR);
5866       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_MAX_REG_PWR);
5867       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_MAX_TX_PWR);
5868       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_TX_PWR_USED);
5869       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_TRANSCEIVER_NOISE_FLOOR);
5870       /* TODO DS Parameter Set ??? */
5871
5872       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5873       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset, tagged_parameter_tree_len);
5874       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree, tagged_parameter_tree_len);
5875       break;
5876     }
5877     case MGT_BEACON:    /* Dissect protocol payload fields  */
5878       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 12);
5879       add_fixed_field(fixed_tree, tvb, 0, FIELD_TIMESTAMP);
5880       add_fixed_field(fixed_tree, tvb, 8, FIELD_BEACON_INTERVAL);
5881       add_fixed_field(fixed_tree, tvb, 10, FIELD_CAP_INFO);
5882       offset = 12;  /* Size of fixed fields */
5883
5884       tagged_parameter_tree_len =
5885           tvb_reported_length_remaining(tvb, offset);
5886       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5887       tagged_parameter_tree_len);
5888       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5889       tagged_parameter_tree_len);
5890       break;
5891
5892     case MGT_ATIM:
5893       break;
5894
5895     case MGT_DISASS:
5896       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 2);
5897       add_fixed_field(fixed_tree, tvb, 0, FIELD_REASON_CODE);
5898       break;
5899
5900     case MGT_AUTHENTICATION:
5901       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 6);
5902       add_fixed_field(fixed_tree, tvb, 0, FIELD_AUTH_ALG);
5903       add_fixed_field(fixed_tree, tvb, 2, FIELD_AUTH_TRANS_SEQ);
5904       add_fixed_field(fixed_tree, tvb, 4, FIELD_STATUS_CODE);
5905       offset = 6;  /* Size of fixed fields */
5906
5907       tagged_parameter_tree_len =
5908         tvb_reported_length_remaining(tvb, offset);
5909       if (tagged_parameter_tree_len != 0)
5910       {
5911         tagged_tree = get_tagged_parameter_tree (mgt_tree,
5912             tvb,
5913             offset,
5914             tagged_parameter_tree_len);
5915         ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5916         tagged_parameter_tree_len);
5917       }
5918       break;
5919
5920     case MGT_DEAUTHENTICATION:
5921       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 2);
5922       add_fixed_field(fixed_tree, tvb, 0, FIELD_REASON_CODE);
5923       break;
5924
5925     case MGT_ACTION:
5926     {
5927       proto_item *fixed_hdr;
5928       proto_tree *fixed_tree;
5929       fixed_hdr = proto_tree_add_text(mgt_tree, tvb, 0, 0, "Fixed parameters");
5930       fixed_tree = proto_item_add_subtree (fixed_hdr, ett_fixed_parameters);
5931
5932       offset += add_fixed_field(fixed_tree, tvb, 0, FIELD_ACTION);
5933
5934       proto_item_set_len(fixed_hdr, offset);
5935       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5936       if (tagged_parameter_tree_len != 0)
5937       {
5938         tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5939           tagged_parameter_tree_len);
5940         ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5941           tagged_parameter_tree_len);
5942       }
5943       break;
5944     }
5945     case MGT_ACTION_NO_ACK:
5946     {
5947       proto_item *fixed_hdr;
5948       proto_tree *fixed_tree;
5949       fixed_hdr = proto_tree_add_text(mgt_tree, tvb, 0, 0, "Fixed parameters");
5950       fixed_tree = proto_item_add_subtree (fixed_hdr, ett_fixed_parameters);
5951
5952       offset += add_fixed_field(fixed_tree, tvb, 0, FIELD_ACTION);
5953
5954       proto_item_set_len(fixed_hdr, offset);
5955       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5956       if (tagged_parameter_tree_len != 0)
5957       {
5958         tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5959           tagged_parameter_tree_len);
5960         ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5961           tagged_parameter_tree_len);
5962       }
5963       break;
5964     }
5965     case MGT_ARUBA_WLAN:
5966     {
5967       proto_item *aruba_hdr;
5968       proto_tree *aruba_tree;
5969       guint16 type;
5970       type = tvb_get_ntohs(tvb, offset);
5971
5972       aruba_hdr = proto_tree_add_text(mgt_tree, tvb, 0, 0, "Aruba Management");
5973       aruba_tree = proto_item_add_subtree(aruba_hdr, ett_fixed_parameters);
5974
5975       proto_tree_add_item(aruba_tree, cf_aruba, tvb, offset, 2, FALSE);
5976       offset += 2;
5977       /* HeartBeat Sequence */
5978       if ( type == 0x0005 )
5979       {
5980         proto_tree_add_item(aruba_tree, cf_aruba_hb_seq, tvb, offset, 8, FALSE);
5981       }
5982       /* MTU Size */
5983       if ( type == 0x0003 )
5984       {
5985         proto_tree_add_item(aruba_tree, cf_aruba_mtu, tvb, offset, 2, FALSE);
5986       }
5987       break;
5988     }
5989   }
5990 }
5991
5992 static void
5993 set_src_addr_cols(packet_info *pinfo, const guint8 *addr, const char *type)
5994 {
5995   if (check_col(pinfo->cinfo, COL_RES_DL_SRC))
5996     col_add_fstr(pinfo->cinfo, COL_RES_DL_SRC, "%s (%s)",
5997         get_ether_name(addr), type);
5998   if (check_col(pinfo->cinfo, COL_UNRES_DL_SRC))
5999     col_add_str(pinfo->cinfo, COL_UNRES_DL_SRC, ether_to_str(addr));
6000 }
6001
6002 static void
6003 set_dst_addr_cols(packet_info *pinfo, const guint8 *addr, const char *type)
6004 {
6005   if (check_col(pinfo->cinfo, COL_RES_DL_DST))
6006     col_add_fstr(pinfo->cinfo, COL_RES_DL_DST, "%s (%s)",
6007         get_ether_name(addr), type);
6008   if (check_col(pinfo->cinfo, COL_UNRES_DL_DST))
6009     col_add_str(pinfo->cinfo, COL_UNRES_DL_DST, ether_to_str(addr));
6010 }
6011
6012 static guint32
6013 crc32_802_tvb_padded(tvbuff_t *tvb, guint hdr_len, guint hdr_size, guint len)
6014 {
6015   guint32 c_crc;
6016
6017   c_crc = crc32_ccitt_tvb(tvb, hdr_len);
6018   c_crc = crc32_ccitt_seed(tvb_get_ptr(tvb, hdr_size, len), len, ~c_crc);
6019
6020   /* Byte reverse. */
6021   c_crc = ((unsigned char)(c_crc>>0)<<24) |
6022     ((unsigned char)(c_crc>>8)<<16) |
6023     ((unsigned char)(c_crc>>16)<<8) |
6024     ((unsigned char)(c_crc>>24)<<0);
6025
6026   return ( c_crc );
6027 }
6028
6029 typedef enum {
6030     ENCAP_802_2,
6031     ENCAP_IPX,
6032     ENCAP_ETHERNET
6033 } encap_t;
6034
6035
6036 /* ************************************************************************* */
6037 /*                          Dissect 802.11 frame                             */
6038 /* ************************************************************************* */
6039
6040 /*
6041  * The 802.11n specification makes some fairly significant changes to the
6042  * layout of the MAC header.  The first two bits of the MAC header are the
6043  * protocol version.  You'd think that the 802.11 committee would have
6044  * bumped the version to indicate a different MAC layout, but NOOOO -- we
6045  * have to go digging for bits in various locations instead.
6046  */
6047
6048 static void
6049 dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
6050         proto_tree * tree, gboolean fixed_length_header, gint fcs_len,
6051         gboolean wlan_broken_fc, gboolean datapad,
6052         gboolean is_ht)
6053 {
6054   guint16 fcf, flags, frame_type_subtype, ctrl_fcf, ctrl_type_subtype;
6055   guint16 seq_control;
6056   guint32 seq_number, frag_number;
6057   gboolean more_frags;
6058   const guint8 *src = NULL;
6059   const guint8 *dst = NULL;
6060   const guint8 *bssid = NULL;
6061   proto_item *ti = NULL;
6062   proto_item *fcs_item = NULL;
6063   proto_item *cw_item = NULL;
6064   proto_item *hidden_item;
6065   proto_tree *hdr_tree = NULL;
6066   proto_tree *fcs_tree = NULL;
6067   proto_tree *cw_tree = NULL;
6068   guint16 hdr_len, ohdr_len, htc_len = 0;
6069   gboolean has_fcs, fcs_good, fcs_bad;
6070   gint len, reported_len, ivlen;
6071   gboolean is_amsdu = 0;
6072   gboolean save_fragmented;
6073   tvbuff_t *volatile next_tvb = NULL;
6074   guint32 addr_type;
6075   volatile encap_t encap_type;
6076   guint8 octet1, octet2;
6077   char out_buff[SHORT_STR];
6078   gint is_iv_bad;
6079   guchar iv_buff[4];
6080   const char *addr1_str = NULL;
6081   int addr1_hf = -1;
6082   guint offset;
6083   const gchar *fts_str;
6084   gchar flag_str[] = "opmPRMFTC";
6085   gint i;
6086
6087   wlan_hdr *volatile whdr;
6088   static wlan_hdr whdrs[4];
6089   gboolean retransmitted;
6090
6091   whdr= &whdrs[0];
6092
6093   if (check_col (pinfo->cinfo, COL_PROTOCOL))
6094     col_set_str (pinfo->cinfo, COL_PROTOCOL, "IEEE 802.11");
6095   if (check_col (pinfo->cinfo, COL_INFO))
6096     col_clear (pinfo->cinfo, COL_INFO);
6097
6098   fcf = FETCH_FCF(0);
6099   frame_type_subtype = COMPOSE_FRAME_TYPE(fcf);
6100   if (frame_type_subtype == CTRL_CONTROL_WRAPPER)
6101     ctrl_fcf = FETCH_FCF(10);
6102   else
6103     ctrl_fcf = 0;
6104
6105   if (fixed_length_header)
6106     hdr_len = DATA_LONG_HDR_LEN;
6107   else
6108     hdr_len = find_header_length (fcf, ctrl_fcf, is_ht);
6109   ohdr_len = hdr_len;
6110   if (datapad)
6111     hdr_len = roundup2(hdr_len, 4);
6112
6113   fts_str = val_to_str(frame_type_subtype, frame_type_subtype_vals,
6114               "Unrecognized (Reserved frame)");
6115   if (check_col (pinfo->cinfo, COL_INFO))
6116       col_set_str (pinfo->cinfo, COL_INFO, fts_str);
6117
6118
6119   flags = FCF_FLAGS (fcf);
6120   more_frags = HAVE_FRAGMENTS (flags);
6121
6122   for (i = 0; i < 8; i++) {
6123     if (! (flags & 0x80 >> i)) {
6124       flag_str[i] = '.';
6125     }
6126   }
6127
6128   if (is_ht && IS_STRICTLY_ORDERED(flags) &&
6129     ((FCF_FRAME_TYPE(fcf) == MGT_FRAME) || (FCF_FRAME_TYPE(fcf) == DATA_FRAME &&
6130       DATA_FRAME_IS_QOS(frame_type_subtype)))) {
6131     htc_len = 4;
6132   }
6133
6134   /* Add the FC to the current tree */
6135   if (tree)
6136     {
6137       ti = proto_tree_add_protocol_format (tree, proto_wlan, tvb, 0, hdr_len,
6138           "IEEE 802.11 %s", fts_str);
6139       hdr_tree = proto_item_add_subtree (ti, ett_80211);
6140
6141       dissect_frame_control(hdr_tree, tvb, wlan_broken_fc, 0);
6142
6143       if (frame_type_subtype == CTRL_PS_POLL)
6144         proto_tree_add_uint(hdr_tree, hf_assoc_id,tvb,2,2,
6145             ASSOC_ID(tvb_get_letohs(tvb,2)));
6146
6147       else
6148         proto_tree_add_uint (hdr_tree, hf_did_duration, tvb, 2, 2,
6149             tvb_get_letohs (tvb, 2));
6150     }
6151
6152   /*
6153    * Decode the part of the frame header that isn't the same for all
6154    * frame types.
6155    */
6156   seq_control = 0;
6157   frag_number = 0;
6158   seq_number = 0;
6159
6160   switch (FCF_FRAME_TYPE (fcf))
6161   {
6162
6163     case MGT_FRAME:
6164       /*
6165        * All management frame types have the same header.
6166        */
6167       src = tvb_get_ptr (tvb, 10, 6);
6168       dst = tvb_get_ptr (tvb, 4, 6);
6169
6170       SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src);
6171       SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src);
6172       SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst);
6173       SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst);
6174
6175       /* for tap */
6176       SET_ADDRESS(&whdr->bssid, AT_ETHER, 6, tvb_get_ptr(tvb, 16,6));
6177       SET_ADDRESS(&whdr->src, AT_ETHER, 6, src);
6178       SET_ADDRESS(&whdr->dst, AT_ETHER, 6, dst);
6179       whdr->type = frame_type_subtype;
6180
6181       seq_control = tvb_get_letohs(tvb, 22);
6182       frag_number = SEQCTL_FRAGMENT_NUMBER(seq_control);
6183       seq_number = SEQCTL_SEQUENCE_NUMBER(seq_control);
6184
6185       if (check_col (pinfo->cinfo, COL_INFO))
6186       {
6187         col_append_fstr(pinfo->cinfo, COL_INFO,
6188             ", SN=%d", seq_number);
6189
6190         col_append_fstr(pinfo->cinfo, COL_INFO,
6191             ", FN=%d",frag_number);
6192       }
6193
6194       if (tree)
6195       {
6196         proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 4, 6, dst);
6197
6198         proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 10, 6, src);
6199
6200         /* add items for wlan.addr filter */
6201         hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 4, 6, dst);
6202         PROTO_ITEM_SET_HIDDEN(hidden_item);
6203         hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 10, 6, src);
6204         PROTO_ITEM_SET_HIDDEN(hidden_item);
6205
6206         proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 16, 6,
6207             tvb_get_ptr (tvb, 16, 6));
6208
6209         proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6210             frag_number);
6211
6212         proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6213             seq_number);
6214       }
6215       break;
6216
6217     case CONTROL_FRAME:
6218     {
6219       /*
6220        * Control Wrapper frames insert themselves between address 1
6221        * and address 2 in a normal control frame.  Process address 1
6222        * first, then handle the rest of the frame in dissect_control.
6223        */
6224       if (frame_type_subtype == CTRL_CONTROL_WRAPPER) {
6225         offset = 10; /* FC + D/ID + Address 1 + CFC + HTC */
6226         ctrl_fcf = FETCH_FCF(10);
6227         ctrl_type_subtype = COMPOSE_FRAME_TYPE(ctrl_fcf);
6228       } else {
6229         offset = 10; /* FC + D/ID + Address 1 */
6230         ctrl_fcf = fcf;
6231         ctrl_type_subtype = frame_type_subtype;
6232       }
6233
6234       switch (ctrl_type_subtype)
6235       {
6236         case CTRL_PS_POLL:
6237           addr1_str = "BSSID";
6238           addr1_hf = hf_addr_bssid;
6239           break;
6240         case CTRL_RTS:
6241         case CTRL_CTS:
6242         case CTRL_ACKNOWLEDGEMENT:
6243         case CTRL_CFP_END:
6244         case CTRL_CFP_ENDACK:
6245         case CTRL_BLOCK_ACK_REQ:
6246         case CTRL_BLOCK_ACK:
6247           addr1_str = "RA";
6248           addr1_hf = hf_addr_ra;
6249           break;
6250         default:
6251           break;
6252       }
6253
6254       if (!addr1_str) /* XXX - Should we throw some sort of error? */
6255         break;
6256
6257       /* Add address 1 */
6258       dst = tvb_get_ptr(tvb, 4, 6);
6259       set_dst_addr_cols(pinfo, dst, addr1_str);
6260       if (tree) {
6261         proto_tree_add_item(hdr_tree, addr1_hf, tvb, 4, 6, FALSE);
6262       }
6263
6264       /*
6265        * Start shoving in other fields if needed.
6266        * XXX - Should we look for is_ht as well?
6267        */
6268       if (frame_type_subtype == CTRL_CONTROL_WRAPPER && tree) {
6269         cw_item = proto_tree_add_text(hdr_tree, tvb, offset, 2,
6270           "Contained Frame Control");
6271         cw_tree = proto_item_add_subtree (cw_item, ett_cntrl_wrapper_fc);
6272         dissect_frame_control(cw_tree, tvb, FALSE, offset);
6273         dissect_ht_control(hdr_tree, tvb, offset + 2);
6274         offset+=6;
6275         cw_item = proto_tree_add_text(hdr_tree, tvb, offset, 2,
6276           "Carried Frame");
6277         hdr_tree = proto_item_add_subtree (cw_item, ett_cntrl_wrapper_fc);
6278       }
6279
6280       switch (ctrl_type_subtype)
6281       {
6282         case CTRL_PS_POLL:
6283         case CTRL_CFP_END:
6284         case CTRL_CFP_ENDACK:
6285         {
6286           src = tvb_get_ptr (tvb, offset, 6);
6287           set_src_addr_cols(pinfo, src, "BSSID");
6288           if (tree) {
6289             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6290           }
6291           break;
6292         }
6293
6294         case CTRL_RTS:
6295         {
6296           src = tvb_get_ptr (tvb, offset, 6);
6297           set_src_addr_cols(pinfo, src, "TA");
6298           if (tree) {
6299             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6300           }
6301           break;
6302         }
6303
6304         case CTRL_CONTROL_WRAPPER:
6305         {
6306           /* XXX - We shouldn't see this.  Should we throw an error? */
6307           break;
6308         }
6309
6310         /*** Begin: Block Ack Request - Dustin Johnson ***/
6311         case CTRL_BLOCK_ACK_REQ:
6312         {
6313           src = tvb_get_ptr (tvb, offset, 6);
6314           set_src_addr_cols(pinfo, src, "TA");
6315
6316           if (tree)
6317           {
6318             guint16 bar_control;
6319             guint8 block_ack_type;
6320             proto_item *bar_parent_item;
6321             proto_tree *bar_sub_tree;
6322
6323             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6324             offset += 6;
6325
6326             bar_control = tvb_get_letohs(tvb, offset);
6327             block_ack_type = (bar_control & 0x0006) >> 1;
6328             proto_tree_add_uint(hdr_tree, hf_block_ack_request_type, tvb,
6329               offset, 1, block_ack_type);
6330             bar_parent_item = proto_tree_add_uint_format(hdr_tree,
6331               hf_block_ack_request_control, tvb, offset, 2, bar_control,
6332               "Block Ack Request (BAR) Control: 0x%04X", bar_control);
6333             bar_sub_tree = proto_item_add_subtree(bar_parent_item,
6334               ett_block_ack);
6335             proto_tree_add_boolean(bar_sub_tree,
6336               hf_block_ack_control_ack_policy, tvb, offset, 1, bar_control);
6337             proto_tree_add_boolean(bar_sub_tree, hf_block_ack_control_multi_tid,
6338               tvb, offset, 1, bar_control);
6339             proto_tree_add_boolean(bar_sub_tree,
6340               hf_block_ack_control_compressed_bitmap, tvb, offset, 1,
6341               bar_control);
6342             proto_tree_add_uint(bar_sub_tree, hf_block_ack_control_reserved,
6343               tvb, offset, 2, bar_control);
6344
6345             switch (block_ack_type)
6346             {
6347               case 0: /*Basic BlockAckReq */
6348               {
6349                 proto_tree_add_uint(bar_sub_tree,
6350                 hf_block_ack_control_basic_tid_info, tvb, offset+1, 1,
6351                   bar_control);
6352                 offset += 2;
6353
6354                 offset += add_fixed_field(hdr_tree, tvb, offset,
6355                   FIELD_BLOCK_ACK_SSC);
6356                 break;
6357               }
6358               case 2: /* Compressed BlockAckReq */
6359               {
6360                 proto_tree_add_uint(bar_sub_tree,
6361                 hf_block_ack_control_compressed_tid_info, tvb, offset+1, 1,
6362                   bar_control);
6363                 offset += 2;
6364
6365                 offset += add_fixed_field(hdr_tree, tvb, offset,
6366                   FIELD_BLOCK_ACK_SSC);
6367                 break;
6368               }
6369               case 3: /* Multi-TID BlockAckReq */
6370               {
6371                 guint8 tid_count, i;
6372                 proto_tree *bar_mtid_tree, *bar_mtid_sub_tree;
6373
6374                 tid_count = ((bar_control & 0xF000) >> 12) + 1;
6375                 proto_tree_add_uint_format(bar_sub_tree, hf_block_ack_control_compressed_tid_info, tvb, offset+1, 1, bar_control,
6376                 decode_numeric_bitfield(bar_control, 0xF000, 16,"Number of TIDs Present: 0x%%X"), tid_count);
6377                 offset += 2;
6378
6379                 bar_parent_item = proto_tree_add_text (hdr_tree, tvb, offset, tid_count*4, "Per TID Info");
6380                 bar_mtid_tree = proto_item_add_subtree(bar_parent_item, ett_block_ack);
6381                 for (i = 1; i <= tid_count; i++) {
6382                   bar_parent_item = proto_tree_add_uint(bar_mtid_tree, hf_block_ack_multi_tid_info, tvb, offset, 4, i);
6383                   bar_mtid_sub_tree = proto_item_add_subtree(bar_parent_item, ett_block_ack);
6384
6385                   bar_control = tvb_get_letohs(tvb, offset);
6386                   proto_tree_add_uint(bar_mtid_sub_tree, hf_block_ack_multi_tid_reserved, tvb, offset, 2, bar_control);
6387                   proto_tree_add_uint(bar_mtid_sub_tree, hf_block_ack_multi_tid_value, tvb, offset+1, 1, bar_control);
6388                   offset += 2;
6389
6390                   offset += add_fixed_field(bar_mtid_sub_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6391                 }
6392                 break;
6393               }
6394             }
6395           }
6396           break;
6397         }
6398         /*** End: Block Ack Request - Dustin Johnson ***/
6399
6400         /*** Begin: Block Ack - Dustin Johnson ***/
6401         case CTRL_BLOCK_ACK:
6402         {
6403           src = tvb_get_ptr (tvb, offset, 6);
6404           set_src_addr_cols(pinfo, src, "TA");
6405
6406           if (tree)
6407           {
6408             guint16 ba_control;
6409             guint8 block_ack_type;
6410             proto_item *ba_parent_item;
6411             proto_tree *ba_sub_tree;
6412
6413             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6414             offset += 6;
6415
6416             ba_control = tvb_get_letohs(tvb, offset);
6417             block_ack_type = (ba_control & 0x0006) >> 1;
6418             proto_tree_add_uint(hdr_tree, hf_block_ack_type, tvb, offset, 1, block_ack_type);
6419             ba_parent_item = proto_tree_add_uint_format(hdr_tree,
6420               hf_block_ack_control, tvb, offset, 2, ba_control,
6421               "Block Ack (BA) Control: 0x%04X", ba_control);
6422             ba_sub_tree = proto_item_add_subtree(ba_parent_item, ett_block_ack);
6423             proto_tree_add_boolean(ba_sub_tree, hf_block_ack_control_ack_policy,
6424               tvb, offset, 1, ba_control);
6425             proto_tree_add_boolean(ba_sub_tree, hf_block_ack_control_multi_tid,
6426               tvb, offset, 1, ba_control);
6427             proto_tree_add_boolean(ba_sub_tree,
6428               hf_block_ack_control_compressed_bitmap, tvb, offset, 1,
6429               ba_control);
6430             proto_tree_add_uint(ba_sub_tree, hf_block_ack_control_reserved, tvb,
6431               offset, 2, ba_control);
6432
6433             switch (block_ack_type)
6434             {
6435               case 0: /*Basic BlockAck */
6436               {
6437                 proto_tree_add_uint(ba_sub_tree,
6438                 hf_block_ack_control_basic_tid_info, tvb, offset+1, 1,
6439                   ba_control);
6440                 offset += 2;
6441
6442                 offset += add_fixed_field(hdr_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6443                 proto_tree_add_text(hdr_tree, tvb, offset, 128, "Block Ack Bitmap");
6444                 offset += 128;
6445                 break;
6446               }
6447               case 2: /* Compressed BlockAck */
6448               {
6449                 proto_tree_add_uint(ba_sub_tree, hf_block_ack_control_basic_tid_info, tvb, offset+1, 1, ba_control);
6450                 offset += 2;
6451
6452                 offset += add_fixed_field(hdr_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6453                 proto_tree_add_text(hdr_tree, tvb, offset, 8, "Block Ack Bitmap");
6454                 offset += 8;
6455                 break;
6456               }
6457               case 3:  /* Multi-TID BlockAck */
6458               {
6459                 guint8 tid_count, i;
6460                 proto_tree *ba_mtid_tree, *ba_mtid_sub_tree;
6461
6462                 tid_count = ((ba_control & 0xF000) >> 12) + 1;
6463                 proto_tree_add_uint_format(ba_sub_tree,
6464                 hf_block_ack_control_compressed_tid_info, tvb, offset+1, 1,
6465                   ba_control, decode_numeric_bitfield(ba_control, 0xF000,
6466                   16,"Number of TIDs Present: 0x%%X"), tid_count);
6467                 offset += 2;
6468
6469                 ba_parent_item = proto_tree_add_text (hdr_tree, tvb, offset, tid_count*4, "Per TID Info");
6470                 ba_mtid_tree = proto_item_add_subtree(ba_parent_item, ett_block_ack);
6471                 for (i=1; i<=tid_count; i++) {
6472                   ba_parent_item = proto_tree_add_uint(ba_mtid_tree, hf_block_ack_multi_tid_info, tvb, offset, 4, i);
6473                   ba_mtid_sub_tree = proto_item_add_subtree(ba_parent_item, ett_block_ack);
6474
6475                   ba_control = tvb_get_letohs(tvb, offset);
6476                   proto_tree_add_uint(ba_mtid_sub_tree, hf_block_ack_multi_tid_reserved, tvb, offset, 2, ba_control);
6477                   proto_tree_add_uint(ba_mtid_sub_tree, hf_block_ack_multi_tid_value, tvb, offset+1, 1, ba_control);
6478                   offset += 2;
6479
6480                   offset += add_fixed_field(ba_mtid_sub_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6481                   proto_tree_add_text(ba_mtid_sub_tree, tvb, offset, 8, "Block Ack Bitmap");
6482                   offset += 8;
6483                 }
6484                 break;
6485               }
6486             }
6487           }
6488           break;
6489         }
6490         /*** End: Block Ack - Dustin Johnson ***/
6491       }
6492       break;
6493     }
6494
6495     case DATA_FRAME:
6496       addr_type = FCF_ADDR_SELECTOR (fcf);
6497
6498       /* In order to show src/dst address we must always do the following */
6499       switch (addr_type)
6500       {
6501
6502         case DATA_ADDR_T1:
6503           src = tvb_get_ptr (tvb, 10, 6);
6504           dst = tvb_get_ptr (tvb, 4, 6);
6505           bssid = tvb_get_ptr (tvb, 16, 6);
6506           break;
6507
6508         case DATA_ADDR_T2:
6509           src = tvb_get_ptr (tvb, 16, 6);
6510           dst = tvb_get_ptr (tvb, 4, 6);
6511           bssid = tvb_get_ptr (tvb, 10, 6);
6512           break;
6513
6514         case DATA_ADDR_T3:
6515           src = tvb_get_ptr (tvb, 10, 6);
6516           dst = tvb_get_ptr (tvb, 16, 6);
6517           bssid = tvb_get_ptr (tvb, 4, 6);
6518           break;
6519
6520         case DATA_ADDR_T4:
6521           src = tvb_get_ptr (tvb, 24, 6);
6522           dst = tvb_get_ptr (tvb, 16, 6);
6523           bssid = tvb_get_ptr (tvb, 16, 6);
6524           break;
6525       }
6526
6527       SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src);
6528       SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src);
6529       SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst);
6530       SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst);
6531
6532       /* for tap */
6533
6534       SET_ADDRESS(&whdr->bssid, AT_ETHER, 6, bssid);
6535       SET_ADDRESS(&whdr->src, AT_ETHER, 6, src);
6536       SET_ADDRESS(&whdr->dst, AT_ETHER, 6, dst);
6537       whdr->type = frame_type_subtype;
6538
6539       seq_control = tvb_get_letohs(tvb, 22);
6540       frag_number = SEQCTL_FRAGMENT_NUMBER(seq_control);
6541       seq_number = SEQCTL_SEQUENCE_NUMBER(seq_control);
6542
6543       if (check_col (pinfo->cinfo, COL_INFO))
6544       {
6545         col_append_fstr(pinfo->cinfo, COL_INFO,
6546             ", SN=%d", seq_number);
6547
6548         col_append_fstr(pinfo->cinfo, COL_INFO,
6549             ", FN=%d",frag_number);
6550       }
6551
6552       /* Now if we have a tree we start adding stuff */
6553       if (tree)
6554       {
6555
6556         switch (addr_type)
6557         {
6558
6559           case DATA_ADDR_T1:
6560             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 4, 6, dst);
6561             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 10, 6, src);
6562             proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 16, 6,
6563                 tvb_get_ptr (tvb, 16, 6));
6564             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6565                frag_number);
6566             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6567                seq_number);
6568
6569             /* add items for wlan.addr filter */
6570             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 4, 6, dst);
6571             PROTO_ITEM_SET_HIDDEN(hidden_item);
6572             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 10, 6, src);
6573             PROTO_ITEM_SET_HIDDEN(hidden_item);
6574             break;
6575
6576           case DATA_ADDR_T2:
6577             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 4, 6, dst);
6578             proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 10, 6,
6579                 tvb_get_ptr (tvb, 10, 6));
6580             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 16, 6, src);
6581             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6582                frag_number);
6583             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6584                seq_number);
6585
6586             /* add items for wlan.addr filter */
6587             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 4, 6, dst);
6588             PROTO_ITEM_SET_HIDDEN(hidden_item);
6589             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 16, 6, src);
6590             PROTO_ITEM_SET_HIDDEN(hidden_item);
6591             break;
6592
6593           case DATA_ADDR_T3:
6594             proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 4, 6,
6595                 tvb_get_ptr (tvb, 4, 6));
6596             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 10, 6, src);
6597             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 16, 6, dst);
6598
6599             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6600                frag_number);
6601             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6602                seq_number);
6603
6604             /* add items for wlan.addr filter */
6605             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 10, 6, src);
6606             PROTO_ITEM_SET_HIDDEN(hidden_item);
6607             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 16, 6, dst);
6608             PROTO_ITEM_SET_HIDDEN(hidden_item);
6609             break;
6610
6611           case DATA_ADDR_T4:
6612             proto_tree_add_ether (hdr_tree, hf_addr_ra, tvb, 4, 6,
6613                 tvb_get_ptr (tvb, 4, 6));
6614             proto_tree_add_ether (hdr_tree, hf_addr_ta, tvb, 10, 6,
6615                 tvb_get_ptr (tvb, 10, 6));
6616             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 16, 6, dst);
6617             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6618                frag_number);
6619             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6620                seq_number);
6621             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 24, 6, src);
6622
6623             /* add items for wlan.addr filter */
6624             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 16, 6, dst);
6625             PROTO_ITEM_SET_HIDDEN(hidden_item);
6626             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 24, 6, src);
6627             PROTO_ITEM_SET_HIDDEN(hidden_item);
6628             break;
6629         }
6630
6631       }
6632       break;
6633   }
6634
6635   len = tvb_length_remaining(tvb, hdr_len);
6636   reported_len = tvb_reported_length_remaining(tvb, hdr_len);
6637
6638   switch (fcs_len)
6639     {
6640       case 0: /* Definitely has no FCS */
6641         has_fcs = FALSE;
6642         break;
6643
6644       case 4: /* Definitely has an FCS */
6645         has_fcs = TRUE;
6646         break;
6647
6648       default: /* Don't know - use "wlan_check_fcs" */
6649         has_fcs = wlan_check_fcs;
6650         break;
6651     }
6652   if (has_fcs)
6653     {
6654       /*
6655        * Well, this packet should, in theory, have an FCS.
6656        * Do we have the entire packet, and does it have enough data for
6657        * the FCS?
6658        */
6659       if (reported_len < 4)
6660       {
6661         /*
6662          * The packet is claimed not to even have enough data for a 4-byte
6663          * FCS.
6664          * Pretend it doesn't have an FCS.
6665          */
6666         ;
6667       }
6668       else if (len < reported_len)
6669       {
6670         /*
6671          * The packet is claimed to have enough data for a 4-byte FCS, but
6672          * we didn't capture all of the packet.
6673          * Slice off the 4-byte FCS from the reported length, and trim the
6674          * captured length so it's no more than the reported length; that
6675          * will slice off what of the FCS, if any, is in the captured
6676          * length.
6677          */
6678         reported_len -= 4;
6679         if (len > reported_len)
6680             len = reported_len;
6681       }
6682       else
6683       {
6684         /*
6685          * We have the entire packet, and it includes a 4-byte FCS.
6686          * Slice it off, and put it into the tree.
6687          */
6688         len -= 4;
6689         reported_len -= 4;
6690         if (tree)
6691         {
6692           guint32 sent_fcs = tvb_get_ntohl(tvb, hdr_len + len);
6693           guint32 fcs;
6694
6695           if (datapad)
6696             fcs = crc32_802_tvb_padded(tvb, ohdr_len, hdr_len, len);
6697           else
6698             fcs = crc32_802_tvb(tvb, hdr_len + len);
6699           if (fcs == sent_fcs) {
6700             fcs_good = TRUE;
6701             fcs_bad = FALSE;
6702           } else {
6703             fcs_good = FALSE;
6704             fcs_bad = TRUE;
6705           }
6706
6707           if(fcs_good) {
6708             fcs_item = proto_tree_add_uint_format(hdr_tree, hf_fcs, tvb,
6709                 hdr_len + len, 4, sent_fcs,
6710                 "Frame check sequence: 0x%08x [correct]", sent_fcs);
6711           } else {
6712             fcs_item = proto_tree_add_uint_format(hdr_tree, hf_fcs, tvb,
6713                 hdr_len + len, 4, sent_fcs,
6714                 "Frame check sequence: 0x%08x [incorrect, should be 0x%08x]",
6715                 sent_fcs, fcs);
6716             flag_str[8] = '.';
6717           }
6718
6719           proto_tree_set_appendix(hdr_tree, tvb, hdr_len + len, 4);
6720
6721           fcs_tree = proto_item_add_subtree(fcs_item, ett_fcs);
6722
6723           fcs_item = proto_tree_add_boolean(fcs_tree,
6724               hf_fcs_good, tvb,
6725               hdr_len + len, 4,
6726               fcs_good);
6727           PROTO_ITEM_SET_GENERATED(fcs_item);
6728
6729           fcs_item = proto_tree_add_boolean(fcs_tree,
6730               hf_fcs_bad, tvb,
6731               hdr_len + len, 4,
6732               fcs_bad);
6733           PROTO_ITEM_SET_GENERATED(fcs_item);
6734         }
6735       }
6736     } else {
6737       flag_str[8] = '\0';
6738     }
6739
6740     proto_item_append_text(ti, ", Flags: %s", flag_str);
6741     if (check_col (pinfo->cinfo, COL_INFO))
6742       col_append_fstr (pinfo->cinfo, COL_INFO, ", Flags=%s", flag_str);
6743
6744
6745   /*
6746    * Only management and data frames have a body, so we don't have
6747    * anything more to do for other types of frames.
6748    */
6749   switch (FCF_FRAME_TYPE (fcf))
6750     {
6751
6752     case MGT_FRAME:
6753       if (htc_len == 4) {
6754         dissect_ht_control(hdr_tree, tvb, ohdr_len - 4);
6755       }
6756       break;
6757
6758     case DATA_FRAME:
6759       if (tree && DATA_FRAME_IS_QOS(frame_type_subtype))
6760       {
6761         proto_item *qos_fields;
6762         proto_tree *qos_tree;
6763
6764         guint16 qosoff;
6765         guint16 qos_control;
6766         guint16 qos_priority;
6767         guint16 qos_ack_policy;
6768         guint16 qos_amsdu_present;
6769         guint16 qos_eosp;
6770         guint16 qos_field_content;
6771
6772         /*
6773          * We calculate the offset to the QoS header data as
6774          * an offset relative to the end of the header.  But
6775          * when the header has been padded to align the data
6776          * this must be done relative to true header size, not
6777          * the padded/aligned value.  To simplify this work we
6778          * stash the original header size in ohdr_len instead
6779          * of recalculating it.
6780          */
6781         qosoff = ohdr_len - htc_len - 2;
6782         qos_fields = proto_tree_add_text(hdr_tree, tvb, qosoff, 2,
6783             "QoS Control");
6784         qos_tree = proto_item_add_subtree (qos_fields, ett_qos_parameters);
6785
6786         qos_control = tvb_get_letohs(tvb, qosoff + 0);
6787         qos_priority = QOS_PRIORITY(qos_control);
6788         qos_ack_policy = QOS_ACK_POLICY(qos_control);
6789         qos_amsdu_present = QOS_AMSDU_PRESENT(qos_control);
6790         qos_eosp = QOS_EOSP(qos_control);
6791         qos_field_content = QOS_FIELD_CONTENT(qos_control);
6792
6793         proto_tree_add_uint_format (qos_tree, hf_qos_priority, tvb,
6794             qosoff, 1, qos_priority,
6795             "Priority: %d (%s) (%s)",
6796             qos_priority, qos_tags[qos_priority], qos_acs[qos_priority]);
6797
6798         if (flags & FLAG_FROM_DS) {
6799           proto_tree_add_boolean (qos_tree, hf_qos_eosp, tvb,
6800               qosoff, 1, qos_control);
6801         }
6802
6803         proto_tree_add_uint (qos_tree, hf_qos_ack_policy, tvb, qosoff, 1,
6804             qos_ack_policy);
6805
6806         if (flags & FLAG_FROM_DS) {
6807           if (!DATA_FRAME_IS_NULL(frame_type_subtype)) {
6808             proto_tree_add_boolean(qos_tree, hf_qos_amsdu_present, tvb,
6809                 qosoff, 1, qos_amsdu_present);
6810             is_amsdu = qos_amsdu_present;
6811           }
6812           if (DATA_FRAME_IS_CF_POLL(frame_type_subtype)) {
6813             /* txop limit */
6814             proto_tree_add_uint_format (qos_tree, hf_qos_field_content, tvb,
6815                 qosoff + 1, 1, qos_field_content, "Transmit Opportunity (TXOP) Limit: 0x%02X", qos_field_content);
6816
6817           } else {
6818             /* qap ps buffer state */
6819             proto_item *qos_ps_buf_state_fields;
6820                 proto_tree *qos_ps_buf_state_tree;
6821             guint16 buf_state;
6822             guint16 buf_ac;
6823             guint16 buf_load;
6824
6825             buf_state = QOS_PS_BUF_STATE(qos_field_content);
6826             buf_ac = QOS_PS_BUF_AC(qos_field_content);  /*access category */
6827             buf_load = QOS_PS_BUF_LOAD(qos_field_content);
6828
6829             qos_ps_buf_state_fields = proto_tree_add_text(qos_tree, tvb, qosoff + 1, 1,
6830                 "QAP PS Buffer State: 0x%x", qos_field_content);
6831             qos_ps_buf_state_tree = proto_item_add_subtree (qos_ps_buf_state_fields, ett_qos_ps_buf_state);
6832
6833 /*  FIXME: hf_ values not defined
6834             proto_tree_add_boolean (qos_ps_buf_state_tree, hf_qos_buf_state, tvb,
6835                 1, 1, buf_state);
6836
6837             proto_tree_add_uint_format (qos_ps_buf_state_tree, hf_qos_buf_ac, tvb,
6838             qosoff + 1, 1, buf_ac, "Priority: %d (%s)",
6839                 buf_ac, wme_acs[buf_ac]);
6840
6841             proto_tree_add_uint_format (qos_ps_buf_state_tree, hf_qos_buf_load, tvb,
6842                 qosoff + 1, 1, buf_load, "Buffered load: %d ", (buf_load * 4096));
6843 */
6844
6845           }
6846         } else {
6847           if (!DATA_FRAME_IS_NULL(frame_type_subtype)) {
6848             proto_tree_add_boolean(qos_tree, hf_qos_amsdu_present, tvb,
6849                 qosoff, 1, qos_amsdu_present);
6850             is_amsdu = qos_amsdu_present;
6851           }
6852           if (qos_eosp) {
6853             /* txop limit requested */
6854             proto_tree_add_uint_format (qos_tree, hf_qos_field_content, tvb,
6855                 qosoff + 1, 1, qos_field_content, "Queue Size: %d", (qos_field_content * 254));
6856           } else {
6857             /* queue size */
6858             proto_tree_add_uint_format (qos_tree, hf_qos_field_content, tvb,
6859             qosoff + 1, 1, qos_field_content, "Transmit Opportunity (TXOP) Limit Requested: 0x%02X", qos_field_content);
6860           }
6861         }
6862
6863         /* Do we have +HTC? */
6864         if (htc_len == 4) {
6865           dissect_ht_control(hdr_tree, tvb, ohdr_len - 4);
6866         }
6867       } /* end of qos control field */
6868
6869 #ifdef HAVE_AIRPDCAP
6870       /* Davide Schiera (2006-11-21): process handshake packet with AirPDcap    */
6871       /* the processing will take care of 4-way handshake sessions for WPA    */
6872       /* and WPA2 decryption                                  */
6873       if (enable_decryption && !pinfo->fd->flags.visited) {
6874         const guint8 *enc_data = tvb_get_ptr(tvb, 0, hdr_len+reported_len);
6875         AirPDcapPacketProcess(&airpdcap_ctx, enc_data, hdr_len, hdr_len+reported_len, NULL, 0, NULL, TRUE, FALSE);
6876       }
6877       /* Davide Schiera --------------------------------------------------------  */
6878 #endif
6879
6880       /*
6881        * No-data frames don't have a body.
6882        */
6883       if (DATA_FRAME_IS_NULL(frame_type_subtype))
6884         return;
6885
6886       if (!wlan_subdissector) {
6887         guint fnum = 0;
6888
6889         /* key: bssid:src
6890          * data: last seq_control seen and frame number
6891          */
6892         retransmitted = FALSE;
6893         if(!pinfo->fd->flags.visited){
6894           retransmit_key key;
6895           retransmit_key *result;
6896
6897           memcpy(key.bssid, bssid, 6);
6898           memcpy(key.src, src, 6);
6899           key.seq_control = 0;
6900           result = (retransmit_key *)g_hash_table_lookup(fc_analyse_retransmit_table, &key);
6901           if (result && result->seq_control == seq_control) {
6902                /* keep a pointer to the first seen frame, could be done with proto data? */
6903                fnum = result->fnum;
6904                g_hash_table_insert(fc_first_frame_table, GINT_TO_POINTER( pinfo->fd->num),
6905                   GINT_TO_POINTER(fnum));
6906                retransmitted = TRUE;
6907           } else {
6908                /* first time or new seq*/
6909                if (!result) {
6910                   result = se_alloc(sizeof(retransmit_key));
6911                   *result = key;
6912                   g_hash_table_insert(fc_analyse_retransmit_table, result, result);
6913                }
6914                result->seq_control = seq_control;
6915                result->fnum =  pinfo->fd->num;
6916            }
6917         }
6918         else if ((fnum = GPOINTER_TO_UINT(g_hash_table_lookup(fc_first_frame_table, GINT_TO_POINTER( pinfo->fd->num))))) {
6919            retransmitted = TRUE;
6920         }
6921
6922         if (retransmitted) {
6923             if (check_col (pinfo->cinfo, COL_INFO))
6924                 col_append_fstr(pinfo->cinfo, COL_INFO, " [retransmitted]");
6925             if (tree) {
6926                 proto_item *item;
6927
6928                 item=proto_tree_add_none_format(hdr_tree, hf_fc_analysis_retransmission, tvb, 0, 0, "Retransmitted frame");
6929                 PROTO_ITEM_SET_GENERATED(item);
6930                 item=proto_tree_add_uint(hdr_tree, hf_fc_analysis_retransmission_frame,tvb, 0, 0, fnum);
6931                 PROTO_ITEM_SET_GENERATED(item);
6932             }
6933             next_tvb = tvb_new_subset (tvb, hdr_len, len, reported_len);
6934             call_dissector(data_handle, next_tvb, pinfo, tree);
6935             goto end_of_wlan;
6936         }
6937       }
6938
6939       break;
6940
6941     case CONTROL_FRAME:
6942       return;
6943
6944     default:
6945       return;
6946     }
6947
6948   if (IS_PROTECTED(FCF_FLAGS(fcf)) && wlan_ignore_wep != WLAN_IGNORE_WEP_WO_IV) {
6949     /*
6950      * It's a WEP or WPA encrypted frame; dissect the protections parameters
6951      * and decrypt the data, if we have a matching key. Otherwise display it as data.
6952      */
6953
6954     gboolean can_decrypt = FALSE;
6955     proto_tree *wep_tree = NULL;
6956     guint32 iv;
6957     guint8 key, keybyte;
6958
6959     /* Davide Schiera (2006-11-27): define algorithms constants and macros  */
6960 #ifdef HAVE_AIRPDCAP
6961 #define PROTECTION_ALG_TKIP  AIRPDCAP_KEY_TYPE_TKIP
6962 #define PROTECTION_ALG_CCMP  AIRPDCAP_KEY_TYPE_CCMP
6963 #define PROTECTION_ALG_WEP  AIRPDCAP_KEY_TYPE_WEP
6964 #define PROTECTION_ALG_RSNA  PROTECTION_ALG_CCMP | PROTECTION_ALG_TKIP
6965 #else
6966 #define PROTECTION_ALG_WEP  0
6967 #define PROTECTION_ALG_TKIP  1
6968 #define PROTECTION_ALG_CCMP  2
6969 #define PROTECTION_ALG_RSNA  PROTECTION_ALG_CCMP | PROTECTION_ALG_TKIP
6970 #endif
6971     guint8 algorithm=-1;
6972     /* Davide Schiera (2006-11-27): added macros to check the algorithm    */
6973     /* used could be TKIP or CCMP                            */
6974 #define IS_TKIP(tvb, hdr_len)  (tvb_get_guint8(tvb, hdr_len + 1) & 0x20)
6975 #define IS_CCMP(tvb, hdr_len)  (tvb_get_guint8(tvb, hdr_len + 2) == 0)
6976     /* Davide Schiera -----------------------------------------------------  */
6977
6978 #ifdef  HAVE_AIRPDCAP
6979     /* Davide Schiera (2006-11-21): recorded original lengths to pass them  */
6980     /* to the packets process function                        */
6981     guint32 sec_header=0;
6982     guint32 sec_trailer=0;
6983
6984     next_tvb = try_decrypt(tvb, hdr_len, reported_len, &algorithm, &sec_header, &sec_trailer);
6985 #endif
6986     /* Davide Schiera -----------------------------------------------------  */
6987
6988     keybyte = tvb_get_guint8(tvb, hdr_len + 3);
6989     key = KEY_OCTET_WEP_KEY(keybyte);
6990     if ((keybyte & KEY_EXTIV) && (len >= EXTIV_LEN)) {
6991       /* Extended IV; this frame is likely encrypted with TKIP or CCMP */
6992
6993
6994       if (tree) {
6995         proto_item *extiv_fields;
6996
6997 #ifdef HAVE_AIRPDCAP
6998         /* Davide Schiera (2006-11-27): differentiated CCMP and TKIP if  */
6999         /* it's possible                                */
7000         if (algorithm==PROTECTION_ALG_TKIP)
7001           extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7002               "TKIP parameters");
7003         else if (algorithm==PROTECTION_ALG_CCMP)
7004           extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7005             "CCMP parameters");
7006         else {
7007           /* Davide Schiera --------------------------------------------  */
7008 #endif
7009           /* Davide Schiera (2006-11-27): differentiated CCMP and TKIP if*/
7010           /* it's possible                              */
7011           if (IS_TKIP(tvb, hdr_len)) {
7012             algorithm=PROTECTION_ALG_TKIP;
7013             extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7014                 "TKIP parameters");
7015           } else if (IS_CCMP(tvb, hdr_len)) {
7016             algorithm=PROTECTION_ALG_CCMP;
7017             extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7018                 "CCMP parameters");
7019           } else
7020             extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7021                 "TKIP/CCMP parameters");
7022 #ifdef HAVE_AIRPDCAP
7023         }
7024 #endif
7025         proto_item_set_len (ti, hdr_len + 8);
7026
7027         wep_tree = proto_item_add_subtree (extiv_fields, ett_wep_parameters);
7028
7029         if (algorithm==PROTECTION_ALG_TKIP) {
7030           g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X",
7031               tvb_get_letohl(tvb, hdr_len + 4),
7032               tvb_get_guint8(tvb, hdr_len),
7033               tvb_get_guint8(tvb, hdr_len + 2));
7034           proto_tree_add_string(wep_tree, hf_tkip_extiv, tvb, hdr_len,
7035               EXTIV_LEN, out_buff);
7036         } else if (algorithm==PROTECTION_ALG_CCMP) {
7037           g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X",
7038               tvb_get_letohl(tvb, hdr_len + 4),
7039               tvb_get_guint8(tvb, hdr_len + 1),
7040               tvb_get_guint8(tvb, hdr_len));
7041           proto_tree_add_string(wep_tree, hf_ccmp_extiv, tvb, hdr_len,
7042               EXTIV_LEN, out_buff);
7043         }
7044
7045         proto_tree_add_uint(wep_tree, hf_wep_key, tvb, hdr_len + 3, 1, key);
7046       }
7047
7048       /* Subtract out the length of the IV. */
7049       len -= EXTIV_LEN;
7050       reported_len -= EXTIV_LEN;
7051       ivlen = EXTIV_LEN;
7052       /* It is unknown whether this is TKIP or CCMP, so let's not even try to
7053        * parse TKIP Michael MIC+ICV or CCMP MIC. */
7054
7055 #ifdef HAVE_AIRPDCAP
7056       /* Davide Schiera (2006-11-21): enable TKIP and CCMP decryption      */
7057       /* checking for the trailer                            */
7058       if (next_tvb!=NULL) {
7059         if (reported_len < (gint) sec_trailer) {
7060           /* There is no space for a trailer, ignore it and don't decrypt  */
7061           ;
7062         } else if (len < reported_len) {
7063           /* There is space for a trailer, but we haven't capture all the  */
7064           /* packet. Slice off the trailer, but don't try to decrypt      */
7065           reported_len -= sec_trailer;
7066           if (len > reported_len)
7067             len = reported_len;
7068         } else {
7069           /* Ok, we have a trailer and the whole packet. Decrypt it!      */
7070           /* TODO: At the moment we won't add the trailer to the tree,    */
7071           /* so don't remove the trailer from the packet              */
7072           len -= sec_trailer;
7073           reported_len -= sec_trailer;
7074           can_decrypt = TRUE;
7075         }
7076       }
7077       /* Davide Schiera --------------------------------------------------  */
7078 #endif
7079     } else {
7080       /* No Ext. IV - WEP packet */
7081       /*
7082        * XXX - pass the IV and key to "try_decrypt_wep()", and have it pass
7083        * them to "wep_decrypt()", rather than having "wep_decrypt()" extract
7084        * them itself.
7085        *
7086        * Also, just pass the data *following* the WEP parameters as the
7087        * buffer to decrypt.
7088        */
7089       iv = tvb_get_ntoh24(tvb, hdr_len);
7090       if (tree) {
7091         proto_item *wep_fields;
7092
7093         wep_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 4,
7094             "WEP parameters");
7095
7096         wep_tree = proto_item_add_subtree (wep_fields, ett_wep_parameters);
7097         proto_tree_add_uint (wep_tree, hf_wep_iv, tvb, hdr_len, 3, iv);
7098         tvb_memcpy(tvb, iv_buff, hdr_len, 3);
7099         is_iv_bad = weak_iv(iv_buff);
7100         if (is_iv_bad != -1) {
7101           proto_tree_add_boolean_format (wep_tree, hf_wep_iv_weak,
7102               tvb, 0, 0, TRUE,
7103               "Weak IV for key byte %d",
7104               is_iv_bad);
7105         }
7106       }
7107       if (tree)
7108         proto_tree_add_uint (wep_tree, hf_wep_key, tvb, hdr_len + 3, 1, key);
7109
7110       /* Subtract out the length of the IV. */
7111       len -= 4;
7112       reported_len -= 4;
7113       ivlen = 4;
7114
7115       /* Davide Schiera (2006-11-27): Even if the decryption was not */
7116       /* successful, set the algorithm                               */
7117       algorithm=PROTECTION_ALG_WEP;
7118
7119       /*
7120        * Well, this packet should, in theory, have an ICV.
7121        * Do we have the entire packet, and does it have enough data for
7122        * the ICV?
7123        */
7124       if (reported_len < 4) {
7125         /*
7126          * The packet is claimed not to even have enough data for a
7127          * 4-byte ICV.
7128          * Pretend it doesn't have an ICV.
7129          */
7130         ;
7131       } else if (len < reported_len) {
7132         /*
7133          * The packet is claimed to have enough data for a 4-byte ICV,
7134          * but we didn't capture all of the packet.
7135          * Slice off the 4-byte ICV from the reported length, and trim
7136          * the captured length so it's no more than the reported length;
7137          * that will slice off what of the ICV, if any, is in the
7138          * captured length.
7139          */
7140         reported_len -= 4;
7141         if (len > reported_len)
7142           len = reported_len;
7143       } else {
7144         /*
7145          * We have the entire packet, and it includes a 4-byte ICV.
7146          * Slice it off, and put it into the tree.
7147          *
7148          * We only support decrypting if we have the the ICV.
7149          *
7150          * XXX - the ICV is encrypted; we're putting the encrypted
7151          * value, not the decrypted value, into the tree.
7152          */
7153         len -= 4;
7154         reported_len -= 4;
7155         can_decrypt = TRUE;
7156       }
7157     }
7158
7159     if (algorithm == PROTECTION_ALG_WEP) {
7160       g_strlcpy (wlan_stats.protection, "WEP", MAX_PROTECT_LEN);
7161     } else if (algorithm == PROTECTION_ALG_TKIP) {
7162       g_strlcpy (wlan_stats.protection, "TKIP", MAX_PROTECT_LEN);
7163     } else if (algorithm == PROTECTION_ALG_CCMP) {
7164       g_strlcpy (wlan_stats.protection, "CCMP", MAX_PROTECT_LEN);
7165     } else {
7166       g_strlcpy (wlan_stats.protection, "Unknown", MAX_PROTECT_LEN);
7167     }
7168
7169 #ifndef HAVE_AIRPDCAP
7170     if (can_decrypt)
7171       next_tvb = try_decrypt_wep(tvb, hdr_len, reported_len + 8);
7172 #else
7173     /* Davide Schiera (2006-11-26): decrypted before parsing header and    */
7174     /* protection header                                  */
7175 #endif
7176     if (!can_decrypt || next_tvb == NULL) {
7177       /*
7178        * WEP decode impossible or failed, treat payload as raw data
7179        * and don't attempt fragment reassembly or further dissection.
7180        */
7181       next_tvb = tvb_new_subset(tvb, hdr_len + ivlen, len, reported_len);
7182
7183       if (tree) {
7184         /* Davide Schiera (2006-11-21): added WEP or WPA separation      */
7185         if (algorithm==PROTECTION_ALG_WEP) {
7186           if (can_decrypt)
7187             proto_tree_add_uint_format (wep_tree, hf_wep_icv, tvb,
7188                 hdr_len + ivlen + len, 4,
7189                 tvb_get_ntohl(tvb, hdr_len + ivlen + len),
7190                 "WEP ICV: 0x%08x (not verified)",
7191                 tvb_get_ntohl(tvb, hdr_len + ivlen + len));
7192         } else if (algorithm==PROTECTION_ALG_CCMP) {
7193         } else if (algorithm==PROTECTION_ALG_TKIP) {
7194         }
7195       }
7196       /* Davide Schiera (2006-11-21) ----------------------------------  */
7197
7198       if (pinfo->ethertype != ETHERTYPE_CENTRINO_PROMISC && wlan_ignore_wep == WLAN_IGNORE_WEP_NO) {
7199         /* Some wireless drivers (such as Centrino) WEP payload already decrypted */
7200         call_dissector(data_handle, next_tvb, pinfo, tree);
7201         goto end_of_wlan;
7202       }
7203     } else {
7204       /* Davide Schiera (2006-11-21): added WEP or WPA separation        */
7205       if (algorithm==PROTECTION_ALG_WEP) {
7206         if (tree)
7207           proto_tree_add_uint_format (wep_tree, hf_wep_icv, tvb,
7208               hdr_len + ivlen + len, 4,
7209               tvb_get_ntohl(tvb, hdr_len + ivlen + len),
7210               "WEP ICV: 0x%08x (correct)",
7211               tvb_get_ntohl(tvb, hdr_len + ivlen + len));
7212
7213         add_new_data_source(pinfo, next_tvb, "Decrypted WEP data");
7214       } else if (algorithm==PROTECTION_ALG_CCMP) {
7215         add_new_data_source(pinfo, next_tvb, "Decrypted CCMP data");
7216       } else if (algorithm==PROTECTION_ALG_TKIP) {
7217         add_new_data_source(pinfo, next_tvb, "Decrypted TKIP data");
7218       }
7219       /* Davide Schiera (2006-11-21) -------------------------------------  */
7220       /* Davide Schiera (2006-11-27): undefine macros and definitions  */
7221 #undef IS_TKIP
7222 #undef IS_CCMP
7223 #undef PROTECTION_ALG_CCMP
7224 #undef PROTECTION_ALG_TKIP
7225 #undef PROTECTION_ALG_WEP
7226       /* Davide Schiera --------------------------------------------------  */
7227     }
7228
7229     /*
7230      * WEP decryption successful!
7231      *
7232      * Use the tvbuff we got back from the decryption; the data starts at
7233      * the beginning.  The lengths are already correct for the decoded WEP
7234      * payload.
7235      */
7236     hdr_len = 0;
7237
7238   } else {
7239     /*
7240      * Not a WEP-encrypted frame; just use the data from the tvbuff
7241      * handed to us.
7242      *
7243      * The payload starts at "hdr_len" (i.e., just past the 802.11
7244      * MAC header), the length of data in the tvbuff following the
7245      * 802.11 header is "len", and the length of data in the packet
7246      * following the 802.11 header is "reported_len".
7247      */
7248     next_tvb = tvb;
7249   }
7250
7251   /*
7252    * Do defragmentation if "wlan_defragment" is true, and we have more
7253    * fragments or this isn't the first fragment.
7254    *
7255    * We have to do some special handling to catch frames that
7256    * have the "More Fragments" indicator not set but that
7257    * don't show up as reassembled and don't have any other
7258    * fragments present.  Some networking interfaces appear
7259    * to do reassembly even when you're capturing raw packets
7260    * *and* show the reassembled packet without the "More
7261    * Fragments" indicator set *but* with a non-zero fragment
7262    * number.
7263    *
7264    * "fragment_add_seq_802_11()" handles that; we want to call it
7265    * even if we have a short frame, so that it does those checks - if
7266    * the frame is short, it doesn't do reassembly on it.
7267    *
7268    * (This could get some false positives if we really *did* only
7269    * capture the last fragment of a fragmented packet, but that's
7270    * life.)
7271    */
7272   save_fragmented = pinfo->fragmented;
7273   if (wlan_defragment && (more_frags || frag_number != 0)) {
7274     fragment_data *fd_head;
7275
7276     /*
7277      * If we've already seen this frame, look it up in the
7278      * table of reassembled packets, otherwise add it to
7279      * whatever reassembly is in progress, if any, and see
7280      * if it's done.
7281      */
7282     if (reported_len < 0)
7283       THROW(ReportedBoundsError);
7284     fd_head = fragment_add_seq_802_11(next_tvb, hdr_len, pinfo, seq_number,
7285         wlan_fragment_table,
7286         wlan_reassembled_table,
7287         frag_number,
7288         reported_len,
7289         more_frags);
7290     next_tvb = process_reassembled_data(tvb, hdr_len, pinfo,
7291         "Reassembled 802.11", fd_head,
7292         &frag_items, NULL, hdr_tree);
7293   } else {
7294     /*
7295      * If this is the first fragment, dissect its contents, otherwise
7296      * just show it as a fragment.
7297      */
7298     if (frag_number != 0) {
7299       /* Not the first fragment - don't dissect it. */
7300       next_tvb = NULL;
7301     } else {
7302       /* First fragment, or not fragmented.  Dissect what we have here. */
7303
7304       /* Get a tvbuff for the payload. */
7305       next_tvb = tvb_new_subset (next_tvb, hdr_len, len, reported_len);
7306
7307       /*
7308        * If this is the first fragment, but not the only fragment,
7309        * tell the next protocol that.
7310        */
7311       if (more_frags)
7312         pinfo->fragmented = TRUE;
7313       else
7314         pinfo->fragmented = FALSE;
7315     }
7316   }
7317
7318   if (next_tvb == NULL) {
7319     /* Just show this as an incomplete fragment. */
7320     if (check_col(pinfo->cinfo, COL_INFO))
7321       col_set_str(pinfo->cinfo, COL_INFO, "Fragmented IEEE 802.11 frame");
7322     next_tvb = tvb_new_subset (tvb, hdr_len, len, reported_len);
7323     call_dissector(data_handle, next_tvb, pinfo, tree);
7324     pinfo->fragmented = save_fragmented;
7325     goto end_of_wlan;
7326   }
7327
7328   switch (FCF_FRAME_TYPE (fcf))
7329     {
7330
7331     case MGT_FRAME:
7332       dissect_ieee80211_mgt (fcf, next_tvb, pinfo, tree);
7333       break;
7334
7335     case DATA_FRAME:
7336       if (is_amsdu && tvb_reported_length_remaining(next_tvb, 0) > 4){
7337         tvbuff_t *volatile msdu_tvb = NULL;
7338         guint32 msdu_offset = 0;
7339         guint16 i = 1;
7340         const guint8 *src = NULL;
7341         const guint8 *dst = NULL;
7342         guint16 msdu_length;
7343         proto_item *parent_item;
7344         proto_tree *mpdu_tree;
7345         proto_tree *subframe_tree;
7346
7347         parent_item = proto_tree_add_protocol_format(tree, proto_aggregate, next_tvb, 0,
7348                                     tvb_reported_length_remaining(next_tvb, 0), "IEEE 802.11 Aggregate MSDU");
7349         mpdu_tree = proto_item_add_subtree(parent_item, ett_msdu_aggregation_parent_tree);
7350
7351         do {
7352           dst = tvb_get_ptr (next_tvb, msdu_offset, 6);
7353           src = tvb_get_ptr (next_tvb, msdu_offset+6, 6);
7354           msdu_length = tvb_get_ntohs (next_tvb, msdu_offset+12);
7355
7356           parent_item = proto_tree_add_uint_format(mpdu_tree, amsdu_msdu_header_text, next_tvb,
7357                             msdu_offset, roundup2(msdu_offset+14+msdu_length, 4),
7358                             i, "A-MSDU Subframe #%u", i);
7359           subframe_tree = proto_item_add_subtree(parent_item, ett_msdu_aggregation_subframe_tree);
7360           i++;
7361
7362           proto_tree_add_ether(subframe_tree, hf_addr_da, next_tvb, msdu_offset, 6, dst);
7363           proto_tree_add_ether(subframe_tree, hf_addr_sa, next_tvb, msdu_offset+6, 6, src);
7364           proto_tree_add_uint_format(subframe_tree, mcsset_highest_data_rate, next_tvb, msdu_offset+12, 2,
7365           msdu_length, "MSDU length: 0x%04X", msdu_length);
7366
7367           msdu_offset += 14;
7368           msdu_tvb = tvb_new_subset(next_tvb, msdu_offset, msdu_length, -1);
7369           call_dissector(llc_handle, msdu_tvb, pinfo, subframe_tree);
7370           msdu_offset = roundup2(msdu_offset+msdu_length, 4);
7371         } while (tvb_reported_length_remaining(next_tvb, msdu_offset) > 14);
7372
7373         break;
7374       }
7375       /* I guess some bridges take Netware Ethernet_802_3 frames,
7376          which are 802.3 frames (with a length field rather than
7377          a type field, but with no 802.2 header in the payload),
7378          and just stick the payload into an 802.11 frame.  I've seen
7379          captures that show frames of that sort.
7380
7381          We also handle some odd form of encapsulation in which a
7382          complete Ethernet frame is encapsulated within an 802.11
7383          data frame, with no 802.2 header.  This has been seen
7384          from some hardware.
7385
7386          So, if the packet doesn't start with 0xaa 0xaa:
7387
7388            we first use the same scheme that linux-wlan-ng does to detect
7389            those encapsulated Ethernet frames, namely looking to see whether
7390            the frame either starts with 6 octets that match the destination
7391            address from the 802.11 header or has 6 octets that match the
7392            source address from the 802.11 header following the first 6 octets,
7393            and, if so, treat it as an encapsulated Ethernet frame;
7394
7395            otherwise, we use the same scheme that we use in the Ethernet
7396            dissector to recognize Netware 802.3 frames, namely checking
7397            whether the packet starts with 0xff 0xff and, if so, treat it
7398            as an encapsulated IPX frame. */
7399       encap_type = ENCAP_802_2;
7400       TRY {
7401         octet1 = tvb_get_guint8(next_tvb, 0);
7402         octet2 = tvb_get_guint8(next_tvb, 1);
7403         if (octet1 != 0xaa || octet2 != 0xaa) {
7404           src = tvb_get_ptr (next_tvb, 6, 6);
7405           dst = tvb_get_ptr (next_tvb, 0, 6);
7406           if (memcmp(src, pinfo->dl_src.data, 6) == 0 ||
7407               memcmp(dst, pinfo->dl_dst.data, 6) == 0)
7408             encap_type = ENCAP_ETHERNET;
7409           else if (octet1 == 0xff && octet2 == 0xff)
7410             encap_type = ENCAP_IPX;
7411         }
7412       }
7413       CATCH2(BoundsError, ReportedBoundsError) {
7414       ; /* do nothing */
7415
7416       }
7417       ENDTRY;
7418
7419       switch (encap_type) {
7420
7421       case ENCAP_802_2:
7422         call_dissector(llc_handle, next_tvb, pinfo, tree);
7423         break;
7424
7425       case ENCAP_ETHERNET:
7426         call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
7427         break;
7428
7429       case ENCAP_IPX:
7430         call_dissector(ipx_handle, next_tvb, pinfo, tree);
7431         break;
7432       }
7433       break;
7434     }
7435   pinfo->fragmented = save_fragmented;
7436
7437   end_of_wlan:
7438   whdr->stats = wlan_stats;
7439   tap_queue_packet(wlan_tap, pinfo, whdr);
7440   memset (&wlan_stats, 0, sizeof wlan_stats);
7441 }
7442
7443 /*
7444  * Dissect 802.11 with a variable-length link-layer header.
7445  */
7446 static void
7447 dissect_ieee80211 (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7448 {
7449   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7450       pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, FALSE, FALSE);
7451 }
7452
7453 /*
7454  * Dissect 802.11 with a variable-length link-layer header and data padding.
7455  */
7456 static void
7457 dissect_ieee80211_datapad (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7458 {
7459   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7460       pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, TRUE, FALSE);
7461 }
7462
7463 /*
7464  * Dissect 802.11 with a variable-length link-layer header and a pseudo-
7465  * header containing radio information.
7466  */
7467 static void
7468 dissect_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7469 {
7470   proto_item *ti = NULL;
7471   proto_tree *radio_tree = NULL;
7472
7473   if (check_col(pinfo->cinfo, COL_PROTOCOL))
7474       col_set_str(pinfo->cinfo, COL_PROTOCOL, "Radio");
7475   if (check_col(pinfo->cinfo, COL_INFO))
7476       col_clear(pinfo->cinfo, COL_INFO);
7477
7478   /* Add the radio information to the column information */
7479   if (check_col(pinfo->cinfo, COL_TX_RATE)) {
7480     col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
7481         pinfo->pseudo_header->ieee_802_11.data_rate / 2,
7482         pinfo->pseudo_header->ieee_802_11.data_rate & 1 ? 5 : 0);
7483   }
7484   if (check_col(pinfo->cinfo, COL_RSSI)) {
7485     /* XX - this is a percentage, not a dBm or normalized or raw RSSI */
7486     col_add_fstr(pinfo->cinfo, COL_RSSI, "%u",
7487         pinfo->pseudo_header->ieee_802_11.signal_level);
7488   }
7489
7490   if (tree) {
7491     ti = proto_tree_add_item(tree, proto_radio, tvb, 0, 0, FALSE);
7492     radio_tree = proto_item_add_subtree (ti, ett_radio);
7493
7494     proto_tree_add_uint64_format(radio_tree, hf_data_rate, tvb, 0, 0,
7495              (guint64)pinfo->pseudo_header->ieee_802_11.data_rate * 500000,
7496              "Data Rate: %u.%u Mb/s",
7497              pinfo->pseudo_header->ieee_802_11.data_rate / 2,
7498              pinfo->pseudo_header->ieee_802_11.data_rate & 1 ? 5 : 0);
7499
7500     proto_tree_add_uint(radio_tree, hf_channel, tvb, 0, 0,
7501             pinfo->pseudo_header->ieee_802_11.channel);
7502
7503     proto_tree_add_uint_format(radio_tree, hf_signal_strength, tvb, 0, 0,
7504             pinfo->pseudo_header->ieee_802_11.signal_level,
7505             "Signal Strength: %u%%",
7506             pinfo->pseudo_header->ieee_802_11.signal_level);
7507   }
7508
7509   pinfo->current_proto = "IEEE 802.11";
7510   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7511      pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, FALSE, FALSE);
7512 }
7513
7514 /*
7515  * Dissect 802.11 with a variable-length link-layer header and a byte-swapped
7516  * control field (some hardware sends out LWAPP-encapsulated 802.11
7517  * packets with the control field byte swapped).
7518  */
7519 static void
7520 dissect_ieee80211_bsfc (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7521 {
7522   dissect_ieee80211_common (tvb, pinfo, tree, FALSE, 0, TRUE, FALSE, FALSE);
7523 }
7524
7525 /*
7526  * Dissect 802.11 with a fixed-length link-layer header (padded to the
7527  * maximum length).
7528  */
7529 static void
7530 dissect_ieee80211_fixed (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7531 {
7532   dissect_ieee80211_common (tvb, pinfo, tree, TRUE, 0, FALSE, FALSE, FALSE);
7533 }
7534
7535 /*
7536  * Dissect an HT 802.11 frame with a variable-length link-layer header.
7537  * XXX - Can we tell if a frame is +HTC just by looking at the MAC header?
7538  * If so, we can dispense with this.
7539  */
7540 static void
7541 dissect_ieee80211_ht (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7542 {
7543   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7544       pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, FALSE, TRUE);
7545 }
7546
7547 static void
7548 wlan_defragment_init(void)
7549 {
7550   fragment_table_init(&wlan_fragment_table);
7551   reassembled_table_init(&wlan_reassembled_table);
7552 }
7553
7554 /* ------------- */
7555 static gboolean
7556 free_all(gpointer key_arg _U_, gpointer value _U_, gpointer user_data _U_)
7557 {
7558   return TRUE;
7559 }
7560
7561 static guint
7562 retransmit_hash(gconstpointer k)
7563 {
7564         const retransmit_key *key = (const retransmit_key *)k;
7565         guint hash_val;
7566         int i;
7567
7568         hash_val = 0;
7569         for (i = 0; i < 6; i++)
7570                 hash_val += key->bssid[i];
7571
7572         for (i = 0; i < 6; i++)
7573                 hash_val += key->src[i];
7574
7575         return hash_val;
7576 }
7577
7578 static gint
7579 retransmit_equal(gconstpointer k1, gconstpointer k2)
7580 {
7581   const retransmit_key *key1 = (const retransmit_key *)k1;
7582   const retransmit_key *key2 = (const retransmit_key *)k2;
7583
7584   return ( (!memcmp(key1->bssid, key2->bssid, 6) && !memcmp( key1->src, key2->src, 6))? TRUE:FALSE);
7585 }
7586
7587 static guint
7588 frame_hash(gconstpointer k)
7589 {
7590   guint32 frame = GPOINTER_TO_UINT(k);
7591
7592   return frame;
7593 }
7594
7595 static gint
7596 frame_equal(gconstpointer k1, gconstpointer k2)
7597 {
7598   guint32 frame1 = GPOINTER_TO_UINT(k1);
7599   guint32 frame2 = GPOINTER_TO_UINT(k2);
7600
7601   return frame1==frame2;
7602 }
7603
7604 static void
7605 wlan_retransmit_init(void)
7606 {
7607   if ( fc_analyse_retransmit_table ){
7608       g_hash_table_foreach_remove(fc_analyse_retransmit_table,free_all, NULL);
7609       g_hash_table_destroy(fc_analyse_retransmit_table);
7610       fc_analyse_retransmit_table = NULL;
7611   }
7612
7613   if( fc_first_frame_table ){
7614       g_hash_table_foreach_remove(fc_first_frame_table,free_all, NULL);
7615       g_hash_table_destroy(fc_first_frame_table);
7616       fc_first_frame_table = NULL;
7617   }
7618
7619   if (wlan_subdissector)
7620       return;
7621
7622   fc_analyse_retransmit_table= g_hash_table_new(retransmit_hash, retransmit_equal);
7623   fc_first_frame_table = g_hash_table_new( frame_hash, frame_equal);
7624
7625 }
7626
7627 /* ------------- */
7628
7629 /*
7630  * yah, I know, macros, ugh, but it makes the code
7631  * below more readable
7632  * XXX - This should be rewritten to use ptvcursors, then.
7633  */
7634 #define FIELD_PRESENT(name)     (hdr.name.status == 0 && hdr.name.did != 0)
7635 #define IFHELP(size, name, var, str) \
7636         if(tree) {                                                \
7637             proto_tree_add_uint_format(prism_tree, hf_prism_ ## name, \
7638                 tvb, offset, size, hdr.var, str, hdr.var);                \
7639         }                                                                 \
7640         offset += (size)
7641 #define INTFIELD(size, name, str)       IFHELP(size, name, name, str)
7642 #define VALFIELD(name, str) \
7643         if (FIELD_PRESENT(name)) {                                      \
7644             if(tree) {                                                  \
7645                 proto_tree_add_uint_format(prism_tree, hf_ ## name,     \
7646                     tvb, offset, 12, hdr.name.data,                     \
7647                     str ": 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",  \
7648                     hdr.name.data, hdr.name.did,                        \
7649                     hdr.name.status, hdr.name.len);                     \
7650             }                                                           \
7651         }                                                               \
7652         offset += 12
7653 #define VALFIELD_PRISM(name, str) \
7654         if (FIELD_PRESENT(name)) {                                      \
7655             if(tree) {                                            \
7656                 proto_tree_add_uint_format(prism_tree, hf_prism_ ## name ## _data, \
7657                     tvb, offset, 12, hdr.name.data,                        \
7658                     str ": 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",     \
7659                     hdr.name.data, hdr.name.did,                           \
7660                     hdr.name.status, hdr.name.len);                        \
7661             }                                                              \
7662         }                                                                  \
7663         offset += 12
7664
7665 static void
7666 dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
7667 {
7668     struct prism_hdr hdr;
7669     proto_tree *prism_tree = NULL;
7670     proto_item *ti;
7671     tvbuff_t *next_tvb;
7672     int offset;
7673     guint32 msgcode;
7674
7675     offset = 0;
7676
7677     /* handle the new capture type. */
7678     msgcode = tvb_get_ntohl(tvb, offset);
7679     if ((msgcode == WLANCAP_MAGIC_COOKIE_V1) ||
7680         (msgcode == WLANCAP_MAGIC_COOKIE_V2)) {
7681             call_dissector(wlancap_handle, tvb, pinfo, tree);
7682             return;
7683     }
7684
7685     tvb_memcpy(tvb, (guint8 *)&hdr, offset, sizeof(hdr));
7686
7687     if(check_col(pinfo->cinfo, COL_PROTOCOL))
7688         col_set_str(pinfo->cinfo, COL_PROTOCOL, "Prism");
7689     if(check_col(pinfo->cinfo, COL_INFO))
7690         col_clear(pinfo->cinfo, COL_INFO);
7691
7692     if(check_col(pinfo->cinfo, COL_INFO))
7693         col_add_fstr(pinfo->cinfo, COL_INFO, "Device: %.16s  "
7694                      "Message 0x%x, Length %d", hdr.devname,
7695                      hdr.msgcode, hdr.msglen);
7696
7697     if(tree) {
7698         ti = proto_tree_add_item(tree, proto_prism, tvb, 0, sizeof hdr, FALSE);
7699         prism_tree = proto_item_add_subtree(ti, ett_radio);
7700     }
7701
7702     INTFIELD(4, msgcode, "Message Code: %d");
7703     INTFIELD(4, msglen, "Message Length: %d");
7704     if(tree) {
7705         proto_tree_add_text(prism_tree, tvb, offset, sizeof hdr.devname,
7706             "Device: %s", hdr.devname);
7707     }
7708     offset += sizeof hdr.devname;
7709
7710     if (FIELD_PRESENT(hosttime)) {
7711       if(tree) {
7712         proto_tree_add_uint64_format(prism_tree, hf_hosttime,
7713             tvb, offset, 12, hdr.hosttime.data,
7714             "Host timestamp: 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",
7715             hdr.hosttime.data, hdr.hosttime.did,
7716             hdr.hosttime.status, hdr.hosttime.len);
7717       }
7718     }
7719     offset += 12;
7720     if (FIELD_PRESENT(mactime)) {
7721       if(tree) {
7722         proto_tree_add_uint64_format(prism_tree, hf_mactime,
7723             tvb, offset, 12, hdr.mactime.data,
7724             "MAC timestamp: 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",
7725             hdr.mactime.data, hdr.mactime.did,
7726             hdr.mactime.status, hdr.mactime.len);
7727       }
7728     }
7729     offset += 12;
7730     if (FIELD_PRESENT(channel)) {
7731       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
7732         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u", hdr.channel.data);
7733     }
7734     VALFIELD(channel, "Channel");
7735     if (FIELD_PRESENT(rssi)) {
7736       if (check_col(pinfo->cinfo, COL_RSSI))
7737         col_add_fstr(pinfo->cinfo, COL_RSSI, "%d", hdr.rssi.data);
7738       if (tree) {
7739         proto_tree_add_uint_format(prism_tree, hf_prism_rssi_data,
7740             tvb, offset, 12, hdr.rssi.data,
7741             "RSSI: 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",
7742             hdr.rssi.data, hdr.rssi.did, hdr.rssi.status, hdr.rssi.len);
7743       }
7744     }
7745     offset += 12;
7746     VALFIELD_PRISM(sq, "SQ");
7747     VALFIELD_PRISM(signal, "Signal");
7748     VALFIELD_PRISM(noise, "Noise");
7749     if (FIELD_PRESENT(rate)) {
7750       if (check_col(pinfo->cinfo, COL_TX_RATE)) {
7751         col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
7752                   hdr.rate.data / 2, hdr.rate.data & 1 ? 5 : 0);
7753       }
7754       if (tree) {
7755           proto_tree_add_uint64_format(prism_tree, hf_data_rate,
7756                   tvb, offset, 12, (guint64)hdr.rate.data * 500000,
7757                   "Data Rate: %u.%u Mb/s",
7758                   hdr.rate.data / 2, hdr.rate.data & 1 ? 5 : 0);
7759       }
7760     }
7761     offset += 12;
7762     VALFIELD_PRISM(istx, "IsTX");
7763     VALFIELD_PRISM(frmlen, "Frame Length");
7764
7765     /* dissect the 802.11 header next */
7766     next_tvb = tvb_new_subset(tvb, sizeof hdr, -1, -1);
7767     call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
7768 }
7769
7770 /*
7771  * AVS linux-wlan-based products use a new sniff header to replace the
7772  * old Prism header.  This one has additional fields, is designed to be
7773  * non-hardware-specific, and more importantly, version and length fields
7774  * so it can be extended later without breaking anything.
7775  *
7776  * Support by Solomon Peachy
7777  *
7778  * Description, from the capturefrm.txt file in the linux-wlan-ng 0.2.9
7779  * release (linux-wlan-ng-0.2.9/doc/capturefrm.txt):
7780  *
7781 AVS Capture Frame Format
7782 Version 2.1.1
7783
7784 1. Introduction
7785 The original header format for "monitor mode" or capturing frames was
7786 a considerable hack.  The document covers a redesign of that format.
7787
7788   Any questions, corrections, or proposed changes go to info@linux-wlan.com
7789
7790 2. Frame Format
7791 All sniff frames follow the same format:
7792
7793         Offset  Name            Size            Description
7794         --------------------------------------------------------------------
7795         0       CaptureHeader                   AVS capture metadata header
7796         64      802.11Header    [10-30]         802.11 frame header
7797         ??      802.11Payload   [0-2312]        802.11 frame payload
7798         ??      802.11FCS       4               802.11 frame check sequence
7799
7800 Note that the header and payload are variable length and the payload
7801 may be empty.
7802
7803 If the hardware does not supply the FCS to the driver, then the frame shall
7804 have a FCS of 0xFFFFFFFF.
7805
7806 3. Byte Order
7807 All multibyte fields of the capture header are in "network" byte
7808 order.  The "host to network" and "network to host" functions should
7809 work just fine.  All the remaining multibyte fields are ordered
7810 according to their respective standards.
7811
7812 4. Capture Header Format
7813 The following fields make up the AVS capture header:
7814
7815         Offset  Name            Type
7816         ------------------------------
7817         0       version         uint32
7818         4       length          uint32
7819         8       mactime         uint64
7820         16      hosttime        uint64
7821         24      phytype         uint32
7822         28      frequency       uint32
7823         32      datarate        uint32
7824         36      antenna         uint32
7825         40      priority        uint32
7826         44      ssi_type        uint32
7827         48      ssi_signal      int32
7828         52      ssi_noise       int32
7829         56      preamble        uint32
7830         60      encoding        uint32
7831         64      sequence        uint32
7832         68      drops           uint32
7833         72      receiver_addr   uint8[6]
7834         78      padding         uint8[2]
7835         ------------------------------
7836         80
7837
7838 The following subsections detail the fields of the capture header.
7839
7840 4.1 version
7841 The version field identifies this type of frame as a subtype of
7842 ETH_P_802111_CAPTURE as received by an ARPHRD_IEEE80211_PRISM or
7843 an ARPHRD_IEEE80211_CAPTURE device.  The value of this field shall be
7844 0x80211002.  As new revisions of this header are necessary, we can
7845 increment the version appropriately.
7846
7847 4.2 length
7848 The length field contains the length of the entire AVS capture header,
7849 in bytes.
7850
7851 4.3 mactime
7852 Many WLAN devices supply a relatively high resolution frame reception
7853 time value.  This field contains the value supplied by the device.  If
7854 the device does not supply a receive time value, this field shall be
7855 set to zero.  The units for this field are microseconds.  
7856
7857 If possible, this time value should be absolute, representing the number
7858 of microseconds elapsed since the UNIX epoch.
7859
7860 4.4 hosttime
7861 The hosttime field is set to the current value of the host maintained
7862 clock variable when the frame is received by the host. 
7863
7864 If possible, this time value should be absolute, representing the number 
7865 of microseconds elapsed since the UNIX epoch.
7866
7867 4.5 phytype
7868 The phytype field identifies what type of PHY is employed by the WLAN 
7869 device used to capture this frame.  The valid values are:
7870
7871         PhyType                         Value
7872         -------------------------------------
7873         phytype_fhss_dot11_97            1
7874         phytype_dsss_dot11_97            2
7875         phytype_irbaseband               3
7876         phytype_dsss_dot11_b             4
7877         phytype_pbcc_dot11_b             5
7878         phytype_ofdm_dot11_g             6
7879         phytype_pbcc_dot11_g             7
7880         phytype_ofdm_dot11_a             8
7881         phytype_dss_ofdm_dot11_g         9
7882
7883 4.6 frequency
7884
7885 This represents the frequency or channel number of the receiver at the 
7886 time the frame was received.  It is interpreted as follows:
7887
7888 For frequency hopping radios, this field is broken in to the 
7889 following subfields:
7890
7891         Byte    Subfield
7892         ------------------------
7893         Byte0   Hop Set
7894         Byte1   Hop Pattern
7895         Byte2   Hop Index
7896         Byte3   reserved
7897
7898 For non-hopping radios, the frequency is interpreted as follows:
7899
7900        Value                Meaning
7901     -----------------------------------------
7902        < 256           Channel number (using externally-defined
7903                          channelization)
7904        < 10000         Center frequency, in MHz
7905       >= 10000         Center frequency, in KHz
7906
7907 4.7 datarate
7908 The data rate field contains the rate at which the frame was received
7909 in units of 100kbps.
7910
7911 4.8 antenna
7912 For WLAN devices that indicate the receive antenna for each frame, the
7913 antenna field shall contain an index value into the dot11AntennaList.
7914 If the device does not indicate a receive antenna value, this field
7915 shall be set to zero.
7916
7917 4.9 priority
7918 The priority field indicates the receive priority of the frame.  The
7919 value is in the range [0-15] with the value 0 reserved to indicate
7920 contention period and the value 6 reserved to indicate contention free
7921 period.
7922
7923 4.10 ssi_type
7924 The ssi_type field is used to indicate what type of signal strength
7925 information is present: "None", "Normalized RSSI" or "dBm".  "None"
7926 indicates that the underlying WLAN device does not supply any signal
7927 strength at all and the ssi_* values are unset.  "Normalized RSSI"
7928 values are integers in the range [0-1000] where higher numbers
7929 indicate stronger signal.  "dBm" values indicate an actual signal 
7930 strength measurement quantity and are usually in the range [-108 - 10].
7931 The following values indicate the three types:
7932
7933         Value   Description
7934         ---------------------------------------------
7935         0       None
7936         1       Normalized RSSI
7937         2       dBm
7938         3       Raw RSSI
7939
7940 4.11 ssi_signal
7941 The ssi_signal field contains the signal strength value reported by
7942 the WLAN device for this frame.  Note that this is a signed quantity
7943 and if the ssi_type value is "dBm" that the value may be negative.
7944
7945 4.12 ssi_noise
7946 The ssi_noise field contains the noise or "silence" value reported by
7947 the WLAN device.  This value is commonly defined to be the "signal
7948 strength reported immediately prior to the baseband processor lock on
7949 the frame preamble".  If the hardware does not provide noise data, this
7950 shall equal 0xffffffff.
7951
7952 4.12 preamble
7953 For PHYs that support variable preamble lengths, the preamble field
7954 indicates the preamble type used for this frame.  The values are:
7955
7956         Value   Description
7957         ---------------------------------------------
7958         0       Undefined
7959         1       Short Preamble
7960         2       Long Preamble
7961
7962 4.13 encoding
7963 This specifies the encoding of the received packet.  For PHYs that support
7964 multiple encoding types, this will tell us which one was used.
7965
7966         Value   Description
7967         ---------------------------------------------
7968         0       Unknown
7969         1       CCK           
7970         2       PBCC
7971         3       OFDM
7972         4       DSSS-OFDM
7973         5       BPSK
7974         6       QPSK
7975         7       16QAM
7976         8       64QAM
7977
7978 4.14 sequence
7979 This is a receive frame sequence counter.  The sniff host shall 
7980 increment this by one for every valid frame received off the medium.
7981 By watching for gaps in the sequence numbers we can determine when 
7982 packets are lost due to unreliable transport, rather than a frame never 
7983 being received to begin with.
7984
7985 4.15 drops
7986 This is a counter of the number of known frame drops that occured.  This 
7987 is particularly useful when the system or hardware cannot keep up with 
7988 the sniffer load.
7989
7990 4.16 receiver_addr
7991 This specifies the MAC address of the receiver of this frame.  
7992 It is six octets in length.  This field is followed by two octets of 
7993 padding to keep the structure 32-bit word aligned.
7994
7995 ================================
7996
7997 Changes: v2->v2.1
7998
7999  * Added contact e-mail address to introduction
8000  * Added sniffer_addr, drop count, and sequence fields, bringing total 
8001    length to 80 bytes
8002  * Bumped version to 0x80211002
8003  * Mactime is specified in microseconds, not nanoseconds
8004  * Added 64QAM, 16QAM, BPSK, QPSK encodings
8005
8006 ================================
8007
8008 Changes: v2.1->v2.1.1
8009
8010  * Renamed 'channel' to 'frequency'
8011  * Clarified the interpretation of the frequency/channel field.
8012  * Renamed 'sniffer address' to 'receiver address'
8013  * Clarified timestamp fields.
8014  */
8015
8016 /*
8017  * Signal/noise strength type values.
8018  */
8019 #define SSI_NONE        0       /* no SSI information */
8020 #define SSI_NORM_RSSI   1       /* normalized RSSI - 0-1000 */
8021 #define SSI_DBM         2       /* dBm */
8022 #define SSI_RAW_RSSI    3       /* raw RSSI from the hardware */
8023
8024 static void
8025 dissect_wlancap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
8026 {
8027     proto_tree *wlan_tree = NULL;
8028     proto_item *ti;
8029     tvbuff_t *next_tvb;
8030     int offset;
8031     guint32 version;
8032     guint32 length;
8033     guint32 channel;
8034     guint32 datarate;
8035     guint32 ssi_type;
8036     guint32 antnoise;
8037
8038     if(check_col(pinfo->cinfo, COL_PROTOCOL))
8039         col_set_str(pinfo->cinfo, COL_PROTOCOL, "WLAN");
8040     if(check_col(pinfo->cinfo, COL_INFO))
8041         col_clear(pinfo->cinfo, COL_INFO);
8042     offset = 0;
8043
8044     version = tvb_get_ntohl(tvb, offset) - WLANCAP_MAGIC_COOKIE_BASE;
8045
8046     length = tvb_get_ntohl(tvb, offset+4);
8047
8048     if(check_col(pinfo->cinfo, COL_INFO))
8049         col_add_fstr(pinfo->cinfo, COL_INFO, "AVS WLAN Capture v%x, Length %d",version, length);
8050
8051     if (version > 2) {
8052       goto skip;
8053     }
8054
8055     /* Dissect the AVS header */
8056     if (tree) {
8057       ti = proto_tree_add_item(tree, proto_wlancap, tvb, 0, length, FALSE);
8058       wlan_tree = proto_item_add_subtree(ti, ett_radio);
8059       proto_tree_add_item(wlan_tree, hf_wlan_magic, tvb, offset, 4, FALSE);
8060       proto_tree_add_item(wlan_tree, hf_wlan_version, tvb, offset, 4, FALSE);
8061     }
8062     offset+=4;
8063     if (tree)
8064       proto_tree_add_item(wlan_tree, hf_wlan_length, tvb, offset, 4, FALSE);
8065     offset+=4;
8066     if (tree)
8067       proto_tree_add_item(wlan_tree, hf_mactime, tvb, offset, 8, FALSE);
8068     offset+=8;
8069     if (tree)
8070       proto_tree_add_item(wlan_tree, hf_hosttime, tvb, offset, 8, FALSE);
8071     offset+=8;
8072     if (tree)
8073       proto_tree_add_item(wlan_tree, hf_wlan_phytype, tvb, offset, 4, FALSE);
8074     offset+=4;
8075
8076     /* XXX cook channel (fh uses different numbers) */
8077     channel = tvb_get_ntohl(tvb, offset);
8078     if (channel < 256) {
8079       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
8080         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u", channel);
8081       if (tree)
8082         proto_tree_add_uint(wlan_tree, hf_channel, tvb, offset, 4, channel);
8083     } else if (channel < 10000) {
8084       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
8085         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u MHz", channel);
8086       if (tree)
8087         proto_tree_add_uint_format(wlan_tree, hf_channel_frequency, tvb, offset,
8088                                    4, channel, "Frequency: %u MHz", channel);
8089     } else {
8090       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
8091         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u KHz", channel);
8092       if (tree)
8093         proto_tree_add_uint_format(wlan_tree, hf_channel_frequency, tvb, offset,
8094                                    4, channel, "Frequency: %u KHz", channel);
8095     }
8096     offset+=4;
8097     datarate = tvb_get_ntohl(tvb, offset);
8098     if (datarate < 100000) {
8099       /* In units of 100 Kb/s; convert to b/s */
8100       datarate *= 100000;
8101     }
8102     if (check_col(pinfo->cinfo, COL_TX_RATE)) {
8103       col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
8104                    datarate / 1000000,
8105                    ((datarate % 1000000) > 500000) ? 5 : 0);
8106     }
8107     if (tree) {
8108       proto_tree_add_uint64_format(wlan_tree, hf_data_rate, tvb, offset, 4,
8109                                    datarate,
8110                                    "Data Rate: %u.%u Mb/s",
8111                                    datarate/1000000,
8112                                    ((datarate % 1000000) > 500000) ? 5 : 0);
8113     }
8114     offset+=4;
8115     if (tree)
8116       proto_tree_add_item(wlan_tree, hf_wlan_antenna, tvb, offset, 4, FALSE);
8117     offset+=4;
8118     if (tree)
8119       proto_tree_add_item(wlan_tree, hf_wlan_priority, tvb, offset, 4, FALSE);
8120     offset+=4;
8121     ssi_type = tvb_get_ntohl(tvb, offset);
8122     if (tree)
8123       proto_tree_add_uint(wlan_tree, hf_wlan_ssi_type, tvb, offset, 4, ssi_type);
8124     offset+=4;
8125     switch (ssi_type) {
8126
8127     case SSI_NONE:
8128     default:
8129       /* either there is no SSI information, or we don't know what type it is */
8130       break;
8131
8132     case SSI_NORM_RSSI:
8133       /* Normalized RSSI */
8134       if (check_col(pinfo->cinfo, COL_RSSI))
8135         col_add_fstr(pinfo->cinfo, COL_RSSI, "%u (norm)", tvb_get_ntohl(tvb, offset));
8136       if (tree)
8137         proto_tree_add_item(wlan_tree, hf_normrssi_antsignal, tvb, offset, 4, FALSE);
8138       break;
8139
8140     case SSI_DBM:
8141       /* dBm */
8142       if (check_col(pinfo->cinfo, COL_RSSI))
8143         col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm", tvb_get_ntohl(tvb, offset));
8144       if (tree)
8145         proto_tree_add_item(wlan_tree, hf_dbm_antsignal, tvb, offset, 4, FALSE);
8146       break;
8147
8148     case SSI_RAW_RSSI:
8149       /* Raw RSSI */
8150       if (check_col(pinfo->cinfo, COL_RSSI))
8151         col_add_fstr(pinfo->cinfo, COL_RSSI, "%u (raw)", tvb_get_ntohl(tvb, offset));
8152       if (tree)
8153         proto_tree_add_item(wlan_tree, hf_rawrssi_antsignal, tvb, offset, 4, FALSE);
8154       break;
8155     }
8156     offset+=4;
8157     antnoise = tvb_get_ntohl(tvb, offset);
8158     /* 0xffffffff means "hardware does not provide noise data" */
8159     if (antnoise != 0xffffffff) {
8160       switch (ssi_type) {
8161
8162       case SSI_NONE:
8163       default:
8164         /* either there is no SSI information, or we don't know what type it is */
8165         break;
8166
8167       case SSI_NORM_RSSI:
8168         /* Normalized RSSI */
8169         if (tree)
8170           proto_tree_add_uint(wlan_tree, hf_normrssi_antnoise, tvb, offset, 4, antnoise);
8171         break;
8172
8173       case SSI_DBM:
8174         /* dBm */
8175         if (tree)
8176           proto_tree_add_int(wlan_tree, hf_dbm_antnoise, tvb, offset, 4, antnoise);
8177         break;
8178
8179       case SSI_RAW_RSSI:
8180         /* Raw RSSI */
8181         if (tree)
8182           proto_tree_add_uint(wlan_tree, hf_rawrssi_antnoise, tvb, offset, 4, antnoise);
8183         break;
8184       }
8185     }
8186     offset+=4;
8187     if (tree)
8188       proto_tree_add_item(wlan_tree, hf_wlan_preamble, tvb, offset, 4, FALSE);
8189     offset+=4;
8190     if (tree)
8191       proto_tree_add_item(wlan_tree, hf_wlan_encoding, tvb, offset, 4, FALSE);
8192     offset+=4;
8193     if (version > 1) {
8194       if (tree)
8195         proto_tree_add_item(wlan_tree, hf_wlan_sequence, tvb, offset, 4, FALSE);
8196       offset+=4;
8197       if (tree)
8198         proto_tree_add_item(wlan_tree, hf_wlan_drops, tvb, offset, 4, FALSE);
8199       offset+=4;
8200       if (tree)
8201         proto_tree_add_item(wlan_tree, hf_wlan_receiver_addr, tvb, offset, 6, FALSE);
8202       offset+=6;
8203       if (tree)
8204         proto_tree_add_item(wlan_tree, hf_wlan_padding, tvb, offset, 2, FALSE);
8205       offset+=2;
8206     }
8207
8208
8209  skip:
8210     offset = length;
8211
8212     /* dissect the 802.11 header next */
8213     next_tvb = tvb_new_subset(tvb, offset, -1, -1);
8214     call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
8215 }
8216
8217 void
8218 proto_register_ieee80211 (void)
8219 {
8220   int i;
8221   GString *key_name, *key_title, *key_desc;
8222
8223   static const value_string frame_type[] = {
8224     {MGT_FRAME,     "Management frame"},
8225     {CONTROL_FRAME, "Control frame"},
8226     {DATA_FRAME,    "Data frame"},
8227     {0,             NULL}
8228   };
8229
8230   static const value_string tofrom_ds[] = {
8231     {0,                       "Not leaving DS or network is operating "
8232       "in AD-HOC mode (To DS: 0 From DS: 0)"},
8233     {FLAG_TO_DS,              "Frame from STA to DS via an AP (To DS: 1 "
8234       "From DS: 0)"},
8235     {FLAG_FROM_DS,            "Frame from DS to a STA via AP(To DS: 0 "
8236       "From DS: 1)"},
8237     {FLAG_TO_DS|FLAG_FROM_DS, "Frame part of WDS from one AP to another "
8238       "AP (To DS: 1 From DS: 1)"},
8239     {0, NULL}
8240   };
8241
8242   static const true_false_string tods_flag = {
8243     "Frame is entering DS",
8244     "Frame is not entering DS"
8245   };
8246
8247   static const true_false_string fromds_flag = {
8248     "Frame is exiting DS",
8249     "Frame is not exiting DS"
8250   };
8251
8252   static const true_false_string more_frags = {
8253     "More fragments follow",
8254     "This is the last fragment"
8255   };
8256
8257   static const true_false_string retry_flags = {
8258     "Frame is being retransmitted",
8259     "Frame is not being retransmitted"
8260   };
8261
8262   static const true_false_string pm_flags = {
8263     "STA will go to sleep",
8264     "STA will stay up"
8265   };
8266
8267   static const true_false_string md_flags = {
8268     "Data is buffered for STA at AP",
8269     "No data buffered"
8270   };
8271
8272   static const true_false_string protected_flags = {
8273     "Data is protected",
8274     "Data is not protected"
8275   };
8276
8277   static const true_false_string order_flags = {
8278     "Strictly ordered",
8279     "Not strictly ordered"
8280   };
8281
8282   static const true_false_string cf_ess_flags = {
8283     "Transmitter is an AP",
8284     "Transmitter is a STA"
8285   };
8286
8287
8288   static const true_false_string cf_privacy_flags = {
8289     "AP/STA can support WEP",
8290     "AP/STA cannot support WEP"
8291   };
8292
8293   static const true_false_string cf_preamble_flags = {
8294     "Short preamble allowed",
8295     "Short preamble not allowed"
8296   };
8297
8298   static const true_false_string cf_pbcc_flags = {
8299     "PBCC modulation allowed",
8300     "PBCC modulation not allowed"
8301   };
8302
8303   static const true_false_string cf_agility_flags = {
8304     "Channel agility in use",
8305     "Channel agility not in use"
8306   };
8307
8308   static const true_false_string short_slot_time_flags = {
8309     "Short slot time in use",
8310     "Short slot time not in use"
8311   };
8312
8313   static const true_false_string dsss_ofdm_flags = {
8314     "DSSS-OFDM modulation allowed",
8315     "DSSS-OFDM modulation not allowed"
8316   };
8317
8318   static const true_false_string cf_spec_man_flags = {
8319     "dot11SpectrumManagementRequired TRUE",
8320     "dot11SpectrumManagementRequired FALSE"
8321   };
8322
8323   static const true_false_string cf_apsd_flags = {
8324     "apsd implemented",
8325     "apsd not implemented"
8326   };
8327
8328   static const true_false_string cf_del_blk_ack_flags = {
8329     "delayed block ack implemented",
8330     "delayed block ack not implemented"
8331   };
8332
8333   static const true_false_string cf_imm_blk_ack_flags = {
8334     "immediate block ack implemented",
8335     "immediate block ack not implemented"
8336   };
8337   static const true_false_string cf_ibss_flags = {
8338     "Transmitter belongs to an IBSS",
8339     "Transmitter belongs to a BSS"
8340   };
8341
8342   static const true_false_string eosp_flag = {
8343     "End of service period",
8344     "Service period"
8345   };
8346
8347   static const true_false_string hf_qos_amsdu_present_flag = {
8348     "A-MSDU",
8349     "MSDU"
8350   };
8351
8352   static const value_string sta_cf_pollable[] = {
8353     {0x00, "Station is not CF-Pollable"},
8354     {0x02, "Station is CF-Pollable, "
8355      "not requesting to be placed on the  CF-polling list"},
8356     {0x01, "Station is CF-Pollable, "
8357      "requesting to be placed on the CF-polling list"},
8358     {0x03, "Station is CF-Pollable, requesting never to be polled"},
8359     {0x0200, "QSTA requesting association in QBSS"},
8360     {0, NULL}
8361   };
8362
8363   static const value_string ap_cf_pollable[] = {
8364     {0x00, "No point coordinator at AP"},
8365     {0x02, "Point coordinator at AP for delivery only (no polling)"},
8366     {0x01, "Point coordinator at AP for delivery and polling"},
8367     {0x03, "Reserved"},
8368     {0x0200, "QAP (HC) does not use CFP for delivery of unicast data type frames"},
8369     {0x0202, "QAP (HC) uses CFP for delivery, but does not send CF-Polls to non-QoS STAs"},
8370     {0x0201, "QAP (HC) uses CFP for delivery, and sends CF-Polls to non-QoS STAs"},
8371     {0x0203, "Reserved"},
8372     {0, NULL}
8373   };
8374
8375
8376   static const value_string auth_alg[] = {
8377     {0x00, "Open System"},
8378     {0x01, "Shared key"},
8379     {0x80, "Network EAP"},  /* Cisco proprietary? */
8380     {0, NULL}
8381   };
8382
8383   /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
8384   static const true_false_string ff_block_ack_params_amsdu_permitted_flag = {
8385     "Permitted in QoS Data MPDUs",
8386     "Not Permitted"
8387   };
8388
8389   static const true_false_string ff_block_ack_params_policy_flag = {
8390     "Immediate Block Ack",
8391     "Delayed Block Ack"
8392   };
8393   /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
8394
8395   /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
8396   static const value_string  ff_channel_width_vals[] = {
8397     {0x00, "20 MHz channel width only"},
8398     {0x01, "Any channel width in the STA\92s Supported Channel Width Set"},
8399     {0, NULL}
8400   };
8401   /*** End: Channel Width Fixed Field - Dustin Johnson ***/
8402
8403   /*** Begin: QoS Information AP Fixed Field - Dustin Johnson ***/
8404   static const true_false_string ff_qos_info_ap_q_ack_flag = {
8405       "Implemented",
8406       "Not Implemented"
8407   };
8408
8409   static const true_false_string ff_qos_info_ap_queue_req_flag = {
8410       "Can process a nonzero Queue Size subfield in the QoS Control field in QoS data frames",
8411       "Can NOT process a nonzero Queue Size subfield in the QoS Control field in QoS data frames"
8412   };
8413
8414   static const true_false_string ff_qos_info_ap_txop_request_flag = {
8415       "Can process a nonzero TXOP Duration Requested subfield in the QoS Control field in QoS data frames",
8416       "Can NOT process a nonzero TXOP Duration Requested subfield in the QoS Control field in QoS data frames"
8417   };
8418   /*** End: QoS Information AP Fixed Field - Dustin Johnson ***/
8419
8420   /*** Begin: QoS Information STA Fixed Field - Dustin Johnson ***/
8421   static const true_false_string ff_qos_info_sta_ac_flag = {
8422       "Trigger-enabled and Delivery-enabled",
8423       "Neither Trigger-enabled nor Delivery-enabled"
8424   };
8425
8426   static const true_false_string ff_qos_info_sta_q_ack_flag = {
8427       "Implemented",
8428       "Not Implemented"
8429   };
8430
8431   static const value_string ff_qos_info_sta_max_sp_len_flags[] = {
8432     {0x00, "AP may deliver all buffered MSDUs, A-MSDUs and MMPDUs"},
8433     {0x01, "AP may deliver a maximum of two MSDUs and MMPDUs per SP"},
8434     {0x02, "AP may deliver a maximum of four MSDUs and MMPDUs per SP"},
8435     {0x03, "AP may deliver a maximum of six MSDUs and MMPDUs per SP"},
8436     {0, NULL}
8437   };
8438
8439   static const true_false_string ff_qos_info_sta_more_data_ack_flag = {
8440       "Can process ACK frames with the More Data bit in the Frame Control field set to 1",
8441       "Can NOT process ACK frames with the More Data bit in the Frame Control field set to 1"
8442   };
8443   /*** End: QoS Information STA Fixed Field - Dustin Johnson ***/
8444
8445   /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
8446   static const true_false_string ff_sm_pwr_save_enabled_flag = {
8447       "Enabled",
8448       "Disabled"
8449   };
8450
8451   static const true_false_string ff_sm_pwr_save_sm_mode_flag = {
8452       "Dynamic SM Power Save mode",
8453       "Static SM Power Save mode"
8454   };
8455   /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
8456
8457   /*** Begin: PCO Phase Control Fixed Field - Dustin Johnson ***/
8458   static const true_false_string ff_pco_phase_cntrl_flag = {
8459       "40 MHz Phase",
8460       "20 MHz Phase"
8461   };
8462   /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
8463
8464   /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
8465   static const true_false_string ff_psmp_param_set_more_psmp_flag = {
8466       "More PSMP Sequences Follow",
8467       "No PSMP Sequences Follow"
8468   };
8469   /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
8470
8471   /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
8472   static const value_string ff_mimo_cntrl_nc_index_flags[] = {
8473     {0x00, "1 Column"},
8474     {0x01, "2 Columns"},
8475     {0x02, "3 Columns"},
8476     {0x03, "4 Columns"},
8477     {0, NULL}
8478   };
8479
8480   static const value_string ff_mimo_cntrl_nr_index_flags[] = {
8481     {0x00, "1 Row"},
8482     {0x01, "2 Rows"},
8483     {0x02, "3 Rows"},
8484     {0x03, "4 Rows"},
8485     {0, NULL}
8486   };
8487
8488   static const true_false_string ff_mimo_cntrl_channel_width_flag = {
8489       "40 MHz",
8490       "20 MHz"
8491   };
8492
8493   /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
8494   static const true_false_string ff_ht_info_information_request_flag = {
8495       "Requesting HT Information Exchange management action frame",
8496       "Should not send an HT Information Exchange management action frame"
8497   };
8498
8499   static const true_false_string ff_ht_info_40_mhz_intolerant_flag = {
8500       "Transmitting station is intolerant of 40 MHz operation",
8501       "Transmitting station permits 40 MHz operation"
8502   };
8503
8504   static const true_false_string ff_ht_info_sta_chan_width_flag = {
8505       "40 MHz",
8506       "20 MHz"
8507   };
8508   /*** End: HT Information Fixed Field - Dustin Johnson ***/
8509
8510   /*** Begin: HT Category Fixed Field - Dustin Johnson ***/
8511   static const value_string ff_ht_action_flags[] = {
8512     {HT_ACTION_NOTIFY_CHAN_WIDTH, "Notify Channel Width"},
8513     {HT_ACTION_SM_PWR_SAVE, "Spatial Multiplexing (SM) Power Save"},
8514     {HT_ACTION_PSMP_ACTION, "Power Save Multi-Poll (PSMP) action frame"},
8515     {HT_ACTION_SET_PCO_PHASE, "Set PCO Phase"},
8516     {HT_ACTION_MIMO_CSI, "MIMO CSI Matrices"},
8517     {HT_ACTION_MIMO_BEAMFORMING, "MIMO Non-compressed Beamforming"},
8518     {HT_ACTION_MIMO_COMPRESSED_BEAMFORMING, "MIMO Compressed Beamforming"},
8519     {HT_ACTION_ANT_SEL_FEEDBACK, "Antenna Selection Indices Feedback"},
8520     {HT_ACTION_HT_INFO_EXCHANGE, "HT Information Exchange"},
8521     {0x00, NULL}
8522   };
8523   /*** Begin: HT Category Fixed Field - Dustin Johnson ***/
8524
8525   static const value_string ff_mimo_cntrl_grouping_flags[] = {
8526     {0x00, "No Grouping"},
8527     {0x01, "Carrier Groups of 2"},
8528     {0x02, "Carrier Groups of 4"},
8529     {0x03, "Reserved"},
8530     {0, NULL}
8531   };
8532
8533   static const value_string ff_mimo_cntrl_coefficient_size_flags[] = {
8534     {0x00, "4 Bits"},
8535     {0x01, "5 Bits"},
8536     {0x02, "6 Bits"},
8537     {0x03, "8 Bits"},
8538     {0, NULL}
8539   };
8540
8541   static const value_string ff_mimo_cntrl_codebook_info_flags[] = {
8542     {0x00, "1 bit for 'Capital Psi', 3 bits for 'Small Psi'"},
8543     {0x01, "2 bit for 'Capital Psi', 4 bits for 'Small Psi'"},
8544     {0x02, "3 bit for 'Capital Psi', 5 bits for 'Small Psi'"},
8545     {0x03, "4 bit for 'Capital Psi', 6 bits for 'Small Psi'"},
8546     {0, NULL}
8547   };
8548   /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
8549
8550   /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
8551   static const value_string ff_psmp_sta_info_flags[] = {
8552     {0x00, "Broadcast"},
8553     {0x01, "Multicast"},
8554     {0x02, "Individually Addressed"},
8555     {0x03, "Unknown"},
8556     {0, NULL}
8557   };
8558   /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
8559
8560   static const value_string reason_codes[] = {
8561     {0x00, "Reserved"},
8562     {0x01, "Unspecified reason"},
8563     {0x02, "Previous authentication no longer valid"},
8564     {0x03, "Deauthenticated because sending STA is leaving (has left) "
8565      "IBSS or ESS"},
8566     {0x04, "Disassociated due to inactivity"},
8567     {0x05, "Disassociated because AP is unable to handle all currently "
8568      "associated stations"},
8569     {0x06, "Class 2 frame received from nonauthenticated station"},
8570     {0x07, "Class 3 frame received from nonassociated station"},
8571     {0x08, "Disassociated because sending STA is leaving (has left) BSS"},
8572     {0x09, "Station requesting (re)association is not authenticated with "
8573       "responding station"},
8574     {0x0A, "Disassociated because the information in the Power Capability "
8575       "element is unacceptable"},
8576     {0x0B, "Disassociated because the information in the Supported"
8577       "Channels element is unacceptable"},
8578     {0x0D, "Invalid Information Element"},
8579     {0x0E, "Michael MIC failure"},
8580     {0x0F, "4-Way Handshake timeout"},
8581     {0x10, "Group key update timeout"},
8582     {0x11, "Information element in 4-Way Handshake different from "
8583      "(Re)Association Request/Probe Response/Beacon"},
8584     {0x12, "Group Cipher is not valid"},
8585     {0x13, "Pairwise Cipher is not valid"},
8586     {0x14, "AKMP is not valid"},
8587     {0x15, "Unsupported RSN IE version"},
8588     {0x16, "Invalid RSN IE Capabilities"},
8589     {0x17, "IEEE 802.1X Authentication failed"},
8590     {0x18, "Cipher suite is rejected per security policy"},
8591     {0x20, "Disassociated for unspecified, QoS-related reason"},
8592     {0x21, "Disassociated because QoS AP lacks sufficient bandwidth for this QoS STA"},
8593     {0x22, "Disassociated because of excessive number of frames that need to be "
8594       "acknowledged, but are not acknowledged for AP transmissions and/or poor "
8595       "channel conditions"},
8596     {0x23, "Disassociated because STA is transmitting outside the limits of its TXOPs"},
8597     {0x24, "Requested from peer STA as the STA is leaving the BSS (or resetting)"},
8598     {0x25, "Requested from peer STA as it does not want to use the mechanism"},
8599     {0x26, "Requested from peer STA as the STA received frames using the mechanism "
8600       "for which a set up is required"},
8601     {0x27, "Requested from peer STA due to time out"},
8602     {0x2D, "Peer STA does not support the requested cipher suite"},
8603     {0x2E, "Association denied due to requesting STA not supporting HT features"},
8604     {0x00, NULL}
8605   };
8606
8607
8608   static const value_string status_codes[] = {
8609     {0x00, "Successful"},
8610     {0x01, "Unspecified failure"},
8611     {0x0A, "Cannot support all requested capabilities in the "
8612      "Capability information field"},
8613     {0x0B, "Reassociation denied due to inability to confirm that "
8614      "association exists"},
8615     {0x0C, "Association denied due to reason outside the scope of this "
8616      "standard"},
8617
8618     {0x0D, "Responding station does not support the specified authentication "
8619      "algorithm"},
8620     {0x0E, "Received an Authentication frame with authentication sequence "
8621      "transaction sequence number out of expected sequence"},
8622     {0x0F, "Authentication rejected because of challenge failure"},
8623     {0x10, "Authentication rejected due to timeout waiting for next "
8624      "frame in sequence"},
8625     {0x11, "Association denied because AP is unable to handle additional "
8626      "associated stations"},
8627     {0x12, "Association denied due to requesting station not supporting all "
8628      "of the datarates in the BSSBasicServiceSet Parameter"},
8629     {0x13, "Association denied due to requesting station not supporting "
8630      "short preamble operation"},
8631     {0x14, "Association denied due to requesting station not supporting "
8632      "PBCC encoding"},
8633     {0x15, "Association denied due to requesting station not supporting "
8634      "channel agility"},
8635     {0x16, "Association request rejected because Spectrum Management"
8636       "capability is required"},
8637     {0x17, "Association request rejected because the information in the"
8638       "Power Capability element is unacceptable"},
8639     {0x18, "Association request rejected because the information in the"
8640       "Supported Channels element is unacceptable"},
8641     {0x19, "Association denied due to requesting station not supporting "
8642      "short slot operation"},
8643     {0x1A, "Association denied due to requesting station not supporting "
8644      "DSSS-OFDM operation"},
8645     {0x20, "Unspecified, QoS-related failure"},
8646     {0x21, "Association denied due to QAP having insufficient bandwidth "
8647       "to handle another QSTA"},
8648     {0x22, "Association denied due to excessive frame loss rates and/or "
8649       "poor conditions on current operating channel"},
8650     {0x23, "Association (with QBSS) denied due to requesting station not "
8651       "supporting the QoS facility"},
8652     {0x24, "Association denied due to requesting station not supporting "
8653       "Block Ack"},
8654     {0x25, "The request has been declined."},
8655     {0x26, "The request has not been successful as one or more parameters "
8656       "have invalid values."},
8657     {0x27, "The TS has not been created because the request cannot be honored. "
8658       "However, a suggested TSPEC is provided so that the initiating QSTA may "
8659       "attempt to set another TS with the suggested changes to the TSPEC."},
8660     {0x28, "Invalid Information Element"},
8661     {0x29, "Group Cipher is not valid"},
8662     {0x2A, "Pairwise Cipher is not valid"},
8663     {0x2B, "AKMP is not valid"},
8664     {0x2C, "Unsupported RSN IE version"},
8665     {0x2D, "Invalid RSN IE Capabilities"},
8666     {0x2E, "Cipher suite is rejected per security policy"},
8667     {0x2F, "The TS has not been created. However, the HC may be capable of "
8668       "creating a TS, in response to a request, after the time indicated in the TS Delay element."},
8669     {0x30, "Direct Link is not allowed in the BSS by policy"},
8670     {0x31, "Destination STA is not present within this QBSS."},
8671     {0x32, "The Destination STA is not a QSTA."},
8672     {0x00, NULL}
8673   };
8674
8675   static const value_string category_codes[] = {
8676     {CAT_SPECTRUM_MGMT, "Spectrum Management (SM)"},
8677     {CAT_QOS, "Quality of Service (QoS)"},
8678     {CAT_DLS, "Direct-Link Setup (DLS)"},
8679     {CAT_BLOCK_ACK, "Block Ack"},
8680     {CAT_RADIO_MEASUREMENT, "Radio Measurement"},
8681     {CAT_HT, "High Throughput"},
8682     {CAT_MGMT_NOTIFICATION, "Management Notification"},
8683     {CAT_VENDOR_SPECIFIC, "Vendor Specific"},
8684     {0, NULL}
8685   };
8686
8687   static const value_string action_codes[] ={
8688     {SM_ACTION_MEASUREMENT_REQUEST, "Measurement Request"},
8689     {SM_ACTION_MEASUREMENT_REPORT, "Measurement Report"},
8690     {SM_ACTION_TPC_REQUEST, "TPC Request"},
8691     {SM_ACTION_TPC_REPORT, "TPC Report"},
8692     {SM_ACTION_CHAN_SWITCH_ANNC, "Channel Switch Announcement"},
8693     {0, NULL}
8694   };
8695
8696   static const value_string vendor_action_types_mrvl[] ={
8697     {MRVL_ACTION_MESH_MANAGEMENT, "Mesh Management"},
8698     {0, NULL}
8699   };
8700
8701   static const value_string mesh_mgt_action_codes_mrvl[] ={
8702     {MRVL_MESH_MGMT_ACTION_RREQ, "Route Request"},
8703     {MRVL_MESH_MGMT_ACTION_RREP, "Route Response"},
8704     {MRVL_MESH_MGMT_ACTION_RERR, "Route Error"},
8705     {MRVL_MESH_MGMT_ACTION_PLDM, "Peer Link Down"},
8706     {0, NULL}
8707   };
8708
8709   static const value_string mesh_path_selection_codes[] ={
8710     {0x0, "Hybrid Wireless Mesh Protocol"},
8711     {0, NULL}
8712   };
8713
8714   static const value_string mesh_metric_codes[] ={
8715     {0x0, "Airtime Link Metric"},
8716     {0, NULL}
8717   };
8718
8719   static const value_string wme_action_codes[] = {
8720     {0x00, "Setup request"},
8721     {0x01, "Setup response"},
8722     {0x02, "Teardown"},
8723     {0x00, NULL}
8724   };
8725
8726   static const value_string wme_status_codes[] = {
8727     {0x00, "Admission accepted"},
8728     {0x01, "Invalid parameters"},
8729     {0x03, "Refused"},
8730     {0x00, NULL}
8731   };
8732
8733   static const value_string ack_policy[] = {
8734     {0x00, "Normal Ack"},
8735     {0x01, "No Ack"},
8736     {0x02, "No explicit acknowledgment"},
8737     {0x03, "Block Ack"},
8738     {0x00, NULL}
8739   };
8740
8741   static const value_string qos_action_codes[] = {
8742     {SM_ACTION_ADDTS_REQUEST, "ADDTS Request"},
8743     {SM_ACTION_ADDTS_RESPONSE, "ADDTS Response"},
8744     {SM_ACTION_DELTS, "DELTS"},
8745     {SM_ACTION_QOS_SCHEDULE, "Schedule"},
8746     {0, NULL}
8747   };
8748
8749   /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
8750   static const value_string ba_action_codes[] = {
8751     {BA_ADD_BLOCK_ACK_REQUEST, "Add Block Ack Request"},
8752     {BA_ADD_BLOCK_ACK_RESPONSE, "Add Block Ack Response"},
8753     {BA_DELETE_BLOCK_ACK, "Delete Block Ack"},
8754     {0x00, NULL}
8755   };
8756   /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
8757
8758   static const value_string dls_action_codes[] = {
8759     {SM_ACTION_DLS_REQUEST, "DLS Request"},
8760     {SM_ACTION_DLS_RESPONSE, "DLS Response"},
8761     {SM_ACTION_DLS_TEARDOWN, "DLS Teardown"},
8762     {0, NULL}
8763   };
8764
8765   static const value_string tsinfo_type[] = {
8766     {0x0, "Aperiodic or unspecified Traffic"},
8767     {0x1, "Periodic Traffic"},
8768     {0, NULL}
8769   };
8770
8771   static const value_string tsinfo_direction[] = {
8772     {0x00, "Uplink"},
8773     {0x01, "Downlink"},
8774     {0x02, "Direct link"},
8775     {0x03, "Bidirectional link"},
8776     {0, NULL}
8777   };
8778
8779   static const value_string tsinfo_access[] = {
8780     {0x00, "Reserved"},
8781     {0x01, "EDCA"},
8782     {0x02, "HCCA"},
8783     {0x03, "HEMM"},
8784     {0, NULL}
8785   };
8786
8787   static const value_string qos_up[] = {
8788     {0x00, "Best Effort"},
8789     {0x01, "Background"},
8790     {0x02, "Spare"},
8791     {0x03, "Excellent Effort"},
8792     {0x04, "Controlled Load"},
8793     {0x05, "Video"},
8794     {0x06, "Voice"},
8795     {0x07, "Network Control"},
8796     {0, NULL}
8797   };
8798
8799   static const value_string classifier_type[] = {
8800     {0x00, "Ethernet parameters"},
8801     {0x01, "TCP/UDP IP parameters"},
8802     {0x02, "IEEE 802.1D/Q parameters"},
8803     {0, NULL}
8804   };
8805
8806   static const value_string tclas_process[] = {
8807     {0x00, "Incoming MSDU's higher layer parameters have to match to the parameters in all associated TCLAS elements."},
8808     {0x01, "Incoming MSDU's higher layer parameters have to match to at least one of the associated TCLAS elements."},
8809     {0x02, "Incoming MSDU's that do not belong to any other TS are classified to the TS for which this TCLAS Processing element is used. In this case, there will not be any associated TCLAS elements."},
8810     {0, NULL}
8811   };
8812
8813   /*** Begin: Block Ack/Block Ack Request  - Dustin Johnson***/
8814   static const true_false_string hf_block_ack_control_ack_policy_flag = {
8815       "Immediate Acknowledgement Required",
8816       "Sender Does Not Require Immediate Acknowledgement"
8817   };
8818
8819   static const value_string hf_block_ack_request_type_flags[] = {
8820     {0x00, "Basic Block Ack Request"},
8821     {0x01, "Reserved"},
8822     {0x02, "Compressed Block Ack Request"},
8823     {0x03, "Multi-TID Block Ack Request"},
8824     {0x00, NULL}
8825   };
8826
8827   static const value_string hf_block_ack_type_flags[] = {
8828     {0x00, "Basic Block Ack"},
8829     {0x01, "Reserved"},
8830     {0x02, "Compressed Block"},
8831     {0x03, "Multi-TID Block"},
8832     {0x00, NULL}
8833   };
8834   /*** End: Block Ack/Block Ack Request  - Dustin Johnson***/
8835
8836   static const value_string phy_type[] = {
8837     { 0, "Unknown" },
8838     { 1, "FHSS 802.11 '97" },
8839     { 2, "DSSS 802.11 '97" },
8840     { 3, "IR Baseband" },
8841     { 4, "DSSS 802.11b" },
8842     { 5, "PBCC 802.11b" },
8843     { 6, "OFDM 802.11g" },
8844     { 7, "PBCC 802.11g" },
8845     { 8, "OFDM 802.11a" },
8846     { 0, NULL }
8847   };
8848
8849   static const value_string encoding_type[] = {
8850     { 0, "Unknown" },
8851     { 1, "CCK" },
8852     { 2, "PBCC" },
8853     { 3, "OFDM" },
8854     { 4, "DSS-OFDM" },
8855     { 5, "BPSK" },
8856     { 6, "QPSK" },
8857     { 7, "16QAM" },
8858     { 8, "64QAM" },
8859     { 0, NULL }
8860   };
8861
8862   static const value_string ssi_type[] = {
8863     { SSI_NONE, "None" },
8864     { SSI_NORM_RSSI, "Normalized RSSI" },
8865     { SSI_DBM, "dBm" },
8866     { SSI_RAW_RSSI, "Raw RSSI" },
8867     { 0, NULL }
8868   };
8869
8870   static const value_string preamble_type[] = {
8871     { 0, "Unknown" },
8872     { 1, "Short" },
8873     { 2, "Long" },
8874     { 0, NULL }
8875   };
8876
8877   static hf_register_info hf[] = {
8878     {&hf_mactime,
8879      {"MAC timestamp", "wlan.mactime", FT_UINT64, BASE_DEC, NULL, 0x0,
8880       "Value in microseconds of the MAC's Time Synchronization Function timer when the first bit of the MPDU arrived at the MAC", HFILL }},
8881
8882     {&hf_hosttime,
8883      {"Host timestamp", "wlan.hosttime", FT_UINT64, BASE_DEC, NULL, 0x0,
8884       "", HFILL }},
8885
8886     {&hf_data_rate,
8887      {"Data Rate", "wlan.data_rate", FT_UINT64, BASE_DEC, NULL, 0,
8888       "Data rate (b/s)", HFILL }},
8889
8890     {&hf_channel,
8891      {"Channel", "wlan.channel", FT_UINT8, BASE_DEC, NULL, 0,
8892       "802.11 channel number that this frame was sent/received on", HFILL }},
8893
8894     {&hf_channel_frequency,
8895      {"Channel frequency", "wlan.channel_frequency", FT_UINT32, BASE_DEC, NULL, 0x0,
8896       "Channel frequency in megahertz that this frame was sent/received on", HFILL }},
8897
8898     {&hf_wlan_antenna,
8899      {"Antenna", "wlan.antenna", FT_UINT32, BASE_DEC, NULL, 0x0,
8900       "Antenna number this frame was sent/received over (starting at 0)", HFILL } },
8901
8902     {&hf_normrssi_antsignal,
8903      {"Normalized RSSI Signal", "wlan.normrssi_antsignal", FT_UINT32, BASE_DEC, NULL, 0x0,
8904       "RF signal power at the antenna, normalized to the range 0-1000", HFILL }},
8905
8906     {&hf_dbm_antsignal,
8907      {"SSI Signal (dBm)", "wlan.dbm_antsignal", FT_INT32, BASE_DEC, NULL, 0x0,
8908       "RF signal power at the antenna from a fixed, arbitrary value in decibels from one milliwatt", HFILL }},
8909
8910     {&hf_rawrssi_antsignal,
8911      {"Raw RSSI Signal", "wlan.rawrssi_antsignal", FT_UINT32, BASE_DEC, NULL, 0x0,
8912       "RF signal power at the antenna, reported as RSSI by the adapter", HFILL }},
8913
8914     {&hf_normrssi_antnoise,
8915      {"Normalized RSSI Noise", "wlan.normrssi_antnoise", FT_UINT32, BASE_DEC, NULL, 0x0,
8916       "RF noise power at the antenna, normalized to the range 0-1000", HFILL }},
8917
8918     {&hf_dbm_antnoise,
8919      {"SSI Noise (dBm)", "radiotap.dbm_antnoise", FT_INT32, BASE_DEC, NULL, 0x0,
8920       "RF noise power at the antenna from a fixed, arbitrary value in decibels per one milliwatt", HFILL }},
8921
8922     {&hf_rawrssi_antnoise,
8923      {"Raw RSSI Noise", "wlan.rawrssi_antnoise", FT_UINT32, BASE_DEC, NULL, 0x0,
8924       "RF noise power at the antenna, reported as RSSI by the adapter", HFILL }},
8925
8926     {&hf_signal_strength,
8927      {"Signal Strength", "wlan.signal_strength", FT_UINT8, BASE_DEC, NULL, 0,
8928       "Signal strength (Percentage)", HFILL }},
8929
8930     {&hf_fc_field,
8931      {"Frame Control Field", "wlan.fc", FT_UINT16, BASE_HEX, NULL, 0,
8932       "MAC Frame control", HFILL }},
8933
8934     {&hf_fc_proto_version,
8935      {"Version", "wlan.fc.version", FT_UINT8, BASE_DEC, NULL, 0,
8936       "MAC Protocol version", HFILL }},  /* 0 */
8937
8938     {&hf_fc_frame_type,
8939      {"Type", "wlan.fc.type", FT_UINT8, BASE_DEC, VALS(frame_type), 0,
8940       "Frame type", HFILL }},
8941
8942     {&hf_fc_frame_subtype,
8943      {"Subtype", "wlan.fc.subtype", FT_UINT8, BASE_DEC, NULL, 0,
8944       "Frame subtype", HFILL }},  /* 2 */
8945
8946     {&hf_fc_frame_type_subtype,
8947      {"Type/Subtype", "wlan.fc.type_subtype", FT_UINT8, BASE_HEX, VALS(frame_type_subtype_vals), 0,
8948       "Type and subtype combined (first byte: type, second byte: subtype)", HFILL }},
8949
8950     {&hf_fc_flags,
8951      {"Protocol Flags", "wlan.flags", FT_UINT8, BASE_HEX, NULL, 0,
8952       "Protocol flags", HFILL }},
8953
8954     {&hf_fc_data_ds,
8955      {"DS status", "wlan.fc.ds", FT_UINT8, BASE_HEX, VALS (&tofrom_ds), (FLAG_FROM_DS|FLAG_TO_DS),
8956       "Data-frame DS-traversal status", HFILL }},  /* 3 */
8957
8958     {&hf_fc_to_ds,
8959      {"To DS", "wlan.fc.tods", FT_BOOLEAN, 8, TFS (&tods_flag), FLAG_TO_DS,
8960       "To DS flag", HFILL }},    /* 4 */
8961
8962     {&hf_fc_from_ds,
8963      {"From DS", "wlan.fc.fromds", FT_BOOLEAN, 8, TFS (&fromds_flag), FLAG_FROM_DS,
8964       "From DS flag", HFILL }},    /* 5 */
8965
8966     {&hf_fc_more_frag,
8967      {"More Fragments", "wlan.fc.frag", FT_BOOLEAN, 8, TFS (&more_frags), FLAG_MORE_FRAGMENTS,
8968       "More Fragments flag", HFILL }},  /* 6 */
8969
8970     {&hf_fc_retry,
8971      {"Retry", "wlan.fc.retry", FT_BOOLEAN, 8, TFS (&retry_flags), FLAG_RETRY,
8972       "Retransmission flag", HFILL }},
8973
8974     { &hf_fc_analysis_retransmission,
8975      {"Retransmission", "wlan.analysis.retransmission", FT_NONE, BASE_NONE,
8976       NULL, 0x0, "This frame is a suspected wireless retransmission", HFILL }},
8977
8978     { &hf_fc_analysis_retransmission_frame,
8979      {"Retransmission of frame", "wlan.analysis.retransmission_frame", FT_FRAMENUM, BASE_NONE,
8980       NULL, 0x0, "This is a retransmission of frame #", HFILL }},
8981
8982     {&hf_fc_pwr_mgt,
8983      {"PWR MGT", "wlan.fc.pwrmgt", FT_BOOLEAN, 8, TFS (&pm_flags), FLAG_POWER_MGT,
8984       "Power management status", HFILL }},
8985
8986     {&hf_fc_more_data,
8987      {"More Data", "wlan.fc.moredata", FT_BOOLEAN, 8, TFS (&md_flags), FLAG_MORE_DATA,
8988       "More data flag", HFILL }},
8989
8990     {&hf_fc_protected,
8991      {"Protected flag", "wlan.fc.protected", FT_BOOLEAN, 8, TFS (&protected_flags), FLAG_PROTECTED,
8992       "Protected flag", HFILL }},
8993
8994     {&hf_fc_order,
8995      {"Order flag", "wlan.fc.order", FT_BOOLEAN, 8, TFS (&order_flags), FLAG_ORDER,
8996       "Strictly ordered flag", HFILL }},
8997
8998     {&hf_assoc_id,
8999      {"Association ID","wlan.aid",FT_UINT16, BASE_DEC,NULL,0,
9000       "Association-ID field", HFILL }},
9001
9002     {&hf_did_duration,
9003      {"Duration", "wlan.duration", FT_UINT16, BASE_DEC, NULL, 0,
9004       "Duration field", HFILL }},
9005
9006     {&hf_addr_da,
9007      {"Destination address", "wlan.da", FT_ETHER, BASE_NONE, NULL, 0,
9008       "Destination Hardware Address", HFILL }},
9009
9010     {&hf_addr_sa,
9011      {"Source address", "wlan.sa", FT_ETHER, BASE_NONE, NULL, 0,
9012       "Source Hardware Address", HFILL }},
9013
9014     { &hf_addr,
9015       {"Source or Destination address", "wlan.addr", FT_ETHER, BASE_NONE, NULL, 0,
9016        "Source or Destination Hardware Address", HFILL }},
9017
9018     {&hf_addr_ra,
9019      {"Receiver address", "wlan.ra", FT_ETHER, BASE_NONE, NULL, 0,
9020       "Receiving Station Hardware Address", HFILL }},
9021
9022     {&hf_addr_ta,
9023      {"Transmitter address", "wlan.ta", FT_ETHER, BASE_NONE, NULL, 0,
9024       "Transmitting Station Hardware Address", HFILL }},
9025
9026     {&hf_addr_addr1,
9027      {"First Address of Contained Frame", "wlan.controlwrap.addr1", FT_ETHER, BASE_NONE, NULL, 0,
9028       "First Address of Contained Frame", HFILL }},
9029
9030     {&hf_addr_bssid,
9031      {"BSS Id", "wlan.bssid", FT_ETHER, BASE_NONE, NULL, 0,
9032       "Basic Service Set ID", HFILL }},
9033
9034     {&hf_frag_number,
9035      {"Fragment number", "wlan.frag", FT_UINT16, BASE_DEC, NULL, 0,
9036       "Fragment number", HFILL }},
9037
9038     {&hf_seq_number,
9039      {"Sequence number", "wlan.seq", FT_UINT16, BASE_DEC, NULL, 0,
9040       "Sequence number", HFILL }},
9041
9042     {&hf_qos_priority,
9043      {"Priority", "wlan.qos.priority", FT_UINT16, BASE_DEC, NULL, 0,
9044       "802.1D Tag", HFILL }},
9045
9046     {&hf_qos_eosp,
9047      {"EOSP", "wlan.qos.eosp", FT_BOOLEAN, 8, TFS (&eosp_flag), QOS_FLAG_EOSP,
9048       "EOSP Field", HFILL }},
9049
9050     {&hf_qos_ack_policy,
9051      {"Ack Policy", "wlan.qos.ack", FT_UINT8, BASE_HEX,  VALS (&ack_policy), 0,
9052       "Ack Policy", HFILL }},
9053
9054     {&hf_qos_amsdu_present,
9055      {"Payload Type", "wlan.qos.amsdupresent", FT_BOOLEAN, BASE_NONE,
9056       TFS (&hf_qos_amsdu_present_flag), 0, "Payload Type", HFILL }},
9057
9058     {&hf_qos_field_content,
9059      {"Content", "wlan.qos.fc_content", FT_UINT16, BASE_DEC, NULL, 0,
9060       "Content1", HFILL }},
9061
9062 /*    {&hf_qos_buffer_state,
9063      {"QAP PS buffer State", "wlan.qos.ps_buf_state", FT_UINT16, BASE_DEC, NULL, 0,
9064       "QAP PS buffer State", HFILL }},
9065
9066     {&hf_qos_txop_dur_req,
9067      {"TXOP Duration Requested", "wlan.qos.txop_dur_req", FT_UINT16, BASE_DEC, NULL, 0,
9068       "TXOP Duration Requested", HFILL }},
9069
9070     {&hf_qos_queue_size,
9071      {"Queue Size", "wlan.qos.queue_size", FT_UINT16, BASE_DEC, NULL, 0,
9072       "Queue Size", HFILL }},*/
9073
9074     {&hf_fcs,
9075      {"Frame check sequence", "wlan.fcs", FT_UINT32, BASE_HEX,
9076       NULL, 0, "Frame Check Sequence (FCS)", HFILL }},
9077
9078     {&hf_fcs_good,
9079      {"Good", "wlan.fcs_good", FT_BOOLEAN, BASE_NONE,
9080       NULL, 0, "True if the FCS is correct", HFILL }},
9081
9082     {&hf_fcs_bad,
9083      {"Bad", "wlan.fcs_bad", FT_BOOLEAN, BASE_NONE,
9084       NULL, 0, "True if the FCS is incorrect", HFILL }},
9085
9086     {&hf_fragment_overlap,
9087       {"Fragment overlap", "wlan.fragment.overlap", FT_BOOLEAN, BASE_NONE,
9088        NULL, 0x0, "Fragment overlaps with other fragments", HFILL }},
9089
9090     {&hf_fragment_overlap_conflict,
9091       {"Conflicting data in fragment overlap", "wlan.fragment.overlap.conflict",
9092        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9093        "Overlapping fragments contained conflicting data", HFILL }},
9094
9095     {&hf_fragment_multiple_tails,
9096       {"Multiple tail fragments found", "wlan.fragment.multipletails",
9097        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9098        "Several tails were found when defragmenting the packet", HFILL }},
9099
9100     {&hf_fragment_too_long_fragment,
9101       {"Fragment too long", "wlan.fragment.toolongfragment",
9102        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9103        "Fragment contained data past end of packet", HFILL }},
9104
9105     {&hf_fragment_error,
9106       {"Defragmentation error", "wlan.fragment.error",
9107        FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9108        "Defragmentation error due to illegal fragments", HFILL }},
9109
9110     {&hf_fragment,
9111       {"802.11 Fragment", "wlan.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9112        "802.11 Fragment", HFILL }},
9113
9114     {&hf_fragments,
9115       {"802.11 Fragments", "wlan.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
9116        "802.11 Fragments", HFILL }},
9117
9118     {&hf_reassembled_in,
9119       {"Reassembled 802.11 in frame", "wlan.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9120        "This 802.11 packet is reassembled in this frame", HFILL }},
9121
9122     {&hf_wep_iv,
9123      {"Initialization Vector", "wlan.wep.iv", FT_UINT24, BASE_HEX, NULL, 0,
9124       "Initialization Vector", HFILL }},
9125
9126     {&hf_wep_iv_weak,
9127      {"Weak IV", "wlan.wep.weakiv", FT_BOOLEAN,BASE_NONE, NULL,0x0,
9128        "Weak IV",HFILL}},
9129
9130     {&hf_tkip_extiv,
9131      {"TKIP Ext. Initialization Vector", "wlan.tkip.extiv", FT_STRING,
9132       BASE_HEX, NULL, 0, "TKIP Extended Initialization Vector", HFILL }},
9133
9134     {&hf_ccmp_extiv,
9135      {"CCMP Ext. Initialization Vector", "wlan.ccmp.extiv", FT_STRING,
9136       BASE_HEX, NULL, 0, "CCMP Extended Initialization Vector", HFILL }},
9137
9138     {&hf_wep_key,
9139      {"Key Index", "wlan.wep.key", FT_UINT8, BASE_DEC, NULL, 0,
9140       "Key Index", HFILL }},
9141
9142     {&hf_wep_icv,
9143      {"WEP ICV", "wlan.wep.icv", FT_UINT32, BASE_HEX, NULL, 0,
9144       "WEP ICV", HFILL }},
9145         /***  Begin: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
9146     {&hf_pst_timingquality,
9147      {"Timing Quality", "pst.timingQuality", FT_UINT16, BASE_DEC, NULL, 0,
9148       "PST Timing Quality", HFILL }},
9149
9150     {&hf_pst_providercount,
9151      {"No. of Providers announcing their Services", "pst.providerCount", FT_UINT8, BASE_DEC, NULL, 0,
9152       "Provider Count", HFILL }},
9153
9154     {&hf_pst_length,
9155      {"Provider Service Table Length ", "pst.length", FT_UINT16, BASE_DEC, NULL, 0,
9156       "PST Length", HFILL }},
9157
9158     {&hf_pst_contents,
9159      {"Provider Service Table Contents ", "pst.contents", FT_UINT8, BASE_HEX, NULL, 0,
9160       "PST Contents", HFILL }},
9161
9162     {&hf_pst_acid,
9163      {"Application Class ID (ACID) ", "pst.ACID", FT_UINT8, BASE_DEC, NULL, 0,
9164       "PST ACID", HFILL }},
9165
9166     {&hf_pst_acm_length,
9167      {"Application Context Mask (ACM) Length", "pst.ACM.length", FT_UINT8, BASE_DEC, NULL, 0,
9168       "PST ACM Length", HFILL }},
9169
9170     {&hf_pst_acm,
9171      {"Application Context Mask", "pst.ACM", FT_STRING, BASE_NONE, NULL, 0,
9172       "PST ACM", HFILL }},
9173
9174     {&hf_pst_acm_contents,
9175      {"Application Context Mask Contents (ACM)", "pst.ACM.contents", FT_UINT32, BASE_DEC, NULL, 0,
9176       "PST ACM Contents", HFILL }},
9177
9178     {&hf_pst_acf,
9179      {"Application Contents Field (ACF)", "pst.ACF", FT_UINT32, BASE_DEC, NULL, 0,
9180       "PST ACF", HFILL }},
9181
9182     {&hf_pst_priority,
9183      {"Application Priority", "pst.priority", FT_UINT8, BASE_DEC, NULL, 0,
9184       "PST Priority", HFILL }},
9185
9186     {&hf_pst_ipv6addr,
9187      {"Internet Protocol V6 Address", "pst.ipv6addr", FT_IPv6, BASE_NONE, NULL, 0,
9188       "IP v6 Addr", HFILL }},
9189
9190     {&hf_pst_macaddr,
9191      {"Medium Access Control Address (MAC addr)", "pst.macaddr", FT_ETHER, BASE_NONE, NULL, 0,
9192       "MAC Address", HFILL }},
9193
9194     {&hf_pst_serviceport,
9195      {"Service Port ", "pst.serviceport", FT_UINT16, BASE_DEC, NULL, 0,
9196       "PST Service Port", HFILL }},
9197
9198     {&hf_pst_addressing,
9199      {"Addressing ", "pst.addressing", FT_UINT8, BASE_DEC, NULL, 0,
9200       "PST Addressing", HFILL }},
9201
9202     {&hf_pst_channel,
9203      {"Service (IEE802.11) Channel", "pst.channel", FT_UINT8, BASE_DEC, NULL, 0,
9204       "PST Service Channel", HFILL }},
9205
9206     {&hf_chan_noc,
9207      {"Number of Channels", "chan.chan_uknown", FT_UINT8, BASE_DEC, NULL, 0,
9208       "Number of Channels", HFILL }},
9209
9210     {&hf_chan_length,
9211      {"Length", "chan.chan_length", FT_UINT8, BASE_DEC, NULL, 0,
9212       "Length", HFILL }},
9213
9214     {&hf_chan_content,
9215      {"Contents", "chan.chan_content", FT_UINT8, BASE_DEC, NULL, 0,
9216       "Contents", HFILL }},
9217
9218     {&hf_chan_channel,
9219      {"channel", "chan.chan_channel", FT_UINT8, BASE_DEC, NULL, 0,
9220       "channel", HFILL }},
9221
9222     {&hf_chan_adapt,
9223      {"Adaptable", "chan.chan_adapt", FT_UINT8, BASE_DEC, NULL, 0,
9224       "Adaptable", HFILL }},
9225
9226     {&hf_chan_rate,
9227      {"Rate", "chan.chan_rate", FT_UINT8, BASE_DEC, NULL, 0,
9228       "Rate", HFILL }},
9229
9230     {&hf_chan_tx_pow,
9231      {"Tx Power", "chan.chan_tx_pow", FT_UINT8, BASE_DEC, NULL, 0,
9232       "Tx Power", HFILL }},
9233
9234     /*** Begin: Block Ack Request/Block Ack  - Dustin Johnson***/
9235     {&hf_block_ack_request_control,
9236      {"Block Ack Request (BAR) Control", "wlan.bar.control",
9237       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Request (BAR) Control", HFILL }},
9238
9239     {&hf_block_ack_control,
9240      {"Block Ack Request Control", "wlan.ba.control",
9241       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Request Control", HFILL }},
9242
9243     {&hf_block_ack_control_ack_policy,
9244      {"BAR Ack Policy", "wlan.ba.control.ackpolicy",
9245       FT_BOOLEAN, 16, TFS (&hf_block_ack_control_ack_policy_flag), 0x01, "Block Ack Request (BAR) Ack Policy", HFILL }},
9246
9247     {&hf_block_ack_control_multi_tid,
9248      {"Multi-TID", "wlan.ba.control.multitid",
9249       FT_BOOLEAN, 16, 0, 0x02, "Multi-Traffic Identifier (TID)", HFILL }},
9250
9251     {&hf_block_ack_control_compressed_bitmap,
9252      {"Compressed Bitmap", "wlan.ba.control.cbitmap",
9253       FT_BOOLEAN, 16, 0, 0x04, "Compressed Bitmap", HFILL }},
9254
9255     {&hf_block_ack_control_reserved,
9256      {"Reserved", "wlan.ba.control.cbitmap",
9257       FT_UINT16, BASE_HEX, NULL, 0x0ff8, "Reserved", HFILL }},
9258
9259     {&hf_block_ack_control_basic_tid_info,
9260      {"TID for which a Basic BlockAck frame is requested", "wlan.ba.basic.tidinfo",
9261       FT_UINT16, BASE_HEX, NULL, 0xf000, "Traffic Identifier (TID) for which a Basic BlockAck frame is requested", HFILL }},
9262
9263     {&hf_block_ack_control_compressed_tid_info,
9264      {"TID for which a BlockAck frame is requested", "wlan.bar.compressed.tidinfo",
9265       FT_UINT16, BASE_HEX, NULL, 0xf000, "Traffic Identifier (TID) for which a BlockAck frame is requested", HFILL }},
9266
9267     {&hf_block_ack_control_multi_tid_info,
9268      {"Number of TIDs Present", "wlan.ba.mtid.tidinfo",
9269       FT_UINT16, BASE_HEX, NULL, 0xf000, "Number of Traffic Identifiers (TIDs) Present", HFILL }},
9270
9271     {&hf_block_ack_multi_tid_info,
9272      {"Traffic Identifier (TID) Info", "wlan.ba.mtid.tid",
9273       FT_UINT8, BASE_DEC, 0, 0, "Traffic Identifier (TID) Info", HFILL }},
9274
9275     {&hf_block_ack_multi_tid_reserved,
9276      {"Reserved", "wlan.bar.mtid.tidinfo.reserved",
9277       FT_UINT16, BASE_HEX, 0, 0x0fff, "Reserved", HFILL }},
9278
9279     {&hf_block_ack_multi_tid_value,
9280      {"Multi-TID Value", "wlan.bar.mtid.tidinfo.value",
9281       FT_UINT16, BASE_HEX, 0, 0xf000, "Multi-TID Value", HFILL }},
9282
9283     {&hf_block_ack_request_type,
9284      {"Block Ack Request Type", "wlan.bar.type",
9285       FT_UINT8, BASE_HEX, VALS(&hf_block_ack_request_type_flags), 0, "Block Ack Request (BAR) Type", HFILL }},
9286
9287     {&hf_block_ack_type,
9288      {"Block Ack Request Type", "wlan.ba.type",
9289       FT_UINT8, BASE_HEX, VALS(&hf_block_ack_type_flags), 0, "Block Ack Request Type", HFILL }}
9290     /*** End: Block Ack Request/Block Ack  - Dustin Johnson***/
9291   };
9292
9293   static hf_register_info hf_prism[] = {
9294     /* Prism-specific header fields
9295        XXX - make as many of these generic as possible. */
9296     { &hf_prism_msgcode,
9297      {"Message Code", "prism.msgcode", FT_UINT32, BASE_HEX, NULL, 0x0,
9298       "", HFILL }},
9299
9300     { &hf_prism_msglen,
9301      {"Message Length", "prism.msglen", FT_UINT32, BASE_HEX, NULL, 0x0,
9302       "", HFILL }},
9303
9304     { &hf_prism_rssi_data,
9305      {"RSSI Field", "prism.rssi.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9306       "", HFILL }},
9307
9308     { &hf_prism_sq_data,
9309      {"SQ Field", "prism.sq.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9310       "", HFILL }},
9311
9312     { &hf_prism_signal_data,
9313      {"Signal Field", "prism.signal.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9314       "", HFILL }},
9315
9316     { &hf_prism_noise_data,
9317      {"Noise Field", "prism.noise.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9318       "", HFILL }},
9319
9320     { &hf_prism_rate_data,
9321      {"Rate Field", "prism.rate.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9322       "", HFILL }},
9323
9324     { &hf_prism_istx_data,
9325      {"IsTX Field", "prism.istx.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9326       "", HFILL }},
9327
9328     { &hf_prism_frmlen_data,
9329      {"Frame Length Field", "prism.frmlen.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9330       "", HFILL }}
9331   };
9332
9333   static hf_register_info hf_wlancap[] = {
9334     /* AVS-specific header fields.
9335        XXX - make as many of these generic as possible. */
9336     {&hf_wlan_magic,
9337      {"Header magic", "wlancap.magic", FT_UINT32, BASE_HEX, NULL, 0xFFFFFFF0, "", HFILL } },
9338     { &hf_wlan_version, { "Header revision", "wlancap.version", FT_UINT32,
9339                           BASE_DEC, NULL, 0xF, "", HFILL } },
9340     { &hf_wlan_length, { "Header length", "wlancap.length", FT_UINT32,
9341                          BASE_DEC, NULL, 0x0, "", HFILL } },
9342     {&hf_wlan_phytype,
9343      {"PHY type", "wlan.phytype", FT_UINT32, BASE_DEC, VALS(phy_type), 0x0,
9344       "", HFILL } },
9345
9346     { &hf_wlan_priority, { "Priority", "wlancap.priority", FT_UINT32, BASE_DEC,
9347                            NULL, 0x0, "", HFILL } },
9348     { &hf_wlan_ssi_type, { "SSI Type", "wlancap.ssi_type", FT_UINT32, BASE_DEC,
9349                            VALS(ssi_type), 0x0, "", HFILL } },
9350     { &hf_wlan_ssi_signal, { "SSI Signal", "wlancap.ssi_signal", FT_INT32,
9351                            BASE_DEC, NULL, 0x0, "", HFILL } },
9352     { &hf_wlan_ssi_noise, { "SSI Noise", "wlancap.ssi_noise", FT_INT32,
9353                            BASE_DEC, NULL, 0x0, "", HFILL } },
9354     { &hf_wlan_preamble, { "Preamble", "wlancap.preamble", FT_UINT32,
9355                            BASE_DEC, VALS(preamble_type), 0x0, "", HFILL } },
9356     { &hf_wlan_encoding, { "Encoding Type", "wlancap.encoding", FT_UINT32,
9357                            BASE_DEC, VALS(encoding_type), 0x0, "", HFILL } },
9358     { &hf_wlan_sequence, { "Receive sequence", "wlancap.sequence", FT_UINT32,
9359                            BASE_DEC, NULL, 0x0, "", HFILL } },
9360     { &hf_wlan_drops, { "Known Dropped Frames", "wlancap.drops", FT_UINT32,
9361                            BASE_DEC, NULL, 0x0, "", HFILL } },
9362     { &hf_wlan_receiver_addr, { "Receiver Address", "wlancap.receiver_addr", FT_ETHER,
9363                            BASE_NONE, NULL, 0x0, "Receiver Hardware Address", HFILL } },
9364     { &hf_wlan_padding, { "Padding", "wlancap.padding", FT_BYTES,
9365                            BASE_NONE, NULL, 0x0, "", HFILL } }
9366   };
9367
9368   static const true_false_string rsn_preauth_flags = {
9369     "Transmitter supports pre-authentication",
9370     "Transmitter does not support pre-authentication"
9371   };
9372
9373   static const true_false_string rsn_no_pairwise_flags = {
9374     "Transmitter cannot support WEP default key 0 simultaneously with "
9375     "Pairwise key",
9376     "Transmitter can support WEP default key 0 simultaneously with "
9377     "Pairwise key"
9378   };
9379
9380   static const value_string rsn_cap_replay_counter[] = {
9381     {0x00, "1 replay counter per PTKSA/GTKSA/STAKeySA"},
9382     {0x01, "2 replay counters per PTKSA/GTKSA/STAKeySA"},
9383     {0x02, "4 replay counters per PTKSA/GTKSA/STAKeySA"},
9384     {0x03, "16 replay counters per PTKSA/GTKSA/STAKeySA"},
9385     {0, NULL}
9386   };
9387
9388   static const true_false_string ht_ldpc_coding_flag = {
9389     "Transmitter supports receiving LDPC coded packets",
9390     "Transmitter does not support receiving LDPC coded packets"
9391   };
9392
9393   static const true_false_string ht_chan_width_flag = {
9394     "Transmitter supports 20MHz and 40MHz operation",
9395     "Transmitter only supports 20MHz operation"
9396   };
9397
9398   static const value_string ht_sm_pwsave_flag[] = {
9399     {0x00, "Static SM Power Save mode"},
9400     {0x01, "Dynamic SM Power Save mode"},
9401     {0x02, "Reserved"},
9402     {0x03, "SM Power Save disabled"},
9403     {0x00, NULL}
9404   };
9405
9406   static const true_false_string ht_green_flag = {
9407     "Transmitter is able to receive PPDUs with Green Field (GF) preamble",
9408     "Transmitter is not able to receive PPDUs with Green Field (GF) preamble"
9409   };
9410
9411   static const true_false_string ht_tf_flag = {
9412     "Supported",
9413     "Not Supported "
9414   };
9415
9416   static const value_string ht_rx_stbc_flag[] = {
9417     {0x00, "No Rx STBC support"},
9418     {0x01, "Rx support of one spatial stream"},
9419     {0x02, "Rx support of one and two spatial streams"},
9420     {0x03, "Rx support of one, two, and three spatial streams"},
9421     {0x00, NULL}
9422   };
9423
9424   static const true_false_string ht_delayed_block_ack_flag = {
9425     "Transmitter supports HT-Delayed BlockAck",
9426     "Transmitter does not support HT-Delayed BlockAck"
9427   };
9428
9429   static const true_false_string ht_max_amsdu_flag = {
9430     "7935 bytes",
9431     "3839 bytes"
9432   };
9433
9434   static const true_false_string ht_dss_cck_40_flag = {
9435     "Will/Can use DSSS/CCK in 40 MHz",
9436     "Won't/Can't use of DSSS/CCK in 40 MHz"
9437   };
9438
9439   static const true_false_string ht_psmp_flag = {
9440     "Will/Can support PSMP operation",
9441     "Won't/Can't support PSMP operation"
9442   };
9443
9444   static const true_false_string ht_40_mhz_intolerant_flag = {
9445     "Use of 40 MHz transmissions restricted/disallowed",
9446     "Use of 40 MHz transmissions unrestricted/allowed"
9447   };
9448
9449   static const value_string ampduparam_mpdu_start_spacing_flags[] = {
9450     {0x00, "no restriction"},
9451     {0x01, "1/4 [usec]"},
9452     {0x02, "1/2 [usec]"},
9453     {0x03, "1 [usec]"},
9454     {0x04, "2 [usec]"},
9455     {0x05, "4 [usec]"},
9456     {0x06, "8 [usec]"},
9457     {0x07, "16 [usec]"},
9458     {0x00, NULL}
9459   };
9460
9461   static const true_false_string mcsset_tx_mcs_set_defined_flag = {
9462     "Defined",
9463     "Not Defined",
9464   };
9465
9466   static const true_false_string mcsset_tx_rx_mcs_set_not_equal_flag = {
9467     "Not Equal",
9468     "Equal",
9469   };
9470
9471   static const value_string mcsset_tx_max_spatial_streams_flags[] = {
9472     {0x00, "1 spatial stream"},
9473     {0x01, "2 spatial streams"},
9474     {0x02, "3 spatial streams"},
9475     {0x03, "4 spatial streams"},
9476     {0x00, NULL}
9477   };
9478
9479   static const value_string htex_transtime_flags[] = {
9480     {0x00, "No Transition"},
9481     {0x01, "400 usec"},
9482     {0x02, "1.5 msec"},
9483     {0x03, "5 msec"},
9484     {0x00, NULL}
9485   };
9486
9487   static const value_string htex_mcs_flags[] = {
9488     {0x00, "STA does not provide MCS feedback"},
9489     {0x01, "Reserved"},
9490     {0x02, "STA provides only unsolicited MCS feedback"},
9491     {0x03, "STA can provide MCS feedback in response to MRQ as well as unsolicited MCS feedback"},
9492     {0x00, NULL}
9493   };
9494
9495   static const value_string txbf_calib_flag[] = {
9496     {0x00, "incapable"},
9497     {0x01, "Limited involvement, cannot initiate"},
9498     {0x02, "Limited involvement, can initiate"},
9499     {0x03, "Fully capable"},
9500     {0x00, NULL}
9501   };
9502
9503   static const value_string txbf_feedback_flags[] = {
9504     {0x00, "not supported"},
9505     {0x01, "delayed feedback capable"},
9506     {0x02, "immediate feedback capable"},
9507     {0x03, "delayed and immediate feedback capable"},
9508     {0x00, NULL}
9509   };
9510
9511   static const value_string txbf_antenna_flags[] = {
9512     {0x00, "1 TX antenna sounding"},
9513     {0x01, "2 TX antenna sounding"},
9514     {0x02, "3 TX antenna sounding"},
9515     {0x03, "4 TX antenna sounding"},
9516     {0x00, NULL}
9517   };
9518
9519   static const value_string txbf_csi_max_rows_bf_flags[] = {
9520     {0x00, "1 row of CSI"},
9521     {0x01, "2 rows of CSI"},
9522     {0x02, "3 rows of CSI"},
9523     {0x03, "4 rows of CSI"},
9524     {0x00, NULL}
9525   };
9526
9527   static const value_string txbf_chan_est_flags[] = {
9528     {0x00, "1 space time stream"},
9529     {0x01, "2 space time streams"},
9530     {0x02, "3 space time streams"},
9531     {0x03, "4 space time streams"},
9532     {0x00, NULL}
9533   };
9534
9535   static const value_string txbf_min_group_flags[] = {
9536     {0x00, "No grouping supported"},
9537     {0x01, "Groups of 1,2 supported"},
9538     {0x02, "Groups of 1,4 supported"},
9539     {0x03, "Groups of 1,2,4 supported"},
9540     {0x00, NULL}
9541   };
9542
9543   static const value_string hta_ext_chan_offset_flag[] = {
9544     {0x00, "No Extension Channel"},
9545     {0x01, "Extension Channel above control channel"},
9546     {0x02, "Undefined"},
9547     {0x03, "Extension Channel below control channel"},
9548     {0x00, NULL}
9549   };
9550
9551   static const true_false_string hta_rec_tx_width_flag = {
9552     "Any channel width enabled",
9553     "Use 20MHz channel (control)"
9554   };
9555
9556   static const true_false_string hta_rifs_mode_flag = {
9557     "Use of RIFS permitted",
9558     "Use of RIFS prohibited"
9559   };
9560
9561   static const true_false_string hta_controlled_access_flag = {
9562     "Not only PSMP",
9563     "PSMP only"
9564   };
9565
9566   static const value_string hta_service_interval_flag[] = {
9567     {0x00, "5ms"},
9568     {0x01, "10ms"},
9569     {0x02, "15ms"},
9570     {0x03, "20ms"},
9571     {0x04, "25ms"},
9572     {0x05, "30ms"},
9573     {0x06, "35ms"},
9574     {0x07, "40ms"},
9575     {0x00, NULL}
9576   };
9577
9578   static const value_string hta_operating_mode_flag[] = {
9579     {0x00, "Pure HT, no protection"},
9580     {0x01, "There may be non-HT devices (control & ext channel)"},
9581     {0x02, "No non-HT is associated, but at least 1 20MHz is. protect on"},
9582     {0x03, "Mixed: no non-HT is associated, protect on"},
9583     {0x00, NULL}
9584   };
9585
9586   static const true_false_string hta_non_gf_devices_flag = {
9587     "All HT devices associated are GF capable",
9588     "One or More HT devices are not GF capable"
9589   };
9590
9591   static const true_false_string hta_dual_stbc_protection_flag = {
9592     "Dual CTS protections is used",
9593     "Regular use of RTS/CTS"
9594   };
9595
9596   static const true_false_string hta_secondary_beacon_flag = {
9597     "Secondary Beacon",
9598     "Primary Beacon"
9599   };
9600
9601   static const true_false_string hta_lsig_txop_protection_flag = {
9602     "Full Support",
9603     "Not full support"
9604   };
9605
9606   static const true_false_string hta_pco_active_flag = {
9607     "PCO is activated in the BSS",
9608     "PCO is not activated in the BSS"
9609   };
9610
9611   static const true_false_string hta_pco_phase_flag = {
9612     "Switch to 20MHz phase/keep 20MHz",
9613     "Switch to 40MHz phase/keep 40MHz"
9614   };
9615
9616   static const value_string ht_info_secondary_channel_offset_flags[] = {
9617     {0x00, "No secondary channel"},
9618     {0x01, "Secondary channel is above the primary channel"},
9619     {0x02, "Reserved"},
9620     {0x03, "Secondary channel is below the primary channel"},
9621     {0x00, NULL}
9622   };
9623
9624   static const true_false_string ht_info_channel_width_flag = {
9625     "Channel of any width supported",
9626     "20 MHz channel width only"
9627   };
9628
9629   static const true_false_string ht_info_rifs_mode_flag = {
9630     "Permitted",
9631     "Prohibited"
9632   };
9633
9634   static const true_false_string ht_info_psmp_stas_only_flag = {
9635     "Association requests are accepted from only PSMP capable STA",
9636     "Association requests are accepted regardless of PSMP capability"
9637   };
9638
9639   static const value_string ht_info_service_interval_granularity_flags[] = {
9640     {0x00, "5 ms"},
9641     {0x01, "10 ms"},
9642     {0x02, "15 ms"},
9643     {0x03, "20 ms"},
9644     {0x04, "25 ms"},
9645     {0x05, "30 ms"},
9646     {0x06, "35 ms"},
9647     {0x07, "40 ms"},
9648     {0x00, NULL}
9649   };
9650
9651   static const value_string ht_info_operating_mode_flags[] = {
9652     {0x00, "All STAs are - 20/40 MHz HT or in a 20/40 MHz BSS or are 20 MHz HT in a 20 MHz BSS"},
9653     {0x01, "HT non-member protection mode"},
9654     {0x02, "Only HT STAs in the BSS, however, there exists at least one 20 MHz STA"},
9655     {0x03, "HT mixed mode"},
9656     {0x00, NULL}
9657   };
9658
9659   static const true_false_string ht_info_non_greenfield_sta_present_flag = {
9660     "One or more associated STAs are not greenfield capable",
9661     "All associated STAs are greenfield capable"
9662   };
9663
9664   static const true_false_string ht_info_transmit_burst_limit_flag = {
9665     "2.4 GHz - 6.16 ms | All other bands - 3.08 ms",
9666     "No limit"
9667   };
9668
9669   static const true_false_string ht_info_obss_non_ht_stas_present_flag = {
9670     "Use of protection for non-HT STAs by overlapping BSSs is needed",
9671     "Use of protection for non-HT STAs by overlapping BSSs is not needed"
9672   };
9673
9674   static const true_false_string ht_info_dual_beacon_flag = {
9675     "AP transmits a secondary beacon",
9676     "No second beacon is transmitted"
9677   };
9678
9679   static const true_false_string ht_info_dual_cts_protection_flag = {
9680     "Required",
9681     "Not required"
9682   };
9683
9684   static const true_false_string ht_info_secondary_beacon_flag = {
9685     "Secondary beacon",
9686     "Primary beacon"
9687   };
9688
9689   static const true_false_string ht_info_lsig_txop_protection_full_support_flag = {
9690     "All HT STAs in the BSS support L-SIG TXOP protection",
9691     "One or more HT STAs in the BSS do not support L-SIG TXOP protection"
9692   };
9693
9694   /* XXX - We might want to use tfs_active_inactive here */
9695   static const true_false_string ht_info_pco_active_flag = {
9696     "Active",
9697     "Not active"
9698   };
9699
9700   static const true_false_string ht_info_pco_phase_flag = {
9701     "Switch to or continue 40 MHz phase",
9702     "Switch to or continue 20 MHz phase"
9703   };
9704
9705   static const true_false_string htc_lac_trq_flag = {
9706     "Want sounding PPDU",
9707     "Don't want sounding PPDU"
9708   };
9709
9710   static const true_false_string htc_lac_mai_mrq_flag = {
9711     "MCS feedback requested",
9712     "No MCS feedback requested"
9713   };
9714
9715   static const value_string hf_htc_lac_asel_command_flags[] = {
9716     {0x00, "Transmit Antenna Selection Sounding Indication (TXASSI)"},
9717     {0x01, "Transmit Antenna Selection Sounding Request (TXASSR)"},
9718     {0x02, "Receive Antenna Selection Sounding Indication (RXASSI)"},
9719     {0x03, "Receive Antenna Selection Sounding Request (RXASSR)"},
9720     {0x04, "Sounding Label"},
9721     {0x05, "No feedback, ASEL training failure"},
9722     {0x06, "Transmit Antenna Selection Sounding Indication (TXASSI) requesting feedback of explicit CSI"},
9723     {0x07, "Reserved"},
9724     {0x00, NULL}
9725   };
9726
9727   static const value_string hf_htc_cal_pos_flags[] = {
9728     {0x00, "Not a calibration frame"},
9729     {0x01, "Calibration Start"},
9730     {0x02, "Sounding Response"},
9731     {0x03, "Sounding Complete"},
9732     {0x00, NULL}
9733   };
9734
9735   static const true_false_string hf_htc_ndp_announcement_flag = {
9736     "NDP will follow",
9737     "No NDP will follow"
9738   };
9739
9740   static const value_string hf_htc_csi_steering_flags[] = {
9741     {0x00, "No feedback required"},
9742     {0x01, "CSI"},
9743     {0x02, "Non-compressed Beamforming Feedback Matrix"},
9744     {0x03, "Compressed Beamforming Feedback Matrix"},
9745     {0x00, NULL}
9746   };
9747
9748   static const value_string hf_tag_secondary_channel_offset_flags[] = {
9749     {0x00, "No Secondary Channel"},
9750     {0x01, "Above Primary Channel"},
9751     {0x02, "Reserved"},
9752     {0x03, "Below Primary Channel"},
9753     {0x00, NULL}
9754   };
9755
9756   static const true_false_string hf_tag_measure_enable_flag = {
9757     "Enabled",
9758     "Disabled"
9759   };
9760
9761   static const true_false_string hf_tag_measure_acc_not_acc = {
9762     "Accepted",
9763     "Not Accepted"
9764   };
9765
9766   static const value_string hf_tag_measure_request_type_flags[] = {
9767     {0x00, "Basic Request"},
9768     {0x01, "Clear Channel Assessment (CCA) Request"},
9769     {0x02, "Receive Power Indication (RPI) Histogram Request"},
9770     {0x03, "Channel Load Request"},
9771     {0x04, "Noise Histogram Request"},
9772     {0x05, "Beacon Request"},
9773     {0x06, "Frame Request"},
9774     {0x07, "STA Statistics Request"},
9775     {0x08, "Location Configuration Indication (LCI) Request"},
9776     {0x09, "Transmit Stream Measurement Request"},
9777     {0x0A, "Measurement Pause Request"},
9778     {0x00, NULL}
9779   };
9780
9781   static const value_string hf_tag_measure_report_type_flags[] = {
9782     {0x00, "Basic Report"},
9783     {0x01, "Clear Channel Assessment (CCA) Report"},
9784     {0x02, "Receive Power Indication (RPI) Histogram Report"},
9785     {0x03, "Channel Load Report"},
9786     {0x04, "Noise Histogram Report"},
9787     {0x05, "Beacon Report"},
9788     {0x06, "Frame Report"},
9789     {0x07, "STA Statistics Report"},
9790     {0x08, "Location Configuration Information (LCI) Report"},
9791     {0x09, "Transmit Stream Measurement Report"},
9792     {0x00, NULL}
9793   };
9794
9795   static const true_false_string hf_tag_measure_report_frame_info_frame_type_flag = {
9796     "Measurement Pilot Frame",
9797     "Beacon/Probe Response Frame"
9798   };
9799
9800   static const true_false_string hf_tag_measure_map_field_bss_flag = {
9801     "At least one MPDU was received by another BSS or IBSS in the measurement period.",
9802     "No MPDUs were received from another BSS or IBSS in the measurement period."
9803   };
9804
9805   static const true_false_string hf_tag_measure_detected_not_detected = {
9806     "Detected",
9807     "Not Detected"
9808   };
9809
9810   static const true_false_string hf_tag_measure_true_false = {
9811     "True",
9812     "False"
9813   };
9814
9815   static const value_string hf_tag_measure_request_measurement_mode_flags[] = {
9816     {0x00, "Passive"},
9817     {0x01, "Active"},
9818     {0x02, "Beacon Table"},
9819     {0x00, NULL}
9820   };
9821
9822   static const value_string hf_tag_measure_request_reporting_condition_flags[] = {
9823     {0x00, "Report to be issued after each measurement."},
9824     {0x01, "The measured RCPI level is greater than an absolute threshold."},
9825     {0x02, "The measured RCPI level is less than an absolute threshold."},
9826     {0x03, "The measured RSNI level is greater than an absolute threshold."},
9827     {0x04, "The measured RSNI level is less than an absolute threshold."},
9828     {0x05, "The measured RCPI level is greater than a threshold defined by an offset from the serving AP's reference RCPI."},
9829     {0x06, "The measured RCPI level is less than a threshold defined by an offset from the serving AP's reference RCPI."},
9830     {0x07, "The measured RSNI level is greater than a threshold defined by an offset from the serving AP's reference RSNI."},
9831     {0x08, "The measured RSNI level is less than a threshold defined by an offset from the serving AP's reference RSNI."},
9832     {0x09, "The measured RCPI level is in a range bound by the serving AP's reference RCPI and an offset from the serving AP's reference RCPI."},
9833     {0x0a, "The measured RSNI level is in a range bound by the serving AP's reference RSNI and an offset from the serving AP's reference RSNI."},
9834     {0xfe, "Report not required to be issued"},
9835     {0x00, NULL}
9836   };
9837
9838   static const value_string hf_tag_measure_request_group_id_flags[] = {
9839     {0x00, "STA Counters from dot11CountersTable"},
9840     {0x01, "STA Counters from dot11MacStatistics group"},
9841     {0x02, "QoS STA Counters for UP0 from dot11QosCountersTable"},
9842     {0x03, "QoS STA Counters for UP1 from dot11QosCountersTable"},
9843     {0x04, "QoS STA Counters for UP2 from dot11QosCountersTable"},
9844     {0x05, "QoS STA Counters for UP3 from dot11QosCountersTable"},
9845     {0x06, "QoS STA Counters for UP4 from dot11QosCountersTable"},
9846     {0x07, "QoS STA Counters for UP5 from dot11QosCountersTable"},
9847     {0x08, "QoS STA Counters for UP6 from dot11QosCountersTable"},
9848     {0x09, "QoS STA Counters for UP7 from dot11QosCountersTable"},
9849     {0x0a, "BSS Average Access Delays"},
9850     {0x0b, "STA Counters from dot11A-MSDU Group"},
9851     {0x0c, "STA Counters from dot11A-MPDU Group"},
9852     {0x0d, "STA Counters from dot11 BAR, Channel Width, PSMP Group"},
9853     {0x0e, "STA Counters from dot11Protection Group"},
9854     {0x0f, "STBC Group"},
9855     {0x00, NULL}
9856   };
9857
9858   static const true_false_string hf_tag_extended_capabilities_flag = {
9859     "Supported",
9860     "Not Supported"
9861   };
9862
9863   /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
9864   static const value_string hf_tag_ext_channel_switch_announcement_switch_mode_flags[] = {
9865     {0x00, "Frames may be transmitted before the channel switch has been completed"},
9866     {0x01, "No more frames are to be transmitted until the channel switch has been completed"},
9867     {0x00, NULL}
9868   };
9869   /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
9870
9871   static hf_register_info ff[] = {
9872
9873     {&ff_timestamp,
9874      {"Timestamp", "wlan_mgt.fixed.timestamp", FT_STRING, BASE_NONE,
9875       NULL, 0, "Timestamp", HFILL }},
9876
9877     {&ff_auth_alg,
9878      {"Authentication Algorithm", "wlan_mgt.fixed.auth.alg",
9879       FT_UINT16, BASE_DEC, VALS (&auth_alg), 0, "Authentication Algorithm", HFILL }},
9880
9881     {&ff_beacon_interval,
9882      {"Beacon Interval", "wlan_mgt.fixed.beacon", FT_DOUBLE, BASE_DEC, NULL, 0,
9883       "Beacon Interval", HFILL }},
9884
9885     {&hf_fixed_parameters,
9886      {"Fixed parameters", "wlan_mgt.fixed.all", FT_UINT16, BASE_DEC, NULL, 0,
9887       "Fixed parameters", HFILL }},
9888
9889     {&hf_tagged_parameters,
9890      {"Tagged parameters", "wlan_mgt.tagged.all", FT_UINT16, BASE_DEC, NULL, 0,
9891       "Tagged parameters", HFILL }},
9892
9893     {&hf_tagged_ssid,
9894      {"SSID", "wlan_mgt.ssid", FT_STRING, BASE_DEC, NULL, 0, 
9895       "SSID", HFILL }},
9896
9897     /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
9898     {&ff_block_ack_params,
9899       {"Block Ack Parameters", "wlan_mgt.fixed.baparams",
9900       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Parameters", HFILL }},
9901
9902     {&ff_block_ack_params_amsdu_permitted,
9903       {"A-MSDUs", "wlan_mgt.fixed.baparams.amsdu",
9904       FT_BOOLEAN, 16, TFS (&ff_block_ack_params_amsdu_permitted_flag), 0x0001, "A-MSDU Permitted in QoS Data MPDUs", HFILL }},
9905
9906     {&ff_block_ack_params_policy,
9907       {"Block Ack Policy", "wlan_mgt.fixed.baparams.policy",
9908       FT_BOOLEAN, 16, TFS (&ff_block_ack_params_policy_flag), 0x0002, "Block Ack Policy", HFILL }},
9909
9910     {&ff_block_ack_params_tid,
9911       {"Traffic Identifier", "wlan_mgt.fixed.baparams.tid",
9912       FT_UINT8, BASE_HEX, NULL, 0x003C, "Traffic Identifier", HFILL }},
9913
9914     {&ff_block_ack_params_buffer_size,
9915       {"Number of Buffers (1 Buffer = 2304 Bytes)", "wlan_mgt.fixed.baparams.buffersize",
9916       FT_UINT16, BASE_DEC, NULL, 0xFFC0, "Number of Buffers", HFILL }},
9917     /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
9918
9919     /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
9920     {&ff_block_ack_timeout,
9921       {"Block Ack Timeout", "wlan_mgt.fixed.batimeout",
9922       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Timeout", HFILL }},
9923     /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
9924
9925     /*** Begin: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
9926     {&ff_block_ack_ssc,
9927      {"Block Ack Starting Sequence Control (SSC)", "wlan_mgt.fixed.ssc",
9928       FT_UINT16, BASE_HEX, 0, 0, "Block Ack Starting Sequence Control (SSC)", HFILL }},
9929
9930     {&ff_block_ack_ssc_fragment,
9931      {"Fragment", "wlan_mgt.fixed.fragment",
9932       FT_UINT16, BASE_DEC, 0, 0x000f, "Fragment", HFILL }},
9933
9934     {&ff_block_ack_ssc_sequence,
9935      {"Starting Sequence Number", "wlan_mgt.fixed.sequence",
9936       FT_UINT16, BASE_DEC, 0, 0xfff0, "Starting Sequence Number", HFILL }},
9937     /*** End: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
9938
9939     /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
9940     {&ff_delba_param,
9941      {"Delete Block Ack (DELBA) Parameter Set", "wlan_mgt.fixed.delba.param",
9942       FT_UINT16, BASE_HEX, 0, 0, "Delete Block Ack (DELBA) Parameter Set", HFILL }},
9943
9944     {&ff_delba_param_reserved,
9945      {"Reserved", "wlan_mgt.fixed.delba.param.reserved",
9946       FT_UINT16, BASE_HEX, 0, 0x07ff, "Reserved", HFILL }},
9947
9948     {&ff_delba_param_init,
9949      {"Initiator", "wlan_mgt.fixed.delba.param.initiator",
9950       FT_BOOLEAN, 16, 0, 0x08000, "Initiator", HFILL }},
9951
9952     {&ff_delba_param_tid,
9953      {"TID", "wlan_mgt.fixed.delba.param.tid",
9954       FT_UINT16, BASE_HEX, 0, 0xf000, "Traffic Identifier (TID)", HFILL }},
9955     /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
9956
9957     /*** Begin: Max Regulation Power Fixed Field - Dustin Johnson ***/
9958     {&ff_max_reg_pwr,
9959      {"Maximum Regulation Power", "wlan_mgt.fixed.maxregpwr",
9960       FT_UINT16, BASE_HEX, 0, 0, "Maximum Regulation Power", HFILL }},
9961     /*** End: Max Regulation Power Fixed Field - Dustin Johnson ***/
9962
9963     /*** Begin: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
9964     {&ff_measurement_pilot_int,
9965      {"Measurement Pilot Interval", "wlan_mgt.fixed.msmtpilotint",
9966       FT_UINT16, BASE_HEX, 0, 0, "Measurement Pilot Interval Fixed Field", HFILL }},
9967     /*** End: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
9968
9969     /*** Begin: Country String Fixed Field - Dustin Johnson ***/
9970     {&ff_country_str,
9971      {"Country String", "wlan_mgt.fixed.country",
9972       FT_STRING, BASE_NONE, 0, 0, "Country String", HFILL }},
9973     /*** End: Country String Fixed Field - Dustin Johnson ***/
9974
9975     /*** Begin: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
9976     {&ff_max_tx_pwr,
9977      {"Maximum Transmit Power", "wlan_mgt.fixed.maxtxpwr",
9978       FT_UINT8, BASE_HEX, 0, 0, "Maximum Transmit Power", HFILL }},
9979     /*** End: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
9980
9981     /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
9982     {&ff_tx_pwr_used,
9983      {"Transmit Power Used", "wlan_mgt.fixed.txpwr",
9984       FT_UINT8, BASE_HEX, 0, 0, "Transmit Power Used", HFILL }},
9985     /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
9986
9987     /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
9988     {&ff_transceiver_noise_floor,
9989      {"Transceiver Noise Floor", "wlan_mgt.fixed.tnoisefloor",
9990       FT_UINT8, BASE_HEX, 0, 0, "Transceiver Noise Floor", HFILL }},
9991     /*** End: Transceiver Noise Floor Fixed Field - Dustin Johnson ***/
9992
9993     /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
9994     {&ff_channel_width,
9995      {"Supported Channel Width", "wlan_mgt.fixed.chanwidth",
9996       FT_UINT8, BASE_HEX, VALS (ff_channel_width_vals), 0, "Supported Channel Width", HFILL }},
9997     /*** End: Channel Width Fixed Field - Dustin Johnson ***/
9998
9999     /*** Begin: QoS Information AP Fixed Field - Dustin Johnson ***/
10000     {&ff_qos_info_ap,
10001      {"QoS Information (AP)", "wlan_mgt.fixed.qosinfo.ap",
10002       FT_UINT8, BASE_HEX, NULL, 0, "QoS Information (AP)", HFILL }},
10003
10004     {&ff_qos_info_ap_edca_param_set_counter,
10005      {"EDCA Parameter Set Update Count", "wlan_mgt.fixed.qosinfo.ap.edcaupdate",
10006       FT_UINT8, BASE_HEX, NULL, 0x0F, "Enhanced Distributed Channel Access (EDCA) Parameter Set Update Count", HFILL }},
10007
10008     {&ff_qos_info_ap_q_ack,
10009      {"Q-Ack", "wlan_mgt.fixed.qosinfo.ap.qack",
10010       FT_BOOLEAN, 8, TFS (&ff_qos_info_ap_q_ack_flag), 0x10, "QoS Ack", HFILL }},
10011
10012     {&ff_qos_info_ap_queue_req,
10013      {"Queue Request", "wlan_mgt.fixed.qosinfo.ap",
10014       FT_BOOLEAN, 8, TFS (&ff_qos_info_ap_queue_req_flag), 0x20, "Queue Request", HFILL }},
10015
10016     {&ff_qos_info_ap_txop_request,
10017      {"TXOP Request", "wlan_mgt.fixed.qosinfo.ap.txopreq",
10018       FT_BOOLEAN, 8, TFS (&ff_qos_info_ap_txop_request_flag), 0x40, "Transmit Opportunity (TXOP) Request", HFILL }},
10019
10020     {&ff_qos_info_ap_reserved,
10021      {"Reserved", "wlan_mgt.fixed.qosinfo.ap.reserved",
10022       FT_BOOLEAN, 8, NULL, 0x80, "Reserved", HFILL }},
10023     /*** End: QoS Information AP Fixed Field - Dustin Johnson ***/
10024
10025     /*** Begin: QoS Information STA Fixed Field - Dustin Johnson ***/
10026     {&ff_qos_info_sta,
10027      {"QoS Information (STA)", "wlan_mgt.fixed.qosinfo.sta",
10028       FT_UINT8, BASE_HEX, NULL, 0, "QoS Information (STA)", HFILL }},
10029
10030     {&ff_qos_info_sta_ac_vo,
10031      {"AC_VO", "wlan_mgt.fixed.qosinfo.sta.ac.vo",
10032       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x01, "AC_VO", HFILL }},
10033
10034     {&ff_qos_info_sta_ac_vi,
10035      {"AC_VI", "wlan_mgt.fixed.qosinfo.sta.ac.vi",
10036       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x02, "AC_VI", HFILL }},
10037
10038     {&ff_qos_info_sta_ac_bk,
10039      {"AC_BK", "wlan_mgt.fixed.qosinfo.sta.ac.bk",
10040       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x04, "AC_BK", HFILL }},
10041
10042     {&ff_qos_info_sta_ac_be,
10043      {"AC_BE", "wlan_mgt.fixed.qosinfo.sta.ac.be",
10044       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x08, "AC_BE", HFILL }},
10045
10046     {&ff_qos_info_sta_q_ack,
10047      {"Q-Ack", "wlan_mgt.fixed.qosinfo.sta.qack",
10048       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_q_ack_flag), 0x10, "QoS Ack", HFILL }},
10049
10050     {&ff_qos_info_sta_max_sp_len,
10051      {"Service Period (SP) Length", "wlan_mgt.fixed.qosinfo.sta.splen",
10052       FT_UINT8, BASE_HEX, VALS (&ff_qos_info_sta_max_sp_len_flags) , 0x60, "Service Period (SP) Length", HFILL }},
10053
10054     {&ff_qos_info_sta_more_data_ack,
10055      {"More Data Ack", "wlan_mgt.fixed.qosinfo.sta.moredataack",
10056       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_more_data_ack_flag), 0x80, "More Data Ack", HFILL }},
10057     /*** End: QoS Information STA Fixed Field - Dustin Johnson ***/
10058
10059     /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
10060     {&ff_sm_pwr_save,
10061      {"Spatial Multiplexing (SM) Power Control", "wlan_mgt.fixed.sm.powercontrol",
10062       FT_UINT8, BASE_HEX, NULL, 0, "Spatial Multiplexing (SM) Power Control", HFILL }},
10063
10064     {&ff_sm_pwr_save_enabled,
10065      {"SM Power Save", "wlan_mgt.fixed.sm.powercontrol.enabled",
10066       FT_BOOLEAN, 8, TFS (&ff_sm_pwr_save_enabled_flag), 0x01, "Spatial Multiplexing (SM) Power Save", HFILL }},
10067
10068     {&ff_sm_pwr_save_sm_mode,
10069      {"SM Mode", "wlan_mgt.fixed.sm.powercontrol.mode",
10070       FT_BOOLEAN, 8, TFS (&ff_sm_pwr_save_sm_mode_flag), 0x02, "Spatial Multiplexing (SM) Mode", HFILL }},
10071
10072     {&ff_sm_pwr_save_reserved,
10073      {"Reserved", "wlan_mgt.fixed.sm.powercontrol.reserved",
10074       FT_UINT8, BASE_HEX, NULL, 0xFC, "Reserved", HFILL }},
10075     /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
10076
10077     /*** Begin: PCO Phase Control Fixed Field - Dustin Johnson ***/
10078     {&ff_pco_phase_cntrl,
10079      {"Phased Coexistence Operation (PCO) Phase Control", "wlan_mgt.fixed.pco.phasecntrl",
10080       FT_BOOLEAN, 0, TFS (&ff_pco_phase_cntrl_flag), 0, "Phased Coexistence Operation (PCO) Phase Control", HFILL }},
10081     /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
10082
10083     /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
10084     {&ff_psmp_param_set,
10085      {"Power Save Multi-Poll (PSMP) Parameter Set", "wlan_mgt.fixed.psmp.paramset",
10086       FT_UINT16, BASE_HEX, 0, 0, "Power Save Multi-Poll (PSMP) Parameter Set", HFILL }},
10087
10088     {&ff_psmp_param_set_n_sta,
10089      {"Number of STA Info Fields Present", "wlan_mgt.fixed.psmp.paramset.nsta",
10090       FT_UINT8, BASE_HEX, 0, 0, "Number of STA Info Fields Present", HFILL }},
10091
10092     {&ff_psmp_param_set_more_psmp,
10093      {"More PSMP", "wlan_mgt.fixed.psmp.paramset.more",
10094       FT_BOOLEAN, 0, TFS(&ff_psmp_param_set_more_psmp_flag), 0, "More Power Save Multi-Poll (PSMP)", HFILL }},
10095
10096     {&ff_psmp_param_set_psmp_sequence_duration,
10097      {"PSMP Sequence Duration", "wlan_mgt.fixed.psmp.paramset.seqduration",
10098       FT_UINT16, BASE_DEC, 0, 0, "Power Save Multi-Poll (PSMP) Sequence Duration", HFILL }},
10099     /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
10100
10101     /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
10102     {&ff_mimo_cntrl_nc_index,
10103      {"Nc Index", "wlan_mgt.fixed.mimo.control.ncindex",
10104       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_nc_index_flags), 0x0003, "Number of Columns Less One", HFILL }},
10105
10106     {&ff_mimo_cntrl_nr_index,
10107      {"Nr Index", "wlan_mgt.fixed.mimo.control.nrindex",
10108       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_nr_index_flags), 0x000C, "Number of Rows Less One", HFILL }},
10109
10110     {&ff_mimo_cntrl_channel_width,
10111      {"Channel Width", "wlan_mgt.fixed.mimo.control.chanwidth",
10112       FT_BOOLEAN, 16, TFS(&ff_mimo_cntrl_channel_width_flag), 0x0010, "Channel Width", HFILL }},
10113
10114     {&ff_mimo_cntrl_grouping,
10115      {"Grouping (Ng)", "wlan_mgt.fixed.mimo.control.grouping",
10116       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_grouping_flags), 0x0060, "Grouping (Ng)", HFILL }},
10117
10118     {&ff_mimo_cntrl_coefficient_size,
10119      {"Coefficient Size (Nb)", "wlan_mgt.fixed.mimo.control.cosize",
10120       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_coefficient_size_flags), 0x0180, "Coefficient Size (Nb)", HFILL }},
10121
10122     {&ff_mimo_cntrl_codebook_info,
10123      {"Codebook Information", "wlan_mgt.fixed.mimo.control.codebookinfo",
10124       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_codebook_info_flags), 0x0600, "Codebook Information", HFILL }},
10125
10126     {&ff_mimo_cntrl_remaining_matrix_segment,
10127      {"Remaining Matrix Segment", "wlan_mgt.fixed.mimo.control.matrixseg",
10128       FT_UINT16, BASE_HEX, 0, 0x3800, "Remaining Matrix Segment", HFILL }},
10129
10130     {&ff_mimo_cntrl_reserved,
10131      {"Reserved", "wlan_mgt.fixed.mimo.control.reserved",
10132       FT_UINT16, BASE_HEX, 0, 0xC000, "Reserved", HFILL }},
10133
10134     {&ff_mimo_cntrl_sounding_timestamp,
10135      {"Sounding Timestamp", "wlan_mgt.fixed.mimo.control.soundingtime",
10136       FT_UINT32, BASE_HEX, 0, 0, "Sounding Timestamp", HFILL }},
10137     /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
10138
10139     /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
10140     {&ff_psmp_sta_info,
10141      {"Power Save Multi-Poll (PSMP) Station Information", "wlan_mgt.fixed.psmp.stainfo",
10142       FT_UINT8, BASE_HEX, VALS (&ff_psmp_sta_info_flags), 0, "Power Save Multi-Poll (PSMP) Station Information", HFILL }},
10143
10144     {&ff_psmp_sta_info_dtt_start_offset,
10145      {"DTT Start Offset", "wlan_mgt.fixed.psmp.stainfo.dttstart",
10146       FT_UINT16, BASE_HEX, 0, 0, "DTT Start Offset", HFILL }},
10147
10148     {&ff_psmp_sta_info_dtt_duration,
10149      {"DTT Duration", "wlan_mgt.fixed.psmp.stainfo.dttduration",
10150       FT_UINT8, BASE_HEX, 0, 0, "DTT Duration", HFILL }},
10151
10152     {&ff_psmp_sta_info_sta_id,
10153      {"Target Station ID", "wlan_mgt.fixed.psmp.stainfo.staid",
10154       FT_UINT16, BASE_HEX, 0, 0, "Target Station ID", HFILL }},
10155
10156     {&ff_psmp_sta_info_utt_start_offset,
10157      {"UTT Start Offset", "wlan_mgt.fixed.psmp.stainfo.uttstart",
10158       FT_UINT16, BASE_HEX, 0, 0, "UTT Start Offset", HFILL }},
10159
10160     {&ff_psmp_sta_info_utt_duration,
10161      {"UTT Duration", "wlan_mgt.fixed.psmp.stainfo.uttduration",
10162       FT_UINT16, BASE_HEX, 0, 0, "UTT Duration", HFILL }},
10163
10164     {&ff_psmp_sta_info_reserved_small,
10165      {"Reserved", "wlan_mgt.fixed.psmp.stainfo.reserved",
10166       FT_UINT16, BASE_HEX, 0, 0, "Reserved", HFILL }},
10167
10168     {&ff_psmp_sta_info_reserved_large,
10169      {"Reserved", "wlan_mgt.fixed.psmp.stainfo.reserved",
10170       FT_UINT64, BASE_HEX, 0, 0, "Reserved", HFILL }},
10171
10172     {&ff_psmp_sta_info_psmp_multicast_id,
10173      {"Power Save Multi-Poll (PSMP) Multicast ID", "wlan_mgt.fixed.psmp.stainfo.multicastid",
10174       FT_UINT64, BASE_HEX, 0, 0, "Power Save Multi-Poll (PSMP) Multicast ID", HFILL }},
10175     /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
10176
10177     /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
10178     {&ff_ant_selection,
10179      {"Antenna Selection", "wlan_mgt.fixed.antsel",
10180       FT_UINT8, BASE_HEX, 0, 0, "Antenna Selection", HFILL }},
10181
10182     {&ff_ant_selection_0,
10183      {"Antenna 0", "wlan_mgt.fixed.antsel.ant0",
10184       FT_UINT8, BASE_HEX, 0, 0x01, "Antenna 0", HFILL }},
10185
10186     {&ff_ant_selection_1,
10187      {"Antenna 1", "wlan_mgt.fixed.antsel.ant1",
10188       FT_UINT8, BASE_HEX, 0, 0x02, "Antenna 1", HFILL }},
10189
10190     {&ff_ant_selection_2,
10191      {"Antenna 2", "wlan_mgt.fixed.antsel.ant2",
10192       FT_UINT8, BASE_HEX, 0, 0x04, "Antenna 2", HFILL }},
10193
10194     {&ff_ant_selection_3,
10195      {"Antenna 3", "wlan_mgt.fixed.antsel.ant3",
10196       FT_UINT8, BASE_HEX, 0, 0x08, "Antenna 3", HFILL }},
10197
10198     {&ff_ant_selection_4,
10199      {"Antenna 4", "wlan_mgt.fixed.antsel.ant4",
10200       FT_UINT8, BASE_HEX, 0, 0x10, "Antenna 4", HFILL }},
10201
10202     {&ff_ant_selection_5,
10203      {"Antenna 5", "wlan_mgt.fixed.antsel.ant5",
10204       FT_UINT8, BASE_HEX, 0, 0x20, "Antenna 5", HFILL }},
10205
10206     {&ff_ant_selection_6,
10207      {"Antenna 6", "wlan_mgt.fixed.antsel.ant6",
10208       FT_UINT8, BASE_HEX, 0, 0x40, "Antenna 6", HFILL }},
10209
10210     {&ff_ant_selection_7,
10211      {"Antenna 7", "wlan_mgt.fixed.antsel.ant7",
10212       FT_UINT8, BASE_HEX, 0, 0x80, "Antenna 7", HFILL }},
10213     /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
10214
10215     /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
10216     {&ff_ext_channel_switch_announcement,
10217      {"Extended Channel Switch Announcement", "wlan_mgt.fixed.extchansw",
10218       FT_UINT32, BASE_HEX, 0, 0, "", HFILL }},
10219     /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
10220
10221     /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
10222     {&ff_ht_info,
10223      {"HT Information", "wlan_mgt.fixed.extchansw",
10224       FT_UINT8, BASE_HEX, 0, 0, "HT Information Fixed Field", HFILL }},
10225
10226     {&ff_ht_info_information_request,
10227      {"Information Request", "wlan_mgt.fixed.mimo.control.chanwidth",
10228       FT_BOOLEAN, 8, TFS(&ff_ht_info_information_request_flag), 0x01, "Information Request", HFILL }},
10229
10230     {&ff_ht_info_40_mhz_intolerant,
10231      {"40 MHz Intolerant", "wlan_mgt.fixed.mimo.control.chanwidth",
10232       FT_BOOLEAN, 8, TFS(&ff_ht_info_40_mhz_intolerant_flag), 0x02, "40 MHz Intolerant", HFILL }},
10233
10234     {&ff_ht_info_sta_chan_width,
10235      {"Station Channel Width", "wlan_mgt.fixed.mimo.control.chanwidth",
10236       FT_BOOLEAN, 8, TFS(&ff_ht_info_sta_chan_width_flag), 0x04, "Station Channel Width", HFILL }},
10237
10238     {&ff_ht_info_reserved,
10239      {"Reserved", "wlan_mgt.fixed.extchansw",
10240       FT_UINT8, BASE_HEX, 0, 0xF8, "Reserved Field", HFILL }},
10241     /*** End: HT Information Fixed Field - Dustin Johnson ***/
10242
10243     /*** Begin: HT Action Fixed Field - Dustin Johnson ***/
10244     {&ff_ht_action,
10245      {"HT Action", "wlan_mgt.fixed.htact",
10246       FT_UINT8, BASE_HEX, VALS (&ff_ht_action_flags), 0, "HT Action Code", HFILL }},
10247     /*** End: HT Action Fixed Field - Dustin Johnson ***/
10248
10249     /*** Begin: MIMO CSI Matrices Report - Dustin Johnson ***/
10250     {&ff_mimo_csi_snr,
10251      {"Signal to Noise Ratio (SNR)", "wlan_mgt.mimo.csimatrices.snr",
10252       FT_UINT8, BASE_HEX, NULL, 0, "Signal to Noise Ratio (SNR)", HFILL }},
10253     /*** End: MIMO CSI Matrices Report - Dustin Johnson ***/
10254
10255     {&ff_capture,
10256      {"Capabilities", "wlan_mgt.fixed.capabilities", FT_UINT16, BASE_HEX, NULL, 0,
10257       "Capability information", HFILL }},
10258
10259     {&ff_cf_ess,
10260      {"ESS capabilities", "wlan_mgt.fixed.capabilities.ess",
10261       FT_BOOLEAN, 16, TFS (&cf_ess_flags), 0x0001, "ESS capabilities", HFILL }},
10262
10263     {&ff_cf_ibss,
10264      {"IBSS status", "wlan_mgt.fixed.capabilities.ibss",
10265       FT_BOOLEAN, 16, TFS (&cf_ibss_flags), 0x0002, "IBSS participation", HFILL }},
10266
10267     {&ff_cf_sta_poll,
10268      {"CFP participation capabilities", "wlan_mgt.fixed.capabilities.cfpoll.sta",
10269       FT_UINT16, BASE_HEX, VALS (&sta_cf_pollable), 0x020C,
10270       "CF-Poll capabilities for a STA", HFILL }},
10271
10272     {&ff_cf_ap_poll,
10273      {"CFP participation capabilities", "wlan_mgt.fixed.capabilities.cfpoll.ap",
10274       FT_UINT16, BASE_HEX, VALS (&ap_cf_pollable), 0x020C,
10275       "CF-Poll capabilities for an AP", HFILL }},
10276
10277     {&ff_cf_privacy,
10278      {"Privacy", "wlan_mgt.fixed.capabilities.privacy",
10279       FT_BOOLEAN, 16, TFS (&cf_privacy_flags), 0x0010, "WEP support", HFILL }},
10280
10281     {&ff_cf_preamble,
10282      {"Short Preamble", "wlan_mgt.fixed.capabilities.preamble",
10283       FT_BOOLEAN, 16, TFS (&cf_preamble_flags), 0x0020, "Short Preamble", HFILL }},
10284
10285     {&ff_cf_pbcc,
10286      {"PBCC", "wlan_mgt.fixed.capabilities.pbcc",
10287       FT_BOOLEAN, 16, TFS (&cf_pbcc_flags), 0x0040, "PBCC Modulation", HFILL }},
10288
10289     {&ff_cf_agility,
10290      {"Channel Agility", "wlan_mgt.fixed.capabilities.agility",
10291       FT_BOOLEAN, 16, TFS (&cf_agility_flags), 0x0080, "Channel Agility", HFILL }},
10292
10293     {&ff_cf_spec_man,
10294      {"Spectrum Management", "wlan_mgt.fixed.capabilities.spec_man",
10295       FT_BOOLEAN, 16, TFS (&cf_spec_man_flags), 0x0100, "Spectrum Management", HFILL }},
10296
10297     {&ff_short_slot_time,
10298      {"Short Slot Time", "wlan_mgt.fixed.capabilities.short_slot_time",
10299       FT_BOOLEAN, 16, TFS (&short_slot_time_flags), 0x0400, "Short Slot Time",
10300       HFILL }},
10301
10302     {&ff_cf_apsd,
10303      {"Automatic Power Save Delivery", "wlan_mgt.fixed.capabilities.apsd",
10304       FT_BOOLEAN, 16, TFS (&cf_apsd_flags), 0x0800, "Automatic Power Save Delivery", HFILL }},
10305
10306     {&ff_dsss_ofdm,
10307      {"DSSS-OFDM", "wlan_mgt.fixed.capabilities.dsss_ofdm",
10308       FT_BOOLEAN, 16, TFS (&dsss_ofdm_flags), 0x2000, "DSSS-OFDM Modulation",
10309       HFILL }},
10310
10311     {&ff_cf_del_blk_ack,
10312      {"Delayed Block Ack", "wlan_mgt.fixed.capabilities.del_blk_ack",
10313       FT_BOOLEAN, 16, TFS (&cf_del_blk_ack_flags), 0x4000, "Delayed Block Ack", HFILL }},
10314
10315     {&ff_cf_imm_blk_ack,
10316      {"Immediate Block Ack", "wlan_mgt.fixed.capabilities.imm_blk_ack",
10317       FT_BOOLEAN, 16, TFS (&cf_imm_blk_ack_flags), 0x8000, "Immediate Block Ack", HFILL }},
10318
10319     {&ff_auth_seq,
10320      {"Authentication SEQ", "wlan_mgt.fixed.auth_seq",
10321       FT_UINT16, BASE_HEX, NULL, 0, "Authentication Sequence Number", HFILL }},
10322
10323     {&ff_assoc_id,
10324      {"Association ID", "wlan_mgt.fixed.aid",
10325       FT_UINT16, BASE_HEX, NULL, 0, "Association ID", HFILL }},
10326
10327     {&ff_listen_ival,
10328      {"Listen Interval", "wlan_mgt.fixed.listen_ival",
10329       FT_UINT16, BASE_HEX, NULL, 0, "Listen Interval", HFILL }},
10330
10331     {&ff_current_ap,
10332      {"Current AP", "wlan_mgt.fixed.current_ap",
10333       FT_ETHER, BASE_NONE, NULL, 0, "MAC address of current AP", HFILL }},
10334
10335     {&ff_reason,
10336      {"Reason code", "wlan_mgt.fixed.reason_code",
10337       FT_UINT16, BASE_HEX, VALS (&reason_codes), 0,
10338       "Reason for unsolicited notification", HFILL }},
10339
10340     {&ff_status_code,
10341      {"Status code", "wlan_mgt.fixed.status_code",
10342       FT_UINT16, BASE_HEX, VALS (&status_codes), 0,
10343       "Status of requested event", HFILL }},
10344
10345     {&ff_category_code,
10346      {"Category code", "wlan_mgt.fixed.category_code",
10347       FT_UINT16, BASE_DEC, VALS (&category_codes), 0,
10348       "Management action category", HFILL }},
10349
10350     {&ff_action_code,
10351      {"Action code", "wlan_mgt.fixed.action_code",
10352       FT_UINT16, BASE_DEC, VALS (&action_codes), 0,
10353       "Management action code", HFILL }},
10354
10355     {&ff_dialog_token,
10356      {"Dialog token", "wlan_mgt.fixed.dialog_token",
10357       FT_UINT8, BASE_HEX, NULL, 0, "Management action dialog token", HFILL }},
10358
10359     {&ff_marvell_action_type,
10360      {"Marvell Action type", "wlan_mgt.fixed.mrvl_action_type",
10361       FT_UINT8, BASE_DEC, VALS (&vendor_action_types_mrvl), 0,
10362       "Vendor Specific Action Type (Marvell)", HFILL }},
10363
10364     {&ff_marvell_mesh_mgt_action_code,
10365      {"Mesh action(Marvell)", "wlan_mgt.fixed.mrvl_mesh_action",
10366       FT_UINT8, BASE_HEX, VALS (&mesh_mgt_action_codes_mrvl), 0,
10367       "Mesh action code(Marvell)", HFILL }},
10368
10369     {&ff_mesh_mgt_length,
10370      {"Message Length", "wlan_mgt.fixed.length",
10371       FT_UINT8, BASE_DEC, NULL, 0, "Message Length", HFILL }},
10372
10373     {&ff_mesh_mgt_mode,
10374      {"Message Mode", "wlan_mgt.fixed.mode",
10375       FT_UINT8, BASE_HEX, NULL, 0, "Message Mode", HFILL }},
10376
10377     {&ff_mesh_mgt_ttl,
10378      {"Message TTL", "wlan_mgt.fixed.ttl",
10379       FT_UINT8, BASE_DEC, NULL, 0, "Message TTL", HFILL }},
10380
10381     {&ff_mesh_mgt_dstcount,
10382      {"Destination Count", "wlan_mgt.fixed.dstcount",
10383       FT_UINT8, BASE_DEC, NULL, 0, "Destination Count", HFILL }},
10384
10385     {&ff_mesh_mgt_hopcount,
10386      {"Hop Count", "wlan_mgt.fixed.hopcount",
10387       FT_UINT8, BASE_DEC, NULL, 0, "Hop Count", HFILL }},
10388
10389     {&ff_mesh_mgt_rreqid,
10390      {"RREQ ID", "wlan_mgt.fixed.rreqid",
10391       FT_UINT32, BASE_DEC, NULL, 0, "RREQ ID", HFILL }},
10392
10393     {&ff_mesh_mgt_sa,
10394      {"Source Address", "wlan_mgt.fixed.sa",
10395       FT_ETHER, BASE_NONE, NULL, 0, "Source MAC address", HFILL }},
10396
10397     {&ff_mesh_mgt_ssn,
10398      {"SSN", "wlan_mgt.fixed.ssn",
10399       FT_UINT32, BASE_DEC, NULL, 0, "Source Sequence Number", HFILL }},
10400
10401     {&ff_mesh_mgt_metric,
10402      {"Metric", "wlan_mgt.fixed.metric",
10403       FT_UINT32, BASE_DEC, NULL, 0, "Route Metric", HFILL }},
10404
10405     {&ff_mesh_mgt_flags,
10406      {"RREQ Flags", "wlan_mgt.fixed.hopcount",
10407       FT_UINT8, BASE_HEX, NULL, 0, "RREQ Flags", HFILL }},
10408
10409     {&ff_mesh_mgt_da,
10410      {"Destination Address", "wlan_mgt.fixed.da",
10411       FT_ETHER, BASE_NONE, NULL, 0, "Destination MAC address", HFILL }},
10412
10413     {&ff_mesh_mgt_dsn,
10414      {"DSN", "wlan_mgt.fixed.dsn",
10415       FT_UINT32, BASE_DEC, NULL, 0, "Destination Sequence Number", HFILL }},
10416
10417     {&ff_mesh_mgt_lifetime,
10418      {"Lifetime", "wlan_mgt.fixed.lifetime",
10419       FT_UINT32, BASE_DEC, NULL, 0, "Route Lifetime", HFILL }},
10420
10421     {&ff_wme_action_code,
10422      {"Action code", "wlan_mgt.fixed.action_code",
10423       FT_UINT16, BASE_HEX, VALS (&wme_action_codes), 0,
10424       "Management notification action code", HFILL }},
10425
10426     {&ff_wme_status_code,
10427      {"Status code", "wlan_mgt.fixed.status_code",
10428       FT_UINT16, BASE_HEX, VALS (&wme_status_codes), 0,
10429       "Management notification setup response status code", HFILL }},
10430
10431     {&ff_qos_action_code,
10432      {"Action code", "wlan_mgt.fixed.action_code",
10433       FT_UINT16, BASE_HEX, VALS (&qos_action_codes), 0,
10434       "QoS management action code", HFILL }},
10435
10436     /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
10437     {&ff_ba_action,
10438      {"Action code", "wlan_mgt.fixed.action_code",
10439       FT_UINT8, BASE_HEX, VALS (&ba_action_codes), 0,
10440       "Block Ack action code", HFILL }},
10441     /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
10442
10443     {&ff_dls_action_code,
10444      {"Action code", "wlan_mgt.fixed.action_code",
10445       FT_UINT16, BASE_HEX, VALS (&dls_action_codes), 0,
10446       "DLS management action code", HFILL }},
10447
10448     {&ff_dst_mac_addr,
10449      {"Destination address", "wlan_mgt.fixed.dst_mac_addr",
10450       FT_ETHER, BASE_NONE, NULL, 0, "Destination MAC address", HFILL }},
10451
10452     {&ff_src_mac_addr,
10453      {"Source address", "wlan_mgt.fixed.src_mac_addr",
10454       FT_ETHER, BASE_NONE, NULL, 0, "Source MAC address", HFILL }},
10455
10456     {&ff_dls_timeout,
10457      {"DLS timeout", "wlan_mgt.fixed.dls_timeout",
10458       FT_UINT16, BASE_HEX, NULL, 0, "DLS timeout value", HFILL }},
10459
10460     {&tag_number,
10461      {"Tag", "wlan_mgt.tag.number",
10462       FT_UINT8, BASE_DEC, VALS(tag_num_vals), 0,
10463       "Element ID", HFILL }},
10464
10465     {&tag_length,
10466      {"Tag length", "wlan_mgt.tag.length",
10467       FT_UINT32, BASE_DEC, NULL, 0, "Length of tag", HFILL }},
10468
10469     {&tag_interpretation,
10470      {"Tag interpretation", "wlan_mgt.tag.interpretation",
10471       FT_STRING, BASE_NONE, NULL, 0, "Interpretation of tag", HFILL }},
10472
10473     {&tag_oui,
10474      {"OUI", "wlan_mgt.tag.oui",
10475       FT_BYTES, BASE_NONE, NULL, 0, "OUI of vendor specific IE", HFILL }},
10476
10477     {&tim_length,
10478      {"TIM length", "wlan_mgt.tim.length",
10479       FT_UINT8, BASE_DEC, NULL, 0,
10480       "Traffic Indication Map length", HFILL }},
10481
10482     {&tim_dtim_count,
10483      {"DTIM count", "wlan_mgt.tim.dtim_count",
10484       FT_UINT8, BASE_DEC, NULL, 0,
10485       "DTIM count", HFILL }},
10486
10487     {&tim_dtim_period,
10488      {"DTIM period", "wlan_mgt.tim.dtim_period",
10489       FT_UINT8, BASE_DEC, NULL, 0,
10490       "DTIM period", HFILL }},
10491
10492     {&tim_bmapctl,
10493      {"Bitmap control", "wlan_mgt.tim.bmapctl",
10494       FT_UINT8, BASE_HEX, NULL, 0,
10495       "Bitmap control", HFILL }},
10496
10497     {&rsn_cap,
10498      {"RSN Capabilities", "wlan_mgt.rsn.capabilities", FT_UINT16, BASE_HEX,
10499       NULL, 0, "RSN Capability information", HFILL }},
10500
10501     {&rsn_cap_preauth,
10502      {"RSN Pre-Auth capabilities", "wlan_mgt.rsn.capabilities.preauth",
10503       FT_BOOLEAN, 16, TFS (&rsn_preauth_flags), 0x0001,
10504       "RSN Pre-Auth capabilities", HFILL }},
10505
10506     {&rsn_cap_no_pairwise,
10507      {"RSN No Pairwise capabilities", "wlan_mgt.rsn.capabilities.no_pairwise",
10508       FT_BOOLEAN, 16, TFS (&rsn_no_pairwise_flags), 0x0002,
10509       "RSN No Pairwise capabilities", HFILL }},
10510
10511     {&rsn_cap_ptksa_replay_counter,
10512      {"RSN PTKSA Replay Counter capabilities",
10513       "wlan_mgt.rsn.capabilities.ptksa_replay_counter",
10514       FT_UINT16, BASE_HEX, VALS (&rsn_cap_replay_counter), 0x000C,
10515       "RSN PTKSA Replay Counter capabilities", HFILL }},
10516
10517     {&rsn_cap_gtksa_replay_counter,
10518      {"RSN GTKSA Replay Counter capabilities",
10519       "wlan_mgt.rsn.capabilities.gtksa_replay_counter",
10520       FT_UINT16, BASE_HEX, VALS (&rsn_cap_replay_counter), 0x0030,
10521       "RSN GTKSA Replay Counter capabilities", HFILL }},
10522
10523     {&ht_cap,
10524      {"HT Capabilities Info", "wlan_mgt.ht.capabilities", FT_UINT16, BASE_HEX,
10525       NULL, 0, "HT Capability information", HFILL }},
10526
10527     {&ht_vs_cap,
10528      {"HT Capabilities Info (VS)", "wlan_mgt.vs.ht.capabilities", FT_UINT16, BASE_HEX,
10529       NULL, 0, "Vendor Specific HT Capability information", HFILL }},
10530
10531     {&ht_ldpc_coding,
10532      {"HT LDPC coding capability", "wlan_mgt.ht.capabilities.ldpccoding",
10533       FT_BOOLEAN, 16, TFS (&ht_ldpc_coding_flag), 0x0001,
10534       "HT LDPC coding capability", HFILL }},
10535
10536     {&ht_chan_width,
10537      {"HT Support channel width", "wlan_mgt.ht.capabilities.width",
10538       FT_BOOLEAN, 16, TFS (&ht_chan_width_flag), 0x0002,
10539       "HT Support channel width", HFILL }},
10540
10541     {&ht_sm_pwsave,
10542      {"HT SM Power Save", "wlan_mgt.ht.capabilities.sm",
10543       FT_UINT16, BASE_HEX, VALS (&ht_sm_pwsave_flag), 0x000c,
10544       "HT SM Power Save", HFILL }},
10545
10546     {&ht_green,
10547      {"HT Green Field", "wlan_mgt.ht.capabilities.green",
10548       FT_BOOLEAN, 16, TFS (&ht_green_flag), 0x0010,
10549       "HT Green Field", HFILL }},
10550
10551     {&ht_short20,
10552      {"HT Short GI for 20MHz", "wlan_mgt.ht.capabilities.short20",
10553       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0020,
10554       "HT Short GI for 20MHz", HFILL }},
10555
10556     {&ht_short40,
10557      {"HT Short GI for 40MHz", "wlan_mgt.ht.capabilities.short40",
10558       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0040,
10559       "HT Short GI for 40MHz", HFILL }},
10560
10561     {&ht_tx_stbc,
10562      {"HT Tx STBC", "wlan_mgt.ht.capabilities.txstbc",
10563       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0080,
10564       "HT Tx STBC", HFILL }},
10565
10566     {&ht_rx_stbc,
10567      {"HT Rx STBC", "wlan_mgt.ht.capabilities.rxstbc",
10568       FT_UINT16, BASE_HEX, VALS (&ht_rx_stbc_flag), 0x0300,
10569       "HT Tx STBC", HFILL }},
10570
10571     {&ht_delayed_block_ack,
10572      {"HT Delayed Block ACK", "wlan_mgt.ht.capabilities.delayedblockack",
10573       FT_BOOLEAN, 16, TFS (&ht_delayed_block_ack_flag), 0x0400,
10574       "HT Delayed Block ACK", HFILL }},
10575
10576     {&ht_max_amsdu,
10577      {"HT Max A-MSDU length", "wlan_mgt.ht.capabilities.amsdu",
10578       FT_BOOLEAN, 16, TFS (&ht_max_amsdu_flag), 0x0800,
10579       "HT Max A-MSDU length", HFILL }},
10580
10581     {&ht_dss_cck_40,
10582      {"HT DSSS/CCK mode in 40MHz", "wlan_mgt.ht.capabilities.dsscck",
10583       FT_BOOLEAN, 16, TFS (&ht_dss_cck_40_flag), 0x1000,
10584       "HT DSS/CCK mode in 40MHz", HFILL }},
10585
10586     {&ht_psmp,
10587      {"HT PSMP Support", "wlan_mgt.ht.capabilities.psmp",
10588       FT_BOOLEAN, 16, TFS (&ht_psmp_flag), 0x2000,
10589       "HT PSMP Support", HFILL }},
10590
10591     {&ht_40_mhz_intolerant,
10592      {"HT Forty MHz Intolerant", "wlan_mgt.ht.capabilities.40mhzintolerant",
10593       FT_BOOLEAN, 16, TFS (&ht_40_mhz_intolerant_flag), 0x4000,
10594       "HT Forty MHz Intolerant", HFILL }},
10595
10596     {&ht_l_sig,
10597      {"HT L-SIG TXOP Protection support", "wlan_mgt.ht.capabilities.lsig",
10598       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x8000,
10599       "HT L-SIG TXOP Protection support", HFILL }},
10600
10601     {&ampduparam,
10602      {"A-MPDU Parameters", "wlan_mgt.ht.ampduparam", FT_UINT16, BASE_HEX,
10603       NULL, 0, "A-MPDU Parameters", HFILL }},
10604
10605     {&ampduparam_vs,
10606      {"A-MPDU Parameters (VS)", "wlan_mgt.vs.ht.ampduparam", FT_UINT16, BASE_HEX,
10607       NULL, 0, "Vendor Specific A-MPDU Parameters", HFILL }},
10608
10609     {&ampduparam_mpdu,
10610      {"Maximum Rx A-MPDU Length", "wlan_mgt.ht.ampduparam.maxlength",
10611       FT_UINT8, BASE_HEX, 0 , 0x03,
10612       "Maximum Rx A-MPDU Length", HFILL }},
10613
10614     {&ampduparam_mpdu_start_spacing,
10615      {"MPDU Density", "wlan_mgt.ht.ampduparam.mpdudensity",
10616       FT_UINT8, BASE_HEX, VALS (&ampduparam_mpdu_start_spacing_flags) , 0x1c,
10617       "MPDU Density", HFILL }},
10618
10619     {&ampduparam_reserved,
10620      {"Reserved", "wlan_mgt.ht.ampduparam.reserved",
10621       FT_UINT8, BASE_HEX, NULL, 0xE0,
10622       "Reserved", HFILL }},
10623
10624     {&mcsset,
10625      {"Rx Supported Modulation and Coding Scheme Set", "wlan_mgt.ht.mcsset",
10626       FT_STRING, BASE_NONE, NULL, 0, "Rx Supported Modulation and Coding Scheme Set", HFILL }},
10627
10628     {&mcsset_vs,
10629      {"Rx Supported Modulation and Coding Scheme Set (VS)", "wlan_mgt.vs.ht.mcsset",
10630       FT_STRING, BASE_NONE, NULL, 0, "Vendor Specific Rx Supported Modulation and Coding Scheme Set", HFILL }},
10631
10632     {&mcsset_rx_bitmask_0to7,
10633      {"Rx Bitmask Bits 0-7", "wlan_mgt.ht.mcsset.rxbitmask.0to7",
10634       FT_UINT32, BASE_HEX, 0, 0x000000ff, "Rx Bitmask Bits 0-7", HFILL }},
10635
10636     {&mcsset_rx_bitmask_8to15,
10637      {"Rx Bitmask Bits 8-15", "wlan_mgt.ht.mcsset.rxbitmask.8to15",
10638       FT_UINT32, BASE_HEX, 0, 0x0000ff00, "Rx Bitmask Bits 8-15", HFILL }},
10639
10640     {&mcsset_rx_bitmask_16to23,
10641      {"Rx Bitmask Bits 16-23", "wlan_mgt.ht.mcsset.rxbitmask.16to23",
10642       FT_UINT32, BASE_HEX, 0, 0x00ff0000, "Rx Bitmask Bits 16-23", HFILL }},
10643
10644     {&mcsset_rx_bitmask_24to31,
10645      {"Rx Bitmask Bits 24-31", "wlan_mgt.ht.mcsset.rxbitmask.24to31",
10646       FT_UINT32, BASE_HEX, 0, 0xff000000, "Rx Bitmask Bits 24-31", HFILL }},
10647
10648     {&mcsset_rx_bitmask_32,
10649      {"Rx Bitmask Bit 32", "wlan_mgt.ht.mcsset.rxbitmask.32",
10650       FT_UINT32, BASE_HEX, 0, 0x000001, "Rx Bitmask Bit 32", HFILL }},
10651
10652     {&mcsset_rx_bitmask_33to38,
10653      {"Rx Bitmask Bits 33-38", "wlan_mgt.ht.mcsset.rxbitmask.33to38",
10654       FT_UINT32, BASE_HEX, 0, 0x00007e, "Rx Bitmask Bits 33-38", HFILL }},
10655
10656     {&mcsset_rx_bitmask_39to52,
10657      {"Rx Bitmask Bits 39-52", "wlan_mgt.ht.mcsset.rxbitmask.39to52",
10658       FT_UINT32, BASE_HEX, 0, 0x1fff80, "Rx Bitmask Bits 39-52", HFILL }},
10659
10660     {&mcsset_rx_bitmask_53to76,
10661      {"Rx Bitmask Bits 53-76", "wlan_mgt.ht.mcsset.rxbitmask.53to76",
10662       FT_UINT32, BASE_HEX, 0, 0x1fffffe0, "Rx Bitmask Bits 53-76", HFILL }},
10663
10664     {&mcsset_highest_data_rate,
10665      {"Highest Supported Data Rate", "wlan_mgt.ht.mcsset.highestdatarate",
10666       FT_UINT16, BASE_HEX, 0, 0x03ff, "Highest Supported Data Rate", HFILL }},
10667
10668     {&mcsset_tx_mcs_set_defined,
10669      {"Tx Supported MCS Set", "wlan_mgt.ht.mcsset.txsetdefined",
10670       FT_BOOLEAN, 16, TFS (&mcsset_tx_mcs_set_defined_flag), 0x0001,
10671       "Tx Supported MCS Set", HFILL }},
10672
10673     {&mcsset_tx_rx_mcs_set_not_equal,
10674      {"Tx and Rx MCS Set", "wlan_mgt.ht.mcsset.txrxmcsnotequal",
10675       FT_BOOLEAN, 16, TFS (&mcsset_tx_rx_mcs_set_not_equal_flag), 0x0002,
10676       "Tx and Rx MCS Set", HFILL }},
10677
10678     {&mcsset_tx_max_spatial_streams,
10679      {"Tx Maximum Number of Spatial Streams Supported", "wlan_mgt.ht.mcsset.txmaxss",
10680       FT_UINT16, BASE_HEX, VALS (&mcsset_tx_max_spatial_streams_flags) , 0x000c,
10681       "Tx Maximum Number of Spatial Streams Supported", HFILL }},
10682
10683     {&mcsset_tx_unequal_modulation,
10684      {"Unequal Modulation", "wlan_mgt.ht.mcsset.txunequalmod",
10685       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0010,
10686       "Unequal Modulation", HFILL }},
10687
10688     {&htex_cap,
10689      {"HT Extended Capabilities", "wlan_mgt.htex.capabilities", FT_UINT16, BASE_HEX,
10690       NULL, 0, "HT Extended Capability information", HFILL }},
10691
10692     {&htex_vs_cap,
10693      {"HT Extended Capabilities (VS)", "wlan_mgt.vs.htex.capabilities", FT_UINT16, BASE_HEX,
10694       NULL, 0, "Vendor Specific HT Extended Capability information", HFILL }},
10695
10696     {&htex_pco,
10697      {"Transmitter supports PCO", "wlan_mgt.htex.capabilities.pco",
10698       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0001,
10699       "Transmitter supports PCO", HFILL }},
10700
10701     {&htex_transtime,
10702      {"Time needed to transition between 20MHz and 40MHz", "wlan_mgt.htex.capabilities.transtime",
10703       FT_UINT16, BASE_HEX, VALS (&htex_transtime_flags), 0x0006,
10704       "Time needed to transition between 20MHz and 40MHz", HFILL }},
10705
10706     {&htex_mcs,
10707      {"MCS Feedback capability", "wlan_mgt.htex.capabilities.mcs",
10708       FT_UINT16, BASE_HEX, VALS (&htex_mcs_flags), 0x0300,
10709       "MCS Feedback capability", HFILL }},
10710
10711     {&htex_htc_support,
10712      {"High Throughput", "wlan_mgt.htex.capabilities.htc",
10713       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0400,
10714       "High Throughput", HFILL }},
10715
10716     {&htex_rd_responder,
10717      {"Reverse Direction Responder", "wlan_mgt.htex.capabilities.rdresponder",
10718       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0800,
10719       "Reverse Direction Responder", HFILL }},
10720
10721     {&txbf,
10722      {"Transmit Beam Forming (TxBF) Capabilities", "wlan_mgt.txbf", FT_UINT16, BASE_HEX,
10723       NULL, 0, "Transmit Beam Forming (TxBF) Capabilities", HFILL }},
10724
10725     {&txbf_vs,
10726      {"Transmit Beam Forming (TxBF) Capabilities (VS)", "wlan_mgt.vs.txbf", FT_UINT16, BASE_HEX,
10727       NULL, 0, "Vendor Specific Transmit Beam Forming (TxBF) Capabilities", HFILL }},
10728
10729     {&txbf_cap,
10730      {"Transmit Beamforming", "wlan_mgt.txbf.txbf",
10731       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000001,
10732       "Transmit Beamforming", HFILL }},
10733
10734     {&txbf_rcv_ssc,
10735      {"Receive Staggered Sounding", "wlan_mgt.txbf.rxss",
10736       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000002,
10737       "Receive Staggered Sounding", HFILL }},
10738
10739     {&txbf_tx_ssc,
10740      {"Transmit Staggered Sounding", "wlan_mgt.txbf.txss",
10741       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000004,
10742       "Transmit staggered sounding", HFILL }},
10743
10744     {&txbf_rcv_ndp,
10745      {"Receive Null Data packet (NDP)", "wlan_mgt.txbf.rxndp",
10746       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000008,
10747       "Receive Null Data packet (NDP)", HFILL }},
10748
10749     {&txbf_tx_ndp,
10750      {"Transmit Null Data packet (NDP)", "wlan_mgt.txbf.txndp",
10751       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000010,
10752       "Transmit Null Data packet (NDP)", HFILL }},
10753
10754     {&txbf_impl_txbf,
10755      {"Implicit TxBF capable", "wlan_mgt.txbf.impltxbf",
10756       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000020,
10757       "Implicit Transmit Beamforming (TxBF) capable", HFILL }},
10758
10759     {&txbf_calib,
10760      {"Calibration", "wlan_mgt.txbf.calibration",
10761       FT_UINT32, BASE_HEX, VALS (&txbf_calib_flag), 0x000000c0,
10762       "Calibration", HFILL }},
10763
10764     {&txbf_expl_csi,
10765      {"STA can apply TxBF using CSI explicit feedback", "wlan_mgt.txbf.csi",
10766       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000100,
10767       "Station can apply TxBF using CSI explicit feedback", HFILL }},
10768
10769     {&txbf_expl_uncomp_fm,
10770      {"STA can apply TxBF using uncompressed beamforming feedback matrix", "wlan_mgt.txbf.fm.uncompressed.tbf",
10771       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000200,
10772       "Station can apply TxBF using uncompressed beamforming feedback matrix", HFILL }},
10773
10774     {&txbf_expl_comp_fm,
10775      {"STA can apply TxBF using compressed beamforming feedback matrix", "wlan_mgt.txbf.fm.compressed.tbf",
10776       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000400,
10777       "Station can apply TxBF using compressed beamforming feedback matrix", HFILL }},
10778
10779     {&txbf_expl_bf_csi,
10780      {"Receiver can return explicit CSI feedback", "wlan_mgt.txbf.rcsi",
10781       FT_UINT32, BASE_HEX, VALS (&txbf_feedback_flags), 0x00001800,
10782       "Receiver can return explicit CSI feedback", HFILL }},
10783
10784     {&txbf_expl_uncomp_fm_feed,
10785      {"Receiver can return explicit uncompressed Beamforming Feedback Matrix", "wlan_mgt.txbf.fm.uncompressed.rbf",
10786       FT_UINT32, BASE_HEX, VALS (&txbf_feedback_flags), 0x00006000,
10787       "Receiver can return explicit uncompressed Beamforming Feedback Matrix", HFILL }},
10788
10789     {&txbf_expl_comp_fm_feed,
10790      {"STA can compress and use compressed Beamforming Feedback Matrix", "wlan_mgt.txbf.fm.compressed.bf",
10791       FT_UINT32, BASE_HEX, VALS (&txbf_feedback_flags), 0x00018000,
10792       "Station can compress and use compressed Beamforming Feedback Matrix", HFILL }},
10793
10794     {&txbf_min_group,
10795      {"Minimal grouping used for explicit feedback reports", "wlan_mgt.txbf.mingroup",
10796       FT_UINT32, BASE_HEX, VALS (&txbf_min_group_flags), 0x00060000,
10797       "Minimal grouping used for explicit feedback reports", HFILL }},
10798
10799     {&txbf_csi_num_bf_ant,
10800      {"Max antennae STA can support when CSI feedback required", "wlan_mgt.txbf.csinumant",
10801       FT_UINT32, BASE_HEX, VALS (&txbf_antenna_flags), 0x00180000,
10802       "Max antennae station can support when CSI feedback required", HFILL }},
10803
10804     {&txbf_uncomp_sm_bf_ant,
10805      {"Max antennae STA can support when uncompressed Beamforming feedback required", "wlan_mgt.txbf.fm.uncompressed.maxant",
10806       FT_UINT32, BASE_HEX, VALS (&txbf_antenna_flags), 0x00600000,
10807       "Max antennae station can support when uncompressed Beamforming feedback required", HFILL }},
10808
10809     {&txbf_comp_sm_bf_ant,
10810      {"Max antennae STA can support when compressed Beamforming feedback required", "wlan_mgt.txbf.fm.compressed.maxant",
10811       FT_UINT32, BASE_HEX, VALS (&txbf_antenna_flags), 0x01800000,
10812       "Max antennae station can support when compressed Beamforming feedback required", HFILL }},
10813
10814     {&txbf_csi_max_rows_bf,
10815      {"Maximum number of rows of CSI explicit feedback", "wlan_mgt.txbf.csi.maxrows",
10816       FT_UINT32, BASE_HEX, VALS (&txbf_csi_max_rows_bf_flags), 0x06000000,
10817       "Maximum number of rows of CSI explicit feedback", HFILL }},
10818
10819     {&txbf_chan_est,
10820      {"Maximum number of space time streams for which channel dimensions can be simultaneously estimated", "wlan_mgt.txbf.channelest",
10821       FT_UINT32, BASE_HEX, VALS (&txbf_chan_est_flags), 0x18000000,
10822       "Maximum number of space time streams for which channel dimensions can be simultaneously estimated", HFILL }},
10823
10824     {&txbf_resrv,
10825      {"Reserved", "wlan_mgt.txbf.reserved",
10826       FT_UINT32, BASE_HEX, NULL, 0xe0000000,
10827       "Reserved", HFILL }},
10828
10829     {&hta_cap,
10830      {"HT Additional Capabilities", "wlan_mgt.hta.capabilities", FT_UINT16, BASE_HEX,
10831       NULL, 0, "HT Additional Capability information", HFILL }},
10832
10833     {&hta_ext_chan_offset,
10834      {"Extension Channel Offset", "wlan_mgt.hta.capabilities.extchan",
10835       FT_UINT16, BASE_HEX, VALS (&hta_ext_chan_offset_flag), 0x0003,
10836       "Extension Channel Offset", HFILL }},
10837
10838     {&hta_rec_tx_width,
10839      {"Recommended Tx Channel Width", "wlan_mgt.hta.capabilities.rectxwidth",
10840       FT_BOOLEAN, 16, TFS (&hta_rec_tx_width_flag), 0x0004,
10841       "Recommended Transmit Channel Width", HFILL }},
10842
10843     {&hta_rifs_mode,
10844      {"Reduced Interframe Spacing (RIFS) Mode", "wlan_mgt.hta.capabilities.rifsmode",
10845       FT_BOOLEAN, 16, TFS (&hta_rifs_mode_flag), 0x0008,
10846       "Reduced Interframe Spacing (RIFS) Mode", HFILL }},
10847
10848     {&hta_controlled_access,
10849      {"Controlled Access Only", "wlan_mgt.hta.capabilities.controlledaccess",
10850       FT_BOOLEAN, 16, TFS (&hta_controlled_access_flag), 0x0010,
10851       "Controlled Access Only", HFILL }},
10852
10853     {&hta_service_interval,
10854      {"Service Interval Granularity", "wlan_mgt.hta.capabilities.serviceinterval",
10855       FT_UINT16, BASE_HEX, VALS (&hta_service_interval_flag), 0x00E0,
10856       "Service Interval Granularity", HFILL }},
10857
10858     {&hta_operating_mode,
10859      {"Operating Mode", "wlan_mgt.hta.capabilities.operatingmode",
10860       FT_UINT16, BASE_HEX, VALS (&hta_operating_mode_flag), 0x0003,
10861       "Operating Mode", HFILL }},
10862
10863     {&hta_non_gf_devices,
10864      {"Non Greenfield (GF) devices Present", "wlan_mgt.hta.capabilities.nongfdevices",
10865       FT_BOOLEAN, 16, TFS (&hta_non_gf_devices_flag), 0x0004,
10866       "on Greenfield (GF) devices Present", HFILL }},
10867
10868     {&hta_basic_stbc_mcs,
10869      {"Basic STB Modulation and Coding Scheme (MCS)", "wlan_mgt.hta.capabilities.",
10870       FT_UINT16, BASE_HEX, NULL , 0x007f,
10871       "Basic STB Modulation and Coding Scheme (MCS)", HFILL }},
10872
10873     {&hta_dual_stbc_protection,
10874      {"Dual Clear To Send (CTS) Protection", "wlan_mgt.hta.capabilities.",
10875       FT_BOOLEAN, 16, TFS (&hta_dual_stbc_protection_flag), 0x0080,
10876       "Dual Clear To Send (CTS) Protection", HFILL }},
10877
10878     {&hta_secondary_beacon,
10879      {"Secondary Beacon", "wlan_mgt.hta.capabilities.",
10880       FT_BOOLEAN, 16, TFS (&hta_secondary_beacon_flag), 0x0100,
10881       "Secondary Beacon", HFILL }},
10882
10883     {&hta_lsig_txop_protection,
10884      {"L-SIG TXOP Protection Support", "wlan_mgt.hta.capabilities.",
10885       FT_BOOLEAN, 16, TFS (&hta_lsig_txop_protection_flag), 0x0200,
10886       "L-SIG TXOP Protection Support", HFILL }},
10887
10888     {&hta_pco_active,
10889      {"Phased Coexistence Operation (PCO) Active", "wlan_mgt.hta.capabilities.",
10890       FT_BOOLEAN, 16, TFS (&hta_pco_active_flag), 0x0400,
10891       "Phased Coexistence Operation (PCO) Active", HFILL }},
10892
10893     {&hta_pco_phase,
10894      {"Phased Coexistence Operation (PCO) Phase", "wlan_mgt.hta.capabilities.",
10895       FT_BOOLEAN, 16, TFS (&hta_pco_phase_flag), 0x0800,
10896       "Phased Coexistence Operation (PCO) Phase", HFILL }},
10897
10898     {&antsel,
10899      {"Antenna Selection (ASEL) Capabilities", "wlan_mgt.asel",
10900       FT_UINT8, BASE_HEX, NULL, 0, "Antenna Selection (ASEL) Capabilities", HFILL }},
10901
10902     {&antsel_vs,
10903      {"Antenna Selection (ASEL) Capabilities (VS)", "wlan_mgt.vs.asel",
10904       FT_UINT8, BASE_HEX, NULL, 0, "Vendor Specific Antenna Selection (ASEL) Capabilities", HFILL }},
10905
10906     {&antsel_b0,
10907      {"Antenna Selection Capable", "wlan_mgt.asel.capable",
10908       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x01, "Antenna Selection Capable", HFILL }},
10909
10910     {&antsel_b1,
10911      {"Explicit CSI Feedback Based Tx ASEL", "wlan_mgt.asel.txcsi",
10912       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x02, "Explicit CSI Feedback Based Tx ASEL", HFILL }},
10913
10914     {&antsel_b2,
10915      {"Antenna Indices Feedback Based Tx ASEL", "wlan_mgt.asel.txif",
10916       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x04, "Antenna Indices Feedback Based Tx ASEL", HFILL }},
10917
10918     {&antsel_b3,
10919      {"Explicit CSI Feedback", "wlan_mgt.asel.csi",
10920       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x08, "Explicit CSI Feedback", HFILL }},
10921
10922     {&antsel_b4,
10923      {"Antenna Indices Feedback", "wlan_mgt.asel.if",
10924       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x10, "Antenna Indices Feedback", HFILL }},
10925
10926     {&antsel_b5,
10927      {"Rx ASEL", "wlan_mgt.asel.rx",
10928       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x20, "Rx ASEL", HFILL }},
10929
10930     {&antsel_b6,
10931      {"Tx Sounding PPDUs", "wlan_mgt.asel.sppdu",
10932       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x40, "Tx Sounding PPDUs", HFILL }},
10933
10934     {&antsel_b7,
10935      {"Reserved", "wlan_mgt.asel.reserved",
10936       FT_UINT8, BASE_HEX, NULL, 0x80, "Reserved", HFILL }},
10937
10938     {&ht_info_delimiter1,
10939      {"HT Information Delimiter #1", "wlan_mgt.ht.info.delim1",
10940       FT_UINT8, BASE_HEX, NULL, 0xff, "HT Information Delimiter #1", HFILL }},
10941
10942     {&ht_info_primary_channel,
10943      {"Primary Channel", "wlan_mgt.ht.info.primarychannel",
10944       FT_UINT8, BASE_DEC, NULL, 0, "Primary Channel", HFILL }},
10945
10946     {&ht_info_secondary_channel_offset,
10947      {"Secondary channel offset", "wlan_mgt.ht.info.secchanoffset",
10948       FT_UINT8, BASE_HEX, VALS (&ht_info_secondary_channel_offset_flags), 0x03, "Secondary channel offset", HFILL }},
10949
10950     {&ht_info_channel_width,
10951      {"Supported channel width", "wlan_mgt.ht.info.chanwidth",
10952       FT_BOOLEAN, 8, TFS (&ht_info_channel_width_flag), 0x04, "Supported channel width", HFILL }},
10953
10954     {&ht_info_rifs_mode,
10955      {"Reduced Interframe Spacing (RIFS)", "wlan_mgt.ht.info.rifs",
10956       FT_BOOLEAN, 8, TFS (&ht_info_rifs_mode_flag), 0x08, "Reduced Interframe Spacing (RIFS)", HFILL }},
10957
10958     {&ht_info_psmp_stas_only,
10959      {"Power Save Multi-Poll (PSMP) stations only", "wlan_mgt.ht.info.psmponly",
10960       FT_BOOLEAN, 8, TFS (&ht_info_psmp_stas_only_flag), 0x10, "Power Save Multi-Poll (PSMP) stations only", HFILL }},
10961
10962     {&ht_info_service_interval_granularity,
10963      {"Shortest service interval", "wlan_mgt.ht.info.",
10964       FT_UINT8, BASE_HEX, VALS (&ht_info_service_interval_granularity_flags), 0xe0, "Shortest service interval", HFILL }},
10965
10966     {&ht_info_delimiter2,
10967      {"HT Information Delimiter #2", "wlan_mgt.ht.info.delim2",
10968       FT_UINT16, BASE_HEX, NULL, 0xffff, "HT Information Delimiter #2", HFILL }},
10969
10970     {&ht_info_operating_mode,
10971      {"Operating mode of BSS", "wlan_mgt.ht.info.operatingmode",
10972       FT_UINT16, BASE_HEX, VALS (&ht_info_operating_mode_flags), 0x0003, "Operating mode of BSS", HFILL }},
10973
10974     {&ht_info_non_greenfield_sta_present,
10975      {"Non-greenfield STAs present", "wlan_mgt.ht.info.greenfield",
10976       FT_BOOLEAN, 16, TFS (&ht_info_non_greenfield_sta_present_flag), 0x0004, "Non-greenfield STAs present", HFILL }},
10977
10978     {&ht_info_transmit_burst_limit,
10979      {"Transmit burst limit", "wlan_mgt.ht.info.burstlim",
10980       FT_BOOLEAN, 16, TFS (&ht_info_transmit_burst_limit_flag), 0x0008, "Transmit burst limit", HFILL }},
10981
10982     {&ht_info_obss_non_ht_stas_present,
10983      {"OBSS non-HT STAs present", "wlan_mgt.ht.info.obssnonht",
10984       FT_BOOLEAN, 16, TFS (&ht_info_obss_non_ht_stas_present_flag), 0x0010, "OBSS non-HT STAs present", HFILL }},
10985
10986     {&ht_info_reserved_1,
10987      {"Reserved", "wlan_mgt.ht.info.reserved1",
10988       FT_UINT16, BASE_HEX, NULL, 0xffe0, "Reserved", HFILL }},
10989
10990     {&ht_info_delimiter3,
10991      {"HT Information Delimiter #3", "wlan_mgt.ht.info.delim3",
10992       FT_UINT16, BASE_HEX, NULL, 0xffff, "HT Information Delimiter #3", HFILL }},
10993
10994     {&ht_info_reserved_2,
10995      {"Reserved", "wlan_mgt.ht.info.reserved2",
10996       FT_UINT16, BASE_HEX, NULL, 0x003f, "Reserved", HFILL }},
10997
10998     {&ht_info_dual_beacon,
10999      {"Dual beacon", "wlan_mgt.ht.info.dualbeacon",
11000       FT_BOOLEAN, 16, TFS (&ht_info_dual_beacon_flag), 0x0040, "Dual beacon", HFILL }},
11001
11002     {&ht_info_dual_cts_protection,
11003      {"Dual Clear To Send (CTS) protection", "wlan_mgt.ht.info.dualcts",
11004       FT_BOOLEAN, 16, TFS (&ht_info_dual_cts_protection_flag), 0x0080, "Dual Clear To Send (CTS) protection", HFILL }},
11005
11006     {&ht_info_secondary_beacon,
11007      {"Beacon ID", "wlan_mgt.ht.info.secondarybeacon",
11008       FT_BOOLEAN, 16, TFS (&ht_info_secondary_beacon_flag), 0x0100, "Beacon ID", HFILL }},
11009
11010     {&ht_info_lsig_txop_protection_full_support,
11011      {"L-SIG TXOP Protection Full Support", "wlan_mgt.ht.info.lsigprotsupport",
11012       FT_BOOLEAN, 16, TFS (&ht_info_lsig_txop_protection_full_support_flag), 0x0200, "L-SIG TXOP Protection Full Support", HFILL }},
11013
11014     {&ht_info_pco_active,
11015      {"Phased Coexistence Operation (PCO)", "wlan_mgt.ht.info.pco.active",
11016       FT_BOOLEAN, 16, TFS (&ht_info_pco_active_flag), 0x0400, "Phased Coexistence Operation (PCO)", HFILL }},
11017
11018     {&ht_info_pco_phase,
11019      {"Phased Coexistence Operation (PCO) Phase", "wlan_mgt.ht.info.pco.phase",
11020       FT_BOOLEAN, 16, TFS (&ht_info_pco_phase_flag), 0x0800, "Phased Coexistence Operation (PCO) Phase", HFILL }},
11021
11022     {&ht_info_reserved_3,
11023      {"Reserved", "wlan_mgt.ht.info.reserved3",
11024       FT_UINT16, BASE_HEX, NULL, 0xf000, "Reserved", HFILL }},
11025
11026     {&hf_tag_secondary_channel_offset,
11027      {"Secondary Channel Offset", "wlan_mgt.secchanoffset",
11028       FT_UINT8, BASE_HEX, VALS (&hf_tag_secondary_channel_offset_flags), 0,
11029       "Secondary Channel Offset", HFILL }},
11030
11031     /*** Begin: Power Capability Tag - Dustin Johnson ***/
11032     {&hf_tag_power_capability_min,
11033      {"Minimum Transmit Power", "wlan_mgt.powercap.min",
11034       FT_UINT8, BASE_HEX, NULL, 0, "Minimum Transmit Power", HFILL }},
11035
11036     {&hf_tag_power_capability_max,
11037      {"Maximum Transmit Power", "wlan_mgt.powercap.max",
11038       FT_UINT8, BASE_HEX, NULL, 0, "Maximum Transmit Power", HFILL }},
11039     /*** End: Power Capability Tag - Dustin Johnson ***/
11040     {&hf_tag_tpc_report_trsmt_pow,
11041      {"Transmit Power", "wlan_mgt.tcprep.trsmt_pow",
11042       FT_INT8, BASE_DEC, NULL, 0, "Transmit Power", HFILL }},
11043     {&hf_tag_tpc_report_link_mrg,
11044      {"Link Margin", "wlan_mgt.tcprep.link_mrg",
11045       FT_INT8, BASE_DEC, NULL, 0, "Link Margin", HFILL }},
11046     /*** Begin: Supported Channels Tag - Dustin Johnson ***/
11047     {&hf_tag_supported_channels,
11048      {"Supported Channels Set", "wlan_mgt.supchan",
11049       FT_UINT8, BASE_DEC, NULL, 0, "Supported Channels Set", HFILL }},
11050
11051     {&hf_tag_supported_channels_first,
11052      {"First Supported Channel", "wlan_mgt.supchan.first",
11053       FT_UINT8, BASE_HEX, NULL, 0, "First Supported Channel", HFILL }},
11054
11055     {&hf_tag_supported_channels_range,
11056      {"Supported Channel Range", "wlan_mgt.supchan.range",
11057       FT_UINT8, BASE_HEX, NULL, 0, "Supported Channel Range", HFILL }},
11058     /*** End: Supported Channels Tag - Dustin Johnson ***/
11059
11060     /*** Start: Measurement Request Tag  - Dustin Johnson***/
11061     {&hf_tag_measure_request_measurement_token,
11062      {"Measurement Token", "wlan_mgt.measure.req.measuretoken",
11063       FT_UINT8, BASE_HEX, NULL, 0xff, "Measurement Token", HFILL }},
11064
11065     {&hf_tag_measure_request_mode,
11066      {"Measurement Request Mode", "wlan_mgt.measure.req.reqmode",
11067       FT_UINT8, BASE_HEX, NULL, 0xff, "Measurement Request Mode", HFILL }},
11068
11069     {&hf_tag_measure_request_mode_reserved1,
11070      {"Reserved", "wlan_mgt.measure.req.reqmode.reserved1",
11071       FT_UINT8, BASE_HEX, NULL, 0x01, "Reserved", HFILL }},
11072
11073     {&hf_tag_measure_request_mode_enable,
11074      {"Measurement Request Mode Field", "wlan_mgt.measure.req.reqmode.enable",
11075       FT_BOOLEAN, 8, TFS (&hf_tag_measure_enable_flag), 0x02, "Measurement Request Mode Field", HFILL }},
11076
11077     {&hf_tag_measure_request_mode_request,
11078      {"Measurement Reports", "wlan_mgt.measure.req.reqmode.request",
11079       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x04, "Measurement Reports", HFILL }},
11080
11081     {&hf_tag_measure_request_mode_report,
11082      {"Autonomous Measurement Reports", "wlan_mgt.measure.req.reqmode.report",
11083       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x08, "Autonomous Measurement Reports", HFILL }},
11084
11085     {&hf_tag_measure_request_mode_reserved2,
11086      {"Reserved", "wlan_mgt.measure.req.reqmode.reserved2",
11087       FT_UINT8, BASE_HEX, NULL, 0xf0, "Reserved", HFILL }},
11088
11089     {&hf_tag_measure_request_type,
11090      {"Measurement Request Type", "wlan_mgt.measure.req.reqtype",
11091       FT_UINT8, BASE_HEX, VALS (&hf_tag_measure_request_type_flags), 0x00, "Measurement Request Type", HFILL }},
11092
11093     {&hf_tag_measure_request_channel_number,
11094      {"Measurement Channel Number", "wlan_mgt.measure.req.channelnumber",
11095       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Channel Number", HFILL }},
11096
11097     {&hf_tag_measure_request_start_time,
11098      {"Measurement Start Time", "wlan_mgt.measure.req.starttime",
11099       FT_UINT64, BASE_HEX, NULL, 0, "Measurement Start Time", HFILL }},
11100
11101     {&hf_tag_measure_request_duration,
11102      {"Measurement Duration", "wlan_mgt.measure.req.channelnumber",
11103       FT_UINT16, BASE_HEX, NULL, 0, "Measurement Duration", HFILL }},
11104
11105     {&hf_tag_measure_request_regulatory_class,
11106      {"Measurement Channel Number", "wlan_mgt.measure.req.regclass",
11107       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Channel Number", HFILL }},
11108
11109     {&hf_tag_measure_request_randomization_interval,
11110      {"Randomization Interval", "wlan_mgt.measure.req.randint",
11111       FT_UINT16, BASE_HEX, NULL, 0, "Randomization Interval", HFILL }},
11112
11113     {&hf_tag_measure_request_measurement_mode,
11114      {"Measurement Mode", "wlan_mgt.measure.req.measurementmode",
11115       FT_UINT8, BASE_HEX, VALS(&hf_tag_measure_request_measurement_mode_flags), 0, "Measurement Mode", HFILL }},
11116
11117     {&hf_tag_measure_request_bssid,
11118      {"BSSID", "wlan_mgt.measure.req.bssid",
11119       FT_ETHER, BASE_NONE, NULL, 0, "BSSID", HFILL }},
11120
11121     {&hf_tag_measure_request_reporting_condition,
11122      {"Reporting Condition", "wlan_mgt.measure.req.repcond",
11123       FT_UINT8, BASE_HEX, VALS(&hf_tag_measure_request_reporting_condition_flags), 0, "Reporting Condition", HFILL }},
11124
11125     {&hf_tag_measure_request_threshold_offset_unsigned,
11126      {"Threshold/Offset", "wlan_mgt.measure.req.threshold",
11127       FT_UINT8, BASE_HEX, 0, 0, "Threshold/Offset", HFILL }},
11128
11129     {&hf_tag_measure_request_threshold_offset_signed,
11130      {"Threshold/Offset", "wlan_mgt.measure.req.threshold",
11131       FT_UINT8, BASE_HEX, 0, 0, "Threshold/Offset", HFILL }},
11132
11133     {&hf_tag_measure_request_report_mac,
11134      {"MAC on wich to gather data", "wlan_mgt.measure.req.reportmac",
11135       FT_ETHER, BASE_NONE, NULL, 0, "MAC on wich to gather data", HFILL }},
11136
11137     {&hf_tag_measure_request_group_id,
11138      {"Group ID", "wlan_mgt.measure.req.groupid",
11139       FT_UINT8, BASE_HEX, VALS(&hf_tag_measure_request_group_id_flags), 0, "Group ID", HFILL }},
11140     /*** End: Measurement Request Tag  - Dustin Johnson***/
11141
11142     /*** Start: Measurement Report Tag  - Dustin Johnson***/
11143     {&hf_tag_measure_report_measurement_token,
11144      {"Measurement Token", "wlan_mgt.measure.req.clr",
11145       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Token", HFILL }},
11146
11147     {&hf_tag_measure_report_mode,
11148      {"Measurement Report Mode", "wlan_mgt.measure.req.clr",
11149       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Report Mode", HFILL }},
11150
11151     {&hf_tag_measure_report_mode_late,
11152      {"Measurement Report Mode Field", "wlan_mgt.measure.rep.repmode.late",
11153       FT_BOOLEAN, 8, TFS (&hf_tag_measure_enable_flag), 0x01, "Measurement Report Mode Field", HFILL }},
11154
11155     {&hf_tag_measure_report_mode_incapable,
11156      {"Measurement Reports", "wlan_mgt.measure.rep.repmode.incapable",
11157       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x02, "Measurement Reports", HFILL }},
11158
11159     {&hf_tag_measure_report_mode_refused,
11160      {"Autonomous Measurement Reports", "wlan_mgt.measure.rep.repmode.refused",
11161       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x04, "Autonomous Measurement Reports", HFILL }},
11162
11163     {&hf_tag_measure_report_mode_reserved,
11164      {"Reserved", "wlan_mgt.measure.rep.repmode.reserved",
11165       FT_UINT8, BASE_HEX, NULL, 0xf8, "Reserved", HFILL }},
11166
11167     {&hf_tag_measure_report_type,
11168      {"Measurement Report Type", "wlan_mgt.measure.rep.reptype",
11169       FT_UINT8, BASE_HEX, VALS (&hf_tag_measure_report_type_flags), 0x00, "Measurement Report Type", HFILL }},
11170
11171     {&hf_tag_measure_report_channel_number,
11172      {"Measurement Channel Number", "wlan_mgt.measure.rep.channelnumber",
11173       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Channel Number", HFILL }},
11174
11175     {&hf_tag_measure_report_start_time,
11176      {"Measurement Start Time", "wlan_mgt.measure.rep.starttime",
11177       FT_UINT64, BASE_HEX, NULL, 0, "Measurement Start Time", HFILL }},
11178
11179     {&hf_tag_measure_report_duration,
11180      {"Measurement Duration", "wlan_mgt.measure.rep.channelnumber",
11181       FT_UINT16, BASE_HEX, NULL, 0, "Measurement Duration", HFILL }},
11182
11183     {&hf_tag_measure_cca_busy_fraction,
11184      {"CCA Busy Fraction", "wlan_mgt.measure.rep.ccabusy",
11185       FT_UINT8, BASE_HEX, NULL, 0, "CCA Busy Fraction", HFILL }},
11186
11187     {&hf_tag_measure_basic_map_field,
11188      {"Map Field", "wlan_mgt.measure.rep.mapfield",
11189       FT_UINT8, BASE_HEX, NULL, 0, "Map Field", HFILL }},
11190
11191     {&hf_tag_measure_map_field_bss,
11192      {"BSS", "wlan_mgt.measure.rep.repmode.mapfield.bss",
11193       FT_BOOLEAN, 8, TFS (&hf_tag_measure_map_field_bss_flag), 0x01, "BSS", HFILL }},
11194
11195     {&hf_tag_measure_map_field_odfm,
11196      {"Orthogonal Frequency Division Multiplexing (ODFM) Preamble", "wlan_mgt.measure.rep.repmode.mapfield.bss",
11197       FT_BOOLEAN, 8, TFS (&hf_tag_measure_detected_not_detected), 0x02, "Orthogonal Frequency Division Multiplexing (ODFM) Preamble", HFILL }},
11198
11199     {&hf_tag_measure_map_field_unident_signal,
11200      {"Unidentified Signal", "wlan_mgt.measure.rep.repmode.mapfield.unidentsig",
11201       FT_BOOLEAN, 8, TFS (&hf_tag_measure_detected_not_detected), 0x04, "Unidentified Signal", HFILL }},
11202
11203     {&hf_tag_measure_map_field_radar,
11204      {"Radar", "wlan_mgt.measure.rep.repmode.mapfield.radar",
11205       FT_BOOLEAN, 8, TFS (&hf_tag_measure_detected_not_detected), 0x08, "Radar", HFILL }},
11206
11207     {&hf_tag_measure_map_field_unmeasured,
11208      {"Unmeasured", "wlan_mgt.measure.rep.repmode.mapfield.unmeasured",
11209       FT_BOOLEAN, 8, TFS (&hf_tag_measure_true_false), 0x10, "Unmeasured", HFILL }},
11210
11211     {&hf_tag_measure_map_field_reserved,
11212      {"Reserved", "wlan_mgt.measure.rep.repmode.mapfield.reserved",
11213       FT_UINT8, BASE_HEX, NULL, 0xe0, "Reserved", HFILL }},
11214
11215     {&hf_tag_measure_rpi_histogram_report,
11216      {"Receive Power Indicator (RPI) Histogram Report", "wlan_mgt.measure.rep.rpi.histogram_report",
11217       FT_STRING, BASE_NONE, NULL, 0, "Receive Power Indicator (RPI) Histogram Report", HFILL }},
11218
11219     {&hf_tag_measure_rpi_histogram_report_0,
11220      {"RPI 0 Density", "wlan_mgt.measure.rep.rpi.rpi0density",
11221       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 0 Density", HFILL }},
11222
11223     {&hf_tag_measure_rpi_histogram_report_1,
11224      {"RPI 1 Density", "wlan_mgt.measure.rep.rpi.rpi1density",
11225       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 1 Density", HFILL }},
11226
11227     {&hf_tag_measure_rpi_histogram_report_2,
11228      {"RPI 2 Density", "wlan_mgt.measure.rep.rpi.rpi2density",
11229       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 2 Density", HFILL }},
11230
11231     {&hf_tag_measure_rpi_histogram_report_3,
11232      {"RPI 3 Density", "wlan_mgt.measure.rep.rpi.rpi3density",
11233       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 3 Density", HFILL }},
11234
11235     {&hf_tag_measure_rpi_histogram_report_4,
11236      {"RPI 4 Density", "wlan_mgt.measure.rep.rpi.rpi4density",
11237       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 4 Density", HFILL }},
11238
11239     {&hf_tag_measure_rpi_histogram_report_5,
11240      {"RPI 5 Density", "wlan_mgt.measure.rep.rpi.rpi5density",
11241       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 5 Density", HFILL }},
11242
11243     {&hf_tag_measure_rpi_histogram_report_6,
11244      {"RPI 6 Density", "wlan_mgt.measure.rep.rpi.rpi6density",
11245       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 6 Density", HFILL }},
11246
11247     {&hf_tag_measure_rpi_histogram_report_7,
11248      {"RPI 7 Density", "wlan_mgt.measure.rep.rpi.rpi7density",
11249       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 7 Density", HFILL }},
11250
11251     {&hf_tag_measure_report_regulatory_class,
11252      {"Regulatory Class", "wlan_mgt.measure.rep.regclass",
11253       FT_UINT8, BASE_HEX, NULL, 0, "Regulatory Class", HFILL }},
11254
11255     {&hf_tag_measure_report_channel_load,
11256      {"Channel Load", "wlan_mgt.measure.rep.chanload",
11257       FT_UINT8, BASE_HEX, NULL, 0, "Channel Load", HFILL }},
11258
11259     {&hf_tag_measure_report_frame_info,
11260      {"Reported Frame Information", "wlan_mgt.measure.rep.frameinfo",
11261       FT_UINT8, BASE_HEX, NULL, 0, "Reported Frame Information", HFILL }},
11262
11263     {&hf_tag_measure_report_frame_info_phy_type,
11264      {"Condensed PHY", "wlan_mgt.measure.rep.frameinfo.phytype",
11265       FT_UINT8, BASE_HEX, NULL, 0x7F, "Condensed PHY", HFILL }},
11266
11267     {&hf_tag_measure_report_frame_info_frame_type,
11268      {"Reported Frame Type", "wlan_mgt.measure.rep.frameinfo.frametype",
11269       FT_UINT8, BASE_HEX, TFS(&hf_tag_measure_report_frame_info_frame_type_flag), 0x80, "Reported Frame Type", HFILL }},
11270
11271     {&hf_tag_measure_report_rcpi,
11272      {"Received Channel Power Indicator (RCPI)", "wlan_mgt.measure.rep.rcpi",
11273       FT_UINT8, BASE_HEX, NULL, 0, "Received Channel Power Indicator (RCPI)", HFILL }},
11274
11275     {&hf_tag_measure_report_rsni,
11276      {"Received Signal to Noise Indicator (RSNI)", "wlan_mgt.measure.rep.rsni",
11277       FT_UINT8, BASE_HEX, NULL, 0, "Received Signal to Noise Indicator (RSNI)", HFILL }},
11278
11279     {&hf_tag_measure_report_bssid,
11280      {"BSSID Being Reported", "wlan_mgt.measure.rep.bssid",
11281       FT_ETHER, BASE_NONE, NULL, 0, "BSSID Being Reported", HFILL }},
11282
11283     {&hf_tag_measure_report_ant_id,
11284      {"Antenna ID", "wlan_mgt.measure.rep.antid",
11285       FT_UINT8, BASE_HEX, NULL, 0, "Antenna ID", HFILL }},
11286
11287     {&hf_tag_measure_report_parent_tsf,
11288      {"Parent Timing Synchronization Function (TSF)", "wlan_mgt.measure.rep.parenttsf",
11289       FT_UINT32, BASE_HEX, NULL, 0, "Parent Timing Synchronization Function (TSF)", HFILL }},
11290     /*** End: Measurement Report Tag  - Dustin Johnson***/
11291
11292     /*** Begin: Extended Capabilities Tag - Dustin Johnson ***/
11293     /* Table 7-35a\97Capabilities field */
11294     {&hf_tag_extended_capabilities,
11295      {"Extended Capabilities", "wlan_mgt.extcap",
11296       FT_UINT8, BASE_HEX, NULL, 0, "Extended Capabilities", HFILL }},
11297
11298     /* P802.11n/D6.0 */
11299     {&hf_tag_extended_capabilities_b0,
11300      {"20/40 BSS Coexistence Management Support", "wlan_mgt.extcap.infoexchange.b0",
11301       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0001, "HT Information Exchange Support", HFILL }},
11302
11303     /* P802.11p/D4.0 */
11304     {&hf_tag_extended_capabilities_b1,
11305      {"On-demand beacon", "wlan_mgt.extcap.infoexchange.b1",
11306       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0002, "On-demand beacon", HFILL }},
11307
11308     {&hf_tag_extended_capabilities_b2,
11309      {"Extended Channel Switching", "wlan_mgt.extcap.infoexchange.b2",
11310       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0004, "Extended Channel Switching", HFILL }},
11311
11312     {&hf_tag_extended_capabilities_b3,
11313      {"WAVE indication", "wlan_mgt.extcap.infoexchange.b3",
11314       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0008, "WAVE indication", HFILL }},
11315     /*End: P802.11p/D4.0 */
11316
11317     /*** End: Extended Capabilities Tag - Dustin Johnson ***/
11318
11319     /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
11320     {&hf_tag_neighbor_report_bssid,
11321      {"BSSID", "wlan_mgt.nreport.bssid",
11322       FT_ETHER, BASE_NONE, NULL, 0, "BSSID", HFILL }},
11323
11324     {&hf_tag_neighbor_report_bssid_info,
11325      {"BSSID Information", "wlan_mgt.nreport.bssid.info",
11326       FT_UINT32, BASE_HEX, NULL, 0, "BSSID Information", HFILL }},
11327
11328     {&hf_tag_neighbor_report_bssid_info_reachability,
11329      {"AP Reachability", "wlan_mgt.nreport.bssid.info.reachability",
11330       FT_UINT16, BASE_HEX, NULL, 0x0003, "AP Reachability", HFILL }},
11331
11332     {&hf_tag_neighbor_report_bssid_info_security,
11333      {"Security", "wlan_mgt.nreport.bssid.info.security",
11334       FT_UINT16, BASE_HEX, NULL, 0x0004, "Security", HFILL }},
11335
11336     {&hf_tag_neighbor_report_bssid_info_key_scope,
11337      {"Key Scope", "wlan_mgt.nreport.bssid.info.keyscope",
11338       FT_UINT16, BASE_HEX, NULL, 0x0008, "Key Scope", HFILL }},
11339
11340     {&hf_tag_neighbor_report_bssid_info_capability_spec_mng,
11341      {"Capability: Spectrum Management", "wlan_mgt.nreport.bssid.info.capability.specmngt",
11342       FT_UINT16, BASE_HEX, NULL, 0x0010, "Capability: Spectrum Management", HFILL }},
11343
11344     {&hf_tag_neighbor_report_bssid_info_capability_qos,
11345      {"Capability: QoS", "wlan_mgt.nreport.bssid.info.capability.qos",
11346       FT_UINT16, BASE_HEX, NULL, 0x0020, "Capability: QoS", HFILL }},
11347
11348     {&hf_tag_neighbor_report_bssid_info_capability_apsd,
11349      {"Capability: APSD", "wlan_mgt.nreport.bssid.info.capability.apsd",
11350       FT_UINT16, BASE_HEX, NULL, 0x0040, "Capability: APSD", HFILL }},
11351
11352     {&hf_tag_neighbor_report_bssid_info_capability_radio_msnt,
11353      {"Capability: Radio Measurement", "wlan_mgt.nreport.bssid.info.capability.radiomsnt",
11354       FT_UINT16, BASE_HEX, NULL, 0x0080, "Capability: Radio Measurement", HFILL }},
11355
11356     {&hf_tag_neighbor_report_bssid_info_capability_dback,
11357      {"Capability: Delayed Block Ack", "wlan_mgt.nreport.bssid.info.capability.dback",
11358       FT_UINT16, BASE_HEX, NULL, 0x0100, "Capability: Delayed Block Ack", HFILL }},
11359
11360     {&hf_tag_neighbor_report_bssid_info_capability_iback,
11361      {"Capability: Immediate Block Ack", "wlan_mgt.nreport.bssid.info.capability.iback",
11362       FT_UINT16, BASE_HEX, NULL, 0x0200, "Capability: Immediate Block Ack", HFILL }},
11363
11364     {&hf_tag_neighbor_report_bssid_info_mobility_domain,
11365      {"Mobility Domain", "wlan_mgt.nreport.bssid.info.mobilitydomain",
11366       FT_UINT16, BASE_HEX, NULL, 0x0400, "Mobility Domain", HFILL }},
11367
11368     {&hf_tag_neighbor_report_bssid_info_high_throughput,
11369      {"High Throughput", "wlan_mgt.nreport.bssid.info.hthoughput",
11370       FT_UINT16, BASE_HEX, NULL, 0x0800, "High Throughput", HFILL }},
11371
11372     {&hf_tag_neighbor_report_bssid_info_reserved,
11373      {"Reserved", "wlan_mgt.nreport.bssid.info.reserved",
11374       FT_UINT32, BASE_HEX, NULL, 0, "Reserved", HFILL }},
11375
11376     {&hf_tag_neighbor_report_reg_class,
11377      {"Regulatory Class", "wlan_mgt.nreport.regclass",
11378       FT_UINT8, BASE_HEX, NULL, 0, "Regulatory Class", HFILL }},
11379
11380     {&hf_tag_neighbor_report_channel_number,
11381      {"Channel Number", "wlan_mgt.nreport.channumber",
11382       FT_UINT8, BASE_HEX, NULL, 0, "Channel Number", HFILL }},
11383
11384     {&hf_tag_neighbor_report_phy_type,
11385      {"PHY Type", "wlan_mgt.nreport.phytype",
11386       FT_UINT8, BASE_HEX, NULL, 0, "PHY Type", HFILL }},
11387     /*** End: Neighbor Report Tag - Dustin Johnson ***/
11388
11389     /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
11390     {&hf_tag_ext_channel_switch_announcement_switch_mode,
11391      {"Channel Switch Mode", "wlan_mgt.extchanswitch.switchmode",
11392       FT_UINT8, BASE_HEX, VALS (&hf_tag_ext_channel_switch_announcement_switch_mode_flags), 0, "Channel Switch Mode", HFILL }},
11393
11394     {&hf_tag_ext_channel_switch_announcement_new_reg_class,
11395      {"New Regulatory Class", "wlan_mgt.extchanswitch.new.regclass",
11396       FT_UINT8, BASE_HEX, NULL, 0, "New Regulatory Class", HFILL }},
11397
11398     {&hf_tag_ext_channel_switch_announcement_new_chan_number,
11399      {"New Channel Number", "wlan_mgt.extchanswitch.new.channumber",
11400       FT_UINT8, BASE_HEX, NULL, 0, "New Channel Number", HFILL }},
11401
11402     {&hf_tag_ext_channel_switch_announcement_switch_count,
11403      {"Channel Switch Count", "wlan_mgt.extchanswitch.switchcount",
11404       FT_UINT8, BASE_HEX, NULL, 0, "Channel Switch Count", HFILL }},
11405     /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
11406
11407     /*** Begin: Supported Regulatory Classes Tag - Dustin Johnson ***/
11408     {&hf_tag_supported_reg_classes_current,
11409      {"Current Regulatory Class", "wlan_mgt.supregclass.current",
11410       FT_UINT8, BASE_HEX, NULL, 0, "Current Regulatory Class", HFILL }},
11411
11412     {&hf_tag_supported_reg_classes_alternate,
11413      {"Alternate Regulatory Classes", "wlan_mgt.supregclass.alt",
11414       FT_STRING, BASE_NONE, NULL, 0, "Alternate Regulatory Classes", HFILL }},
11415     /*** End: Supported Regulatory Classes Tag - Dustin Johnson ***/
11416
11417     {&hf_marvell_ie_type,
11418      {"Type", "wlan_mgt.marvell.ie.type",
11419       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11420
11421     {&hf_marvell_ie_mesh_subtype,
11422      {"Subtype", "wlan_mgt.marvell.ie.subtype",
11423       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11424
11425     {&hf_marvell_ie_mesh_version,
11426      {"Version", "wlan_mgt.marvell.ie.version",
11427       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11428
11429     {&hf_marvell_ie_mesh_active_proto_id,
11430      {"Path Selection Protocol", "wlan_mgt.marvell.ie.proto_id",
11431       FT_UINT8, BASE_HEX, VALS(mesh_path_selection_codes), 0, "", HFILL }},
11432
11433     {&hf_marvell_ie_mesh_active_metric_id,
11434      {"Path Selection Metric", "wlan_mgt.marvell.ie.metric_id",
11435       FT_UINT8, BASE_HEX, VALS(mesh_metric_codes), 0, "", HFILL }},
11436
11437     {&hf_marvell_ie_mesh_cap,
11438      {"Mesh Capabilities", "wlan_mgt.marvell.ie.cap",
11439       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11440
11441     {&hf_marvell_ie_data,
11442       { "Marvell IE data", "wlan_mgt.marvell.data",
11443         FT_BYTES, BASE_NONE, NULL, 0x0, "Marvell IE data", HFILL }},
11444
11445     {&hf_aironet_ie_type,
11446      {"Aironet IE type", "wlan_mgt.aironet.type",
11447       FT_UINT8, BASE_DEC, VALS(aironet_ie_type_vals), 0, "Aironet IE type", HFILL }},
11448
11449     {&hf_aironet_ie_version,
11450      {"Aironet IE CCX version?", "wlan_mgt.aironet.version",
11451       FT_UINT8, BASE_DEC, NULL, 0, "Aironet IE CCX version?", HFILL }},
11452
11453     {&hf_aironet_ie_data,
11454       { "Aironet IE data", "wlan_mgt.aironet.data",
11455         FT_BYTES, BASE_NONE, NULL, 0x0, "Aironet IE data", HFILL }},
11456
11457     {&hf_qbss_version,
11458      {"QBSS Version", "wlan_mgt.qbss.version",
11459       FT_UINT8, BASE_DEC, NULL, 0, "QBSS Version", HFILL }},
11460
11461     {&hf_qbss_scount,
11462      {"Station Count", "wlan_mgt.qbss.scount",
11463       FT_UINT16, BASE_DEC, NULL, 0, "Station Count", HFILL }},
11464
11465     {&hf_qbss_cu,
11466      {"Channel Utilization", "wlan_mgt.qbss.cu",
11467        FT_UINT8, BASE_DEC, NULL, 0, "Channel Utilization", HFILL }},
11468
11469     {&hf_qbss_adc,
11470      {"Available Admission Capabilities", "wlan_mgt.qbss.adc",
11471      FT_UINT8, BASE_DEC, NULL, 0, "Available Admission Capabilities", HFILL }},
11472
11473     {&hf_qbss2_cu,
11474      {"Channel Utilization", "wlan_mgt.qbss2.cu",
11475        FT_UINT8, BASE_DEC, NULL, 0, "Channel Utilization", HFILL }},
11476
11477     {&hf_qbss2_gl,
11478      {"G.711 CU Quantum", "wlan_mgt.qbss2.glimit",
11479       FT_UINT8, BASE_DEC, NULL, 0, "G.711 CU Quantum", HFILL }},
11480
11481     {&hf_qbss2_cal,
11482      {"Call Admission Limit", "wlan_mgt.qbss2.cal",
11483       FT_UINT8, BASE_DEC, NULL, 0, "Call Admission Limit", HFILL }},
11484
11485     {&hf_qbss2_scount,
11486      {"Station Count", "wlan_mgt.qbss2.scount",
11487       FT_UINT16, BASE_DEC, NULL, 0, "Station Count", HFILL }},
11488
11489     {&hf_aironet_ie_qos_unk1,
11490      {"Aironet IE QoS unknown 1", "wlan_mgt.aironet.qos.unk1",
11491       FT_UINT8, BASE_HEX, NULL, 0, "Aironet IE QoS unknown 1", HFILL }},
11492
11493     {&hf_aironet_ie_qos_paramset,
11494      {"Aironet IE QoS paramset", "wlan_mgt.aironet.qos.paramset",
11495       FT_UINT8, BASE_DEC, NULL, 0, "Aironet IE QoS paramset", HFILL }},
11496
11497     {&hf_aironet_ie_qos_val,
11498      {"Aironet IE QoS valueset", "wlan_mgt.aironet.qos.val",
11499       FT_BYTES, BASE_NONE, NULL, 0, "Aironet IE QoS valueset", HFILL }},
11500
11501     {&hf_ts_info,
11502      {"Traffic Stream (TS) Info", "wlan_mgt.ts_info",
11503       FT_UINT24, BASE_HEX, NULL, 0, "Traffic Stream (TS) Info field", HFILL }},
11504
11505     {&hf_tsinfo_type,
11506      {"Traffic Type", "wlan_mgt.ts_info.type", FT_UINT8, BASE_DEC,
11507       VALS (&tsinfo_type), 0, "Traffic Stream (TS) Info Traffic Type", HFILL }},
11508
11509     {&hf_tsinfo_tsid,
11510      {"Traffic Stream ID (TSID)", "wlan_mgt.ts_info.tsid",
11511       FT_UINT8, BASE_DEC, NULL, 0, "Traffic Stream ID (TSID) Info TSID", HFILL }},
11512
11513     {&hf_tsinfo_dir,
11514      {"Direction", "wlan_mgt.ts_info.dir", FT_UINT8, BASE_DEC,
11515       VALS (&tsinfo_direction), 0, "Traffic Stream (TS) Info Direction", HFILL }},
11516
11517     {&hf_tsinfo_access,
11518      {"Access Policy", "wlan_mgt.ts_info.dir", FT_UINT8, BASE_DEC,
11519       VALS (&tsinfo_access), 0, "Traffic Stream (TS) Info Access Policy", HFILL }},
11520
11521     {&hf_tsinfo_agg,
11522      {"Aggregation", "wlan_mgt.ts_info.agg", FT_UINT8, BASE_DEC,
11523       NULL, 0, "Traffic Stream (TS) Info Access Policy", HFILL }},
11524
11525     {&hf_tsinfo_apsd,
11526      {"Automatic Power-Save Delivery (APSD)", "wlan_mgt.ts_info.apsd", FT_UINT8, BASE_DEC,
11527       NULL, 0, "Traffic Stream (TS) Info Automatic Power-Save Delivery (APSD)", HFILL }},
11528
11529     {&hf_tsinfo_up,
11530      {"User Priority", "wlan_mgt.ts_info.up", FT_UINT8, BASE_DEC,
11531       VALS (&qos_up), 0, "Traffic Stream (TS) Info User Priority", HFILL }},
11532
11533     {&hf_tsinfo_ack,
11534      {"Ack Policy", "wlan_mgt.ts_info.ack", FT_UINT8, BASE_DEC,
11535       VALS (&ack_policy), 0, "Traffic Stream (TS) Info Ack Policy", HFILL }},
11536
11537     {&hf_tsinfo_sched,
11538      {"Schedule", "wlan_mgt.ts_info.sched", FT_UINT8, BASE_DEC,
11539       NULL, 0, "Traffic Stream (TS) Info Schedule", HFILL }},
11540
11541     {&tspec_nor_msdu,
11542      {"Normal MSDU Size", "wlan_mgt.tspec.nor_msdu",
11543       FT_UINT16, BASE_DEC, NULL, 0, "Normal MSDU Size", HFILL }},
11544
11545     {&tspec_max_msdu,
11546      {"Maximum MSDU Size", "wlan_mgt.tspec.max_msdu",
11547       FT_UINT16, BASE_DEC, NULL, 0, "Maximum MSDU Size", HFILL }},
11548
11549     {&tspec_min_srv,
11550      {"Minimum Service Interval", "wlan_mgt.tspec.min_srv",
11551       FT_UINT32, BASE_DEC, NULL, 0, "Minimum Service Interval", HFILL }},
11552
11553     {&tspec_max_srv,
11554      {"Maximum Service Interval", "wlan_mgt.tspec.max_srv",
11555       FT_UINT32, BASE_DEC, NULL, 0, "Maximum Service Interval", HFILL }},
11556
11557     {&tspec_inact_int,
11558      {"Inactivity Interval", "wlan_mgt.tspec.inact_int",
11559       FT_UINT32, BASE_DEC, NULL, 0, "Inactivity Interval", HFILL }},
11560
11561     {&tspec_susp_int,
11562      {"Suspension Interval", "wlan_mgt.tspec.susp_int",
11563       FT_UINT32, BASE_DEC, NULL, 0, "Suspension Interval", HFILL }},
11564
11565     {&tspec_srv_start,
11566      {"Service Start Time", "wlan_mgt.tspec.srv_start",
11567       FT_UINT32, BASE_DEC, NULL, 0, "Service Start Time", HFILL }},
11568
11569     {&tspec_min_data,
11570      {"Minimum Data Rate", "wlan_mgt.tspec.min_data",
11571       FT_UINT32, BASE_DEC, NULL, 0, "Minimum Data Rate", HFILL }},
11572
11573     {&tspec_mean_data,
11574      {"Mean Data Rate", "wlan_mgt.tspec.mean_data",
11575       FT_UINT32, BASE_DEC, NULL, 0, "Mean Data Rate", HFILL }},
11576
11577     {&tspec_peak_data,
11578      {"Peak Data Rate", "wlan_mgt.tspec.peak_data",
11579       FT_UINT32, BASE_DEC, NULL, 0, "Peak Data Rate", HFILL }},
11580
11581     {&tspec_burst_size,
11582      {"Burst Size", "wlan_mgt.tspec.burst_size",
11583       FT_UINT32, BASE_DEC, NULL, 0, "Burst Size", HFILL }},
11584
11585     {&tspec_delay_bound,
11586      {"Delay Bound", "wlan_mgt.tspec.delay_bound",
11587       FT_UINT32, BASE_DEC, NULL, 0, "Delay Bound", HFILL }},
11588
11589     {&tspec_min_phy,
11590      {"Minimum PHY Rate", "wlan_mgt.tspec.min_phy",
11591       FT_UINT32, BASE_DEC, NULL, 0, "Minimum PHY Rate", HFILL }},
11592
11593     {&tspec_surplus,
11594      {"Surplus Bandwidth Allowance", "wlan_mgt.tspec.surplus",
11595       FT_UINT16, BASE_DEC, NULL, 0, "Surplus Bandwidth Allowance", HFILL }},
11596
11597     {&tspec_medium,
11598      {"Medium Time", "wlan_mgt.tspec.medium",
11599       FT_UINT16, BASE_DEC, NULL, 0, "Medium Time", HFILL }},
11600
11601     {&ts_delay,
11602      {"Traffic Stream (TS) Delay", "wlan_mgt.ts_delay",
11603       FT_UINT32, BASE_DEC, NULL, 0, "Traffic Stream (TS) Delay", HFILL }},
11604
11605     {&hf_class_type,
11606      {"Classifier Type", "wlan_mgt.tclas.class_type", FT_UINT8, BASE_DEC,
11607       VALS (classifier_type), 0, "Classifier Type", HFILL }},
11608
11609     {&hf_class_mask,
11610      {"Classifier Mask", "wlan_mgt.tclas.class_mask", FT_UINT8, BASE_HEX,
11611       NULL, 0, "Classifier Mask", HFILL }},
11612
11613     {&hf_ether_type,
11614      {"Ethernet Type", "wlan_mgt.tclas.params.type", FT_UINT8, BASE_DEC,
11615       NULL, 0, "Classifier Parameters Ethernet Type", HFILL }},
11616
11617     {&hf_tclas_process,
11618      {"Processing", "wlan_mgt.tclas_proc.processing", FT_UINT8, BASE_DEC,
11619       VALS (tclas_process), 0, "TCLAS Processing", HFILL }},
11620
11621     {&hf_sched_info,
11622      {"Schedule Info", "wlan_mgt.sched.sched_info",
11623       FT_UINT16, BASE_HEX, NULL, 0, "Schedule Info field", HFILL }},
11624
11625     {&hf_sched_srv_start,
11626      {"Service Start Time", "wlan_mgt.sched.srv_start",
11627       FT_UINT32, BASE_HEX, NULL, 0, "Service Start Time", HFILL }},
11628
11629     {&hf_sched_srv_int,
11630      {"Service Interval", "wlan_mgt.sched.srv_int",
11631       FT_UINT32, BASE_HEX, NULL, 0, "Service Interval", HFILL }},
11632
11633     {&hf_sched_spec_int,
11634      {"Specification Interval", "wlan_mgt.sched.spec_int",
11635       FT_UINT16, BASE_HEX, NULL, 0, "Specification Interval", HFILL }},
11636
11637     {&hf_action,
11638      {"Action", "wlan_mgt.fixed.action",
11639       FT_UINT8, BASE_HEX, NULL, 0, "Action", HFILL }},
11640
11641     {&cf_version,
11642      {"IP Version", "wlan_mgt.tclas.params.version",
11643       FT_UINT8, BASE_DEC, NULL, 0, "IP Version", HFILL }},
11644
11645     {&cf_ipv4_src,
11646      {"IPv4 Src Addr", "wlan_mgt.tclas.params.ipv4_src",
11647       FT_IPv4, BASE_NONE, NULL, 0, "IPv4 Src Addr", HFILL }},
11648
11649     {&cf_ipv4_dst,
11650      {"IPv4 Dst Addr", "wlan_mgt.tclas.params.ipv4_dst",
11651       FT_IPv4, BASE_NONE, NULL, 0, "IPv4 Dst Addr", HFILL }},
11652
11653     {&cf_src_port,
11654      {"Source Port", "wlan_mgt.tclas.params.src_port",
11655       FT_UINT16, BASE_DEC, NULL, 0, "Source Port", HFILL }},
11656
11657     {&cf_dst_port,
11658      {"Destination Port", "wlan_mgt.tclas.params.dst_port",
11659       FT_UINT16, BASE_DEC, NULL, 0, "Destination Port", HFILL }},
11660
11661     {&cf_dscp,
11662      {"IPv4 DSCP", "wlan_mgt.tclas.params.dscp",
11663       FT_UINT8, BASE_HEX, NULL, 0, "IPv4 Differentiated Services Code Point (DSCP) Field", HFILL }},
11664
11665     {&cf_protocol,
11666      {"Protocol", "wlan_mgt.tclas.params.protocol",
11667       FT_UINT8, BASE_HEX, NULL, 0, "IPv4 Protocol", HFILL }},
11668
11669     {&cf_ipv6_src,
11670      {"IPv6 Src Addr", "wlan_mgt.tclas.params.ipv6_src",
11671       FT_IPv6, BASE_NONE, NULL, 0, "IPv6 Src Addr", HFILL }},
11672
11673     {&cf_ipv6_dst,
11674      {"IPv6 Dst Addr", "wlan_mgt.tclas.params.ipv6_dst",
11675       FT_IPv6, BASE_NONE, NULL, 0, "IPv6 Dst Addr", HFILL }},
11676
11677     {&cf_flow,
11678      {"Flow Label", "wlan_mgt.tclas.params.flow",
11679       FT_UINT24, BASE_HEX, NULL, 0, "IPv6 Flow Label", HFILL }},
11680
11681     {&cf_tag_type,
11682      {"802.1Q Tag Type", "wlan_mgt.tclas.params.tag_type",
11683       FT_UINT16, BASE_HEX, NULL, 0, "802.1Q Tag Type", HFILL }},
11684
11685     {&cf_aruba,
11686      {"Aruba Type", "wlan_mgt.aruba_type",
11687       FT_UINT16, BASE_DEC, VALS(aruba_mgt_typevals), 0, "Aruba Management", HFILL }},
11688
11689     {&cf_aruba_hb_seq,
11690      {"Aruba Heartbeat Sequence", "wlan_mgt.aruba_heartbeat_sequence",
11691       FT_UINT64, BASE_DEC, NULL, 0, "Aruba Heartbeat Sequence", HFILL }},
11692
11693     {&cf_aruba_mtu,
11694      {"Aruba MTU Size", "wlan_mgt.aruba_mtu_size",
11695       FT_UINT16, BASE_DEC, NULL, 0, "Aruba MTU Size", HFILL }},
11696
11697     /* Start: HT Control (+HTC) */
11698     {&hf_htc,
11699      {"HT Control (+HTC)", "wlan_mgt.htc",
11700       FT_UINT32, BASE_HEX, NULL, 0, "High Throughput Control (+HTC)", HFILL }},
11701     {&hf_htc_lac,
11702      {"Link Adaptation Control (LAC)", "wlan_mgt.htc.lac",
11703       FT_UINT16, BASE_HEX, NULL, 0, "High Throughput Control Link Adaptation Control (LAC)", HFILL }},
11704     {&hf_htc_lac_reserved,
11705      {"Reserved", "wlan_mgt.htc.lac.reserved",
11706       FT_BOOLEAN, 16, NULL, 0x0001, "High Throughput Control Link Adaptation Control Reserved", HFILL }},
11707     {&hf_htc_lac_trq,
11708      {"Training Request (TRQ)", "wlan_mgt.htc.lac.trq",
11709       FT_BOOLEAN, 16, TFS(&htc_lac_trq_flag), 0x0002, "High Throughput Control Link Adaptation Control Training Request (TRQ)", HFILL }},
11710     {&hf_htc_lac_mai_aseli,
11711      {"Antenna Selection Indication (ASELI)", "wlan_mgt.htc.lac.mai.aseli",
11712       FT_UINT16, BASE_HEX, NULL, 0x003C, "High Throughput Control Link Adaptation Control MAI Antenna Selection Indication", HFILL }},
11713     {&hf_htc_lac_mai_mrq,
11714      {"MCS Request (MRQ)", "wlan_mgt.htc.lac.mai.mrq",
11715       FT_BOOLEAN, 16, TFS(&htc_lac_mai_mrq_flag), 0x0004, "High Throughput Control Link Adaptation Control MAI MCS Request", HFILL }},
11716     {&hf_htc_lac_mai_msi,
11717      {"MCS Request Sequence Identifier (MSI)", "wlan_mgt.htc.lac.mai.msi",
11718       FT_UINT16, BASE_HEX, NULL, 0x0038, "High Throughput Control Link Adaptation Control MAI MCS Request Sequence Identifier", HFILL }},
11719     {&hf_htc_lac_mai_reserved,
11720      {"Reserved", "wlan_mgt.htc.lac.mai.reserved",
11721       FT_UINT16, BASE_HEX, NULL, 0x0038, "High Throughput Control Link Adaptation Control MAI Reserved", HFILL }},
11722     {&hf_htc_lac_mfsi,
11723      {"MCS Feedback Sequence Identifier (MFSI)", "wlan_mgt.htc.lac.mfsi",
11724       FT_UINT16, BASE_DEC, NULL, 0x01C0, "High Throughput Control Link Adaptation Control MCS Feedback Sequence Identifier (MSI)", HFILL }},
11725     {&hf_htc_lac_asel_command,
11726      {"Antenna Selection (ASEL) Command", "wlan_mgt.htc.lac.asel.command",
11727       FT_UINT16, BASE_HEX, VALS (&hf_htc_lac_asel_command_flags), 0x0E00, "High Throughput Control Link Adaptation Control Antenna Selection (ASEL) Command", HFILL }},
11728     {&hf_htc_lac_asel_data,
11729      {"Antenna Selection (ASEL) Data", "wlan_mgt.htc.lac.asel.data",
11730       FT_UINT16, BASE_HEX, NULL, 0xF000, "High Throughput Control Link Adaptation Control Antenna Selection (ASEL) Data", HFILL }},
11731     {&hf_htc_lac_mfb,
11732      {"MCS Feedback (MFB)", "wlan_mgt.htc.lac.mfb",
11733       FT_UINT16, BASE_HEX, NULL, 0xFE00, "High Throughput Control Link Adaptation Control MCS Feedback", HFILL }},
11734     {&hf_htc_cal_pos,
11735      {"Calibration Position", "wlan_mgt.htc.cal.pos",
11736       FT_UINT16, BASE_DEC, VALS (&hf_htc_cal_pos_flags), 0x0003, "High Throughput Control Calibration Position", HFILL }},
11737     {&hf_htc_cal_seq,
11738      {"Calibration Sequence Identifier", "wlan_mgt.htc.cal.seq",
11739       FT_UINT16, BASE_DEC, NULL, 0x000C, "High Throughput Control Calibration Sequence Identifier", HFILL }},
11740     {&hf_htc_reserved1,
11741      {"Reserved", "wlan_mgt.htc.reserved1",
11742       FT_UINT16, BASE_DEC, NULL, 0x0030, "High Throughput Control Reserved", HFILL }},
11743     {&hf_htc_csi_steering,
11744      {"CSI/Steering", "wlan_mgt.htc.csi_steering",
11745       FT_UINT16, BASE_DEC, VALS (&hf_htc_csi_steering_flags), 0x00C0, "High Throughput Control CSI/Steering", HFILL }},
11746     {&hf_htc_ndp_announcement,
11747      {"NDP Announcement", "wlan_mgt.htc.ndp_announcement",
11748       FT_BOOLEAN, 16, TFS(&hf_htc_ndp_announcement_flag), 0x0100, "High Throughput Control NDP Announcement", HFILL }},
11749     {&hf_htc_reserved2,
11750      {"Reserved", "wlan_mgt.htc.reserved2",
11751       FT_UINT16, BASE_HEX, NULL, 0x3E00, "High Throughput Control Reserved", HFILL }},
11752     {&hf_htc_ac_constraint,
11753      {"AC Constraint", "wlan_mgt.htc.ac_constraint",
11754       FT_BOOLEAN, 16, NULL, 0x4000, "High Throughput Control AC Constraint", HFILL }},
11755     {&hf_htc_rdg_more_ppdu,
11756      {"RDG/More PPDU", "wlan_mgt.htc.rdg_more_ppdu",
11757       FT_BOOLEAN, 16, NULL, 0x8000, "High Throughput Control RDG/More PPDU", HFILL }}
11758     /* End: HT Control (+HTC) */
11759   };
11760
11761   static hf_register_info aggregate_fields[] = {
11762     {&amsdu_msdu_header_text,
11763      {"MAC Service Data Unit (MSDU)",   "wlan_aggregate.msduheader", FT_UINT16,
11764       BASE_DEC, 0, 0x0000, "MAC Service Data Unit (MSDU)", HFILL }}
11765   };
11766
11767   static gint *tree_array[] = {
11768     &ett_80211,
11769     &ett_fc_tree,
11770     &ett_proto_flags,
11771     &ett_fragments,
11772     &ett_fragment,
11773     &ett_block_ack,
11774     &ett_80211_mgt,
11775     &ett_fixed_parameters,
11776     &ett_tagged_parameters,
11777     &ett_qos_parameters,
11778     &ett_qos_ps_buf_state,
11779     &ett_wep_parameters,
11780     &ett_cap_tree,
11781     &ett_rsn_cap_tree,
11782     &ett_ht_cap_tree,
11783     &ett_ff_ba_param_tree,
11784     &ett_ff_qos_info,
11785     &ett_ff_sm_pwr_save,
11786     &ett_ff_psmp_param_set,
11787     &ett_ff_mimo_cntrl,
11788     &ett_ff_ant_sel,
11789     &ett_ff_chan_switch_announce,
11790     &ett_ff_ht_info,
11791     &ett_ff_psmp_sta_info,
11792     &ett_ff_delba_param_tree,
11793     &ett_ff_ba_ssc_tree,
11794     &ett_mimo_report,
11795     &ett_cntrl_wrapper_fc,
11796     &ett_cntrl_wrapper_payload,
11797     &ett_ht_info_delimiter1_tree,
11798     &ett_ht_info_delimiter2_tree,
11799     &ett_ht_info_delimiter3_tree,
11800     &ett_msdu_aggregation_parent_tree,
11801     &ett_msdu_aggregation_subframe_tree,
11802     &ett_tag_measure_request_tree,
11803         &ett_tag_ex_cap,
11804     &ett_tag_supported_channels,
11805     &ett_tag_neighbor_report_bssid_info_tree,
11806     &ett_tag_neighbor_report_bssid_info_capability_tree,
11807     &ett_tag_neighbor_report_sub_tag_tree,
11808     &ett_ampduparam_tree,
11809     &ett_mcsset_tree,
11810     &ett_mcsbit_tree,
11811     &ett_htex_cap_tree,
11812     &ett_txbf_tree,
11813     &ett_hta_cap_tree,
11814     &ett_hta_cap1_tree,
11815     &ett_hta_cap2_tree,
11816     &ett_htc_tree,
11817     &ett_antsel_tree,
11818     &ett_80211_mgt_ie,
11819     &ett_tsinfo_tree,
11820     &ett_sched_tree,
11821     &ett_fcs,
11822     &ett_radio,
11823     &ett_pst_tree,
11824     &ett_pst_cap_tree,
11825     &ett_chan_noc_tree,
11826     &ett_wave_chnl_tree
11827   };
11828   module_t *wlan_module;
11829
11830   memset (&wlan_stats, 0, sizeof wlan_stats);
11831
11832   proto_aggregate = proto_register_protocol("IEEE 802.11 wireless LAN aggregate frame",
11833       "IEEE 802.11 Aggregate Data", "wlan_aggregate");
11834   proto_register_field_array(proto_aggregate, aggregate_fields, array_length(aggregate_fields));
11835   proto_wlan = proto_register_protocol ("IEEE 802.11 wireless LAN",
11836       "IEEE 802.11", "wlan");
11837   proto_register_field_array (proto_wlan, hf, array_length (hf));
11838   proto_wlan_mgt = proto_register_protocol ("IEEE 802.11 wireless LAN management frame",
11839       "802.11 MGT", "wlan_mgt");
11840   proto_register_field_array (proto_wlan_mgt, ff, array_length (ff));
11841   proto_register_subtree_array (tree_array, array_length (tree_array));
11842
11843   register_dissector("wlan", dissect_ieee80211, proto_wlan);
11844   register_dissector("wlan_fixed", dissect_ieee80211_fixed, proto_wlan);
11845   register_dissector("wlan_bsfc", dissect_ieee80211_bsfc, proto_wlan);
11846   register_dissector("wlan_datapad", dissect_ieee80211_datapad, proto_wlan);
11847   register_dissector("wlan_ht", dissect_ieee80211_ht, proto_wlan);
11848   register_init_routine(wlan_defragment_init);
11849   register_init_routine(wlan_retransmit_init);
11850
11851   proto_radio = proto_register_protocol("802.11 radio information", "Radio", "radio");
11852
11853   proto_prism = proto_register_protocol("Prism capture header", "Prism", "prism");
11854   proto_register_field_array(proto_prism, hf_prism, array_length(hf_prism));
11855
11856   proto_wlancap = proto_register_protocol("AVS WLAN Capture header",
11857       "AVS WLANCAP", "wlancap");
11858   proto_register_field_array(proto_wlancap, hf_wlancap, array_length(hf_wlancap));
11859   register_dissector("wlancap", dissect_wlancap, proto_wlancap);
11860
11861   wlan_tap = register_tap("wlan");
11862
11863   /* Register configuration options */
11864   wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys);
11865   prefs_register_bool_preference(wlan_module, "defragment",
11866       "Reassemble fragmented 802.11 datagrams",
11867       "Whether fragmented 802.11 datagrams should be reassembled",
11868       &wlan_defragment);
11869
11870   prefs_register_bool_preference(wlan_module, "ignore_draft_ht",
11871     "Ignore vendor-specific HT elements",
11872     "Don't dissect 802.11n draft HT elements (which might contain duplicate information).",
11873     &wlan_ignore_draft_ht);
11874
11875   prefs_register_bool_preference(wlan_module, "retransmitted",
11876     "Call subdissector for retransmitted 802.11 frames",
11877     "Whether retransmitted 802.11 frames should be subdissected",
11878     &wlan_subdissector);
11879
11880   prefs_register_bool_preference(wlan_module, "check_fcs",
11881     "Assume packets have FCS",
11882     "Some 802.11 cards include the FCS at the end of a packet, others do not.",
11883     &wlan_check_fcs);
11884
11885   /* Davide Schiera (2006-11-26): changed "WEP bit" in "Protection bit"    */
11886   /*    (according to the document IEEE Std 802.11i-2004)              */
11887   prefs_register_enum_preference(wlan_module, "ignore_wep",
11888       "Ignore the Protection bit",
11889       "Some 802.11 cards leave the Protection bit set even though the packet is decrypted, "
11890       "and some also leave the IV (initialization vector).",
11891       &wlan_ignore_wep, wlan_ignore_wep_options, TRUE);
11892
11893 #ifndef USE_ENV
11894
11895   prefs_register_obsolete_preference(wlan_module, "wep_keys");
11896
11897 #ifdef HAVE_AIRPDCAP
11898   /* Davide Schiera (2006-11-26): added reference to WPA/WPA2 decryption    */
11899   prefs_register_bool_preference(wlan_module, "enable_decryption",
11900       "Enable decryption", "Enable WEP and WPA/WPA2 decryption",
11901       &enable_decryption);
11902 #else
11903   prefs_register_bool_preference(wlan_module, "enable_decryption",
11904       "Enable decryption", "Enable WEP decryption",
11905       &enable_decryption);
11906 #endif
11907
11908 #ifdef HAVE_AIRPDCAP
11909   prefs_register_static_text_preference(wlan_module, "info_decryption_key",
11910       "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
11911       "010203040506070809101111213 (104/128-bit WEP),\n"
11912       "wpa-pwd:MyPassword[:MyAP] (WPA + plaintext password [+ SSID]),\n"
11913       "wpa-psk:0102030405...6061626364 (WPA + 256-bit key).  "
11914       "Invalid keys will be ignored.",
11915       "Valid key formats");
11916 #else
11917   prefs_register_static_text_preference(wlan_module, "info_decryption_key",
11918       "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
11919       "010203040506070809101111213 (104/128-bit WEP)",
11920       "Valid key formats");
11921 #endif
11922
11923   for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
11924     key_name = g_string_new("");
11925     key_title = g_string_new("");
11926     key_desc = g_string_new("");
11927     wep_keystr[i] = NULL;
11928     /* prefs_register_*_preference() expects unique strings, so
11929      * we build them using g_string_printf and just leave them
11930      * allocated. */
11931 #ifdef HAVE_AIRPDCAP
11932     g_string_printf(key_name, "wep_key%d", i + 1);
11933     g_string_printf(key_title, "Key #%d", i + 1);
11934     /* Davide Schiera (2006-11-26): modified keys input tooltip          */
11935     g_string_printf(key_desc,
11936       "Key #%d string can be:"
11937       "   <wep hexadecimal key>;"
11938       "   wep:<wep hexadecimal key>;"
11939       "   wpa-pwd:<passphrase>[:<ssid>];"
11940       "   wpa-psk:<wpa hexadecimal key>", i + 1);
11941 #else
11942       g_string_printf(key_name, "wep_key%d", i + 1);
11943       g_string_printf(key_title, "WEP key #%d", i + 1);
11944       g_string_printf(key_desc, "WEP key #%d can be:"
11945         "   <wep hexadecimal key>;"
11946         "   wep:<wep hexadecimal key>", i + 1);
11947 #endif
11948
11949     prefs_register_string_preference(wlan_module, key_name->str,
11950         key_title->str, key_desc->str, (const char **) &wep_keystr[i]);
11951
11952     g_string_free(key_name, FALSE);
11953     g_string_free(key_title, FALSE);
11954     g_string_free(key_desc, FALSE);
11955   }
11956 #endif
11957 }
11958
11959 void
11960 proto_reg_handoff_ieee80211(void)
11961 {
11962   dissector_handle_t radio_handle;
11963   dissector_handle_t prism_handle;
11964
11965   /*
11966    * Get handles for the LLC, IPX and Ethernet  dissectors.
11967    */
11968   llc_handle = find_dissector("llc");
11969   ipx_handle = find_dissector("ipx");
11970   eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
11971   data_handle = find_dissector("data");
11972
11973   ieee80211_handle = find_dissector("wlan");
11974   dissector_add("wtap_encap", WTAP_ENCAP_IEEE_802_11, ieee80211_handle);
11975   dissector_add("ethertype", ETHERTYPE_CENTRINO_PROMISC, ieee80211_handle);
11976
11977   /* Register handoff to radio-header dissectors */
11978   radio_handle = create_dissector_handle(dissect_radio, proto_radio);
11979   dissector_add("wtap_encap", WTAP_ENCAP_IEEE_802_11_WITH_RADIO, radio_handle);
11980
11981   prism_handle = create_dissector_handle(dissect_prism, proto_prism);
11982   dissector_add("wtap_encap", WTAP_ENCAP_PRISM_HEADER, prism_handle);
11983
11984   wlancap_handle = create_dissector_handle(dissect_wlancap, proto_wlancap);
11985   dissector_add("wtap_encap", WTAP_ENCAP_IEEE_802_11_WLAN_AVS, wlancap_handle);
11986
11987   /* Register handoff to Aruba GRE */
11988   dissector_add("gre.proto", GRE_ARUBA_8200, ieee80211_handle);
11989   dissector_add("gre.proto", GRE_ARUBA_8210, ieee80211_handle);
11990   dissector_add("gre.proto", GRE_ARUBA_8220, ieee80211_handle);
11991   dissector_add("gre.proto", GRE_ARUBA_8230, ieee80211_handle);
11992   dissector_add("gre.proto", GRE_ARUBA_8240, ieee80211_handle);
11993   dissector_add("gre.proto", GRE_ARUBA_8250, ieee80211_handle);
11994   dissector_add("gre.proto", GRE_ARUBA_8260, ieee80211_handle);
11995   dissector_add("gre.proto", GRE_ARUBA_8270, ieee80211_handle);
11996   dissector_add("gre.proto", GRE_ARUBA_8280, ieee80211_handle);
11997   dissector_add("gre.proto", GRE_ARUBA_8290, ieee80211_handle);
11998   dissector_add("gre.proto", GRE_ARUBA_82A0, ieee80211_handle);
11999   dissector_add("gre.proto", GRE_ARUBA_82B0, ieee80211_handle);
12000   dissector_add("gre.proto", GRE_ARUBA_82C0, ieee80211_handle);
12001   dissector_add("gre.proto", GRE_ARUBA_82D0, ieee80211_handle);
12002   dissector_add("gre.proto", GRE_ARUBA_82E0, ieee80211_handle);
12003   dissector_add("gre.proto", GRE_ARUBA_82F0, ieee80211_handle);
12004   dissector_add("gre.proto", GRE_ARUBA_8300, ieee80211_handle);
12005   dissector_add("gre.proto", GRE_ARUBA_8310, ieee80211_handle);
12006   dissector_add("gre.proto", GRE_ARUBA_8320, ieee80211_handle);
12007   dissector_add("gre.proto", GRE_ARUBA_8330, ieee80211_handle);
12008   dissector_add("gre.proto", GRE_ARUBA_8340, ieee80211_handle);
12009   dissector_add("gre.proto", GRE_ARUBA_8350, ieee80211_handle);
12010   dissector_add("gre.proto", GRE_ARUBA_8360, ieee80211_handle);
12011   dissector_add("gre.proto", GRE_ARUBA_8370, ieee80211_handle);
12012 }
12013
12014 #ifdef HAVE_AIRPDCAP
12015 /* Davide Schiera (2006-11-26): this function will try to decrypt with WEP or  */
12016 /* WPA and return a tvb to the caller to add a new tab. It returns the    */
12017 /* algorithm used for decryption (WEP, TKIP, CCMP) and the header and    */
12018 /* trailer lengths.                                      */
12019 static tvbuff_t *
12020 try_decrypt(tvbuff_t *tvb, guint offset, guint len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer) {
12021   const guint8 *enc_data;
12022   guint8 *tmp = NULL;
12023   tvbuff_t *decr_tvb = NULL;
12024   guint32 dec_caplen;
12025   guchar dec_data[AIRPDCAP_MAX_CAPLEN];
12026   AIRPDCAP_KEY_ITEM used_key;
12027
12028   if (!enable_decryption)
12029     return NULL;
12030
12031   /* get the entire packet                                  */
12032   enc_data = tvb_get_ptr(tvb, 0, len+offset);
12033
12034   /*  process packet with AirPDcap                              */
12035   if (AirPDcapPacketProcess(&airpdcap_ctx, enc_data, offset, offset+len, dec_data, &dec_caplen, &used_key, FALSE, TRUE)==AIRPDCAP_RET_SUCCESS)
12036   {
12037     *algorithm=used_key.KeyType;
12038     switch (*algorithm) {
12039       case AIRPDCAP_KEY_TYPE_WEP:
12040         *sec_header=AIRPDCAP_WEP_HEADER;
12041         *sec_trailer=AIRPDCAP_WEP_TRAILER;
12042         break;
12043       case AIRPDCAP_KEY_TYPE_CCMP:
12044         *sec_header=AIRPDCAP_RSNA_HEADER;
12045         *sec_trailer=AIRPDCAP_CCMP_TRAILER;
12046         break;
12047       case AIRPDCAP_KEY_TYPE_TKIP:
12048         *sec_header=AIRPDCAP_RSNA_HEADER;
12049         *sec_trailer=AIRPDCAP_TKIP_TRAILER;
12050         break;
12051       default:
12052         return NULL;
12053     }
12054
12055     /* allocate buffer for decrypted payload                      */
12056     if ((tmp = g_malloc(dec_caplen-offset)) == NULL)
12057       return NULL;  /* krap! */
12058     memcpy(tmp, dec_data+offset, dec_caplen-offset);
12059
12060     len=dec_caplen-offset;
12061
12062     /* decrypt successful, let's set up a new data tvb.              */
12063     decr_tvb = tvb_new_real_data(tmp, len, len);
12064     tvb_set_free_cb(decr_tvb, g_free);
12065     tvb_set_child_real_data_tvbuff(tvb, decr_tvb);
12066   } else
12067     g_free(tmp);
12068
12069   return decr_tvb;
12070 }
12071 /*  Davide Schiera -----------------------------------------------------------  */
12072 #else
12073
12074 static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
12075   const guint8 *enc_data;
12076   guint8 *tmp = NULL;
12077   int i;
12078   tvbuff_t *decr_tvb = NULL;
12079
12080   if (! enable_decryption)
12081     return NULL;
12082
12083   enc_data = tvb_get_ptr(tvb, offset, len);
12084
12085   if ((tmp = g_malloc(len)) == NULL)
12086     return NULL;  /* krap! */
12087
12088   /* try once with the key index in the packet, then look through our list. */
12089   for (i = 0; i < num_wepkeys; i++) {
12090     /* copy the encrypted data over to the tmp buffer */
12091 #if 0
12092     printf("trying %d\n", i);
12093 #endif
12094     memcpy(tmp, enc_data, len);
12095     if (wep_decrypt(tmp, len, i) == 0) {
12096
12097       /* decrypt successful, let's set up a new data tvb. */
12098       decr_tvb = tvb_new_real_data(tmp, len-8, len-8);
12099       tvb_set_free_cb(decr_tvb, g_free);
12100       tvb_set_child_real_data_tvbuff(tvb, decr_tvb);
12101
12102       break;
12103     }
12104   }
12105
12106   if ((!decr_tvb) && (tmp))    g_free(tmp);
12107
12108 #if 0
12109   printf("de-wep %p\n", decr_tvb);
12110 #endif
12111
12112   return decr_tvb;
12113 }
12114 #endif
12115
12116 /*
12117  * Convert a raw WEP key or one prefixed with "wep:" to a byte array.
12118  * Separators are allowed.
12119  */
12120 /* XXX This is duplicated in epan/airpdcap.c:parse_key_string() */
12121 static gboolean
12122 wep_str_to_bytes(const char *hex_str, GByteArray *bytes) {
12123   char *first_nibble = (char *) hex_str;
12124
12125   if (g_ascii_strncasecmp(hex_str, STRING_KEY_TYPE_WEP ":", 4) == 0) {
12126     first_nibble += 4;
12127   }
12128
12129   return hex_str_to_bytes(first_nibble, bytes, FALSE);
12130 }
12131
12132 /* Collect our WEP and WPA keys */
12133 #ifdef HAVE_AIRPDCAP
12134 static
12135 void set_airpdcap_keys(void)
12136 {
12137   guint i = 0;
12138   AIRPDCAP_KEY_ITEM key;
12139   PAIRPDCAP_KEYS_COLLECTION keys;
12140   decryption_key_t* dk = NULL;
12141   GByteArray *bytes = NULL;
12142   gboolean res;
12143   gchar* tmpk = NULL;
12144
12145   keys=(PAIRPDCAP_KEYS_COLLECTION)g_malloc(sizeof(AIRPDCAP_KEYS_COLLECTION));
12146   keys->nKeys = 0;
12147
12148   for(i = 0; i < MAX_ENCRYPTION_KEYS; i++)
12149   {
12150     tmpk = g_strdup(wep_keystr[i]);
12151
12152     dk = parse_key_string(tmpk);
12153
12154     if(dk != NULL)
12155     {
12156       if(dk->type == AIRPDCAP_KEY_TYPE_WEP)
12157       {
12158         key.KeyType = AIRPDCAP_KEY_TYPE_WEP;
12159
12160         bytes = g_byte_array_new();
12161         res = wep_str_to_bytes(dk->key->str, bytes);
12162
12163         if (dk->key->str && res && bytes->len > 0 && bytes->len <= AIRPDCAP_WEP_KEY_MAXLEN)
12164         {
12165           /*
12166            * WEP key is correct (well, the can be even or odd, so it is not
12167            * a real check, I think... is a check performed somewhere in the
12168            * AirPDcap function??? )
12169            */
12170           memcpy(key.KeyData.Wep.WepKey, bytes->data, bytes->len);
12171           key.KeyData.Wep.WepKeyLen = bytes->len;
12172           keys->Keys[keys->nKeys] = key;
12173           keys->nKeys++;
12174         }
12175       }
12176       else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
12177       {
12178         key.KeyType = AIRPDCAP_KEY_TYPE_WPA_PWD;
12179
12180         /* XXX - This just lops the end if the key off if it's too long.
12181          *       Should we handle this more gracefully? */
12182         g_strlcpy(key.UserPwd.Passphrase, dk->key->str, AIRPDCAP_WPA_PASSPHRASE_MAX_LEN);
12183
12184         key.UserPwd.SsidLen = 0;
12185         if(dk->ssid != NULL && dk->ssid->len <= AIRPDCAP_WPA_SSID_MAX_LEN)
12186         {
12187           memcpy(key.UserPwd.Ssid, dk->ssid->data, dk->ssid->len);
12188           key.UserPwd.SsidLen = dk->ssid->len;
12189         }
12190
12191         keys->Keys[keys->nKeys] = key;
12192         keys->nKeys++;
12193       }
12194       else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
12195       {
12196         key.KeyType = AIRPDCAP_KEY_TYPE_WPA_PMK;
12197
12198         bytes = g_byte_array_new();
12199         res = wep_str_to_bytes(dk->key->str, bytes);
12200
12201         /* XXX - Pass the correct array of bytes... */
12202         if (bytes-> len <= AIRPDCAP_WPA_PMK_LEN) {
12203           memcpy(key.KeyData.Wpa.Pmk, bytes->data, bytes->len);
12204
12205           keys->Keys[keys->nKeys] = key;
12206           keys->nKeys++;
12207         }
12208       }
12209     }
12210     if(tmpk != NULL) g_free(tmpk);
12211   }
12212
12213   /* Now set the keys */
12214   AirPDcapSetKeys(&airpdcap_ctx,keys->Keys,keys->nKeys);
12215   g_free(keys);
12216   if (bytes)
12217     g_byte_array_free(bytes, TRUE);
12218
12219 }
12220 #endif
12221
12222 #ifndef HAVE_AIRPDCAP
12223 /* de-weps the block.  if successful, buf* will point to the data start. */
12224 static int wep_decrypt(guint8 *buf, guint32 len, int keyidx) {
12225   guint32 i, j, k, crc, keylen;
12226   guint8 s[256], key[128], c_crc[4];
12227   guint8 *dpos, *cpos;
12228
12229   /* Needs to be at least 8 bytes of payload */
12230   if (len < 8)
12231     return -1;
12232
12233   /* initialize the first bytes of the key from the IV */
12234   key[0] = buf[0];
12235   key[1] = buf[1];
12236   key[2] = buf[2];
12237
12238   if (keyidx < 0 || keyidx >= num_wepkeys)
12239     return -1;
12240
12241   keylen = wep_keylens[keyidx];
12242
12243   if (keylen == 0)
12244     return -1;
12245   if (wep_keys[keyidx] == NULL)
12246     return -1;
12247
12248   keylen+=3;  /* add in ICV bytes */
12249
12250   /* copy the rest of the key over from the designated key */
12251   memcpy(key+3, wep_keys[keyidx], wep_keylens[keyidx]);
12252
12253 #if 0
12254   printf("%d: %02x %02x %02x (%d %d) %02x:%02x:%02x:%02x:%02x\n", len, key[0], key[1], key[2], keyidx, keylen, key[3], key[4], key[5], key[6], key[7]);
12255 #endif
12256
12257   /* set up the RC4 state */
12258   for (i = 0; i < 256; i++)
12259     s[i] = i;
12260   j = 0;
12261   for (i = 0; i < 256; i++) {
12262     j = (j + s[i] + key[i % keylen]) & 0xff;
12263     SSWAP(i,j);
12264   }
12265
12266   /* Apply the RC4 to the data, update the CRC32 */
12267   cpos = buf+4;
12268   dpos = buf;
12269   crc = ~0;
12270   i = j = 0;
12271   for (k = 0; k < (len -8); k++) {
12272     i = (i+1) & 0xff;
12273     j = (j+s[i]) & 0xff;
12274     SSWAP(i,j);
12275 #if 0
12276     printf("%d -- %02x ", k, *dpos);
12277 #endif
12278     *dpos = *cpos++ ^ s[(s[i] + s[j]) & 0xff];
12279 #if 0
12280     printf("%02x\n", *dpos);
12281 #endif
12282     crc = crc32_ccitt_table[(crc ^ *dpos++) & 0xff] ^ (crc >> 8);
12283   }
12284   crc = ~crc;
12285
12286   /* now let's check the crc */
12287   c_crc[0] = crc;
12288   c_crc[1] = crc >> 8;
12289   c_crc[2] = crc >> 16;
12290   c_crc[3] = crc >> 24;
12291
12292   for (k = 0; k < 4; k++) {
12293     i = (i + 1) & 0xff;
12294     j = (j+s[i]) & 0xff;
12295     SSWAP(i,j);
12296 #if 0
12297     printf("-- %02x %02x\n", *dpos, c_crc[k]);
12298 #endif
12299     if ((*cpos++ ^ s[(s[i] + s[j]) & 0xff]) != c_crc[k])
12300       return -1; /* ICV mismatch */
12301   }
12302
12303   return 0;
12304 }
12305 #endif
12306
12307 static void init_wepkeys(void) {
12308 #ifndef  HAVE_AIRPDCAP
12309   const char *tmp;
12310   int i, keyidx;
12311   GByteArray *bytes;
12312   gboolean res;
12313
12314   if (wep_keys) {
12315     for (i = 0; i < num_wepkeys; i++)
12316       g_free(wep_keys[i]);
12317     g_free(wep_keys);
12318   }
12319
12320   if (wep_keylens)
12321     g_free(wep_keylens);
12322
12323 #ifdef USE_ENV
12324   guint8 *buf;
12325
12326   tmp = getenv("WIRESHARK_WEPKEYNUM");
12327   if (!tmp) {
12328     num_wepkeys = 0;
12329     return;
12330   }
12331   num_wepkeys = atoi(tmp);
12332
12333   if (num_wepkeys < 1)
12334     return;
12335 #endif
12336
12337   /* Figure out how many valid keys we have */
12338   bytes = g_byte_array_new();
12339   num_wepkeys = 0;
12340   for ( i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
12341     g_strstrip(wep_keystr[i]);
12342     res = wep_str_to_bytes(wep_keystr[i], bytes);
12343     if (wep_keystr[i] && res && bytes-> len > 0) {
12344       num_wepkeys++;
12345     }
12346   }
12347
12348   wep_keys = g_malloc0(num_wepkeys * sizeof(guint8*));
12349   wep_keylens = g_malloc(num_wepkeys * sizeof(int));
12350
12351   for (i = 0, keyidx = 0; i < MAX_ENCRYPTION_KEYS && keyidx < num_wepkeys; i++) {
12352     wep_keys[keyidx] = NULL;
12353     wep_keylens[keyidx] = 0;
12354
12355 #ifdef USE_ENV
12356     buf=ep_alloc(128);
12357     g_snprintf(buf, 128, "WIRESHARK_WEPKEY%d", i+1);
12358     tmp = getenv(buf);
12359 #else
12360     tmp = wep_keystr[i];
12361 #endif
12362
12363     if (tmp) {
12364 #if 0
12365 #ifdef USE_ENV
12366       printf("%s -- %s\n", buf, tmp);
12367 #else
12368       printf("%d -- %s\n", i+1, tmp);
12369 #endif
12370 #endif
12371
12372       if (wep_keys[keyidx]) {
12373         g_free(wep_keys[keyidx]);
12374       }
12375
12376       res = wep_str_to_bytes(tmp, bytes);
12377       if (tmp && res && bytes->len > 0) {
12378         if (bytes->len > 32) {
12379           bytes->len = 32;
12380         }
12381         wep_keys[keyidx] = g_malloc0(32 * sizeof(guint8));
12382         memcpy(wep_keys[keyidx], bytes->data, bytes->len * sizeof(guint8));
12383         wep_keylens[keyidx] = bytes->len;
12384         keyidx++;
12385 #if 0
12386         printf("%d: %d bytes\n", i, bytes->len);
12387         printf("%d: %s\n", i, bytes_to_str(bytes->data, bytes->len));
12388 #endif
12389       } else {
12390 #if 0
12391         printf("res: %d  bytes->len: %d\n", res, bytes->len);
12392 #endif
12393         if (tmp[0] != 'w') /* Assume it begins with "wep:" or "wpa-*:" */
12394           g_warning("Could not parse WEP key %d: %s", i + 1, tmp);
12395       }
12396     }
12397   }
12398   g_byte_array_free(bytes, TRUE);
12399
12400 #else /* HAVE_AIRPDCAP defined */
12401
12402   /*
12403    * XXX - AirPDcap - That God sends it to us beautiful (che dio ce la mandi bona)
12404    * The next lines will add a key to the AirPDcap context. The keystring will be added
12405    * to the old WEP array too, but we don't care, because the packets will come here
12406    * already decrypted... One of these days we will fix this too
12407    */
12408   set_airpdcap_keys();
12409 #endif /* HAVE_AIRPDCAP */
12410 }
12411 /*
12412  * This code had been taken from AirSnort crack.c function classify()
12413  * Permission granted by snax <at> shmoo dot com
12414  * weak_iv - determine which key byte an iv is useful in resolving
12415  * parm     - p, pointer to the first byte of an IV
12416  * return   -  n - this IV is weak for byte n of a WEP key
12417  *            -1 - this IV is not weak for any key bytes
12418  *
12419  * This function tests for IVs that are known to satisfy the criteria
12420  * for a weak IV as specified in FMS section 7.1
12421  *
12422  */
12423 static int
12424 weak_iv(guchar *iv)
12425 {
12426         guchar sum, k;
12427
12428         if (iv[1] == 255 && iv[0] > 2 && iv[0] < 16) {
12429                 return iv[0] -3;
12430         }
12431
12432         sum = iv[0] + iv[1];
12433         if (sum == 1) {
12434                 if (iv[2] <= 0x0a) {
12435                         return iv[2] +2;
12436                 }
12437                 else if (iv[2] == 0xff){
12438                         return 0;
12439                 }
12440         }
12441         k = 0xfe - iv[2];
12442         if (sum == k  && (iv[2] >= 0xf2 && iv[2] <= 0xfe && iv[2] != 0xfd)){
12443                 return k;
12444         }
12445         return -1;
12446 }
12447
12448 /*
12449  * Editor modelines
12450  *
12451  * Local Variables:
12452  * c-basic-offset: 2
12453  * tab-width: 8
12454  * indent-tabs-mode: nil
12455  * End:
12456  *
12457  * ex: set shiftwidth=2 tabstop=8 expandtab
12458  * :indentSize=2:tabSize=8:noTabs=true:
12459  */