Trivial warning fixes
[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/oui.h>
77 #include <epan/crc32.h>
78 #include <epan/tap.h>
79 #include <epan/emem.h>
80 #include <epan/crypt/wep-wpadefs.h>
81
82 #include <ctype.h>
83 #include "isprint.h"
84
85 #include "packet-wps.h"
86
87 #ifndef roundup2
88 #define roundup2(x, y)  (((x)+((y)-1))&(~((y)-1)))  /* if y is powers of two */
89 #endif
90
91 /* Defragment fragmented 802.11 datagrams */
92 static gboolean wlan_defragment = TRUE;
93
94 /* call subdissector for retransmitted frames */
95 static gboolean wlan_subdissector = TRUE;
96
97 /* Check for the presence of the 802.11 FCS */
98 static gboolean wlan_check_fcs = FALSE;
99
100 /* Ignore vendor-specific HT elements */
101 static gboolean wlan_ignore_draft_ht = FALSE;
102
103 /* Ignore the WEP bit; assume packet is decrypted */
104 #define WLAN_IGNORE_WEP_NO     0
105 #define WLAN_IGNORE_WEP_WO_IV  1
106 #define WLAN_IGNORE_WEP_W_IV   2
107 static gint wlan_ignore_wep = WLAN_IGNORE_WEP_NO;
108
109 /* Tables for reassembly of fragments. */
110 static GHashTable *wlan_fragment_table = NULL;
111 static GHashTable *wlan_reassembled_table = NULL;
112
113 /* Statistical data */
114 static struct _wlan_stats wlan_stats;
115
116 /* Stuff for the WEP decoder */
117 static gboolean enable_decryption = FALSE;
118 static void init_wepkeys(void);
119
120 #ifndef HAVE_AIRPDCAP
121 static gint num_wepkeys = 0;
122 static guint8 **wep_keys = NULL;
123 static int *wep_keylens = NULL;
124 static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len);
125 static int wep_decrypt(guint8 *buf, guint32 len, int key_override);
126 #else
127 /* Davide Schiera (2006-11-26): created function to decrypt WEP and WPA/WPA2  */
128 static tvbuff_t *try_decrypt(tvbuff_t *tvb, guint32 offset, guint32 len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer);
129 #endif
130
131 static int weak_iv(guchar *iv);
132 #define SSWAP(a,b) {guint8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;}
133
134 /* #define USE_ENV */
135 /* When this is set, an unlimited number of WEP keys can be set in the
136    environment:
137
138    WIRESHARK_WEPKEYNUM=##
139    WIRESHARK_WEPKEY1=aa:bb:cc:dd:...
140    WIRESHARK_WEPKEY2=aa:bab:cc:dd:ee:...
141
142    ... you get the idea.
143
144    otherwise you're limited to specifying four keys in the preference system.
145  */
146
147 #ifndef USE_ENV
148 static char *wep_keystr[MAX_ENCRYPTION_KEYS];
149 #endif
150
151 typedef struct mimo_control
152   {
153     guint8 nc;
154     guint8 nr;
155     gboolean chan_width;
156     guint8 grouping;
157     guint8 coefficient_size;
158     guint8 codebook_info;
159     guint8 remaining_matrix_segment;
160   } mimo_control_t;
161
162 mimo_control_t get_mimo_control (tvbuff_t *tvb, int offset);
163 int add_mimo_csi_matrices_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl);
164 int add_mimo_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl);
165 int add_mimo_compressed_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl);
166
167 /* ************************************************************************* */
168 /*                          Miscellaneous Constants                          */
169 /* ************************************************************************* */
170 #define SHORT_STR 256
171
172 /* ************************************************************************* */
173 /*  Define some very useful macros that are used to analyze frame types etc. */
174 /* ************************************************************************* */
175
176 /*
177  * Fetch the frame control field and swap it if needed.  "fcf" and "tvb"
178  * must be valid variables.
179  */
180 #define FETCH_FCF(off) (wlan_broken_fc ? \
181   BSWAP16(tvb_get_letohs(tvb, off)) : \
182   tvb_get_letohs(tvb, off))
183
184 /*
185  * Extract the protocol version from the frame control field
186  */
187 #define FCF_PROT_VERSION(x)  ((x) & 0x3)
188
189 /*
190  * Extract the frame type from the frame control field.
191  */
192 #define FCF_FRAME_TYPE(x)    (((x) & 0xC) >> 2)
193
194 /*
195  * Extract the frame subtype from the frame control field.
196  */
197 #define FCF_FRAME_SUBTYPE(x) (((x) & 0xF0) >> 4)
198
199 /*
200  * Convert the frame type and subtype from the frame control field into
201  * one of the MGT_, CTRL_, or DATA_ values.
202  */
203 #define COMPOSE_FRAME_TYPE(x) (((x & 0x0C)<< 2)+FCF_FRAME_SUBTYPE(x))  /* Create key to (sub)type */
204
205 /*
206  * The subtype field of a data frame is, in effect, composed of 4 flag
207  * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
208  * any data), and QoS.
209  */
210 #define DATA_FRAME_IS_CF_ACK(x)  ((x) & 0x01)
211 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
212 #define DATA_FRAME_IS_NULL(x)    ((x) & 0x04)
213 #define DATA_FRAME_IS_QOS(x)     ((x) & 0x08)
214
215 /*
216  * Extract the flags from the frame control field.
217  */
218 #define FCF_FLAGS(x)           (((x) & 0xFF00) >> 8)
219
220 /*
221  * Bits from the flags field.
222  */
223 #define FLAG_TO_DS            0x01
224 #define FLAG_FROM_DS          0x02
225 #define FLAG_MORE_FRAGMENTS   0x04
226 #define FLAG_RETRY            0x08
227 #define FLAG_POWER_MGT        0x10
228 #define FLAG_MORE_DATA        0x20
229 #define FLAG_PROTECTED        0x40
230 #define FLAG_ORDER            0x80
231
232 /*
233  * Test bits in the flags field.
234  */
235 /*
236  * XXX - Only HAVE_FRAGMENTS, IS_PROTECTED, and IS_STRICTLY_ORDERED
237  * are in use.  Should the rest be removed?
238  */
239 #define IS_TO_DS(x)            ((x) & FLAG_TO_DS)
240 #define IS_FROM_DS(x)          ((x) & FLAG_FROM_DS)
241 #define HAVE_FRAGMENTS(x)      ((x) & FLAG_MORE_FRAGMENTS)
242 #define IS_RETRY(x)            ((x) & FLAG_RETRY)
243 #define POWER_MGT_STATUS(x)    ((x) & FLAG_POWER_MGT)
244 #define HAS_MORE_DATA(x)       ((x) & FLAG_MORE_DATA)
245 #define IS_PROTECTED(x)        ((x) & FLAG_PROTECTED)
246 #define IS_STRICTLY_ORDERED(x) ((x) & FLAG_ORDER)
247
248 /*
249  * Extract subfields from the flags field.
250  */
251 #define FLAGS_DS_STATUS(x)          ((x) & (FLAG_FROM_DS|FLAG_TO_DS))
252
253 /*
254  * Extract an indication of the types of addresses in a data frame from
255  * the frame control field.
256  */
257 #define FCF_ADDR_SELECTOR(x) ((x) & ((FLAG_TO_DS|FLAG_FROM_DS) << 8))
258
259 #define DATA_ADDR_T1         0
260 #define DATA_ADDR_T2         (FLAG_FROM_DS << 8)
261 #define DATA_ADDR_T3         (FLAG_TO_DS << 8)
262 #define DATA_ADDR_T4         ((FLAG_TO_DS|FLAG_FROM_DS) << 8)
263
264 /*
265  * Extract the fragment number and sequence number from the sequence
266  * control field.
267  */
268 #define SEQCTL_FRAGMENT_NUMBER(x) ((x) & 0x000F)
269 #define SEQCTL_SEQUENCE_NUMBER(x) (((x) & 0xFFF0) >> 4)
270
271 /*
272  * Extract subfields from the QoS control field.
273  */
274 #define QOS_TID(x)            ((x) & 0x000F)
275 #define QOS_PRIORITY(x)       ((x) & 0x0007)
276 #define QOS_EOSP(x)           (((x) & 0x0010) >> 4) /* end of service period */
277 #define QOS_ACK_POLICY(x)     (((x) & 0x0060) >> 5)
278 #define QOS_AMSDU_PRESENT(x)  (((x) & 0x0080) >> 6)
279 #define QOS_FIELD_CONTENT(x)  (((x) & 0xFF00) >> 8)
280
281 #define QOS_FLAG_EOSP    0x10
282
283 /*
284  * Extract subfields from the result of QOS_FIELD_CONTENT().
285  */
286 #define QOS_PS_BUF_STATE(x)  (((x) & 0x02) >> 1)
287 #define QOS_PS_BUF_AC(x)     (((x) & 0x0C) >> 2)
288 #define QOS_PS_BUF_LOAD(x)   (((x) & 0xF0) >> 4)
289
290 /*
291  * Extract subfields from the HT Control field.
292  * .11n D-1.10 & D-2.0, 7.1.3.5a, 32 bits.
293  */
294 #define HTC_LAC(htc)           ((htc) & 0xFF)
295 #define HTC_LAC_MAI(htc)       (((htc) >> 2) & 0xF)
296 #define HTC_IS_ASELI(htc)      (HTC_LAC_MAI(htc) == 0xE)
297 #define HTC_LAC_MAI_MRQ(htc)   ((HTC_LAC_MAI(htc))  & 0x1)
298 #define HTC_LAC_MAI_MSI(htc)   ((HTC_LAC_MAI(htc) >> 1) & 0x7)
299 #define HTC_LAC_MFSI(htc)      (((htc) >> 4) & 0x7)
300 #define HTC_LAC_ASEL_CMD(htc)  (((htc) >> 9) & 0x7)
301 #define HTC_LAC_ASEL_DATA(htc) (((htc) >> 12) & 0xF)
302 #define HTC_LAC_MFB(htc)       (((htc) >> 9) & 0x7F)
303 #define HTC_CAL_POS(htc)       (((htc) >> 16) & 0x3)
304 #define HTC_CAL_SEQ(htc)       (((htc) >> 18) & 0x3)
305 #define HTC_CSI_STEERING(htc)  (((htc) >> 22) & 0x3)
306 #define HTC_NDP_ANN(htc)       (((htc) >> 24) & 0x1)
307 #define HTC_AC_CONSTRAINT(htc) (((htc) >> 30) & 0x1)
308 #define HTC_RDG_MORE_PPDU(htc) (((htc) >> 31) & 0x1)
309
310 /*
311  * Extract the association ID from the value in an association ID field.
312  */
313 #define ASSOC_ID(x)            ((x) & 0x3FFF)
314
315 /*
316  * Extract subfields from the key octet in WEP-encrypted frames.
317  */
318 #define KEY_OCTET_WEP_KEY(x)   (((x) & 0xC0) >> 6)
319
320 /*
321  * Extract subfields from TS Info field.
322  */
323 #define TSI_TYPE(x)      (((x) & 0x000001) >> 0)
324 #define TSI_TSID(x)      (((x) & 0x00001E) >> 1)
325 #define TSI_DIR(x)       (((x) & 0x000060) >> 5)
326 #define TSI_ACCESS(x)    (((x) & 0x000180) >> 7)
327 #define TSI_AGG(x)       (((x) & 0x000200) >> 9)
328 #define TSI_APSD(x)      (((x) & 0x000400) >> 10)
329 #define TSI_UP(x)        (((x) & 0x003800) >> 11)
330 #define TSI_ACK(x)       (((x) & 0x00C000) >> 14)
331 #define TSI_SCHED(x)     (((x) & 0x010000) >> 16)
332 #define TSI_RESERVED(x)  (((x) & 0xFE0000) >> 17)
333
334 #define KEY_EXTIV    0x20
335 #define EXTIV_LEN    8
336
337
338 /* ************************************************************************* */
339 /*              Constants used to identify cooked frame types                */
340 /* ************************************************************************* */
341 #define MGT_FRAME            0x00  /* Frame type is management */
342 #define CONTROL_FRAME        0x01  /* Frame type is control */
343 #define DATA_FRAME           0x02  /* Frame type is Data */
344
345 #define DATA_SHORT_HDR_LEN     24
346 #define DATA_LONG_HDR_LEN      30
347 #define MGT_FRAME_HDR_LEN      24  /* Length of Managment frame-headers */
348
349 /*
350  * COMPOSE_FRAME_TYPE() values for management frames.
351  */
352 #define MGT_ASSOC_REQ          0x00  /* association request        */
353 #define MGT_ASSOC_RESP         0x01  /* association response       */
354 #define MGT_REASSOC_REQ        0x02  /* reassociation request      */
355 #define MGT_REASSOC_RESP       0x03  /* reassociation response     */
356 #define MGT_PROBE_REQ          0x04  /* Probe request              */
357 #define MGT_PROBE_RESP         0x05  /* Probe response             */
358 #define MGT_MEASUREMENT_PILOT  0x06  /* Measurement Pilot          */
359 #define MGT_BEACON             0x08  /* Beacon frame               */
360 #define MGT_ATIM               0x09  /* ATIM                       */
361 #define MGT_DISASS             0x0A  /* Disassociation             */
362 #define MGT_AUTHENTICATION     0x0B  /* Authentication             */
363 #define MGT_DEAUTHENTICATION   0x0C  /* Deauthentication           */
364 #define MGT_ACTION             0x0D  /* Action                     */
365 #define MGT_ACTION_NO_ACK      0x0E  /* Action No Ack              */
366 #define MGT_ARUBA_WLAN         0x0F  /* Aruba WLAN Specific        */
367
368 /*
369  * COMPOSE_FRAME_TYPE() values for control frames.
370  */
371 #define CTRL_CONTROL_WRAPPER 0x17  /* Control Wrapper        */
372 #define CTRL_BLOCK_ACK_REQ   0x18  /* Block ack Request        */
373 #define CTRL_BLOCK_ACK       0x19  /* Block ack          */
374 #define CTRL_PS_POLL         0x1A  /* power-save poll               */
375 #define CTRL_RTS             0x1B  /* request to send               */
376 #define CTRL_CTS             0x1C  /* clear to send                 */
377 #define CTRL_ACKNOWLEDGEMENT 0x1D  /* acknowledgement               */
378 #define CTRL_CFP_END         0x1E  /* contention-free period end    */
379 #define CTRL_CFP_ENDACK      0x1F  /* contention-free period end/ack */
380
381 /*
382  * COMPOSE_FRAME_TYPE() values for data frames.
383  */
384 #define DATA                        0x20  /* Data                       */
385 #define DATA_CF_ACK                 0x21  /* Data + CF-Ack              */
386 #define DATA_CF_POLL                0x22  /* Data + CF-Poll             */
387 #define DATA_CF_ACK_POLL            0x23  /* Data + CF-Ack + CF-Poll    */
388 #define DATA_NULL_FUNCTION          0x24  /* Null function (no data)    */
389 #define DATA_CF_ACK_NOD             0x25  /* CF-Ack (no data)           */
390 #define DATA_CF_POLL_NOD            0x26  /* CF-Poll (No data)          */
391 #define DATA_CF_ACK_POLL_NOD        0x27  /* CF-Ack + CF-Poll (no data) */
392
393 #define DATA_QOS_DATA               0x28  /* QoS Data                   */
394 #define DATA_QOS_DATA_CF_ACK        0x29  /* QoS Data + CF-Ack        */
395 #define DATA_QOS_DATA_CF_POLL       0x2A  /* QoS Data + CF-Poll      */
396 #define DATA_QOS_DATA_CF_ACK_POLL   0x2B  /* QoS Data + CF-Ack + CF-Poll    */
397 #define DATA_QOS_NULL               0x2C  /* QoS Null        */
398 #define DATA_QOS_CF_POLL_NOD        0x2E  /* QoS CF-Poll (No Data)      */
399 #define DATA_QOS_CF_ACK_POLL_NOD    0x2F  /* QoS CF-Ack + CF-Poll (No Data) */
400
401
402 /* ************************************************************************* */
403 /*          Macros used to extract information about fixed fields            */
404 /* ************************************************************************* */
405 #define ESS_SET(x)  ((x) & 0x0001)
406 #define IBSS_SET(x) ((x) & 0x0002)
407
408
409
410 /* ************************************************************************* */
411 /*        Logical field codes (dissector's encoding of fixed fields)         */
412 /* ************************************************************************* */
413 #define FIELD_TIMESTAMP                 0x01  /* 64-bit timestamp                       */
414 #define FIELD_BEACON_INTERVAL           0x02  /* 16-bit beacon interval                 */
415 #define FIELD_CAP_INFO                  0x03  /* Add capability information tree        */
416 #define FIELD_AUTH_ALG                  0x04  /* Authentication algorithm used          */
417 #define FIELD_AUTH_TRANS_SEQ            0x05  /* Authentication sequence number         */
418 #define FIELD_CURRENT_AP_ADDR           0x06
419 #define FIELD_LISTEN_IVAL               0x07
420 #define FIELD_REASON_CODE               0x08
421 #define FIELD_ASSOC_ID                  0x09
422 #define FIELD_STATUS_CODE               0x0A
423 #define FIELD_CATEGORY_CODE             0x0B  /* Management action category */
424 #define FIELD_ACTION_CODE               0x0C  /* Management action code */
425 #define FIELD_DIALOG_TOKEN              0x0D  /* Management action dialog token */
426 #define FIELD_WME_ACTION_CODE           0x0E  /* Management notification action code */
427 #define FIELD_WME_DIALOG_TOKEN          0x0F  /* Management notification dialog token */
428 #define FIELD_WME_STATUS_CODE           0x10  /* Management notification setup response status code */
429 #define FIELD_QOS_ACTION_CODE           0x11
430 #define FIELD_QOS_TS_INFO               0x12
431 #define FIELD_DLS_ACTION_CODE           0x13
432 #define FIELD_DST_MAC_ADDR              0X14  /* DLS destination MAC address */
433 #define FIELD_SRC_MAC_ADDR              0X15  /* DLS source MAC address */
434 #define FIELD_DLS_TIMEOUT               0X16  /* DLS timeout value */
435 #define FIELD_SCHEDULE_INFO             0X17  /* Schedule Info field */
436 #define FIELD_ACTION                    0X18  /* Action field */
437 #define FIELD_BLOCK_ACK_ACTION_CODE     0x19
438 #define FIELD_QOS_INFO_AP               0x1A
439 #define FIELD_QOS_INFO_STA              0x1B
440 #define FIELD_BLOCK_ACK_PARAM           0x1C
441 #define FIELD_BLOCK_ACK_TIMEOUT         0x1D
442 #define FIELD_BLOCK_ACK_SSC             0x1E
443 #define FIELD_DELBA_PARAM_SET           0x1F
444 #define FIELD_MAX_REG_PWR               0x20
445 #define FIELD_MEASUREMENT_PILOT_INT     0x21
446 #define FIELD_COUNTRY_STR               0x22
447 #define FIELD_MAX_TX_PWR                0x23
448 #define FIELD_TX_PWR_USED               0x24
449 #define FIELD_TRANSCEIVER_NOISE_FLOOR   0x25
450 #define FIELD_DS_PARAM_SET              0x26
451 #define FIELD_CHANNEL_WIDTH             0x27
452 #define FIELD_SM_PWR_CNTRL              0x28
453 #define FIELD_PCO_PHASE_CNTRL           0x29
454 #define FIELD_PSMP_PARAM_SET            0x2A
455 #define FIELD_PSMP_STA_INFO             0x2B
456 #define FIELD_MIMO_CNTRL                0x2C
457 #define FIELD_ANT_SELECTION             0x2D
458 #define FIELD_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT 0x2E
459 #define FIELD_HT_INFORMATION            0x2F
460 #define FIELD_HT_ACTION_CODE            0x30
461
462 /* ************************************************************************* */
463 /*        Logical field codes (IEEE 802.11 encoding of tags)                 */
464 /* ************************************************************************* */
465 #define TAG_SSID                  0x00
466 #define TAG_SUPP_RATES            0x01
467 #define TAG_FH_PARAMETER          0x02
468 #define TAG_DS_PARAMETER          0x03
469 #define TAG_CF_PARAMETER          0x04
470 #define TAG_TIM                   0x05
471 #define TAG_IBSS_PARAMETER        0x06
472 #define TAG_COUNTRY_INFO          0x07
473 #define TAG_FH_HOPPING_PARAMETER  0x08
474 #define TAG_FH_HOPPING_TABLE      0x09
475 #define TAG_REQUEST               0x0A
476 #define TAG_QBSS_LOAD             0x0B
477 #define TAG_EDCA_PARAM_SET        0x0C
478 #define TAG_TSPEC                 0x0D
479 #define TAG_TCLAS                 0x0E
480 #define TAG_SCHEDULE              0x0F
481 #define TAG_CHALLENGE_TEXT        0x10
482 #define TAG_POWER_CONSTRAINT      0x20
483 #define TAG_POWER_CAPABILITY      0x21
484 #define TAG_TPC_REQUEST           0x22
485 #define TAG_TPC_REPORT            0x23
486 #define TAG_SUPPORTED_CHANNELS    0x24
487 #define TAG_CHANNEL_SWITCH_ANN    0x25
488 #define TAG_MEASURE_REQ           0x26
489 #define TAG_MEASURE_REP           0x27
490 #define TAG_QUIET                 0x28
491 #define TAG_IBSS_DFS              0x29
492 #define TAG_ERP_INFO              0x2A
493 #define TAG_TS_DELAY              0x2B
494 #define TAG_TCLAS_PROCESS         0x2C
495 #define TAG_HT_CAPABILITY         0x2D  /* IEEE Stc 802.11n/D2.0 */
496 #define TAG_QOS_CAPABILITY        0x2E
497 #define TAG_ERP_INFO_OLD          0x2F  /* IEEE Std 802.11g/D4.0 */
498 #define TAG_RSN_IE                0x30
499 /* Reserved 49 */
500 #define TAG_EXT_SUPP_RATES        0x32
501 #define TAG_NEIGHBOR_REPORT       0x34
502 #define TAG_HT_INFO               0x3D  /* IEEE Stc 802.11n/D2.0 */
503 #define TAG_SECONDARY_CHANNEL_OFFSET 0x3E  /* IEEE Stc 802.11n/D1.10/D2.0 */
504 #define TAG_WSIE                         0x45   /* tag of the Wave Service Information (802.11p) */
505 #define TAG_20_40_BSS_CO_EX          0x48   /* IEEE P802.11n/D6.0 */
506 #define TAG_20_40_BSS_INTOL_CH_REP   0x49   /* IEEE P802.11n/D6.0 */
507 #define TAG_OVERLAP_BSS_SCAN_PAR     0x49   /* IEEE P802.11n/D6.0 */
508 #define TAG_EXTENDED_CAPABILITIES    0X7F   /* IEEE Stc 802.11n/D1.10/D2.0 */
509 #define TAG_AGERE_PROPRIETARY        0x80
510 #define TAG_CISCO_UNKNOWN_1          0x85  /* Cisco Compatible eXtensions */
511 #define TAG_CISCO_UNKNOWN_2          0x88  /* Cisco Compatible eXtensions? */
512 #define TAG_CISCO_UNKNOWN_3          0x95  /* Cisco Compatible eXtensions */
513 #define TAG_VENDOR_SPECIFIC_IE       0xDD
514 #define TAG_SYMBOL_PROPRIETARY       0xAD
515 #if 0 /* Not yet assigned tag numbers by ANA */
516 #define TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT    0xFF
517 #define TAG_SUPPORTED_REGULATORY_CLASSES            0xFE
518 #endif
519
520 #define WPA_OUI     (const guint8 *) "\x00\x50\xF2"
521 #define RSN_OUI     (const guint8 *) "\x00\x0F\xAC"
522 #define WME_OUI     (const guint8 *) "\x00\x50\xF2"
523 #define PRE_11N_OUI (const guint8 *) "\x00\x90\x4c" /* 802.11n pre 1 oui */
524
525 #define PMKID_LEN 16
526
527 /* ************************************************************************* */
528 /*              Wireless Access in Vehicular Environment  IEEE 802.11p       */
529 /* ************************************************************************* */
530 #define WAVE_ACID       0x0001
531 #define WAVE_ACM        0x0002
532 #define WAVE_ACF        0x0004
533 #define WAVE_PRIORITY   0x0008
534 #define WAVE_CHANNEL    0x0010
535 #define WAVE_IPV6ADDR   0x0020
536 #define WAVE_PEERMAC    0x0040
537
538 /* ************************************************************************* */
539 /*              Aruba GRE Encapulsation ID                                   */
540 /* ************************************************************************* */
541 #define GRE_ARUBA_8200  0x8200
542 #define GRE_ARUBA_8210  0x8210
543 #define GRE_ARUBA_8220  0x8220
544 #define GRE_ARUBA_8230  0x8230
545 #define GRE_ARUBA_8240  0x8240
546 #define GRE_ARUBA_8250  0x8250
547 #define GRE_ARUBA_8260  0x8260
548 #define GRE_ARUBA_8270  0x8270
549 #define GRE_ARUBA_8280  0x8280
550 #define GRE_ARUBA_8290  0x8290
551 #define GRE_ARUBA_82A0  0x82A0
552 #define GRE_ARUBA_82B0  0x82B0
553 #define GRE_ARUBA_82C0  0x82C0
554 #define GRE_ARUBA_82D0  0x82D0
555 #define GRE_ARUBA_82E0  0x82E0
556 #define GRE_ARUBA_82F0  0x82F0
557 #define GRE_ARUBA_8300  0x8300
558 #define GRE_ARUBA_8310  0x8310
559 #define GRE_ARUBA_8320  0x8320
560 #define GRE_ARUBA_8330  0x8330
561 #define GRE_ARUBA_8340  0x8340
562 #define GRE_ARUBA_8350  0x8350
563 #define GRE_ARUBA_8360  0x8360
564 #define GRE_ARUBA_8370  0x8370
565
566
567 /* ************************************************************************* */
568 /*                         Frame types, and their names                      */
569 /* ************************************************************************* */
570 static const value_string frame_type_subtype_vals[] = {
571   {MGT_ASSOC_REQ,        "Association Request"},
572   {MGT_ASSOC_RESP,       "Association Response"},
573   {MGT_REASSOC_REQ,      "Reassociation Request"},
574   {MGT_REASSOC_RESP,     "Reassociation Response"},
575   {MGT_PROBE_REQ,        "Probe Request"},
576   {MGT_PROBE_RESP,       "Probe Response"},
577   {MGT_MEASUREMENT_PILOT,"Measurement Pilot"},
578   {MGT_BEACON,           "Beacon frame"},
579   {MGT_ATIM,             "ATIM"},
580   {MGT_DISASS,           "Disassociate"},
581   {MGT_AUTHENTICATION,   "Authentication"},
582   {MGT_DEAUTHENTICATION, "Deauthentication"},
583   {MGT_ACTION,           "Action"},
584   {MGT_ACTION_NO_ACK,    "Action No Ack"},
585   {MGT_ARUBA_WLAN,       "Aruba Management"},
586
587   {CTRL_CONTROL_WRAPPER, "Control Wrapper"},
588   {CTRL_BLOCK_ACK_REQ,   "802.11 Block Ack Req"},
589   {CTRL_BLOCK_ACK,       "802.11 Block Ack"},
590   {CTRL_PS_POLL,         "Power-Save poll"},
591   {CTRL_RTS,             "Request-to-send"},
592   {CTRL_CTS,             "Clear-to-send"},
593   {CTRL_ACKNOWLEDGEMENT, "Acknowledgement"},
594   {CTRL_CFP_END,         "CF-End (Control-frame)"},
595   {CTRL_CFP_ENDACK,      "CF-End + CF-Ack (Control-frame)"},
596
597   {DATA,                      "Data"},
598   {DATA_CF_ACK,               "Data + CF-Ack"},
599   {DATA_CF_POLL,              "Data + CF-Poll"},
600   {DATA_CF_ACK_POLL,          "Data + CF-Ack + CF-Poll"},
601   {DATA_NULL_FUNCTION,        "Null function (No data)"},
602   {DATA_CF_ACK_NOD,           "Acknowledgement (No data)"},
603   {DATA_CF_POLL_NOD,          "CF-Poll (No data)"},
604   {DATA_CF_ACK_POLL_NOD,      "CF-Ack/Poll (No data)"},
605   {DATA_QOS_DATA,             "QoS Data"},
606   {DATA_QOS_DATA_CF_ACK,      "QoS Data + CF-Acknowledgment"},
607   {DATA_QOS_DATA_CF_POLL,     "QoS Data + CF-Poll"},
608   {DATA_QOS_DATA_CF_ACK_POLL, "QoS Data + CF-Ack + CF-Poll"},
609   {DATA_QOS_NULL,             "QoS Null function (No data)"},
610   {DATA_QOS_CF_POLL_NOD,      "QoS CF-Poll (No Data)"},
611   {DATA_QOS_CF_ACK_POLL_NOD,  "QoS CF-Ack + CF-Poll (No data)"},
612   {0,                         NULL}
613 };
614
615 /* ************************************************************************* */
616 /*                             802.1D Tag Names                              */
617 /* ************************************************************************* */
618 static const char *qos_tags[8] = {
619   "Best Effort",
620   "Background",
621   "Spare",
622   "Excellent Effort",
623   "Controlled Load",
624   "Video",
625   "Voice",
626   "Network Control"
627 };
628
629 /* ************************************************************************* */
630 /*                 WME Access Category Names (by 802.1D Tag)                 */
631 /* ************************************************************************* */
632 static const char *qos_acs[8] = {
633   "Best Effort",
634   "Background",
635   "Background",
636   "Video",
637   "Video",
638   "Video",
639   "Voice",
640   "Voice"
641 };
642
643 /* ************************************************************************* */
644 /*                   WME Access Category Names (by WME ACI)                  */
645 /* ************************************************************************* */
646 static const char *wme_acs[4] = {
647   "Best Effort",
648   "Background",
649   "Video",
650   "Voice",
651 };
652
653 /* ************************************************************************* */
654 /*                  Aruba Management Type                                    */
655 /* ************************************************************************* */
656 static const value_string aruba_mgt_typevals[] = {
657   { 0x0001,       "Hello" },
658   { 0x0002,       "Probe" },
659   { 0x0003,       "MTU" },
660   { 0x0004,       "Ageout" },
661   { 0x0005,       "Heartbeat" },
662   { 0x0006,       "Deauth" },
663   { 0x0007,       "Disassoc" },
664   { 0x0008,       "Probe response" },
665   { 0x0009,       "Tunnel update" },
666   { 0x000A,       "Laser beam active" },
667   { 0x000B,       "Client IP" },
668   { 0x000C,       "Laser beam active v2" },
669   { 0x000D,       "AP statistics" },
670   { 0,            NULL }
671 };
672
673 /*** Begin: Action Fixed Parameter ***/
674 #define CAT_SPECTRUM_MGMT      0
675 #define CAT_QOS                1
676 #define CAT_DLS                2
677 #define CAT_BLOCK_ACK          3
678
679 #define CAT_RADIO_MEASUREMENT   6
680 #define CAT_HT                  7
681 #define CAT_MGMT_NOTIFICATION   17
682 #define CAT_VENDOR_SPECIFIC     127
683
684 #define SM_ACTION_MEASUREMENT_REQUEST   0
685 #define SM_ACTION_MEASUREMENT_REPORT    1
686 #define SM_ACTION_TPC_REQUEST           2
687 #define SM_ACTION_TPC_REPORT            3
688 #define SM_ACTION_CHAN_SWITCH_ANNC      4
689 #define SM_ACTION_EXT_CHAN_SWITCH_ANNC  5
690
691 #define SM_ACTION_ADDTS_REQUEST     0
692 #define SM_ACTION_ADDTS_RESPONSE    1
693 #define SM_ACTION_DELTS             2
694 #define SM_ACTION_QOS_SCHEDULE      3
695
696 #define SM_ACTION_DLS_REQUEST       0
697 #define SM_ACTION_DLS_RESPONSE      1
698 #define SM_ACTION_DLS_TEARDOWN      2
699
700 #define BA_ADD_BLOCK_ACK_REQUEST    0
701 #define BA_ADD_BLOCK_ACK_RESPONSE   1
702 #define BA_DELETE_BLOCK_ACK         2
703
704 #define HT_ACTION_NOTIFY_CHAN_WIDTH           0
705 #define HT_ACTION_SM_PWR_SAVE                 1
706 #define HT_ACTION_PSMP_ACTION                 2
707 #define HT_ACTION_SET_PCO_PHASE               3
708 #define HT_ACTION_MIMO_CSI                    4
709 #define HT_ACTION_MIMO_BEAMFORMING            5
710 #define HT_ACTION_MIMO_COMPRESSED_BEAMFORMING 6
711 #define HT_ACTION_ANT_SEL_FEEDBACK            7
712 #define HT_ACTION_HT_INFO_EXCHANGE            8
713 /* Vendor actions */
714 /* MARVELL */
715 #define MRVL_ACTION_MESH_MANAGEMENT     1
716
717 #define MRVL_MESH_MGMT_ACTION_RREQ      0
718 #define MRVL_MESH_MGMT_ACTION_RREP      1
719 #define MRVL_MESH_MGMT_ACTION_RERR      2
720 #define MRVL_MESH_MGMT_ACTION_PLDM      3
721
722 /*** End: Action Fixed Parameter ***/
723
724 static int proto_wlan = -1;
725 static int proto_aggregate = -1;
726 static packet_info * g_pinfo;
727
728 static int proto_radio = -1;
729 static int proto_wlancap = -1;
730 static int proto_prism = -1;
731
732 /* ************************************************************************* */
733 /*                Header field info values for radio information             */
734 /* ************************************************************************* */
735 static int hf_mactime = -1;
736 static int hf_hosttime = -1;
737 static int hf_data_rate = -1;
738 static int hf_channel = -1;
739 static int hf_channel_frequency = -1;
740 static int hf_normrssi_antsignal = -1;
741 static int hf_dbm_antsignal = -1;
742 static int hf_rawrssi_antsignal = -1;
743 static int hf_normrssi_antnoise = -1;
744 static int hf_dbm_antnoise = -1;
745 static int hf_rawrssi_antnoise = -1;
746 static int hf_signal_strength = -1;
747
748 /* Prism radio header */
749 static int hf_prism_msgcode = -1;
750 static int hf_prism_msglen = -1;
751 static int hf_prism_rssi_data = -1;
752 static int hf_prism_sq_data = -1;
753 static int hf_prism_signal_data = -1;
754 static int hf_prism_noise_data = -1;
755 static int hf_prism_rate_data = -1;
756 static int hf_prism_istx_data = -1;
757 static int hf_prism_frmlen_data = -1;
758
759 /* AVS WLANCAP radio header */
760 static int hf_wlan_magic = -1;
761 static int hf_wlan_version = -1;
762 static int hf_wlan_length = -1;
763 static int hf_wlan_phytype = -1;
764 static int hf_wlan_antenna = -1;
765 static int hf_wlan_priority = -1;
766 static int hf_wlan_ssi_type = -1;
767 static int hf_wlan_ssi_signal = -1;
768 static int hf_wlan_ssi_noise = -1;
769 static int hf_wlan_preamble = -1;
770 static int hf_wlan_encoding = -1;
771 static int hf_wlan_sequence = -1;
772 static int hf_wlan_drops = -1;
773 static int hf_wlan_receiver_addr = -1;
774 static int hf_wlan_padding = -1;
775
776 /* ************************************************************************* */
777 /*                Header field info values for FC-field                      */
778 /* ************************************************************************* */
779 static int hf_fc_field = -1;
780 static int hf_fc_proto_version = -1;
781 static int hf_fc_frame_type = -1;
782 static int hf_fc_frame_subtype = -1;
783 static int hf_fc_frame_type_subtype = -1;
784
785 static int hf_fc_flags = -1;
786 static int hf_fc_to_ds = -1;
787 static int hf_fc_from_ds = -1;
788 static int hf_fc_data_ds = -1;
789
790 static int hf_fc_more_frag = -1;
791 static int hf_fc_retry = -1;
792 static int hf_fc_pwr_mgt = -1;
793 static int hf_fc_more_data = -1;
794 static int hf_fc_protected = -1;
795 static int hf_fc_order = -1;
796
797 typedef struct retransmit_key {
798         guint8  bssid[6];
799         guint8  src[6];
800         guint16 seq_control;
801         guint   fnum;
802 } retransmit_key;
803
804 static GHashTable *fc_analyse_retransmit_table = NULL;
805 static GHashTable *fc_first_frame_table = NULL;
806
807 static int hf_fc_analysis_retransmission = -1;
808 static int hf_fc_analysis_retransmission_frame = -1;
809
810 /* ************************************************************************* */
811 /*                   Header values for Duration/ID field                     */
812 /* ************************************************************************* */
813 static int hf_did_duration = -1;
814 static int hf_assoc_id = -1;
815
816
817 /* ************************************************************************* */
818 /*         Header values for different address-fields (all 4 of them)        */
819 /* ************************************************************************* */
820 static int hf_addr_da = -1;  /* Destination address subfield */
821 static int hf_addr_sa = -1;  /* Source address subfield */
822 static int hf_addr_ra = -1;  /* Receiver address subfield */
823 static int hf_addr_ta = -1;  /* Transmitter address subfield */
824 static int hf_addr_addr1 = -1;
825 static int hf_addr_bssid = -1;  /* address is bssid */
826
827 static int hf_addr = -1;  /* Source or destination address subfield */
828
829
830 /* ************************************************************************* */
831 /*                Header values for QoS control field                        */
832 /* ************************************************************************* */
833 static int hf_qos_priority = -1;
834 static int hf_qos_ack_policy = -1;
835 static int hf_qos_amsdu_present = -1;
836 static int hf_qos_eosp = -1;
837 static int hf_qos_field_content = -1;
838 /*static int hf_qos_txop_limit = -1;*/
839 /*  FIXME: hf_ values not defined
840 static int hf_qos_buf_state = -1;
841 static int hf_qos_buf_ac = -1;
842 static int hf_qos_buf_load = -1;
843 */
844 /*static int hf_qos_txop_dur_req = -1;
845 static int hf_qos_queue_size = -1;*/
846
847 /* ************************************************************************* */
848 /*                Header values for HT control field (+HTC)                  */
849 /* ************************************************************************* */
850 /* 802.11nD-1.10 & 802.11nD-2.0 7.1.3.5a */
851 static int hf_htc = -1;
852 static int hf_htc_lac = -1;
853 static int hf_htc_lac_reserved = -1;
854 static int hf_htc_lac_trq = -1;
855 static int hf_htc_lac_mai_aseli = -1;
856 static int hf_htc_lac_mai_mrq = -1;
857 static int hf_htc_lac_mai_msi = -1;
858 static int hf_htc_lac_mai_reserved = -1;
859 static int hf_htc_lac_mfsi = -1;
860 static int hf_htc_lac_mfb = -1;
861 static int hf_htc_lac_asel_command = -1;
862 static int hf_htc_lac_asel_data = -1;
863 static int hf_htc_cal_pos = -1;
864 static int hf_htc_cal_seq = -1;
865 static int hf_htc_reserved1 = -1;
866 static int hf_htc_csi_steering = -1;
867 static int hf_htc_ndp_announcement = -1;
868 static int hf_htc_reserved2 = -1;
869 static int hf_htc_ac_constraint = -1;
870 static int hf_htc_rdg_more_ppdu = -1;
871
872 /* ************************************************************************* */
873 /*                Header values for sequence number field                    */
874 /* ************************************************************************* */
875 static int hf_frag_number = -1;
876 static int hf_seq_number = -1;
877
878 /* ************************************************************************* */
879 /*                   Header values for Frame Check field                     */
880 /* ************************************************************************* */
881 static int hf_fcs = -1;
882 static int hf_fcs_good = -1;
883 static int hf_fcs_bad = -1;
884
885 /* ************************************************************************* */
886 /*                   Header values for reassembly                            */
887 /* ************************************************************************* */
888 static int hf_fragments = -1;
889 static int hf_fragment = -1;
890 static int hf_fragment_overlap = -1;
891 static int hf_fragment_overlap_conflict = -1;
892 static int hf_fragment_multiple_tails = -1;
893 static int hf_fragment_too_long_fragment = -1;
894 static int hf_fragment_error = -1;
895 static int hf_reassembled_in = -1;
896
897
898 static int proto_wlan_mgt = -1;
899
900 /* ************************************************************************* */
901 /*                   Header values for WAVE                                  */
902 /* ************************************************************************* */
903 static int hf_pst_timingquality = -1;
904 static int hf_pst_providercount = -1;
905 static int hf_pst_length = -1;
906 static int hf_pst_contents = -1;
907
908 static int hf_pst_acid =        -1;
909 static int hf_pst_acm_length =  -1;
910 static int hf_pst_acm = -1;
911 static int hf_pst_acm_contents =-1;
912 static int hf_pst_acf =         -1;
913 static int hf_pst_priority =    -1;
914 static int hf_pst_ipv6addr =    -1;
915 static int hf_pst_serviceport = -1;
916 static int hf_pst_addressing =  -1;
917 static int hf_pst_macaddr =     -1;
918 static int hf_pst_channel =     -1;
919
920 static int hf_chan_noc = -1;
921 static int hf_chan_length = -1;
922 static int hf_chan_content =    -1;
923 static int hf_chan_channel =    -1;
924 static int hf_chan_adapt   =    -1;
925 static int hf_chan_rate    =    -1;
926 static int hf_chan_tx_pow  =    -1;
927
928 /* ************************************************************************* */
929 /*                      Fixed fields found in mgt frames                     */
930 /* ************************************************************************* */
931 static int ff_auth_alg = -1;  /* Authentication algorithm field            */
932 static int ff_auth_seq = -1;  /* Authentication transaction sequence       */
933 static int ff_current_ap = -1;  /* Current AP MAC address                    */
934 static int ff_listen_ival = -1;  /* Listen interval fixed field               */
935 static int ff_timestamp = -1;  /* 64 bit timestamp                          */
936 static int ff_beacon_interval = -1;  /* 16 bit Beacon interval            */
937 static int ff_assoc_id = -1;  /* 16 bit AID field                          */
938 static int ff_reason = -1;  /* 16 bit reason code                        */
939 static int ff_status_code = -1;  /* Status code                               */
940 static int ff_category_code = -1;  /* 8 bit Category code */
941 static int ff_action_code = -1;    /* 8 bit Action code */
942 static int ff_dialog_token = -1;  /* 8 bit Dialog token */
943 static int ff_wme_action_code = -1;  /* Management notification action code */
944 static int ff_wme_status_code = -1;  /* Management notification setup response status code */
945 static int ff_qos_action_code = -1;
946 static int ff_dls_action_code = -1;
947 static int ff_dst_mac_addr = -1;  /* DLS destination MAC addressi */
948 static int ff_src_mac_addr = -1;  /* DLS source MAC addressi */
949 static int ff_dls_timeout = -1;    /* DLS timeout value */
950
951 /* Vendor specific */
952 static int ff_marvell_action_type = -1;
953 static int ff_marvell_mesh_mgt_action_code = -1;
954 static int ff_mesh_mgt_length = -1;     /* Mesh Management length */
955 static int ff_mesh_mgt_mode = -1;       /* Mesh Management mode */
956 static int ff_mesh_mgt_ttl = -1;        /* Mesh Management TTL */
957 static int ff_mesh_mgt_dstcount = -1;   /* Mesh Management dst count */
958 static int ff_mesh_mgt_hopcount = -1;   /* Mesh Management hop count */
959 static int ff_mesh_mgt_rreqid = -1;     /* Mesh Management RREQ ID */
960 static int ff_mesh_mgt_sa = -1;         /* Mesh Management src addr */
961 static int ff_mesh_mgt_ssn = -1;        /* Mesh Management src sequence number */
962 static int ff_mesh_mgt_metric = -1;     /* Mesh Management metric */
963 static int ff_mesh_mgt_flags = -1;      /* Mesh Management RREQ flags */
964 static int ff_mesh_mgt_da = -1;         /* Mesh Management dst addr */
965 static int ff_mesh_mgt_dsn = -1;        /* Mesh Management dst sequence number */
966 static int ff_mesh_mgt_lifetime = -1;   /* Mesh Management lifetime */
967
968
969 /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
970 static int ff_ba_action = -1;
971 /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
972
973 /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
974 static int ff_block_ack_params = -1;
975 static int ff_block_ack_params_amsdu_permitted = -1;
976 static int ff_block_ack_params_policy = -1;
977 static int ff_block_ack_params_tid = -1;
978 static int ff_block_ack_params_buffer_size = -1;
979 /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
980
981 /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
982 static int ff_block_ack_timeout = -1;
983 /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
984
985 /*** Begin: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
986 static int ff_block_ack_ssc = -1;
987 static int ff_block_ack_ssc_fragment = -1;
988 static int ff_block_ack_ssc_sequence = -1;
989 /*** End: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
990
991 /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
992 static int ff_delba_param = -1;
993 static int ff_delba_param_reserved = -1;
994 static int ff_delba_param_init = -1;
995 static int ff_delba_param_tid = -1;
996 /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
997
998 /*** Begin: Max Regulation Power Fixed Field - Dustin Johnson ***/
999 static int ff_max_reg_pwr = -1;
1000 /*** End: Max Regulation Power Fixed Field - Dustin Johnson ***/
1001
1002 /*** Begin: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
1003 static int ff_measurement_pilot_int = -1;
1004 /*** End: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
1005
1006 /*** Begin: Country String Fixed Field - Dustin Johnson ***/
1007 static int ff_country_str = -1;
1008 /*** End: Country String Fixed Field - Dustin Johnson ***/
1009
1010 /*** Begin: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
1011 static int ff_max_tx_pwr = -1;
1012 /*** End: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
1013
1014 /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
1015 static int ff_tx_pwr_used = -1;
1016 /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
1017
1018 /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
1019 static int ff_transceiver_noise_floor = -1;
1020 /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
1021
1022 /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
1023 static int ff_channel_width = -1;
1024 /*** End: Channel Width Fixed Field - Dustin Johnson ***/
1025
1026 /*** Begin: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
1027 static int ff_qos_info_ap = -1;
1028 static int ff_qos_info_ap_edca_param_set_counter = -1;
1029 static int ff_qos_info_ap_q_ack = -1;
1030 static int ff_qos_info_ap_queue_req = -1;
1031 static int ff_qos_info_ap_txop_request = -1;
1032 static int ff_qos_info_ap_reserved = -1;
1033 /*** End: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
1034
1035 /*** Begin: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
1036 static int ff_qos_info_sta = -1;
1037 static int ff_qos_info_sta_ac_vo = -1;
1038 static int ff_qos_info_sta_ac_vi = -1;
1039 static int ff_qos_info_sta_ac_bk = -1;
1040 static int ff_qos_info_sta_ac_be = -1;
1041 static int ff_qos_info_sta_q_ack = -1;
1042 static int ff_qos_info_sta_max_sp_len = -1;
1043 static int ff_qos_info_sta_more_data_ack = -1;
1044 /*** End: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
1045
1046 /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1047 static int ff_sm_pwr_save = -1;
1048 static int ff_sm_pwr_save_enabled = -1;
1049 static int ff_sm_pwr_save_sm_mode = -1;
1050 static int ff_sm_pwr_save_reserved = -1;
1051 /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1052
1053 /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
1054 static int ff_pco_phase_cntrl = -1;
1055 /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
1056
1057 /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1058 static int ff_psmp_param_set = -1;
1059 static int ff_psmp_param_set_n_sta = -1;
1060 static int ff_psmp_param_set_more_psmp = -1;
1061 static int ff_psmp_param_set_psmp_sequence_duration = -1;
1062 /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1063
1064 /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
1065 static int ff_mimo_cntrl_nc_index = -1;
1066 static int ff_mimo_cntrl_nr_index = -1;
1067 static int ff_mimo_cntrl_channel_width = -1;
1068 static int ff_mimo_cntrl_grouping = -1;
1069 static int ff_mimo_cntrl_coefficient_size = -1;
1070 static int ff_mimo_cntrl_codebook_info = -1;
1071 static int ff_mimo_cntrl_remaining_matrix_segment = -1;
1072 static int ff_mimo_cntrl_reserved = -1;
1073 static int ff_mimo_cntrl_sounding_timestamp = -1;
1074 /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
1075
1076 /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
1077 static int ff_ant_selection = -1;
1078 static int ff_ant_selection_0 = -1;
1079 static int ff_ant_selection_1 = -1;
1080 static int ff_ant_selection_2 = -1;
1081 static int ff_ant_selection_3 = -1;
1082 static int ff_ant_selection_4 = -1;
1083 static int ff_ant_selection_5 = -1;
1084 static int ff_ant_selection_6 = -1;
1085 static int ff_ant_selection_7 = -1;
1086 /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
1087
1088 /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1089 static int ff_ext_channel_switch_announcement = -1;
1090 /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1091
1092 /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
1093 static int ff_ht_info = -1;
1094 static int ff_ht_info_information_request = -1;
1095 static int ff_ht_info_40_mhz_intolerant = -1;
1096 static int ff_ht_info_sta_chan_width = -1;
1097 static int ff_ht_info_reserved = -1;
1098 /*** End: HT Information Fixed Field - Dustin Johnson ***/
1099
1100 /*** Begin: HT Action Fixed Field - Dustin Johnson ***/
1101 static int ff_ht_action = -1;
1102 /*** End: HT Action Fixed Field - Dustin Johnson ***/
1103
1104 /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
1105 static int ff_psmp_sta_info = -1;
1106 static int ff_psmp_sta_info_dtt_start_offset = -1;
1107 static int ff_psmp_sta_info_dtt_duration = -1;
1108 static int ff_psmp_sta_info_sta_id = -1;
1109 static int ff_psmp_sta_info_utt_start_offset = -1;
1110 static int ff_psmp_sta_info_utt_duration = -1;
1111 static int ff_psmp_sta_info_reserved_small= -1;
1112 static int ff_psmp_sta_info_reserved_large = -1;
1113 static int ff_psmp_sta_info_psmp_multicast_id = -1;
1114 /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
1115
1116 /*** Begin: MIMO CSI Matrices Report - Dustin Johnson ***/
1117 static int ff_mimo_csi_snr = -1;
1118 /*** End: MIMO CSI Matrices Report - Dustin Johnson ***/
1119
1120 /* ************************************************************************* */
1121 /*            Flags found in the capability field (fixed field)              */
1122 /* ************************************************************************* */
1123 static int ff_capture = -1;
1124 static int ff_cf_ess = -1;
1125 static int ff_cf_ibss = -1;
1126 static int ff_cf_sta_poll = -1; /* CF pollable status for a STA            */
1127 static int ff_cf_ap_poll = -1;  /* CF pollable status for an AP            */
1128 static int ff_cf_privacy = -1;
1129 static int ff_cf_preamble = -1;
1130 static int ff_cf_pbcc = -1;
1131 static int ff_cf_agility = -1;
1132 static int ff_short_slot_time = -1;
1133 static int ff_dsss_ofdm = -1;
1134 static int ff_cf_spec_man = -1;
1135 static int ff_cf_apsd = -1;
1136 static int ff_cf_del_blk_ack = -1;
1137 static int ff_cf_imm_blk_ack = -1;
1138
1139 /* ************************************************************************* */
1140 /*                       A-MSDU fields                                             */
1141 /* ************************************************************************* */
1142 static int amsdu_msdu_header_text = -1;
1143
1144
1145 /* ************************************************************************* */
1146 /*                       Tagged value format fields                          */
1147 /* ************************************************************************* */
1148 static int tag_number = -1;
1149 static int tag_length = -1;
1150 static int tag_interpretation = -1;
1151 static int tag_oui = -1;
1152
1153
1154 static int tim_length = -1;
1155 static int tim_dtim_count = -1;
1156 static int tim_dtim_period = -1;
1157 static int tim_bmapctl = -1;
1158
1159
1160 static int hf_fixed_parameters = -1;  /* Protocol payload for management frames */
1161 static int hf_tagged_parameters = -1;  /* Fixed payload item */
1162 static int hf_tagged_ssid = -1;
1163 static int hf_wep_iv = -1;
1164 static int hf_wep_iv_weak = -1;
1165 static int hf_tkip_extiv = -1;
1166 static int hf_ccmp_extiv = -1;
1167 static int hf_wep_key = -1;
1168 static int hf_wep_icv = -1;
1169
1170 /*** Begin: Block Ack Request/Block Ack  - Dustin Johnson***/
1171 static int hf_block_ack_request_control = -1;
1172 static int hf_block_ack_control = -1;
1173 static int hf_block_ack_control_ack_policy = -1;
1174 static int hf_block_ack_control_multi_tid = -1;
1175 static int hf_block_ack_control_compressed_bitmap = -1;
1176 static int hf_block_ack_control_reserved = -1;
1177
1178 static int hf_block_ack_control_basic_tid_info = -1;
1179 static int hf_block_ack_control_compressed_tid_info = -1;
1180 static int hf_block_ack_control_multi_tid_info = -1;
1181
1182 static int hf_tag_measure_request_measurement_mode = -1;
1183 static int hf_tag_measure_request_bssid = -1;
1184 static int hf_tag_measure_request_reporting_condition = -1;
1185 static int hf_tag_measure_request_threshold_offset_unsigned = -1;
1186 static int hf_tag_measure_request_threshold_offset_signed = -1;
1187
1188 static int hf_tag_measure_request_report_mac = -1;
1189
1190 static int hf_tag_measure_request_group_id = -1;
1191
1192 static int hf_block_ack_multi_tid_info = -1;
1193 static int hf_block_ack_request_type = -1;
1194 static int hf_block_ack_multi_tid_reserved = -1;
1195 static int hf_block_ack_multi_tid_value = -1;
1196 static int hf_block_ack_type = -1;
1197 /*** End: Block Ack Request/Block Ack  - Dustin Johnson***/
1198
1199 static int ht_cap = -1;
1200 static int ht_vs_cap = -1;
1201 static int ht_ldpc_coding = -1;
1202 static int ht_chan_width = -1;
1203 static int ht_sm_pwsave = -1;
1204 static int ht_green = -1;
1205 static int ht_short20 = -1;
1206 static int ht_short40 = -1;
1207 static int ht_tx_stbc = -1;
1208 static int ht_rx_stbc = -1;
1209 static int ht_delayed_block_ack = -1;
1210 static int ht_max_amsdu = -1;
1211 static int ht_dss_cck_40 = -1;
1212 static int ht_psmp = -1;
1213 static int ht_40_mhz_intolerant = -1;
1214 static int ht_l_sig = -1;
1215
1216 static int ampduparam = -1;
1217 static int ampduparam_vs = -1;
1218 static int ampduparam_mpdu = -1;
1219 static int ampduparam_mpdu_start_spacing = -1;
1220 static int ampduparam_reserved = -1;
1221
1222 static int mcsset = -1;
1223 static int mcsset_vs = -1;
1224 static int mcsset_rx_bitmask_0to7 = -1;
1225 static int mcsset_rx_bitmask_8to15 = -1;
1226 static int mcsset_rx_bitmask_16to23 = -1;
1227 static int mcsset_rx_bitmask_24to31 = -1;
1228 static int mcsset_rx_bitmask_32 = -1;
1229 static int mcsset_rx_bitmask_33to38 = -1;
1230 static int mcsset_rx_bitmask_39to52 = -1;
1231 static int mcsset_rx_bitmask_53to76 = -1;
1232 static int mcsset_highest_data_rate = -1;
1233 static int mcsset_tx_mcs_set_defined = -1;
1234 static int mcsset_tx_rx_mcs_set_not_equal = -1;
1235 static int mcsset_tx_max_spatial_streams = -1;
1236 static int mcsset_tx_unequal_modulation = -1;
1237
1238 static int htex_cap = -1;
1239 static int htex_vs_cap = -1;
1240 static int htex_pco = -1;
1241 static int htex_transtime = -1;
1242 static int htex_mcs = -1;
1243 static int htex_htc_support = -1;
1244 static int htex_rd_responder = -1;
1245
1246 static int txbf = -1;
1247 static int txbf_vs = -1;
1248 static int txbf_cap = -1;
1249 static int txbf_rcv_ssc = -1;
1250 static int txbf_tx_ssc = -1;
1251 static int txbf_rcv_ndp = -1;
1252 static int txbf_tx_ndp = -1;
1253 static int txbf_impl_txbf = -1;
1254 static int txbf_calib = -1;
1255 static int txbf_expl_csi = -1;
1256 static int txbf_expl_uncomp_fm = -1;
1257 static int txbf_expl_comp_fm = -1;
1258 static int txbf_expl_bf_csi = -1;
1259 static int txbf_expl_uncomp_fm_feed = -1;
1260 static int txbf_expl_comp_fm_feed = -1;
1261 static int txbf_csi_num_bf_ant = -1;
1262 static int txbf_min_group = -1;
1263 static int txbf_uncomp_sm_bf_ant = -1;
1264 static int txbf_comp_sm_bf_ant = -1;
1265 static int txbf_csi_max_rows_bf = -1;
1266 static int txbf_chan_est = -1;
1267 static int txbf_resrv = -1;
1268
1269 /*** Begin: 802.11n D1.10 - HT Information IE  ***/
1270 static int ht_info_primary_channel = -1;
1271
1272 static int ht_info_delimiter1 = -1;
1273 static int ht_info_secondary_channel_offset = -1;
1274 static int ht_info_channel_width = -1;
1275 static int ht_info_rifs_mode = -1;
1276 static int ht_info_psmp_stas_only = -1;
1277 static int ht_info_service_interval_granularity = -1;
1278
1279 static int ht_info_delimiter2 = -1;
1280 static int ht_info_operating_mode = -1;
1281 static int ht_info_non_greenfield_sta_present = -1;
1282 static int ht_info_transmit_burst_limit = -1;
1283 static int ht_info_obss_non_ht_stas_present = -1;
1284 static int ht_info_reserved_1 = -1;
1285
1286 static int ht_info_delimiter3 = -1;
1287 static int ht_info_reserved_2 = -1;
1288 static int ht_info_dual_beacon = -1;
1289 static int ht_info_dual_cts_protection = -1;
1290 static int ht_info_secondary_beacon = -1;
1291 static int ht_info_lsig_txop_protection_full_support = -1;
1292 static int ht_info_pco_active = -1;
1293 static int ht_info_pco_phase = -1;
1294 static int ht_info_reserved_3 = -1;
1295 /*** End: 802.11n D1.10 - HT Information IE  ***/
1296
1297 /*** Begin: 802.11n D1.10 - Secondary Channel Offset Tag  - Dustin Johnson***/
1298 static int hf_tag_secondary_channel_offset = -1;
1299 /*** End: 802.11n D1.10 - Secondary Channel Offset Tag  - Dustin Johnson***/
1300
1301 /*** Begin: Power Capability Tag - Dustin Johnson ***/
1302 static int hf_tag_power_capability_min = -1;
1303 static int hf_tag_power_capability_max = -1;
1304 /*** End: Power Capability Tag - Dustin Johnson ***/
1305
1306 static int hf_tag_tpc_report_trsmt_pow = -1;
1307 static int hf_tag_tpc_report_link_mrg = -1;
1308
1309 /*** Begin: Power Capability Tag - Dustin Johnson ***/
1310 static int hf_tag_supported_channels = -1;
1311 static int hf_tag_supported_channels_first = -1;
1312 static int hf_tag_supported_channels_range = -1;
1313 /*** End: Power Capability Tag - Dustin Johnson ***/
1314
1315 /*** Begin: Measurement Request Tag  - Dustin Johnson***/
1316 static int hf_tag_measure_request_measurement_token = -1;
1317 static int hf_tag_measure_request_mode = -1;
1318 static int hf_tag_measure_request_mode_reserved1 = -1;
1319 static int hf_tag_measure_request_mode_enable = -1;
1320 static int hf_tag_measure_request_mode_request = -1;
1321 static int hf_tag_measure_request_mode_report = -1;
1322 static int hf_tag_measure_request_mode_reserved2 = -1;
1323 static int hf_tag_measure_request_type = -1;
1324
1325 static int hf_tag_measure_request_channel_number = -1;
1326 static int hf_tag_measure_request_start_time = -1;
1327 static int hf_tag_measure_request_duration = -1;
1328
1329 static int hf_tag_measure_request_regulatory_class = -1;
1330 static int hf_tag_measure_request_randomization_interval = -1;
1331 /*** End: Measurement Request Tag  - Dustin Johnson***/
1332
1333 /*** Begin: Measurement Report Tag  - Dustin Johnson***/
1334 static int hf_tag_measure_report_measurement_token = -1;
1335 static int hf_tag_measure_report_mode = -1;
1336 static int hf_tag_measure_report_mode_late = -1;
1337 static int hf_tag_measure_report_mode_incapable = -1;
1338 static int hf_tag_measure_report_mode_refused = -1;
1339 static int hf_tag_measure_report_mode_reserved = -1;
1340 static int hf_tag_measure_report_type = -1;
1341 static int hf_tag_measure_report_channel_number = -1;
1342 static int hf_tag_measure_report_start_time = -1;
1343 static int hf_tag_measure_report_duration = -1;
1344
1345 static int hf_tag_measure_basic_map_field = -1;
1346 static int hf_tag_measure_map_field_bss = -1;
1347 static int hf_tag_measure_map_field_odfm = -1;
1348 static int hf_tag_measure_map_field_unident_signal = -1;
1349 static int hf_tag_measure_map_field_radar = -1;
1350 static int hf_tag_measure_map_field_unmeasured = -1;
1351 static int hf_tag_measure_map_field_reserved = -1;
1352
1353 static int hf_tag_measure_cca_busy_fraction = -1;
1354
1355 static int hf_tag_measure_rpi_histogram_report = -1;
1356 static int hf_tag_measure_rpi_histogram_report_0 = -1;
1357 static int hf_tag_measure_rpi_histogram_report_1 = -1;
1358 static int hf_tag_measure_rpi_histogram_report_2 = -1;
1359 static int hf_tag_measure_rpi_histogram_report_3 = -1;
1360 static int hf_tag_measure_rpi_histogram_report_4 = -1;
1361 static int hf_tag_measure_rpi_histogram_report_5 = -1;
1362 static int hf_tag_measure_rpi_histogram_report_6 = -1;
1363 static int hf_tag_measure_rpi_histogram_report_7 = -1;
1364
1365 static int hf_tag_measure_report_regulatory_class = -1;
1366 static int hf_tag_measure_report_channel_load = -1;
1367 static int hf_tag_measure_report_frame_info = -1;
1368 static int hf_tag_measure_report_frame_info_phy_type = -1;
1369 static int hf_tag_measure_report_frame_info_frame_type = -1;
1370 static int hf_tag_measure_report_rcpi = -1;
1371 static int hf_tag_measure_report_rsni = -1;
1372 static int hf_tag_measure_report_bssid = -1;
1373 static int hf_tag_measure_report_ant_id = -1;
1374 static int hf_tag_measure_report_parent_tsf = -1;
1375 /*** End: Measurement Report Tag  - Dustin Johnson***/
1376
1377 /*** Begin: Extended Capabilities Tag - Dustin Johnson ***/
1378 static int hf_tag_extended_capabilities = -1;
1379 static int hf_tag_extended_capabilities_b0 = -1;
1380 static int hf_tag_extended_capabilities_b1 = -1;
1381 static int hf_tag_extended_capabilities_b2 = -1;
1382 static int hf_tag_extended_capabilities_b3 = -1;
1383 /*** End: Extended Capabilities Tag - Dustin Johnson ***/
1384
1385 /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
1386 static int hf_tag_neighbor_report_bssid = -1;
1387 static int hf_tag_neighbor_report_bssid_info = -1;
1388 static int hf_tag_neighbor_report_bssid_info_reachability = -1;
1389 static int hf_tag_neighbor_report_bssid_info_security = -1;
1390 static int hf_tag_neighbor_report_bssid_info_key_scope = -1;
1391 /*static int hf_tag_neighbor_report_bssid_info_capability = -1; */ /* TODO Make this the parent tree item */
1392 static int hf_tag_neighbor_report_bssid_info_capability_spec_mng = -1;
1393 static int hf_tag_neighbor_report_bssid_info_capability_qos = -1;
1394 static int hf_tag_neighbor_report_bssid_info_capability_apsd = -1;
1395 static int hf_tag_neighbor_report_bssid_info_capability_radio_msnt = -1;
1396 static int hf_tag_neighbor_report_bssid_info_capability_dback = -1;
1397 static int hf_tag_neighbor_report_bssid_info_capability_iback = -1;
1398 static int hf_tag_neighbor_report_bssid_info_mobility_domain = -1;
1399 static int hf_tag_neighbor_report_bssid_info_high_throughput = -1;
1400 static int hf_tag_neighbor_report_bssid_info_reserved = -1;
1401 static int hf_tag_neighbor_report_reg_class = -1;
1402 static int hf_tag_neighbor_report_channel_number = -1;
1403 static int hf_tag_neighbor_report_phy_type = -1;
1404 /*** End: Neighbor Report Tag - Dustin Johnson ***/
1405
1406 /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
1407 static int hf_tag_ext_channel_switch_announcement_switch_mode = -1;
1408 static int hf_tag_ext_channel_switch_announcement_new_reg_class = -1;
1409 static int hf_tag_ext_channel_switch_announcement_new_chan_number = -1;
1410 static int hf_tag_ext_channel_switch_announcement_switch_count = -1;
1411 /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
1412
1413 /*** Begin: Supported Regulatory Classes Tag - Dustin Johnson ***/
1414 static int hf_tag_supported_reg_classes_current = -1;
1415 static int hf_tag_supported_reg_classes_alternate = -1;
1416 /*** End: Supported Regulatory Classes Tag - Dustin Johnson ***/
1417
1418 /* 802.11n 7.3.2.48 */
1419 static int hta_cap = -1;
1420 static int hta_ext_chan_offset = -1;
1421 static int hta_rec_tx_width = -1;
1422 static int hta_rifs_mode = -1;
1423 static int hta_controlled_access = -1;
1424 static int hta_service_interval = -1;
1425 static int hta_operating_mode = -1;
1426 static int hta_non_gf_devices = -1;
1427 static int hta_basic_stbc_mcs = -1;
1428 static int hta_dual_stbc_protection = -1;
1429 static int hta_secondary_beacon = -1;
1430 static int hta_lsig_txop_protection = -1;
1431 static int hta_pco_active = -1;
1432 static int hta_pco_phase = -1;
1433
1434
1435 static int antsel = -1;
1436 static int antsel_vs = -1;
1437 static int antsel_b0 = -1;
1438 static int antsel_b1 = -1;
1439 static int antsel_b2 = -1;
1440 static int antsel_b3 = -1;
1441 static int antsel_b4 = -1;
1442 static int antsel_b5 = -1;
1443 static int antsel_b6 = -1;
1444 static int antsel_b7 = -1;
1445
1446 static int rsn_cap = -1;
1447 static int rsn_cap_preauth = -1;
1448 static int rsn_cap_no_pairwise = -1;
1449 static int rsn_cap_ptksa_replay_counter = -1;
1450 static int rsn_cap_gtksa_replay_counter = -1;
1451
1452 static int hf_aironet_ie_type = -1;
1453 static int hf_aironet_ie_version = -1;
1454 static int hf_aironet_ie_data = -1;
1455 static int hf_aironet_ie_qos_unk1 = -1;
1456 static int hf_aironet_ie_qos_paramset = -1;
1457 static int hf_aironet_ie_qos_val = -1;
1458
1459 static int hf_marvell_ie_type = -1;
1460 static int hf_marvell_ie_mesh_subtype = -1;
1461 static int hf_marvell_ie_mesh_version = -1;
1462 static int hf_marvell_ie_mesh_active_proto_id = -1;
1463 static int hf_marvell_ie_mesh_active_metric_id = -1;
1464 static int hf_marvell_ie_mesh_cap = -1;
1465 static int hf_marvell_ie_data = -1;
1466
1467 /*QBSS - Version 1,2,802.11e*/
1468
1469 static int hf_qbss2_cal = -1;
1470 static int hf_qbss2_gl = -1;
1471 static int hf_qbss_cu = -1;
1472 static int hf_qbss2_cu = -1;
1473 static int hf_qbss_scount = -1;
1474 static int hf_qbss2_scount = -1;
1475 static int hf_qbss_version = -1;
1476 static int hf_qbss_adc = -1;
1477
1478 static int hf_ts_info = -1;
1479 static int hf_tsinfo_type = -1;
1480 static int hf_tsinfo_tsid = -1;
1481 static int hf_tsinfo_dir = -1;
1482 static int hf_tsinfo_access = -1;
1483 static int hf_tsinfo_agg = -1;
1484 static int hf_tsinfo_apsd = -1;
1485 static int hf_tsinfo_up = -1;
1486 static int hf_tsinfo_ack = -1;
1487 static int hf_tsinfo_sched = -1;
1488 static int tspec_nor_msdu = -1;
1489 static int tspec_max_msdu = -1;
1490 static int tspec_min_srv = -1;
1491 static int tspec_max_srv = -1;
1492 static int tspec_inact_int = -1;
1493 static int tspec_susp_int = -1;
1494 static int tspec_srv_start = -1;
1495 static int tspec_min_data = -1;
1496 static int tspec_mean_data = -1;
1497 static int tspec_peak_data = -1;
1498 static int tspec_burst_size = -1;
1499 static int tspec_delay_bound = -1;
1500 static int tspec_min_phy = -1;
1501 static int tspec_surplus = -1;
1502 static int tspec_medium = -1;
1503 static int ts_delay = -1;
1504 static int hf_class_type = -1;
1505 static int hf_class_mask = -1;
1506 static int hf_ether_type = -1;
1507 static int hf_tclas_process = -1;
1508 static int hf_sched_info = -1;
1509 static int hf_sched_srv_start = -1;
1510 static int hf_sched_srv_int = -1;
1511 static int hf_sched_spec_int = -1;
1512 static int hf_action = -1;
1513 static int cf_version = -1;
1514 static int cf_ipv4_src = -1;
1515 static int cf_ipv4_dst = -1;
1516 static int cf_src_port = -1;
1517 static int cf_dst_port = -1;
1518 static int cf_dscp = -1;
1519 static int cf_protocol = -1;
1520 static int cf_ipv6_src = -1;
1521 static int cf_ipv6_dst = -1;
1522 static int cf_flow = -1;
1523 static int cf_tag_type = -1;
1524 static int cf_aruba = -1;
1525 static int cf_aruba_hb_seq = -1;
1526 static int cf_aruba_mtu = -1;
1527
1528 /* ************************************************************************* */
1529 /*                               Protocol trees                              */
1530 /* ************************************************************************* */
1531 static gint ett_80211 = -1;
1532 static gint ett_proto_flags = -1;
1533 static gint ett_cap_tree = -1;
1534 static gint ett_fc_tree = -1;
1535 static gint ett_cntrl_wrapper_fc = -1;
1536 static gint ett_cntrl_wrapper_payload = -1;
1537 static gint ett_fragments = -1;
1538 static gint ett_fragment = -1;
1539 static gint ett_block_ack = -1;
1540
1541
1542 static gint ett_80211_mgt = -1;
1543 static gint ett_fixed_parameters = -1;
1544 static gint ett_tagged_parameters = -1;
1545 static gint ett_qos_parameters = -1;
1546 static gint ett_qos_ps_buf_state = -1;
1547 static gint ett_wep_parameters = -1;
1548
1549 static gint ett_rsn_cap_tree = -1;
1550
1551 static gint ett_ht_cap_tree = -1;
1552 static gint ett_ampduparam_tree = -1;
1553 static gint ett_mcsset_tree = -1;
1554 static gint ett_mcsbit_tree = -1;
1555 static gint ett_htex_cap_tree = -1;
1556 static gint ett_txbf_tree = -1;
1557 static gint ett_antsel_tree = -1;
1558 static gint ett_hta_cap_tree = -1;
1559 static gint ett_hta_cap1_tree = -1;
1560 static gint ett_hta_cap2_tree = -1;
1561 static gint ett_htc_tree = -1;
1562
1563 /*** Start: 802.11n D1.10 - HT Information IE - Dustin Johnson ***/
1564 static gint ett_ht_info_delimiter1_tree = -1;
1565 static gint ett_ht_info_delimiter2_tree = -1;
1566 static gint ett_ht_info_delimiter3_tree = -1;
1567 /*** End: 802.11n D1.10 - HT Information IE  - Dustin Johnson ***/
1568
1569 /*** Start: 802.11n D1.10 - Tag Measure Request IE - Dustin Johnson ***/
1570 static gint ett_tag_measure_request_tree = -1;
1571 /*** End: 802.11n D1.10 - Tag Measure Request IE  - Dustin Johnson ***/
1572
1573 static gint ett_tag_ex_cap = -1;
1574
1575 /*** Begin: Supported Channels Tag - Dustin Johnson ***/
1576 static gint ett_tag_supported_channels = -1;
1577 /*** End: Supported Channels Tag - Dustin Johnson ***/
1578
1579 /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
1580 static gint ett_tag_neighbor_report_bssid_info_tree = -1;
1581 static gint ett_tag_neighbor_report_bssid_info_capability_tree = -1;
1582 static gint ett_tag_neighbor_report_sub_tag_tree = -1;
1583 /*** End: Neighbor Report Tag - Dustin Johnson ***/
1584
1585 /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
1586 static gint ett_ff_ba_param_tree = -1;
1587 static gint ett_ff_ba_ssc_tree = -1;
1588 /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
1589
1590 /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
1591 static gint ett_ff_delba_param_tree = -1;
1592 /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
1593
1594 /*** Begin: QoS Inforamtion AP/STA Fixed Field - Dustin Johnson ***/
1595 static gint ett_ff_qos_info = -1;
1596 /*** End: QoS Inforamtion AP/STA Fixed Field - Dustin Johnson ***/
1597
1598 /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1599 static gint ett_ff_sm_pwr_save = -1;
1600 /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
1601
1602 /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1603 static gint ett_ff_psmp_param_set = -1;
1604 /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
1605
1606 /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
1607 static gint ett_ff_mimo_cntrl = -1;
1608 /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
1609
1610 /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
1611 static gint ett_ff_ant_sel = -1;
1612 /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
1613
1614 /*** Begin: MIMO Reports - Dustin Johnson ***/
1615 static gint ett_mimo_report = -1;
1616 /*** End: MIMO Reports - Dustin Johnson ***/
1617
1618 /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1619 static gint ett_ff_chan_switch_announce = -1;
1620 /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
1621
1622 /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
1623 static gint ett_ff_ht_info = -1;
1624 /*** End: HT Information Fixed Field - Dustin Johnson ***/
1625
1626 /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
1627 static gint ett_ff_psmp_sta_info = -1;
1628 /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
1629
1630 /*** Begin: A-MSDU Dissection - Dustin Johnson ***/
1631 static gint ett_msdu_aggregation_parent_tree = -1;
1632 static gint ett_msdu_aggregation_subframe_tree = -1;
1633 /*** End: A-MSDU Dissection - Dustin Johnson ***/
1634
1635 /***  Begin: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
1636 static gint ett_pst_tree = -1;
1637 static gint ett_pst_cap_tree = -1;
1638 static gint ett_chan_noc_tree = -1;
1639 static gint ett_wave_chnl_tree = -1;
1640
1641 /***  End: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
1642
1643 static gint ett_80211_mgt_ie = -1;
1644 static gint ett_tsinfo_tree = -1;
1645 static gint ett_sched_tree = -1;
1646
1647 static gint ett_fcs = -1;
1648
1649 static gint ett_radio = -1;
1650
1651 static const fragment_items frag_items = {
1652   &ett_fragment,
1653   &ett_fragments,
1654   &hf_fragments,
1655   &hf_fragment,
1656   &hf_fragment_overlap,
1657   &hf_fragment_overlap_conflict,
1658   &hf_fragment_multiple_tails,
1659   &hf_fragment_too_long_fragment,
1660   &hf_fragment_error,
1661   &hf_reassembled_in,
1662   "fragments"
1663 };
1664
1665 static enum_val_t wlan_ignore_wep_options[] = {
1666   { "no",         "No",               WLAN_IGNORE_WEP_NO    },
1667   { "without_iv", "Yes - without IV", WLAN_IGNORE_WEP_WO_IV },
1668   { "with_iv",    "Yes - with IV",    WLAN_IGNORE_WEP_W_IV  },
1669   { NULL,         NULL,               0                     }
1670 };
1671
1672 static dissector_handle_t ieee80211_handle;
1673 static dissector_handle_t llc_handle;
1674 static dissector_handle_t ipx_handle;
1675 static dissector_handle_t eth_withoutfcs_handle;
1676 static dissector_handle_t data_handle;
1677 static dissector_handle_t wlancap_handle;
1678
1679 static int wlan_tap = -1;
1680
1681 /*     Davide Schiera (2006-11-22): including AirPDcap project                */
1682 #ifdef HAVE_AIRPDCAP
1683 #include <epan/crypt/airpdcap_ws.h>
1684 AIRPDCAP_CONTEXT airpdcap_ctx;
1685 #else
1686 int airpdcap_ctx;
1687 #endif
1688 /* Davide Schiera (2006-11-22) ---------------------------------------------- */
1689
1690
1691 /* ************************************************************************* */
1692 /*            Return the length of the current header (in bytes)             */
1693 /* ************************************************************************* */
1694 static int
1695 find_header_length (guint16 fcf, guint16 ctrl_fcf, gboolean is_ht)
1696 {
1697   int len;
1698   guint16 cw_fcf;
1699
1700   switch (FCF_FRAME_TYPE (fcf)) {
1701
1702   case MGT_FRAME:
1703     if (is_ht && IS_STRICTLY_ORDERED(FCF_FLAGS(fcf)))
1704       return MGT_FRAME_HDR_LEN + 4;
1705
1706     return MGT_FRAME_HDR_LEN;
1707
1708   case CONTROL_FRAME:
1709     if (COMPOSE_FRAME_TYPE(fcf) == CTRL_CONTROL_WRAPPER) {
1710       len = 6;
1711       cw_fcf = ctrl_fcf;
1712     } else {
1713       len = 0;
1714       cw_fcf = fcf;
1715     }
1716     switch (COMPOSE_FRAME_TYPE (cw_fcf)) {
1717
1718     case CTRL_CTS:
1719     case CTRL_ACKNOWLEDGEMENT:
1720       return len + 10;
1721
1722     case CTRL_RTS:
1723     case CTRL_PS_POLL:
1724     case CTRL_CFP_END:
1725     case CTRL_CFP_ENDACK:
1726     case CTRL_BLOCK_ACK_REQ:
1727     case CTRL_BLOCK_ACK:
1728       return len + 16;
1729     }
1730     return len + 4;  /* XXX */
1731
1732   case DATA_FRAME:
1733     len = (FCF_ADDR_SELECTOR(fcf) ==
1734       DATA_ADDR_T4) ? DATA_LONG_HDR_LEN : DATA_SHORT_HDR_LEN;
1735
1736     if (DATA_FRAME_IS_QOS(COMPOSE_FRAME_TYPE(fcf))) {
1737       len += 2;
1738       if (is_ht && IS_STRICTLY_ORDERED(FCF_FLAGS(fcf))) {
1739         len += 4;
1740       }
1741     }
1742
1743     return len;
1744
1745   default:
1746     return 4;  /* XXX */
1747   }
1748 }
1749
1750 mimo_control_t get_mimo_control (tvbuff_t *tvb, int offset)
1751 {
1752   guint16 mimo;
1753   mimo_control_t output;
1754
1755   mimo = tvb_get_letohs (tvb, offset);
1756
1757   output.nc = (mimo & 0x0003) + 1;
1758   output.nr = ((mimo & 0x000C) >> 2) + 1;
1759   output.chan_width = (mimo & 0x0010) >> 4;
1760   output.coefficient_size = 4; /* XXX - Is this a good default? */
1761
1762   switch ((mimo & 0x0060) >> 5)
1763     {
1764       case 0:
1765         output.grouping = 1;
1766         break;
1767
1768       case 1:
1769         output.grouping = 2;
1770         break;
1771
1772       case 2:
1773         output.grouping = 4;
1774         break;
1775
1776       default:
1777         output.grouping = 1;
1778         break;
1779     }
1780
1781   switch ((mimo & 0x0180) >> 7)
1782     {
1783       case 0:
1784         output.coefficient_size = 4;
1785         break;
1786
1787       case 1:
1788         output.coefficient_size = 5;
1789         break;
1790
1791       case 2:
1792         output.coefficient_size = 6;
1793         break;
1794
1795       case 3:
1796         output.coefficient_size = 8;
1797         break;
1798     }
1799
1800   output.codebook_info = (mimo & 0x0600) >> 9;
1801   output.remaining_matrix_segment = (mimo & 0x3800) >> 11;
1802
1803   return output;
1804 }
1805
1806 int get_mimo_na (guint8 nr, guint8 nc)
1807 {
1808   if (nr == 2 && nc == 1){
1809     return 2;
1810   }else if (nr == 2 && nc == 2){
1811     return 2;
1812   }else if (nr == 3 && nc == 1){
1813     return 4;
1814   }else if (nr == 3 && nc == 2){
1815     return 6;
1816   }else if (nr == 3 && nc == 3){
1817     return 6;
1818   }else if (nr == 4 && nc == 1){
1819     return 6;
1820   }else if (nr == 4 && nc == 2){
1821     return 10;
1822   }else if (nr == 4 && nc == 3){
1823     return 12;
1824   }else if (nr == 4 && nc == 4){
1825     return 12;
1826   }else{
1827     return 0;
1828   }
1829 }
1830
1831 int get_mimo_ns (gboolean chan_width, guint8 output_grouping)
1832 {
1833   int ns = 0;
1834
1835   if (chan_width)
1836   {
1837       switch (output_grouping)
1838       {
1839         case 1:
1840           ns = 114;
1841           break;
1842
1843           case 2:
1844             ns = 58;
1845             break;
1846
1847           case 4:
1848             ns = 30;
1849             break;
1850
1851           default:
1852             ns = 0;
1853       }
1854   } else {
1855     switch (output_grouping)
1856     {
1857       case 1:
1858         ns = 56;
1859         break;
1860
1861       case 2:
1862         ns = 30;
1863         break;
1864
1865       case 4:
1866         ns = 16;
1867         break;
1868
1869       default:
1870         ns = 0;
1871     }
1872   }
1873
1874   return ns;
1875 }
1876
1877 int add_mimo_csi_matrices_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl)
1878 {
1879   proto_item *snr_item;
1880   proto_tree *snr_tree;
1881   int csi_matrix_size, start_offset;
1882   int ns, i;
1883
1884   start_offset = offset;
1885   snr_item = proto_tree_add_text(tree, tvb, offset, mimo_cntrl.nc, "Signal to Noise Ratio");
1886   snr_tree = proto_item_add_subtree (snr_item, ett_mimo_report);
1887
1888   for (i=1; i <= mimo_cntrl.nr; i++)
1889   {
1890     guint8 snr;
1891
1892     snr = tvb_get_guint8(tvb, offset);
1893     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);
1894     offset++;
1895   }
1896
1897   ns = get_mimo_ns(mimo_cntrl.chan_width, mimo_cntrl.grouping);
1898   csi_matrix_size = ns*(3+(2*mimo_cntrl.nc*mimo_cntrl.nr*mimo_cntrl.coefficient_size));
1899   csi_matrix_size = roundup2(csi_matrix_size, 8) / 8;
1900   proto_tree_add_text(tree, tvb, offset, csi_matrix_size, "CSI Matrices");
1901   offset += csi_matrix_size;
1902   return offset - start_offset;
1903 }
1904
1905 int add_mimo_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl)
1906 {
1907   proto_item *snr_item;
1908   proto_tree *snr_tree;
1909   int csi_matrix_size, start_offset;
1910   int ns, i;
1911
1912   start_offset = offset;
1913   snr_item = proto_tree_add_text(tree, tvb, offset, mimo_cntrl.nc, "Signal to Noise Ratio");
1914   snr_tree = proto_item_add_subtree (snr_item, ett_mimo_report);
1915
1916   for (i=1; i <= mimo_cntrl.nc; i++)
1917   {
1918     guint8 snr;
1919
1920     snr = tvb_get_guint8(tvb, offset);
1921     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);
1922     offset++;
1923   }
1924
1925   ns = get_mimo_ns(mimo_cntrl.chan_width, mimo_cntrl.grouping);
1926   csi_matrix_size = ns*(2*mimo_cntrl.nc*mimo_cntrl.nr*mimo_cntrl.coefficient_size);
1927   csi_matrix_size = roundup2(csi_matrix_size, 8) / 8;
1928   proto_tree_add_text(tree, tvb, offset, csi_matrix_size, "Beamforming Feedback Matrices");
1929   offset += csi_matrix_size;
1930   return offset - start_offset;
1931 }
1932
1933 int add_mimo_compressed_beamforming_feedback_report (proto_tree *tree, tvbuff_t *tvb, int offset, mimo_control_t mimo_cntrl)
1934 {
1935   proto_item *snr_item;
1936   proto_tree *snr_tree;
1937   int csi_matrix_size, start_offset;
1938   int ns, na, i;
1939
1940   start_offset = offset;
1941   snr_item = proto_tree_add_text(tree, tvb, offset, mimo_cntrl.nc, "Signal to Noise Ratio");
1942   snr_tree = proto_item_add_subtree (snr_item, ett_mimo_report);
1943
1944   for (i=1; i <= mimo_cntrl.nc; i++)
1945   {
1946     guint8 snr;
1947
1948     snr = tvb_get_guint8(tvb, offset);
1949     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);
1950     offset++;
1951   }
1952
1953   na = get_mimo_na(mimo_cntrl.nr, mimo_cntrl.nc);
1954   ns = get_mimo_ns(mimo_cntrl.chan_width, mimo_cntrl.grouping);
1955   csi_matrix_size = ns*(na*((mimo_cntrl.codebook_info+1)*2 + 2)/2);
1956   csi_matrix_size = roundup2(csi_matrix_size, 8) / 8;
1957   proto_tree_add_text(tree, tvb, offset, csi_matrix_size, "Compressed Beamforming Feedback Matrices");
1958   offset += csi_matrix_size;
1959   return offset - start_offset;
1960 }
1961
1962 /* ************************************************************************* */
1963 /*          This is the capture function used to update packet counts        */
1964 /* ************************************************************************* */
1965 static void
1966 capture_ieee80211_common (const guchar * pd, int offset, int len,
1967         packet_counts * ld, gboolean fixed_length_header,
1968         gboolean datapad, gboolean is_ht)
1969 {
1970   guint16 fcf, hdr_length;
1971
1972   if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
1973     ld->other++;
1974     return;
1975   }
1976
1977   fcf = pletohs (&pd[offset]);
1978
1979   if (IS_PROTECTED(FCF_FLAGS(fcf)) && wlan_ignore_wep == WLAN_IGNORE_WEP_NO) {
1980     ld->other++;
1981     return;
1982   }
1983
1984   switch (COMPOSE_FRAME_TYPE (fcf)) {
1985
1986     case DATA:          /* We got a data frame */
1987     case DATA_CF_ACK:   /* Data with ACK */
1988     case DATA_CF_POLL:
1989     case DATA_CF_ACK_POLL:
1990     case DATA_QOS_DATA:
1991     {
1992       if (fixed_length_header)
1993         hdr_length = DATA_LONG_HDR_LEN;
1994       else
1995         hdr_length = find_header_length (fcf, 0, is_ht);
1996       if (datapad)
1997         hdr_length = roundup2(hdr_length, 4);
1998       /* I guess some bridges take Netware Ethernet_802_3 frames,
1999          which are 802.3 frames (with a length field rather than
2000          a type field, but with no 802.2 header in the payload),
2001          and just stick the payload into an 802.11 frame.  I've seen
2002          captures that show frames of that sort.
2003
2004          This means we have to do the same check for Netware 802.3 -
2005          or, if you will, "Netware 802.11" - that we do in the
2006          Ethernet dissector, i.e. checking for 0xffff as the first
2007          four bytes of the payload and, if we find it, treating it
2008          as an IPX frame. */
2009       if (!BYTES_ARE_IN_FRAME(offset+hdr_length, len, 2)) {
2010         ld->other++;
2011         return;
2012       }
2013       if (pd[offset+hdr_length] == 0xff && pd[offset+hdr_length+1] == 0xff) {
2014         capture_ipx (ld);
2015       }
2016       else {
2017         capture_llc (pd, offset + hdr_length, len, ld);
2018       }
2019       break;
2020     }
2021
2022     default:
2023       ld->other++;
2024       break;
2025   }
2026 }
2027
2028 /*
2029  * Handle 802.11 with a variable-length link-layer header.
2030  */
2031 void
2032 capture_ieee80211 (const guchar * pd, int offset, int len, packet_counts * ld)
2033 {
2034   capture_ieee80211_common (pd, offset, len, ld, FALSE, FALSE, FALSE);
2035 }
2036
2037 /*
2038  * Handle 802.11 with a variable-length link-layer header and data padding.
2039  */
2040 void
2041 capture_ieee80211_datapad (const guchar * pd, int offset, int len,
2042                            packet_counts * ld)
2043 {
2044   capture_ieee80211_common (pd, offset, len, ld, FALSE, TRUE, FALSE);
2045 }
2046
2047 /*
2048  * Handle 802.11 with a fixed-length link-layer header (padded to the
2049  * maximum length).
2050  */
2051 void
2052 capture_ieee80211_fixed (const guchar * pd, int offset, int len, packet_counts * ld)
2053 {
2054   capture_ieee80211_common (pd, offset, len, ld, TRUE, FALSE, FALSE);
2055 }
2056
2057 /*
2058  * Handle an HT 802.11 with a variable-length link-layer header.
2059  */
2060 void
2061 capture_ieee80211_ht (const guchar * pd, int offset, int len, packet_counts * ld)
2062 {
2063   capture_ieee80211_common (pd, offset, len, ld, FALSE, FALSE, TRUE);
2064 }
2065
2066 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000
2067 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001
2068 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002
2069
2070 /*
2071  * Prism II-based wlan devices have a monitoring mode that sticks
2072  * a proprietary header on each packet with lots of good
2073  * information.  This file is responsible for decoding that
2074  * data.
2075  *
2076  * Support by Tim Newsham
2077  *
2078  * A value from the header.
2079  *
2080  * It appears from looking at the linux-wlan-ng and Prism II HostAP
2081  * drivers, and various patches to the orinoco_cs drivers to add
2082  * Prism headers, that:
2083  *
2084  *      the "did" identifies what the value is (i.e., what it's the value
2085  *      of);
2086  *
2087  *      "status" is 0 if the value is present or 1 if it's absent;
2088  *
2089  *      "len" is the length of the value (always 4, in that code);
2090  *
2091  *      "data" is the value of the data (or 0 if not present).
2092  *
2093  * Note: all of those values are in the *host* byte order of the machine
2094  * on which the capture was written.
2095  */
2096 struct val_80211 {
2097     unsigned int did;
2098     unsigned short status, len;
2099     unsigned int data;
2100 };
2101
2102 /*
2103  * Header attached during Prism monitor mode.
2104  *
2105  * At least according to one paper I've seen, the Prism 2.5 chip set
2106  * provides:
2107  *
2108  *      RSSI (receive signal strength indication) is "the total power
2109  *      received by the radio hardware while receiving the frame,
2110  *      including signal, interfereence, and background noise";
2111  *
2112  *      "silence value" is "the total power observed just before the
2113  *      start of the frame".
2114  *
2115  * None of the drivers I looked at supply the "rssi" or "sq" value,
2116  * but they do supply "signal" and "noise" values, along with a "rate"
2117  * value that's 1/5 of the raw value from what is presumably a raw
2118  * HFA384x frame descriptor, with the comment "set to 802.11 units",
2119  * which presumably means the units are 500 Kb/s.
2120  *
2121  * I infer from the current NetBSD "wi" driver that "signal" and "noise"
2122  * are adjusted dBm values, with the dBm value having 100 added to it
2123  * for the Prism II cards (although the NetBSD code has an XXX comment
2124  * for the #define for WI_PRISM_DBM_OFFSET) and 149 (with no XXX comment)
2125  * for the Orinoco cards.
2126  *
2127  * XXX - what about other drivers that supply Prism headers, such as
2128  * old versions of the MadWifi driver?
2129  */
2130 struct prism_hdr {
2131     unsigned int msgcode, msglen;
2132     char devname[16];
2133     struct val_80211 hosttime, mactime, channel, rssi, sq, signal,
2134         noise, rate, istx, frmlen;
2135 };
2136
2137 void
2138 capture_prism(const guchar *pd, int offset, int len, packet_counts *ld)
2139 {
2140   guint32 cookie;
2141
2142   if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32))) {
2143     ld->other++;
2144     return;
2145   }
2146
2147   /* Some captures with DLT_PRISM have the AVS WLAN header */
2148   cookie = pntohl(pd);
2149   if ((cookie == WLANCAP_MAGIC_COOKIE_V1) ||
2150       (cookie == WLANCAP_MAGIC_COOKIE_V2)) {
2151     capture_wlancap(pd, offset, len, ld);
2152     return;
2153   }
2154
2155   /* Prism header */
2156   if (!BYTES_ARE_IN_FRAME(offset, len, (int)sizeof(struct prism_hdr))) {
2157     ld->other++;
2158     return;
2159   }
2160   offset += sizeof(struct prism_hdr);
2161
2162   /* 802.11 header follows */
2163   capture_ieee80211(pd, offset, len, ld);
2164 }
2165
2166 void
2167 capture_wlancap(const guchar *pd, int offset, int len, packet_counts *ld)
2168 {
2169   guint32 length;
2170
2171   if (!BYTES_ARE_IN_FRAME(offset, len, sizeof(guint32)*2)) {
2172     ld->other++;
2173     return;
2174   }
2175
2176   length = pntohl(pd+sizeof(guint32));
2177
2178   if (!BYTES_ARE_IN_FRAME(offset, len, length)) {
2179     ld->other++;
2180     return;
2181   }
2182
2183   offset += length;
2184
2185   /* 802.11 header follows */
2186   capture_ieee80211(pd, offset, len, ld);
2187 }
2188
2189 /* ************************************************************************* */
2190 /*          Add the subtree used to store the fixed parameters               */
2191 /* ************************************************************************* */
2192 static proto_tree *
2193 get_fixed_parameter_tree (proto_tree * tree, tvbuff_t *tvb, int start, int size)
2194 {
2195   proto_item *fixed_fields;
2196   fixed_fields =
2197     proto_tree_add_uint_format (tree, hf_fixed_parameters, tvb, start,
2198         size, size, "Fixed parameters (%d bytes)",
2199         size);
2200
2201   return proto_item_add_subtree (fixed_fields, ett_fixed_parameters);
2202 }
2203
2204
2205 /* ************************************************************************* */
2206 /*            Add the subtree used to store tagged parameters                */
2207 /* ************************************************************************* */
2208 static proto_tree *
2209 get_tagged_parameter_tree (proto_tree * tree, tvbuff_t *tvb, int start, int size)
2210 {
2211   proto_item *tagged_fields;
2212
2213   tagged_fields = proto_tree_add_uint_format (tree, hf_tagged_parameters,
2214     tvb,
2215     start,
2216     size,
2217     size,
2218     "Tagged parameters (%d bytes)",
2219     size);
2220
2221   return proto_item_add_subtree (tagged_fields, ett_tagged_parameters);
2222 }
2223
2224
2225 /* ************************************************************************* */
2226 /*              Dissect and add fixed mgmt fields to protocol tree           */
2227 /* ************************************************************************* */
2228 static guint
2229 add_fixed_field(proto_tree * tree, tvbuff_t * tvb, int offset, int lfcode)
2230 {
2231   const guint8 *dataptr;
2232   char out_buff[SHORT_STR];
2233   guint16 capability;
2234   proto_item *cap_item;
2235   static proto_tree *cap_tree;
2236   double temp_double;
2237   guint length = 0;
2238
2239   switch (lfcode)
2240   {
2241     case FIELD_TIMESTAMP:
2242       dataptr = tvb_get_ptr (tvb, offset, 8);
2243       memset (out_buff, 0, SHORT_STR);
2244       g_snprintf (out_buff, SHORT_STR, "0x%02X%02X%02X%02X%02X%02X%02X%02X",
2245         dataptr[7],
2246         dataptr[6],
2247         dataptr[5],
2248         dataptr[4],
2249         dataptr[3],
2250         dataptr[2],
2251         dataptr[1],
2252         dataptr[0]);
2253
2254       proto_tree_add_string (tree, ff_timestamp, tvb, offset, 8, out_buff);
2255       length += 8;
2256       break;
2257
2258     case FIELD_BEACON_INTERVAL:
2259       {
2260         capability = tvb_get_letohs (tvb, offset);
2261         temp_double = (double)capability;
2262         temp_double = temp_double * 1024 / 1000000;
2263         proto_tree_add_double_format (tree, ff_beacon_interval, tvb, offset, 2,
2264           temp_double,"Beacon Interval: %f [Seconds]", temp_double);
2265         if (check_col (g_pinfo->cinfo, COL_INFO)) {
2266           col_append_fstr(g_pinfo->cinfo, COL_INFO, ", BI=%d", capability);
2267         }
2268         length += 2;
2269         break;
2270       }
2271
2272     case FIELD_CAP_INFO:
2273       {
2274         capability = tvb_get_letohs (tvb, offset);
2275
2276         cap_item = proto_tree_add_uint_format (tree, ff_capture,
2277           tvb, offset, 2, capability,
2278           "Capability Information: 0x%04X", capability);
2279         cap_tree = proto_item_add_subtree (cap_item, ett_cap_tree);
2280         proto_tree_add_boolean (cap_tree, ff_cf_ess, tvb, offset, 2, capability);
2281         proto_tree_add_boolean (cap_tree, ff_cf_ibss, tvb, offset, 2, capability);
2282         if (ESS_SET (capability) != 0)  /* This is an AP */
2283           proto_tree_add_uint (cap_tree, ff_cf_ap_poll, tvb, offset, 2,
2284             capability);
2285         else      /* This is a STA */
2286         proto_tree_add_uint (cap_tree, ff_cf_sta_poll, tvb, offset, 2,
2287           capability);
2288
2289         proto_tree_add_boolean (cap_tree, ff_cf_privacy, tvb, offset, 2,
2290           capability);
2291         proto_tree_add_boolean (cap_tree, ff_cf_preamble, tvb, offset, 2,
2292           capability);
2293         proto_tree_add_boolean (cap_tree, ff_cf_pbcc, tvb, offset, 2,
2294           capability);
2295         proto_tree_add_boolean (cap_tree, ff_cf_agility, tvb, offset, 2,
2296           capability);
2297         proto_tree_add_boolean (cap_tree, ff_cf_spec_man, tvb, offset, 2,
2298           capability);
2299         proto_tree_add_boolean (cap_tree, ff_short_slot_time, tvb, offset, 2,
2300           capability);
2301         proto_tree_add_boolean (cap_tree, ff_cf_apsd, tvb, offset, 2,
2302           capability);
2303         proto_tree_add_boolean (cap_tree, ff_dsss_ofdm, tvb, offset, 2,
2304           capability);
2305         proto_tree_add_boolean (cap_tree, ff_cf_del_blk_ack, tvb, offset, 2,
2306           capability);
2307         proto_tree_add_boolean (cap_tree, ff_cf_imm_blk_ack, tvb, offset, 2,
2308           capability);
2309         length += 2;
2310         break;
2311       }
2312     case FIELD_AUTH_ALG:
2313       proto_tree_add_item (tree, ff_auth_alg, tvb, offset, 2, TRUE);
2314       length += 2;
2315       break;
2316
2317     case FIELD_AUTH_TRANS_SEQ:
2318       proto_tree_add_item (tree, ff_auth_seq, tvb, offset, 2, TRUE);
2319       length += 2;
2320       break;
2321
2322     case FIELD_CURRENT_AP_ADDR:
2323       proto_tree_add_item (tree, ff_current_ap, tvb, offset, 6, FALSE);
2324       length += 6;
2325       break;
2326
2327     case FIELD_LISTEN_IVAL:
2328       proto_tree_add_item (tree, ff_listen_ival, tvb, offset, 2, TRUE);
2329       length += 2;
2330       break;
2331
2332     case FIELD_REASON_CODE:
2333       proto_tree_add_item (tree, ff_reason, tvb, offset, 2, TRUE);
2334       length += 2;
2335       break;
2336
2337     case FIELD_ASSOC_ID:
2338       proto_tree_add_uint(tree, ff_assoc_id, tvb, offset, 2,
2339         ASSOC_ID(tvb_get_letohs(tvb,offset)));
2340       /* proto_tree_add_item (tree, ff_assoc_id, tvb, offset, 2, TRUE); */
2341       length += 2;
2342       break;
2343
2344     case FIELD_STATUS_CODE:
2345       proto_tree_add_item (tree, ff_status_code, tvb, offset, 2, TRUE);
2346       length += 2;
2347       break;
2348
2349     case FIELD_CATEGORY_CODE:
2350       proto_tree_add_item (tree, ff_category_code, tvb, offset, 1, TRUE);
2351       length += 1;
2352       break;
2353
2354     case FIELD_ACTION_CODE:
2355       proto_tree_add_item (tree, ff_action_code, tvb, offset, 1, TRUE);
2356       length += 1;
2357       break;
2358
2359     case FIELD_DIALOG_TOKEN:
2360       proto_tree_add_item (tree, ff_dialog_token, tvb, offset, 1, TRUE);
2361       length += 1;
2362       break;
2363
2364     case FIELD_WME_ACTION_CODE:
2365       proto_tree_add_item (tree, ff_wme_action_code, tvb, offset, 1, TRUE);
2366       length += 1;
2367       break;
2368
2369     case FIELD_WME_STATUS_CODE:
2370       proto_tree_add_item (tree, ff_wme_status_code, tvb, offset, 1, TRUE);
2371       length += 1;
2372       break;
2373
2374     case FIELD_QOS_ACTION_CODE:
2375       proto_tree_add_item (tree, ff_qos_action_code, tvb, offset, 1, TRUE);
2376       length += 1;
2377       break;
2378
2379     /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
2380     case FIELD_BLOCK_ACK_ACTION_CODE:
2381       proto_tree_add_item (tree, ff_ba_action, tvb, offset, 1, TRUE);
2382       length += 1;
2383       break;
2384     /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
2385
2386     /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
2387     case FIELD_BLOCK_ACK_PARAM:
2388       {
2389         guint16 params;
2390         proto_item *param_item;
2391         proto_tree *param_tree;
2392
2393         params = tvb_get_letohs (tvb, offset);
2394
2395         param_item = proto_tree_add_uint(tree, ff_block_ack_params, tvb, offset, 2, params);
2396         param_tree = proto_item_add_subtree (param_item, ett_ff_ba_param_tree);
2397
2398         proto_tree_add_boolean(param_tree, ff_block_ack_params_amsdu_permitted, tvb, offset, 1, params);
2399         proto_tree_add_boolean(param_tree, ff_block_ack_params_policy, tvb, offset, 1, params);
2400         proto_tree_add_uint(param_tree, ff_block_ack_params_tid, tvb, offset, 1, params);
2401         proto_tree_add_uint(param_tree, ff_block_ack_params_buffer_size, tvb, offset, 2, params);
2402         length += 2;
2403         break;
2404       }
2405     /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
2406
2407     /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
2408     case FIELD_BLOCK_ACK_TIMEOUT:
2409       {
2410         guint16 timeout;
2411
2412         timeout = tvb_get_letohs (tvb, offset);
2413         proto_tree_add_uint(tree, ff_block_ack_timeout, tvb, offset, 2, timeout);
2414         length += 2;
2415         break;
2416       }
2417     /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
2418
2419     /*** Begin: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
2420     case FIELD_BLOCK_ACK_SSC:
2421       {
2422         guint16 ssc;
2423         proto_item *ssc_item;
2424         proto_tree *ssc_tree;
2425
2426         ssc = tvb_get_letohs (tvb, offset);
2427         ssc_item = proto_tree_add_uint(tree, ff_block_ack_ssc, tvb, offset, 2, ssc);
2428         ssc_tree = proto_item_add_subtree (ssc_item, ett_ff_ba_ssc_tree);
2429         proto_tree_add_uint(ssc_tree, ff_block_ack_ssc_fragment, tvb, offset, 1, ssc);
2430         proto_tree_add_uint(ssc_tree, ff_block_ack_ssc_sequence, tvb, offset, 2, ssc);
2431         length += 2;
2432         break;
2433       }
2434     /*** End: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
2435
2436     case FIELD_QOS_TS_INFO:
2437       {
2438         proto_item *tsinfo_item;
2439         proto_tree *tsinfo_tree;
2440         guint32 tsi;
2441
2442         tsinfo_item = proto_tree_add_item(tree, hf_ts_info, tvb,
2443           offset, 3, TRUE);
2444         tsinfo_tree = proto_item_add_subtree(tsinfo_item, ett_tsinfo_tree);
2445         tsi = tvb_get_letoh24(tvb, offset);
2446         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_type, tvb,
2447           offset, 3, TSI_TYPE (tsi));
2448         if (TSI_TSID (tsi) < 8)
2449         {
2450           proto_tree_add_text(tsinfo_tree, tvb, offset, 3,
2451             "TSID: %u (< 8 is invalid)", TSI_TSID (tsi));
2452         }
2453         else
2454         {
2455           proto_tree_add_uint(tsinfo_tree, hf_tsinfo_tsid, tvb,
2456             offset, 3, TSI_TSID (tsi));
2457         }
2458         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_dir, tvb,
2459           offset, 3, TSI_DIR (tsi));
2460         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_access, tvb,
2461           offset, 3, TSI_ACCESS (tsi));
2462         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_agg, tvb,
2463           offset, 3, TSI_AGG (tsi));
2464         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_apsd, tvb,
2465           offset, 3, TSI_APSD (tsi));
2466         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_up, tvb,
2467           offset, 3, TSI_UP (tsi));
2468         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_ack, tvb,
2469           offset, 3, TSI_ACK (tsi));
2470         proto_tree_add_uint(tsinfo_tree, hf_tsinfo_sched, tvb,
2471           offset, 3, TSI_SCHED (tsi));
2472         length += 3;
2473         break;
2474       }
2475
2476     case FIELD_DLS_ACTION_CODE:
2477       proto_tree_add_item (tree, ff_dls_action_code, tvb, offset, 1, TRUE);
2478       length += 1;
2479       break;
2480
2481     case FIELD_DST_MAC_ADDR:
2482       proto_tree_add_item (tree, ff_dst_mac_addr, tvb, offset, 6, TRUE);
2483       length += 6;
2484       break;
2485
2486     case FIELD_SRC_MAC_ADDR:
2487       proto_tree_add_item (tree, ff_src_mac_addr, tvb, offset, 6, TRUE);
2488       length += 6;
2489       break;
2490
2491     case FIELD_DLS_TIMEOUT:
2492       proto_tree_add_item (tree, ff_dls_timeout, tvb, offset, 2, TRUE);
2493       length += 2;
2494       break;
2495
2496     /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
2497     case FIELD_DELBA_PARAM_SET:
2498       {
2499         guint16 params;
2500         proto_item *param_item;
2501         proto_tree *param_tree;
2502
2503         params = tvb_get_letohs (tvb, offset);
2504
2505         param_item = proto_tree_add_uint(tree, ff_delba_param, tvb, offset, 2, params);
2506         param_tree = proto_item_add_subtree (param_item, ett_ff_ba_param_tree);
2507
2508         proto_tree_add_uint(param_tree, ff_delba_param_reserved, tvb, offset, 2, params);
2509         proto_tree_add_boolean(param_tree, ff_delba_param_init, tvb, offset+1, 1, params);
2510         proto_tree_add_uint(param_tree, ff_delba_param_tid, tvb, offset+1, 1, params);
2511         length +=2;
2512         break;
2513       }
2514     /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
2515
2516     /*** Begin: Max Regulation Power Fixed Field - Dustin Johnson ***/
2517     case FIELD_MAX_REG_PWR:
2518       proto_tree_add_uint(tree, ff_max_reg_pwr, tvb, offset, 2, tvb_get_letohs (tvb, offset));
2519       length +=2;
2520       break;
2521     /*** End: Max Regulation Power Fixed Field - Dustin Johnson ***/
2522
2523     /*** Begin: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
2524     case FIELD_MEASUREMENT_PILOT_INT:
2525       proto_tree_add_uint(tree, ff_measurement_pilot_int, tvb, offset, 2, tvb_get_letohs (tvb, offset));
2526       length +=2;
2527       break;
2528     /*** End: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
2529
2530     /*** Begin: Country String Fixed Field - Dustin Johnson ***/
2531     case FIELD_COUNTRY_STR:
2532       {
2533         guint8 *country_string;
2534
2535         country_string = tvb_get_ephemeral_string(tvb, offset, 3);
2536         proto_tree_add_string (tree, ff_country_str, tvb, offset, 3, (char *) country_string);
2537         break;
2538       }
2539     /*** End: Country String Fixed Field - Dustin Johnson ***/
2540
2541     /*** Begin: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
2542     case FIELD_MAX_TX_PWR:
2543       proto_tree_add_uint(tree, ff_max_tx_pwr, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2544       length +=1;
2545       break;
2546     /*** End: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
2547
2548     /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
2549     case FIELD_TX_PWR_USED:
2550       proto_tree_add_uint(tree, ff_tx_pwr_used, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2551       length +=1;
2552       break;
2553     /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
2554
2555     /*** Begin: Transceiver Noise Floor Fixed Field - Dustin Johnson ***/
2556     case FIELD_TRANSCEIVER_NOISE_FLOOR:
2557       proto_tree_add_uint(tree, ff_transceiver_noise_floor, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2558       length +=1;
2559       break;
2560     /*** End: Transceiver Noise Floor Fixed Field - Dustin Johnson ***/
2561
2562     /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
2563     case FIELD_CHANNEL_WIDTH:
2564       proto_tree_add_item(tree, ff_channel_width, tvb, offset, 1, TRUE);
2565       length +=1;
2566       break;
2567     /*** End: Channel Width Fixed Field - Dustin Johnson ***/
2568
2569     /*** Begin: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
2570     case FIELD_QOS_INFO_AP:
2571       {
2572         guint8 info;
2573         proto_item *info_item;
2574         proto_tree *info_tree;
2575
2576         info = tvb_get_guint8 (tvb, offset);
2577
2578         info_item = proto_tree_add_uint(tree, ff_qos_info_ap, tvb, offset, 1, info);
2579         info_tree = proto_item_add_subtree (info_item, ett_ff_qos_info);
2580
2581         proto_tree_add_uint(info_tree, ff_qos_info_ap_edca_param_set_counter, tvb, offset, 1, info);
2582         proto_tree_add_uint(info_tree, ff_qos_info_ap_q_ack, tvb, offset, 1, info);
2583         proto_tree_add_boolean(info_tree, ff_qos_info_ap_queue_req, tvb, offset, 1, info);
2584         proto_tree_add_boolean(info_tree, ff_qos_info_ap_txop_request, tvb, offset, 1, info);
2585         proto_tree_add_boolean(info_tree, ff_qos_info_ap_reserved, tvb, offset, 1, info);
2586         length +=1;
2587         break;
2588       }
2589     /*** End: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
2590
2591     /*** Begin: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
2592     case FIELD_QOS_INFO_STA:
2593       {
2594         guint8 info;
2595         proto_item *info_item;
2596         proto_tree *info_tree;
2597
2598         info = tvb_get_guint8 (tvb, offset);
2599
2600         info_item = proto_tree_add_uint(tree, ff_qos_info_sta, tvb, offset, 1, info);
2601         info_tree = proto_item_add_subtree (info_item, ett_ff_qos_info);
2602
2603         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_vo, tvb, offset, 1, info);
2604         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_vi, tvb, offset, 1, info);
2605         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_bk, tvb, offset, 1, info);
2606         proto_tree_add_boolean(info_tree, ff_qos_info_sta_ac_be, tvb, offset, 1, info);
2607         proto_tree_add_boolean(info_tree, ff_qos_info_sta_q_ack, tvb, offset, 1, info);
2608         proto_tree_add_uint(info_tree, ff_qos_info_sta_max_sp_len, tvb, offset, 1, info);
2609         proto_tree_add_boolean(info_tree, ff_qos_info_sta_more_data_ack, tvb, offset, 1, info);
2610
2611         length +=1;
2612         break;
2613       }
2614     /*** End: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
2615
2616     /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
2617     case FIELD_SM_PWR_CNTRL:
2618       {
2619         guint8 info;
2620         proto_item *info_item;
2621         proto_tree *info_tree;
2622
2623         info = tvb_get_guint8 (tvb, offset);
2624
2625         info_item = proto_tree_add_uint(tree, ff_sm_pwr_save, tvb, offset, 1, info);
2626         info_tree = proto_item_add_subtree (info_item, ett_ff_sm_pwr_save);
2627
2628         proto_tree_add_boolean(info_tree, ff_sm_pwr_save_enabled, tvb, offset, 1, info);
2629         proto_tree_add_boolean(info_tree, ff_sm_pwr_save_sm_mode, tvb, offset, 1, info);
2630         proto_tree_add_uint(info_tree, ff_sm_pwr_save_reserved, tvb, offset, 1, info);
2631         length +=1;
2632         break;
2633       }
2634     /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
2635
2636     /*** Begin: PCO Phase Control Fixed Field - Dustin Johnson ***/
2637     case FIELD_PCO_PHASE_CNTRL:
2638         proto_tree_add_item(tree, ff_pco_phase_cntrl, tvb, offset, 1, TRUE);
2639         length +=1;
2640         break;
2641     /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
2642
2643     /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
2644     case FIELD_PSMP_PARAM_SET:
2645       {
2646         guint16 params;
2647         proto_item *param_item;
2648         proto_tree *param_tree;
2649
2650         params = tvb_get_letohs (tvb, offset);
2651
2652         param_item = proto_tree_add_uint(tree, ff_psmp_param_set, tvb, offset, 2, params);
2653         param_tree = proto_item_add_subtree (param_item, ett_ff_psmp_param_set);
2654
2655         proto_tree_add_uint(param_tree, ff_psmp_param_set_n_sta, tvb, offset, 1, params & 0x000F);
2656         proto_tree_add_boolean(param_tree, ff_psmp_param_set_more_psmp, tvb, offset, 1, (params & 0x0010) >> 4);
2657         proto_tree_add_uint_format(param_tree, ff_psmp_param_set_psmp_sequence_duration, tvb, offset, 2,
2658           (params & 0xFFE0) >> 5, "PSMP Sequence Duration: %u [us]", ((params & 0xFFE0) >> 5) * 8);
2659         length +=2;
2660         break;
2661       }
2662     /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
2663
2664     /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
2665     case FIELD_MIMO_CNTRL:
2666       {
2667         guint16 mimo;
2668         guint32 time;
2669         proto_item *mimo_item;
2670         proto_tree *mimo_tree;
2671
2672         mimo = tvb_get_letohs (tvb, offset);
2673
2674         mimo_item = proto_tree_add_text(tree, tvb, offset, 2, "MIMO Control");
2675         mimo_tree = proto_item_add_subtree (mimo_item, ett_ff_mimo_cntrl);
2676
2677         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_nc_index, tvb, offset, 1, mimo);
2678         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_nr_index, tvb, offset, 1, mimo);
2679         proto_tree_add_boolean(mimo_tree, ff_mimo_cntrl_channel_width, tvb, offset, 1, mimo);
2680         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_grouping, tvb, offset, 1, mimo);
2681         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_coefficient_size, tvb, offset, 2, mimo);
2682         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_codebook_info, tvb, offset+1, 1, mimo);
2683         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_remaining_matrix_segment, tvb, offset+1, 1, mimo);
2684         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_reserved, tvb, offset+1, 1, mimo);
2685
2686         offset+=2;
2687         time = tvb_get_letohl (tvb, offset);
2688         proto_tree_add_uint(mimo_tree, ff_mimo_cntrl_sounding_timestamp, tvb, offset, 4, time);
2689         length +=6;
2690         break;
2691       }
2692     /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
2693
2694     /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
2695     case FIELD_ANT_SELECTION:
2696       {
2697         guint8 ant;
2698         proto_item *ant_item;
2699         proto_tree *ant_tree;
2700
2701         ant = tvb_get_guint8 (tvb, offset);
2702
2703         ant_item = proto_tree_add_uint(tree, ff_ant_selection, tvb, offset, 1, ant);
2704         ant_tree = proto_item_add_subtree (ant_item, ett_ff_ant_sel);
2705
2706         proto_tree_add_uint(ant_tree, ff_ant_selection_0, tvb, offset, 1, ant);
2707         proto_tree_add_uint(ant_tree, ff_ant_selection_1, tvb, offset, 1, ant);
2708         proto_tree_add_uint(ant_tree, ff_ant_selection_2, tvb, offset, 1, ant);
2709         proto_tree_add_uint(ant_tree, ff_ant_selection_3, tvb, offset, 1, ant);
2710         proto_tree_add_uint(ant_tree, ff_ant_selection_4, tvb, offset, 1, ant);
2711         proto_tree_add_uint(ant_tree, ff_ant_selection_5, tvb, offset, 1, ant);
2712         proto_tree_add_uint(ant_tree, ff_ant_selection_6, tvb, offset, 1, ant);
2713         proto_tree_add_uint(ant_tree, ff_ant_selection_7, tvb, offset, 1, ant);
2714
2715         length +=1;
2716         break;
2717       }
2718     /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
2719
2720     /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
2721     case FIELD_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT:
2722       {
2723         guint32 ext_chan;
2724         proto_item *chan_item;
2725         proto_tree *chan_tree;
2726
2727         ext_chan = tvb_get_letohl (tvb, offset);
2728
2729         chan_item = proto_tree_add_uint(tree, ff_ext_channel_switch_announcement, tvb, offset, 1, ext_chan);
2730         chan_tree = proto_item_add_subtree (chan_item, ett_ff_chan_switch_announce);
2731
2732         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_switch_mode, tvb, offset++, 1, (ext_chan & 0x000000FF));
2733         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_new_reg_class, tvb, offset++, 1, (ext_chan & 0x0000FF00) >> 8);
2734         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_new_chan_number, tvb, offset++, 1, (ext_chan & 0x00FF0000) >> 16);
2735         proto_tree_add_uint(chan_tree, hf_tag_ext_channel_switch_announcement_switch_count, tvb, offset++, 1, (ext_chan & 0xFF000000) >> 24);
2736         length += 4;
2737         break;
2738       }
2739     /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
2740
2741     /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
2742     case FIELD_HT_INFORMATION:
2743       {
2744         guint8 info;
2745         proto_item *ht_item;
2746         proto_tree *ht_tree;
2747
2748         info = tvb_get_guint8 (tvb, offset);
2749
2750         ht_item = proto_tree_add_uint(tree, ff_ht_info, tvb, offset, 1, info);
2751         ht_tree = proto_item_add_subtree (ht_item, ett_ff_ht_info);
2752
2753         proto_tree_add_boolean(ht_tree, ff_ht_info_information_request, tvb, offset, 1, info);
2754         proto_tree_add_boolean(ht_tree, ff_ht_info_40_mhz_intolerant, tvb, offset, 1, info);
2755         proto_tree_add_boolean(ht_tree, ff_ht_info_sta_chan_width, tvb, offset, 1, info);
2756         proto_tree_add_uint(ht_tree, ff_ht_info_reserved, tvb, offset, 1, info);
2757         length += 1;
2758         break;
2759       }
2760       /*** End: HT Information Fixed Field - Dustin Johnson ***/
2761
2762     /*** Begin: HT Action Fixed Field - Dustin Johnson ***/
2763     case FIELD_HT_ACTION_CODE:
2764         proto_tree_add_uint(tree, ff_ht_action, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
2765         length +=1;
2766         break;
2767     /*** End: HT Action Fixed Field - Dustin Johnson ***/
2768
2769     /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
2770     case FIELD_PSMP_STA_INFO:
2771       {
2772         #define BROADCAST 0
2773         #define MULTICAST 1
2774         #define INDIVIDUALLY_ADDRESSED 2
2775
2776         guint64 info_large;
2777         guint32 info_medium;
2778         guint16 info_small;
2779         guint8 type;
2780         proto_item *psmp_item;
2781         proto_tree *psmp_tree;
2782
2783         info_medium = tvb_get_letohl (tvb, offset);
2784         type = info_medium & 0x3;
2785
2786         psmp_item = proto_tree_add_uint(tree, ff_psmp_sta_info, tvb, offset, 8, type);
2787         psmp_tree = proto_item_add_subtree (psmp_item, ett_ff_psmp_sta_info);
2788
2789         switch (type)
2790           {
2791             case BROADCAST:
2792               {
2793                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_start_offset, tvb, offset, 2, (info_medium & 0x00001FFC) >> 2);
2794                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_duration, tvb, offset+1, 2, (info_medium & 0x001FE000) >> 13);
2795                 info_large = tvb_get_letoh64 (tvb, offset);
2796                 proto_tree_add_uint64(psmp_tree, ff_psmp_sta_info_reserved_large, tvb, offset, 6, (info_large & G_GINT64_CONSTANT(0xFFFFFFFFFFE00000)) >> 21);
2797                 break;
2798               }
2799
2800             case MULTICAST:
2801               {
2802                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_start_offset, tvb, offset, 2, (info_medium & 0x00001FFC) >> 2);
2803                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_duration, tvb, offset+1, 2, (info_medium & 0x001FE000) >> 13);
2804                 info_large = tvb_get_letoh64 (tvb, offset);
2805                 proto_tree_add_uint64(psmp_tree, ff_psmp_sta_info_psmp_multicast_id, tvb, offset, 6, (info_large & G_GINT64_CONSTANT(0xFFFFFFFFFFE00000)) >> 21);
2806                 break;
2807               }
2808
2809             case INDIVIDUALLY_ADDRESSED:
2810               {
2811                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_start_offset, tvb, offset, 2, (info_medium & 0x00001FFC) >> 2);
2812                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_dtt_duration, tvb, offset+1, 2, (info_medium & 0x001FE000) >> 13);
2813                 offset+=2;
2814                 info_medium = tvb_get_letohl (tvb, offset);
2815                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_sta_id, tvb, offset, 3, (info_medium & 0x001FFFE0) >> 5);
2816                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_utt_start_offset, tvb, offset+2, 2, (info_medium & 0xFFE00000) >> 21);
2817                 offset+=4;
2818                 info_small = tvb_get_letohs (tvb, offset);
2819                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_utt_duration, tvb, offset, 2, info_small & 0x03FF);
2820                 proto_tree_add_uint(psmp_tree, ff_psmp_sta_info_reserved_small, tvb, offset+1, 1, (info_small & 0xFC00) >> 10);
2821                 break;
2822               }
2823           }
2824         length +=8;
2825         break;
2826       }
2827     /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
2828
2829     case FIELD_SCHEDULE_INFO:
2830       {
2831         proto_item *sched_item;
2832         proto_tree *sched_tree;
2833         guint16 sched;
2834
2835         sched_item = proto_tree_add_item(tree, hf_sched_info,
2836           tvb, offset, 2, TRUE);
2837         sched_tree = proto_item_add_subtree(sched_item, ett_sched_tree);
2838         sched = tvb_get_letohs(tvb, offset);
2839         proto_tree_add_uint(sched_tree, hf_tsinfo_agg, tvb, offset,
2840           2, sched & 0x0001);
2841         if (sched & 0x0001)
2842         {
2843           proto_tree_add_uint(sched_tree, hf_tsinfo_tsid, tvb, offset,
2844             2, (sched & 0x001E) >> 1);
2845           proto_tree_add_uint(sched_tree, hf_tsinfo_dir, tvb, offset,
2846             2, (sched & 0x0060) >> 5);
2847         }
2848
2849         length += 2;
2850         break;
2851       }
2852
2853     case FIELD_ACTION:
2854       {
2855         proto_item *action_item;
2856         proto_tree *action_tree;
2857
2858         action_item = proto_tree_add_item(tree, hf_action, tvb, offset, 1, TRUE);
2859         action_tree = proto_item_add_subtree(action_item, ett_sched_tree);
2860
2861         switch (tvb_get_guint8(tvb, offset))
2862           {
2863             case CAT_SPECTRUM_MGMT:
2864               {
2865                 switch (tvb_get_guint8(tvb, offset+1))
2866                   {
2867                     case SM_ACTION_MEASUREMENT_REQUEST:
2868                     case SM_ACTION_MEASUREMENT_REPORT:
2869                     case SM_ACTION_TPC_REQUEST:
2870                     case SM_ACTION_TPC_REPORT:
2871                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2872                       add_fixed_field(action_tree, tvb, offset+1, FIELD_ACTION_CODE);
2873                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DIALOG_TOKEN);
2874                       length += 3;  /* Size of fixed fields */
2875                       break;
2876
2877                     case SM_ACTION_CHAN_SWITCH_ANNC:
2878                     case SM_ACTION_EXT_CHAN_SWITCH_ANNC:
2879                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2880                       add_fixed_field(action_tree, tvb, offset+1, FIELD_ACTION_CODE);
2881                       length += 2;  /* Size of fixed fields */
2882                       break;
2883
2884                     default:
2885                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2886                       add_fixed_field(action_tree, tvb, offset+1, FIELD_ACTION_CODE);
2887                       length += 2;  /* Size of fixed fields */
2888                       break;
2889                   }
2890                 break;
2891               }
2892
2893             case CAT_QOS:
2894               {
2895                 switch (tvb_get_guint8(tvb, offset+1))
2896                   {
2897                     case SM_ACTION_ADDTS_REQUEST:
2898                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2899                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2900                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DIALOG_TOKEN);
2901                       length += 3;
2902                       break;
2903
2904                     case SM_ACTION_ADDTS_RESPONSE:
2905                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2906                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2907                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DIALOG_TOKEN);
2908                       add_fixed_field(action_tree, tvb, offset+3, FIELD_STATUS_CODE);
2909                       length += 5;
2910                       break;
2911
2912                     case SM_ACTION_DELTS:
2913                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2914                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2915                       add_fixed_field(action_tree, tvb, offset+2, FIELD_QOS_TS_INFO);
2916                       add_fixed_field(action_tree, tvb, offset+5, FIELD_REASON_CODE);
2917                       length += 7;
2918                       break;
2919
2920                     case SM_ACTION_QOS_SCHEDULE:
2921                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2922                       add_fixed_field(action_tree, tvb, offset+1, FIELD_QOS_ACTION_CODE);
2923                       length += 2;
2924                       break;
2925
2926                     default:
2927                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2928                       length += 2;  /* Size of fixed fields */
2929                       break;
2930                   }
2931                 break;
2932               }
2933
2934             case CAT_DLS:
2935               {
2936                 switch (tvb_get_guint8(tvb, offset+1))
2937                   {
2938                     case SM_ACTION_DLS_REQUEST:
2939                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2940                       add_fixed_field(action_tree, tvb, offset+1, FIELD_DLS_ACTION_CODE);
2941                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DST_MAC_ADDR);
2942                       add_fixed_field(action_tree, tvb, offset+8, FIELD_SRC_MAC_ADDR);
2943                       add_fixed_field(action_tree, tvb, offset+14, FIELD_CAP_INFO);
2944                       add_fixed_field(action_tree, tvb, offset+16, FIELD_DLS_TIMEOUT);
2945                       length += 18;
2946                       break;
2947
2948                     case SM_ACTION_DLS_RESPONSE:
2949                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2950                       add_fixed_field(action_tree, tvb, offset+1, FIELD_DLS_ACTION_CODE);
2951                       add_fixed_field(action_tree, tvb, offset+2, FIELD_STATUS_CODE);
2952                       add_fixed_field(action_tree, tvb, offset+4, FIELD_DST_MAC_ADDR);
2953                       add_fixed_field(action_tree, tvb, offset+10, FIELD_SRC_MAC_ADDR);
2954                       length += 16;
2955                       if (!ff_status_code)
2956                         add_fixed_field(action_tree, tvb, offset+16, FIELD_CAP_INFO);
2957                       break;
2958
2959                     case SM_ACTION_DLS_TEARDOWN:
2960                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2961                       add_fixed_field(action_tree, tvb, offset+1, FIELD_DLS_ACTION_CODE);
2962                       add_fixed_field(action_tree, tvb, offset+2, FIELD_DST_MAC_ADDR);
2963                       add_fixed_field(action_tree, tvb, offset+8, FIELD_SRC_MAC_ADDR);
2964                       add_fixed_field(action_tree, tvb, offset+14, FIELD_REASON_CODE);
2965                       length += 16;
2966                       break;
2967
2968                     default:
2969                       add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2970                       length += 2;  /* Size of fixed fields */
2971                       break;
2972                   }
2973                 break;
2974               }
2975
2976             case CAT_BLOCK_ACK:
2977               {
2978                 switch (tvb_get_guint8(tvb, offset+1))
2979                   {
2980                     case BA_ADD_BLOCK_ACK_REQUEST:
2981                       {
2982                         guint start = 0;
2983                         start = offset;
2984
2985                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
2986                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_ACTION_CODE);
2987                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_DIALOG_TOKEN);
2988                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_PARAM);
2989                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_TIMEOUT);
2990                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
2991                         length = offset - start;  /* Size of fixed fields */
2992                         break;
2993                       }
2994                     case BA_ADD_BLOCK_ACK_RESPONSE:
2995                       {
2996                         guint start = 0;
2997                         start = offset;
2998
2999                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3000                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_ACTION_CODE);
3001                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_DIALOG_TOKEN);
3002                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_STATUS_CODE);
3003                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_PARAM);
3004                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_TIMEOUT);
3005                         length = offset - start;  /* Size of fixed fields */
3006                         break;
3007                       }
3008                     case BA_DELETE_BLOCK_ACK:
3009                       {
3010                         guint start = 0;
3011                         start = offset;
3012
3013                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3014                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_BLOCK_ACK_ACTION_CODE);
3015                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_DELBA_PARAM_SET);
3016                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_REASON_CODE);
3017                         length = offset - start;  /* Size of fixed fields */
3018                         break;
3019                       }
3020                   }
3021                 break;
3022               }
3023
3024             case CAT_MGMT_NOTIFICATION:  /* Management notification frame */
3025               {
3026                 guint start = 0;
3027                 start = offset;
3028
3029                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3030                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_WME_ACTION_CODE);
3031                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_DIALOG_TOKEN);
3032                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_WME_STATUS_CODE);
3033                 length = offset - start;  /* Size of fixed fields */
3034                 break;
3035               }
3036
3037           case CAT_VENDOR_SPECIFIC:/* Vendor Specific Category */
3038                   {
3039                           guint start = 0;
3040                           guint32 oui;
3041                           const guint8 *tag_data_ptr;
3042                           guint8 octet;
3043
3044                           start = offset;
3045
3046               offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3047                           oui = tvb_get_ntoh24(tvb, offset);
3048                           tag_data_ptr = tvb_get_ptr(tvb, offset, 3);
3049                           proto_tree_add_bytes_format (action_tree, tag_oui, tvb, offset, 3,
3050                                   tag_data_ptr, "Vendor: %s", get_manuf_name(tag_data_ptr));
3051                           offset+=3;
3052                           switch(oui){
3053                                   case OUI_MARVELL:
3054                                           octet = tvb_get_guint8(tvb, offset);
3055                                           proto_tree_add_item (action_tree, ff_marvell_action_type, tvb, offset, 1, TRUE);
3056                                           offset++;
3057                                           switch (octet){
3058                                                   case MRVL_ACTION_MESH_MANAGEMENT:
3059                                                           octet = tvb_get_guint8(tvb, offset);
3060                                                           proto_tree_add_item (action_tree, ff_marvell_mesh_mgt_action_code, tvb, offset, 1, TRUE);
3061                                                           offset++;
3062                                                           switch (octet){
3063                                                                   case MRVL_MESH_MGMT_ACTION_RREQ:
3064                                                                           proto_tree_add_item (action_tree, ff_mesh_mgt_length, tvb, offset, 1, TRUE);
3065                                                                           offset++;
3066                                                                           proto_tree_add_item (action_tree, ff_mesh_mgt_mode, tvb, offset, 1, TRUE);
3067                                                                           offset++;
3068                                                                           proto_tree_add_item (tree, ff_mesh_mgt_hopcount, tvb, offset, 1, TRUE);
3069                                                                           offset++;
3070                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ttl, tvb, offset, 1, TRUE);
3071                                                                           offset++;
3072                                                                           proto_tree_add_item (tree, ff_mesh_mgt_rreqid, tvb, offset, 4, TRUE);
3073                                                                           offset+= 4;
3074                                                                           proto_tree_add_item (tree, ff_mesh_mgt_sa, tvb, offset, 6, FALSE);
3075                                                                           offset+= 6;
3076                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ssn, tvb, offset, 4, TRUE);
3077                                                                           offset+= 4;
3078                                                                           proto_tree_add_item (tree, ff_mesh_mgt_lifetime, tvb, offset, 4, TRUE);
3079                                                                           offset+= 4;
3080                                                                           proto_tree_add_item (tree, ff_mesh_mgt_metric, tvb, offset, 4, TRUE);
3081                                                                           offset+= 4;
3082                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dstcount, tvb, offset, 1, TRUE);
3083                                                                           offset++;
3084                                                                           proto_tree_add_item (tree, ff_mesh_mgt_flags, tvb, offset, 1, TRUE);
3085                                                                           offset++;
3086                                                                           proto_tree_add_item (tree, ff_mesh_mgt_da, tvb, offset, 6, FALSE);
3087                                                                           offset+= 6;
3088                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dsn, tvb, offset, 4, TRUE);
3089                                                                           offset+= 4;
3090                                                                           length = offset - start;  /* Size of fixed fields */
3091                                                                           break;
3092                                                                   case MRVL_MESH_MGMT_ACTION_RREP:
3093                                                                           proto_tree_add_item (tree, ff_mesh_mgt_length, tvb, offset, 1, TRUE);
3094                                                                           offset++;
3095                                                                           proto_tree_add_item (tree, ff_mesh_mgt_mode, tvb, offset, 1, TRUE);
3096                                                                           offset++;
3097                                                                           proto_tree_add_item (tree, ff_mesh_mgt_hopcount, tvb, offset, 1, TRUE);
3098                                                                           offset++;
3099                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ttl, tvb, offset, 1, TRUE);
3100                                                                           offset++;
3101                                                                           proto_tree_add_item (tree, ff_mesh_mgt_da, tvb, offset, 6, FALSE);
3102                                                                           offset+= 6;
3103                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dsn, tvb, offset, 4, TRUE);
3104                                                                           offset+= 4;
3105                                                                           proto_tree_add_item (tree, ff_mesh_mgt_lifetime, tvb, offset, 4, TRUE);
3106                                                                           offset+= 4;
3107                                                                           proto_tree_add_item (tree, ff_mesh_mgt_metric, tvb, offset, 4, TRUE);
3108                                                                           offset+= 4;
3109                                                                           proto_tree_add_item (tree, ff_mesh_mgt_sa, tvb, offset, 6, FALSE);
3110                                                                           offset+= 6;
3111                                                                           proto_tree_add_item (tree, ff_mesh_mgt_ssn, tvb, offset, 4, TRUE);
3112                                                                           offset+= 4;
3113                                                                           length = offset - start;  /* Size of fixed fields */
3114                                                                           break;
3115                                                                   case MRVL_MESH_MGMT_ACTION_RERR:
3116                                                                           proto_tree_add_item (tree, ff_mesh_mgt_length, tvb, offset, 1, TRUE);
3117                                                                           offset++;
3118                                                                           proto_tree_add_item (tree, ff_mesh_mgt_mode, tvb, offset, 1, TRUE);
3119                                                                           offset++;
3120                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dstcount, tvb, offset, 1, TRUE);
3121                                                                           offset++;
3122                                                                           proto_tree_add_item (tree, ff_mesh_mgt_da, tvb, offset, 6, FALSE);
3123                                                                           offset+= 6;
3124                                                                           proto_tree_add_item (tree, ff_mesh_mgt_dsn, tvb, offset, 4, TRUE);
3125                                                                           offset+= 4;
3126                                                                           length = offset - start;  /* Size of fixed fields */
3127                                                                           break;
3128                                                                   default:
3129                                                                           break;
3130                                                           }
3131                                                           break;
3132                                                   default:
3133                                                           break;
3134                                           }
3135                                           break;
3136                                   default:
3137                                           /* Don't know how to handle this vendor */
3138                                           break;
3139                           }/* switch(oui) */
3140                           break;
3141                   }/* Case vendor specific */
3142
3143             case CAT_HT:
3144               {
3145                 guint start = 0;
3146                 start = offset;
3147
3148                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3149                 offset += add_fixed_field(action_tree, tvb, offset, FIELD_HT_ACTION_CODE);
3150                 switch (tvb_get_guint8(tvb, offset-1))
3151                   {
3152                     case HT_ACTION_NOTIFY_CHAN_WIDTH:
3153                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_CHANNEL_WIDTH);
3154                       break;
3155
3156                     case HT_ACTION_SM_PWR_SAVE:
3157                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_SM_PWR_CNTRL);
3158                       break;
3159
3160                     case HT_ACTION_PSMP_ACTION:
3161                       {
3162                         guint8 n_sta, i;
3163
3164                         n_sta = tvb_get_guint8(tvb, offset);
3165                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_PSMP_PARAM_SET);
3166
3167                         for (i=0; i< (n_sta & 0x0F); i++)
3168                           offset += add_fixed_field(action_tree, tvb, offset, FIELD_PSMP_STA_INFO);
3169
3170                         break;
3171                       }
3172
3173                     case HT_ACTION_SET_PCO_PHASE:
3174                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_PCO_PHASE_CNTRL);
3175                       break;
3176
3177                     case HT_ACTION_MIMO_CSI:
3178                       {
3179                         mimo_control_t mimo_cntrl;
3180                         mimo_cntrl = get_mimo_control (tvb, offset);
3181                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_MIMO_CNTRL);
3182                         offset += add_mimo_csi_matrices_report (action_tree, tvb, offset, mimo_cntrl);
3183                         break;
3184                       }
3185
3186                     case HT_ACTION_MIMO_BEAMFORMING:
3187                       {
3188                         mimo_control_t mimo_cntrl;
3189                         mimo_cntrl = get_mimo_control (tvb, offset);
3190                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_MIMO_CNTRL);
3191                         offset += add_mimo_beamforming_feedback_report (action_tree, tvb, offset, mimo_cntrl);
3192                         break;
3193                       }
3194
3195                     case HT_ACTION_MIMO_COMPRESSED_BEAMFORMING:
3196                       {
3197                         mimo_control_t mimo_cntrl;
3198                         mimo_cntrl = get_mimo_control (tvb, offset);
3199                         offset += add_fixed_field(action_tree, tvb, offset, FIELD_MIMO_CNTRL);
3200                         offset += add_mimo_compressed_beamforming_feedback_report (action_tree, tvb, offset, mimo_cntrl);
3201                         break;
3202                       }
3203
3204                     case HT_ACTION_ANT_SEL_FEEDBACK:
3205                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_ANT_SELECTION);
3206                       break;
3207
3208                     case HT_ACTION_HT_INFO_EXCHANGE:
3209                       offset += add_fixed_field(action_tree, tvb, offset, FIELD_HT_INFORMATION);
3210                       break;
3211
3212                     default:
3213                       /* Unknown */
3214                       break;
3215                   }
3216                 length = offset - start;
3217                 break;
3218               }
3219
3220             default:
3221               add_fixed_field(action_tree, tvb, offset, FIELD_CATEGORY_CODE);
3222               length += 1;  /* Size of fixed fields */
3223               break;
3224           }
3225       }
3226   }
3227   return length;
3228 }
3229
3230 static const value_string wpa_cipher_vals[] =
3231 {
3232   {0, "NONE"},
3233   {1, "WEP (40-bit)"},
3234   {2, "TKIP"},
3235   {3, "AES (OCB)"},
3236   {4, "AES (CCM)"},
3237   {5, "WEP (104-bit)"},
3238   {0, NULL}
3239 };
3240
3241 static const value_string wpa_keymgmt_vals[] =
3242 {
3243   {0, "NONE"},
3244   {1, "WPA"},
3245   {2, "PSK"},
3246   {0, NULL}
3247 };
3248
3249
3250 static void
3251 dissect_vendor_ie_wpawme(proto_item * item, proto_tree * tree, tvbuff_t * tag_tvb)
3252 {
3253   gint tag_off = 0;
3254   gint tag_len = tvb_length(tag_tvb);
3255   gchar out_buff[SHORT_STR];
3256   guint i, byte1, byte2;
3257
3258   /* Wi-Fi Protected Access (WPA) Information Element */
3259   if (tag_off + 6 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WPA_OUI"\x01", 4)) {
3260     g_snprintf(out_buff, SHORT_STR, "WPA IE, type %u, version %u",
3261     tvb_get_guint8(tag_tvb, tag_off + 3), tvb_get_letohs(tag_tvb, tag_off + 4));
3262     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 6, out_buff);
3263     tag_off += 6;
3264     if (tag_off + 4 <= tag_len) {
3265       /* multicast cipher suite */
3266       if (!tvb_memeql(tag_tvb, tag_off, WPA_OUI, 3)) {
3267         g_snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s",
3268         val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3), wpa_cipher_vals,
3269           "UNKNOWN"));
3270         proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3271           out_buff);
3272         tag_off += 4;
3273         /* unicast cipher suites */
3274         if (tag_off + 2 <= tag_len) {
3275           g_snprintf(out_buff, SHORT_STR,
3276             "# of unicast cipher suites: %u", tvb_get_letohs(tag_tvb, tag_off));
3277           proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3278             out_buff);
3279           tag_off += 2;
3280           i = 1;
3281           while (tag_off + 4 <= tag_len) {
3282             if (!tvb_memeql(tag_tvb, tag_off, WPA_OUI, 3)) {
3283               g_snprintf(out_buff, SHORT_STR,
3284                 "Unicast cipher suite %u: %s", i,
3285                 val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3286                 wpa_cipher_vals, "UNKNOWN"));
3287               proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3288                 out_buff);
3289               tag_off += 4;
3290               i ++;
3291             }
3292             else
3293               break;
3294           }
3295           /* authenticated key management suites */
3296           if (tag_off + 2 <= tag_len) {
3297             g_snprintf(out_buff, SHORT_STR,
3298               "# of auth key management suites: %u", tvb_get_letohs(tag_tvb, tag_off));
3299             proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3300               out_buff);
3301             tag_off += 2;
3302             i = 1;
3303             while (tag_off + 4 <= tag_len) {
3304               if (!tvb_memeql(tag_tvb, tag_off, WPA_OUI, 3)) {
3305                 g_snprintf(out_buff, SHORT_STR,
3306                   "auth key management suite %u: %s", i,
3307                   val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3308                   wpa_keymgmt_vals, "UNKNOWN"));
3309                 proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3310                   out_buff);
3311                 tag_off += 4;
3312                 i ++;
3313               }
3314               else
3315                 break;
3316             }
3317           }
3318         }
3319       }
3320     }
3321     if (tag_off < tag_len)
3322       proto_tree_add_string(tree, tag_interpretation, tag_tvb,
3323         tag_off, tag_len - tag_off, "Not interpreted");
3324       proto_item_append_text(item, ": WPA");
3325   } else if (tag_off + 7 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WME_OUI"\x02\x00", 5)) {
3326     /* Wireless Multimedia Enhancements (WME) Information Element */
3327     g_snprintf(out_buff, SHORT_STR,
3328       "WME IE: type %u, subtype %u, version %u, parameter set %u",
3329       tvb_get_guint8(tag_tvb, tag_off+3), tvb_get_guint8(tag_tvb, tag_off+4),
3330       tvb_get_guint8(tag_tvb, tag_off+5), tvb_get_guint8(tag_tvb, tag_off+6));
3331     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 7,
3332       out_buff);
3333     proto_item_append_text(item, ": WME");
3334   } else if (tag_off + 24 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WME_OUI"\x02\x01", 5)) {
3335     /* Wireless Multimedia Enhancements (WME) Parameter Element */
3336     g_snprintf(out_buff, SHORT_STR,
3337       "WME PE: type %u, subtype %u, version %u, parameter set %u",
3338       tvb_get_guint8(tag_tvb, tag_off+3), tvb_get_guint8(tag_tvb, tag_off+4),
3339       tvb_get_guint8(tag_tvb, tag_off+5), tvb_get_guint8(tag_tvb, tag_off+6));
3340     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 7,
3341       out_buff);
3342     tag_off += 8;
3343     for (i = 0; i < 4; i++) {
3344       byte1 = tvb_get_guint8(tag_tvb, tag_off);
3345       byte2 = tvb_get_guint8(tag_tvb, tag_off + 1);
3346       g_snprintf(out_buff, SHORT_STR,
3347         "WME AC Parameters: ACI %u (%s), Admission Control %sMandatory, AIFSN %u, ECWmin %u, ECWmax %u, TXOP %u",
3348          (byte1 & 0x60) >> 5, wme_acs[(byte1 & 0x60) >> 5],
3349          (byte1 & 0x10) ? "" : "not ", byte1 & 0x0f,
3350          byte2 & 0x0f, byte2 & 0xf0 >> 4,
3351          tvb_get_letohs(tag_tvb, tag_off + 2));
3352       proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3353         out_buff);
3354       tag_off += 4;
3355     }
3356     proto_item_append_text(item, ": WME");
3357   } else if (tag_off + 56 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WME_OUI"\x02\x02", 5)) {
3358     /* Wireless Multimedia Enhancements (WME) TSPEC Element */
3359     guint16 ts_info, msdu_size, surplus_bandwidth;
3360     const char *direction[] = { "Uplink", "Downlink", "Reserved", "Bi-directional" };
3361     const value_string fields[] = {
3362       {13, "Minimum Service Interval"},
3363       {17, "Maximum Service Interval"},
3364       {21, "Inactivity Interval"},
3365       {25, "Suspension Interval"},
3366       {29, "Service Start Time"},
3367       {33, "Minimum Data Rate"},
3368       {37, "Mean Data Rate"},
3369       {41, "Peak Data Rate"},
3370       {45, "Maximum Burst Size"},
3371       {49, "Delay Bound"},
3372       {53, "Minimum PHY Rate"},
3373       {0, NULL}
3374     };
3375     const char *field;
3376
3377     g_snprintf(out_buff, SHORT_STR,
3378       "WME TSPEC: type %u, subtype %u, version %u",
3379       tvb_get_guint8(tag_tvb, tag_off+3), tvb_get_guint8(tag_tvb, tag_off+4),
3380       tvb_get_guint8(tag_tvb, tag_off+5));
3381     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 6,
3382       out_buff);
3383     tag_off += 6;
3384
3385     ts_info = tvb_get_letohs(tag_tvb, tag_off);
3386     byte1 = (ts_info >> 11) & 0x7;
3387     g_snprintf(out_buff, SHORT_STR,
3388       "WME TS Info: Priority %u (%s) (%s), Contention-based access %sset, %s",
3389       byte1, qos_tags[byte1], qos_acs[byte1],
3390       (ts_info & 0x0080) ? "" : "not ",
3391       direction[(ts_info >> 5) & 0x3]);
3392     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 3,
3393       out_buff);
3394     tag_off += 3;
3395
3396     msdu_size = tvb_get_letohs(tag_tvb, tag_off);
3397     g_snprintf(out_buff, SHORT_STR,
3398       "WME TSPEC: %s MSDU Size %u",
3399       (msdu_size & 0x8000) ? "Fixed" : "Nominal", msdu_size & 0x7fff);
3400     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3401       out_buff);
3402     tag_off += 2;
3403
3404     g_snprintf(out_buff, SHORT_STR,
3405       "WME TSPEC: Maximum MSDU Size %u", tvb_get_letohs(tag_tvb, tag_off));
3406     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3407       out_buff);
3408     tag_off += 2;
3409
3410     while ((field = val_to_str(tag_off, fields, "Unknown"))) {
3411       g_snprintf(out_buff, SHORT_STR,
3412         "WME TSPEC: %s %u", field, tvb_get_letohl(tag_tvb, tag_off));
3413       proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4,
3414         out_buff);
3415       tag_off += 4;
3416       if (tag_off == 57)
3417         break;
3418     }
3419
3420     surplus_bandwidth = tvb_get_letohs(tag_tvb, tag_off);
3421     g_snprintf(out_buff, SHORT_STR,
3422       "WME TSPEC: Surplus Bandwidth Allowance Factor %u.%u",
3423       (surplus_bandwidth >> 13) & 0x7, (surplus_bandwidth & 0x1fff));
3424     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3425       out_buff);
3426     tag_off += 2;
3427
3428     g_snprintf(out_buff, SHORT_STR,
3429       "WME TSPEC: Medium Time %u", tvb_get_letohs(tag_tvb, tag_off));
3430     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2,
3431       out_buff);
3432     tag_off += 2;
3433     proto_item_append_text(item, ": WME");
3434   } else if (tag_off + 6 <= tag_len && !tvb_memeql(tag_tvb, tag_off, WPA_OUI"\x04", 4)) {
3435     dissect_wps_tlvs(item, tag_tvb, tag_off+4, tag_len-4, NULL);
3436     proto_item_append_text(item, ": WPS");
3437   }
3438 }
3439
3440 static void
3441 dissect_vendor_ie_rsn(proto_item * item, proto_tree * tree, tvbuff_t * tag_tvb)
3442 {
3443   guint tag_off = 0;
3444   guint tag_len = tvb_length(tag_tvb);
3445   guint pmkid_len = tag_len - 4;
3446   char out_buff[SHORT_STR], valid_str[SHORT_STR] = "";
3447
3448   if (tag_len >= 4 && !tvb_memeql(tag_tvb, tag_off, RSN_OUI"\x04", 4)) {
3449     /* IEEE 802.11i / Key Data Encapsulation / Data Type=4 - PMKID.
3450      * This is only used within EAPOL-Key frame Key Data. */
3451     if (pmkid_len != PMKID_LEN) {
3452       g_snprintf(valid_str, SHORT_STR,
3453         "(invalid PMKID len=%d, expected 16) ", pmkid_len);
3454     }
3455     g_snprintf(out_buff, SHORT_STR, "RSN PMKID: %s%s", valid_str,
3456       tvb_bytes_to_str(tag_tvb, 4, pmkid_len));
3457     proto_tree_add_string(tree, tag_interpretation, tag_tvb, 0,
3458       tag_len, out_buff);
3459   }
3460   proto_item_append_text(item, ": RSN");
3461 }
3462
3463 typedef enum {
3464   MARVELL_IE_MESH = 4
3465 } marvell_ie_type_t;
3466
3467 static void
3468 dissect_vendor_ie_marvell(proto_item * item _U_, proto_tree * ietree,
3469                           tvbuff_t * tvb, int offset, guint32 tag_len)
3470 {
3471   guint8 type;
3472
3473   type = tvb_get_guint8(tvb, offset);
3474   proto_tree_add_item (ietree, hf_marvell_ie_type, tvb, offset, 1, TRUE);
3475   offset += 1;
3476
3477   switch (type) {
3478   case MARVELL_IE_MESH:
3479     proto_tree_add_item (ietree, hf_marvell_ie_mesh_subtype, tvb,
3480                          offset++, 1, TRUE );
3481     proto_tree_add_item (ietree, hf_marvell_ie_mesh_version, tvb,
3482                          offset++, 1, TRUE );
3483     proto_tree_add_item (ietree, hf_marvell_ie_mesh_active_proto_id, tvb,
3484                          offset++, 1, TRUE );
3485     proto_tree_add_item (ietree, hf_marvell_ie_mesh_active_metric_id, tvb,
3486                          offset++, 1, TRUE );
3487     proto_tree_add_item (ietree, hf_marvell_ie_mesh_cap, tvb,
3488                          offset++, 1, TRUE );
3489     break;
3490
3491   default:
3492     proto_tree_add_item(ietree, hf_marvell_ie_data, tvb, offset,
3493       tag_len - 1, FALSE);
3494     break;
3495   }
3496 }
3497
3498 typedef enum {
3499   AIRONET_IE_VERSION = 3,
3500   AIRONET_IE_QOS,
3501   AIRONET_IE_QBSS_V2 = 14
3502 } aironet_ie_type_t;
3503
3504 static const value_string aironet_ie_type_vals[] = {
3505   { AIRONET_IE_VERSION,   "CCX version"},
3506   { AIRONET_IE_QOS,       "Qos"},
3507   { AIRONET_IE_QBSS_V2,   "QBSS V2 - CCA"},
3508   { 0,                    NULL }
3509 };
3510
3511 static void
3512 dissect_vendor_ie_aironet(proto_item * aironet_item, proto_tree * ietree,
3513   tvbuff_t * tvb, int offset, guint32 tag_len)
3514 {
3515   guint8  type;
3516   int i;
3517   gboolean dont_change = FALSE; /* Don't change the IE item text to default */
3518
3519   type = tvb_get_guint8(tvb, offset);
3520   proto_tree_add_item (ietree, hf_aironet_ie_type, tvb, offset, 1, TRUE);
3521   offset += 1;
3522
3523   switch (type) {
3524   case AIRONET_IE_VERSION:
3525     proto_tree_add_item (ietree, hf_aironet_ie_version, tvb, offset, 1, TRUE);
3526     proto_item_append_text(aironet_item, ": Aironet CCX version = %d",
3527     tvb_get_guint8(tvb, offset));
3528     dont_change = TRUE;
3529     break;
3530   case AIRONET_IE_QOS:
3531     proto_tree_add_item (ietree, hf_aironet_ie_qos_unk1, tvb, offset, 1, TRUE);
3532     offset += 1;
3533     proto_tree_add_item (ietree, hf_aironet_ie_qos_paramset, tvb, offset, 1, TRUE);
3534     offset += 1;
3535
3536     /* XXX: just copied over from WME. Maybe "Best Effort" and "Background"
3537      *  need to be swapped. Also, the "TXOP" may be TXOP - or not.
3538      */
3539     for (i = 0; i < 4; i++) {
3540       guint8 byte1, byte2;
3541       guint16 txop;
3542       byte1 = tvb_get_guint8(tvb, offset);
3543       byte2 = tvb_get_guint8(tvb, offset + 1);
3544       txop = tvb_get_letohs(tvb, offset + 2);
3545       proto_tree_add_bytes_format(ietree, hf_aironet_ie_qos_val, tvb, offset, 4,
3546         tvb_get_ptr(tvb, offset, 4),
3547           "CCX QoS Parameters??: ACI %u (%s), Admission Control %sMandatory, AIFSN %u, ECWmin %u, ECWmax %u, TXOP %u",
3548         (byte1 & 0x60) >> 5, wme_acs[(byte1 & 0x60) >> 5],
3549         (byte1 & 0x10) ? "" : "not ", byte1 & 0x0f,
3550         byte2 & 0x0f, (byte2 & 0xf0) >> 4,
3551         txop);
3552       offset += 4;
3553     }
3554     break;
3555   case AIRONET_IE_QBSS_V2:
3556     /* Extract Values */
3557     proto_tree_add_item (ietree, hf_qbss2_scount, tvb, offset, 2, TRUE);
3558     proto_tree_add_item (ietree, hf_qbss2_cu, tvb, offset + 2, 1, FALSE);
3559     proto_tree_add_item (ietree, hf_qbss2_cal, tvb, offset + 3, 1, FALSE);
3560     proto_tree_add_item (ietree, hf_qbss2_gl, tvb, offset + 4, 1, FALSE);
3561     break;
3562   default:
3563     proto_tree_add_item(ietree, hf_aironet_ie_data, tvb, offset,
3564       tag_len - 1, FALSE);
3565     break;
3566   }
3567   if (!dont_change) {
3568     proto_item_append_text(aironet_item, ": Aironet %s",
3569       val_to_str(type, aironet_ie_type_vals, "Unknown"));
3570   }
3571 }
3572
3573 static void
3574 dissect_rsn_ie(proto_tree * tree, tvbuff_t * tag_tvb)
3575 {
3576   guint tag_off = 0;
3577   guint tag_len = tvb_length(tag_tvb);
3578   guint16 rsn_capab;
3579   char out_buff[SHORT_STR];
3580   int i, count;
3581   proto_item *cap_item;
3582   proto_tree *cap_tree;
3583
3584   if (tag_off + 2 > tag_len) {
3585     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, tag_len,
3586         "Not interpreted");
3587     return;
3588   }
3589
3590   g_snprintf(out_buff, SHORT_STR, "RSN IE, version %u",
3591      tvb_get_letohs(tag_tvb, tag_off));
3592   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3593
3594   tag_off += 2;
3595
3596   if (tag_off + 4 > tag_len)
3597     goto done;
3598
3599   /* multicast cipher suite */
3600   if (!tvb_memeql(tag_tvb, tag_off, RSN_OUI, 3)) {
3601     g_snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s",
3602        val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3603          wpa_cipher_vals, "UNKNOWN"));
3604     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4, out_buff);
3605     tag_off += 4;
3606   }
3607
3608   if (tag_off + 2 > tag_len)
3609     goto done;
3610
3611   /* unicast cipher suites */
3612   count = tvb_get_letohs(tag_tvb, tag_off);
3613   g_snprintf(out_buff, SHORT_STR, "# of unicast cipher suites: %u", count);
3614   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3615   tag_off += 2;
3616   i = 1;
3617   while (tag_off + 4 <= tag_len && i <= count) {
3618     if (tvb_memeql(tag_tvb, tag_off, RSN_OUI, 3) != 0)
3619       goto done;
3620     g_snprintf(out_buff, SHORT_STR, "Unicast cipher suite %u: %s",
3621        i, val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3622          wpa_cipher_vals, "UNKNOWN"));
3623     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4, out_buff);
3624     tag_off += 4;
3625     i++;
3626   }
3627
3628   if (i <= count || tag_off + 2 > tag_len)
3629     goto done;
3630
3631   /* authenticated key management suites */
3632   count = tvb_get_letohs(tag_tvb, tag_off);
3633   g_snprintf(out_buff, SHORT_STR, "# of auth key management suites: %u", count);
3634   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3635   tag_off += 2;
3636   i = 1;
3637   while (tag_off + 4 <= tag_len && i <= count) {
3638     if (tvb_memeql(tag_tvb, tag_off, RSN_OUI, 3) != 0)
3639       goto done;
3640     g_snprintf(out_buff, SHORT_STR, "auth key management suite %u: %s",
3641        i, val_to_str(tvb_get_guint8(tag_tvb, tag_off + 3),
3642          wpa_keymgmt_vals, "UNKNOWN"));
3643     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 4, out_buff);
3644     tag_off += 4;
3645     i++;
3646   }
3647
3648   if (i <= count || tag_off + 2 > tag_len)
3649     goto done;
3650
3651   rsn_capab = tvb_get_letohs(tag_tvb, tag_off);
3652   g_snprintf(out_buff, SHORT_STR, "RSN Capabilities 0x%04x", rsn_capab);
3653   cap_item = proto_tree_add_uint_format(tree, rsn_cap, tag_tvb,
3654           tag_off, 2, rsn_capab,
3655           "RSN Capabilities: 0x%04X", rsn_capab);
3656   cap_tree = proto_item_add_subtree(cap_item, ett_rsn_cap_tree);
3657   proto_tree_add_boolean(cap_tree, rsn_cap_preauth, tag_tvb, tag_off, 2,
3658        rsn_capab);
3659   proto_tree_add_boolean(cap_tree, rsn_cap_no_pairwise, tag_tvb, tag_off, 2,
3660        rsn_capab);
3661   proto_tree_add_uint(cap_tree, rsn_cap_ptksa_replay_counter, tag_tvb, tag_off, 2,
3662           rsn_capab);
3663   proto_tree_add_uint(cap_tree, rsn_cap_gtksa_replay_counter, tag_tvb, tag_off, 2,
3664           rsn_capab);
3665   tag_off += 2;
3666
3667   if (tag_off + 2 > tag_len)
3668     goto done;
3669
3670   count = tvb_get_letohs(tag_tvb, tag_off);
3671   g_snprintf(out_buff, SHORT_STR, "# of PMKIDs: %u", count);
3672   proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off, 2, out_buff);
3673   tag_off += 2;
3674
3675   /* PMKID List (16 * n octets) */
3676   for (i = 0; i < count; i++) {
3677     if (tag_off + PMKID_LEN > tag_len)
3678       break;
3679     g_snprintf(out_buff, SHORT_STR, "PMKID %u: %s", i,
3680         tvb_bytes_to_str(tag_tvb, tag_off, PMKID_LEN));
3681     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off,
3682         PMKID_LEN, out_buff);
3683     tag_off += PMKID_LEN;
3684   }
3685
3686 done:
3687   if (tag_off < tag_len)
3688     proto_tree_add_string(tree, tag_interpretation, tag_tvb, tag_off,
3689         tag_len - tag_off, "Not interpreted");
3690 }
3691
3692 static void
3693 dissect_mcs_set(proto_tree *tree, tvbuff_t *tvb, int offset, gboolean basic, gboolean vs) {
3694   proto_item *ti;
3695   proto_tree *mcs_tree, *bit_tree;
3696   guint16 capability;
3697
3698   /* 16 byte Supported MCS set */
3699   ti = proto_tree_add_string(tree, vs ? mcsset_vs : mcsset, tvb, offset, 16,
3700       basic ? "Basic MCS Set" : "MCS Set");
3701   mcs_tree = proto_item_add_subtree(ti, ett_mcsset_tree);
3702
3703   /* Rx MCS Bitmask */
3704   ti = proto_tree_add_string(mcs_tree, tag_interpretation, tvb, offset,
3705       10, "Rx Modulation and Coding Scheme (One bit per modulation)");
3706   bit_tree = proto_item_add_subtree(ti, ett_mcsbit_tree);
3707
3708   /* Bits 0 - 31 */
3709   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_0to7, tvb, offset, 4, TRUE);
3710   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_8to15, tvb, offset, 4, TRUE);
3711   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_16to23, tvb, offset, 4, TRUE);
3712   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_24to31, tvb, offset, 4, TRUE);
3713
3714   /* Bits 32 - 52 */
3715   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_32, tvb, offset + 4, 4, TRUE);
3716   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_33to38, tvb, offset + 4, 4, TRUE);
3717   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_39to52, tvb, offset + 4, 4, TRUE);
3718
3719   /* Bits 53 - 76 */
3720   proto_tree_add_item(bit_tree, mcsset_rx_bitmask_53to76, tvb, offset + 6, 4, TRUE);
3721
3722   capability = tvb_get_letohs (tvb, offset+10);
3723   proto_tree_add_uint_format(mcs_tree, mcsset_highest_data_rate, tvb, offset + 10, 2,
3724       capability, "Highest Supported Data Rate: 0x%04X", capability);
3725   capability = tvb_get_letohs (tvb, offset+12);
3726   proto_tree_add_boolean(mcs_tree, mcsset_tx_mcs_set_defined, tvb, offset + 12, 1,
3727       capability);
3728   proto_tree_add_boolean(mcs_tree, mcsset_tx_rx_mcs_set_not_equal, tvb, offset + 12, 1,
3729       capability);
3730   proto_tree_add_uint(mcs_tree, mcsset_tx_max_spatial_streams, tvb, offset + 12, 1,
3731       capability);
3732   proto_tree_add_boolean(mcs_tree, mcsset_tx_unequal_modulation, tvb, offset + 12, 1,
3733       capability);
3734 }
3735
3736 /*  802.11n D1.10 - HT Information IE  */
3737 static void
3738 dissect_ht_info_ie_1_1(proto_tree * tree, tvbuff_t * tvb, int offset,
3739          guint32 tag_len)
3740 {
3741   proto_item *cap_item;
3742   proto_tree *cap_tree;
3743   guint32 tag_val_init_off = 0;
3744   guint16 info = 0;
3745
3746   tag_val_init_off = offset;
3747   cap_tree = tree;
3748
3749   if (tag_len < 22) {
3750     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
3751               "HT Information IE content length must be at least 22 bytes");
3752     return;
3753   }
3754
3755   info = tvb_get_guint8 (tvb, offset);
3756   proto_tree_add_item(cap_tree, ht_info_primary_channel, tvb, offset, 1, TRUE);
3757
3758   info = tvb_get_guint8 (tvb, ++offset);
3759   cap_item = proto_tree_add_uint_format(tree, ht_info_delimiter1, tvb,
3760                     offset, 1, info,
3761                     "HT Information Subset (1 of 3): 0x%02X", info);
3762   cap_tree = proto_item_add_subtree(cap_item, ett_ht_info_delimiter1_tree);
3763   proto_tree_add_uint(cap_tree, ht_info_secondary_channel_offset, tvb, offset, 1,
3764              info);
3765   proto_tree_add_boolean(cap_tree, ht_info_channel_width, tvb, offset, 1,
3766              info);
3767   proto_tree_add_boolean(cap_tree, ht_info_rifs_mode, tvb, offset, 1,
3768              info);
3769   proto_tree_add_boolean(cap_tree, ht_info_psmp_stas_only, tvb, offset, 1,
3770              info);
3771   proto_tree_add_uint(cap_tree, ht_info_service_interval_granularity, tvb, offset, 1,
3772              info);
3773
3774   info = tvb_get_letohs (tvb, ++offset);
3775   cap_item = proto_tree_add_uint_format(tree, ht_info_delimiter2, tvb,
3776                     offset, 2, info,
3777                     "HT Information Subset (2 of 3): 0x%04X", info);
3778   cap_tree = proto_item_add_subtree(cap_item, ett_ht_info_delimiter2_tree);
3779   proto_tree_add_uint(cap_tree, ht_info_operating_mode, tvb, offset, 1,
3780              info);
3781   proto_tree_add_boolean(cap_tree, ht_info_non_greenfield_sta_present, tvb, offset, 1,
3782              info);
3783   proto_tree_add_boolean(cap_tree, ht_info_transmit_burst_limit, tvb, offset, 1,
3784              info);
3785   proto_tree_add_boolean(cap_tree, ht_info_obss_non_ht_stas_present, tvb, offset, 1,
3786              info);
3787   proto_tree_add_uint(cap_tree, ht_info_reserved_1, tvb, offset, 2,
3788              info);
3789
3790   offset += 2;
3791   info = tvb_get_letohs (tvb, offset);
3792   cap_item = proto_tree_add_uint_format(tree, ht_info_delimiter3, tvb,
3793                     offset, 2, info,
3794                     "HT Information Subset (3 of 3): 0x%04X", info);
3795   cap_tree = proto_item_add_subtree(cap_item, ett_ht_info_delimiter3_tree);
3796   proto_tree_add_uint(cap_tree, ht_info_reserved_2, tvb, offset, 1,
3797              info);
3798   proto_tree_add_boolean(cap_tree, ht_info_dual_beacon, tvb, offset, 1,
3799              info);
3800   proto_tree_add_boolean(cap_tree, ht_info_dual_cts_protection, tvb, offset, 1,
3801              info);
3802   proto_tree_add_boolean(cap_tree, ht_info_secondary_beacon, tvb, offset+1, 1,
3803              info);
3804   proto_tree_add_boolean(cap_tree, ht_info_lsig_txop_protection_full_support, tvb, offset+1, 1,
3805              info);
3806   proto_tree_add_boolean(cap_tree, ht_info_pco_active, tvb, offset+1, 1,
3807              info);
3808   proto_tree_add_boolean(cap_tree, ht_info_pco_phase, tvb, offset+1, 1,
3809              info);
3810   proto_tree_add_uint(cap_tree, ht_info_reserved_3, tvb, offset+1, 1,
3811              info);
3812
3813   offset += 2;
3814   cap_tree = tree;
3815
3816   dissect_mcs_set(cap_tree, tvb, offset, TRUE, FALSE);
3817   offset += 16;
3818
3819   if (tag_val_init_off - offset < tag_len){
3820     proto_tree_add_string(cap_tree, tag_interpretation, tvb, offset,
3821        tag_len + tag_val_init_off - offset, "Unparsed Extra Data");
3822   }
3823 }
3824
3825 /***  WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
3826 static void
3827 dissect_wsie_ie(proto_tree * tree, tvbuff_t * tvb, int offset, guint32 tag_len _U_)
3828 {
3829         proto_item *pst_item, *cap_item, *chan_noc_item, *chnl_item;
3830         proto_tree *pst_tree, *cap_tree, *chan_noc_tree, *chnl_tree;
3831
3832         guint8 providercount, pst_contents, pst_acm_length;
3833         int i;
3834         guint16 pst_length = 0;
3835         guint16 chan_noc;
3836         guint8 chan_length = 0;
3837         int local_offset;
3838
3839         proto_tree_add_item(tree, hf_pst_timingquality, tvb, offset, 2, TRUE);
3840         offset+=2;
3841
3842         providercount = tvb_get_guint8 (tvb, offset);
3843         pst_item = proto_tree_add_item(tree, hf_pst_providercount, tvb, offset, 1, TRUE);
3844         pst_tree = proto_item_add_subtree(pst_item,ett_pst_tree);
3845         offset++;
3846
3847         for (i=0;i<providercount;i++) {
3848
3849                 local_offset = offset;
3850                 cap_item = proto_tree_add_text (pst_tree, tvb, local_offset, pst_length, "Capabilities of Provider :%u", i+1);
3851                 cap_tree = proto_item_add_subtree(cap_item, ett_pst_cap_tree);
3852
3853                 pst_length = tvb_get_letohl(tvb, local_offset);
3854                 proto_tree_add_item(cap_tree, hf_pst_length, tvb, local_offset, 2, TRUE);
3855                 local_offset+=2;
3856
3857                 pst_contents = tvb_get_guint8 (tvb, local_offset);
3858                 proto_tree_add_item(cap_tree, hf_pst_contents, tvb, local_offset, 1, TRUE);
3859                 local_offset++;
3860
3861                 if (pst_contents & WAVE_ACID) {
3862                         proto_tree_add_item(cap_tree, hf_pst_acid, tvb, local_offset, 1, TRUE);
3863                         local_offset++;
3864                 }
3865
3866                 if (pst_contents & WAVE_ACM) {
3867                         pst_acm_length = tvb_get_guint8 (tvb, local_offset);
3868                         proto_tree_add_item(cap_tree, hf_pst_acm_length, tvb, local_offset, 1, TRUE);
3869                         local_offset++;
3870                         proto_tree_add_item(cap_tree, hf_pst_acm, tvb, local_offset, pst_acm_length, FALSE);
3871                 }
3872                 if (pst_contents & WAVE_ACF) {
3873                         local_offset +=32;
3874                 }
3875                 if (pst_contents & WAVE_PRIORITY) {
3876                         proto_tree_add_item(cap_tree, hf_pst_priority, tvb, local_offset, 1, TRUE);
3877                         local_offset++;
3878                 }
3879                 if (pst_contents & WAVE_IPV6ADDR) {
3880                         proto_tree_add_item(cap_tree, hf_pst_ipv6addr, tvb, local_offset, 16, FALSE);
3881                         local_offset +=16;
3882                         proto_tree_add_item(cap_tree, hf_pst_serviceport, tvb, local_offset, 2, FALSE);
3883                         local_offset +=2;
3884                         proto_tree_add_item(cap_tree, hf_pst_addressing, tvb, local_offset, 1, FALSE);
3885                         local_offset++;
3886                 }
3887                 if (pst_contents & WAVE_PEERMAC) {
3888                         proto_tree_add_item(cap_tree, hf_pst_macaddr, tvb, local_offset, 6, FALSE);
3889                         local_offset +=6;
3890                 }
3891                 if (pst_contents & WAVE_CHANNEL) {
3892                         proto_tree_add_item(cap_tree, hf_pst_channel, tvb, local_offset, 1, FALSE);
3893                         local_offset++;
3894                 }
3895
3896                 offset = offset + pst_length;
3897         }
3898
3899         chan_noc = tvb_get_guint8 (tvb, offset);
3900         chan_noc_item = proto_tree_add_item(tree, hf_chan_noc, tvb, offset, 1, TRUE);
3901         chan_noc_tree = proto_item_add_subtree(chan_noc_item,ett_chan_noc_tree);
3902         offset++;
3903
3904         if (chan_noc != 0){
3905                 for (i=0;i<chan_noc;i++) {
3906                         chan_length = tvb_get_guint8 (tvb, offset);
3907                         chnl_item = proto_tree_add_text (chan_noc_tree, tvb, offset, chan_length, "Channel :%u Information ", i+1);
3908                         chnl_tree = proto_item_add_subtree(chnl_item, ett_wave_chnl_tree);
3909                         proto_tree_add_item(chnl_tree, hf_chan_length, tvb, offset, 1, TRUE);
3910                         proto_tree_add_item(chnl_tree, hf_chan_content, tvb, offset+1, 1, TRUE);
3911                         proto_tree_add_item(chnl_tree, hf_chan_channel, tvb, offset+2, 1, TRUE);
3912                         proto_tree_add_item(chnl_tree, hf_chan_adapt, tvb, offset+3, 1, TRUE);
3913                         proto_tree_add_item(chnl_tree, hf_chan_rate, tvb, offset+4, 1, TRUE);
3914                         proto_tree_add_item(chnl_tree, hf_chan_tx_pow, tvb, offset+5, 1, TRUE);
3915                         offset = offset + chan_length;
3916                 }
3917         }
3918 }
3919
3920 /*** Begin: Secondary Channel Offset Tag - Dustin Johnson ***/
3921 static void secondary_channel_offset_ie(proto_tree * tree, tvbuff_t * tvb, int offset, guint32 tag_len)
3922 {
3923   int tag_offset;
3924
3925   if (tag_len != 1)
3926   {
3927     proto_tree_add_text (tree, tvb, offset, tag_len, "Secondary Channel Offset: Error: Tag length must be at least 1 byte long");
3928     return;
3929   }
3930
3931   tag_offset = offset;
3932   proto_tree_add_uint(tree, hf_tag_secondary_channel_offset, tvb, offset, 1, tvb_get_guint8 (tvb, offset));
3933
3934   offset++;
3935   if ((tag_len - (offset-tag_offset)) > 0)
3936   {
3937     proto_tree_add_text (tree, tvb, offset, tag_len - (offset-tag_offset), "Unknown Data");
3938     return;
3939   }
3940 }
3941 /*** End: Secondary Channel Offset Tag - Dustin Johnson ***/
3942
3943 static void
3944 dissect_ht_capability_ie(proto_tree * tree, tvbuff_t * tvb, int offset,
3945          guint32 tag_len, gboolean vs)
3946 {
3947   proto_item *cap_item;
3948   proto_tree *cap_tree;
3949   guint16 capability;
3950   guint32 txbfcap;
3951   guint32 tag_val_off = 0;
3952
3953   if (tag_val_off + 2 > tag_len) {
3954     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
3955         "Not interpreted");
3956     return;
3957   }
3958
3959   if (tag_len != 26) {
3960     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
3961               "HT Capabilities IE content length must be exactly 26 bytes");
3962     return;
3963   }
3964
3965   if (wlan_ignore_draft_ht && vs)
3966     return;
3967
3968   /* 2 byte HT Capabilities  Info*/
3969   capability = tvb_get_letohs (tvb, offset);
3970   cap_item = proto_tree_add_item(tree, vs ? ht_vs_cap : ht_cap, tvb,
3971                     offset, 2, TRUE);
3972   cap_tree = proto_item_add_subtree(cap_item, ett_ht_cap_tree);
3973   proto_tree_add_boolean(cap_tree, ht_ldpc_coding, tvb, offset, 1,
3974              capability);
3975   proto_tree_add_boolean(cap_tree, ht_chan_width, tvb, offset, 1,
3976              capability);
3977   proto_tree_add_uint(cap_tree, ht_sm_pwsave, tvb, offset, 1,
3978              capability);
3979   proto_tree_add_boolean(cap_tree, ht_green, tvb, offset, 1,
3980              capability);
3981   proto_tree_add_boolean(cap_tree, ht_short20, tvb, offset, 1,
3982              capability);
3983   proto_tree_add_boolean(cap_tree, ht_short40, tvb, offset, 1,
3984              capability);
3985   proto_tree_add_boolean(cap_tree, ht_tx_stbc, tvb, offset, 1,
3986              capability);
3987   proto_tree_add_uint(cap_tree, ht_rx_stbc, tvb, offset+1, 1,
3988              capability);
3989   proto_tree_add_boolean(cap_tree, ht_delayed_block_ack, tvb, offset+1, 1,
3990              capability);
3991   proto_tree_add_boolean(cap_tree, ht_max_amsdu, tvb, offset+1, 1,
3992              capability);
3993   proto_tree_add_boolean(cap_tree, ht_dss_cck_40, tvb, offset+1, 1,
3994              capability);
3995   proto_tree_add_boolean(cap_tree, ht_psmp, tvb, offset+1, 1,
3996              capability);
3997   proto_tree_add_boolean(cap_tree, ht_40_mhz_intolerant, tvb, offset+1, 1,
3998              capability);
3999   proto_tree_add_boolean(cap_tree, ht_l_sig, tvb, offset+1, 1,
4000              capability);
4001
4002   offset += 2;
4003   tag_val_off += 2;
4004
4005   /* 1 byte A-MPDU Parameters */
4006   capability = tvb_get_guint8 (tvb, offset);
4007   cap_item = proto_tree_add_item(tree, vs ? ampduparam_vs : ampduparam, tvb,
4008                     offset, 1, TRUE);
4009   cap_tree = proto_item_add_subtree(cap_item, ett_ampduparam_tree);
4010   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);
4011   proto_tree_add_uint(cap_tree, ampduparam_mpdu_start_spacing, tvb, offset, 1, capability);
4012   proto_tree_add_uint(cap_tree, ampduparam_reserved, tvb, offset, 1, capability);
4013   offset += 1;
4014   tag_val_off += 1;
4015
4016   /* 16 byte MCS set */
4017   dissect_mcs_set(tree, tvb, offset, FALSE, vs);
4018   offset += 16;
4019   tag_val_off += 16;
4020
4021   /* 2 byte HT Extended Capabilities */
4022   capability = tvb_get_letohs (tvb, offset);
4023   cap_item = proto_tree_add_item(tree, vs ? htex_vs_cap : htex_cap, tvb,
4024                     offset, 2, TRUE);
4025   cap_tree = proto_item_add_subtree(cap_item, ett_htex_cap_tree);
4026   proto_tree_add_boolean(cap_tree, htex_pco, tvb, offset, 1,
4027              capability);
4028   proto_tree_add_uint(cap_tree, htex_transtime, tvb, offset, 1,
4029              capability);
4030   proto_tree_add_uint(cap_tree, htex_mcs, tvb, offset+1, 1,
4031              capability);
4032   proto_tree_add_boolean(cap_tree, htex_htc_support, tvb, offset+1, 1,
4033              capability);
4034   proto_tree_add_boolean(cap_tree, htex_rd_responder, tvb, offset+1, 1,
4035              capability);
4036
4037   offset += 2;
4038   tag_val_off += 2;
4039
4040   /* 4 byte TxBF capabilities */
4041   txbfcap = tvb_get_letohl (tvb, offset);
4042   cap_item = proto_tree_add_item(tree, vs ? txbf_vs : txbf, tvb,
4043                     offset, 4, TRUE);
4044   cap_tree = proto_item_add_subtree(cap_item, ett_txbf_tree);
4045   proto_tree_add_boolean(cap_tree, txbf_cap, tvb, offset, 1,
4046              txbfcap);
4047   proto_tree_add_boolean(cap_tree, txbf_rcv_ssc, tvb, offset, 1,
4048              txbfcap);
4049   proto_tree_add_boolean(cap_tree, txbf_tx_ssc, tvb, offset, 1,
4050              txbfcap);
4051   proto_tree_add_boolean(cap_tree, txbf_rcv_ndp, tvb, offset, 1,
4052              txbfcap);
4053   proto_tree_add_boolean(cap_tree, txbf_tx_ndp, tvb, offset, 1,
4054              txbfcap);
4055   proto_tree_add_boolean(cap_tree, txbf_impl_txbf, tvb, offset, 1,
4056              txbfcap);
4057   proto_tree_add_uint(cap_tree, txbf_calib, tvb, offset, 1,
4058              txbfcap);
4059   proto_tree_add_boolean(cap_tree, txbf_expl_csi, tvb, offset+1, 1,
4060              txbfcap);
4061   proto_tree_add_boolean(cap_tree, txbf_expl_uncomp_fm, tvb, offset+1, 1,
4062              txbfcap);
4063   proto_tree_add_boolean(cap_tree, txbf_expl_comp_fm, tvb, offset+1, 1,
4064              txbfcap);
4065   proto_tree_add_uint(cap_tree, txbf_expl_bf_csi, tvb, offset+1, 1,
4066              txbfcap);
4067   proto_tree_add_uint(cap_tree, txbf_expl_uncomp_fm_feed, tvb, offset+1, 1,
4068              txbfcap);
4069   proto_tree_add_uint(cap_tree, txbf_expl_comp_fm_feed, tvb, offset+1, 2,
4070              txbfcap);
4071   proto_tree_add_uint(cap_tree, txbf_min_group, tvb, offset+2, 1,
4072              txbfcap);
4073   proto_tree_add_uint(cap_tree, txbf_csi_num_bf_ant, tvb, offset+2, 1,
4074              txbfcap);
4075   proto_tree_add_uint(cap_tree, txbf_uncomp_sm_bf_ant, tvb, offset+2, 1,
4076              txbfcap);
4077   proto_tree_add_uint(cap_tree, txbf_comp_sm_bf_ant, tvb, offset+2, 2,
4078              txbfcap);
4079   proto_tree_add_uint(cap_tree, txbf_csi_max_rows_bf, tvb, offset+3, 1,
4080              txbfcap);
4081   proto_tree_add_uint(cap_tree, txbf_chan_est, tvb, offset+3, 1,
4082              txbfcap);
4083   proto_tree_add_uint(cap_tree, txbf_resrv, tvb, offset+3, 1,
4084              txbfcap);
4085
4086   offset += 4;
4087   tag_val_off += 4;
4088
4089   /* 1 byte Antenna Selection (ASEL) capabilities */
4090   capability = tvb_get_guint8 (tvb, offset);
4091   cap_item = proto_tree_add_item(tree, vs ? antsel_vs : antsel, tvb,
4092                     offset, 1, TRUE);
4093   cap_tree = proto_item_add_subtree(cap_item, ett_antsel_tree);
4094   proto_tree_add_boolean(cap_tree, antsel_b0, tvb, offset, 1,
4095              capability);
4096   proto_tree_add_boolean(cap_tree, antsel_b1, tvb, offset, 1,
4097              capability);
4098   proto_tree_add_boolean(cap_tree, antsel_b2, tvb, offset, 1,
4099              capability);
4100   proto_tree_add_boolean(cap_tree, antsel_b3, tvb, offset, 1,
4101              capability);
4102   proto_tree_add_boolean(cap_tree, antsel_b4, tvb, offset, 1,
4103              capability);
4104   proto_tree_add_boolean(cap_tree, antsel_b5, tvb, offset, 1,
4105              capability);
4106   proto_tree_add_boolean(cap_tree, antsel_b6, tvb, offset, 1,
4107              capability);
4108   proto_tree_add_uint(cap_tree, antsel_b7, tvb, offset, 1,
4109              capability);
4110
4111   offset += 1;
4112   tag_val_off += 1;
4113
4114   if (tag_val_off < tag_len)
4115     proto_tree_add_string(tree, tag_interpretation, tvb, offset,
4116         tag_len - tag_val_off, "Not interpreted");
4117 }
4118
4119 static void
4120 dissect_ht_info_ie_1_0(proto_tree * tree, tvbuff_t * tvb, int offset,
4121          guint32 tag_len)
4122 {
4123   proto_item *cap_item;
4124   proto_tree *cap_tree;
4125   guint16 capability;
4126   guint32 tag_val_off = 0;
4127   gchar out_buff[SHORT_STR];
4128
4129   if (tag_val_off + 2 > tag_len) {
4130     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
4131         "Not interpreted");
4132     return;
4133   }
4134
4135   if (tag_len < 22) {
4136     proto_tree_add_string(tree, tag_interpretation, tvb, offset, tag_len,
4137               "HT Additional Capabilities IE content length must be 22");
4138     return;
4139   }
4140
4141   if (wlan_ignore_draft_ht)
4142     return;
4143
4144   g_snprintf(out_buff, SHORT_STR, "Control Channel %d",
4145              tvb_get_guint8(tvb, offset));
4146   proto_tree_add_string(tree, tag_interpretation, tvb, offset, 1, out_buff);
4147   offset += 1;
4148   tag_val_off += 1;
4149
4150   /* 1 byte HT additional capabilities */
4151   capability = tvb_get_guint8 (tvb, offset);
4152   cap_item = proto_tree_add_uint_format(tree, hta_cap, tvb,
4153                     offset, 1, capability,
4154                     "HT Additional Capabilities: 0x%04X", capability);
4155   cap_tree = proto_item_add_subtree(cap_item, ett_hta_cap_tree);
4156   proto_tree_add_uint(cap_tree, hta_ext_chan_offset, tvb, offset, 1,
4157              capability);
4158   proto_tree_add_boolean(cap_tree, hta_rec_tx_width, tvb, offset, 1,
4159              capability);
4160   proto_tree_add_boolean(cap_tree, hta_rifs_mode, tvb, offset, 1,
4161              capability);
4162   proto_tree_add_boolean(cap_tree, hta_controlled_access, tvb, offset, 1,
4163              capability);
4164   proto_tree_add_uint(cap_tree, hta_service_interval, tvb, offset, 1,
4165              capability);
4166   offset += 1;
4167   tag_val_off += 1;
4168
4169   /* 2 byte HT additional capabilities */
4170   capability = tvb_get_letohs (tvb, offset);
4171   cap_item = proto_tree_add_uint_format(tree, hta_cap, tvb,
4172                     offset, 2, capability,
4173                     "HT Additional Capabilities: 0x%04X", capability);
4174   cap_tree = proto_item_add_subtree(cap_item, ett_hta_cap1_tree);
4175   proto_tree_add_uint(cap_tree, hta_operating_mode, tvb, offset, 2,
4176              capability);
4177   proto_tree_add_boolean(cap_tree, hta_non_gf_devices, tvb, offset, 2,
4178              capability);
4179
4180   offset += 2;
4181   tag_val_off += 2;
4182
4183   /* 2 byte HT additional capabilities */
4184   capability = tvb_get_letohs (tvb, offset);
4185   cap_item = proto_tree_add_uint_format(tree, hta_cap, tvb,
4186                     offset, 2, capability,
4187                     "HT Additional Capabilities: 0x%04X", capability);
4188   cap_tree = proto_item_add_subtree(cap_item, ett_hta_cap2_tree);
4189   proto_tree_add_uint(cap_tree, hta_basic_stbc_mcs, tvb, offset, 2,
4190              capability);
4191   proto_tree_add_boolean(cap_tree, hta_dual_stbc_protection, tvb, offset, 2,
4192              capability);
4193   proto_tree_add_boolean(cap_tree, hta_secondary_beacon, tvb, offset, 2,
4194              capability);
4195   proto_tree_add_boolean(cap_tree, hta_lsig_txop_protection, tvb, offset, 2,
4196              capability);
4197   proto_tree_add_boolean(cap_tree, hta_pco_active, tvb, offset, 2,
4198              capability);
4199   proto_tree_add_boolean(cap_tree, hta_pco_phase, tvb, offset, 2,
4200              capability);
4201   offset += 2;
4202   tag_val_off += 2;
4203
4204   /* 16 byte Supported MCS set */
4205   dissect_mcs_set(tree, tvb, offset, FALSE, TRUE);
4206   offset += 16;
4207   tag_val_off += 16;
4208
4209    if (tag_val_off < tag_len)
4210      proto_tree_add_string(tree, tag_interpretation, tvb, offset,
4211                tag_len - tag_val_off, "Not interpreted");
4212 }
4213
4214 /* 802.11n-D1.10 and 802.11n-D2.0, 7.1.3.5a */
4215
4216 /*
4217  * 7.1.3.1.10 says:
4218  * "The Order field is 1 bit in length and is set to 1 in any non-QoS Data
4219  * frame that contains an MSDU, or fragment thereof, which is being
4220  * transferred using the StrictlyOrdered service class. The presence of the
4221  * HT Control field in frames is indicated by setting the Order field to 1
4222  * in any Data type or Management type frame that  is transmitted with a
4223  * value of HT_GF or HT_MM for the FORMAT parameter of the TXVECTOR except
4224  * a non-QoS Data frame or a Control Wrapper frame. The Order field is set
4225  * to 0 in all other frames. All non-HT QoS STAs set the Order field to 0."
4226  *
4227  * ...so does this mean that we can check for the presence of +HTC by
4228  * looking for QoS frames with the Order bit set, or do we need extra
4229  * information from the PHY (which would be monumentally silly)?
4230  *
4231  * At any rate, it doesn't look like any equipment we have produces
4232  * +HTC frames, so the code is completely untested.
4233  */
4234
4235 static void
4236 dissect_ht_control(proto_tree *tree, tvbuff_t * tvb, int offset)
4237 {
4238   proto_item *ti;
4239   proto_tree *htc_tree, *lac_subtree;
4240   guint16 htc;
4241
4242   htc = tvb_get_letohs(tvb, offset);
4243
4244   ti = proto_tree_add_item(tree, hf_htc, tvb, offset, 4, TRUE);
4245   htc_tree = proto_item_add_subtree(ti, ett_htc_tree);
4246
4247   /* Start: Link Adaptation Control */
4248   ti = proto_tree_add_item(htc_tree, hf_htc_lac, tvb, offset, 2, TRUE);
4249   lac_subtree = proto_item_add_subtree(ti, ett_htc_tree);
4250   proto_tree_add_item(lac_subtree, hf_htc_lac_reserved, tvb, offset, 1, htc);
4251   proto_tree_add_item(lac_subtree, hf_htc_lac_trq, tvb, offset, 1, TRUE);
4252
4253   if (HTC_IS_ASELI(htc)) {
4254     proto_tree_add_uint(lac_subtree, hf_htc_lac_mai_aseli, tvb, offset, 1, htc);
4255   } else {
4256     proto_tree_add_item(lac_subtree, hf_htc_lac_mai_mrq, tvb, offset, 1, TRUE);
4257     if (HTC_LAC_MAI_MRQ(htc)){
4258       proto_tree_add_uint(lac_subtree, hf_htc_lac_mai_msi, tvb, offset, 1, htc);
4259     } else {
4260       proto_tree_add_uint(lac_subtree, hf_htc_lac_mai_reserved, tvb, offset, 1, htc);
4261     }
4262   }
4263
4264   proto_tree_add_uint(lac_subtree, hf_htc_lac_mfsi, tvb, offset, 2, htc);
4265   offset++;
4266
4267   if (HTC_IS_ASELI(htc)) {
4268     proto_tree_add_uint(lac_subtree, hf_htc_lac_asel_command, tvb, offset, 1, htc);
4269     proto_tree_add_uint(lac_subtree, hf_htc_lac_asel_data, tvb, offset, 1, htc);
4270   } else {
4271     proto_tree_add_uint(lac_subtree, hf_htc_lac_mfb, tvb, offset, 1, htc);
4272   }
4273   /* End: Link Adaptation Control */
4274
4275   offset++;
4276   htc = tvb_get_letohs(tvb, offset);
4277
4278   proto_tree_add_uint(htc_tree, hf_htc_cal_pos, tvb, offset, 1, htc);
4279   proto_tree_add_uint(htc_tree, hf_htc_cal_seq, tvb, offset, 1, htc);
4280   proto_tree_add_uint(htc_tree, hf_htc_reserved1, tvb, offset, 1, htc);
4281   proto_tree_add_uint(htc_tree, hf_htc_csi_steering, tvb, offset, 1, htc);
4282
4283   offset++;
4284   proto_tree_add_boolean(htc_tree, hf_htc_ndp_announcement, tvb, offset, 1, htc);
4285   proto_tree_add_uint(htc_tree, hf_htc_reserved2, tvb, offset, 1, htc);
4286   proto_tree_add_boolean(htc_tree, hf_htc_ac_constraint, tvb, offset, 1, htc);
4287   proto_tree_add_boolean(htc_tree, hf_htc_rdg_more_ppdu, tvb, offset, 1, htc);
4288 }
4289
4290 static void
4291 dissect_frame_control(proto_tree * tree, tvbuff_t * tvb, gboolean wlan_broken_fc,
4292                       guint32 offset)
4293 {
4294   guint16 fcf, flags, frame_type_subtype;
4295   proto_tree *fc_tree, *flag_tree;
4296   proto_item *fc_item, *flag_item, *hidden_item;
4297
4298   fcf = FETCH_FCF(offset);
4299
4300   flags = FCF_FLAGS(fcf);
4301   frame_type_subtype = COMPOSE_FRAME_TYPE(fcf);
4302
4303   proto_tree_add_uint (tree, hf_fc_frame_type_subtype,
4304     tvb, wlan_broken_fc?offset+1:offset, 1,
4305     frame_type_subtype);
4306
4307   fc_item = proto_tree_add_uint_format (tree, hf_fc_field, tvb,
4308     offset, 2, fcf, "Frame Control: 0x%04X (%s)",
4309     fcf, wlan_broken_fc?"Swapped":"Normal");
4310
4311   fc_tree = proto_item_add_subtree (fc_item, ett_fc_tree);
4312
4313   proto_tree_add_uint (fc_tree, hf_fc_proto_version, tvb, wlan_broken_fc?offset+1:offset, 1,
4314     FCF_PROT_VERSION (fcf));
4315
4316   proto_tree_add_uint (fc_tree, hf_fc_frame_type, tvb, wlan_broken_fc?offset+1:offset, 1,
4317     FCF_FRAME_TYPE (fcf));
4318
4319   proto_tree_add_uint (fc_tree, hf_fc_frame_subtype, tvb, wlan_broken_fc?offset+1:offset, 1,
4320     FCF_FRAME_SUBTYPE (fcf));
4321
4322   flag_item = proto_tree_add_uint_format (fc_tree, hf_fc_flags, tvb,
4323     wlan_broken_fc?offset:offset+1, 1,
4324     flags, "Flags: 0x%X", flags);
4325
4326   flag_tree = proto_item_add_subtree (flag_item, ett_proto_flags);
4327   proto_tree_add_uint (flag_tree, hf_fc_data_ds, tvb, wlan_broken_fc?offset:offset+1, 1,
4328     FLAGS_DS_STATUS (flags));
4329   hidden_item = proto_tree_add_boolean (flag_tree, hf_fc_to_ds, tvb, offset+1, 1, flags);
4330   PROTO_ITEM_SET_HIDDEN(hidden_item);
4331   hidden_item = proto_tree_add_boolean (flag_tree, hf_fc_from_ds, tvb, offset+1, 1, flags);
4332   PROTO_ITEM_SET_HIDDEN(hidden_item);
4333   proto_tree_add_boolean (flag_tree, hf_fc_more_frag, tvb, wlan_broken_fc?offset:offset+1, 1,
4334     flags);
4335   proto_tree_add_boolean (flag_tree, hf_fc_retry, tvb, wlan_broken_fc?offset:offset+1, 1,
4336     flags);
4337   proto_tree_add_boolean (flag_tree, hf_fc_pwr_mgt, tvb, wlan_broken_fc?offset:offset+1, 1,
4338     flags);
4339   proto_tree_add_boolean (flag_tree, hf_fc_more_data, tvb, wlan_broken_fc?offset:offset+1, 1,
4340     flags);
4341   proto_tree_add_boolean (flag_tree, hf_fc_protected, tvb, wlan_broken_fc?offset:offset+1, 1,
4342     flags);
4343   proto_tree_add_boolean (flag_tree, hf_fc_order, tvb, wlan_broken_fc?offset:offset+1, 1,
4344     flags);
4345 }
4346
4347 static void
4348 dissect_vendor_ie_ht(proto_item * item, proto_tree * tree, tvbuff_t * tag_tvb)
4349 {
4350   gint tag_len = tvb_length(tag_tvb);
4351   gchar out_buff[SHORT_STR];
4352
4353   g_snprintf(out_buff, SHORT_STR, "802.11n (Pre) OUI");
4354   proto_tree_add_string(tree, tag_interpretation, tag_tvb, 0, 3, out_buff);
4355   /* 802.11n OUI  Information Element */
4356   if (4 <= tag_len && !tvb_memeql(tag_tvb, 0, PRE_11N_OUI"\x33", 4)) {
4357     g_snprintf(out_buff, SHORT_STR, "802.11n (Pre) HT information");
4358     proto_tree_add_string(tree, tag_interpretation, tag_tvb, 3, 1, out_buff);
4359
4360     dissect_ht_capability_ie(tree, tag_tvb, 4, tag_len - 4, TRUE);
4361     proto_item_append_text(item, ": HT Capabilities (802.11n D1.10)");
4362   }
4363   else {
4364     if (4 <= tag_len && !tvb_memeql(tag_tvb, 0, PRE_11N_OUI"\x34", 4)) {
4365       g_snprintf(out_buff, SHORT_STR, "HT additional information (802.11n D1.00)");
4366       proto_tree_add_string(tree, tag_interpretation, tag_tvb, 3, 1, out_buff);
4367
4368       dissect_ht_info_ie_1_0(tree, tag_tvb, 4, tag_len - 4);
4369       proto_item_append_text(item, ": HT Additional Capabilities (802.11n D1.00)");
4370     }
4371     else {
4372         g_snprintf(out_buff, SHORT_STR, "Unknown type");
4373         proto_tree_add_string(tree, tag_interpretation, tag_tvb, 3, 1, out_buff);
4374         proto_item_append_text(item, ": 802.11n (pre) Unknown type");
4375         proto_tree_add_string(tree, tag_interpretation, tag_tvb, 4,
4376                   tag_len - 4, "Not interpreted");
4377     }
4378   }
4379 }
4380
4381
4382 /* ************************************************************************* */
4383 /*           Dissect and add tagged (optional) fields to proto tree          */
4384 /* ************************************************************************* */
4385
4386 static const value_string tag_num_vals[] = {
4387   { TAG_SSID,                 "SSID parameter set" },
4388   { TAG_SUPP_RATES,           "Supported Rates" },
4389   { TAG_FH_PARAMETER,         "FH Parameter set" },
4390   { TAG_DS_PARAMETER,         "DS Parameter set" },
4391   { TAG_CF_PARAMETER,         "CF Parameter set" },
4392   { TAG_TIM,                  "Traffic Indication Map (TIM)" },
4393   { TAG_IBSS_PARAMETER,       "IBSS Parameter set" },
4394   { TAG_COUNTRY_INFO,         "Country Information" },
4395   { TAG_FH_HOPPING_PARAMETER, "Hopping Pattern Parameters" },
4396   { TAG_CHALLENGE_TEXT,       "Challenge text" },
4397   { TAG_ERP_INFO,             "ERP Information" },
4398   { TAG_ERP_INFO_OLD,         "ERP Information" },
4399   { TAG_RSN_IE,               "RSN Information" },
4400   { TAG_EXT_SUPP_RATES,       "Extended Supported Rates" },
4401   { TAG_CISCO_UNKNOWN_1,      "Cisco Unknown 1 + Device Name" },
4402   { TAG_CISCO_UNKNOWN_2,      "Cisco Unknown 2" },
4403   { TAG_CISCO_UNKNOWN_3,      "Cisco Unknown 3" },
4404   { TAG_VENDOR_SPECIFIC_IE,   "Vendor Specific" },
4405   { TAG_SYMBOL_PROPRIETARY,   "Symbol Proprietary"},
4406   { TAG_AGERE_PROPRIETARY,    "Agere Proprietary"},
4407   { TAG_REQUEST,              "Request"},
4408   { TAG_QBSS_LOAD,            "QBSS Load Element"},
4409   { TAG_EDCA_PARAM_SET,       "EDCA Parameter Set"},
4410   { TAG_TSPEC,                "Traffic Specification"},
4411   { TAG_TCLAS,                "Traffic Classification"},
4412   { TAG_SCHEDULE,             "Schedule"},
4413   { TAG_TS_DELAY,             "TS Delay"},
4414   { TAG_TCLAS_PROCESS,        "TCLAS Processing"},
4415   { TAG_HT_CAPABILITY,        "HT Capabilities (802.11n D1.10)"},
4416   { TAG_NEIGHBOR_REPORT,      "Neighbor Report"},
4417   { TAG_HT_INFO,              "HT Information (802.11n D1.10)"},
4418   { TAG_SECONDARY_CHANNEL_OFFSET, "Secondary Channel Offset (802.11n D1.10)"},
4419   { TAG_WSIE,                     "Wave Service Information"}, /* www.aradasystems.com */
4420   { TAG_20_40_BSS_CO_EX,          "20/40 BSS Coexistence"},
4421   { TAG_20_40_BSS_INTOL_CH_REP,   "20/40 BSS Intolerant Channel Report"},   /* IEEE P802.11n/D6.0 */
4422   { TAG_OVERLAP_BSS_SCAN_PAR,     "Overlapping BSS Scan Parameters"},       /* IEEE P802.11n/D6.0 */
4423   { TAG_QOS_CAPABILITY,           "QoS Capability"},
4424   { TAG_POWER_CONSTRAINT,         "Power Constraint"},
4425   { TAG_POWER_CAPABILITY,         "Power Capability"},
4426   { TAG_TPC_REQUEST,              "TPC Request"},
4427   { TAG_TPC_REPORT,               "TPC Report"},
4428   { TAG_SUPPORTED_CHANNELS,       "Supported Channels"},
4429   { TAG_CHANNEL_SWITCH_ANN,       "Channel Switch Announcement"},
4430   { TAG_MEASURE_REQ,              "Measurement Request"},
4431   { TAG_MEASURE_REP,              "Measurement Report"},
4432   { TAG_QUIET,                    "Quiet"},
4433   { TAG_IBSS_DFS,                 "IBSS DFS"},
4434   { TAG_EXTENDED_CAPABILITIES,    "Extended Capabilities"},
4435   #if 0 /*Not yet assigned tag numbers by ANA */
4436   { TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT, "Extended Channel Switch Announcement"},
4437   { TAG_SUPPORTED_REGULATORY_CLASSES, "Supported Regulatory Classes"},
4438   #endif
4439   { 0,                        NULL }
4440 };
4441
4442 static const value_string environment_vals[] = {
4443   { 0x20, "Any" },
4444   { 0x4f, "Outdoor" },
4445   { 0x49, "Indoor" },
4446   { 0,    NULL }
4447 };
4448
4449 static int beacon_padding = 0; /* beacon padding bug */
4450 static int
4451 add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int offset)
4452 {
4453   guint32 oui;
4454   tvbuff_t *tag_tvb;
4455   const guint8 *tag_data_ptr;
4456   guint32 tag_no, tag_len;
4457   unsigned int i;
4458   int n, ret;
4459   char out_buff[SHORT_STR];
4460   char print_buff[SHORT_STR];
4461   proto_tree * orig_tree=tree;
4462   proto_item *ti, *en;
4463   guint8 tag_len_len; /* The length of the length parameter in bytes*/
4464
4465   tag_no = tvb_get_guint8(tvb, offset);
4466   if(tag_no == TAG_WSIE){
4467           tag_len_len = 2;
4468           tag_len = tvb_get_letohl(tvb, offset + 1);
4469   }else{
4470           tag_len_len = 1;
4471           tag_len = tvb_get_guint8(tvb, offset + 1);
4472   }
4473
4474   ti=proto_tree_add_text(orig_tree,tvb,offset,tag_len+1+tag_len_len,"%s",
4475                          val_to_str(tag_no, tag_num_vals,
4476                          (tag_no >= 17 && tag_no <= 31) ?
4477                          "Reserved for challenge text" : "Reserved tag number" ));
4478   tree=proto_item_add_subtree(ti,ett_80211_mgt_ie);
4479
4480   proto_tree_add_uint_format (tree, tag_number, tvb, offset, 1, tag_no,
4481             "Tag Number: %u (%s)",
4482             tag_no,
4483             val_to_str(tag_no, tag_num_vals,
4484                        (tag_no >= 17 && tag_no <= 31) ?
4485                        "Reserved for challenge text" :
4486                        "Reserved tag number"));
4487   proto_tree_add_uint (tree, (tag_no==TAG_TIM ? tim_length : tag_length), tvb, offset + 1, tag_len_len, tag_len);
4488
4489   switch (tag_no)
4490   {
4491
4492     case TAG_SSID:
4493       if(beacon_padding == 0) /* padding bug */
4494       {
4495         guint8 *ssid; /* The SSID may consist of arbitrary bytes */
4496
4497         ssid = tvb_get_ephemeral_string(tvb, offset + 2, tag_len);
4498 #ifdef HAVE_AIRPDCAP
4499         AirPDcapSetLastSSID(&airpdcap_ctx, (CHAR *) ssid, tag_len);
4500 #endif
4501         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4502                                tag_len, (char *) ssid);
4503         if (check_col (pinfo->cinfo, COL_INFO)) {
4504           if (tag_len > 0) {
4505             col_append_fstr(pinfo->cinfo, COL_INFO, ", SSID=\"%s\"",
4506                             format_text(ssid, tag_len));
4507           } else {
4508             col_append_str(pinfo->cinfo, COL_INFO, ", SSID=Broadcast");
4509           }
4510         }
4511         if (tag_len > 0) {
4512           proto_item_append_text(ti, ": \"%s\"",
4513                                  format_text(ssid, tag_len));
4514           memcpy(wlan_stats.ssid, ssid, MAX_SSID_LEN);
4515           wlan_stats.ssid_len = tag_len;
4516         } else {
4517           proto_item_append_text(ti, ": Broadcast");
4518         }
4519         en = proto_tree_add_string_format (tree, hf_tagged_ssid, tvb, offset + 2,
4520                                            tag_len, format_text(ssid, tag_len), 
4521                                            "SSID: %s", format_text(ssid, tag_len));
4522         PROTO_ITEM_SET_HIDDEN (en);
4523         beacon_padding++; /* padding bug */
4524       }
4525       break;
4526
4527     case TAG_SUPP_RATES:
4528     case TAG_EXT_SUPP_RATES:
4529       if (tag_len < 1)
4530       {
4531         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4532             "Tag length %u too short, must be greater than 0", tag_len);
4533         break;
4534       }
4535
4536       tag_data_ptr = tvb_get_ptr (tvb, offset + 2, tag_len);
4537       for (i = 0, n = 0; i < tag_len && n < SHORT_STR; i++) {
4538         if (tag_data_ptr[i] == 0xFF){
4539           proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2 + i,
4540                1, "BSS requires support for mandatory features of HT PHY (IEEE 802.11 - Clause 20)");
4541         } else {
4542           ret = g_snprintf (print_buff + n, SHORT_STR - n, "%2.1f%s ",
4543                           (tag_data_ptr[i] & 0x7F) * 0.5,
4544                           (tag_data_ptr[i] & 0x80) ? "(B)" : "");
4545           if (ret == -1 || ret >= SHORT_STR - n) {
4546             /* Some versions of snprintf return -1 if they'd truncate
4547                the output. Others return <buf_size> or greater.  */
4548             break;
4549           }
4550           n += ret;
4551         }
4552       }
4553       g_snprintf (out_buff, SHORT_STR, "Supported rates: %s [Mbit/sec]", print_buff);
4554       out_buff[SHORT_STR-1] = '\0';
4555       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4556            tag_len, out_buff);
4557       proto_item_append_text(ti, ": %s", print_buff);
4558       break;
4559
4560     case TAG_FH_PARAMETER:
4561       if (tag_len < 5)
4562       {
4563         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 5",
4564                              tag_len);
4565         break;
4566       }
4567       g_snprintf (out_buff, SHORT_STR,
4568           "Dwell time 0x%04X, Hop Set %2d, Hop Pattern %2d, Hop Index %2d",
4569           tvb_get_letohs(tvb, offset + 2),
4570           tvb_get_guint8(tvb, offset + 4),
4571           tvb_get_guint8(tvb, offset + 5),
4572           tvb_get_guint8(tvb, offset + 6));
4573       out_buff[SHORT_STR-1] = '\0';
4574       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4575                              tag_len, out_buff);
4576       break;
4577
4578     case TAG_DS_PARAMETER:
4579       if (tag_len < 1)
4580       {
4581         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 1",
4582                              tag_len);
4583         break;
4584       }
4585       g_snprintf (out_buff, SHORT_STR, "Current Channel: %u",
4586                 tvb_get_guint8(tvb, offset + 2));
4587       out_buff[SHORT_STR-1] = '\0';
4588       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4589                              tag_len, out_buff);
4590       proto_item_append_text(ti, ": %s", out_buff);
4591       wlan_stats.channel = tvb_get_guint8(tvb, offset + 2);
4592       break;
4593
4594     case TAG_CF_PARAMETER:
4595       if (tag_len < 6)
4596       {
4597         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 6",
4598                              tag_len);
4599         break;
4600       }
4601       g_snprintf (out_buff, SHORT_STR, "CFP count: %u",
4602                 tvb_get_guint8(tvb, offset + 2));
4603       out_buff[SHORT_STR-1] = '\0';
4604       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2,
4605                                    1, out_buff, "%s", out_buff);
4606       g_snprintf (out_buff, SHORT_STR, "CFP period: %u",
4607                 tvb_get_guint8(tvb, offset + 3));
4608       out_buff[SHORT_STR-1] = '\0';
4609       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 3,
4610                                    1, out_buff, "%s", out_buff);
4611       g_snprintf (out_buff, SHORT_STR, "CFP max duration: %u",
4612                 tvb_get_letohs(tvb, offset + 4));
4613       out_buff[SHORT_STR-1] = '\0';
4614       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 4,
4615                                    2, out_buff, "%s", out_buff);
4616       g_snprintf (out_buff, SHORT_STR, "CFP Remaining: %u",
4617                 tvb_get_letohs(tvb, offset + 6));
4618       out_buff[SHORT_STR-1] = '\0';
4619       proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 6,
4620                                    2, out_buff, "%s", out_buff);
4621       proto_item_append_text(ti, ": CFP count %u, CFP period %u, CFP max duration %u, "
4622                              "CFP Remaining %u",
4623                              tvb_get_guint8(tvb, offset + 2),
4624                              tvb_get_guint8(tvb, offset + 3),
4625                              tvb_get_letohs(tvb, offset + 4),
4626                              tvb_get_letohs(tvb, offset + 6));
4627       break;
4628
4629     case TAG_TIM:
4630       if (tag_len < 4)
4631       {
4632         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 4",
4633                              tag_len);
4634         break;
4635       }
4636       {
4637         guint8 bmapctl;
4638         guint8 bmapoff;
4639         guint8 bmaplen;
4640         const guint8* bmap;
4641
4642         proto_tree_add_item(tree, tim_dtim_count, tvb,
4643                             offset + 2, 1, TRUE);
4644         proto_tree_add_item(tree, tim_dtim_period, tvb,
4645                             offset + 3, 1, TRUE);
4646         proto_item_append_text(ti, ": DTIM %u of %u bitmap",
4647                                tvb_get_guint8(tvb, offset + 2),
4648                                tvb_get_guint8(tvb, offset + 3));
4649
4650         bmapctl = tvb_get_guint8(tvb, offset + 4);
4651         bmapoff = bmapctl>>1;
4652         proto_tree_add_uint_format(tree, tim_bmapctl, tvb,
4653                             offset + 4, 1, bmapctl,
4654                             "Bitmap Control: 0x%02X (mcast:%u, bitmap offset %u)",
4655                             bmapctl, bmapctl&1, bmapoff);
4656
4657         bmaplen = tag_len - 3;
4658         bmap = tvb_get_ptr(tvb, offset + 5, bmaplen);
4659         if (bmaplen==1 && 0==bmap[0] && !(bmapctl&1)) {
4660           proto_item_append_text(ti, " empty");
4661         } else {
4662           if (bmapctl&1) {
4663             proto_item_append_text(ti, " mcast");
4664           }
4665         }
4666         if (bmaplen>1 || bmap[0]) {
4667           int len=g_snprintf (out_buff, SHORT_STR,
4668                             "Bitmap: traffic for AID's:");
4669           int i=0;
4670           for (i=0;i<bmaplen*8;i++) {
4671             if (bmap[i/8] & (1<<(i%8))) {
4672               int aid=i+2*bmapoff*8;
4673               len+=g_snprintf (out_buff+len, SHORT_STR-len," %u", aid);
4674               proto_item_append_text(ti, " %u", aid);
4675               if (len>=SHORT_STR) {
4676                 break;
4677               }
4678             }
4679           }
4680           out_buff[SHORT_STR-1] = '\0';
4681           proto_tree_add_string_format (tree, tag_interpretation, tvb, offset + 5,
4682                bmaplen, out_buff, "%s", out_buff);
4683         }
4684       }
4685       break;
4686
4687     case TAG_IBSS_PARAMETER:
4688       if (tag_len < 2)
4689       {
4690         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 2",
4691                              tag_len);
4692         break;
4693       }
4694       g_snprintf (out_buff, SHORT_STR, "ATIM window 0x%X",
4695                 tvb_get_letohs(tvb, offset + 2));
4696       out_buff[SHORT_STR-1] = '\0';
4697       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4698            tag_len, out_buff);
4699       proto_item_append_text(ti, ": %s", out_buff);
4700       break;
4701
4702     case TAG_COUNTRY_INFO: /* IEEE 802.11d-2001 and IEEE 802.11j-2004 */
4703       {
4704         guint8 ccode[2+1];
4705
4706         if (tag_len < 3)
4707         {
4708           proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 3",
4709                                tag_len);
4710           break;
4711         }
4712         tvb_memcpy(tvb, ccode, offset + 2, 2);
4713         ccode[2] = '\0';
4714         g_snprintf (out_buff, SHORT_STR, "Country Code: %s, %s Environment",
4715                  format_text(ccode, 2),
4716                  val_to_str(tvb_get_guint8(tvb, offset + 4), environment_vals,"Unknown (0x%02x)"));
4717         out_buff[SHORT_STR-1] = '\0';
4718         proto_item_append_text(ti, ": %s", out_buff);
4719         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,3, out_buff);
4720
4721         for (i = 3; (i + 3) <= tag_len; i += 3)
4722         {
4723           guint8 val1, val2, val3;
4724           val1 = tvb_get_guint8(tvb, offset + 2 + i);
4725           val2 = tvb_get_guint8(tvb, offset + 3 + i);
4726           val3 = tvb_get_guint8(tvb, offset + 4 + i);
4727
4728           if (val1 <= 200) {  /* 802.11d */
4729             proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2+i,3, out_buff,
4730                                        "  Start Channel: %u, Channels: %u, Max TX Power: %d dBm",
4731                                        val1, val2, (gint) val3);
4732           } else {  /* 802.11j */
4733             proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2+i,3, out_buff,
4734                                        "  Reg Extension Id: %u, Regulatory Class: %u, Coverage Class: %u",
4735                                        val1, val2, val3);
4736           }
4737         }
4738       }
4739       break;
4740
4741     case TAG_QBSS_LOAD:
4742       if (tag_len < 4 || tag_len >5)
4743       {
4744         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Wrong QBSS Tag Length %u", tag_len);
4745         break;
4746       }
4747
4748       if (tag_len == 4)
4749       {
4750         /* QBSS Version 1 */
4751         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 1,
4752           tag_len, "Cisco QBSS Version 1 - non CCA");
4753
4754         /* Extract Values */
4755         proto_tree_add_uint (tree, hf_qbss_version, tvb, offset + 2, tag_len, 1);
4756         proto_tree_add_item (tree, hf_qbss_scount, tvb, offset + 2, 2, TRUE);
4757         proto_tree_add_item (tree, hf_qbss_cu, tvb, offset + 4, 1, FALSE);
4758         proto_tree_add_item (tree, hf_qbss_adc, tvb, offset + 5, 1, FALSE);
4759       }
4760       else if (tag_len == 5)
4761       {
4762          /* QBSS Version 2 */
4763          proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4764            tag_len, "802.11e CCA Version");
4765
4766          /* Extract Values */
4767          proto_tree_add_uint (tree, hf_qbss_version, tvb, offset + 2, tag_len, 2);
4768          proto_tree_add_item (tree, hf_qbss_scount, tvb, offset + 2, 2, TRUE);
4769          proto_tree_add_item (tree, hf_qbss_cu, tvb, offset + 4, 1, FALSE);
4770          proto_tree_add_item (tree, hf_qbss_adc, tvb, offset + 5, 2, TRUE);
4771       }
4772       break;
4773
4774     case TAG_FH_HOPPING_PARAMETER:
4775       if (tag_len < 2)
4776       {
4777         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 2",
4778                              tag_len);
4779         break;
4780       }
4781       g_snprintf (out_buff, SHORT_STR, "Prime Radix: %u, Number of Channels: %u",
4782                 tvb_get_guint8(tvb, offset + 2),
4783                 tvb_get_guint8(tvb, offset + 3));
4784       out_buff[SHORT_STR-1] = '\0';
4785       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, tag_len, out_buff);
4786       proto_item_append_text(ti, ": %s", out_buff);
4787       break;
4788
4789     case TAG_TSPEC:
4790       if (tag_len != 55)
4791       {
4792         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4793             "TSPEC tag length %u != 55", tag_len);
4794         break;
4795       }
4796       add_fixed_field(tree, tvb, offset + 2, FIELD_QOS_TS_INFO);
4797       proto_tree_add_item(tree, tspec_nor_msdu, tvb, offset + 5, 2, TRUE);
4798       proto_tree_add_item(tree, tspec_max_msdu, tvb, offset + 7, 2, TRUE);
4799       proto_tree_add_item(tree, tspec_min_srv, tvb, offset + 9, 4, TRUE);
4800       proto_tree_add_item(tree, tspec_max_srv, tvb, offset + 13, 4, TRUE);
4801       proto_tree_add_item(tree, tspec_inact_int, tvb, offset + 17, 4, TRUE);
4802       proto_tree_add_item(tree, tspec_susp_int, tvb, offset + 21, 4, TRUE);
4803       proto_tree_add_item(tree, tspec_srv_start, tvb, offset + 25, 4, TRUE);
4804       proto_tree_add_item(tree, tspec_min_data, tvb, offset + 29, 4, TRUE);
4805       proto_tree_add_item(tree, tspec_mean_data, tvb, offset + 33, 4, TRUE);
4806       proto_tree_add_item(tree, tspec_peak_data, tvb, offset + 37, 4, TRUE);
4807       proto_tree_add_item(tree, tspec_burst_size, tvb, offset + 41, 4, TRUE);
4808       proto_tree_add_item(tree, tspec_delay_bound, tvb, offset + 45, 4, TRUE);
4809       proto_tree_add_item(tree, tspec_min_phy, tvb, offset + 49, 4, TRUE);
4810       proto_tree_add_item(tree, tspec_surplus, tvb, offset + 53, 2, TRUE);
4811       proto_tree_add_item(tree, tspec_medium, tvb, offset + 55, 2, TRUE);
4812       break;
4813
4814     case TAG_TS_DELAY:
4815       if (tag_len != 4)
4816       {
4817         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4818             "TS_DELAY tag length %u != 4", tag_len);
4819         break;
4820       }
4821       proto_tree_add_item(tree, ts_delay, tvb, offset + 2, 4, TRUE);
4822       break;
4823
4824     case TAG_TCLAS:
4825       if (tag_len < 6)
4826       {
4827         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4828             "TCLAS element is too small %u", tag_len);
4829         break;
4830       }
4831       {
4832       guint8 type;
4833       guint8 version;
4834
4835       type = tvb_get_guint8(tvb, offset + 2);
4836       proto_tree_add_item(tree, hf_tsinfo_up, tvb, offset + 2, 1, TRUE);
4837       proto_tree_add_item(tree, hf_class_type, tvb, offset + 3, 1, TRUE);
4838       proto_tree_add_item(tree, hf_class_mask, tvb, offset + 4, 1, TRUE);
4839       switch (type)
4840         {
4841           case 0:
4842             proto_tree_add_item(tree, ff_src_mac_addr, tvb, offset + 5,
4843                     6, TRUE);
4844             proto_tree_add_item(tree, ff_dst_mac_addr, tvb, offset + 11,
4845                     6, TRUE);
4846             proto_tree_add_item(tree, hf_ether_type, tvb, offset + 17,
4847                     2, TRUE);
4848             break;
4849
4850           case 1:
4851             version = tvb_get_guint8(tvb, offset + 5);
4852             proto_tree_add_item(tree, cf_version, tvb, offset + 5, 1, TRUE);
4853             if (version == 4)
4854             {
4855               proto_tree_add_item(tree, cf_ipv4_src, tvb, offset + 6,
4856                 4, FALSE);
4857               proto_tree_add_item(tree, cf_ipv4_dst, tvb, offset + 10,
4858                 4, FALSE);
4859               proto_tree_add_item(tree, cf_src_port, tvb, offset + 14,
4860                 2, FALSE);
4861               proto_tree_add_item(tree, cf_dst_port, tvb, offset + 16,
4862                 2, FALSE);
4863               proto_tree_add_item(tree, cf_dscp, tvb, offset + 18,
4864                 1, FALSE);
4865               proto_tree_add_item(tree, cf_protocol, tvb, offset + 19,
4866                 1, FALSE);
4867             }
4868             else if (version == 6)
4869             {
4870               proto_tree_add_item(tree, cf_ipv6_src, tvb, offset + 6,
4871                 16, FALSE);
4872               proto_tree_add_item(tree, cf_ipv6_dst, tvb, offset + 22,
4873                 16, FALSE);
4874               proto_tree_add_item(tree, cf_src_port, tvb, offset + 38,
4875                 2, FALSE);
4876               proto_tree_add_item(tree, cf_dst_port, tvb, offset + 40,
4877                 2, FALSE);
4878               proto_tree_add_item(tree, cf_flow, tvb, offset + 42,
4879                 3, FALSE);
4880             }
4881             break;
4882
4883           case 2:
4884             proto_tree_add_item(tree, cf_tag_type, tvb, offset + 5,
4885                     2, TRUE);
4886             break;
4887
4888           default:
4889             break;
4890         }
4891       }
4892       break;
4893
4894     case TAG_TCLAS_PROCESS:
4895       if (tag_len != 1)
4896       {
4897         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4898             "TCLAS_PROCESS element length %u != 1", tag_len);
4899         break;
4900       }
4901       proto_tree_add_item(tree, hf_tclas_process, tvb, offset + 2, 1, TRUE);
4902       break;
4903
4904     case TAG_SCHEDULE:
4905       if (tag_len != 14)
4906       {
4907         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
4908             "TCLAS_PROCESS element length %u != 14", tag_len);
4909         break;
4910       }
4911       add_fixed_field(tree, tvb, offset + 2, FIELD_SCHEDULE_INFO);
4912       proto_tree_add_item(tree, hf_sched_srv_start, tvb, offset + 4, 4, TRUE);
4913       proto_tree_add_item(tree, hf_sched_srv_int, tvb, offset + 8, 4, TRUE);
4914       proto_tree_add_item(tree, hf_sched_spec_int, tvb, offset + 12, 2, TRUE);
4915       break;
4916
4917     case TAG_CHALLENGE_TEXT:
4918       g_snprintf (out_buff, SHORT_STR, "Challenge text: %s",
4919                 tvb_bytes_to_str(tvb, offset + 2, tag_len));
4920       out_buff[SHORT_STR-1] = '\0';
4921       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4922            tag_len, out_buff);
4923       break;
4924
4925     case TAG_ERP_INFO:
4926     case TAG_ERP_INFO_OLD:
4927       {
4928         guint8 erp_info;
4929
4930         if (tag_len < 1)
4931         {
4932           proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 1",
4933                                tag_len);
4934           break;
4935         }
4936         erp_info = tvb_get_guint8 (tvb, offset + 2);
4937         g_snprintf (print_buff, SHORT_STR, "%sNon-ERP STAs, %suse protection, %s preambles",
4938                   erp_info & 0x01 ? "" : "no ",
4939                   erp_info & 0x02 ? "" : "do not ",
4940                   /* 802.11g, 7.3.2.13: 1 means "one or more ... STAs
4941                    * are not short preamble capable" */
4942                   erp_info & 0x04 ? "long": "short or long");
4943         print_buff[SHORT_STR-1] = '\0';
4944         g_snprintf (out_buff, SHORT_STR,
4945                   "ERP info: 0x%x (%s)",erp_info,print_buff);
4946         out_buff[SHORT_STR-1] = '\0';
4947         proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
4948                                tag_len, out_buff);
4949         proto_item_append_text(ti, ": %s", print_buff);
4950       }
4951       break;
4952
4953     case TAG_CISCO_UNKNOWN_1:
4954       /* From WCS manual:
4955        * If Aironet IE support is enabled, the access point sends an Aironet
4956        * IE 0x85 (which contains the access point name, load, number of
4957        * associated clients, and so on) in the beacon and probe responses of
4958        * this WLAN, and the controller sends Aironet IEs 0x85 and 0x95
4959        * (which contains the management IP address of the controller and
4960        * the IP address of the access point) in the reassociation response
4961        * if it receives Aironet IE 0x85 in the reassociation request.
4962        */
4963
4964       /* The Name of the sending device starts at offset 10 and is up to
4965          15 or 16 bytes in length, \0 padded */
4966       if (tag_len < 26)
4967       {
4968         proto_tree_add_text (tree, tvb, offset + 2, tag_len, "Tag length %u too short, must be >= 26",
4969                              tag_len);
4970         break;
4971       }
4972       /* A cisco AP transmits the first 15 bytes of the AP name, probably
4973          followed by '\0' for ASCII termination */
4974       g_snprintf (out_buff, SHORT_STR, "%.16s",
4975                 tvb_format_stringzpad(tvb, offset + 12, 16));
4976       out_buff[SHORT_STR-1] = '\0';
4977       proto_tree_add_string_format (tree, tag_interpretation, tvb, offset + 2,
4978            tag_len, "", "Tag interpretation: Unknown + Name: %s #Clients: %u",
4979            out_buff,
4980            /* Total number off associated clients and repeater access points */
4981            tvb_get_guint8(tvb, offset + 28));
4982       if (check_col (pinfo->cinfo, COL_INFO)) {
4983           col_append_fstr(pinfo->cinfo, COL_INFO, ", Name=\"%s\"", out_buff);
4984       }
4985       break;
4986
4987 /* Std 802.11-2007
4988  * 7.3.2.26 Vendor Specific information element 
4989  * The
4990  * information element is in the format shown in Figure 7-75 and requires that the first 3 octets of the
4991  * information field contain the OUI of the entity that has defined the content of the particular Vendor Specific
4992  * information element. The length of the information field (n) is 3 >= n =< 255. The OUI field shall be a public
4993  * OUI assigned by the IEEE. It is 3 octets in length. The length of the vendor-specific content is n-3 octets.
4994  *
4995  *          Element ID Length OUI Vendor-specific content
4996  * Octets   1          1      3    n-3
4997  */
4998
4999     case TAG_VENDOR_SPECIFIC_IE:
5000       tvb_ensure_bytes_exist (tvb, offset + 2, tag_len);
5001       if (tag_len >= 3) {
5002         oui = tvb_get_ntoh24(tvb, offset + 2);
5003         tag_tvb = tvb_new_subset(tvb, offset + 2, tag_len, tag_len);
5004         tag_data_ptr = tvb_get_ptr(tag_tvb, 0, 3);
5005         proto_tree_add_bytes_format (tree, tag_oui, tvb, offset + 2, 3,
5006           tag_data_ptr, "Vendor: %s", get_manuf_name(tag_data_ptr));
5007         proto_item_append_text(ti, ": %s", get_manuf_name(tag_data_ptr));
5008
5009 #define WPAWME_OUI  0x0050F2
5010 #define RSNOUI_VAL  0x000FAC
5011 #define PRE11N_OUI  0x00904c
5012
5013       switch (oui) {
5014         case WPAWME_OUI:
5015           dissect_vendor_ie_wpawme(ti, tree, tag_tvb);
5016           break;
5017         case RSNOUI_VAL:
5018           dissect_vendor_ie_rsn(ti, tree, tag_tvb);
5019           break;
5020         case OUI_CISCOWL:  /* Cisco Wireless (Aironet) */
5021           dissect_vendor_ie_aironet(ti, tree, tvb, offset + 5, tag_len - 3);
5022           break;
5023         case PRE11N_OUI:
5024           dissect_vendor_ie_ht(ti, tree, tag_tvb);
5025           break;
5026         case OUI_MARVELL:
5027           dissect_vendor_ie_marvell(ti, tree, tvb, offset + 5, tag_len - 3);
5028           break;
5029         default:
5030           proto_tree_add_string (tree, tag_interpretation, tvb, offset + 5,
5031             tag_len - 3, "Not interpreted");
5032           break;
5033         }
5034
5035       }
5036       break;
5037
5038     case TAG_RSN_IE:
5039       tag_tvb = tvb_new_subset(tvb, offset + 2, tag_len, tag_len);
5040       dissect_rsn_ie(tree, tag_tvb);
5041       break;
5042
5043     case TAG_HT_CAPABILITY:
5044       dissect_ht_capability_ie(tree, tvb, offset + 2, tag_len, FALSE);
5045       break;
5046
5047     case TAG_HT_INFO:
5048       dissect_ht_info_ie_1_1(tree, tvb, offset + 2, tag_len);
5049       break;
5050     /*** Begin: Secondary Channel Offset Tag - Dustin Johnson ***/
5051     case TAG_SECONDARY_CHANNEL_OFFSET:
5052       secondary_channel_offset_ie(tree, tvb, offset + 2, tag_len);
5053       break;
5054     /*** End: Secondary Channel Offset Tag - Dustin Johnson ***/
5055
5056     /***  Begin: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
5057         case TAG_WSIE:
5058                 dissect_wsie_ie(tree, tvb, offset + 3, tag_len);
5059                 break;
5060     /***  End: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
5061
5062         /*** Begin: Power Capability Tag - Dustin Johnson ***/
5063     case TAG_POWER_CAPABILITY:
5064       {
5065         offset += 2;
5066         if (tag_len != 2)
5067         {
5068           proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5069             "Power Capability: Error: Tag length must be exactly 2 bytes long");
5070         }
5071
5072         proto_tree_add_item(tree, hf_tag_power_capability_min, tvb, offset, 1, TRUE);
5073         proto_tree_add_item(tree, hf_tag_power_capability_max, tvb, offset+1, 1, TRUE);
5074         break;
5075       }
5076     /*** End: Power Capability Tag - Dustin Johnson ***/
5077           /* 
5078            * 7.3.2.18 TPC Report element
5079            *
5080            */
5081         case TAG_TPC_REPORT:
5082                 if(tag_len !=2)
5083                 proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5084                     "TPC Report: Error: Tag length must be 2 bytes long");
5085                 /* Transmit Power field
5086                  * The field is coded as a signed integer in units of decibels relative to 1 mW
5087                  */
5088                 offset += 2;
5089                 proto_tree_add_item(tree, hf_tag_tpc_report_trsmt_pow, tvb, offset, 1, TRUE);
5090                 offset++;
5091                 /* Link Margin */
5092                 proto_tree_add_item(tree, hf_tag_tpc_report_link_mrg, tvb, offset, 1, TRUE);
5093                 offset++;
5094                 break;
5095     /*** Begin: Supported Channels Tag - Dustin Johnson ***/
5096     case TAG_SUPPORTED_CHANNELS:
5097       {
5098         proto_item *chan_item;
5099         proto_tree *chan_tree;
5100         guint8 i;
5101
5102         offset += 2;
5103         if (tag_len > 8) /* XXX Is this a sane limit? */
5104         {
5105           proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5106             "Supported Channels: Error: Tag length too long");
5107         } else if (tag_len % 2 == 1) {
5108           proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5109             "Supported Channels: Error: Tag length must be even");
5110         }
5111
5112         for (i=0; i<(tag_len/2); i++)
5113         {
5114           chan_item = proto_tree_add_uint_format(tree, hf_tag_supported_channels, tvb, offset, 2, i,
5115             "Supported Channels Set #%d", i);
5116           chan_tree = proto_item_add_subtree(chan_item , ett_tag_supported_channels);
5117           proto_tree_add_item(chan_tree, hf_tag_supported_channels_first, tvb, offset++, 1, TRUE);
5118           proto_tree_add_item(chan_tree, hf_tag_supported_channels_range, tvb, offset++, 1, TRUE);
5119         }
5120         break;
5121       }
5122     /*** End: Supported Channels Tag - Dustin Johnson ***/
5123
5124     /*** Begin: Measure Request Tag - Dustin Johnson ***/
5125     case TAG_MEASURE_REQ:
5126       if (tag_len < 3)
5127       {
5128         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5129             "Measurement Request: Error: Tag length must be at least 3 bytes long");
5130       } else {
5131         guint8 info, request_type;
5132         guint tag_offset;
5133         proto_item *parent_item;
5134         proto_tree *sub_tree;
5135
5136         offset += 2;
5137         tag_offset = offset;
5138         info = tvb_get_guint8 (tvb, offset);
5139         proto_tree_add_uint_format(tree, hf_tag_measure_request_measurement_token, tvb,
5140             offset, 1, info, "Measurement Token: 0x%02X", info);
5141
5142         info = tvb_get_guint8 (tvb, ++offset);
5143         parent_item = proto_tree_add_uint_format(tree, hf_tag_measure_request_mode, tvb,
5144             offset, 1, info, "Measurement Request Mode: 0x%02X", info);
5145         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5146         proto_tree_add_uint(sub_tree, hf_tag_measure_request_mode_reserved1, tvb, offset, 1, info);
5147         proto_tree_add_boolean(sub_tree, hf_tag_measure_request_mode_enable, tvb, offset, 1, info);
5148         proto_tree_add_boolean(sub_tree, hf_tag_measure_request_mode_request, tvb, offset, 1, info);
5149         proto_tree_add_boolean(sub_tree, hf_tag_measure_request_mode_report, tvb, offset, 1, info);
5150         proto_tree_add_uint(sub_tree, hf_tag_measure_request_mode_reserved2, tvb, offset, 1, info);
5151
5152         request_type = tvb_get_guint8 (tvb, ++offset);
5153         parent_item = proto_tree_add_uint(tree, hf_tag_measure_request_type, tvb, offset, 1, request_type);
5154         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5155
5156         offset++;
5157         switch (request_type) {
5158           case 0: /* Basic Request */
5159           case 1: /* Clear channel assessment (CCA) request */
5160           case 2: /* Receive power indication (RPI) histogram request */
5161           {
5162             guint8 channel_number;
5163             guint64 start_time;
5164             guint16 duration;
5165
5166             channel_number = tvb_get_guint8 (tvb, offset);
5167             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);
5168
5169             start_time = tvb_get_letoh64 (tvb, offset);
5170             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);
5171
5172             offset += 8;
5173             duration = tvb_get_letohs (tvb, offset);
5174             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);
5175             break;
5176           }
5177           case 3: /* Channel Load Request */
5178           case 4: /* Noise Histogram Request */
5179           {
5180             guint8 regulatory_class, channel_number;
5181             guint16 rand_interval, duration;
5182
5183             regulatory_class = tvb_get_guint8 (tvb, offset);
5184             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_regulatory_class, tvb, offset, 1, regulatory_class, "Regulatory Class: 0x%02X", regulatory_class);
5185
5186             offset++;
5187             channel_number = tvb_get_guint8 (tvb, offset);
5188             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);
5189
5190             offset++;
5191             rand_interval = tvb_get_letohs (tvb, offset);
5192             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);
5193
5194             offset += 2;
5195             duration = tvb_get_letohs (tvb, offset);
5196             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);
5197             break;
5198           }
5199           case 5: /* Beacon Request */
5200           {
5201             guint8 regulatory_class, channel_number, measurement_mode, reporting_condition, threshold_offset;
5202             guint16 rand_interval, duration;
5203             const guint8 *bssid = NULL;
5204
5205             regulatory_class = tvb_get_guint8 (tvb, offset);
5206             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_regulatory_class, tvb, offset, 1, regulatory_class, "Regulatory Class: 0x%02X", regulatory_class);
5207
5208             offset++;
5209             channel_number = tvb_get_guint8 (tvb, offset);
5210             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);
5211
5212             offset++;
5213             rand_interval = tvb_get_letohs (tvb, offset);
5214             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);
5215
5216             offset += 2;
5217             duration = tvb_get_letohs (tvb, offset);
5218             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);
5219
5220             offset+=2;
5221             measurement_mode = tvb_get_guint8 (tvb, offset);
5222             proto_tree_add_uint(sub_tree, hf_tag_measure_request_measurement_mode, tvb, offset, 1, measurement_mode);
5223
5224             offset++;
5225             bssid = tvb_get_ptr (tvb, offset, 6);
5226             proto_tree_add_ether(sub_tree, hf_tag_measure_request_bssid, tvb, offset, 6, bssid);
5227
5228             offset+=6;
5229             reporting_condition = tvb_get_guint8 (tvb, offset);
5230             proto_tree_add_uint(sub_tree, hf_tag_measure_request_reporting_condition, tvb, offset, 1, reporting_condition);
5231
5232             offset++;
5233             threshold_offset = tvb_get_guint8 (tvb, offset);
5234             if (reporting_condition == 0) {
5235               /* XXX ? */
5236             } else if (reporting_condition >= 1 && reporting_condition <= 4){ /* Unsigned dBm */
5237               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);
5238             } else if (reporting_condition == 5 || reporting_condition == 6 || reporting_condition == 9){ /* Signed dBm */
5239               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);
5240             } else if (reporting_condition == 7 || reporting_condition == 8 || reporting_condition == 10){ /* Signed dB */
5241               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);
5242             } else {
5243               /* Not Defined */
5244             }
5245             offset++;
5246
5247             add_tagged_field (pinfo, sub_tree, tvb, offset);
5248
5249             break;
5250           }
5251           case 6: /* Frame Request */
5252           {
5253             guint8 regulatory_class, channel_number;
5254             guint16 rand_interval, duration;
5255             const guint8 *mac = NULL;
5256
5257             regulatory_class = tvb_get_guint8 (tvb, offset);
5258             proto_tree_add_uint_format(sub_tree, hf_tag_measure_request_regulatory_class, tvb, offset, 1, regulatory_class, "Regulatory Class: 0x%02X", regulatory_class);
5259
5260             offset++;
5261             channel_number = tvb_get_guint8 (tvb, offset);
5262             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);
5263
5264             offset++;
5265             rand_interval = tvb_get_letohs (tvb, offset);
5266             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);
5267
5268             offset += 2;
5269             duration = tvb_get_letohs (tvb, offset);
5270             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);
5271
5272             offset += 2;
5273             if (tag_len >= ((offset-tag_offset)+6)){
5274               mac = tvb_get_ptr (tvb, offset, 6);
5275               proto_tree_add_ether(sub_tree, hf_tag_measure_request_bssid, tvb, offset, 6, mac);
5276             }
5277             break;
5278           }
5279           case 7: /* BSTA Statistics Request */
5280           {
5281             guint8 group_id;
5282             guint16 rand_interval, duration;
5283
5284             offset++;
5285             rand_interval = tvb_get_letohs (tvb, offset);
5286             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);
5287
5288             offset += 2;
5289             duration = tvb_get_letohs (tvb, offset);
5290             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);
5291
5292             offset++;
5293             group_id = tvb_get_guint8 (tvb, offset);
5294             proto_tree_add_uint(sub_tree, hf_tag_measure_request_group_id, tvb, offset, 1, group_id);
5295             break;
5296           }
5297           case 8: /* Location Configuration Indication (LCI) Request */
5298             /* TODO */
5299           case 9: /* Transmit Stream Measurement Request */
5300             /* TODO */
5301           case 255: /* Measurement Pause Request*/
5302             /* TODO */
5303           default: /* unknown */
5304             proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Undissected Data");
5305             break;
5306         }
5307       }
5308
5309       break;
5310     /* End: Measure Request Tag - Dustin Johnson */
5311     /* Begin: Measure Report Tag - Dustin Johnson */
5312         /* 7.3.2.22 Measurement Report element
5313          * The Length field is variable and depends on the length of the 
5314          * Measurement Report field. The minimum value of the Length field is 3.
5315          */
5316     case TAG_MEASURE_REP:
5317       if (tag_len < 3)
5318       {
5319         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5320             "Measurement Report: Error: Tag length must be at least 3 bytes long");
5321       } else {
5322         guint8 info, report_type, channel_number;
5323         guint16 duration;
5324         guint64 start_time;
5325         proto_item *parent_item;
5326         proto_tree *sub_tree;
5327         guint tag_offset;
5328
5329         offset += 2;
5330         tag_offset = offset;
5331         info = tvb_get_guint8 (tvb, offset);
5332         proto_tree_add_uint_format(tree, hf_tag_measure_report_measurement_token, tvb,
5333             offset, 1, info, "Measurement Token: 0x%02X", info);
5334
5335         offset++;
5336         info = tvb_get_guint8 (tvb, offset);
5337         parent_item = proto_tree_add_uint_format(tree, hf_tag_measure_report_mode, tvb,
5338             offset, 1, info, "Measurement Report Mode: 0x%02X", info);
5339         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5340         proto_tree_add_boolean(sub_tree, hf_tag_measure_report_mode_late, tvb, offset, 1, info);
5341         proto_tree_add_boolean(sub_tree, hf_tag_measure_report_mode_incapable, tvb, offset, 1, info);
5342         proto_tree_add_boolean(sub_tree, hf_tag_measure_report_mode_refused, tvb, offset, 1, info);
5343         proto_tree_add_uint(sub_tree, hf_tag_measure_report_mode_reserved, tvb, offset, 1, info);
5344
5345         offset++;
5346         report_type = tvb_get_guint8 (tvb, offset);
5347         parent_item = proto_tree_add_uint(tree, hf_tag_measure_report_type, tvb, offset, 1, report_type);
5348         sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5349         offset++;
5350
5351         if (tag_len == 3)
5352             break;
5353         switch (report_type) {
5354           case 0: /* Basic Report */
5355           {
5356             proto_tree *sub_tree_map_field;
5357
5358             channel_number = tvb_get_guint8 (tvb, offset);
5359             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);
5360
5361             offset++;
5362             start_time = tvb_get_letoh64 (tvb, offset);
5363             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);
5364
5365             offset += 8;
5366             duration = tvb_get_letohs (tvb, offset);
5367             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);
5368
5369             offset+=2;
5370             info = tvb_get_guint8 (tvb, offset);
5371             parent_item = proto_tree_add_uint_format(tree, hf_tag_measure_basic_map_field, tvb,
5372                               offset, 1, info, "Map Field: 0x%02X", info);
5373             sub_tree_map_field = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5374             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_bss, tvb, offset, 1, info);
5375             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_odfm, tvb, offset, 1, info);
5376             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_unident_signal, tvb, offset, 1, info);
5377             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_radar, tvb, offset, 1, info);
5378             proto_tree_add_boolean(sub_tree_map_field, hf_tag_measure_map_field_unmeasured, tvb, offset, 1, info);
5379             proto_tree_add_uint(sub_tree_map_field, hf_tag_measure_map_field_reserved, tvb, offset, 1, info);
5380             break;
5381           }
5382           case 1: /* Clear channel assessment (CCA) report */
5383             channel_number = tvb_get_guint8 (tvb, offset);
5384             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);
5385
5386             offset++;
5387             start_time = tvb_get_letoh64 (tvb, offset);
5388             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);
5389
5390             offset += 8;
5391             duration = tvb_get_letohs (tvb, offset);
5392             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);
5393
5394             offset+=2;
5395             info = tvb_get_guint8 (tvb, offset);
5396             proto_tree_add_uint_format(sub_tree, hf_tag_measure_cca_busy_fraction, tvb, offset, 1, info, "CCA Busy Fraction: 0x%02X", info);
5397             break;
5398           case 2: /* Receive power indication (RPI) histogram report */
5399             channel_number = tvb_get_guint8 (tvb, offset);
5400             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);
5401
5402             offset++;
5403             start_time = tvb_get_letoh64 (tvb, offset);
5404             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);
5405
5406             offset += 8;
5407             duration = tvb_get_letohs (tvb, offset);
5408             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);
5409
5410             offset+=2;
5411             parent_item = proto_tree_add_string(sub_tree, hf_tag_measure_rpi_histogram_report, tvb,
5412                               offset, 8, "RPI Histogram Report");
5413             sub_tree = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5414             info = tvb_get_guint8 (tvb, offset);
5415             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_0, tvb, offset, 1, info, "RPI 0 Density: 0x%02X", info);
5416             info = tvb_get_guint8 (tvb, ++offset);
5417             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_1, tvb, offset, 1, info, "RPI 1 Density: 0x%02X", info);
5418             info = tvb_get_guint8 (tvb, ++offset);
5419             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_2, tvb, offset, 1, info, "RPI 2 Density: 0x%02X", info);
5420             info = tvb_get_guint8 (tvb, ++offset);
5421             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_3, tvb, offset, 1, info, "RPI 3 Density: 0x%02X", info);
5422             info = tvb_get_guint8 (tvb, ++offset);
5423             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_4, tvb, offset, 1, info, "RPI 4 Density: 0x%02X", info);
5424             info = tvb_get_guint8 (tvb, ++offset);
5425             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_5, tvb, offset, 1, info, "RPI 5 Density: 0x%02X", info);
5426             info = tvb_get_guint8 (tvb, ++offset);
5427             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_6, tvb, offset, 1, info, "RPI 6 Density: 0x%02X", info);
5428             info = tvb_get_guint8 (tvb, ++offset);
5429             proto_tree_add_uint_format(sub_tree, hf_tag_measure_rpi_histogram_report_7, tvb, offset, 1, info, "RPI 7 Density: 0x%02X", info);
5430             break;
5431           case 3: /* Channel Load Report */
5432           {
5433             guint8 regulatory_class, channel_load;
5434
5435             regulatory_class = tvb_get_guint8 (tvb, offset);
5436             proto_tree_add_uint(sub_tree, hf_tag_measure_report_regulatory_class, tvb, offset, 1, regulatory_class);
5437
5438             offset++;
5439             channel_number = tvb_get_guint8 (tvb, offset);
5440             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);
5441
5442             offset++;
5443             start_time = tvb_get_letoh64 (tvb, offset);
5444             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);
5445
5446             offset += 8;
5447             duration = tvb_get_letohs (tvb, offset);
5448             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);
5449
5450             offset+=2;
5451             channel_load = tvb_get_guint8 (tvb, offset);
5452             proto_tree_add_uint(sub_tree, hf_tag_measure_report_channel_load, tvb, offset, 1, channel_load);
5453             break;
5454           }
5455           case 4: /* Noise Histogram Report */
5456             /* TODO */
5457             proto_tree_add_text (sub_tree, tvb, offset, tag_len - (offset - tag_offset), "Undissected Data");
5458             break;
5459           case 5: /* Beacon Report */
5460           {
5461             guint8 regulatory_class, reported_frame_info, rcpi, rsni, ant_id;
5462             guint32 parent_tsf;
5463             proto_tree *sub_tree_frame_info;
5464             const guint8 *bssid = NULL;
5465
5466             regulatory_class = tvb_get_guint8 (tvb, offset);
5467             proto_tree_add_uint(sub_tree, hf_tag_measure_report_regulatory_class, tvb, offset, 1, regulatory_class);
5468
5469             offset++;
5470             channel_number = tvb_get_guint8 (tvb, offset);
5471             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);
5472
5473             offset++;
5474             start_time = tvb_get_letoh64 (tvb, offset);
5475             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);
5476
5477             offset += 8;
5478             duration = tvb_get_letohs (tvb, offset);
5479             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);
5480
5481             offset+=2;
5482             reported_frame_info = tvb_get_guint8 (tvb, offset);
5483             parent_item = proto_tree_add_uint(sub_tree, hf_tag_measure_report_frame_info, tvb, offset, 1, reported_frame_info);
5484             sub_tree_frame_info = proto_item_add_subtree(parent_item, ett_tag_measure_request_tree);
5485             proto_tree_add_uint(sub_tree_frame_info, hf_tag_measure_report_frame_info_phy_type, tvb, offset, 1, reported_frame_info);
5486             proto_tree_add_uint(sub_tree_frame_info, hf_tag_measure_report_frame_info_frame_type, tvb, offset, 1, reported_frame_info);
5487
5488             offset++;
5489             rcpi = tvb_get_guint8 (tvb, offset);
5490             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);
5491
5492             offset++;
5493             rsni = tvb_get_guint8 (tvb, offset);
5494             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);
5495
5496             offset++;
5497             bssid = tvb_get_ptr (tvb, offset, 6);
5498             proto_tree_add_ether(sub_tree, hf_tag_measure_request_bssid, tvb, offset, 6, bssid);
5499
5500             offset+=6;
5501             ant_id = tvb_get_guint8 (tvb, offset);
5502             proto_tree_add_uint(sub_tree, hf_tag_measure_report_ant_id, tvb, offset, 1, ant_id);
5503
5504             offset++;
5505             parent_tsf = tvb_get_letohl (tvb, offset);
5506             proto_tree_add_uint(sub_tree, hf_tag_measure_report_parent_tsf, tvb, offset, 4, parent_tsf);
5507
5508             offset+=4;
5509             /* TODO - Must determine frame type and dissect this */
5510             if (tag_len > (offset - tag_offset))
5511             {
5512               proto_tree_add_text (sub_tree, tvb, offset, tag_len - (offset - tag_offset), "Reported Frame Body");
5513             }
5514             break;
5515           }
5516           case 6: /* Frame Report */
5517             /* TODO */
5518           case 7: /* BSTA Statistics Report */
5519             /* TODO */
5520           case 8: /* Location Configuration Information Report element */
5521             /* TODO */
5522           case 9: /* Transmit Stream Measurement Report */
5523             /* TODO */
5524           default: /* unknown */
5525             proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Undissected Data");
5526             break;
5527         }
5528       }
5529
5530       break;
5531     /*** End: Measure Report Tag - Dustin Johnson ***/
5532     /*** Begin: Extended Capabilities Tag - Dustin Johnson ***/
5533     /* The Capabilities field is a bit field indicating the capabilities being advertised 
5534          * by the STA transmitting the information element
5535          */
5536     case TAG_EXTENDED_CAPABILITIES:
5537     {
5538       guint tag_offset;
5539       guint8 info_exchange;
5540           proto_item *ti;
5541           proto_tree *ex_cap_tree;
5542
5543       if (tag_len < 1)
5544       {
5545         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5546             "Extended Capabilities: Error: Tag length must be at least 1 byte long");
5547         break;
5548       }
5549       offset+=2;
5550       tag_offset = offset;
5551
5552       info_exchange = tvb_get_guint8 (tvb, offset);
5553           ti = proto_tree_add_item (tree, hf_tag_extended_capabilities, tvb, offset, 1, FALSE);
5554           ex_cap_tree = proto_item_add_subtree (ti, ett_tag_ex_cap);
5555           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b0, tvb, offset, 1, FALSE);
5556           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b1, tvb, offset, 1, FALSE);
5557           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b2, tvb, offset, 1, FALSE);
5558           proto_tree_add_item (ex_cap_tree, hf_tag_extended_capabilities_b3, tvb, offset, 1, FALSE);
5559
5560       if (tag_len > (offset - tag_offset))
5561       {
5562         proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Unknown Data");
5563         break;
5564       }
5565       break;
5566     }
5567     /*** End: Extended Capabilities Tag - Dustin Johnson ***/
5568     /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
5569     case TAG_NEIGHBOR_REPORT:
5570     {
5571       #define SUB_TAG_TSF_INFO                 0x01
5572       #define SUB_TAG_MEASUREMENT_PILOT_INFO   0x02
5573       #define SUB_TAG_HT_CAPABILITIES          0x03
5574       #define SUB_TAG_HT_INFO                  0x04
5575       #define SUB_TAG_SEC_CHANNEL_OFFSET       0x05
5576       #define SUB_TAG_VENDOR_SPECIFIC          0xDD
5577
5578
5579       guint tag_offset;
5580       guint8 sub_tag_id;
5581       guint32 bssid_info, info, sub_tag_length;
5582       const guint8 *bssid = NULL;
5583       proto_item *parent_item;
5584       proto_tree *bssid_info_subtree, *sub_tag_tree;
5585       tvbuff_t *volatile sub_tag_tvb = NULL;
5586
5587       if (tag_len < 13)
5588       {
5589         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5590             "Neighbor Report: Error: Tag length must be at least 13 bytes long");
5591         break;
5592       }
5593       offset+=2;
5594       tag_offset = offset;
5595
5596       bssid = tvb_get_ptr (tvb, offset, 6);
5597       proto_tree_add_ether(tree, hf_tag_neighbor_report_bssid, tvb, offset, 6, bssid);
5598
5599       /*** Begin: BSSID Information ***/
5600       offset+=6;
5601       bssid_info = tvb_get_letohl (tvb, offset);
5602       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);
5603       bssid_info_subtree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_bssid_info_tree);
5604
5605       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_reachability, tvb, offset, 1, bssid_info);
5606       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_security, tvb, offset, 1, bssid_info);
5607       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_key_scope, tvb, offset, 1, bssid_info);
5608       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_spec_mng, tvb, offset, 1, bssid_info);
5609       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_qos, tvb, offset, 1, bssid_info);
5610       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_apsd, tvb, offset, 1, bssid_info);
5611       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_radio_msnt, tvb, offset, 1, bssid_info);
5612       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_dback, tvb, offset+1, 1, bssid_info);
5613       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_capability_iback, tvb, offset+1, 1, bssid_info);
5614       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_mobility_domain, tvb, offset+1, 1, bssid_info);
5615       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_high_throughput, tvb, offset+1, 1, bssid_info);
5616       proto_tree_add_uint(bssid_info_subtree, hf_tag_neighbor_report_bssid_info_reserved, tvb, offset+1, 3, (bssid_info & 0xfffff000) >> 12);
5617       /*** End: BSSID Information ***/
5618
5619       offset+=4;
5620       info = tvb_get_guint8 (tvb, offset);
5621       proto_tree_add_uint_format(tree, hf_tag_neighbor_report_reg_class, tvb, offset, 1, info, "Regulatory Class: 0x%02X", info);
5622
5623       offset++;
5624       info = tvb_get_guint8 (tvb, offset);
5625       proto_tree_add_uint_format(tree, hf_tag_neighbor_report_channel_number, tvb, offset, 1, info, "Channel Number: 0x%02X", info);
5626
5627       offset++;
5628       info = tvb_get_guint8 (tvb, offset);
5629       proto_tree_add_uint_format(tree, hf_tag_neighbor_report_phy_type, tvb, offset, 1, info, "PHY Type: 0x%02X", info);
5630
5631       offset++;
5632       sub_tag_id = tvb_get_guint8 (tvb, offset);
5633       offset++;
5634       sub_tag_length = tvb_get_guint8 (tvb, offset);
5635
5636       offset++;
5637       sub_tag_tvb = tvb_new_subset(tvb, offset, sub_tag_length, -1);
5638
5639       switch (sub_tag_id) {
5640         case SUB_TAG_TSF_INFO:
5641           /* TODO */
5642           break;
5643         case SUB_TAG_MEASUREMENT_PILOT_INFO:
5644           /* TODO */
5645           break;
5646         case SUB_TAG_HT_CAPABILITIES:
5647           parent_item = proto_tree_add_text (tree, tvb, offset, sub_tag_length, "HT Capabilities");
5648           sub_tag_tree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_sub_tag_tree);
5649           dissect_ht_capability_ie(sub_tag_tree, sub_tag_tvb, 0, sub_tag_length, FALSE);
5650           break;
5651         case SUB_TAG_HT_INFO:
5652           parent_item = proto_tree_add_text (tree, tvb, offset, sub_tag_length, "HT Information");
5653           sub_tag_tree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_sub_tag_tree);
5654           dissect_ht_info_ie_1_1(sub_tag_tree, sub_tag_tvb, 0, sub_tag_length);
5655           break;
5656         case SUB_TAG_SEC_CHANNEL_OFFSET:
5657           parent_item = proto_tree_add_text (tree, tvb, offset, sub_tag_length, "Secondary Channel Offset");
5658           sub_tag_tree = proto_item_add_subtree(parent_item, ett_tag_neighbor_report_sub_tag_tree);
5659           secondary_channel_offset_ie(sub_tag_tree, sub_tag_tvb, 0, sub_tag_length);
5660           break;
5661         case SUB_TAG_VENDOR_SPECIFIC:
5662         default:
5663           break;
5664       }
5665
5666       offset += sub_tag_length;
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: Neighbor Report Tag - Dustin Johnson ***/
5676 #if 0 /*Not yet assigned tag numbers by ANA */
5677     /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
5678     case TAG_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT:
5679     {
5680       guint tag_offset;
5681
5682       if (tag_len != 4)
5683       {
5684         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5685             "Extended Channel Switch Announcement: Error: Tag length must be exactly 4 bytes long");
5686         break;
5687       }
5688
5689       offset+=2;
5690       tag_offset = offset;
5691
5692       offset+= add_fixed_field(tree, tvb, offset, FIELD_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT);
5693
5694       if (tag_len > (offset - tag_offset))
5695       {
5696         proto_tree_add_text (tree, tvb, offset, tag_len - (offset - tag_offset), "Unknown Data");
5697         break;
5698       }
5699       break;
5700     }
5701     /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
5702 #endif
5703 #if 0 /*Not yet assigned tag numbers by ANA */
5704     /*** Begin: Supported Regulatory Classes Tag - Dustin Johnson ***/
5705     case TAG_SUPPORTED_REGULATORY_CLASSES:
5706     {
5707       guint tag_offset;
5708       guint8 current_field;
5709
5710       if (tag_len < 2) {
5711         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5712             "Supported Regulatory Classes: Error: Tag length must be at least 2 bytes long");
5713         break;
5714       } else if (tag_len > 32) {
5715         proto_tree_add_text (tree, tvb, offset + 2, tag_len,
5716             "Supported Regulatory Classes: Error: Tag length must be no more than 32 bytes long");
5717         break;
5718       }
5719
5720       offset+=2;
5721       tag_offset = offset;
5722
5723       current_field = tvb_get_guint8 (tvb, offset);
5724       proto_tree_add_uint(tree, hf_tag_supported_reg_classes_current, tvb, offset, 1, current_field);
5725
5726       offset++;
5727       /* Partially taken from the ssid section */
5728       tag_data_ptr = tvb_get_ptr (tvb, offset, tag_len);
5729       for (i = 0, n = 0; i < tag_len && n < SHORT_STR; i++) {
5730         ret = g_snprintf (print_buff + n, SHORT_STR - n, (i == tag_len-1)?"%d":"%d, ", tag_data_ptr[i]);
5731         if (ret == -1 || ret >= SHORT_STR - n) {
5732           /* Some versions of snprintf return -1 if they'd truncate
5733              the output. Others return <buf_size> or greater.  */
5734           break;
5735         }
5736         n += ret;
5737       }
5738       print_buff[SHORT_STR-1] = '\0';
5739       proto_tree_add_string (tree, hf_tag_supported_reg_classes_alternate, tvb, offset, tag_len, print_buff);
5740
5741       break;
5742     }
5743     /*** End: Supported Regulatory Classes Tag - Dustin Johnson ***/
5744 #endif
5745     default:
5746       tvb_ensure_bytes_exist (tvb, offset + 2, tag_len);
5747       proto_tree_add_string (tree, tag_interpretation, tvb, offset + 1 + tag_len_len,
5748           tag_len, "Not interpreted");
5749       proto_item_append_text(ti, ": Tag %u Len %u", tag_no, tag_len);
5750       break;
5751   }
5752
5753   return tag_len + 1 + tag_len_len;
5754 }
5755
5756 void
5757 ieee_80211_add_tagged_parameters (tvbuff_t * tvb, int offset, packet_info * pinfo,
5758   proto_tree * tree, int tagged_parameters_len)
5759 {
5760   int next_len;
5761
5762   beacon_padding = 0; /* this is for the beacon padding confused with ssid fix */
5763   while (tagged_parameters_len > 0) {
5764     if ((next_len=add_tagged_field (pinfo, tree, tvb, offset))==0)
5765       break;
5766     if (next_len > tagged_parameters_len) {
5767       /* XXX - flag this as an error? */
5768       next_len = tagged_parameters_len;
5769     }
5770     offset += next_len;
5771     tagged_parameters_len -= next_len;
5772   }
5773 }
5774
5775 /* ************************************************************************* */
5776 /*                     Dissect 802.11 management frame                       */
5777 /* ************************************************************************* */
5778 static void
5779 dissect_ieee80211_mgt (guint16 fcf, tvbuff_t * tvb, packet_info * pinfo,
5780     proto_tree * tree)
5781 {
5782   proto_item *ti = NULL;
5783   proto_tree *mgt_tree;
5784   proto_tree *fixed_tree;
5785   proto_tree *tagged_tree;
5786   int offset = 0;
5787   int tagged_parameter_tree_len;
5788
5789   g_pinfo = pinfo;
5790
5791   CHECK_DISPLAY_AS_X(data_handle,proto_wlan_mgt, tvb, pinfo, tree);
5792
5793   ti = proto_tree_add_item (tree, proto_wlan_mgt, tvb, 0, -1, FALSE);
5794   mgt_tree = proto_item_add_subtree (ti, ett_80211_mgt);
5795
5796   switch (COMPOSE_FRAME_TYPE(fcf))
5797   {
5798
5799     case MGT_ASSOC_REQ:
5800       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 4);
5801       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5802       add_fixed_field(fixed_tree, tvb, 2, FIELD_LISTEN_IVAL);
5803       offset = 4;  /* Size of fixed fields */
5804
5805       tagged_parameter_tree_len =
5806           tvb_reported_length_remaining(tvb, offset);
5807       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5808                  tagged_parameter_tree_len);
5809       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5810           tagged_parameter_tree_len);
5811       break;
5812
5813
5814     case MGT_ASSOC_RESP:
5815       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 6);
5816       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5817       add_fixed_field(fixed_tree, tvb, 2, FIELD_STATUS_CODE);
5818       add_fixed_field(fixed_tree, tvb, 4, FIELD_ASSOC_ID);
5819       offset = 6;  /* Size of fixed fields */
5820
5821       tagged_parameter_tree_len =
5822           tvb_reported_length_remaining(tvb, offset);
5823       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5824                  tagged_parameter_tree_len);
5825       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5826           tagged_parameter_tree_len);
5827       break;
5828
5829
5830     case MGT_REASSOC_REQ:
5831       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 10);
5832       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5833       add_fixed_field(fixed_tree, tvb, 2, FIELD_LISTEN_IVAL);
5834       add_fixed_field(fixed_tree, tvb, 4, FIELD_CURRENT_AP_ADDR);
5835       offset = 10;  /* Size of fixed fields */
5836
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_REASSOC_RESP:
5846       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 6);
5847       add_fixed_field(fixed_tree, tvb, 0, FIELD_CAP_INFO);
5848       add_fixed_field(fixed_tree, tvb, 2, FIELD_STATUS_CODE);
5849       add_fixed_field(fixed_tree, tvb, 4, FIELD_ASSOC_ID);
5850       offset = 6;  /* Size of fixed fields */
5851
5852       tagged_parameter_tree_len =
5853           tvb_reported_length_remaining(tvb, offset);
5854       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5855                  tagged_parameter_tree_len);
5856       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5857           tagged_parameter_tree_len);
5858       break;
5859
5860
5861     case MGT_PROBE_REQ:
5862       offset = 0;
5863       tagged_parameter_tree_len =
5864           tvb_reported_length_remaining(tvb, offset);
5865       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5866                  tagged_parameter_tree_len);
5867       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5868           tagged_parameter_tree_len);
5869       break;
5870
5871     case MGT_PROBE_RESP:
5872     {
5873       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 12);
5874       add_fixed_field(fixed_tree, tvb, 0, FIELD_TIMESTAMP);
5875       add_fixed_field(fixed_tree, tvb, 8, FIELD_BEACON_INTERVAL);
5876       add_fixed_field(fixed_tree, tvb, 10, FIELD_CAP_INFO);
5877       offset = 12;  /* Size of fixed fields */
5878
5879       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5880       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset, tagged_parameter_tree_len);
5881       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree, tagged_parameter_tree_len);
5882       break;
5883     }
5884     case MGT_MEASUREMENT_PILOT:
5885     {
5886       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 12);
5887       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_TIMESTAMP);
5888       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_MEASUREMENT_PILOT_INT);
5889       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_BEACON_INTERVAL);
5890       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_CAP_INFO);
5891       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_COUNTRY_STR);
5892       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_MAX_REG_PWR);
5893       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_MAX_TX_PWR);
5894       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_TX_PWR_USED);
5895       offset += add_fixed_field(fixed_tree, tvb, offset, FIELD_TRANSCEIVER_NOISE_FLOOR);
5896       /* TODO DS Parameter Set ??? */
5897
5898       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5899       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset, tagged_parameter_tree_len);
5900       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree, tagged_parameter_tree_len);
5901       break;
5902     }
5903     case MGT_BEACON:    /* Dissect protocol payload fields  */
5904       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 12);
5905       add_fixed_field(fixed_tree, tvb, 0, FIELD_TIMESTAMP);
5906       add_fixed_field(fixed_tree, tvb, 8, FIELD_BEACON_INTERVAL);
5907       add_fixed_field(fixed_tree, tvb, 10, FIELD_CAP_INFO);
5908       offset = 12;  /* Size of fixed fields */
5909
5910       tagged_parameter_tree_len =
5911           tvb_reported_length_remaining(tvb, offset);
5912       tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5913       tagged_parameter_tree_len);
5914       ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5915       tagged_parameter_tree_len);
5916       break;
5917
5918     case MGT_ATIM:
5919       break;
5920
5921     case MGT_DISASS:
5922       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 2);
5923       add_fixed_field(fixed_tree, tvb, 0, FIELD_REASON_CODE);
5924       break;
5925
5926     case MGT_AUTHENTICATION:
5927       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 6);
5928       add_fixed_field(fixed_tree, tvb, 0, FIELD_AUTH_ALG);
5929       add_fixed_field(fixed_tree, tvb, 2, FIELD_AUTH_TRANS_SEQ);
5930       add_fixed_field(fixed_tree, tvb, 4, FIELD_STATUS_CODE);
5931       offset = 6;  /* Size of fixed fields */
5932
5933       tagged_parameter_tree_len =
5934         tvb_reported_length_remaining(tvb, offset);
5935       if (tagged_parameter_tree_len != 0)
5936       {
5937         tagged_tree = get_tagged_parameter_tree (mgt_tree,
5938             tvb,
5939             offset,
5940             tagged_parameter_tree_len);
5941         ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5942         tagged_parameter_tree_len);
5943       }
5944       break;
5945
5946     case MGT_DEAUTHENTICATION:
5947       fixed_tree = get_fixed_parameter_tree (mgt_tree, tvb, 0, 2);
5948       add_fixed_field(fixed_tree, tvb, 0, FIELD_REASON_CODE);
5949       break;
5950
5951     case MGT_ACTION:
5952     {
5953       proto_item *fixed_hdr;
5954       proto_tree *fixed_tree;
5955       fixed_hdr = proto_tree_add_text(mgt_tree, tvb, 0, 0, "Fixed parameters");
5956       fixed_tree = proto_item_add_subtree (fixed_hdr, ett_fixed_parameters);
5957
5958       offset += add_fixed_field(fixed_tree, tvb, 0, FIELD_ACTION);
5959
5960       proto_item_set_len(fixed_hdr, offset);
5961       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5962       if (tagged_parameter_tree_len != 0)
5963       {
5964         tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5965           tagged_parameter_tree_len);
5966         ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5967           tagged_parameter_tree_len);
5968       }
5969       break;
5970     }
5971     case MGT_ACTION_NO_ACK:
5972     {
5973       proto_item *fixed_hdr;
5974       proto_tree *fixed_tree;
5975       fixed_hdr = proto_tree_add_text(mgt_tree, tvb, 0, 0, "Fixed parameters");
5976       fixed_tree = proto_item_add_subtree (fixed_hdr, ett_fixed_parameters);
5977
5978       offset += add_fixed_field(fixed_tree, tvb, 0, FIELD_ACTION);
5979
5980       proto_item_set_len(fixed_hdr, offset);
5981       tagged_parameter_tree_len = tvb_reported_length_remaining(tvb, offset);
5982       if (tagged_parameter_tree_len != 0)
5983       {
5984         tagged_tree = get_tagged_parameter_tree (mgt_tree, tvb, offset,
5985           tagged_parameter_tree_len);
5986         ieee_80211_add_tagged_parameters (tvb, offset, pinfo, tagged_tree,
5987           tagged_parameter_tree_len);
5988       }
5989       break;
5990     }
5991     case MGT_ARUBA_WLAN:
5992     {
5993       proto_item *aruba_hdr;
5994       proto_tree *aruba_tree;
5995       guint16 type;
5996       type = tvb_get_ntohs(tvb, offset);
5997
5998       aruba_hdr = proto_tree_add_text(mgt_tree, tvb, 0, 0, "Aruba Management");
5999       aruba_tree = proto_item_add_subtree(aruba_hdr, ett_fixed_parameters);
6000
6001       proto_tree_add_item(aruba_tree, cf_aruba, tvb, offset, 2, FALSE);
6002       offset += 2;
6003       /* HeartBeat Sequence */
6004       if ( type == 0x0005 )
6005       {
6006         proto_tree_add_item(aruba_tree, cf_aruba_hb_seq, tvb, offset, 8, FALSE);
6007       }
6008       /* MTU Size */
6009       if ( type == 0x0003 )
6010       {
6011         proto_tree_add_item(aruba_tree, cf_aruba_mtu, tvb, offset, 2, FALSE);
6012       }
6013       break;
6014     }
6015   }
6016 }
6017
6018 static void
6019 set_src_addr_cols(packet_info *pinfo, const guint8 *addr, const char *type)
6020 {
6021   if (check_col(pinfo->cinfo, COL_RES_DL_SRC))
6022     col_add_fstr(pinfo->cinfo, COL_RES_DL_SRC, "%s (%s)",
6023         get_ether_name(addr), type);
6024   if (check_col(pinfo->cinfo, COL_UNRES_DL_SRC))
6025     col_add_str(pinfo->cinfo, COL_UNRES_DL_SRC, ether_to_str(addr));
6026 }
6027
6028 static void
6029 set_dst_addr_cols(packet_info *pinfo, const guint8 *addr, const char *type)
6030 {
6031   if (check_col(pinfo->cinfo, COL_RES_DL_DST))
6032     col_add_fstr(pinfo->cinfo, COL_RES_DL_DST, "%s (%s)",
6033         get_ether_name(addr), type);
6034   if (check_col(pinfo->cinfo, COL_UNRES_DL_DST))
6035     col_add_str(pinfo->cinfo, COL_UNRES_DL_DST, ether_to_str(addr));
6036 }
6037
6038 static guint32
6039 crc32_802_tvb_padded(tvbuff_t *tvb, guint hdr_len, guint hdr_size, guint len)
6040 {
6041   guint32 c_crc;
6042
6043   c_crc = crc32_ccitt_tvb(tvb, hdr_len);
6044   c_crc = crc32_ccitt_seed(tvb_get_ptr(tvb, hdr_size, len), len, ~c_crc);
6045
6046   /* Byte reverse. */
6047   c_crc = ((unsigned char)(c_crc>>0)<<24) |
6048     ((unsigned char)(c_crc>>8)<<16) |
6049     ((unsigned char)(c_crc>>16)<<8) |
6050     ((unsigned char)(c_crc>>24)<<0);
6051
6052   return ( c_crc );
6053 }
6054
6055 typedef enum {
6056     ENCAP_802_2,
6057     ENCAP_IPX,
6058     ENCAP_ETHERNET
6059 } encap_t;
6060
6061
6062 /* ************************************************************************* */
6063 /*                          Dissect 802.11 frame                             */
6064 /* ************************************************************************* */
6065
6066 /*
6067  * The 802.11n specification makes some fairly significant changes to the
6068  * layout of the MAC header.  The first two bits of the MAC header are the
6069  * protocol version.  You'd think that the 802.11 committee would have
6070  * bumped the version to indicate a different MAC layout, but NOOOO -- we
6071  * have to go digging for bits in various locations instead.
6072  */
6073
6074 static void
6075 dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
6076         proto_tree * tree, gboolean fixed_length_header, gint fcs_len,
6077         gboolean wlan_broken_fc, gboolean datapad,
6078         gboolean is_ht)
6079 {
6080   guint16 fcf, flags, frame_type_subtype, ctrl_fcf, ctrl_type_subtype;
6081   guint16 seq_control;
6082   guint32 seq_number, frag_number;
6083   gboolean more_frags;
6084   const guint8 *src = NULL;
6085   const guint8 *dst = NULL;
6086   const guint8 *bssid = NULL;
6087   proto_item *ti = NULL;
6088   proto_item *fcs_item = NULL;
6089   proto_item *cw_item = NULL;
6090   proto_item *hidden_item;
6091   proto_tree *hdr_tree = NULL;
6092   proto_tree *fcs_tree = NULL;
6093   proto_tree *cw_tree = NULL;
6094   guint16 hdr_len, ohdr_len, htc_len = 0;
6095   gboolean has_fcs, fcs_good, fcs_bad;
6096   gint len, reported_len, ivlen;
6097   gboolean is_amsdu = 0;
6098   gboolean save_fragmented;
6099   tvbuff_t *volatile next_tvb = NULL;
6100   guint32 addr_type;
6101   volatile encap_t encap_type;
6102   guint8 octet1, octet2;
6103   char out_buff[SHORT_STR];
6104   gint is_iv_bad;
6105   guchar iv_buff[4];
6106   const char *addr1_str = NULL;
6107   int addr1_hf = -1;
6108   guint offset;
6109   const gchar *fts_str;
6110   gchar flag_str[] = "opmPRMFTC";
6111   gint i;
6112
6113   wlan_hdr *volatile whdr;
6114   static wlan_hdr whdrs[4];
6115   gboolean retransmitted;
6116
6117   whdr= &whdrs[0];
6118
6119   if (check_col (pinfo->cinfo, COL_PROTOCOL))
6120     col_set_str (pinfo->cinfo, COL_PROTOCOL, "IEEE 802.11");
6121   if (check_col (pinfo->cinfo, COL_INFO))
6122     col_clear (pinfo->cinfo, COL_INFO);
6123
6124   fcf = FETCH_FCF(0);
6125   frame_type_subtype = COMPOSE_FRAME_TYPE(fcf);
6126   if (frame_type_subtype == CTRL_CONTROL_WRAPPER)
6127     ctrl_fcf = FETCH_FCF(10);
6128   else
6129     ctrl_fcf = 0;
6130
6131   if (fixed_length_header)
6132     hdr_len = DATA_LONG_HDR_LEN;
6133   else
6134     hdr_len = find_header_length (fcf, ctrl_fcf, is_ht);
6135   ohdr_len = hdr_len;
6136   if (datapad)
6137     hdr_len = roundup2(hdr_len, 4);
6138
6139   fts_str = val_to_str(frame_type_subtype, frame_type_subtype_vals,
6140               "Unrecognized (Reserved frame)");
6141   if (check_col (pinfo->cinfo, COL_INFO))
6142       col_set_str (pinfo->cinfo, COL_INFO, fts_str);
6143
6144
6145   flags = FCF_FLAGS (fcf);
6146   more_frags = HAVE_FRAGMENTS (flags);
6147
6148   for (i = 0; i < 8; i++) {
6149     if (! (flags & 0x80 >> i)) {
6150       flag_str[i] = '.';
6151     }
6152   }
6153
6154   if (is_ht && IS_STRICTLY_ORDERED(flags) &&
6155     ((FCF_FRAME_TYPE(fcf) == MGT_FRAME) || (FCF_FRAME_TYPE(fcf) == DATA_FRAME &&
6156       DATA_FRAME_IS_QOS(frame_type_subtype)))) {
6157     htc_len = 4;
6158   }
6159
6160   /* Add the FC to the current tree */
6161   if (tree)
6162     {
6163       ti = proto_tree_add_protocol_format (tree, proto_wlan, tvb, 0, hdr_len,
6164           "IEEE 802.11 %s", fts_str);
6165       hdr_tree = proto_item_add_subtree (ti, ett_80211);
6166
6167       dissect_frame_control(hdr_tree, tvb, wlan_broken_fc, 0);
6168
6169       if (frame_type_subtype == CTRL_PS_POLL)
6170         proto_tree_add_uint(hdr_tree, hf_assoc_id,tvb,2,2,
6171             ASSOC_ID(tvb_get_letohs(tvb,2)));
6172
6173       else
6174         proto_tree_add_uint (hdr_tree, hf_did_duration, tvb, 2, 2,
6175             tvb_get_letohs (tvb, 2));
6176     }
6177
6178   /*
6179    * Decode the part of the frame header that isn't the same for all
6180    * frame types.
6181    */
6182   seq_control = 0;
6183   frag_number = 0;
6184   seq_number = 0;
6185
6186   switch (FCF_FRAME_TYPE (fcf))
6187   {
6188
6189     case MGT_FRAME:
6190       /*
6191        * All management frame types have the same header.
6192        */
6193       src = tvb_get_ptr (tvb, 10, 6);
6194       dst = tvb_get_ptr (tvb, 4, 6);
6195
6196       SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src);
6197       SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src);
6198       SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst);
6199       SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst);
6200
6201       /* for tap */
6202       SET_ADDRESS(&whdr->bssid, AT_ETHER, 6, tvb_get_ptr(tvb, 16,6));
6203       SET_ADDRESS(&whdr->src, AT_ETHER, 6, src);
6204       SET_ADDRESS(&whdr->dst, AT_ETHER, 6, dst);
6205       whdr->type = frame_type_subtype;
6206
6207       seq_control = tvb_get_letohs(tvb, 22);
6208       frag_number = SEQCTL_FRAGMENT_NUMBER(seq_control);
6209       seq_number = SEQCTL_SEQUENCE_NUMBER(seq_control);
6210
6211       if (check_col (pinfo->cinfo, COL_INFO))
6212       {
6213         col_append_fstr(pinfo->cinfo, COL_INFO,
6214             ", SN=%d", seq_number);
6215
6216         col_append_fstr(pinfo->cinfo, COL_INFO,
6217             ", FN=%d",frag_number);
6218       }
6219
6220       if (tree)
6221       {
6222         proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 4, 6, dst);
6223
6224         proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 10, 6, src);
6225
6226         /* add items for wlan.addr filter */
6227         hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 4, 6, dst);
6228         PROTO_ITEM_SET_HIDDEN(hidden_item);
6229         hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 10, 6, src);
6230         PROTO_ITEM_SET_HIDDEN(hidden_item);
6231
6232         proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 16, 6,
6233             tvb_get_ptr (tvb, 16, 6));
6234
6235         proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6236             frag_number);
6237
6238         proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6239             seq_number);
6240       }
6241       break;
6242
6243     case CONTROL_FRAME:
6244     {
6245       /*
6246        * Control Wrapper frames insert themselves between address 1
6247        * and address 2 in a normal control frame.  Process address 1
6248        * first, then handle the rest of the frame in dissect_control.
6249        */
6250       if (frame_type_subtype == CTRL_CONTROL_WRAPPER) {
6251         offset = 10; /* FC + D/ID + Address 1 + CFC + HTC */
6252         ctrl_fcf = FETCH_FCF(10);
6253         ctrl_type_subtype = COMPOSE_FRAME_TYPE(ctrl_fcf);
6254       } else {
6255         offset = 10; /* FC + D/ID + Address 1 */
6256         ctrl_fcf = fcf;
6257         ctrl_type_subtype = frame_type_subtype;
6258       }
6259
6260       switch (ctrl_type_subtype)
6261       {
6262         case CTRL_PS_POLL:
6263           addr1_str = "BSSID";
6264           addr1_hf = hf_addr_bssid;
6265           break;
6266         case CTRL_RTS:
6267         case CTRL_CTS:
6268         case CTRL_ACKNOWLEDGEMENT:
6269         case CTRL_CFP_END:
6270         case CTRL_CFP_ENDACK:
6271         case CTRL_BLOCK_ACK_REQ:
6272         case CTRL_BLOCK_ACK:
6273           addr1_str = "RA";
6274           addr1_hf = hf_addr_ra;
6275           break;
6276         default:
6277           break;
6278       }
6279
6280       if (!addr1_str) /* XXX - Should we throw some sort of error? */
6281         break;
6282
6283       /* Add address 1 */
6284       dst = tvb_get_ptr(tvb, 4, 6);
6285       set_dst_addr_cols(pinfo, dst, addr1_str);
6286       if (tree) {
6287         proto_tree_add_item(hdr_tree, addr1_hf, tvb, 4, 6, FALSE);
6288       }
6289
6290       /*
6291        * Start shoving in other fields if needed.
6292        * XXX - Should we look for is_ht as well?
6293        */
6294       if (frame_type_subtype == CTRL_CONTROL_WRAPPER && tree) {
6295         cw_item = proto_tree_add_text(hdr_tree, tvb, offset, 2,
6296           "Contained Frame Control");
6297         cw_tree = proto_item_add_subtree (cw_item, ett_cntrl_wrapper_fc);
6298         dissect_frame_control(cw_tree, tvb, FALSE, offset);
6299         dissect_ht_control(hdr_tree, tvb, offset + 2);
6300         offset+=6;
6301         cw_item = proto_tree_add_text(hdr_tree, tvb, offset, 2,
6302           "Carried Frame");
6303         hdr_tree = proto_item_add_subtree (cw_item, ett_cntrl_wrapper_fc);
6304       }
6305
6306       switch (ctrl_type_subtype)
6307       {
6308         case CTRL_PS_POLL:
6309         case CTRL_CFP_END:
6310         case CTRL_CFP_ENDACK:
6311         {
6312           src = tvb_get_ptr (tvb, offset, 6);
6313           set_src_addr_cols(pinfo, src, "BSSID");
6314           if (tree) {
6315             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6316           }
6317           break;
6318         }
6319
6320         case CTRL_RTS:
6321         {
6322           src = tvb_get_ptr (tvb, offset, 6);
6323           set_src_addr_cols(pinfo, src, "TA");
6324           if (tree) {
6325             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6326           }
6327           break;
6328         }
6329
6330         case CTRL_CONTROL_WRAPPER:
6331         {
6332           /* XXX - We shouldn't see this.  Should we throw an error? */
6333           break;
6334         }
6335
6336         /*** Begin: Block Ack Request - Dustin Johnson ***/
6337         case CTRL_BLOCK_ACK_REQ:
6338         {
6339           src = tvb_get_ptr (tvb, offset, 6);
6340           set_src_addr_cols(pinfo, src, "TA");
6341
6342           if (tree)
6343           {
6344             guint16 bar_control;
6345             guint8 block_ack_type;
6346             proto_item *bar_parent_item;
6347             proto_tree *bar_sub_tree;
6348
6349             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6350             offset += 6;
6351
6352             bar_control = tvb_get_letohs(tvb, offset);
6353             block_ack_type = (bar_control & 0x0006) >> 1;
6354             proto_tree_add_uint(hdr_tree, hf_block_ack_request_type, tvb,
6355               offset, 1, block_ack_type);
6356             bar_parent_item = proto_tree_add_uint_format(hdr_tree,
6357               hf_block_ack_request_control, tvb, offset, 2, bar_control,
6358               "Block Ack Request (BAR) Control: 0x%04X", bar_control);
6359             bar_sub_tree = proto_item_add_subtree(bar_parent_item,
6360               ett_block_ack);
6361             proto_tree_add_boolean(bar_sub_tree,
6362               hf_block_ack_control_ack_policy, tvb, offset, 1, bar_control);
6363             proto_tree_add_boolean(bar_sub_tree, hf_block_ack_control_multi_tid,
6364               tvb, offset, 1, bar_control);
6365             proto_tree_add_boolean(bar_sub_tree,
6366               hf_block_ack_control_compressed_bitmap, tvb, offset, 1,
6367               bar_control);
6368             proto_tree_add_uint(bar_sub_tree, hf_block_ack_control_reserved,
6369               tvb, offset, 2, bar_control);
6370
6371             switch (block_ack_type)
6372             {
6373               case 0: /*Basic BlockAckReq */
6374               {
6375                 proto_tree_add_uint(bar_sub_tree,
6376                 hf_block_ack_control_basic_tid_info, tvb, offset+1, 1,
6377                   bar_control);
6378                 offset += 2;
6379
6380                 offset += add_fixed_field(hdr_tree, tvb, offset,
6381                   FIELD_BLOCK_ACK_SSC);
6382                 break;
6383               }
6384               case 2: /* Compressed BlockAckReq */
6385               {
6386                 proto_tree_add_uint(bar_sub_tree,
6387                 hf_block_ack_control_compressed_tid_info, tvb, offset+1, 1,
6388                   bar_control);
6389                 offset += 2;
6390
6391                 offset += add_fixed_field(hdr_tree, tvb, offset,
6392                   FIELD_BLOCK_ACK_SSC);
6393                 break;
6394               }
6395               case 3: /* Multi-TID BlockAckReq */
6396               {
6397                 guint8 tid_count, i;
6398                 proto_tree *bar_mtid_tree, *bar_mtid_sub_tree;
6399
6400                 tid_count = ((bar_control & 0xF000) >> 12) + 1;
6401                 proto_tree_add_uint_format(bar_sub_tree, hf_block_ack_control_compressed_tid_info, tvb, offset+1, 1, bar_control,
6402                 decode_numeric_bitfield(bar_control, 0xF000, 16,"Number of TIDs Present: 0x%%X"), tid_count);
6403                 offset += 2;
6404
6405                 bar_parent_item = proto_tree_add_text (hdr_tree, tvb, offset, tid_count*4, "Per TID Info");
6406                 bar_mtid_tree = proto_item_add_subtree(bar_parent_item, ett_block_ack);
6407                 for (i = 1; i <= tid_count; i++) {
6408                   bar_parent_item = proto_tree_add_uint(bar_mtid_tree, hf_block_ack_multi_tid_info, tvb, offset, 4, i);
6409                   bar_mtid_sub_tree = proto_item_add_subtree(bar_parent_item, ett_block_ack);
6410
6411                   bar_control = tvb_get_letohs(tvb, offset);
6412                   proto_tree_add_uint(bar_mtid_sub_tree, hf_block_ack_multi_tid_reserved, tvb, offset, 2, bar_control);
6413                   proto_tree_add_uint(bar_mtid_sub_tree, hf_block_ack_multi_tid_value, tvb, offset+1, 1, bar_control);
6414                   offset += 2;
6415
6416                   offset += add_fixed_field(bar_mtid_sub_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6417                 }
6418                 break;
6419               }
6420             }
6421           }
6422           break;
6423         }
6424         /*** End: Block Ack Request - Dustin Johnson ***/
6425
6426         /*** Begin: Block Ack - Dustin Johnson ***/
6427         case CTRL_BLOCK_ACK:
6428         {
6429           src = tvb_get_ptr (tvb, offset, 6);
6430           set_src_addr_cols(pinfo, src, "TA");
6431
6432           if (tree)
6433           {
6434             guint16 ba_control;
6435             guint8 block_ack_type;
6436             proto_item *ba_parent_item;
6437             proto_tree *ba_sub_tree;
6438
6439             proto_tree_add_item(hdr_tree, hf_addr_ta, tvb, offset, 6, FALSE);
6440             offset += 6;
6441
6442             ba_control = tvb_get_letohs(tvb, offset);
6443             block_ack_type = (ba_control & 0x0006) >> 1;
6444             proto_tree_add_uint(hdr_tree, hf_block_ack_type, tvb, offset, 1, block_ack_type);
6445             ba_parent_item = proto_tree_add_uint_format(hdr_tree,
6446               hf_block_ack_control, tvb, offset, 2, ba_control,
6447               "Block Ack (BA) Control: 0x%04X", ba_control);
6448             ba_sub_tree = proto_item_add_subtree(ba_parent_item, ett_block_ack);
6449             proto_tree_add_boolean(ba_sub_tree, hf_block_ack_control_ack_policy,
6450               tvb, offset, 1, ba_control);
6451             proto_tree_add_boolean(ba_sub_tree, hf_block_ack_control_multi_tid,
6452               tvb, offset, 1, ba_control);
6453             proto_tree_add_boolean(ba_sub_tree,
6454               hf_block_ack_control_compressed_bitmap, tvb, offset, 1,
6455               ba_control);
6456             proto_tree_add_uint(ba_sub_tree, hf_block_ack_control_reserved, tvb,
6457               offset, 2, ba_control);
6458
6459             switch (block_ack_type)
6460             {
6461               case 0: /*Basic BlockAck */
6462               {
6463                 proto_tree_add_uint(ba_sub_tree,
6464                 hf_block_ack_control_basic_tid_info, tvb, offset+1, 1,
6465                   ba_control);
6466                 offset += 2;
6467
6468                 offset += add_fixed_field(hdr_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6469                 proto_tree_add_text(hdr_tree, tvb, offset, 128, "Block Ack Bitmap");
6470                 offset += 128;
6471                 break;
6472               }
6473               case 2: /* Compressed BlockAck */
6474               {
6475                 proto_tree_add_uint(ba_sub_tree, hf_block_ack_control_basic_tid_info, tvb, offset+1, 1, ba_control);
6476                 offset += 2;
6477
6478                 offset += add_fixed_field(hdr_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6479                 proto_tree_add_text(hdr_tree, tvb, offset, 8, "Block Ack Bitmap");
6480                 offset += 8;
6481                 break;
6482               }
6483               case 3:  /* Multi-TID BlockAck */
6484               {
6485                 guint8 tid_count, i;
6486                 proto_tree *ba_mtid_tree, *ba_mtid_sub_tree;
6487
6488                 tid_count = ((ba_control & 0xF000) >> 12) + 1;
6489                 proto_tree_add_uint_format(ba_sub_tree,
6490                 hf_block_ack_control_compressed_tid_info, tvb, offset+1, 1,
6491                   ba_control, decode_numeric_bitfield(ba_control, 0xF000,
6492                   16,"Number of TIDs Present: 0x%%X"), tid_count);
6493                 offset += 2;
6494
6495                 ba_parent_item = proto_tree_add_text (hdr_tree, tvb, offset, tid_count*4, "Per TID Info");
6496                 ba_mtid_tree = proto_item_add_subtree(ba_parent_item, ett_block_ack);
6497                 for (i=1; i<=tid_count; i++) {
6498                   ba_parent_item = proto_tree_add_uint(ba_mtid_tree, hf_block_ack_multi_tid_info, tvb, offset, 4, i);
6499                   ba_mtid_sub_tree = proto_item_add_subtree(ba_parent_item, ett_block_ack);
6500
6501                   ba_control = tvb_get_letohs(tvb, offset);
6502                   proto_tree_add_uint(ba_mtid_sub_tree, hf_block_ack_multi_tid_reserved, tvb, offset, 2, ba_control);
6503                   proto_tree_add_uint(ba_mtid_sub_tree, hf_block_ack_multi_tid_value, tvb, offset+1, 1, ba_control);
6504                   offset += 2;
6505
6506                   offset += add_fixed_field(ba_mtid_sub_tree, tvb, offset, FIELD_BLOCK_ACK_SSC);
6507                   proto_tree_add_text(ba_mtid_sub_tree, tvb, offset, 8, "Block Ack Bitmap");
6508                   offset += 8;
6509                 }
6510                 break;
6511               }
6512             }
6513           }
6514           break;
6515         }
6516         /*** End: Block Ack - Dustin Johnson ***/
6517       }
6518       break;
6519     }
6520
6521     case DATA_FRAME:
6522       addr_type = FCF_ADDR_SELECTOR (fcf);
6523
6524       /* In order to show src/dst address we must always do the following */
6525       switch (addr_type)
6526       {
6527
6528         case DATA_ADDR_T1:
6529           src = tvb_get_ptr (tvb, 10, 6);
6530           dst = tvb_get_ptr (tvb, 4, 6);
6531           bssid = tvb_get_ptr (tvb, 16, 6);
6532           break;
6533
6534         case DATA_ADDR_T2:
6535           src = tvb_get_ptr (tvb, 16, 6);
6536           dst = tvb_get_ptr (tvb, 4, 6);
6537           bssid = tvb_get_ptr (tvb, 10, 6);
6538           break;
6539
6540         case DATA_ADDR_T3:
6541           src = tvb_get_ptr (tvb, 10, 6);
6542           dst = tvb_get_ptr (tvb, 16, 6);
6543           bssid = tvb_get_ptr (tvb, 4, 6);
6544           break;
6545
6546         case DATA_ADDR_T4:
6547           src = tvb_get_ptr (tvb, 24, 6);
6548           dst = tvb_get_ptr (tvb, 16, 6);
6549           bssid = tvb_get_ptr (tvb, 16, 6);
6550           break;
6551       }
6552
6553       SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src);
6554       SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src);
6555       SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst);
6556       SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst);
6557
6558       /* for tap */
6559
6560       SET_ADDRESS(&whdr->bssid, AT_ETHER, 6, bssid);
6561       SET_ADDRESS(&whdr->src, AT_ETHER, 6, src);
6562       SET_ADDRESS(&whdr->dst, AT_ETHER, 6, dst);
6563       whdr->type = frame_type_subtype;
6564
6565       seq_control = tvb_get_letohs(tvb, 22);
6566       frag_number = SEQCTL_FRAGMENT_NUMBER(seq_control);
6567       seq_number = SEQCTL_SEQUENCE_NUMBER(seq_control);
6568
6569       if (check_col (pinfo->cinfo, COL_INFO))
6570       {
6571         col_append_fstr(pinfo->cinfo, COL_INFO,
6572             ", SN=%d", seq_number);
6573
6574         col_append_fstr(pinfo->cinfo, COL_INFO,
6575             ", FN=%d",frag_number);
6576       }
6577
6578       /* Now if we have a tree we start adding stuff */
6579       if (tree)
6580       {
6581
6582         switch (addr_type)
6583         {
6584
6585           case DATA_ADDR_T1:
6586             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 4, 6, dst);
6587             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 10, 6, src);
6588             proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 16, 6,
6589                 tvb_get_ptr (tvb, 16, 6));
6590             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6591                frag_number);
6592             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6593                seq_number);
6594
6595             /* add items for wlan.addr filter */
6596             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 4, 6, dst);
6597             PROTO_ITEM_SET_HIDDEN(hidden_item);
6598             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 10, 6, src);
6599             PROTO_ITEM_SET_HIDDEN(hidden_item);
6600             break;
6601
6602           case DATA_ADDR_T2:
6603             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 4, 6, dst);
6604             proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 10, 6,
6605                 tvb_get_ptr (tvb, 10, 6));
6606             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 16, 6, src);
6607             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6608                frag_number);
6609             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6610                seq_number);
6611
6612             /* add items for wlan.addr filter */
6613             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 4, 6, dst);
6614             PROTO_ITEM_SET_HIDDEN(hidden_item);
6615             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 16, 6, src);
6616             PROTO_ITEM_SET_HIDDEN(hidden_item);
6617             break;
6618
6619           case DATA_ADDR_T3:
6620             proto_tree_add_ether (hdr_tree, hf_addr_bssid, tvb, 4, 6,
6621                 tvb_get_ptr (tvb, 4, 6));
6622             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 10, 6, src);
6623             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 16, 6, dst);
6624
6625             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6626                frag_number);
6627             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6628                seq_number);
6629
6630             /* add items for wlan.addr filter */
6631             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 10, 6, src);
6632             PROTO_ITEM_SET_HIDDEN(hidden_item);
6633             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 16, 6, dst);
6634             PROTO_ITEM_SET_HIDDEN(hidden_item);
6635             break;
6636
6637           case DATA_ADDR_T4:
6638             proto_tree_add_ether (hdr_tree, hf_addr_ra, tvb, 4, 6,
6639                 tvb_get_ptr (tvb, 4, 6));
6640             proto_tree_add_ether (hdr_tree, hf_addr_ta, tvb, 10, 6,
6641                 tvb_get_ptr (tvb, 10, 6));
6642             proto_tree_add_ether (hdr_tree, hf_addr_da, tvb, 16, 6, dst);
6643             proto_tree_add_uint (hdr_tree, hf_frag_number, tvb, 22, 2,
6644                frag_number);
6645             proto_tree_add_uint (hdr_tree, hf_seq_number, tvb, 22, 2,
6646                seq_number);
6647             proto_tree_add_ether (hdr_tree, hf_addr_sa, tvb, 24, 6, src);
6648
6649             /* add items for wlan.addr filter */
6650             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 16, 6, dst);
6651             PROTO_ITEM_SET_HIDDEN(hidden_item);
6652             hidden_item = proto_tree_add_ether (hdr_tree, hf_addr, tvb, 24, 6, src);
6653             PROTO_ITEM_SET_HIDDEN(hidden_item);
6654             break;
6655         }
6656
6657       }
6658       break;
6659   }
6660
6661   len = tvb_length_remaining(tvb, hdr_len);
6662   reported_len = tvb_reported_length_remaining(tvb, hdr_len);
6663
6664   switch (fcs_len)
6665     {
6666       case 0: /* Definitely has no FCS */
6667         has_fcs = FALSE;
6668         break;
6669
6670       case 4: /* Definitely has an FCS */
6671         has_fcs = TRUE;
6672         break;
6673
6674       default: /* Don't know - use "wlan_check_fcs" */
6675         has_fcs = wlan_check_fcs;
6676         break;
6677     }
6678   if (has_fcs)
6679     {
6680       /*
6681        * Well, this packet should, in theory, have an FCS.
6682        * Do we have the entire packet, and does it have enough data for
6683        * the FCS?
6684        */
6685       if (reported_len < 4)
6686       {
6687         /*
6688          * The packet is claimed not to even have enough data for a 4-byte
6689          * FCS.
6690          * Pretend it doesn't have an FCS.
6691          */
6692         ;
6693       }
6694       else if (len < reported_len)
6695       {
6696         /*
6697          * The packet is claimed to have enough data for a 4-byte FCS, but
6698          * we didn't capture all of the packet.
6699          * Slice off the 4-byte FCS from the reported length, and trim the
6700          * captured length so it's no more than the reported length; that
6701          * will slice off what of the FCS, if any, is in the captured
6702          * length.
6703          */
6704         reported_len -= 4;
6705         if (len > reported_len)
6706             len = reported_len;
6707       }
6708       else
6709       {
6710         /*
6711          * We have the entire packet, and it includes a 4-byte FCS.
6712          * Slice it off, and put it into the tree.
6713          */
6714         len -= 4;
6715         reported_len -= 4;
6716         if (tree)
6717         {
6718           guint32 sent_fcs = tvb_get_ntohl(tvb, hdr_len + len);
6719           guint32 fcs;
6720
6721           if (datapad)
6722             fcs = crc32_802_tvb_padded(tvb, ohdr_len, hdr_len, len);
6723           else
6724             fcs = crc32_802_tvb(tvb, hdr_len + len);
6725           if (fcs == sent_fcs) {
6726             fcs_good = TRUE;
6727             fcs_bad = FALSE;
6728           } else {
6729             fcs_good = FALSE;
6730             fcs_bad = TRUE;
6731           }
6732
6733           if(fcs_good) {
6734             fcs_item = proto_tree_add_uint_format(hdr_tree, hf_fcs, tvb,
6735                 hdr_len + len, 4, sent_fcs,
6736                 "Frame check sequence: 0x%08x [correct]", sent_fcs);
6737           } else {
6738             fcs_item = proto_tree_add_uint_format(hdr_tree, hf_fcs, tvb,
6739                 hdr_len + len, 4, sent_fcs,
6740                 "Frame check sequence: 0x%08x [incorrect, should be 0x%08x]",
6741                 sent_fcs, fcs);
6742             flag_str[8] = '.';
6743           }
6744
6745           proto_tree_set_appendix(hdr_tree, tvb, hdr_len + len, 4);
6746
6747           fcs_tree = proto_item_add_subtree(fcs_item, ett_fcs);
6748
6749           fcs_item = proto_tree_add_boolean(fcs_tree,
6750               hf_fcs_good, tvb,
6751               hdr_len + len, 4,
6752               fcs_good);
6753           PROTO_ITEM_SET_GENERATED(fcs_item);
6754
6755           fcs_item = proto_tree_add_boolean(fcs_tree,
6756               hf_fcs_bad, tvb,
6757               hdr_len + len, 4,
6758               fcs_bad);
6759           PROTO_ITEM_SET_GENERATED(fcs_item);
6760         }
6761       }
6762     } else {
6763       flag_str[8] = '\0';
6764     }
6765
6766     proto_item_append_text(ti, ", Flags: %s", flag_str);
6767     if (check_col (pinfo->cinfo, COL_INFO))
6768       col_append_fstr (pinfo->cinfo, COL_INFO, ", Flags=%s", flag_str);
6769
6770
6771   /*
6772    * Only management and data frames have a body, so we don't have
6773    * anything more to do for other types of frames.
6774    */
6775   switch (FCF_FRAME_TYPE (fcf))
6776     {
6777
6778     case MGT_FRAME:
6779       if (htc_len == 4) {
6780         dissect_ht_control(hdr_tree, tvb, ohdr_len - 4);
6781       }
6782       break;
6783
6784     case DATA_FRAME:
6785       if (tree && DATA_FRAME_IS_QOS(frame_type_subtype))
6786       {
6787         proto_item *qos_fields;
6788         proto_tree *qos_tree;
6789
6790         guint16 qosoff;
6791         guint16 qos_control;
6792         guint16 qos_priority;
6793         guint16 qos_ack_policy;
6794         guint16 qos_amsdu_present;
6795         guint16 qos_eosp;
6796         guint16 qos_field_content;
6797
6798         /*
6799          * We calculate the offset to the QoS header data as
6800          * an offset relative to the end of the header.  But
6801          * when the header has been padded to align the data
6802          * this must be done relative to true header size, not
6803          * the padded/aligned value.  To simplify this work we
6804          * stash the original header size in ohdr_len instead
6805          * of recalculating it.
6806          */
6807         qosoff = ohdr_len - htc_len - 2;
6808         qos_fields = proto_tree_add_text(hdr_tree, tvb, qosoff, 2,
6809             "QoS Control");
6810         qos_tree = proto_item_add_subtree (qos_fields, ett_qos_parameters);
6811
6812         qos_control = tvb_get_letohs(tvb, qosoff + 0);
6813         qos_priority = QOS_PRIORITY(qos_control);
6814         qos_ack_policy = QOS_ACK_POLICY(qos_control);
6815         qos_amsdu_present = QOS_AMSDU_PRESENT(qos_control);
6816         qos_eosp = QOS_EOSP(qos_control);
6817         qos_field_content = QOS_FIELD_CONTENT(qos_control);
6818
6819         proto_tree_add_uint_format (qos_tree, hf_qos_priority, tvb,
6820             qosoff, 1, qos_priority,
6821             "Priority: %d (%s) (%s)",
6822             qos_priority, qos_tags[qos_priority], qos_acs[qos_priority]);
6823
6824         if (flags & FLAG_FROM_DS) {
6825           proto_tree_add_boolean (qos_tree, hf_qos_eosp, tvb,
6826               qosoff, 1, qos_control);
6827         }
6828
6829         proto_tree_add_uint (qos_tree, hf_qos_ack_policy, tvb, qosoff, 1,
6830             qos_ack_policy);
6831
6832         if (flags & FLAG_FROM_DS) {
6833           if (!DATA_FRAME_IS_NULL(frame_type_subtype)) {
6834             proto_tree_add_boolean(qos_tree, hf_qos_amsdu_present, tvb,
6835                 qosoff, 1, qos_amsdu_present);
6836             is_amsdu = qos_amsdu_present;
6837           }
6838           if (DATA_FRAME_IS_CF_POLL(frame_type_subtype)) {
6839             /* txop limit */
6840             proto_tree_add_uint_format (qos_tree, hf_qos_field_content, tvb,
6841                 qosoff + 1, 1, qos_field_content, "Transmit Opportunity (TXOP) Limit: 0x%02X", qos_field_content);
6842
6843           } else {
6844             /* qap ps buffer state */
6845             proto_item *qos_ps_buf_state_fields;
6846                 proto_tree *qos_ps_buf_state_tree;
6847             guint16 buf_state;
6848             guint16 buf_ac;
6849             guint16 buf_load;
6850
6851             buf_state = QOS_PS_BUF_STATE(qos_field_content);
6852             buf_ac = QOS_PS_BUF_AC(qos_field_content);  /*access category */
6853             buf_load = QOS_PS_BUF_LOAD(qos_field_content);
6854
6855             qos_ps_buf_state_fields = proto_tree_add_text(qos_tree, tvb, qosoff + 1, 1,
6856                 "QAP PS Buffer State: 0x%x", qos_field_content);
6857             qos_ps_buf_state_tree = proto_item_add_subtree (qos_ps_buf_state_fields, ett_qos_ps_buf_state);
6858
6859 /*  FIXME: hf_ values not defined
6860             proto_tree_add_boolean (qos_ps_buf_state_tree, hf_qos_buf_state, tvb,
6861                 1, 1, buf_state);
6862
6863             proto_tree_add_uint_format (qos_ps_buf_state_tree, hf_qos_buf_ac, tvb,
6864             qosoff + 1, 1, buf_ac, "Priority: %d (%s)",
6865                 buf_ac, wme_acs[buf_ac]);
6866
6867             proto_tree_add_uint_format (qos_ps_buf_state_tree, hf_qos_buf_load, tvb,
6868                 qosoff + 1, 1, buf_load, "Buffered load: %d ", (buf_load * 4096));
6869 */
6870
6871           }
6872         } else {
6873           if (!DATA_FRAME_IS_NULL(frame_type_subtype)) {
6874             proto_tree_add_boolean(qos_tree, hf_qos_amsdu_present, tvb,
6875                 qosoff, 1, qos_amsdu_present);
6876             is_amsdu = qos_amsdu_present;
6877           }
6878           if (qos_eosp) {
6879             /* txop limit requested */
6880             proto_tree_add_uint_format (qos_tree, hf_qos_field_content, tvb,
6881                 qosoff + 1, 1, qos_field_content, "Queue Size: %d", (qos_field_content * 254));
6882           } else {
6883             /* queue size */
6884             proto_tree_add_uint_format (qos_tree, hf_qos_field_content, tvb,
6885             qosoff + 1, 1, qos_field_content, "Transmit Opportunity (TXOP) Limit Requested: 0x%02X", qos_field_content);
6886           }
6887         }
6888
6889         /* Do we have +HTC? */
6890         if (htc_len == 4) {
6891           dissect_ht_control(hdr_tree, tvb, ohdr_len - 4);
6892         }
6893       } /* end of qos control field */
6894
6895 #ifdef HAVE_AIRPDCAP
6896       /* Davide Schiera (2006-11-21): process handshake packet with AirPDcap    */
6897       /* the processing will take care of 4-way handshake sessions for WPA    */
6898       /* and WPA2 decryption                                  */
6899       if (enable_decryption && !pinfo->fd->flags.visited) {
6900         const guint8 *enc_data = tvb_get_ptr(tvb, 0, hdr_len+reported_len);
6901         AirPDcapPacketProcess(&airpdcap_ctx, enc_data, hdr_len, hdr_len+reported_len, NULL, 0, NULL, TRUE, FALSE);
6902       }
6903       /* Davide Schiera --------------------------------------------------------  */
6904 #endif
6905
6906       /*
6907        * No-data frames don't have a body.
6908        */
6909       if (DATA_FRAME_IS_NULL(frame_type_subtype))
6910         return;
6911
6912       if (!wlan_subdissector) {
6913         guint fnum = 0;
6914
6915         /* key: bssid:src
6916          * data: last seq_control seen and frame number
6917          */
6918         retransmitted = FALSE;
6919         if(!pinfo->fd->flags.visited){
6920           retransmit_key key;
6921           retransmit_key *result;
6922
6923           memcpy(key.bssid, bssid, 6);
6924           memcpy(key.src, src, 6);
6925           key.seq_control = 0;
6926           result = (retransmit_key *)g_hash_table_lookup(fc_analyse_retransmit_table, &key);
6927           if (result && result->seq_control == seq_control) {
6928                /* keep a pointer to the first seen frame, could be done with proto data? */
6929                fnum = result->fnum;
6930                g_hash_table_insert(fc_first_frame_table, GINT_TO_POINTER( pinfo->fd->num),
6931                   GINT_TO_POINTER(fnum));
6932                retransmitted = TRUE;
6933           } else {
6934                /* first time or new seq*/
6935                if (!result) {
6936                   result = se_alloc(sizeof(retransmit_key));
6937                   *result = key;
6938                   g_hash_table_insert(fc_analyse_retransmit_table, result, result);
6939                }
6940                result->seq_control = seq_control;
6941                result->fnum =  pinfo->fd->num;
6942            }
6943         }
6944         else if ((fnum = GPOINTER_TO_UINT(g_hash_table_lookup(fc_first_frame_table, GINT_TO_POINTER( pinfo->fd->num))))) {
6945            retransmitted = TRUE;
6946         }
6947
6948         if (retransmitted) {
6949             if (check_col (pinfo->cinfo, COL_INFO))
6950                 col_append_fstr(pinfo->cinfo, COL_INFO, " [retransmitted]");
6951             if (tree) {
6952                 proto_item *item;
6953
6954                 item=proto_tree_add_none_format(hdr_tree, hf_fc_analysis_retransmission, tvb, 0, 0, "Retransmitted frame");
6955                 PROTO_ITEM_SET_GENERATED(item);
6956                 item=proto_tree_add_uint(hdr_tree, hf_fc_analysis_retransmission_frame,tvb, 0, 0, fnum);
6957                 PROTO_ITEM_SET_GENERATED(item);
6958             }
6959             next_tvb = tvb_new_subset (tvb, hdr_len, len, reported_len);
6960             call_dissector(data_handle, next_tvb, pinfo, tree);
6961             goto end_of_wlan;
6962         }
6963       }
6964
6965       break;
6966
6967     case CONTROL_FRAME:
6968       return;
6969
6970     default:
6971       return;
6972     }
6973
6974   if (IS_PROTECTED(FCF_FLAGS(fcf)) && wlan_ignore_wep != WLAN_IGNORE_WEP_WO_IV) {
6975     /*
6976      * It's a WEP or WPA encrypted frame; dissect the protections parameters
6977      * and decrypt the data, if we have a matching key. Otherwise display it as data.
6978      */
6979
6980     gboolean can_decrypt = FALSE;
6981     proto_tree *wep_tree = NULL;
6982     guint32 iv;
6983     guint8 key, keybyte;
6984
6985     /* Davide Schiera (2006-11-27): define algorithms constants and macros  */
6986 #ifdef HAVE_AIRPDCAP
6987 #define PROTECTION_ALG_TKIP  AIRPDCAP_KEY_TYPE_TKIP
6988 #define PROTECTION_ALG_CCMP  AIRPDCAP_KEY_TYPE_CCMP
6989 #define PROTECTION_ALG_WEP  AIRPDCAP_KEY_TYPE_WEP
6990 #define PROTECTION_ALG_RSNA  PROTECTION_ALG_CCMP | PROTECTION_ALG_TKIP
6991 #else
6992 #define PROTECTION_ALG_WEP  0
6993 #define PROTECTION_ALG_TKIP  1
6994 #define PROTECTION_ALG_CCMP  2
6995 #define PROTECTION_ALG_RSNA  PROTECTION_ALG_CCMP | PROTECTION_ALG_TKIP
6996 #endif
6997     guint8 algorithm=-1;
6998     /* Davide Schiera (2006-11-27): added macros to check the algorithm    */
6999     /* used could be TKIP or CCMP                            */
7000 #define IS_TKIP(tvb, hdr_len)  (tvb_get_guint8(tvb, hdr_len + 1) & 0x20)
7001 #define IS_CCMP(tvb, hdr_len)  (tvb_get_guint8(tvb, hdr_len + 2) == 0)
7002     /* Davide Schiera -----------------------------------------------------  */
7003
7004 #ifdef  HAVE_AIRPDCAP
7005     /* Davide Schiera (2006-11-21): recorded original lengths to pass them  */
7006     /* to the packets process function                        */
7007     guint32 sec_header=0;
7008     guint32 sec_trailer=0;
7009
7010     next_tvb = try_decrypt(tvb, hdr_len, reported_len, &algorithm, &sec_header, &sec_trailer);
7011 #endif
7012     /* Davide Schiera -----------------------------------------------------  */
7013
7014     keybyte = tvb_get_guint8(tvb, hdr_len + 3);
7015     key = KEY_OCTET_WEP_KEY(keybyte);
7016     if ((keybyte & KEY_EXTIV) && (len >= EXTIV_LEN)) {
7017       /* Extended IV; this frame is likely encrypted with TKIP or CCMP */
7018
7019
7020       if (tree) {
7021         proto_item *extiv_fields;
7022
7023 #ifdef HAVE_AIRPDCAP
7024         /* Davide Schiera (2006-11-27): differentiated CCMP and TKIP if  */
7025         /* it's possible                                */
7026         if (algorithm==PROTECTION_ALG_TKIP)
7027           extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7028               "TKIP parameters");
7029         else if (algorithm==PROTECTION_ALG_CCMP)
7030           extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7031             "CCMP parameters");
7032         else {
7033           /* Davide Schiera --------------------------------------------  */
7034 #endif
7035           /* Davide Schiera (2006-11-27): differentiated CCMP and TKIP if*/
7036           /* it's possible                              */
7037           if (IS_TKIP(tvb, hdr_len)) {
7038             algorithm=PROTECTION_ALG_TKIP;
7039             extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7040                 "TKIP parameters");
7041           } else if (IS_CCMP(tvb, hdr_len)) {
7042             algorithm=PROTECTION_ALG_CCMP;
7043             extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7044                 "CCMP parameters");
7045           } else
7046             extiv_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 8,
7047                 "TKIP/CCMP parameters");
7048 #ifdef HAVE_AIRPDCAP
7049         }
7050 #endif
7051         proto_item_set_len (ti, hdr_len + 8);
7052
7053         wep_tree = proto_item_add_subtree (extiv_fields, ett_wep_parameters);
7054
7055         if (algorithm==PROTECTION_ALG_TKIP) {
7056           g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X",
7057               tvb_get_letohl(tvb, hdr_len + 4),
7058               tvb_get_guint8(tvb, hdr_len),
7059               tvb_get_guint8(tvb, hdr_len + 2));
7060           proto_tree_add_string(wep_tree, hf_tkip_extiv, tvb, hdr_len,
7061               EXTIV_LEN, out_buff);
7062         } else if (algorithm==PROTECTION_ALG_CCMP) {
7063           g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X",
7064               tvb_get_letohl(tvb, hdr_len + 4),
7065               tvb_get_guint8(tvb, hdr_len + 1),
7066               tvb_get_guint8(tvb, hdr_len));
7067           proto_tree_add_string(wep_tree, hf_ccmp_extiv, tvb, hdr_len,
7068               EXTIV_LEN, out_buff);
7069         }
7070
7071         proto_tree_add_uint(wep_tree, hf_wep_key, tvb, hdr_len + 3, 1, key);
7072       }
7073
7074       /* Subtract out the length of the IV. */
7075       len -= EXTIV_LEN;
7076       reported_len -= EXTIV_LEN;
7077       ivlen = EXTIV_LEN;
7078       /* It is unknown whether this is TKIP or CCMP, so let's not even try to
7079        * parse TKIP Michael MIC+ICV or CCMP MIC. */
7080
7081 #ifdef HAVE_AIRPDCAP
7082       /* Davide Schiera (2006-11-21): enable TKIP and CCMP decryption      */
7083       /* checking for the trailer                            */
7084       if (next_tvb!=NULL) {
7085         if (reported_len < (gint) sec_trailer) {
7086           /* There is no space for a trailer, ignore it and don't decrypt  */
7087           ;
7088         } else if (len < reported_len) {
7089           /* There is space for a trailer, but we haven't capture all the  */
7090           /* packet. Slice off the trailer, but don't try to decrypt      */
7091           reported_len -= sec_trailer;
7092           if (len > reported_len)
7093             len = reported_len;
7094         } else {
7095           /* Ok, we have a trailer and the whole packet. Decrypt it!      */
7096           /* TODO: At the moment we won't add the trailer to the tree,    */
7097           /* so don't remove the trailer from the packet              */
7098           len -= sec_trailer;
7099           reported_len -= sec_trailer;
7100           can_decrypt = TRUE;
7101         }
7102       }
7103       /* Davide Schiera --------------------------------------------------  */
7104 #endif
7105     } else {
7106       /* No Ext. IV - WEP packet */
7107       /*
7108        * XXX - pass the IV and key to "try_decrypt_wep()", and have it pass
7109        * them to "wep_decrypt()", rather than having "wep_decrypt()" extract
7110        * them itself.
7111        *
7112        * Also, just pass the data *following* the WEP parameters as the
7113        * buffer to decrypt.
7114        */
7115       iv = tvb_get_ntoh24(tvb, hdr_len);
7116       if (tree) {
7117         proto_item *wep_fields;
7118
7119         wep_fields = proto_tree_add_text(hdr_tree, tvb, hdr_len, 4,
7120             "WEP parameters");
7121
7122         wep_tree = proto_item_add_subtree (wep_fields, ett_wep_parameters);
7123         proto_tree_add_uint (wep_tree, hf_wep_iv, tvb, hdr_len, 3, iv);
7124         tvb_memcpy(tvb, iv_buff, hdr_len, 3);
7125         is_iv_bad = weak_iv(iv_buff);
7126         if (is_iv_bad != -1) {
7127           proto_tree_add_boolean_format (wep_tree, hf_wep_iv_weak,
7128               tvb, 0, 0, TRUE,
7129               "Weak IV for key byte %d",
7130               is_iv_bad);
7131         }
7132       }
7133       if (tree)
7134         proto_tree_add_uint (wep_tree, hf_wep_key, tvb, hdr_len + 3, 1, key);
7135
7136       /* Subtract out the length of the IV. */
7137       len -= 4;
7138       reported_len -= 4;
7139       ivlen = 4;
7140
7141       /* Davide Schiera (2006-11-27): Even if the decryption was not */
7142       /* successful, set the algorithm                               */
7143       algorithm=PROTECTION_ALG_WEP;
7144
7145       /*
7146        * Well, this packet should, in theory, have an ICV.
7147        * Do we have the entire packet, and does it have enough data for
7148        * the ICV?
7149        */
7150       if (reported_len < 4) {
7151         /*
7152          * The packet is claimed not to even have enough data for a
7153          * 4-byte ICV.
7154          * Pretend it doesn't have an ICV.
7155          */
7156         ;
7157       } else if (len < reported_len) {
7158         /*
7159          * The packet is claimed to have enough data for a 4-byte ICV,
7160          * but we didn't capture all of the packet.
7161          * Slice off the 4-byte ICV from the reported length, and trim
7162          * the captured length so it's no more than the reported length;
7163          * that will slice off what of the ICV, if any, is in the
7164          * captured length.
7165          */
7166         reported_len -= 4;
7167         if (len > reported_len)
7168           len = reported_len;
7169       } else {
7170         /*
7171          * We have the entire packet, and it includes a 4-byte ICV.
7172          * Slice it off, and put it into the tree.
7173          *
7174          * We only support decrypting if we have the the ICV.
7175          *
7176          * XXX - the ICV is encrypted; we're putting the encrypted
7177          * value, not the decrypted value, into the tree.
7178          */
7179         len -= 4;
7180         reported_len -= 4;
7181         can_decrypt = TRUE;
7182       }
7183     }
7184
7185     if (algorithm == PROTECTION_ALG_WEP) {
7186       g_strlcpy (wlan_stats.protection, "WEP", MAX_PROTECT_LEN);
7187     } else if (algorithm == PROTECTION_ALG_TKIP) {
7188       g_strlcpy (wlan_stats.protection, "TKIP", MAX_PROTECT_LEN);
7189     } else if (algorithm == PROTECTION_ALG_CCMP) {
7190       g_strlcpy (wlan_stats.protection, "CCMP", MAX_PROTECT_LEN);
7191     } else {
7192       g_strlcpy (wlan_stats.protection, "Unknown", MAX_PROTECT_LEN);
7193     }
7194
7195 #ifndef HAVE_AIRPDCAP
7196     if (can_decrypt)
7197       next_tvb = try_decrypt_wep(tvb, hdr_len, reported_len + 8);
7198 #else
7199     /* Davide Schiera (2006-11-26): decrypted before parsing header and    */
7200     /* protection header                                  */
7201 #endif
7202     if (!can_decrypt || next_tvb == NULL) {
7203       /*
7204        * WEP decode impossible or failed, treat payload as raw data
7205        * and don't attempt fragment reassembly or further dissection.
7206        */
7207       next_tvb = tvb_new_subset(tvb, hdr_len + ivlen, len, reported_len);
7208
7209       if (tree) {
7210         /* Davide Schiera (2006-11-21): added WEP or WPA separation      */
7211         if (algorithm==PROTECTION_ALG_WEP) {
7212           if (can_decrypt)
7213             proto_tree_add_uint_format (wep_tree, hf_wep_icv, tvb,
7214                 hdr_len + ivlen + len, 4,
7215                 tvb_get_ntohl(tvb, hdr_len + ivlen + len),
7216                 "WEP ICV: 0x%08x (not verified)",
7217                 tvb_get_ntohl(tvb, hdr_len + ivlen + len));
7218         } else if (algorithm==PROTECTION_ALG_CCMP) {
7219         } else if (algorithm==PROTECTION_ALG_TKIP) {
7220         }
7221       }
7222       /* Davide Schiera (2006-11-21) ----------------------------------  */
7223
7224       if (pinfo->ethertype != ETHERTYPE_CENTRINO_PROMISC && wlan_ignore_wep == WLAN_IGNORE_WEP_NO) {
7225         /* Some wireless drivers (such as Centrino) WEP payload already decrypted */
7226         call_dissector(data_handle, next_tvb, pinfo, tree);
7227         goto end_of_wlan;
7228       }
7229     } else {
7230       /* Davide Schiera (2006-11-21): added WEP or WPA separation        */
7231       if (algorithm==PROTECTION_ALG_WEP) {
7232         if (tree)
7233           proto_tree_add_uint_format (wep_tree, hf_wep_icv, tvb,
7234               hdr_len + ivlen + len, 4,
7235               tvb_get_ntohl(tvb, hdr_len + ivlen + len),
7236               "WEP ICV: 0x%08x (correct)",
7237               tvb_get_ntohl(tvb, hdr_len + ivlen + len));
7238
7239         add_new_data_source(pinfo, next_tvb, "Decrypted WEP data");
7240       } else if (algorithm==PROTECTION_ALG_CCMP) {
7241         add_new_data_source(pinfo, next_tvb, "Decrypted CCMP data");
7242       } else if (algorithm==PROTECTION_ALG_TKIP) {
7243         add_new_data_source(pinfo, next_tvb, "Decrypted TKIP data");
7244       }
7245       /* Davide Schiera (2006-11-21) -------------------------------------  */
7246       /* Davide Schiera (2006-11-27): undefine macros and definitions  */
7247 #undef IS_TKIP
7248 #undef IS_CCMP
7249 #undef PROTECTION_ALG_CCMP
7250 #undef PROTECTION_ALG_TKIP
7251 #undef PROTECTION_ALG_WEP
7252       /* Davide Schiera --------------------------------------------------  */
7253     }
7254
7255     /*
7256      * WEP decryption successful!
7257      *
7258      * Use the tvbuff we got back from the decryption; the data starts at
7259      * the beginning.  The lengths are already correct for the decoded WEP
7260      * payload.
7261      */
7262     hdr_len = 0;
7263
7264   } else {
7265     /*
7266      * Not a WEP-encrypted frame; just use the data from the tvbuff
7267      * handed to us.
7268      *
7269      * The payload starts at "hdr_len" (i.e., just past the 802.11
7270      * MAC header), the length of data in the tvbuff following the
7271      * 802.11 header is "len", and the length of data in the packet
7272      * following the 802.11 header is "reported_len".
7273      */
7274     next_tvb = tvb;
7275   }
7276
7277   /*
7278    * Do defragmentation if "wlan_defragment" is true, and we have more
7279    * fragments or this isn't the first fragment.
7280    *
7281    * We have to do some special handling to catch frames that
7282    * have the "More Fragments" indicator not set but that
7283    * don't show up as reassembled and don't have any other
7284    * fragments present.  Some networking interfaces appear
7285    * to do reassembly even when you're capturing raw packets
7286    * *and* show the reassembled packet without the "More
7287    * Fragments" indicator set *but* with a non-zero fragment
7288    * number.
7289    *
7290    * "fragment_add_seq_802_11()" handles that; we want to call it
7291    * even if we have a short frame, so that it does those checks - if
7292    * the frame is short, it doesn't do reassembly on it.
7293    *
7294    * (This could get some false positives if we really *did* only
7295    * capture the last fragment of a fragmented packet, but that's
7296    * life.)
7297    */
7298   save_fragmented = pinfo->fragmented;
7299   if (wlan_defragment && (more_frags || frag_number != 0)) {
7300     fragment_data *fd_head;
7301
7302     /*
7303      * If we've already seen this frame, look it up in the
7304      * table of reassembled packets, otherwise add it to
7305      * whatever reassembly is in progress, if any, and see
7306      * if it's done.
7307      */
7308     if (reported_len < 0)
7309       THROW(ReportedBoundsError);
7310     fd_head = fragment_add_seq_802_11(next_tvb, hdr_len, pinfo, seq_number,
7311         wlan_fragment_table,
7312         wlan_reassembled_table,
7313         frag_number,
7314         reported_len,
7315         more_frags);
7316     next_tvb = process_reassembled_data(tvb, hdr_len, pinfo,
7317         "Reassembled 802.11", fd_head,
7318         &frag_items, NULL, hdr_tree);
7319   } else {
7320     /*
7321      * If this is the first fragment, dissect its contents, otherwise
7322      * just show it as a fragment.
7323      */
7324     if (frag_number != 0) {
7325       /* Not the first fragment - don't dissect it. */
7326       next_tvb = NULL;
7327     } else {
7328       /* First fragment, or not fragmented.  Dissect what we have here. */
7329
7330       /* Get a tvbuff for the payload. */
7331       next_tvb = tvb_new_subset (next_tvb, hdr_len, len, reported_len);
7332
7333       /*
7334        * If this is the first fragment, but not the only fragment,
7335        * tell the next protocol that.
7336        */
7337       if (more_frags)
7338         pinfo->fragmented = TRUE;
7339       else
7340         pinfo->fragmented = FALSE;
7341     }
7342   }
7343
7344   if (next_tvb == NULL) {
7345     /* Just show this as an incomplete fragment. */
7346     if (check_col(pinfo->cinfo, COL_INFO))
7347       col_set_str(pinfo->cinfo, COL_INFO, "Fragmented IEEE 802.11 frame");
7348     next_tvb = tvb_new_subset (tvb, hdr_len, len, reported_len);
7349     call_dissector(data_handle, next_tvb, pinfo, tree);
7350     pinfo->fragmented = save_fragmented;
7351     goto end_of_wlan;
7352   }
7353
7354   switch (FCF_FRAME_TYPE (fcf))
7355     {
7356
7357     case MGT_FRAME:
7358       dissect_ieee80211_mgt (fcf, next_tvb, pinfo, tree);
7359       break;
7360
7361     case DATA_FRAME:
7362       if (is_amsdu && tvb_reported_length_remaining(next_tvb, 0) > 4){
7363         tvbuff_t *volatile msdu_tvb = NULL;
7364         guint32 msdu_offset = 0;
7365         guint16 i = 1;
7366         const guint8 *src = NULL;
7367         const guint8 *dst = NULL;
7368         guint16 msdu_length;
7369         proto_item *parent_item;
7370         proto_tree *mpdu_tree;
7371         proto_tree *subframe_tree;
7372
7373         parent_item = proto_tree_add_protocol_format(tree, proto_aggregate, next_tvb, 0,
7374                                     tvb_reported_length_remaining(next_tvb, 0), "IEEE 802.11 Aggregate MSDU");
7375         mpdu_tree = proto_item_add_subtree(parent_item, ett_msdu_aggregation_parent_tree);
7376
7377         do {
7378           dst = tvb_get_ptr (next_tvb, msdu_offset, 6);
7379           src = tvb_get_ptr (next_tvb, msdu_offset+6, 6);
7380           msdu_length = tvb_get_ntohs (next_tvb, msdu_offset+12);
7381
7382           parent_item = proto_tree_add_uint_format(mpdu_tree, amsdu_msdu_header_text, next_tvb,
7383                             msdu_offset, roundup2(msdu_offset+14+msdu_length, 4),
7384                             i, "A-MSDU Subframe #%u", i);
7385           subframe_tree = proto_item_add_subtree(parent_item, ett_msdu_aggregation_subframe_tree);
7386           i++;
7387
7388           proto_tree_add_ether(subframe_tree, hf_addr_da, next_tvb, msdu_offset, 6, dst);
7389           proto_tree_add_ether(subframe_tree, hf_addr_sa, next_tvb, msdu_offset+6, 6, src);
7390           proto_tree_add_uint_format(subframe_tree, mcsset_highest_data_rate, next_tvb, msdu_offset+12, 2,
7391           msdu_length, "MSDU length: 0x%04X", msdu_length);
7392
7393           msdu_offset += 14;
7394           msdu_tvb = tvb_new_subset(next_tvb, msdu_offset, msdu_length, -1);
7395           call_dissector(llc_handle, msdu_tvb, pinfo, subframe_tree);
7396           msdu_offset = roundup2(msdu_offset+msdu_length, 4);
7397         } while (tvb_reported_length_remaining(next_tvb, msdu_offset) > 14);
7398
7399         break;
7400       }
7401       /* I guess some bridges take Netware Ethernet_802_3 frames,
7402          which are 802.3 frames (with a length field rather than
7403          a type field, but with no 802.2 header in the payload),
7404          and just stick the payload into an 802.11 frame.  I've seen
7405          captures that show frames of that sort.
7406
7407          We also handle some odd form of encapsulation in which a
7408          complete Ethernet frame is encapsulated within an 802.11
7409          data frame, with no 802.2 header.  This has been seen
7410          from some hardware.
7411
7412          So, if the packet doesn't start with 0xaa 0xaa:
7413
7414            we first use the same scheme that linux-wlan-ng does to detect
7415            those encapsulated Ethernet frames, namely looking to see whether
7416            the frame either starts with 6 octets that match the destination
7417            address from the 802.11 header or has 6 octets that match the
7418            source address from the 802.11 header following the first 6 octets,
7419            and, if so, treat it as an encapsulated Ethernet frame;
7420
7421            otherwise, we use the same scheme that we use in the Ethernet
7422            dissector to recognize Netware 802.3 frames, namely checking
7423            whether the packet starts with 0xff 0xff and, if so, treat it
7424            as an encapsulated IPX frame. */
7425       encap_type = ENCAP_802_2;
7426       TRY {
7427         octet1 = tvb_get_guint8(next_tvb, 0);
7428         octet2 = tvb_get_guint8(next_tvb, 1);
7429         if (octet1 != 0xaa || octet2 != 0xaa) {
7430           src = tvb_get_ptr (next_tvb, 6, 6);
7431           dst = tvb_get_ptr (next_tvb, 0, 6);
7432           if (memcmp(src, pinfo->dl_src.data, 6) == 0 ||
7433               memcmp(dst, pinfo->dl_dst.data, 6) == 0)
7434             encap_type = ENCAP_ETHERNET;
7435           else if (octet1 == 0xff && octet2 == 0xff)
7436             encap_type = ENCAP_IPX;
7437         }
7438       }
7439       CATCH2(BoundsError, ReportedBoundsError) {
7440       ; /* do nothing */
7441
7442       }
7443       ENDTRY;
7444
7445       switch (encap_type) {
7446
7447       case ENCAP_802_2:
7448         call_dissector(llc_handle, next_tvb, pinfo, tree);
7449         break;
7450
7451       case ENCAP_ETHERNET:
7452         call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
7453         break;
7454
7455       case ENCAP_IPX:
7456         call_dissector(ipx_handle, next_tvb, pinfo, tree);
7457         break;
7458       }
7459       break;
7460     }
7461   pinfo->fragmented = save_fragmented;
7462
7463   end_of_wlan:
7464   whdr->stats = wlan_stats;
7465   tap_queue_packet(wlan_tap, pinfo, whdr);
7466   memset (&wlan_stats, 0, sizeof wlan_stats);
7467 }
7468
7469 /*
7470  * Dissect 802.11 with a variable-length link-layer header.
7471  */
7472 static void
7473 dissect_ieee80211 (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7474 {
7475   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7476       pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, FALSE, FALSE);
7477 }
7478
7479 /*
7480  * Dissect 802.11 with a variable-length link-layer header and data padding.
7481  */
7482 static void
7483 dissect_ieee80211_datapad (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7484 {
7485   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7486       pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, TRUE, FALSE);
7487 }
7488
7489 /*
7490  * Dissect 802.11 with a variable-length link-layer header and a pseudo-
7491  * header containing radio information.
7492  */
7493 static void
7494 dissect_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7495 {
7496   proto_item *ti = NULL;
7497   proto_tree *radio_tree = NULL;
7498
7499   if (check_col(pinfo->cinfo, COL_PROTOCOL))
7500       col_set_str(pinfo->cinfo, COL_PROTOCOL, "Radio");
7501   if (check_col(pinfo->cinfo, COL_INFO))
7502       col_clear(pinfo->cinfo, COL_INFO);
7503
7504   /* Add the radio information to the column information */
7505   if (check_col(pinfo->cinfo, COL_TX_RATE)) {
7506     col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
7507         pinfo->pseudo_header->ieee_802_11.data_rate / 2,
7508         pinfo->pseudo_header->ieee_802_11.data_rate & 1 ? 5 : 0);
7509   }
7510   if (check_col(pinfo->cinfo, COL_RSSI)) {
7511     /* XX - this is a percentage, not a dBm or normalized or raw RSSI */
7512     col_add_fstr(pinfo->cinfo, COL_RSSI, "%u",
7513         pinfo->pseudo_header->ieee_802_11.signal_level);
7514   }
7515
7516   if (tree) {
7517     ti = proto_tree_add_item(tree, proto_radio, tvb, 0, 0, FALSE);
7518     radio_tree = proto_item_add_subtree (ti, ett_radio);
7519
7520     proto_tree_add_uint64_format(radio_tree, hf_data_rate, tvb, 0, 0,
7521              (guint64)pinfo->pseudo_header->ieee_802_11.data_rate * 500000,
7522              "Data Rate: %u.%u Mb/s",
7523              pinfo->pseudo_header->ieee_802_11.data_rate / 2,
7524              pinfo->pseudo_header->ieee_802_11.data_rate & 1 ? 5 : 0);
7525
7526     proto_tree_add_uint(radio_tree, hf_channel, tvb, 0, 0,
7527             pinfo->pseudo_header->ieee_802_11.channel);
7528
7529     proto_tree_add_uint_format(radio_tree, hf_signal_strength, tvb, 0, 0,
7530             pinfo->pseudo_header->ieee_802_11.signal_level,
7531             "Signal Strength: %u%%",
7532             pinfo->pseudo_header->ieee_802_11.signal_level);
7533   }
7534
7535   pinfo->current_proto = "IEEE 802.11";
7536   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7537      pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, FALSE, FALSE);
7538 }
7539
7540 /*
7541  * Dissect 802.11 with a variable-length link-layer header and a byte-swapped
7542  * control field (some hardware sends out LWAPP-encapsulated 802.11
7543  * packets with the control field byte swapped).
7544  */
7545 static void
7546 dissect_ieee80211_bsfc (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7547 {
7548   dissect_ieee80211_common (tvb, pinfo, tree, FALSE, 0, TRUE, FALSE, FALSE);
7549 }
7550
7551 /*
7552  * Dissect 802.11 with a fixed-length link-layer header (padded to the
7553  * maximum length).
7554  */
7555 static void
7556 dissect_ieee80211_fixed (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7557 {
7558   dissect_ieee80211_common (tvb, pinfo, tree, TRUE, 0, FALSE, FALSE, FALSE);
7559 }
7560
7561 /*
7562  * Dissect an HT 802.11 frame with a variable-length link-layer header.
7563  * XXX - Can we tell if a frame is +HTC just by looking at the MAC header?
7564  * If so, we can dispense with this.
7565  */
7566 static void
7567 dissect_ieee80211_ht (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
7568 {
7569   dissect_ieee80211_common (tvb, pinfo, tree, FALSE,
7570       pinfo->pseudo_header->ieee_802_11.fcs_len, FALSE, FALSE, TRUE);
7571 }
7572
7573 static void
7574 wlan_defragment_init(void)
7575 {
7576   fragment_table_init(&wlan_fragment_table);
7577   reassembled_table_init(&wlan_reassembled_table);
7578 }
7579
7580 /* ------------- */
7581 static gboolean
7582 free_all(gpointer key_arg _U_, gpointer value _U_, gpointer user_data _U_)
7583 {
7584   return TRUE;
7585 }
7586
7587 static guint
7588 retransmit_hash(gconstpointer k)
7589 {
7590         const retransmit_key *key = (const retransmit_key *)k;
7591         guint hash_val;
7592         int i;
7593
7594         hash_val = 0;
7595         for (i = 0; i < 6; i++)
7596                 hash_val += key->bssid[i];
7597
7598         for (i = 0; i < 6; i++)
7599                 hash_val += key->src[i];
7600
7601         return hash_val;
7602 }
7603
7604 static gint
7605 retransmit_equal(gconstpointer k1, gconstpointer k2)
7606 {
7607   const retransmit_key *key1 = (const retransmit_key *)k1;
7608   const retransmit_key *key2 = (const retransmit_key *)k2;
7609
7610   return ( (!memcmp(key1->bssid, key2->bssid, 6) && !memcmp( key1->src, key2->src, 6))? TRUE:FALSE);
7611 }
7612
7613 static guint
7614 frame_hash(gconstpointer k)
7615 {
7616   guint32 frame = GPOINTER_TO_UINT(k);
7617
7618   return frame;
7619 }
7620
7621 static gint
7622 frame_equal(gconstpointer k1, gconstpointer k2)
7623 {
7624   guint32 frame1 = GPOINTER_TO_UINT(k1);
7625   guint32 frame2 = GPOINTER_TO_UINT(k2);
7626
7627   return frame1==frame2;
7628 }
7629
7630 static void
7631 wlan_retransmit_init(void)
7632 {
7633   if ( fc_analyse_retransmit_table ){
7634       g_hash_table_foreach_remove(fc_analyse_retransmit_table,free_all, NULL);
7635       g_hash_table_destroy(fc_analyse_retransmit_table);
7636       fc_analyse_retransmit_table = NULL;
7637   }
7638
7639   if( fc_first_frame_table ){
7640       g_hash_table_foreach_remove(fc_first_frame_table,free_all, NULL);
7641       g_hash_table_destroy(fc_first_frame_table);
7642       fc_first_frame_table = NULL;
7643   }
7644
7645   if (wlan_subdissector)
7646       return;
7647
7648   fc_analyse_retransmit_table= g_hash_table_new(retransmit_hash, retransmit_equal);
7649   fc_first_frame_table = g_hash_table_new( frame_hash, frame_equal);
7650
7651 }
7652
7653 /* ------------- */
7654
7655 /*
7656  * yah, I know, macros, ugh, but it makes the code
7657  * below more readable
7658  * XXX - This should be rewritten to use ptvcursors, then.
7659  */
7660 #define FIELD_PRESENT(name)     (hdr.name.status == 0 && hdr.name.did != 0)
7661 #define IFHELP(size, name, var, str) \
7662         if(tree) {                                                \
7663             proto_tree_add_uint_format(prism_tree, hf_prism_ ## name, \
7664                 tvb, offset, size, hdr.var, str, hdr.var);                \
7665         }                                                                 \
7666         offset += (size)
7667 #define INTFIELD(size, name, str)       IFHELP(size, name, name, str)
7668 #define VALFIELD(name, str) \
7669         if (FIELD_PRESENT(name)) {                                      \
7670             if(tree) {                                                  \
7671                 proto_tree_add_uint_format(prism_tree, hf_ ## name,     \
7672                     tvb, offset, 12, hdr.name.data,                     \
7673                     str ": 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",  \
7674                     hdr.name.data, hdr.name.did,                        \
7675                     hdr.name.status, hdr.name.len);                     \
7676             }                                                           \
7677         }                                                               \
7678         offset += 12
7679 #define VALFIELD_PRISM(name, str) \
7680         if (FIELD_PRESENT(name)) {                                      \
7681             if(tree) {                                            \
7682                 proto_tree_add_uint_format(prism_tree, hf_prism_ ## name ## _data, \
7683                     tvb, offset, 12, hdr.name.data,                        \
7684                     str ": 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",     \
7685                     hdr.name.data, hdr.name.did,                           \
7686                     hdr.name.status, hdr.name.len);                        \
7687             }                                                              \
7688         }                                                                  \
7689         offset += 12
7690
7691 static void
7692 dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
7693 {
7694     struct prism_hdr hdr;
7695     proto_tree *prism_tree = NULL;
7696     proto_item *ti;
7697     tvbuff_t *next_tvb;
7698     int offset;
7699     guint32 msgcode;
7700
7701     offset = 0;
7702
7703     /* handle the new capture type. */
7704     msgcode = tvb_get_ntohl(tvb, offset);
7705     if ((msgcode == WLANCAP_MAGIC_COOKIE_V1) ||
7706         (msgcode == WLANCAP_MAGIC_COOKIE_V2)) {
7707             call_dissector(wlancap_handle, tvb, pinfo, tree);
7708             return;
7709     }
7710
7711     tvb_memcpy(tvb, (guint8 *)&hdr, offset, sizeof(hdr));
7712
7713     if(check_col(pinfo->cinfo, COL_PROTOCOL))
7714         col_set_str(pinfo->cinfo, COL_PROTOCOL, "Prism");
7715     if(check_col(pinfo->cinfo, COL_INFO))
7716         col_clear(pinfo->cinfo, COL_INFO);
7717
7718     if(check_col(pinfo->cinfo, COL_INFO))
7719         col_add_fstr(pinfo->cinfo, COL_INFO, "Device: %.16s  "
7720                      "Message 0x%x, Length %d", hdr.devname,
7721                      hdr.msgcode, hdr.msglen);
7722
7723     if(tree) {
7724         ti = proto_tree_add_item(tree, proto_prism, tvb, 0, sizeof hdr, FALSE);
7725         prism_tree = proto_item_add_subtree(ti, ett_radio);
7726     }
7727
7728     INTFIELD(4, msgcode, "Message Code: %d");
7729     INTFIELD(4, msglen, "Message Length: %d");
7730     if(tree) {
7731         proto_tree_add_text(prism_tree, tvb, offset, sizeof hdr.devname,
7732             "Device: %s", hdr.devname);
7733     }
7734     offset += sizeof hdr.devname;
7735
7736     if (FIELD_PRESENT(hosttime)) {
7737       if(tree) {
7738         proto_tree_add_uint64_format(prism_tree, hf_hosttime,
7739             tvb, offset, 12, hdr.hosttime.data,
7740             "Host timestamp: 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",
7741             hdr.hosttime.data, hdr.hosttime.did,
7742             hdr.hosttime.status, hdr.hosttime.len);
7743       }
7744     }
7745     offset += 12;
7746     if (FIELD_PRESENT(mactime)) {
7747       if(tree) {
7748         proto_tree_add_uint64_format(prism_tree, hf_mactime,
7749             tvb, offset, 12, hdr.mactime.data,
7750             "MAC timestamp: 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",
7751             hdr.mactime.data, hdr.mactime.did,
7752             hdr.mactime.status, hdr.mactime.len);
7753       }
7754     }
7755     offset += 12;
7756     if (FIELD_PRESENT(channel)) {
7757       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
7758         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u", hdr.channel.data);
7759     }
7760     VALFIELD(channel, "Channel");
7761     if (FIELD_PRESENT(rssi)) {
7762       if (check_col(pinfo->cinfo, COL_RSSI))
7763         col_add_fstr(pinfo->cinfo, COL_RSSI, "%d", hdr.rssi.data);
7764       if (tree) {
7765         proto_tree_add_uint_format(prism_tree, hf_prism_rssi_data,
7766             tvb, offset, 12, hdr.rssi.data,
7767             "RSSI: 0x%x (DID 0x%x, Status 0x%x, Length 0x%x)",
7768             hdr.rssi.data, hdr.rssi.did, hdr.rssi.status, hdr.rssi.len);
7769       }
7770     }
7771     offset += 12;
7772     VALFIELD_PRISM(sq, "SQ");
7773     VALFIELD_PRISM(signal, "Signal");
7774     VALFIELD_PRISM(noise, "Noise");
7775     if (FIELD_PRESENT(rate)) {
7776       if (check_col(pinfo->cinfo, COL_TX_RATE)) {
7777         col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
7778                   hdr.rate.data / 2, hdr.rate.data & 1 ? 5 : 0);
7779       }
7780       if (tree) {
7781           proto_tree_add_uint64_format(prism_tree, hf_data_rate,
7782                   tvb, offset, 12, (guint64)hdr.rate.data * 500000,
7783                   "Data Rate: %u.%u Mb/s",
7784                   hdr.rate.data / 2, hdr.rate.data & 1 ? 5 : 0);
7785       }
7786     }
7787     offset += 12;
7788     VALFIELD_PRISM(istx, "IsTX");
7789     VALFIELD_PRISM(frmlen, "Frame Length");
7790
7791     /* dissect the 802.11 header next */
7792     next_tvb = tvb_new_subset(tvb, sizeof hdr, -1, -1);
7793     call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
7794 }
7795
7796 /*
7797  * AVS linux-wlan-based products use a new sniff header to replace the
7798  * old Prism header.  This one has additional fields, is designed to be
7799  * non-hardware-specific, and more importantly, version and length fields
7800  * so it can be extended later without breaking anything.
7801  *
7802  * Support by Solomon Peachy
7803  *
7804  * Description, from the capturefrm.txt file in the linux-wlan-ng 0.2.9
7805  * release (linux-wlan-ng-0.2.9/doc/capturefrm.txt):
7806  *
7807 AVS Capture Frame Format
7808 Version 2.1.1
7809
7810 1. Introduction
7811 The original header format for "monitor mode" or capturing frames was
7812 a considerable hack.  The document covers a redesign of that format.
7813
7814   Any questions, corrections, or proposed changes go to info@linux-wlan.com
7815
7816 2. Frame Format
7817 All sniff frames follow the same format:
7818
7819         Offset  Name            Size            Description
7820         --------------------------------------------------------------------
7821         0       CaptureHeader                   AVS capture metadata header
7822         64      802.11Header    [10-30]         802.11 frame header
7823         ??      802.11Payload   [0-2312]        802.11 frame payload
7824         ??      802.11FCS       4               802.11 frame check sequence
7825
7826 Note that the header and payload are variable length and the payload
7827 may be empty.
7828
7829 If the hardware does not supply the FCS to the driver, then the frame shall
7830 have a FCS of 0xFFFFFFFF.
7831
7832 3. Byte Order
7833 All multibyte fields of the capture header are in "network" byte
7834 order.  The "host to network" and "network to host" functions should
7835 work just fine.  All the remaining multibyte fields are ordered
7836 according to their respective standards.
7837
7838 4. Capture Header Format
7839 The following fields make up the AVS capture header:
7840
7841         Offset  Name            Type
7842         ------------------------------
7843         0       version         uint32
7844         4       length          uint32
7845         8       mactime         uint64
7846         16      hosttime        uint64
7847         24      phytype         uint32
7848         28      frequency       uint32
7849         32      datarate        uint32
7850         36      antenna         uint32
7851         40      priority        uint32
7852         44      ssi_type        uint32
7853         48      ssi_signal      int32
7854         52      ssi_noise       int32
7855         56      preamble        uint32
7856         60      encoding        uint32
7857         64      sequence        uint32
7858         68      drops           uint32
7859         72      receiver_addr   uint8[6]
7860         78      padding         uint8[2]
7861         ------------------------------
7862         80
7863
7864 The following subsections detail the fields of the capture header.
7865
7866 4.1 version
7867 The version field identifies this type of frame as a subtype of
7868 ETH_P_802111_CAPTURE as received by an ARPHRD_IEEE80211_PRISM or
7869 an ARPHRD_IEEE80211_CAPTURE device.  The value of this field shall be
7870 0x80211002.  As new revisions of this header are necessary, we can
7871 increment the version appropriately.
7872
7873 4.2 length
7874 The length field contains the length of the entire AVS capture header,
7875 in bytes.
7876
7877 4.3 mactime
7878 Many WLAN devices supply a relatively high resolution frame reception
7879 time value.  This field contains the value supplied by the device.  If
7880 the device does not supply a receive time value, this field shall be
7881 set to zero.  The units for this field are microseconds.  
7882
7883 If possible, this time value should be absolute, representing the number
7884 of microseconds elapsed since the UNIX epoch.
7885
7886 4.4 hosttime
7887 The hosttime field is set to the current value of the host maintained
7888 clock variable when the frame is received by the host. 
7889
7890 If possible, this time value should be absolute, representing the number 
7891 of microseconds elapsed since the UNIX epoch.
7892
7893 4.5 phytype
7894 The phytype field identifies what type of PHY is employed by the WLAN 
7895 device used to capture this frame.  The valid values are:
7896
7897         PhyType                         Value
7898         -------------------------------------
7899         phytype_fhss_dot11_97            1
7900         phytype_dsss_dot11_97            2
7901         phytype_irbaseband               3
7902         phytype_dsss_dot11_b             4
7903         phytype_pbcc_dot11_b             5
7904         phytype_ofdm_dot11_g             6
7905         phytype_pbcc_dot11_g             7
7906         phytype_ofdm_dot11_a             8
7907         phytype_dss_ofdm_dot11_g         9
7908
7909 4.6 frequency
7910
7911 This represents the frequency or channel number of the receiver at the 
7912 time the frame was received.  It is interpreted as follows:
7913
7914 For frequency hopping radios, this field is broken in to the 
7915 following subfields:
7916
7917         Byte    Subfield
7918         ------------------------
7919         Byte0   Hop Set
7920         Byte1   Hop Pattern
7921         Byte2   Hop Index
7922         Byte3   reserved
7923
7924 For non-hopping radios, the frequency is interpreted as follows:
7925
7926        Value                Meaning
7927     -----------------------------------------
7928        < 256           Channel number (using externally-defined
7929                          channelization)
7930        < 10000         Center frequency, in MHz
7931       >= 10000         Center frequency, in KHz
7932
7933 4.7 datarate
7934 The data rate field contains the rate at which the frame was received
7935 in units of 100kbps.
7936
7937 4.8 antenna
7938 For WLAN devices that indicate the receive antenna for each frame, the
7939 antenna field shall contain an index value into the dot11AntennaList.
7940 If the device does not indicate a receive antenna value, this field
7941 shall be set to zero.
7942
7943 4.9 priority
7944 The priority field indicates the receive priority of the frame.  The
7945 value is in the range [0-15] with the value 0 reserved to indicate
7946 contention period and the value 6 reserved to indicate contention free
7947 period.
7948
7949 4.10 ssi_type
7950 The ssi_type field is used to indicate what type of signal strength
7951 information is present: "None", "Normalized RSSI" or "dBm".  "None"
7952 indicates that the underlying WLAN device does not supply any signal
7953 strength at all and the ssi_* values are unset.  "Normalized RSSI"
7954 values are integers in the range [0-1000] where higher numbers
7955 indicate stronger signal.  "dBm" values indicate an actual signal 
7956 strength measurement quantity and are usually in the range [-108 - 10].
7957 The following values indicate the three types:
7958
7959         Value   Description
7960         ---------------------------------------------
7961         0       None
7962         1       Normalized RSSI
7963         2       dBm
7964         3       Raw RSSI
7965
7966 4.11 ssi_signal
7967 The ssi_signal field contains the signal strength value reported by
7968 the WLAN device for this frame.  Note that this is a signed quantity
7969 and if the ssi_type value is "dBm" that the value may be negative.
7970
7971 4.12 ssi_noise
7972 The ssi_noise field contains the noise or "silence" value reported by
7973 the WLAN device.  This value is commonly defined to be the "signal
7974 strength reported immediately prior to the baseband processor lock on
7975 the frame preamble".  If the hardware does not provide noise data, this
7976 shall equal 0xffffffff.
7977
7978 4.12 preamble
7979 For PHYs that support variable preamble lengths, the preamble field
7980 indicates the preamble type used for this frame.  The values are:
7981
7982         Value   Description
7983         ---------------------------------------------
7984         0       Undefined
7985         1       Short Preamble
7986         2       Long Preamble
7987
7988 4.13 encoding
7989 This specifies the encoding of the received packet.  For PHYs that support
7990 multiple encoding types, this will tell us which one was used.
7991
7992         Value   Description
7993         ---------------------------------------------
7994         0       Unknown
7995         1       CCK           
7996         2       PBCC
7997         3       OFDM
7998         4       DSSS-OFDM
7999         5       BPSK
8000         6       QPSK
8001         7       16QAM
8002         8       64QAM
8003
8004 4.14 sequence
8005 This is a receive frame sequence counter.  The sniff host shall 
8006 increment this by one for every valid frame received off the medium.
8007 By watching for gaps in the sequence numbers we can determine when 
8008 packets are lost due to unreliable transport, rather than a frame never 
8009 being received to begin with.
8010
8011 4.15 drops
8012 This is a counter of the number of known frame drops that occured.  This 
8013 is particularly useful when the system or hardware cannot keep up with 
8014 the sniffer load.
8015
8016 4.16 receiver_addr
8017 This specifies the MAC address of the receiver of this frame.  
8018 It is six octets in length.  This field is followed by two octets of 
8019 padding to keep the structure 32-bit word aligned.
8020
8021 ================================
8022
8023 Changes: v2->v2.1
8024
8025  * Added contact e-mail address to introduction
8026  * Added sniffer_addr, drop count, and sequence fields, bringing total 
8027    length to 80 bytes
8028  * Bumped version to 0x80211002
8029  * Mactime is specified in microseconds, not nanoseconds
8030  * Added 64QAM, 16QAM, BPSK, QPSK encodings
8031
8032 ================================
8033
8034 Changes: v2.1->v2.1.1
8035
8036  * Renamed 'channel' to 'frequency'
8037  * Clarified the interpretation of the frequency/channel field.
8038  * Renamed 'sniffer address' to 'receiver address'
8039  * Clarified timestamp fields.
8040  */
8041
8042 /*
8043  * Signal/noise strength type values.
8044  */
8045 #define SSI_NONE        0       /* no SSI information */
8046 #define SSI_NORM_RSSI   1       /* normalized RSSI - 0-1000 */
8047 #define SSI_DBM         2       /* dBm */
8048 #define SSI_RAW_RSSI    3       /* raw RSSI from the hardware */
8049
8050 static void
8051 dissect_wlancap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
8052 {
8053     proto_tree *wlan_tree = NULL;
8054     proto_item *ti;
8055     tvbuff_t *next_tvb;
8056     int offset;
8057     guint32 version;
8058     guint32 length;
8059     guint32 channel;
8060     guint32 datarate;
8061     guint32 ssi_type;
8062     guint32 antnoise;
8063
8064     if(check_col(pinfo->cinfo, COL_PROTOCOL))
8065         col_set_str(pinfo->cinfo, COL_PROTOCOL, "WLAN");
8066     if(check_col(pinfo->cinfo, COL_INFO))
8067         col_clear(pinfo->cinfo, COL_INFO);
8068     offset = 0;
8069
8070     version = tvb_get_ntohl(tvb, offset) - WLANCAP_MAGIC_COOKIE_BASE;
8071
8072     length = tvb_get_ntohl(tvb, offset+4);
8073
8074     if(check_col(pinfo->cinfo, COL_INFO))
8075         col_add_fstr(pinfo->cinfo, COL_INFO, "AVS WLAN Capture v%x, Length %d",version, length);
8076
8077     if (version > 2) {
8078       goto skip;
8079     }
8080
8081     /* Dissect the AVS header */
8082     if (tree) {
8083       ti = proto_tree_add_item(tree, proto_wlancap, tvb, 0, length, FALSE);
8084       wlan_tree = proto_item_add_subtree(ti, ett_radio);
8085       proto_tree_add_item(wlan_tree, hf_wlan_magic, tvb, offset, 4, FALSE);
8086       proto_tree_add_item(wlan_tree, hf_wlan_version, tvb, offset, 4, FALSE);
8087     }
8088     offset+=4;
8089     if (tree)
8090       proto_tree_add_item(wlan_tree, hf_wlan_length, tvb, offset, 4, FALSE);
8091     offset+=4;
8092     if (tree)
8093       proto_tree_add_item(wlan_tree, hf_mactime, tvb, offset, 8, FALSE);
8094     offset+=8;
8095     if (tree)
8096       proto_tree_add_item(wlan_tree, hf_hosttime, tvb, offset, 8, FALSE);
8097     offset+=8;
8098     if (tree)
8099       proto_tree_add_item(wlan_tree, hf_wlan_phytype, tvb, offset, 4, FALSE);
8100     offset+=4;
8101
8102     /* XXX cook channel (fh uses different numbers) */
8103     channel = tvb_get_ntohl(tvb, offset);
8104     if (channel < 256) {
8105       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
8106         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u", channel);
8107       if (tree)
8108         proto_tree_add_uint(wlan_tree, hf_channel, tvb, offset, 4, channel);
8109     } else if (channel < 10000) {
8110       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
8111         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u MHz", channel);
8112       if (tree)
8113         proto_tree_add_uint_format(wlan_tree, hf_channel_frequency, tvb, offset,
8114                                    4, channel, "Frequency: %u MHz", channel);
8115     } else {
8116       if (check_col(pinfo->cinfo, COL_FREQ_CHAN))
8117         col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%u KHz", channel);
8118       if (tree)
8119         proto_tree_add_uint_format(wlan_tree, hf_channel_frequency, tvb, offset,
8120                                    4, channel, "Frequency: %u KHz", channel);
8121     }
8122     offset+=4;
8123     datarate = tvb_get_ntohl(tvb, offset);
8124     if (datarate < 100000) {
8125       /* In units of 100 Kb/s; convert to b/s */
8126       datarate *= 100000;
8127     }
8128     if (check_col(pinfo->cinfo, COL_TX_RATE)) {
8129       col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
8130                    datarate / 1000000,
8131                    ((datarate % 1000000) > 500000) ? 5 : 0);
8132     }
8133     if (tree) {
8134       proto_tree_add_uint64_format(wlan_tree, hf_data_rate, tvb, offset, 4,
8135                                    datarate,
8136                                    "Data Rate: %u.%u Mb/s",
8137                                    datarate/1000000,
8138                                    ((datarate % 1000000) > 500000) ? 5 : 0);
8139     }
8140     offset+=4;
8141     if (tree)
8142       proto_tree_add_item(wlan_tree, hf_wlan_antenna, tvb, offset, 4, FALSE);
8143     offset+=4;
8144     if (tree)
8145       proto_tree_add_item(wlan_tree, hf_wlan_priority, tvb, offset, 4, FALSE);
8146     offset+=4;
8147     ssi_type = tvb_get_ntohl(tvb, offset);
8148     if (tree)
8149       proto_tree_add_uint(wlan_tree, hf_wlan_ssi_type, tvb, offset, 4, ssi_type);
8150     offset+=4;
8151     switch (ssi_type) {
8152
8153     case SSI_NONE:
8154     default:
8155       /* either there is no SSI information, or we don't know what type it is */
8156       break;
8157
8158     case SSI_NORM_RSSI:
8159       /* Normalized RSSI */
8160       if (check_col(pinfo->cinfo, COL_RSSI))
8161         col_add_fstr(pinfo->cinfo, COL_RSSI, "%u (norm)", tvb_get_ntohl(tvb, offset));
8162       if (tree)
8163         proto_tree_add_item(wlan_tree, hf_normrssi_antsignal, tvb, offset, 4, FALSE);
8164       break;
8165
8166     case SSI_DBM:
8167       /* dBm */
8168       if (check_col(pinfo->cinfo, COL_RSSI))
8169         col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm", tvb_get_ntohl(tvb, offset));
8170       if (tree)
8171         proto_tree_add_item(wlan_tree, hf_dbm_antsignal, tvb, offset, 4, FALSE);
8172       break;
8173
8174     case SSI_RAW_RSSI:
8175       /* Raw RSSI */
8176       if (check_col(pinfo->cinfo, COL_RSSI))
8177         col_add_fstr(pinfo->cinfo, COL_RSSI, "%u (raw)", tvb_get_ntohl(tvb, offset));
8178       if (tree)
8179         proto_tree_add_item(wlan_tree, hf_rawrssi_antsignal, tvb, offset, 4, FALSE);
8180       break;
8181     }
8182     offset+=4;
8183     antnoise = tvb_get_ntohl(tvb, offset);
8184     /* 0xffffffff means "hardware does not provide noise data" */
8185     if (antnoise != 0xffffffff) {
8186       switch (ssi_type) {
8187
8188       case SSI_NONE:
8189       default:
8190         /* either there is no SSI information, or we don't know what type it is */
8191         break;
8192
8193       case SSI_NORM_RSSI:
8194         /* Normalized RSSI */
8195         if (tree)
8196           proto_tree_add_uint(wlan_tree, hf_normrssi_antnoise, tvb, offset, 4, antnoise);
8197         break;
8198
8199       case SSI_DBM:
8200         /* dBm */
8201         if (tree)
8202           proto_tree_add_int(wlan_tree, hf_dbm_antnoise, tvb, offset, 4, antnoise);
8203         break;
8204
8205       case SSI_RAW_RSSI:
8206         /* Raw RSSI */
8207         if (tree)
8208           proto_tree_add_uint(wlan_tree, hf_rawrssi_antnoise, tvb, offset, 4, antnoise);
8209         break;
8210       }
8211     }
8212     offset+=4;
8213     if (tree)
8214       proto_tree_add_item(wlan_tree, hf_wlan_preamble, tvb, offset, 4, FALSE);
8215     offset+=4;
8216     if (tree)
8217       proto_tree_add_item(wlan_tree, hf_wlan_encoding, tvb, offset, 4, FALSE);
8218     offset+=4;
8219     if (version > 1) {
8220       if (tree)
8221         proto_tree_add_item(wlan_tree, hf_wlan_sequence, tvb, offset, 4, FALSE);
8222       offset+=4;
8223       if (tree)
8224         proto_tree_add_item(wlan_tree, hf_wlan_drops, tvb, offset, 4, FALSE);
8225       offset+=4;
8226       if (tree)
8227         proto_tree_add_item(wlan_tree, hf_wlan_receiver_addr, tvb, offset, 6, FALSE);
8228       offset+=6;
8229       if (tree)
8230         proto_tree_add_item(wlan_tree, hf_wlan_padding, tvb, offset, 2, FALSE);
8231       offset+=2;
8232     }
8233
8234
8235  skip:
8236     offset = length;
8237
8238     /* dissect the 802.11 header next */
8239     next_tvb = tvb_new_subset(tvb, offset, -1, -1);
8240     call_dissector(ieee80211_handle, next_tvb, pinfo, tree);
8241 }
8242
8243 void
8244 proto_register_ieee80211 (void)
8245 {
8246   int i;
8247   GString *key_name, *key_title, *key_desc;
8248
8249   static const value_string frame_type[] = {
8250     {MGT_FRAME,     "Management frame"},
8251     {CONTROL_FRAME, "Control frame"},
8252     {DATA_FRAME,    "Data frame"},
8253     {0,             NULL}
8254   };
8255
8256   static const value_string tofrom_ds[] = {
8257     {0,                       "Not leaving DS or network is operating "
8258       "in AD-HOC mode (To DS: 0 From DS: 0)"},
8259     {FLAG_TO_DS,              "Frame from STA to DS via an AP (To DS: 1 "
8260       "From DS: 0)"},
8261     {FLAG_FROM_DS,            "Frame from DS to a STA via AP(To DS: 0 "
8262       "From DS: 1)"},
8263     {FLAG_TO_DS|FLAG_FROM_DS, "Frame part of WDS from one AP to another "
8264       "AP (To DS: 1 From DS: 1)"},
8265     {0, NULL}
8266   };
8267
8268   static const true_false_string tods_flag = {
8269     "Frame is entering DS",
8270     "Frame is not entering DS"
8271   };
8272
8273   static const true_false_string fromds_flag = {
8274     "Frame is exiting DS",
8275     "Frame is not exiting DS"
8276   };
8277
8278   static const true_false_string more_frags = {
8279     "More fragments follow",
8280     "This is the last fragment"
8281   };
8282
8283   static const true_false_string retry_flags = {
8284     "Frame is being retransmitted",
8285     "Frame is not being retransmitted"
8286   };
8287
8288   static const true_false_string pm_flags = {
8289     "STA will go to sleep",
8290     "STA will stay up"
8291   };
8292
8293   static const true_false_string md_flags = {
8294     "Data is buffered for STA at AP",
8295     "No data buffered"
8296   };
8297
8298   static const true_false_string protected_flags = {
8299     "Data is protected",
8300     "Data is not protected"
8301   };
8302
8303   static const true_false_string order_flags = {
8304     "Strictly ordered",
8305     "Not strictly ordered"
8306   };
8307
8308   static const true_false_string cf_ess_flags = {
8309     "Transmitter is an AP",
8310     "Transmitter is a STA"
8311   };
8312
8313
8314   static const true_false_string cf_privacy_flags = {
8315     "AP/STA can support WEP",
8316     "AP/STA cannot support WEP"
8317   };
8318
8319   static const true_false_string cf_preamble_flags = {
8320     "Short preamble allowed",
8321     "Short preamble not allowed"
8322   };
8323
8324   static const true_false_string cf_pbcc_flags = {
8325     "PBCC modulation allowed",
8326     "PBCC modulation not allowed"
8327   };
8328
8329   static const true_false_string cf_agility_flags = {
8330     "Channel agility in use",
8331     "Channel agility not in use"
8332   };
8333
8334   static const true_false_string short_slot_time_flags = {
8335     "Short slot time in use",
8336     "Short slot time not in use"
8337   };
8338
8339   static const true_false_string dsss_ofdm_flags = {
8340     "DSSS-OFDM modulation allowed",
8341     "DSSS-OFDM modulation not allowed"
8342   };
8343
8344   static const true_false_string cf_spec_man_flags = {
8345     "dot11SpectrumManagementRequired TRUE",
8346     "dot11SpectrumManagementRequired FALSE"
8347   };
8348
8349   static const true_false_string cf_apsd_flags = {
8350     "apsd implemented",
8351     "apsd not implemented"
8352   };
8353
8354   static const true_false_string cf_del_blk_ack_flags = {
8355     "delayed block ack implemented",
8356     "delayed block ack not implemented"
8357   };
8358
8359   static const true_false_string cf_imm_blk_ack_flags = {
8360     "immediate block ack implemented",
8361     "immediate block ack not implemented"
8362   };
8363   static const true_false_string cf_ibss_flags = {
8364     "Transmitter belongs to an IBSS",
8365     "Transmitter belongs to a BSS"
8366   };
8367
8368   static const true_false_string eosp_flag = {
8369     "End of service period",
8370     "Service period"
8371   };
8372
8373   static const true_false_string hf_qos_amsdu_present_flag = {
8374     "A-MSDU",
8375     "MSDU"
8376   };
8377
8378   static const value_string sta_cf_pollable[] = {
8379     {0x00, "Station is not CF-Pollable"},
8380     {0x02, "Station is CF-Pollable, "
8381      "not requesting to be placed on the  CF-polling list"},
8382     {0x01, "Station is CF-Pollable, "
8383      "requesting to be placed on the CF-polling list"},
8384     {0x03, "Station is CF-Pollable, requesting never to be polled"},
8385     {0x0200, "QSTA requesting association in QBSS"},
8386     {0, NULL}
8387   };
8388
8389   static const value_string ap_cf_pollable[] = {
8390     {0x00, "No point coordinator at AP"},
8391     {0x02, "Point coordinator at AP for delivery only (no polling)"},
8392     {0x01, "Point coordinator at AP for delivery and polling"},
8393     {0x03, "Reserved"},
8394     {0x0200, "QAP (HC) does not use CFP for delivery of unicast data type frames"},
8395     {0x0202, "QAP (HC) uses CFP for delivery, but does not send CF-Polls to non-QoS STAs"},
8396     {0x0201, "QAP (HC) uses CFP for delivery, and sends CF-Polls to non-QoS STAs"},
8397     {0x0203, "Reserved"},
8398     {0, NULL}
8399   };
8400
8401
8402   static const value_string auth_alg[] = {
8403     {0x00, "Open System"},
8404     {0x01, "Shared key"},
8405     {0x80, "Network EAP"},  /* Cisco proprietary? */
8406     {0, NULL}
8407   };
8408
8409   /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
8410   static const true_false_string ff_block_ack_params_amsdu_permitted_flag = {
8411     "Permitted in QoS Data MPDUs",
8412     "Not Permitted"
8413   };
8414
8415   static const true_false_string ff_block_ack_params_policy_flag = {
8416     "Immediate Block Ack",
8417     "Delayed Block Ack"
8418   };
8419   /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
8420
8421   /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
8422   static const value_string  ff_channel_width_vals[] = {
8423     {0x00, "20 MHz channel width only"},
8424     {0x01, "Any channel width in the STA\92s Supported Channel Width Set"},
8425     {0, NULL}
8426   };
8427   /*** End: Channel Width Fixed Field - Dustin Johnson ***/
8428
8429   /*** Begin: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
8430   static const true_false_string ff_qos_info_ap_q_ack_flag = {
8431       "Implemented",
8432       "Not Implemented"
8433   };
8434
8435   static const true_false_string ff_qos_info_ap_queue_req_flag = {
8436       "Can process a nonzero Queue Size subfield in the QoS Control field in QoS data frames",
8437       "Can NOT process a nonzero Queue Size subfield in the QoS Control field in QoS data frames"
8438   };
8439
8440   static const true_false_string ff_qos_info_ap_txop_request_flag = {
8441       "Can process a nonzero TXOP Duration Requested subfield in the QoS Control field in QoS data frames",
8442       "Can NOT process a nonzero TXOP Duration Requested subfield in the QoS Control field in QoS data frames"
8443   };
8444   /*** End: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
8445
8446   /*** Begin: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
8447   static const true_false_string ff_qos_info_sta_ac_flag = {
8448       "Trigger-enabled and Delivery-enabled",
8449       "Neither Trigger-enabled nor Delivery-enabled"
8450   };
8451
8452   static const true_false_string ff_qos_info_sta_q_ack_flag = {
8453       "Implemented",
8454       "Not Implemented"
8455   };
8456
8457   static const value_string ff_qos_info_sta_max_sp_len_flags[] = {
8458     {0x00, "AP may deliver all buffered MSDUs, A-MSDUs and MMPDUs"},
8459     {0x01, "AP may deliver a maximum of two MSDUs and MMPDUs per SP"},
8460     {0x02, "AP may deliver a maximum of four MSDUs and MMPDUs per SP"},
8461     {0x03, "AP may deliver a maximum of six MSDUs and MMPDUs per SP"},
8462     {0, NULL}
8463   };
8464
8465   static const true_false_string ff_qos_info_sta_more_data_ack_flag = {
8466       "Can process ACK frames with the More Data bit in the Frame Control field set to 1",
8467       "Can NOT process ACK frames with the More Data bit in the Frame Control field set to 1"
8468   };
8469   /*** End: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
8470
8471   /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
8472   static const true_false_string ff_sm_pwr_save_enabled_flag = {
8473       "Enabled",
8474       "Disabled"
8475   };
8476
8477   static const true_false_string ff_sm_pwr_save_sm_mode_flag = {
8478       "Dynamic SM Power Save mode",
8479       "Static SM Power Save mode"
8480   };
8481   /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
8482
8483   /*** Begin: PCO Phase Control Fixed Field - Dustin Johnson ***/
8484   static const true_false_string ff_pco_phase_cntrl_flag = {
8485       "40 MHz Phase",
8486       "20 MHz Phase"
8487   };
8488   /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
8489
8490   /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
8491   static const true_false_string ff_psmp_param_set_more_psmp_flag = {
8492       "More PSMP Sequences Follow",
8493       "No PSMP Sequences Follow"
8494   };
8495   /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
8496
8497   /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
8498   static const value_string ff_mimo_cntrl_nc_index_flags[] = {
8499     {0x00, "1 Column"},
8500     {0x01, "2 Columns"},
8501     {0x02, "3 Columns"},
8502     {0x03, "4 Columns"},
8503     {0, NULL}
8504   };
8505
8506   static const value_string ff_mimo_cntrl_nr_index_flags[] = {
8507     {0x00, "1 Row"},
8508     {0x01, "2 Rows"},
8509     {0x02, "3 Rows"},
8510     {0x03, "4 Rows"},
8511     {0, NULL}
8512   };
8513
8514   static const true_false_string ff_mimo_cntrl_channel_width_flag = {
8515       "40 MHz",
8516       "20 MHz"
8517   };
8518
8519   /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
8520   static const true_false_string ff_ht_info_information_request_flag = {
8521       "Requesting HT Information Exchange management action frame",
8522       "Should not send an HT Information Exchange management action frame"
8523   };
8524
8525   static const true_false_string ff_ht_info_40_mhz_intolerant_flag = {
8526       "Transmitting station is intolerant of 40 MHz operation",
8527       "Transmitting station permits 40 MHz operation"
8528   };
8529
8530   static const true_false_string ff_ht_info_sta_chan_width_flag = {
8531       "40 MHz",
8532       "20 MHz"
8533   };
8534   /*** End: HT Information Fixed Field - Dustin Johnson ***/
8535
8536   /*** Begin: HT Category Fixed Field - Dustin Johnson ***/
8537   static const value_string ff_ht_action_flags[] = {
8538     {HT_ACTION_NOTIFY_CHAN_WIDTH, "Notify Channel Width"},
8539     {HT_ACTION_SM_PWR_SAVE, "Spatial Multiplexing (SM) Power Save"},
8540     {HT_ACTION_PSMP_ACTION, "Power Save Multi-Poll (PSMP) action frame"},
8541     {HT_ACTION_SET_PCO_PHASE, "Set PCO Phase"},
8542     {HT_ACTION_MIMO_CSI, "MIMO CSI Matrices"},
8543     {HT_ACTION_MIMO_BEAMFORMING, "MIMO Non-compressed Beamforming"},
8544     {HT_ACTION_MIMO_COMPRESSED_BEAMFORMING, "MIMO Compressed Beamforming"},
8545     {HT_ACTION_ANT_SEL_FEEDBACK, "Antenna Selection Indices Feedback"},
8546     {HT_ACTION_HT_INFO_EXCHANGE, "HT Information Exchange"},
8547     {0x00, NULL}
8548   };
8549   /*** Begin: HT Category Fixed Field - Dustin Johnson ***/
8550
8551   static const value_string ff_mimo_cntrl_grouping_flags[] = {
8552     {0x00, "No Grouping"},
8553     {0x01, "Carrier Groups of 2"},
8554     {0x02, "Carrier Groups of 4"},
8555     {0x03, "Reserved"},
8556     {0, NULL}
8557   };
8558
8559   static const value_string ff_mimo_cntrl_coefficient_size_flags[] = {
8560     {0x00, "4 Bits"},
8561     {0x01, "5 Bits"},
8562     {0x02, "6 Bits"},
8563     {0x03, "8 Bits"},
8564     {0, NULL}
8565   };
8566
8567   static const value_string ff_mimo_cntrl_codebook_info_flags[] = {
8568     {0x00, "1 bit for 'Capital Psi', 3 bits for 'Small Psi'"},
8569     {0x01, "2 bit for 'Capital Psi', 4 bits for 'Small Psi'"},
8570     {0x02, "3 bit for 'Capital Psi', 5 bits for 'Small Psi'"},
8571     {0x03, "4 bit for 'Capital Psi', 6 bits for 'Small Psi'"},
8572     {0, NULL}
8573   };
8574   /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
8575
8576   /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
8577   static const value_string ff_psmp_sta_info_flags[] = {
8578     {0x00, "Broadcast"},
8579     {0x01, "Multicast"},
8580     {0x02, "Individually Addressed"},
8581     {0x03, "Unknown"},
8582     {0, NULL}
8583   };
8584   /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
8585
8586   static const value_string reason_codes[] = {
8587     {0x00, "Reserved"},
8588     {0x01, "Unspecified reason"},
8589     {0x02, "Previous authentication no longer valid"},
8590     {0x03, "Deauthenticated because sending STA is leaving (has left) "
8591      "IBSS or ESS"},
8592     {0x04, "Disassociated due to inactivity"},
8593     {0x05, "Disassociated because AP is unable to handle all currently "
8594      "associated stations"},
8595     {0x06, "Class 2 frame received from nonauthenticated station"},
8596     {0x07, "Class 3 frame received from nonassociated station"},
8597     {0x08, "Disassociated because sending STA is leaving (has left) BSS"},
8598     {0x09, "Station requesting (re)association is not authenticated with "
8599       "responding station"},
8600     {0x0A, "Disassociated because the information in the Power Capability "
8601       "element is unacceptable"},
8602     {0x0B, "Disassociated because the information in the Supported"
8603       "Channels element is unacceptable"},
8604     {0x0D, "Invalid Information Element"},
8605     {0x0E, "Michael MIC failure"},
8606     {0x0F, "4-Way Handshake timeout"},
8607     {0x10, "Group key update timeout"},
8608     {0x11, "Information element in 4-Way Handshake different from "
8609      "(Re)Association Request/Probe Response/Beacon"},
8610     {0x12, "Group Cipher is not valid"},
8611     {0x13, "Pairwise Cipher is not valid"},
8612     {0x14, "AKMP is not valid"},
8613     {0x15, "Unsupported RSN IE version"},
8614     {0x16, "Invalid RSN IE Capabilities"},
8615     {0x17, "IEEE 802.1X Authentication failed"},
8616     {0x18, "Cipher suite is rejected per security policy"},
8617     {0x20, "Disassociated for unspecified, QoS-related reason"},
8618     {0x21, "Disassociated because QoS AP lacks sufficient bandwidth for this QoS STA"},
8619     {0x22, "Disassociated because of excessive number of frames that need to be "
8620       "acknowledged, but are not acknowledged for AP transmissions and/or poor "
8621       "channel conditions"},
8622     {0x23, "Disassociated because STA is transmitting outside the limits of its TXOPs"},
8623     {0x24, "Requested from peer STA as the STA is leaving the BSS (or resetting)"},
8624     {0x25, "Requested from peer STA as it does not want to use the mechanism"},
8625     {0x26, "Requested from peer STA as the STA received frames using the mechanism "
8626       "for which a set up is required"},
8627     {0x27, "Requested from peer STA due to time out"},
8628     {0x2D, "Peer STA does not support the requested cipher suite"},
8629     {0x2E, "Association denied due to requesting STA not supporting HT features"},
8630     {0x00, NULL}
8631   };
8632
8633
8634   static const value_string status_codes[] = {
8635     {0x00, "Successful"},
8636     {0x01, "Unspecified failure"},
8637     {0x0A, "Cannot support all requested capabilities in the "
8638      "Capability information field"},
8639     {0x0B, "Reassociation denied due to inability to confirm that "
8640      "association exists"},
8641     {0x0C, "Association denied due to reason outside the scope of this "
8642      "standard"},
8643
8644     {0x0D, "Responding station does not support the specified authentication "
8645      "algorithm"},
8646     {0x0E, "Received an Authentication frame with authentication sequence "
8647      "transaction sequence number out of expected sequence"},
8648     {0x0F, "Authentication rejected because of challenge failure"},
8649     {0x10, "Authentication rejected due to timeout waiting for next "
8650      "frame in sequence"},
8651     {0x11, "Association denied because AP is unable to handle additional "
8652      "associated stations"},
8653     {0x12, "Association denied due to requesting station not supporting all "
8654      "of the datarates in the BSSBasicServiceSet Parameter"},
8655     {0x13, "Association denied due to requesting station not supporting "
8656      "short preamble operation"},
8657     {0x14, "Association denied due to requesting station not supporting "
8658      "PBCC encoding"},
8659     {0x15, "Association denied due to requesting station not supporting "
8660      "channel agility"},
8661     {0x16, "Association request rejected because Spectrum Management"
8662       "capability is required"},
8663     {0x17, "Association request rejected because the information in the"
8664       "Power Capability element is unacceptable"},
8665     {0x18, "Association request rejected because the information in the"
8666       "Supported Channels element is unacceptable"},
8667     {0x19, "Association denied due to requesting station not supporting "
8668      "short slot operation"},
8669     {0x1A, "Association denied due to requesting station not supporting "
8670      "DSSS-OFDM operation"},
8671     {0x20, "Unspecified, QoS-related failure"},
8672     {0x21, "Association denied due to QAP having insufficient bandwidth "
8673       "to handle another QSTA"},
8674     {0x22, "Association denied due to excessive frame loss rates and/or "
8675       "poor conditions on current operating channel"},
8676     {0x23, "Association (with QBSS) denied due to requesting station not "
8677       "supporting the QoS facility"},
8678     {0x24, "Association denied due to requesting station not supporting "
8679       "Block Ack"},
8680     {0x25, "The request has been declined."},
8681     {0x26, "The request has not been successful as one or more parameters "
8682       "have invalid values."},
8683     {0x27, "The TS has not been created because the request cannot be honored. "
8684       "However, a suggested TSPEC is provided so that the initiating QSTA may "
8685       "attempt to set another TS with the suggested changes to the TSPEC."},
8686     {0x28, "Invalid Information Element"},
8687     {0x29, "Group Cipher is not valid"},
8688     {0x2A, "Pairwise Cipher is not valid"},
8689     {0x2B, "AKMP is not valid"},
8690     {0x2C, "Unsupported RSN IE version"},
8691     {0x2D, "Invalid RSN IE Capabilities"},
8692     {0x2E, "Cipher suite is rejected per security policy"},
8693     {0x2F, "The TS has not been created. However, the HC may be capable of "
8694       "creating a TS, in response to a request, after the time indicated in the TS Delay element."},
8695     {0x30, "Direct Link is not allowed in the BSS by policy"},
8696     {0x31, "Destination STA is not present within this QBSS."},
8697     {0x32, "The Destination STA is not a QSTA."},
8698     {0x00, NULL}
8699   };
8700
8701   static const value_string category_codes[] = {
8702     {CAT_SPECTRUM_MGMT, "Spectrum Management (SM)"},
8703     {CAT_QOS, "Quality of Service (QoS)"},
8704     {CAT_DLS, "Direct-Link Setup (DLS)"},
8705     {CAT_BLOCK_ACK, "Block Ack"},
8706     {CAT_RADIO_MEASUREMENT, "Radio Measurement"},
8707     {CAT_HT, "High Throughput"},
8708     {CAT_MGMT_NOTIFICATION, "Management Notification"},
8709     {CAT_VENDOR_SPECIFIC, "Vendor Specific"},
8710     {0, NULL}
8711   };
8712
8713   static const value_string action_codes[] ={
8714     {SM_ACTION_MEASUREMENT_REQUEST, "Measurement Request"},
8715     {SM_ACTION_MEASUREMENT_REPORT, "Measurement Report"},
8716     {SM_ACTION_TPC_REQUEST, "TPC Request"},
8717     {SM_ACTION_TPC_REPORT, "TPC Report"},
8718     {SM_ACTION_CHAN_SWITCH_ANNC, "Channel Switch Announcement"},
8719     {0, NULL}
8720   };
8721
8722   static const value_string vendor_action_types_mrvl[] ={
8723     {MRVL_ACTION_MESH_MANAGEMENT, "Mesh Management"},
8724     {0, NULL}
8725   };
8726
8727   static const value_string mesh_mgt_action_codes_mrvl[] ={
8728     {MRVL_MESH_MGMT_ACTION_RREQ, "Route Request"},
8729     {MRVL_MESH_MGMT_ACTION_RREP, "Route Response"},
8730     {MRVL_MESH_MGMT_ACTION_RERR, "Route Error"},
8731     {MRVL_MESH_MGMT_ACTION_PLDM, "Peer Link Down"},
8732     {0, NULL}
8733   };
8734
8735   static const value_string mesh_path_selection_codes[] ={
8736     {0x0, "Hybrid Wireless Mesh Protocol"},
8737     {0, NULL}
8738   };
8739
8740   static const value_string mesh_metric_codes[] ={
8741     {0x0, "Airtime Link Metric"},
8742     {0, NULL}
8743   };
8744
8745   static const value_string wme_action_codes[] = {
8746     {0x00, "Setup request"},
8747     {0x01, "Setup response"},
8748     {0x02, "Teardown"},
8749     {0x00, NULL}
8750   };
8751
8752   static const value_string wme_status_codes[] = {
8753     {0x00, "Admission accepted"},
8754     {0x01, "Invalid parameters"},
8755     {0x03, "Refused"},
8756     {0x00, NULL}
8757   };
8758
8759   static const value_string ack_policy[] = {
8760     {0x00, "Normal Ack"},
8761     {0x01, "No Ack"},
8762     {0x02, "No explicit acknowledgment"},
8763     {0x03, "Block Ack"},
8764     {0x00, NULL}
8765   };
8766
8767   static const value_string qos_action_codes[] = {
8768     {SM_ACTION_ADDTS_REQUEST, "ADDTS Request"},
8769     {SM_ACTION_ADDTS_RESPONSE, "ADDTS Response"},
8770     {SM_ACTION_DELTS, "DELTS"},
8771     {SM_ACTION_QOS_SCHEDULE, "Schedule"},
8772     {0, NULL}
8773   };
8774
8775   /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
8776   static const value_string ba_action_codes[] = {
8777     {BA_ADD_BLOCK_ACK_REQUEST, "Add Block Ack Request"},
8778     {BA_ADD_BLOCK_ACK_RESPONSE, "Add Block Ack Response"},
8779     {BA_DELETE_BLOCK_ACK, "Delete Block Ack"},
8780     {0x00, NULL}
8781   };
8782   /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
8783
8784   static const value_string dls_action_codes[] = {
8785     {SM_ACTION_DLS_REQUEST, "DLS Request"},
8786     {SM_ACTION_DLS_RESPONSE, "DLS Response"},
8787     {SM_ACTION_DLS_TEARDOWN, "DLS Teardown"},
8788     {0, NULL}
8789   };
8790
8791   static const value_string tsinfo_type[] = {
8792     {0x0, "Aperiodic or unspecified Traffic"},
8793     {0x1, "Periodic Traffic"},
8794     {0, NULL}
8795   };
8796
8797   static const value_string tsinfo_direction[] = {
8798     {0x00, "Uplink"},
8799     {0x01, "Downlink"},
8800     {0x02, "Direct link"},
8801     {0x03, "Bidirectional link"},
8802     {0, NULL}
8803   };
8804
8805   static const value_string tsinfo_access[] = {
8806     {0x00, "Reserved"},
8807     {0x01, "EDCA"},
8808     {0x02, "HCCA"},
8809     {0x03, "HEMM"},
8810     {0, NULL}
8811   };
8812
8813   static const value_string qos_up[] = {
8814     {0x00, "Best Effort"},
8815     {0x01, "Background"},
8816     {0x02, "Spare"},
8817     {0x03, "Excellent Effort"},
8818     {0x04, "Controlled Load"},
8819     {0x05, "Video"},
8820     {0x06, "Voice"},
8821     {0x07, "Network Control"},
8822     {0, NULL}
8823   };
8824
8825   static const value_string classifier_type[] = {
8826     {0x00, "Ethernet parameters"},
8827     {0x01, "TCP/UDP IP parameters"},
8828     {0x02, "IEEE 802.1D/Q parameters"},
8829     {0, NULL}
8830   };
8831
8832   static const value_string tclas_process[] = {
8833     {0x00, "Incoming MSDU's higher layer parameters have to match to the parameters in all associated TCLAS elements."},
8834     {0x01, "Incoming MSDU's higher layer parameters have to match to at least one of the associated TCLAS elements."},
8835     {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."},
8836     {0, NULL}
8837   };
8838
8839   /*** Begin: Block Ack/Block Ack Request  - Dustin Johnson***/
8840   static const true_false_string hf_block_ack_control_ack_policy_flag = {
8841       "Immediate Acknowledgement Required",
8842       "Sender Does Not Require Immediate Acknowledgement"
8843   };
8844
8845   static const value_string hf_block_ack_request_type_flags[] = {
8846     {0x00, "Basic Block Ack Request"},
8847     {0x01, "Reserved"},
8848     {0x02, "Compressed Block Ack Request"},
8849     {0x03, "Multi-TID Block Ack Request"},
8850     {0x00, NULL}
8851   };
8852
8853   static const value_string hf_block_ack_type_flags[] = {
8854     {0x00, "Basic Block Ack"},
8855     {0x01, "Reserved"},
8856     {0x02, "Compressed Block"},
8857     {0x03, "Multi-TID Block"},
8858     {0x00, NULL}
8859   };
8860   /*** End: Block Ack/Block Ack Request  - Dustin Johnson***/
8861
8862   static const value_string phy_type[] = {
8863     { 0, "Unknown" },
8864     { 1, "FHSS 802.11 '97" },
8865     { 2, "DSSS 802.11 '97" },
8866     { 3, "IR Baseband" },
8867     { 4, "DSSS 802.11b" },
8868     { 5, "PBCC 802.11b" },
8869     { 6, "OFDM 802.11g" },
8870     { 7, "PBCC 802.11g" },
8871     { 8, "OFDM 802.11a" },
8872     { 0, NULL }
8873   };
8874
8875   static const value_string encoding_type[] = {
8876     { 0, "Unknown" },
8877     { 1, "CCK" },
8878     { 2, "PBCC" },
8879     { 3, "OFDM" },
8880     { 4, "DSS-OFDM" },
8881     { 5, "BPSK" },
8882     { 6, "QPSK" },
8883     { 7, "16QAM" },
8884     { 8, "64QAM" },
8885     { 0, NULL }
8886   };
8887
8888   static const value_string ssi_type[] = {
8889     { SSI_NONE, "None" },
8890     { SSI_NORM_RSSI, "Normalized RSSI" },
8891     { SSI_DBM, "dBm" },
8892     { SSI_RAW_RSSI, "Raw RSSI" },
8893     { 0, NULL }
8894   };
8895
8896   static const value_string preamble_type[] = {
8897     { 0, "Unknown" },
8898     { 1, "Short" },
8899     { 2, "Long" },
8900     { 0, NULL }
8901   };
8902
8903   static hf_register_info hf[] = {
8904     {&hf_mactime,
8905      {"MAC timestamp", "wlan.mactime", FT_UINT64, BASE_DEC, NULL, 0x0,
8906       "Value in microseconds of the MAC's Time Synchronization Function timer when the first bit of the MPDU arrived at the MAC", HFILL }},
8907
8908     {&hf_hosttime,
8909      {"Host timestamp", "wlan.hosttime", FT_UINT64, BASE_DEC, NULL, 0x0,
8910       "", HFILL }},
8911
8912     {&hf_data_rate,
8913      {"Data Rate", "wlan.data_rate", FT_UINT64, BASE_DEC, NULL, 0,
8914       "Data rate (b/s)", HFILL }},
8915
8916     {&hf_channel,
8917      {"Channel", "wlan.channel", FT_UINT8, BASE_DEC, NULL, 0,
8918       "802.11 channel number that this frame was sent/received on", HFILL }},
8919
8920     {&hf_channel_frequency,
8921      {"Channel frequency", "wlan.channel_frequency", FT_UINT32, BASE_DEC, NULL, 0x0,
8922       "Channel frequency in megahertz that this frame was sent/received on", HFILL }},
8923
8924     {&hf_wlan_antenna,
8925      {"Antenna", "wlan.antenna", FT_UINT32, BASE_DEC, NULL, 0x0,
8926       "Antenna number this frame was sent/received over (starting at 0)", HFILL } },
8927
8928     {&hf_normrssi_antsignal,
8929      {"Normalized RSSI Signal", "wlan.normrssi_antsignal", FT_UINT32, BASE_DEC, NULL, 0x0,
8930       "RF signal power at the antenna, normalized to the range 0-1000", HFILL }},
8931
8932     {&hf_dbm_antsignal,
8933      {"SSI Signal (dBm)", "wlan.dbm_antsignal", FT_INT32, BASE_DEC, NULL, 0x0,
8934       "RF signal power at the antenna from a fixed, arbitrary value in decibels from one milliwatt", HFILL }},
8935
8936     {&hf_rawrssi_antsignal,
8937      {"Raw RSSI Signal", "wlan.rawrssi_antsignal", FT_UINT32, BASE_DEC, NULL, 0x0,
8938       "RF signal power at the antenna, reported as RSSI by the adapter", HFILL }},
8939
8940     {&hf_normrssi_antnoise,
8941      {"Normalized RSSI Noise", "wlan.normrssi_antnoise", FT_UINT32, BASE_DEC, NULL, 0x0,
8942       "RF noise power at the antenna, normalized to the range 0-1000", HFILL }},
8943
8944     {&hf_dbm_antnoise,
8945      {"SSI Noise (dBm)", "radiotap.dbm_antnoise", FT_INT32, BASE_DEC, NULL, 0x0,
8946       "RF noise power at the antenna from a fixed, arbitrary value in decibels per one milliwatt", HFILL }},
8947
8948     {&hf_rawrssi_antnoise,
8949      {"Raw RSSI Noise", "wlan.rawrssi_antnoise", FT_UINT32, BASE_DEC, NULL, 0x0,
8950       "RF noise power at the antenna, reported as RSSI by the adapter", HFILL }},
8951
8952     {&hf_signal_strength,
8953      {"Signal Strength", "wlan.signal_strength", FT_UINT8, BASE_DEC, NULL, 0,
8954       "Signal strength (Percentage)", HFILL }},
8955
8956     {&hf_fc_field,
8957      {"Frame Control Field", "wlan.fc", FT_UINT16, BASE_HEX, NULL, 0,
8958       "MAC Frame control", HFILL }},
8959
8960     {&hf_fc_proto_version,
8961      {"Version", "wlan.fc.version", FT_UINT8, BASE_DEC, NULL, 0,
8962       "MAC Protocol version", HFILL }},  /* 0 */
8963
8964     {&hf_fc_frame_type,
8965      {"Type", "wlan.fc.type", FT_UINT8, BASE_DEC, VALS(frame_type), 0,
8966       "Frame type", HFILL }},
8967
8968     {&hf_fc_frame_subtype,
8969      {"Subtype", "wlan.fc.subtype", FT_UINT8, BASE_DEC, NULL, 0,
8970       "Frame subtype", HFILL }},  /* 2 */
8971
8972     {&hf_fc_frame_type_subtype,
8973      {"Type/Subtype", "wlan.fc.type_subtype", FT_UINT8, BASE_HEX, VALS(frame_type_subtype_vals), 0,
8974       "Type and subtype combined (first byte: type, second byte: subtype)", HFILL }},
8975
8976     {&hf_fc_flags,
8977      {"Protocol Flags", "wlan.flags", FT_UINT8, BASE_HEX, NULL, 0,
8978       "Protocol flags", HFILL }},
8979
8980     {&hf_fc_data_ds,
8981      {"DS status", "wlan.fc.ds", FT_UINT8, BASE_HEX, VALS (&tofrom_ds), (FLAG_FROM_DS|FLAG_TO_DS),
8982       "Data-frame DS-traversal status", HFILL }},  /* 3 */
8983
8984     {&hf_fc_to_ds,
8985      {"To DS", "wlan.fc.tods", FT_BOOLEAN, 8, TFS (&tods_flag), FLAG_TO_DS,
8986       "To DS flag", HFILL }},    /* 4 */
8987
8988     {&hf_fc_from_ds,
8989      {"From DS", "wlan.fc.fromds", FT_BOOLEAN, 8, TFS (&fromds_flag), FLAG_FROM_DS,
8990       "From DS flag", HFILL }},    /* 5 */
8991
8992     {&hf_fc_more_frag,
8993      {"More Fragments", "wlan.fc.frag", FT_BOOLEAN, 8, TFS (&more_frags), FLAG_MORE_FRAGMENTS,
8994       "More Fragments flag", HFILL }},  /* 6 */
8995
8996     {&hf_fc_retry,
8997      {"Retry", "wlan.fc.retry", FT_BOOLEAN, 8, TFS (&retry_flags), FLAG_RETRY,
8998       "Retransmission flag", HFILL }},
8999
9000     { &hf_fc_analysis_retransmission,
9001      {"Retransmission", "wlan.analysis.retransmission", FT_NONE, BASE_NONE,
9002       NULL, 0x0, "This frame is a suspected wireless retransmission", HFILL }},
9003
9004     { &hf_fc_analysis_retransmission_frame,
9005      {"Retransmission of frame", "wlan.analysis.retransmission_frame", FT_FRAMENUM, BASE_NONE,
9006       NULL, 0x0, "This is a retransmission of frame #", HFILL }},
9007
9008     {&hf_fc_pwr_mgt,
9009      {"PWR MGT", "wlan.fc.pwrmgt", FT_BOOLEAN, 8, TFS (&pm_flags), FLAG_POWER_MGT,
9010       "Power management status", HFILL }},
9011
9012     {&hf_fc_more_data,
9013      {"More Data", "wlan.fc.moredata", FT_BOOLEAN, 8, TFS (&md_flags), FLAG_MORE_DATA,
9014       "More data flag", HFILL }},
9015
9016     {&hf_fc_protected,
9017      {"Protected flag", "wlan.fc.protected", FT_BOOLEAN, 8, TFS (&protected_flags), FLAG_PROTECTED,
9018       "Protected flag", HFILL }},
9019
9020     {&hf_fc_order,
9021      {"Order flag", "wlan.fc.order", FT_BOOLEAN, 8, TFS (&order_flags), FLAG_ORDER,
9022       "Strictly ordered flag", HFILL }},
9023
9024     {&hf_assoc_id,
9025      {"Association ID","wlan.aid",FT_UINT16, BASE_DEC,NULL,0,
9026       "Association-ID field", HFILL }},
9027
9028     {&hf_did_duration,
9029      {"Duration", "wlan.duration", FT_UINT16, BASE_DEC, NULL, 0,
9030       "Duration field", HFILL }},
9031
9032     {&hf_addr_da,
9033      {"Destination address", "wlan.da", FT_ETHER, BASE_NONE, NULL, 0,
9034       "Destination Hardware Address", HFILL }},
9035
9036     {&hf_addr_sa,
9037      {"Source address", "wlan.sa", FT_ETHER, BASE_NONE, NULL, 0,
9038       "Source Hardware Address", HFILL }},
9039
9040     { &hf_addr,
9041       {"Source or Destination address", "wlan.addr", FT_ETHER, BASE_NONE, NULL, 0,
9042        "Source or Destination Hardware Address", HFILL }},
9043
9044     {&hf_addr_ra,
9045      {"Receiver address", "wlan.ra", FT_ETHER, BASE_NONE, NULL, 0,
9046       "Receiving Station Hardware Address", HFILL }},
9047
9048     {&hf_addr_ta,
9049      {"Transmitter address", "wlan.ta", FT_ETHER, BASE_NONE, NULL, 0,
9050       "Transmitting Station Hardware Address", HFILL }},
9051
9052     {&hf_addr_addr1,
9053      {"First Address of Contained Frame", "wlan.controlwrap.addr1", FT_ETHER, BASE_NONE, NULL, 0,
9054       "First Address of Contained Frame", HFILL }},
9055
9056     {&hf_addr_bssid,
9057      {"BSS Id", "wlan.bssid", FT_ETHER, BASE_NONE, NULL, 0,
9058       "Basic Service Set ID", HFILL }},
9059
9060     {&hf_frag_number,
9061      {"Fragment number", "wlan.frag", FT_UINT16, BASE_DEC, NULL, 0,
9062       "Fragment number", HFILL }},
9063
9064     {&hf_seq_number,
9065      {"Sequence number", "wlan.seq", FT_UINT16, BASE_DEC, NULL, 0,
9066       "Sequence number", HFILL }},
9067
9068     {&hf_qos_priority,
9069      {"Priority", "wlan.qos.priority", FT_UINT16, BASE_DEC, NULL, 0,
9070       "802.1D Tag", HFILL }},
9071
9072     {&hf_qos_eosp,
9073      {"EOSP", "wlan.qos.eosp", FT_BOOLEAN, 8, TFS (&eosp_flag), QOS_FLAG_EOSP,
9074       "EOSP Field", HFILL }},
9075
9076     {&hf_qos_ack_policy,
9077      {"Ack Policy", "wlan.qos.ack", FT_UINT8, BASE_HEX,  VALS (&ack_policy), 0,
9078       "Ack Policy", HFILL }},
9079
9080     {&hf_qos_amsdu_present,
9081      {"Payload Type", "wlan.qos.amsdupresent", FT_BOOLEAN, BASE_NONE,
9082       TFS (&hf_qos_amsdu_present_flag), 0, "Payload Type", HFILL }},
9083
9084     {&hf_qos_field_content,
9085      {"Content", "wlan.qos.fc_content", FT_UINT16, BASE_DEC, NULL, 0,
9086       "Content1", HFILL }},
9087
9088 /*    {&hf_qos_buffer_state,
9089      {"QAP PS buffer State", "wlan.qos.ps_buf_state", FT_UINT16, BASE_DEC, NULL, 0,
9090       "QAP PS buffer State", HFILL }},
9091
9092     {&hf_qos_txop_dur_req,
9093      {"TXOP Duration Requested", "wlan.qos.txop_dur_req", FT_UINT16, BASE_DEC, NULL, 0,
9094       "TXOP Duration Requested", HFILL }},
9095
9096     {&hf_qos_queue_size,
9097      {"Queue Size", "wlan.qos.queue_size", FT_UINT16, BASE_DEC, NULL, 0,
9098       "Queue Size", HFILL }},*/
9099
9100     {&hf_fcs,
9101      {"Frame check sequence", "wlan.fcs", FT_UINT32, BASE_HEX,
9102       NULL, 0, "Frame Check Sequence (FCS)", HFILL }},
9103
9104     {&hf_fcs_good,
9105      {"Good", "wlan.fcs_good", FT_BOOLEAN, BASE_NONE,
9106       NULL, 0, "True if the FCS is correct", HFILL }},
9107
9108     {&hf_fcs_bad,
9109      {"Bad", "wlan.fcs_bad", FT_BOOLEAN, BASE_NONE,
9110       NULL, 0, "True if the FCS is incorrect", HFILL }},
9111
9112     {&hf_fragment_overlap,
9113       {"Fragment overlap", "wlan.fragment.overlap", FT_BOOLEAN, BASE_NONE,
9114        NULL, 0x0, "Fragment overlaps with other fragments", HFILL }},
9115
9116     {&hf_fragment_overlap_conflict,
9117       {"Conflicting data in fragment overlap", "wlan.fragment.overlap.conflict",
9118        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9119        "Overlapping fragments contained conflicting data", HFILL }},
9120
9121     {&hf_fragment_multiple_tails,
9122       {"Multiple tail fragments found", "wlan.fragment.multipletails",
9123        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9124        "Several tails were found when defragmenting the packet", HFILL }},
9125
9126     {&hf_fragment_too_long_fragment,
9127       {"Fragment too long", "wlan.fragment.toolongfragment",
9128        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
9129        "Fragment contained data past end of packet", HFILL }},
9130
9131     {&hf_fragment_error,
9132       {"Defragmentation error", "wlan.fragment.error",
9133        FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9134        "Defragmentation error due to illegal fragments", HFILL }},
9135
9136     {&hf_fragment,
9137       {"802.11 Fragment", "wlan.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9138        "802.11 Fragment", HFILL }},
9139
9140     {&hf_fragments,
9141       {"802.11 Fragments", "wlan.fragments", FT_NONE, BASE_NONE, NULL, 0x0,
9142        "802.11 Fragments", HFILL }},
9143
9144     {&hf_reassembled_in,
9145       {"Reassembled 802.11 in frame", "wlan.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
9146        "This 802.11 packet is reassembled in this frame", HFILL }},
9147
9148     {&hf_wep_iv,
9149      {"Initialization Vector", "wlan.wep.iv", FT_UINT24, BASE_HEX, NULL, 0,
9150       "Initialization Vector", HFILL }},
9151
9152     {&hf_wep_iv_weak,
9153      {"Weak IV", "wlan.wep.weakiv", FT_BOOLEAN,BASE_NONE, NULL,0x0,
9154        "Weak IV",HFILL}},
9155
9156     {&hf_tkip_extiv,
9157      {"TKIP Ext. Initialization Vector", "wlan.tkip.extiv", FT_STRING,
9158       BASE_HEX, NULL, 0, "TKIP Extended Initialization Vector", HFILL }},
9159
9160     {&hf_ccmp_extiv,
9161      {"CCMP Ext. Initialization Vector", "wlan.ccmp.extiv", FT_STRING,
9162       BASE_HEX, NULL, 0, "CCMP Extended Initialization Vector", HFILL }},
9163
9164     {&hf_wep_key,
9165      {"Key Index", "wlan.wep.key", FT_UINT8, BASE_DEC, NULL, 0,
9166       "Key Index", HFILL }},
9167
9168     {&hf_wep_icv,
9169      {"WEP ICV", "wlan.wep.icv", FT_UINT32, BASE_HEX, NULL, 0,
9170       "WEP ICV", HFILL }},
9171         /***  Begin: WAVE Service information element Dissection - IEEE 802.11p Draft 4.0 ***/
9172     {&hf_pst_timingquality,
9173      {"Timing Quality", "pst.timingQuality", FT_UINT16, BASE_DEC, NULL, 0,
9174       "PST Timing Quality", HFILL }},
9175
9176     {&hf_pst_providercount,
9177      {"No. of Providers announcing their Services", "pst.providerCount", FT_UINT8, BASE_DEC, NULL, 0,
9178       "Provider Count", HFILL }},
9179
9180     {&hf_pst_length,
9181      {"Provider Service Table Length ", "pst.length", FT_UINT16, BASE_DEC, NULL, 0,
9182       "PST Length", HFILL }},
9183
9184     {&hf_pst_contents,
9185      {"Provider Service Table Contents ", "pst.contents", FT_UINT8, BASE_HEX, NULL, 0,
9186       "PST Contents", HFILL }},
9187
9188     {&hf_pst_acid,
9189      {"Application Class ID (ACID) ", "pst.ACID", FT_UINT8, BASE_DEC, NULL, 0,
9190       "PST ACID", HFILL }},
9191
9192     {&hf_pst_acm_length,
9193      {"Application Context Mask (ACM) Length", "pst.ACM.length", FT_UINT8, BASE_DEC, NULL, 0,
9194       "PST ACM Length", HFILL }},
9195
9196     {&hf_pst_acm,
9197      {"Application Context Mask", "pst.ACM", FT_STRING, BASE_NONE, NULL, 0,
9198       "PST ACM", HFILL }},
9199
9200     {&hf_pst_acm_contents,
9201      {"Application Context Mask Contents (ACM)", "pst.ACM.contents", FT_UINT32, BASE_DEC, NULL, 0,
9202       "PST ACM Contents", HFILL }},
9203
9204     {&hf_pst_acf,
9205      {"Application Contents Field (ACF)", "pst.ACF", FT_UINT32, BASE_DEC, NULL, 0,
9206       "PST ACF", HFILL }},
9207
9208     {&hf_pst_priority,
9209      {"Application Priority", "pst.priority", FT_UINT8, BASE_DEC, NULL, 0,
9210       "PST Priority", HFILL }},
9211
9212     {&hf_pst_ipv6addr,
9213      {"Internet Protocol V6 Address", "pst.ipv6addr", FT_IPv6, BASE_NONE, NULL, 0,
9214       "IP v6 Addr", HFILL }},
9215
9216     {&hf_pst_macaddr,
9217      {"Medium Access Control Address (MAC addr)", "pst.macaddr", FT_ETHER, BASE_NONE, NULL, 0,
9218       "MAC Address", HFILL }},
9219
9220     {&hf_pst_serviceport,
9221      {"Service Port ", "pst.serviceport", FT_UINT16, BASE_DEC, NULL, 0,
9222       "PST Service Port", HFILL }},
9223
9224     {&hf_pst_addressing,
9225      {"Addressing ", "pst.addressing", FT_UINT8, BASE_DEC, NULL, 0,
9226       "PST Addressing", HFILL }},
9227
9228     {&hf_pst_channel,
9229      {"Service (IEE802.11) Channel", "pst.channel", FT_UINT8, BASE_DEC, NULL, 0,
9230       "PST Service Channel", HFILL }},
9231
9232     {&hf_chan_noc,
9233      {"Number of Channels", "chan.chan_uknown", FT_UINT8, BASE_DEC, NULL, 0,
9234       "Number of Channels", HFILL }},
9235
9236     {&hf_chan_length,
9237      {"Length", "chan.chan_length", FT_UINT8, BASE_DEC, NULL, 0,
9238       "Length", HFILL }},
9239
9240     {&hf_chan_content,
9241      {"Contents", "chan.chan_content", FT_UINT8, BASE_DEC, NULL, 0,
9242       "Contents", HFILL }},
9243
9244     {&hf_chan_channel,
9245      {"channel", "chan.chan_channel", FT_UINT8, BASE_DEC, NULL, 0,
9246       "channel", HFILL }},
9247
9248     {&hf_chan_adapt,
9249      {"Adaptable", "chan.chan_adapt", FT_UINT8, BASE_DEC, NULL, 0,
9250       "Adaptable", HFILL }},
9251
9252     {&hf_chan_rate,
9253      {"Rate", "chan.chan_rate", FT_UINT8, BASE_DEC, NULL, 0,
9254       "Rate", HFILL }},
9255
9256     {&hf_chan_tx_pow,
9257      {"Tx Power", "chan.chan_tx_pow", FT_UINT8, BASE_DEC, NULL, 0,
9258       "Tx Power", HFILL }},
9259
9260     /*** Begin: Block Ack Request/Block Ack  - Dustin Johnson***/
9261     {&hf_block_ack_request_control,
9262      {"Block Ack Request (BAR) Control", "wlan.bar.control",
9263       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Request (BAR) Control", HFILL }},
9264
9265     {&hf_block_ack_control,
9266      {"Block Ack Request Control", "wlan.ba.control",
9267       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Request Control", HFILL }},
9268
9269     {&hf_block_ack_control_ack_policy,
9270      {"BAR Ack Policy", "wlan.ba.control.ackpolicy",
9271       FT_BOOLEAN, 16, TFS (&hf_block_ack_control_ack_policy_flag), 0x01, "Block Ack Request (BAR) Ack Policy", HFILL }},
9272
9273     {&hf_block_ack_control_multi_tid,
9274      {"Multi-TID", "wlan.ba.control.multitid",
9275       FT_BOOLEAN, 16, 0, 0x02, "Multi-Traffic Identifier (TID)", HFILL }},
9276
9277     {&hf_block_ack_control_compressed_bitmap,
9278      {"Compressed Bitmap", "wlan.ba.control.cbitmap",
9279       FT_BOOLEAN, 16, 0, 0x04, "Compressed Bitmap", HFILL }},
9280
9281     {&hf_block_ack_control_reserved,
9282      {"Reserved", "wlan.ba.control.cbitmap",
9283       FT_UINT16, BASE_HEX, NULL, 0x0ff8, "Reserved", HFILL }},
9284
9285     {&hf_block_ack_control_basic_tid_info,
9286      {"TID for which a Basic BlockAck frame is requested", "wlan.ba.basic.tidinfo",
9287       FT_UINT16, BASE_HEX, NULL, 0xf000, "Traffic Identifier (TID) for which a Basic BlockAck frame is requested", HFILL }},
9288
9289     {&hf_block_ack_control_compressed_tid_info,
9290      {"TID for which a BlockAck frame is requested", "wlan.bar.compressed.tidinfo",
9291       FT_UINT16, BASE_HEX, NULL, 0xf000, "Traffic Identifier (TID) for which a BlockAck frame is requested", HFILL }},
9292
9293     {&hf_block_ack_control_multi_tid_info,
9294      {"Number of TIDs Present", "wlan.ba.mtid.tidinfo",
9295       FT_UINT16, BASE_HEX, NULL, 0xf000, "Number of Traffic Identifiers (TIDs) Present", HFILL }},
9296
9297     {&hf_block_ack_multi_tid_info,
9298      {"Traffic Identifier (TID) Info", "wlan.ba.mtid.tid",
9299       FT_UINT8, BASE_DEC, 0, 0, "Traffic Identifier (TID) Info", HFILL }},
9300
9301     {&hf_block_ack_multi_tid_reserved,
9302      {"Reserved", "wlan.bar.mtid.tidinfo.reserved",
9303       FT_UINT16, BASE_HEX, 0, 0x0fff, "Reserved", HFILL }},
9304
9305     {&hf_block_ack_multi_tid_value,
9306      {"Multi-TID Value", "wlan.bar.mtid.tidinfo.value",
9307       FT_UINT16, BASE_HEX, 0, 0xf000, "Multi-TID Value", HFILL }},
9308
9309     {&hf_block_ack_request_type,
9310      {"Block Ack Request Type", "wlan.bar.type",
9311       FT_UINT8, BASE_HEX, VALS(&hf_block_ack_request_type_flags), 0, "Block Ack Request (BAR) Type", HFILL }},
9312
9313     {&hf_block_ack_type,
9314      {"Block Ack Request Type", "wlan.ba.type",
9315       FT_UINT8, BASE_HEX, VALS(&hf_block_ack_type_flags), 0, "Block Ack Request Type", HFILL }}
9316     /*** End: Block Ack Request/Block Ack  - Dustin Johnson***/
9317   };
9318
9319   static hf_register_info hf_prism[] = {
9320     /* Prism-specific header fields
9321        XXX - make as many of these generic as possible. */
9322     { &hf_prism_msgcode,
9323      {"Message Code", "prism.msgcode", FT_UINT32, BASE_HEX, NULL, 0x0,
9324       "", HFILL }},
9325
9326     { &hf_prism_msglen,
9327      {"Message Length", "prism.msglen", FT_UINT32, BASE_HEX, NULL, 0x0,
9328       "", HFILL }},
9329
9330     { &hf_prism_rssi_data,
9331      {"RSSI Field", "prism.rssi.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9332       "", HFILL }},
9333
9334     { &hf_prism_sq_data,
9335      {"SQ Field", "prism.sq.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9336       "", HFILL }},
9337
9338     { &hf_prism_signal_data,
9339      {"Signal Field", "prism.signal.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9340       "", HFILL }},
9341
9342     { &hf_prism_noise_data,
9343      {"Noise Field", "prism.noise.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9344       "", HFILL }},
9345
9346     { &hf_prism_rate_data,
9347      {"Rate Field", "prism.rate.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9348       "", HFILL }},
9349
9350     { &hf_prism_istx_data,
9351      {"IsTX Field", "prism.istx.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9352       "", HFILL }},
9353
9354     { &hf_prism_frmlen_data,
9355      {"Frame Length Field", "prism.frmlen.data", FT_UINT32, BASE_HEX, NULL, 0x0,
9356       "", HFILL }}
9357   };
9358
9359   static hf_register_info hf_wlancap[] = {
9360     /* AVS-specific header fields.
9361        XXX - make as many of these generic as possible. */
9362     {&hf_wlan_magic,
9363      {"Header magic", "wlancap.magic", FT_UINT32, BASE_HEX, NULL, 0xFFFFFFF0, "", HFILL } },
9364     { &hf_wlan_version, { "Header revision", "wlancap.version", FT_UINT32,
9365                           BASE_DEC, NULL, 0xF, "", HFILL } },
9366     { &hf_wlan_length, { "Header length", "wlancap.length", FT_UINT32,
9367                          BASE_DEC, NULL, 0x0, "", HFILL } },
9368     {&hf_wlan_phytype,
9369      {"PHY type", "wlan.phytype", FT_UINT32, BASE_DEC, VALS(phy_type), 0x0,
9370       "", HFILL } },
9371
9372     { &hf_wlan_priority, { "Priority", "wlancap.priority", FT_UINT32, BASE_DEC,
9373                            NULL, 0x0, "", HFILL } },
9374     { &hf_wlan_ssi_type, { "SSI Type", "wlancap.ssi_type", FT_UINT32, BASE_DEC,
9375                            VALS(ssi_type), 0x0, "", HFILL } },
9376     { &hf_wlan_ssi_signal, { "SSI Signal", "wlancap.ssi_signal", FT_INT32,
9377                            BASE_DEC, NULL, 0x0, "", HFILL } },
9378     { &hf_wlan_ssi_noise, { "SSI Noise", "wlancap.ssi_noise", FT_INT32,
9379                            BASE_DEC, NULL, 0x0, "", HFILL } },
9380     { &hf_wlan_preamble, { "Preamble", "wlancap.preamble", FT_UINT32,
9381                            BASE_DEC, VALS(preamble_type), 0x0, "", HFILL } },
9382     { &hf_wlan_encoding, { "Encoding Type", "wlancap.encoding", FT_UINT32,
9383                            BASE_DEC, VALS(encoding_type), 0x0, "", HFILL } },
9384     { &hf_wlan_sequence, { "Receive sequence", "wlancap.sequence", FT_UINT32,
9385                            BASE_DEC, NULL, 0x0, "", HFILL } },
9386     { &hf_wlan_drops, { "Known Dropped Frames", "wlancap.drops", FT_UINT32,
9387                            BASE_DEC, NULL, 0x0, "", HFILL } },
9388     { &hf_wlan_receiver_addr, { "Receiver Address", "wlancap.receiver_addr", FT_ETHER,
9389                            BASE_NONE, NULL, 0x0, "Receiver Hardware Address", HFILL } },
9390     { &hf_wlan_padding, { "Padding", "wlancap.padding", FT_BYTES,
9391                            BASE_NONE, NULL, 0x0, "", HFILL } }
9392   };
9393
9394   static const true_false_string rsn_preauth_flags = {
9395     "Transmitter supports pre-authentication",
9396     "Transmitter does not support pre-authentication"
9397   };
9398
9399   static const true_false_string rsn_no_pairwise_flags = {
9400     "Transmitter cannot support WEP default key 0 simultaneously with "
9401     "Pairwise key",
9402     "Transmitter can support WEP default key 0 simultaneously with "
9403     "Pairwise key"
9404   };
9405
9406   static const value_string rsn_cap_replay_counter[] = {
9407     {0x00, "1 replay counter per PTKSA/GTKSA/STAKeySA"},
9408     {0x01, "2 replay counters per PTKSA/GTKSA/STAKeySA"},
9409     {0x02, "4 replay counters per PTKSA/GTKSA/STAKeySA"},
9410     {0x03, "16 replay counters per PTKSA/GTKSA/STAKeySA"},
9411     {0, NULL}
9412   };
9413
9414   static const true_false_string ht_ldpc_coding_flag = {
9415     "Transmitter supports receiving LDPC coded packets",
9416     "Transmitter does not support receiving LDPC coded packets"
9417   };
9418
9419   static const true_false_string ht_chan_width_flag = {
9420     "Transmitter supports 20MHz and 40MHz operation",
9421     "Transmitter only supports 20MHz operation"
9422   };
9423
9424   static const value_string ht_sm_pwsave_flag[] = {
9425     {0x00, "Static SM Power Save mode"},
9426     {0x01, "Dynamic SM Power Save mode"},
9427     {0x02, "Reserved"},
9428     {0x03, "SM enabled"},
9429     {0x00, NULL}
9430   };
9431
9432   static const true_false_string ht_green_flag = {
9433     "Transmitter is able to receive PPDUs with Green Field (GF) preamble",
9434     "Transmitter is not able to receive PPDUs with Green Field (GF) preamble"
9435   };
9436
9437   static const true_false_string ht_tf_flag = {
9438     "Supported",
9439     "Not Supported "
9440   };
9441
9442   static const value_string ht_rx_stbc_flag[] = {
9443     {0x00, "No Rx STBC support"},
9444     {0x01, "Rx support of one spatial stream"},
9445     {0x02, "Rx support of one and two spatial streams"},
9446     {0x03, "Rx support of one, two, and three spatial streams"},
9447     {0x00, NULL}
9448   };
9449
9450   static const true_false_string ht_delayed_block_ack_flag = {
9451     "Transmitter supports HT-Delayed BlockAck",
9452     "Transmitter does not support HT-Delayed BlockAck"
9453   };
9454
9455   static const true_false_string ht_max_amsdu_flag = {
9456     "7935 bytes",
9457     "3839 bytes"
9458   };
9459
9460   static const true_false_string ht_dss_cck_40_flag = {
9461     "Will/Can use DSSS/CCK in 40 MHz",
9462     "Won't/Can't use of DSSS/CCK in 40 MHz"
9463   };
9464
9465   static const true_false_string ht_psmp_flag = {
9466     "Will/Can support PSMP operation",
9467     "Won't/Can't support PSMP operation"
9468   };
9469
9470   static const true_false_string ht_40_mhz_intolerant_flag = {
9471     "Use of 40 MHz transmissions restricted/disallowed",
9472     "Use of 40 MHz transmissions unrestricted/allowed"
9473   };
9474
9475   static const value_string ampduparam_mpdu_start_spacing_flags[] = {
9476     {0x00, "no restriction"},
9477     {0x01, "1/4 [usec]"},
9478     {0x02, "1/2 [usec]"},
9479     {0x03, "1 [usec]"},
9480     {0x04, "2 [usec]"},
9481     {0x05, "4 [usec]"},
9482     {0x06, "8 [usec]"},
9483     {0x07, "16 [usec]"},
9484     {0x00, NULL}
9485   };
9486
9487   static const true_false_string mcsset_tx_mcs_set_defined_flag = {
9488     "Defined",
9489     "Not Defined",
9490   };
9491
9492   static const true_false_string mcsset_tx_rx_mcs_set_not_equal_flag = {
9493     "Not Equal",
9494     "Equal",
9495   };
9496
9497   static const value_string mcsset_tx_max_spatial_streams_flags[] = {
9498     {0x00, "1 spatial stream"},
9499     {0x01, "2 spatial streams"},
9500     {0x02, "3 spatial streams"},
9501     {0x03, "4 spatial streams"},
9502     {0x00, NULL}
9503   };
9504
9505   static const value_string htex_transtime_flags[] = {
9506     {0x00, "No Transition"},
9507     {0x01, "400 usec"},
9508     {0x02, "1.5 msec"},
9509     {0x03, "5 msec"},
9510     {0x00, NULL}
9511   };
9512
9513   static const value_string htex_mcs_flags[] = {
9514     {0x00, "STA does not provide MCS feedback"},
9515     {0x01, "Reserved"},
9516     {0x02, "STA provides only unsolicited MCS feedback"},
9517     {0x03, "STA can provide MCS feedback in response to MRQ as well as unsolicited MCS feedback"},
9518     {0x00, NULL}
9519   };
9520
9521   static const value_string txbf_calib_flag[] = {
9522     {0x00, "incapable"},
9523     {0x01, "Limited involvement, cannot initiate"},
9524     {0x02, "Limited involvement, can initiate"},
9525     {0x03, "Fully capable"},
9526     {0x00, NULL}
9527   };
9528
9529   static const value_string txbf_feedback_flags[] = {
9530     {0x00, "not supported"},
9531     {0x01, "delayed feedback capable"},
9532     {0x02, "immediate feedback capable"},
9533     {0x03, "delayed and immediate feedback capable"},
9534     {0x00, NULL}
9535   };
9536
9537   static const value_string txbf_antenna_flags[] = {
9538     {0x00, "1 TX antenna sounding"},
9539     {0x01, "2 TX antenna sounding"},
9540     {0x02, "3 TX antenna sounding"},
9541     {0x03, "4 TX antenna sounding"},
9542     {0x00, NULL}
9543   };
9544
9545   static const value_string txbf_csi_max_rows_bf_flags[] = {
9546     {0x00, "1 row of CSI"},
9547     {0x01, "2 rows of CSI"},
9548     {0x02, "3 rows of CSI"},
9549     {0x03, "4 rows of CSI"},
9550     {0x00, NULL}
9551   };
9552
9553   static const value_string txbf_chan_est_flags[] = {
9554     {0x00, "1 space time stream"},
9555     {0x01, "2 space time streams"},
9556     {0x02, "3 space time streams"},
9557     {0x03, "4 space time streams"},
9558     {0x00, NULL}
9559   };
9560
9561   static const value_string txbf_min_group_flags[] = {
9562     {0x00, "No grouping supported"},
9563     {0x01, "Groups of 1,2 supported"},
9564     {0x02, "Groups of 1,4 supported"},
9565     {0x03, "Groups of 1,2,4 supported"},
9566     {0x00, NULL}
9567   };
9568
9569   static const value_string hta_ext_chan_offset_flag[] = {
9570     {0x00, "No Extension Channel"},
9571     {0x01, "Extension Channel above control channel"},
9572     {0x02, "Undefined"},
9573     {0x03, "Extension Channel below control channel"},
9574     {0x00, NULL}
9575   };
9576
9577   static const true_false_string hta_rec_tx_width_flag = {
9578     "Any channel width enabled",
9579     "Use 20MHz channel (control)"
9580   };
9581
9582   static const true_false_string hta_rifs_mode_flag = {
9583     "Use of RIFS permitted",
9584     "Use of RIFS prohibited"
9585   };
9586
9587   static const true_false_string hta_controlled_access_flag = {
9588     "Not only PSMP",
9589     "PSMP only"
9590   };
9591
9592   static const value_string hta_service_interval_flag[] = {
9593     {0x00, "5ms"},
9594     {0x01, "10ms"},
9595     {0x02, "15ms"},
9596     {0x03, "20ms"},
9597     {0x04, "25ms"},
9598     {0x05, "30ms"},
9599     {0x06, "35ms"},
9600     {0x07, "40ms"},
9601     {0x00, NULL}
9602   };
9603
9604   static const value_string hta_operating_mode_flag[] = {
9605     {0x00, "Pure HT, no protection"},
9606     {0x01, "There may be non-HT devices (control & ext channel)"},
9607     {0x02, "No non-HT is associated, but at least 1 20MHz is. protect on"},
9608     {0x03, "Mixed: no non-HT is associated, protect on"},
9609     {0x00, NULL}
9610   };
9611
9612   static const true_false_string hta_non_gf_devices_flag = {
9613     "All HT devices associated are GF capable",
9614     "One or More HT devices are not GF capable"
9615   };
9616
9617   static const true_false_string hta_dual_stbc_protection_flag = {
9618     "Dual CTS protections is used",
9619     "Regular use of RTS/CTS"
9620   };
9621
9622   static const true_false_string hta_secondary_beacon_flag = {
9623     "Secondary Beacon",
9624     "Primary Beacon"
9625   };
9626
9627   static const true_false_string hta_lsig_txop_protection_flag = {
9628     "Full Support",
9629     "Not full support"
9630   };
9631
9632   static const true_false_string hta_pco_active_flag = {
9633     "PCO is activated in the BSS",
9634     "PCO is not activated in the BSS"
9635   };
9636
9637   static const true_false_string hta_pco_phase_flag = {
9638     "Switch to 20MHz phase/keep 20MHz",
9639     "Switch to 40MHz phase/keep 40MHz"
9640   };
9641
9642   static const value_string ht_info_secondary_channel_offset_flags[] = {
9643     {0x00, "No secondary channel"},
9644     {0x01, "Secondary channel is above the primary channel"},
9645     {0x02, "Reserved"},
9646     {0x03, "Secondary channel is below the primary channel"},
9647     {0x00, NULL}
9648   };
9649
9650   static const true_false_string ht_info_channel_width_flag = {
9651     "Channel of any width supported",
9652     "20 MHz channel width only"
9653   };
9654
9655   static const true_false_string ht_info_rifs_mode_flag = {
9656     "Permitted",
9657     "Prohibited"
9658   };
9659
9660   static const true_false_string ht_info_psmp_stas_only_flag = {
9661     "Association requests are accepted from only PSMP capable STA",
9662     "Association requests are accepted regardless of PSMP capability"
9663   };
9664
9665   static const value_string ht_info_service_interval_granularity_flags[] = {
9666     {0x00, "5 ms"},
9667     {0x01, "10 ms"},
9668     {0x02, "15 ms"},
9669     {0x03, "20 ms"},
9670     {0x04, "25 ms"},
9671     {0x05, "30 ms"},
9672     {0x06, "35 ms"},
9673     {0x07, "40 ms"},
9674     {0x00, NULL}
9675   };
9676
9677   static const value_string ht_info_operating_mode_flags[] = {
9678     {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"},
9679     {0x01, "HT non-member protection mode"},
9680     {0x02, "Only HT STAs in the BSS, however, there exists at least one 20 MHz STA"},
9681     {0x03, "HT mixed mode"},
9682     {0x00, NULL}
9683   };
9684
9685   static const true_false_string ht_info_non_greenfield_sta_present_flag = {
9686     "One or more associated STAs are not greenfield capable",
9687     "All associated STAs are greenfield capable"
9688   };
9689
9690   static const true_false_string ht_info_transmit_burst_limit_flag = {
9691     "2.4 GHz - 6.16 ms | All other bands - 3.08 ms",
9692     "No limit"
9693   };
9694
9695   static const true_false_string ht_info_obss_non_ht_stas_present_flag = {
9696     "Use of protection for non-HT STAs by overlapping BSSs is needed",
9697     "Use of protection for non-HT STAs by overlapping BSSs is not needed"
9698   };
9699
9700   static const true_false_string ht_info_dual_beacon_flag = {
9701     "AP transmits a secondary beacon",
9702     "No second beacon is transmitted"
9703   };
9704
9705   static const true_false_string ht_info_dual_cts_protection_flag = {
9706     "Required",
9707     "Not required"
9708   };
9709
9710   static const true_false_string ht_info_secondary_beacon_flag = {
9711     "Secondary beacon",
9712     "Primary beacon"
9713   };
9714
9715   static const true_false_string ht_info_lsig_txop_protection_full_support_flag = {
9716     "All HT STAs in the BSS support L-SIG TXOP protection",
9717     "One or more HT STAs in the BSS do not support L-SIG TXOP protection"
9718   };
9719
9720   /* XXX - We might want to use tfs_active_inactive here */
9721   static const true_false_string ht_info_pco_active_flag = {
9722     "Active",
9723     "Not active"
9724   };
9725
9726   static const true_false_string ht_info_pco_phase_flag = {
9727     "Switch to or continue 40 MHz phase",
9728     "Switch to or continue 20 MHz phase"
9729   };
9730
9731   static const true_false_string htc_lac_trq_flag = {
9732     "Want sounding PPDU",
9733     "Don't want sounding PPDU"
9734   };
9735
9736   static const true_false_string htc_lac_mai_mrq_flag = {
9737     "MCS feedback requested",
9738     "No MCS feedback requested"
9739   };
9740
9741   static const value_string hf_htc_lac_asel_command_flags[] = {
9742     {0x00, "Transmit Antenna Selection Sounding Indication (TXASSI)"},
9743     {0x01, "Transmit Antenna Selection Sounding Request (TXASSR)"},
9744     {0x02, "Receive Antenna Selection Sounding Indication (RXASSI)"},
9745     {0x03, "Receive Antenna Selection Sounding Request (RXASSR)"},
9746     {0x04, "Sounding Label"},
9747     {0x05, "No feedback, ASEL training failure"},
9748     {0x06, "Transmit Antenna Selection Sounding Indication (TXASSI) requesting feedback of explicit CSI"},
9749     {0x07, "Reserved"},
9750     {0x00, NULL}
9751   };
9752
9753   static const value_string hf_htc_cal_pos_flags[] = {
9754     {0x00, "Not a calibration frame"},
9755     {0x01, "Calibration Start"},
9756     {0x02, "Sounding Response"},
9757     {0x03, "Sounding Complete"},
9758     {0x00, NULL}
9759   };
9760
9761   static const true_false_string hf_htc_ndp_announcement_flag = {
9762     "NDP will follow",
9763     "No NDP will follow"
9764   };
9765
9766   static const value_string hf_htc_csi_steering_flags[] = {
9767     {0x00, "No feedback required"},
9768     {0x01, "CSI"},
9769     {0x02, "Non-compressed Beamforming Feedback Matrix"},
9770     {0x03, "Compressed Beamforming Feedback Matrix"},
9771     {0x00, NULL}
9772   };
9773
9774   static const value_string hf_tag_secondary_channel_offset_flags[] = {
9775     {0x00, "No Secondary Channel"},
9776     {0x01, "Above Primary Channel"},
9777     {0x02, "Reserved"},
9778     {0x03, "Below Primary Channel"},
9779     {0x00, NULL}
9780   };
9781
9782   static const true_false_string hf_tag_measure_enable_flag = {
9783     "Enabled",
9784     "Disabled"
9785   };
9786
9787   static const true_false_string hf_tag_measure_acc_not_acc = {
9788     "Accepted",
9789     "Not Accepted"
9790   };
9791
9792   static const value_string hf_tag_measure_request_type_flags[] = {
9793     {0x00, "Basic Request"},
9794     {0x01, "Clear Channel Assessment (CCA) Request"},
9795     {0x02, "Receive Power Indication (RPI) Histogram Request"},
9796     {0x03, "Channel Load Request"},
9797     {0x04, "Noise Histogram Request"},
9798     {0x05, "Beacon Request"},
9799     {0x06, "Frame Request"},
9800     {0x07, "STA Statistics Request"},
9801     {0x08, "Location Configuration Indication (LCI) Request"},
9802     {0x09, "Transmit Stream Measurement Request"},
9803     {0x0A, "Measurement Pause Request"},
9804     {0x00, NULL}
9805   };
9806
9807   static const value_string hf_tag_measure_report_type_flags[] = {
9808     {0x00, "Basic Report"},
9809     {0x01, "Clear Channel Assessment (CCA) Report"},
9810     {0x02, "Receive Power Indication (RPI) Histogram Report"},
9811     {0x03, "Channel Load Report"},
9812     {0x04, "Noise Histogram Report"},
9813     {0x05, "Beacon Report"},
9814     {0x06, "Frame Report"},
9815     {0x07, "STA Statistics Report"},
9816     {0x08, "Location Configuration Information (LCI) Report"},
9817     {0x09, "Transmit Stream Measurement Report"},
9818     {0x00, NULL}
9819   };
9820
9821   static const true_false_string hf_tag_measure_report_frame_info_frame_type_flag = {
9822     "Measurement Pilot Frame",
9823     "Beacon/Probe Response Frame"
9824   };
9825
9826   static const true_false_string hf_tag_measure_map_field_bss_flag = {
9827     "At least one MPDU was received by another BSS or IBSS in the measurement period.",
9828     "No MPDUs were received from another BSS or IBSS in the measurement period."
9829   };
9830
9831   static const true_false_string hf_tag_measure_detected_not_detected = {
9832     "Detected",
9833     "Not Detected"
9834   };
9835
9836   static const true_false_string hf_tag_measure_true_false = {
9837     "True",
9838     "False"
9839   };
9840
9841   static const value_string hf_tag_measure_request_measurement_mode_flags[] = {
9842     {0x00, "Passive"},
9843     {0x01, "Active"},
9844     {0x02, "Beacon Table"},
9845     {0x00, NULL}
9846   };
9847
9848   static const value_string hf_tag_measure_request_reporting_condition_flags[] = {
9849     {0x00, "Report to be issued after each measurement."},
9850     {0x01, "The measured RCPI level is greater than an absolute threshold."},
9851     {0x02, "The measured RCPI level is less than an absolute threshold."},
9852     {0x03, "The measured RSNI level is greater than an absolute threshold."},
9853     {0x04, "The measured RSNI level is less than an absolute threshold."},
9854     {0x05, "The measured RCPI level is greater than a threshold defined by an offset from the serving AP's reference RCPI."},
9855     {0x06, "The measured RCPI level is less than a threshold defined by an offset from the serving AP's reference RCPI."},
9856     {0x07, "The measured RSNI level is greater than a threshold defined by an offset from the serving AP's reference RSNI."},
9857     {0x08, "The measured RSNI level is less than a threshold defined by an offset from the serving AP's reference RSNI."},
9858     {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."},
9859     {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."},
9860     {0xfe, "Report not required to be issued"},
9861     {0x00, NULL}
9862   };
9863
9864   static const value_string hf_tag_measure_request_group_id_flags[] = {
9865     {0x00, "STA Counters from dot11CountersTable"},
9866     {0x01, "STA Counters from dot11MacStatistics group"},
9867     {0x02, "QoS STA Counters for UP0 from dot11QosCountersTable"},
9868     {0x03, "QoS STA Counters for UP1 from dot11QosCountersTable"},
9869     {0x04, "QoS STA Counters for UP2 from dot11QosCountersTable"},
9870     {0x05, "QoS STA Counters for UP3 from dot11QosCountersTable"},
9871     {0x06, "QoS STA Counters for UP4 from dot11QosCountersTable"},
9872     {0x07, "QoS STA Counters for UP5 from dot11QosCountersTable"},
9873     {0x08, "QoS STA Counters for UP6 from dot11QosCountersTable"},
9874     {0x09, "QoS STA Counters for UP7 from dot11QosCountersTable"},
9875     {0x0a, "BSS Average Access Delays"},
9876     {0x0b, "STA Counters from dot11A-MSDU Group"},
9877     {0x0c, "STA Counters from dot11A-MPDU Group"},
9878     {0x0d, "STA Counters from dot11 BAR, Channel Width, PSMP Group"},
9879     {0x0e, "STA Counters from dot11Protection Group"},
9880     {0x0f, "STBC Group"},
9881     {0x00, NULL}
9882   };
9883
9884   static const true_false_string hf_tag_extended_capabilities_flag = {
9885     "Supported",
9886     "Not Supported"
9887   };
9888
9889   /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
9890   static const value_string hf_tag_ext_channel_switch_announcement_switch_mode_flags[] = {
9891     {0x00, "Frames may be transmitted before the channel switch has been completed"},
9892     {0x01, "No more frames are to be transmitted until the channel switch has been completed"},
9893     {0x00, NULL}
9894   };
9895   /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
9896
9897   static hf_register_info ff[] = {
9898
9899     {&ff_timestamp,
9900      {"Timestamp", "wlan_mgt.fixed.timestamp", FT_STRING, BASE_NONE,
9901       NULL, 0, "Timestamp", HFILL }},
9902
9903     {&ff_auth_alg,
9904      {"Authentication Algorithm", "wlan_mgt.fixed.auth.alg",
9905       FT_UINT16, BASE_DEC, VALS (&auth_alg), 0, "Authentication Algorithm", HFILL }},
9906
9907     {&ff_beacon_interval,
9908      {"Beacon Interval", "wlan_mgt.fixed.beacon", FT_DOUBLE, BASE_DEC, NULL, 0,
9909       "Beacon Interval", HFILL }},
9910
9911     {&hf_fixed_parameters,
9912      {"Fixed parameters", "wlan_mgt.fixed.all", FT_UINT16, BASE_DEC, NULL, 0,
9913       "Fixed parameters", HFILL }},
9914
9915     {&hf_tagged_parameters,
9916      {"Tagged parameters", "wlan_mgt.tagged.all", FT_UINT16, BASE_DEC, NULL, 0,
9917       "Tagged parameters", HFILL }},
9918
9919     {&hf_tagged_ssid,
9920      {"SSID", "wlan_mgt.ssid", FT_STRING, BASE_DEC, NULL, 0, 
9921       "SSID", HFILL }},
9922
9923     /*** Begin: Block Ack Params Fixed Field - Dustin Johnson ***/
9924     {&ff_block_ack_params,
9925       {"Block Ack Parameters", "wlan_mgt.fixed.baparams",
9926       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Parameters", HFILL }},
9927
9928     {&ff_block_ack_params_amsdu_permitted,
9929       {"A-MSDUs", "wlan_mgt.fixed.baparams.amsdu",
9930       FT_BOOLEAN, 16, TFS (&ff_block_ack_params_amsdu_permitted_flag), 0x0001, "A-MSDU Permitted in QoS Data MPDUs", HFILL }},
9931
9932     {&ff_block_ack_params_policy,
9933       {"Block Ack Policy", "wlan_mgt.fixed.baparams.policy",
9934       FT_BOOLEAN, 16, TFS (&ff_block_ack_params_policy_flag), 0x0002, "Block Ack Policy", HFILL }},
9935
9936     {&ff_block_ack_params_tid,
9937       {"Traffic Identifier", "wlan_mgt.fixed.baparams.tid",
9938       FT_UINT8, BASE_HEX, NULL, 0x003C, "Traffic Identifier", HFILL }},
9939
9940     {&ff_block_ack_params_buffer_size,
9941       {"Number of Buffers (1 Buffer = 2304 Bytes)", "wlan_mgt.fixed.baparams.buffersize",
9942       FT_UINT16, BASE_DEC, NULL, 0xFFC0, "Number of Buffers", HFILL }},
9943     /*** End: Block Ack Params Fixed Field - Dustin Johnson ***/
9944
9945     /*** Begin: Block Ack Timeout Fixed Field - Dustin Johnson ***/
9946     {&ff_block_ack_timeout,
9947       {"Block Ack Timeout", "wlan_mgt.fixed.batimeout",
9948       FT_UINT16, BASE_HEX, NULL, 0, "Block Ack Timeout", HFILL }},
9949     /*** End: Block Ack Timeout Fixed Field - Dustin Johnson ***/
9950
9951     /*** Begin: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
9952     {&ff_block_ack_ssc,
9953      {"Block Ack Starting Sequence Control (SSC)", "wlan_mgt.fixed.ssc",
9954       FT_UINT16, BASE_HEX, 0, 0, "Block Ack Starting Sequence Control (SSC)", HFILL }},
9955
9956     {&ff_block_ack_ssc_fragment,
9957      {"Fragment", "wlan_mgt.fixed.fragment",
9958       FT_UINT16, BASE_DEC, 0, 0x000f, "Fragment", HFILL }},
9959
9960     {&ff_block_ack_ssc_sequence,
9961      {"Starting Sequence Number", "wlan_mgt.fixed.sequence",
9962       FT_UINT16, BASE_DEC, 0, 0xfff0, "Starting Sequence Number", HFILL }},
9963     /*** End: Block Ack Starting Sequence Control Fixed Field - Dustin Johnson ***/
9964
9965     /*** Begin: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
9966     {&ff_delba_param,
9967      {"Delete Block Ack (DELBA) Parameter Set", "wlan_mgt.fixed.delba.param",
9968       FT_UINT16, BASE_HEX, 0, 0, "Delete Block Ack (DELBA) Parameter Set", HFILL }},
9969
9970     {&ff_delba_param_reserved,
9971      {"Reserved", "wlan_mgt.fixed.delba.param.reserved",
9972       FT_UINT16, BASE_HEX, 0, 0x07ff, "Reserved", HFILL }},
9973
9974     {&ff_delba_param_init,
9975      {"Initiator", "wlan_mgt.fixed.delba.param.initiator",
9976       FT_BOOLEAN, 16, 0, 0x08000, "Initiator", HFILL }},
9977
9978     {&ff_delba_param_tid,
9979      {"TID", "wlan_mgt.fixed.delba.param.tid",
9980       FT_UINT16, BASE_HEX, 0, 0xf000, "Traffic Identifier (TID)", HFILL }},
9981     /*** End: DELBA Parameter Set Fixed Field - Dustin Johnson ***/
9982
9983     /*** Begin: Max Regulation Power Fixed Field - Dustin Johnson ***/
9984     {&ff_max_reg_pwr,
9985      {"Maximum Regulation Power", "wlan_mgt.fixed.maxregpwr",
9986       FT_UINT16, BASE_HEX, 0, 0, "Maximum Regulation Power", HFILL }},
9987     /*** End: Max Regulation Power Fixed Field - Dustin Johnson ***/
9988
9989     /*** Begin: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
9990     {&ff_measurement_pilot_int,
9991      {"Measurement Pilot Interval", "wlan_mgt.fixed.msmtpilotint",
9992       FT_UINT16, BASE_HEX, 0, 0, "Measurement Pilot Interval Fixed Field", HFILL }},
9993     /*** End: Measurement Pilot Interval Fixed Field - Dustin Johnson ***/
9994
9995     /*** Begin: Country String Fixed Field - Dustin Johnson ***/
9996     {&ff_country_str,
9997      {"Country String", "wlan_mgt.fixed.country",
9998       FT_STRING, BASE_NONE, 0, 0, "Country String", HFILL }},
9999     /*** End: Country String Fixed Field - Dustin Johnson ***/
10000
10001     /*** Begin: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
10002     {&ff_max_tx_pwr,
10003      {"Maximum Transmit Power", "wlan_mgt.fixed.maxtxpwr",
10004       FT_UINT8, BASE_HEX, 0, 0, "Maximum Transmit Power", HFILL }},
10005     /*** End: Maximum Transmit Power Fixed Field - Dustin Johnson ***/
10006
10007     /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
10008     {&ff_tx_pwr_used,
10009      {"Transmit Power Used", "wlan_mgt.fixed.txpwr",
10010       FT_UINT8, BASE_HEX, 0, 0, "Transmit Power Used", HFILL }},
10011     /*** End: Transmit Power Used Fixed Field - Dustin Johnson ***/
10012
10013     /*** Begin: Transmit Power Used Fixed Field - Dustin Johnson ***/
10014     {&ff_transceiver_noise_floor,
10015      {"Transceiver Noise Floor", "wlan_mgt.fixed.tnoisefloor",
10016       FT_UINT8, BASE_HEX, 0, 0, "Transceiver Noise Floor", HFILL }},
10017     /*** End: Transceiver Noise Floor Fixed Field - Dustin Johnson ***/
10018
10019     /*** Begin: Channel Width Fixed Field - Dustin Johnson ***/
10020     {&ff_channel_width,
10021      {"Supported Channel Width", "wlan_mgt.fixed.chanwidth",
10022       FT_UINT8, BASE_HEX, VALS (ff_channel_width_vals), 0, "Supported Channel Width", HFILL }},
10023     /*** End: Channel Width Fixed Field - Dustin Johnson ***/
10024
10025     /*** Begin: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
10026     {&ff_qos_info_ap,
10027      {"QoS Inforamtion (AP)", "wlan_mgt.fixed.qosinfo.ap",
10028       FT_UINT8, BASE_HEX, NULL, 0, "QoS Inforamtion (AP)", HFILL }},
10029
10030     {&ff_qos_info_ap_edca_param_set_counter,
10031      {"EDCA Parameter Set Update Count", "wlan_mgt.fixed.qosinfo.ap.edcaupdate",
10032       FT_UINT8, BASE_HEX, NULL, 0x0F, "Enhanced Distributed Channel Access (EDCA) Parameter Set Update Count", HFILL }},
10033
10034     {&ff_qos_info_ap_q_ack,
10035      {"Q-Ack", "wlan_mgt.fixed.qosinfo.ap.qack",
10036       FT_BOOLEAN, 8, TFS (&ff_qos_info_ap_q_ack_flag), 0x10, "QoS Ack", HFILL }},
10037
10038     {&ff_qos_info_ap_queue_req,
10039      {"Queue Request", "wlan_mgt.fixed.qosinfo.ap",
10040       FT_BOOLEAN, 8, TFS (&ff_qos_info_ap_queue_req_flag), 0x20, "Queue Request", HFILL }},
10041
10042     {&ff_qos_info_ap_txop_request,
10043      {"TXOP Request", "wlan_mgt.fixed.qosinfo.ap.txopreq",
10044       FT_BOOLEAN, 8, TFS (&ff_qos_info_ap_txop_request_flag), 0x40, "Transmit Opportunity (TXOP) Request", HFILL }},
10045
10046     {&ff_qos_info_ap_reserved,
10047      {"Reserved", "wlan_mgt.fixed.qosinfo.ap.reserved",
10048       FT_BOOLEAN, 8, NULL, 0x80, "Reserved", HFILL }},
10049     /*** End: QoS Inforamtion AP Fixed Field - Dustin Johnson ***/
10050
10051     /*** Begin: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
10052     {&ff_qos_info_sta,
10053      {"QoS Inforamtion (STA)", "wlan_mgt.fixed.qosinfo.sta",
10054       FT_UINT8, BASE_HEX, NULL, 0, "QoS Inforamtion (STA)", HFILL }},
10055
10056     {&ff_qos_info_sta_ac_vo,
10057      {"AC_VO", "wlan_mgt.fixed.qosinfo.sta.ac.vo",
10058       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x01, "AC_VO", HFILL }},
10059
10060     {&ff_qos_info_sta_ac_vi,
10061      {"AC_VI", "wlan_mgt.fixed.qosinfo.sta.ac.vi",
10062       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x02, "AC_VI", HFILL }},
10063
10064     {&ff_qos_info_sta_ac_bk,
10065      {"AC_BK", "wlan_mgt.fixed.qosinfo.sta.ac.bk",
10066       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x04, "AC_BK", HFILL }},
10067
10068     {&ff_qos_info_sta_ac_be,
10069      {"AC_BE", "wlan_mgt.fixed.qosinfo.sta.ac.be",
10070       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_ac_flag), 0x08, "AC_BE", HFILL }},
10071
10072     {&ff_qos_info_sta_q_ack,
10073      {"Q-Ack", "wlan_mgt.fixed.qosinfo.sta.qack",
10074       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_q_ack_flag), 0x10, "QoS Ack", HFILL }},
10075
10076     {&ff_qos_info_sta_max_sp_len,
10077      {"Service Period (SP) Length", "wlan_mgt.fixed.qosinfo.sta.splen",
10078       FT_UINT8, BASE_HEX, VALS (&ff_qos_info_sta_max_sp_len_flags) , 0x60, "Service Period (SP) Length", HFILL }},
10079
10080     {&ff_qos_info_sta_more_data_ack,
10081      {"More Data Ack", "wlan_mgt.fixed.qosinfo.sta.moredataack",
10082       FT_BOOLEAN, 8, TFS (&ff_qos_info_sta_more_data_ack_flag), 0x80, "More Data Ack", HFILL }},
10083     /*** End: QoS Inforamtion STA Fixed Field - Dustin Johnson ***/
10084
10085     /*** Begin: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
10086     {&ff_sm_pwr_save,
10087      {"Spatial Multiplexing (SM) Power Control", "wlan_mgt.fixed.sm.powercontrol",
10088       FT_UINT8, BASE_HEX, NULL, 0, "Spatial Multiplexing (SM) Power Control", HFILL }},
10089
10090     {&ff_sm_pwr_save_enabled,
10091      {"SM Power Save", "wlan_mgt.fixed.sm.powercontrol.enabled",
10092       FT_BOOLEAN, 8, TFS (&ff_sm_pwr_save_enabled_flag), 0x01, "Spatial Multiplexing (SM) Power Save", HFILL }},
10093
10094     {&ff_sm_pwr_save_sm_mode,
10095      {"SM Mode", "wlan_mgt.fixed.sm.powercontrol.mode",
10096       FT_BOOLEAN, 8, TFS (&ff_sm_pwr_save_sm_mode_flag), 0x02, "Spatial Multiplexing (SM) Mode", HFILL }},
10097
10098     {&ff_sm_pwr_save_reserved,
10099      {"Reserved", "wlan_mgt.fixed.sm.powercontrol.reserved",
10100       FT_UINT8, BASE_HEX, NULL, 0xFC, "Reserved", HFILL }},
10101     /*** End: Spatial Multiplexing (SM) Power Control - Dustin Johnson ***/
10102
10103     /*** Begin: PCO Phase Control Fixed Field - Dustin Johnson ***/
10104     {&ff_pco_phase_cntrl,
10105      {"Phased Coexistence Operation (PCO) Phase Control", "wlan_mgt.fixed.pco.phasecntrl",
10106       FT_BOOLEAN, 0, TFS (&ff_pco_phase_cntrl_flag), 0, "Phased Coexistence Operation (PCO) Phase Control", HFILL }},
10107     /*** End: PCO Phase Control Fixed Field - Dustin Johnson ***/
10108
10109     /*** Begin: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
10110     {&ff_psmp_param_set,
10111      {"Power Save Multi-Poll (PSMP) Parameter Set", "wlan_mgt.fixed.psmp.paramset",
10112       FT_UINT16, BASE_HEX, 0, 0, "Power Save Multi-Poll (PSMP) Parameter Set", HFILL }},
10113
10114     {&ff_psmp_param_set_n_sta,
10115      {"Number of STA Info Fields Present", "wlan_mgt.fixed.psmp.paramset.nsta",
10116       FT_UINT8, BASE_HEX, 0, 0, "Number of STA Info Fields Present", HFILL }},
10117
10118     {&ff_psmp_param_set_more_psmp,
10119      {"More PSMP", "wlan_mgt.fixed.psmp.paramset.more",
10120       FT_BOOLEAN, 0, TFS(&ff_psmp_param_set_more_psmp_flag), 0, "More Power Save Multi-Poll (PSMP)", HFILL }},
10121
10122     {&ff_psmp_param_set_psmp_sequence_duration,
10123      {"PSMP Sequence Duration", "wlan_mgt.fixed.psmp.paramset.seqduration",
10124       FT_UINT16, BASE_DEC, 0, 0, "Power Save Multi-Poll (PSMP) Sequence Duration", HFILL }},
10125     /*** End: PSMP Parameter Set Fixed Field - Dustin Johnson ***/
10126
10127     /*** Begin: MIMO Control Fixed Field - Dustin Johnson ***/
10128     {&ff_mimo_cntrl_nc_index,
10129      {"Nc Index", "wlan_mgt.fixed.mimo.control.ncindex",
10130       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_nc_index_flags), 0x0003, "Number of Columns Less One", HFILL }},
10131
10132     {&ff_mimo_cntrl_nr_index,
10133      {"Nr Index", "wlan_mgt.fixed.mimo.control.nrindex",
10134       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_nr_index_flags), 0x000C, "Number of Rows Less One", HFILL }},
10135
10136     {&ff_mimo_cntrl_channel_width,
10137      {"Channel Width", "wlan_mgt.fixed.mimo.control.chanwidth",
10138       FT_BOOLEAN, 16, TFS(&ff_mimo_cntrl_channel_width_flag), 0x0010, "Channel Width", HFILL }},
10139
10140     {&ff_mimo_cntrl_grouping,
10141      {"Grouping (Ng)", "wlan_mgt.fixed.mimo.control.grouping",
10142       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_grouping_flags), 0x0060, "Grouping (Ng)", HFILL }},
10143
10144     {&ff_mimo_cntrl_coefficient_size,
10145      {"Coefficient Size (Nb)", "wlan_mgt.fixed.mimo.control.cosize",
10146       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_coefficient_size_flags), 0x0180, "Coefficient Size (Nb)", HFILL }},
10147
10148     {&ff_mimo_cntrl_codebook_info,
10149      {"Codebook Information", "wlan_mgt.fixed.mimo.control.codebookinfo",
10150       FT_UINT16, BASE_HEX, VALS (&ff_mimo_cntrl_codebook_info_flags), 0x0600, "Codebook Information", HFILL }},
10151
10152     {&ff_mimo_cntrl_remaining_matrix_segment,
10153      {"Remaining Matrix Segment", "wlan_mgt.fixed.mimo.control.matrixseg",
10154       FT_UINT16, BASE_HEX, 0, 0x3800, "Remaining Matrix Segment", HFILL }},
10155
10156     {&ff_mimo_cntrl_reserved,
10157      {"Reserved", "wlan_mgt.fixed.mimo.control.reserved",
10158       FT_UINT16, BASE_HEX, 0, 0xC000, "Reserved", HFILL }},
10159
10160     {&ff_mimo_cntrl_sounding_timestamp,
10161      {"Sounding Timestamp", "wlan_mgt.fixed.mimo.control.soundingtime",
10162       FT_UINT32, BASE_HEX, 0, 0, "Sounding Timestamp", HFILL }},
10163     /*** End: MIMO Control Fixed Field - Dustin Johnson ***/
10164
10165     /*** Begin: PSMP Station Information Fixed Field - Dustin Johnson ***/
10166     {&ff_psmp_sta_info,
10167      {"Power Save Multi-Poll (PSMP) Station Information", "wlan_mgt.fixed.psmp.stainfo",
10168       FT_UINT8, BASE_HEX, VALS (&ff_psmp_sta_info_flags), 0, "Power Save Multi-Poll (PSMP) Station Information", HFILL }},
10169
10170     {&ff_psmp_sta_info_dtt_start_offset,
10171      {"DTT Start Offset", "wlan_mgt.fixed.psmp.stainfo.dttstart",
10172       FT_UINT16, BASE_HEX, 0, 0, "DTT Start Offset", HFILL }},
10173
10174     {&ff_psmp_sta_info_dtt_duration,
10175      {"DTT Duration", "wlan_mgt.fixed.psmp.stainfo.dttduration",
10176       FT_UINT8, BASE_HEX, 0, 0, "DTT Duration", HFILL }},
10177
10178     {&ff_psmp_sta_info_sta_id,
10179      {"Target Station ID", "wlan_mgt.fixed.psmp.stainfo.staid",
10180       FT_UINT16, BASE_HEX, 0, 0, "Target Station ID", HFILL }},
10181
10182     {&ff_psmp_sta_info_utt_start_offset,
10183      {"UTT Start Offset", "wlan_mgt.fixed.psmp.stainfo.uttstart",
10184       FT_UINT16, BASE_HEX, 0, 0, "UTT Start Offset", HFILL }},
10185
10186     {&ff_psmp_sta_info_utt_duration,
10187      {"UTT Duration", "wlan_mgt.fixed.psmp.stainfo.uttduration",
10188       FT_UINT16, BASE_HEX, 0, 0, "UTT Duration", HFILL }},
10189
10190     {&ff_psmp_sta_info_reserved_small,
10191      {"Reserved", "wlan_mgt.fixed.psmp.stainfo.reserved",
10192       FT_UINT16, BASE_HEX, 0, 0, "Reserved", HFILL }},
10193
10194     {&ff_psmp_sta_info_reserved_large,
10195      {"Reserved", "wlan_mgt.fixed.psmp.stainfo.reserved",
10196       FT_UINT64, BASE_HEX, 0, 0, "Reserved", HFILL }},
10197
10198     {&ff_psmp_sta_info_psmp_multicast_id,
10199      {"Power Save Multi-Poll (PSMP) Multicast ID", "wlan_mgt.fixed.psmp.stainfo.multicastid",
10200       FT_UINT64, BASE_HEX, 0, 0, "Power Save Multi-Poll (PSMP) Multicast ID", HFILL }},
10201     /*** End: PSMP Station Information Fixed Field - Dustin Johnson ***/
10202
10203     /*** Begin: Antenna Selection Fixed Field - Dustin Johnson ***/
10204     {&ff_ant_selection,
10205      {"Antenna Selection", "wlan_mgt.fixed.antsel",
10206       FT_UINT8, BASE_HEX, 0, 0, "Antenna Selection", HFILL }},
10207
10208     {&ff_ant_selection_0,
10209      {"Antenna 0", "wlan_mgt.fixed.antsel.ant0",
10210       FT_UINT8, BASE_HEX, 0, 0x01, "Antenna 0", HFILL }},
10211
10212     {&ff_ant_selection_1,
10213      {"Antenna 1", "wlan_mgt.fixed.antsel.ant1",
10214       FT_UINT8, BASE_HEX, 0, 0x02, "Antenna 1", HFILL }},
10215
10216     {&ff_ant_selection_2,
10217      {"Antenna 2", "wlan_mgt.fixed.antsel.ant2",
10218       FT_UINT8, BASE_HEX, 0, 0x04, "Antenna 2", HFILL }},
10219
10220     {&ff_ant_selection_3,
10221      {"Antenna 3", "wlan_mgt.fixed.antsel.ant3",
10222       FT_UINT8, BASE_HEX, 0, 0x08, "Antenna 3", HFILL }},
10223
10224     {&ff_ant_selection_4,
10225      {"Antenna 4", "wlan_mgt.fixed.antsel.ant4",
10226       FT_UINT8, BASE_HEX, 0, 0x10, "Antenna 4", HFILL }},
10227
10228     {&ff_ant_selection_5,
10229      {"Antenna 5", "wlan_mgt.fixed.antsel.ant5",
10230       FT_UINT8, BASE_HEX, 0, 0x20, "Antenna 5", HFILL }},
10231
10232     {&ff_ant_selection_6,
10233      {"Antenna 6", "wlan_mgt.fixed.antsel.ant6",
10234       FT_UINT8, BASE_HEX, 0, 0x40, "Antenna 6", HFILL }},
10235
10236     {&ff_ant_selection_7,
10237      {"Antenna 7", "wlan_mgt.fixed.antsel.ant7",
10238       FT_UINT8, BASE_HEX, 0, 0x80, "Antenna 7", HFILL }},
10239     /*** End: Antenna Selection Fixed Field - Dustin Johnson ***/
10240
10241     /*** Begin: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
10242     {&ff_ext_channel_switch_announcement,
10243      {"Extended Channel Switch Announcement", "wlan_mgt.fixed.extchansw",
10244       FT_UINT32, BASE_HEX, 0, 0, "", HFILL }},
10245     /*** End: Extended Channel Switch Announcement Fixed Field - Dustin Johnson ***/
10246
10247     /*** Begin: HT Information Fixed Field - Dustin Johnson ***/
10248     {&ff_ht_info,
10249      {"HT Information", "wlan_mgt.fixed.extchansw",
10250       FT_UINT8, BASE_HEX, 0, 0, "HT Information Fixed Field", HFILL }},
10251
10252     {&ff_ht_info_information_request,
10253      {"Information Request", "wlan_mgt.fixed.mimo.control.chanwidth",
10254       FT_BOOLEAN, 8, TFS(&ff_ht_info_information_request_flag), 0x01, "Information Request", HFILL }},
10255
10256     {&ff_ht_info_40_mhz_intolerant,
10257      {"40 MHz Intolerant", "wlan_mgt.fixed.mimo.control.chanwidth",
10258       FT_BOOLEAN, 8, TFS(&ff_ht_info_40_mhz_intolerant_flag), 0x02, "40 MHz Intolerant", HFILL }},
10259
10260     {&ff_ht_info_sta_chan_width,
10261      {"Station Channel Width", "wlan_mgt.fixed.mimo.control.chanwidth",
10262       FT_BOOLEAN, 8, TFS(&ff_ht_info_sta_chan_width_flag), 0x04, "Station Channel Width", HFILL }},
10263
10264     {&ff_ht_info_reserved,
10265      {"Reserved", "wlan_mgt.fixed.extchansw",
10266       FT_UINT8, BASE_HEX, 0, 0xF8, "Reserved Field", HFILL }},
10267     /*** End: HT Information Fixed Field - Dustin Johnson ***/
10268
10269     /*** Begin: HT Action Fixed Field - Dustin Johnson ***/
10270     {&ff_ht_action,
10271      {"HT Action", "wlan_mgt.fixed.htact",
10272       FT_UINT8, BASE_HEX, VALS (&ff_ht_action_flags), 0, "HT Action Code", HFILL }},
10273     /*** End: HT Action Fixed Field - Dustin Johnson ***/
10274
10275     /*** Begin: MIMO CSI Matrices Report - Dustin Johnson ***/
10276     {&ff_mimo_csi_snr,
10277      {"Signal to Noise Ratio (SNR)", "wlan_mgt.mimo.csimatrices.snr",
10278       FT_UINT8, BASE_HEX, NULL, 0, "Signal to Noise Ratio (SNR)", HFILL }},
10279     /*** End: MIMO CSI Matrices Report - Dustin Johnson ***/
10280
10281     {&ff_capture,
10282      {"Capabilities", "wlan_mgt.fixed.capabilities", FT_UINT16, BASE_HEX, NULL, 0,
10283       "Capability information", HFILL }},
10284
10285     {&ff_cf_ess,
10286      {"ESS capabilities", "wlan_mgt.fixed.capabilities.ess",
10287       FT_BOOLEAN, 16, TFS (&cf_ess_flags), 0x0001, "ESS capabilities", HFILL }},
10288
10289     {&ff_cf_ibss,
10290      {"IBSS status", "wlan_mgt.fixed.capabilities.ibss",
10291       FT_BOOLEAN, 16, TFS (&cf_ibss_flags), 0x0002, "IBSS participation", HFILL }},
10292
10293     {&ff_cf_sta_poll,
10294      {"CFP participation capabilities", "wlan_mgt.fixed.capabilities.cfpoll.sta",
10295       FT_UINT16, BASE_HEX, VALS (&sta_cf_pollable), 0x020C,
10296       "CF-Poll capabilities for a STA", HFILL }},
10297
10298     {&ff_cf_ap_poll,
10299      {"CFP participation capabilities", "wlan_mgt.fixed.capabilities.cfpoll.ap",
10300       FT_UINT16, BASE_HEX, VALS (&ap_cf_pollable), 0x020C,
10301       "CF-Poll capabilities for an AP", HFILL }},
10302
10303     {&ff_cf_privacy,
10304      {"Privacy", "wlan_mgt.fixed.capabilities.privacy",
10305       FT_BOOLEAN, 16, TFS (&cf_privacy_flags), 0x0010, "WEP support", HFILL }},
10306
10307     {&ff_cf_preamble,
10308      {"Short Preamble", "wlan_mgt.fixed.capabilities.preamble",
10309       FT_BOOLEAN, 16, TFS (&cf_preamble_flags), 0x0020, "Short Preamble", HFILL }},
10310
10311     {&ff_cf_pbcc,
10312      {"PBCC", "wlan_mgt.fixed.capabilities.pbcc",
10313       FT_BOOLEAN, 16, TFS (&cf_pbcc_flags), 0x0040, "PBCC Modulation", HFILL }},
10314
10315     {&ff_cf_agility,
10316      {"Channel Agility", "wlan_mgt.fixed.capabilities.agility",
10317       FT_BOOLEAN, 16, TFS (&cf_agility_flags), 0x0080, "Channel Agility", HFILL }},
10318
10319     {&ff_cf_spec_man,
10320      {"Spectrum Management", "wlan_mgt.fixed.capabilities.spec_man",
10321       FT_BOOLEAN, 16, TFS (&cf_spec_man_flags), 0x0100, "Spectrum Management", HFILL }},
10322
10323     {&ff_short_slot_time,
10324      {"Short Slot Time", "wlan_mgt.fixed.capabilities.short_slot_time",
10325       FT_BOOLEAN, 16, TFS (&short_slot_time_flags), 0x0400, "Short Slot Time",
10326       HFILL }},
10327
10328     {&ff_cf_apsd,
10329      {"Automatic Power Save Delivery", "wlan_mgt.fixed.capabilities.apsd",
10330       FT_BOOLEAN, 16, TFS (&cf_apsd_flags), 0x0800, "Automatic Power Save Delivery", HFILL }},
10331
10332     {&ff_dsss_ofdm,
10333      {"DSSS-OFDM", "wlan_mgt.fixed.capabilities.dsss_ofdm",
10334       FT_BOOLEAN, 16, TFS (&dsss_ofdm_flags), 0x2000, "DSSS-OFDM Modulation",
10335       HFILL }},
10336
10337     {&ff_cf_del_blk_ack,
10338      {"Delayed Block Ack", "wlan_mgt.fixed.capabilities.del_blk_ack",
10339       FT_BOOLEAN, 16, TFS (&cf_del_blk_ack_flags), 0x4000, "Delayed Block Ack", HFILL }},
10340
10341     {&ff_cf_imm_blk_ack,
10342      {"Immediate Block Ack", "wlan_mgt.fixed.capabilities.imm_blk_ack",
10343       FT_BOOLEAN, 16, TFS (&cf_imm_blk_ack_flags), 0x8000, "Immediate Block Ack", HFILL }},
10344
10345     {&ff_auth_seq,
10346      {"Authentication SEQ", "wlan_mgt.fixed.auth_seq",
10347       FT_UINT16, BASE_HEX, NULL, 0, "Authentication Sequence Number", HFILL }},
10348
10349     {&ff_assoc_id,
10350      {"Association ID", "wlan_mgt.fixed.aid",
10351       FT_UINT16, BASE_HEX, NULL, 0, "Association ID", HFILL }},
10352
10353     {&ff_listen_ival,
10354      {"Listen Interval", "wlan_mgt.fixed.listen_ival",
10355       FT_UINT16, BASE_HEX, NULL, 0, "Listen Interval", HFILL }},
10356
10357     {&ff_current_ap,
10358      {"Current AP", "wlan_mgt.fixed.current_ap",
10359       FT_ETHER, BASE_NONE, NULL, 0, "MAC address of current AP", HFILL }},
10360
10361     {&ff_reason,
10362      {"Reason code", "wlan_mgt.fixed.reason_code",
10363       FT_UINT16, BASE_HEX, VALS (&reason_codes), 0,
10364       "Reason for unsolicited notification", HFILL }},
10365
10366     {&ff_status_code,
10367      {"Status code", "wlan_mgt.fixed.status_code",
10368       FT_UINT16, BASE_HEX, VALS (&status_codes), 0,
10369       "Status of requested event", HFILL }},
10370
10371     {&ff_category_code,
10372      {"Category code", "wlan_mgt.fixed.category_code",
10373       FT_UINT16, BASE_DEC, VALS (&category_codes), 0,
10374       "Management action category", HFILL }},
10375
10376     {&ff_action_code,
10377      {"Action code", "wlan_mgt.fixed.action_code",
10378       FT_UINT16, BASE_DEC, VALS (&action_codes), 0,
10379       "Management action code", HFILL }},
10380
10381     {&ff_dialog_token,
10382      {"Dialog token", "wlan_mgt.fixed.dialog_token",
10383       FT_UINT8, BASE_HEX, NULL, 0, "Management action dialog token", HFILL }},
10384
10385     {&ff_marvell_action_type,
10386      {"Marvell Action type", "wlan_mgt.fixed.mrvl_action_type",
10387       FT_UINT8, BASE_DEC, VALS (&vendor_action_types_mrvl), 0,
10388       "Vendor Specific Action Type (Marvell)", HFILL }},
10389
10390     {&ff_marvell_mesh_mgt_action_code,
10391      {"Mesh action(Marvell)", "wlan_mgt.fixed.mrvl_mesh_action",
10392       FT_UINT8, BASE_HEX, VALS (&mesh_mgt_action_codes_mrvl), 0,
10393       "Mesh action code(Marvell)", HFILL }},
10394
10395     {&ff_mesh_mgt_length,
10396      {"Message Length", "wlan_mgt.fixed.length",
10397       FT_UINT8, BASE_DEC, NULL, 0, "Message Length", HFILL }},
10398
10399     {&ff_mesh_mgt_mode,
10400      {"Message Mode", "wlan_mgt.fixed.mode",
10401       FT_UINT8, BASE_HEX, NULL, 0, "Message Mode", HFILL }},
10402
10403     {&ff_mesh_mgt_ttl,
10404      {"Message TTL", "wlan_mgt.fixed.ttl",
10405       FT_UINT8, BASE_DEC, NULL, 0, "Message TTL", HFILL }},
10406
10407     {&ff_mesh_mgt_dstcount,
10408      {"Destination Count", "wlan_mgt.fixed.dstcount",
10409       FT_UINT8, BASE_DEC, NULL, 0, "Destination Count", HFILL }},
10410
10411     {&ff_mesh_mgt_hopcount,
10412      {"Hop Count", "wlan_mgt.fixed.hopcount",
10413       FT_UINT8, BASE_DEC, NULL, 0, "Hop Count", HFILL }},
10414
10415     {&ff_mesh_mgt_rreqid,
10416      {"RREQ ID", "wlan_mgt.fixed.rreqid",
10417       FT_UINT32, BASE_DEC, NULL, 0, "RREQ ID", HFILL }},
10418
10419     {&ff_mesh_mgt_sa,
10420      {"Source Address", "wlan_mgt.fixed.sa",
10421       FT_ETHER, BASE_NONE, NULL, 0, "Source MAC address", HFILL }},
10422
10423     {&ff_mesh_mgt_ssn,
10424      {"SSN", "wlan_mgt.fixed.ssn",
10425       FT_UINT32, BASE_DEC, NULL, 0, "Source Sequence Number", HFILL }},
10426
10427     {&ff_mesh_mgt_metric,
10428      {"Metric", "wlan_mgt.fixed.metric",
10429       FT_UINT32, BASE_DEC, NULL, 0, "Route Metric", HFILL }},
10430
10431     {&ff_mesh_mgt_flags,
10432      {"RREQ Flags", "wlan_mgt.fixed.hopcount",
10433       FT_UINT8, BASE_HEX, NULL, 0, "RREQ Flags", HFILL }},
10434
10435     {&ff_mesh_mgt_da,
10436      {"Destination Address", "wlan_mgt.fixed.da",
10437       FT_ETHER, BASE_NONE, NULL, 0, "Destination MAC address", HFILL }},
10438
10439     {&ff_mesh_mgt_dsn,
10440      {"DSN", "wlan_mgt.fixed.dsn",
10441       FT_UINT32, BASE_DEC, NULL, 0, "Destination Sequence Number", HFILL }},
10442
10443     {&ff_mesh_mgt_lifetime,
10444      {"Lifetime", "wlan_mgt.fixed.lifetime",
10445       FT_UINT32, BASE_DEC, NULL, 0, "Route Lifetime", HFILL }},
10446
10447     {&ff_wme_action_code,
10448      {"Action code", "wlan_mgt.fixed.action_code",
10449       FT_UINT16, BASE_HEX, VALS (&wme_action_codes), 0,
10450       "Management notification action code", HFILL }},
10451
10452     {&ff_wme_status_code,
10453      {"Status code", "wlan_mgt.fixed.status_code",
10454       FT_UINT16, BASE_HEX, VALS (&wme_status_codes), 0,
10455       "Management notification setup response status code", HFILL }},
10456
10457     {&ff_qos_action_code,
10458      {"Action code", "wlan_mgt.fixed.action_code",
10459       FT_UINT16, BASE_HEX, VALS (&qos_action_codes), 0,
10460       "QoS management action code", HFILL }},
10461
10462     /*** Begin: Block Ack Action Fixed Field - Dustin Johnson ***/
10463     {&ff_ba_action,
10464      {"Action code", "wlan_mgt.fixed.action_code",
10465       FT_UINT8, BASE_HEX, VALS (&ba_action_codes), 0,
10466       "Block Ack action code", HFILL }},
10467     /*** End: Block Ack Action Fixed Field - Dustin Johnson ***/
10468
10469     {&ff_dls_action_code,
10470      {"Action code", "wlan_mgt.fixed.action_code",
10471       FT_UINT16, BASE_HEX, VALS (&dls_action_codes), 0,
10472       "DLS management action code", HFILL }},
10473
10474     {&ff_dst_mac_addr,
10475      {"Destination address", "wlan_mgt.fixed.dst_mac_addr",
10476       FT_ETHER, BASE_NONE, NULL, 0, "Destination MAC address", HFILL }},
10477
10478     {&ff_src_mac_addr,
10479      {"Source address", "wlan_mgt.fixed.src_mac_addr",
10480       FT_ETHER, BASE_NONE, NULL, 0, "Source MAC address", HFILL }},
10481
10482     {&ff_dls_timeout,
10483      {"DLS timeout", "wlan_mgt.fixed.dls_timeout",
10484       FT_UINT16, BASE_HEX, NULL, 0, "DLS timeout value", HFILL }},
10485
10486     {&tag_number,
10487      {"Tag", "wlan_mgt.tag.number",
10488       FT_UINT8, BASE_DEC, VALS(tag_num_vals), 0,
10489       "Element ID", HFILL }},
10490
10491     {&tag_length,
10492      {"Tag length", "wlan_mgt.tag.length",
10493       FT_UINT32, BASE_DEC, NULL, 0, "Length of tag", HFILL }},
10494
10495     {&tag_interpretation,
10496      {"Tag interpretation", "wlan_mgt.tag.interpretation",
10497       FT_STRING, BASE_NONE, NULL, 0, "Interpretation of tag", HFILL }},
10498
10499     {&tag_oui,
10500      {"OUI", "wlan_mgt.tag.oui",
10501       FT_BYTES, BASE_NONE, NULL, 0, "OUI of vendor specific IE", HFILL }},
10502
10503     {&tim_length,
10504      {"TIM length", "wlan_mgt.tim.length",
10505       FT_UINT8, BASE_DEC, NULL, 0,
10506       "Traffic Indication Map length", HFILL }},
10507
10508     {&tim_dtim_count,
10509      {"DTIM count", "wlan_mgt.tim.dtim_count",
10510       FT_UINT8, BASE_DEC, NULL, 0,
10511       "DTIM count", HFILL }},
10512
10513     {&tim_dtim_period,
10514      {"DTIM period", "wlan_mgt.tim.dtim_period",
10515       FT_UINT8, BASE_DEC, NULL, 0,
10516       "DTIM period", HFILL }},
10517
10518     {&tim_bmapctl,
10519      {"Bitmap control", "wlan_mgt.tim.bmapctl",
10520       FT_UINT8, BASE_HEX, NULL, 0,
10521       "Bitmap control", HFILL }},
10522
10523     {&rsn_cap,
10524      {"RSN Capabilities", "wlan_mgt.rsn.capabilities", FT_UINT16, BASE_HEX,
10525       NULL, 0, "RSN Capability information", HFILL }},
10526
10527     {&rsn_cap_preauth,
10528      {"RSN Pre-Auth capabilities", "wlan_mgt.rsn.capabilities.preauth",
10529       FT_BOOLEAN, 16, TFS (&rsn_preauth_flags), 0x0001,
10530       "RSN Pre-Auth capabilities", HFILL }},
10531
10532     {&rsn_cap_no_pairwise,
10533      {"RSN No Pairwise capabilities", "wlan_mgt.rsn.capabilities.no_pairwise",
10534       FT_BOOLEAN, 16, TFS (&rsn_no_pairwise_flags), 0x0002,
10535       "RSN No Pairwise capabilities", HFILL }},
10536
10537     {&rsn_cap_ptksa_replay_counter,
10538      {"RSN PTKSA Replay Counter capabilities",
10539       "wlan_mgt.rsn.capabilities.ptksa_replay_counter",
10540       FT_UINT16, BASE_HEX, VALS (&rsn_cap_replay_counter), 0x000C,
10541       "RSN PTKSA Replay Counter capabilities", HFILL }},
10542
10543     {&rsn_cap_gtksa_replay_counter,
10544      {"RSN GTKSA Replay Counter capabilities",
10545       "wlan_mgt.rsn.capabilities.gtksa_replay_counter",
10546       FT_UINT16, BASE_HEX, VALS (&rsn_cap_replay_counter), 0x0030,
10547       "RSN GTKSA Replay Counter capabilities", HFILL }},
10548
10549     {&ht_cap,
10550      {"HT Capabilities Info", "wlan_mgt.ht.capabilities", FT_UINT16, BASE_HEX,
10551       NULL, 0, "HT Capability information", HFILL }},
10552
10553     {&ht_vs_cap,
10554      {"HT Capabilities Info (VS)", "wlan_mgt.vs.ht.capabilities", FT_UINT16, BASE_HEX,
10555       NULL, 0, "Vendor Specific HT Capability information", HFILL }},
10556
10557     {&ht_ldpc_coding,
10558      {"HT LDPC coding capability", "wlan_mgt.ht.capabilities.ldpccoding",
10559       FT_BOOLEAN, 16, TFS (&ht_ldpc_coding_flag), 0x0001,
10560       "HT LDPC coding capability", HFILL }},
10561
10562     {&ht_chan_width,
10563      {"HT Support channel width", "wlan_mgt.ht.capabilities.width",
10564       FT_BOOLEAN, 16, TFS (&ht_chan_width_flag), 0x0002,
10565       "HT Support channel width", HFILL }},
10566
10567     {&ht_sm_pwsave,
10568      {"HT SM Power Save", "wlan_mgt.ht.capabilities.sm",
10569       FT_UINT16, BASE_HEX, VALS (&ht_sm_pwsave_flag), 0x000c,
10570       "HT SM Power Save", HFILL }},
10571
10572     {&ht_green,
10573      {"HT Green Field", "wlan_mgt.ht.capabilities.green",
10574       FT_BOOLEAN, 16, TFS (&ht_green_flag), 0x0010,
10575       "HT Green Field", HFILL }},
10576
10577     {&ht_short20,
10578      {"HT Short GI for 20MHz", "wlan_mgt.ht.capabilities.short20",
10579       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0020,
10580       "HT Short GI for 20MHz", HFILL }},
10581
10582     {&ht_short40,
10583      {"HT Short GI for 40MHz", "wlan_mgt.ht.capabilities.short40",
10584       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0040,
10585       "HT Short GI for 40MHz", HFILL }},
10586
10587     {&ht_tx_stbc,
10588      {"HT Tx STBC", "wlan_mgt.ht.capabilities.txstbc",
10589       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0080,
10590       "HT Tx STBC", HFILL }},
10591
10592     {&ht_rx_stbc,
10593      {"HT Rx STBC", "wlan_mgt.ht.capabilities.rxstbc",
10594       FT_UINT16, BASE_HEX, VALS (&ht_rx_stbc_flag), 0x0300,
10595       "HT Tx STBC", HFILL }},
10596
10597     {&ht_delayed_block_ack,
10598      {"HT Delayed Block ACK", "wlan_mgt.ht.capabilities.delayedblockack",
10599       FT_BOOLEAN, 16, TFS (&ht_delayed_block_ack_flag), 0x0400,
10600       "HT Delayed Block ACK", HFILL }},
10601
10602     {&ht_max_amsdu,
10603      {"HT Max A-MSDU length", "wlan_mgt.ht.capabilities.amsdu",
10604       FT_BOOLEAN, 16, TFS (&ht_max_amsdu_flag), 0x0800,
10605       "HT Max A-MSDU length", HFILL }},
10606
10607     {&ht_dss_cck_40,
10608      {"HT DSSS/CCK mode in 40MHz", "wlan_mgt.ht.capabilities.dsscck",
10609       FT_BOOLEAN, 16, TFS (&ht_dss_cck_40_flag), 0x1000,
10610       "HT DSS/CCK mode in 40MHz", HFILL }},
10611
10612     {&ht_psmp,
10613      {"HT PSMP Support", "wlan_mgt.ht.capabilities.psmp",
10614       FT_BOOLEAN, 16, TFS (&ht_psmp_flag), 0x2000,
10615       "HT PSMP Support", HFILL }},
10616
10617     {&ht_40_mhz_intolerant,
10618      {"HT Forty MHz Intolerant", "wlan_mgt.ht.capabilities.40mhzintolerant",
10619       FT_BOOLEAN, 16, TFS (&ht_40_mhz_intolerant_flag), 0x4000,
10620       "HT Forty MHz Intolerant", HFILL }},
10621
10622     {&ht_l_sig,
10623      {"HT L-SIG TXOP Protection support", "wlan_mgt.ht.capabilities.lsig",
10624       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x8000,
10625       "HT L-SIG TXOP Protection support", HFILL }},
10626
10627     {&ampduparam,
10628      {"A-MPDU Parameters", "wlan_mgt.ht.ampduparam", FT_UINT16, BASE_HEX,
10629       NULL, 0, "A-MPDU Parameters", HFILL }},
10630
10631     {&ampduparam_vs,
10632      {"A-MPDU Parameters (VS)", "wlan_mgt.vs.ht.ampduparam", FT_UINT16, BASE_HEX,
10633       NULL, 0, "Vendor Specific A-MPDU Parameters", HFILL }},
10634
10635     {&ampduparam_mpdu,
10636      {"Maximum Rx A-MPDU Length", "wlan_mgt.ht.ampduparam.maxlength",
10637       FT_UINT8, BASE_HEX, 0 , 0x03,
10638       "Maximum Rx A-MPDU Length", HFILL }},
10639
10640     {&ampduparam_mpdu_start_spacing,
10641      {"MPDU Density", "wlan_mgt.ht.ampduparam.mpdudensity",
10642       FT_UINT8, BASE_HEX, VALS (&ampduparam_mpdu_start_spacing_flags) , 0x1c,
10643       "MPDU Density", HFILL }},
10644
10645     {&ampduparam_reserved,
10646      {"Reserved", "wlan_mgt.ht.ampduparam.reserved",
10647       FT_UINT8, BASE_HEX, NULL, 0xE0,
10648       "Reserved", HFILL }},
10649
10650     {&mcsset,
10651      {"Rx Supported Modulation and Coding Scheme Set", "wlan_mgt.ht.mcsset",
10652       FT_STRING, BASE_NONE, NULL, 0, "Rx Supported Modulation and Coding Scheme Set", HFILL }},
10653
10654     {&mcsset_vs,
10655      {"Rx Supported Modulation and Coding Scheme Set (VS)", "wlan_mgt.vs.ht.mcsset",
10656       FT_STRING, BASE_NONE, NULL, 0, "Vendor Specific Rx Supported Modulation and Coding Scheme Set", HFILL }},
10657
10658     {&mcsset_rx_bitmask_0to7,
10659      {"Rx Bitmask Bits 0-7", "wlan_mgt.ht.mcsset.rxbitmask.0to7",
10660       FT_UINT32, BASE_HEX, 0, 0x000000ff, "Rx Bitmask Bits 0-7", HFILL }},
10661
10662     {&mcsset_rx_bitmask_8to15,
10663      {"Rx Bitmask Bits 8-15", "wlan_mgt.ht.mcsset.rxbitmask.8to15",
10664       FT_UINT32, BASE_HEX, 0, 0x0000ff00, "Rx Bitmask Bits 8-15", HFILL }},
10665
10666     {&mcsset_rx_bitmask_16to23,
10667      {"Rx Bitmask Bits 16-23", "wlan_mgt.ht.mcsset.rxbitmask.16to23",
10668       FT_UINT32, BASE_HEX, 0, 0x00ff0000, "Rx Bitmask Bits 16-23", HFILL }},
10669
10670     {&mcsset_rx_bitmask_24to31,
10671      {"Rx Bitmask Bits 24-31", "wlan_mgt.ht.mcsset.rxbitmask.24to31",
10672       FT_UINT32, BASE_HEX, 0, 0xff000000, "Rx Bitmask Bits 24-31", HFILL }},
10673
10674     {&mcsset_rx_bitmask_32,
10675      {"Rx Bitmask Bit 32", "wlan_mgt.ht.mcsset.rxbitmask.32",
10676       FT_UINT32, BASE_HEX, 0, 0x000001, "Rx Bitmask Bit 32", HFILL }},
10677
10678     {&mcsset_rx_bitmask_33to38,
10679      {"Rx Bitmask Bits 33-38", "wlan_mgt.ht.mcsset.rxbitmask.33to38",
10680       FT_UINT32, BASE_HEX, 0, 0x00007e, "Rx Bitmask Bits 33-38", HFILL }},
10681
10682     {&mcsset_rx_bitmask_39to52,
10683      {"Rx Bitmask Bits 39-52", "wlan_mgt.ht.mcsset.rxbitmask.39to52",
10684       FT_UINT32, BASE_HEX, 0, 0x1fff80, "Rx Bitmask Bits 39-52", HFILL }},
10685
10686     {&mcsset_rx_bitmask_53to76,
10687      {"Rx Bitmask Bits 53-76", "wlan_mgt.ht.mcsset.rxbitmask.53to76",
10688       FT_UINT32, BASE_HEX, 0, 0x1fffffe0, "Rx Bitmask Bits 53-76", HFILL }},
10689
10690     {&mcsset_highest_data_rate,
10691      {"Highest Supported Data Rate", "wlan_mgt.ht.mcsset.highestdatarate",
10692       FT_UINT16, BASE_HEX, 0, 0x03ff, "Highest Supported Data Rate", HFILL }},
10693
10694     {&mcsset_tx_mcs_set_defined,
10695      {"Tx Supported MCS Set", "wlan_mgt.ht.mcsset.txsetdefined",
10696       FT_BOOLEAN, 16, TFS (&mcsset_tx_mcs_set_defined_flag), 0x0001,
10697       "Tx Supported MCS Set", HFILL }},
10698
10699     {&mcsset_tx_rx_mcs_set_not_equal,
10700      {"Tx and Rx MCS Set", "wlan_mgt.ht.mcsset.txrxmcsnotequal",
10701       FT_BOOLEAN, 16, TFS (&mcsset_tx_rx_mcs_set_not_equal_flag), 0x0002,
10702       "Tx and Rx MCS Set", HFILL }},
10703
10704     {&mcsset_tx_max_spatial_streams,
10705      {"Tx Maximum Number of Spatial Streams Supported", "wlan_mgt.ht.mcsset.txmaxss",
10706       FT_UINT16, BASE_HEX, VALS (&mcsset_tx_max_spatial_streams_flags) , 0x000c,
10707       "Tx Maximum Number of Spatial Streams Supported", HFILL }},
10708
10709     {&mcsset_tx_unequal_modulation,
10710      {"Unequal Modulation", "wlan_mgt.ht.mcsset.txunequalmod",
10711       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0010,
10712       "Unequal Modulation", HFILL }},
10713
10714     {&htex_cap,
10715      {"HT Extended Capabilities", "wlan_mgt.htex.capabilities", FT_UINT16, BASE_HEX,
10716       NULL, 0, "HT Extended Capability information", HFILL }},
10717
10718     {&htex_vs_cap,
10719      {"HT Extended Capabilities (VS)", "wlan_mgt.vs.htex.capabilities", FT_UINT16, BASE_HEX,
10720       NULL, 0, "Vendor Specific HT Extended Capability information", HFILL }},
10721
10722     {&htex_pco,
10723      {"Transmitter supports PCO", "wlan_mgt.htex.capabilities.pco",
10724       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0001,
10725       "Transmitter supports PCO", HFILL }},
10726
10727     {&htex_transtime,
10728      {"Time needed to transition between 20MHz and 40MHz", "wlan_mgt.htex.capabilities.transtime",
10729       FT_UINT16, BASE_HEX, VALS (&htex_transtime_flags), 0x0006,
10730       "Time needed to transition between 20MHz and 40MHz", HFILL }},
10731
10732     {&htex_mcs,
10733      {"MCS Feedback capability", "wlan_mgt.htex.capabilities.mcs",
10734       FT_UINT16, BASE_HEX, VALS (&htex_mcs_flags), 0x0300,
10735       "MCS Feedback capability", HFILL }},
10736
10737     {&htex_htc_support,
10738      {"High Throughput", "wlan_mgt.htex.capabilities.htc",
10739       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0400,
10740       "High Throughput", HFILL }},
10741
10742     {&htex_rd_responder,
10743      {"Reverse Direction Responder", "wlan_mgt.htex.capabilities.rdresponder",
10744       FT_BOOLEAN, 16, TFS (&ht_tf_flag), 0x0800,
10745       "Reverse Direction Responder", HFILL }},
10746
10747     {&txbf,
10748      {"Transmit Beam Forming (TxBF) Capabilities", "wlan_mgt.txbf", FT_UINT16, BASE_HEX,
10749       NULL, 0, "Transmit Beam Forming (TxBF) Capabilities", HFILL }},
10750
10751     {&txbf_vs,
10752      {"Transmit Beam Forming (TxBF) Capabilities (VS)", "wlan_mgt.vs.txbf", FT_UINT16, BASE_HEX,
10753       NULL, 0, "Vendor Specific Transmit Beam Forming (TxBF) Capabilities", HFILL }},
10754
10755     {&txbf_cap,
10756      {"Transmit Beamforming", "wlan_mgt.txbf.txbf",
10757       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000001,
10758       "Transmit Beamforming", HFILL }},
10759
10760     {&txbf_rcv_ssc,
10761      {"Receive Staggered Sounding", "wlan_mgt.txbf.rxss",
10762       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000002,
10763       "Receive Staggered Sounding", HFILL }},
10764
10765     {&txbf_tx_ssc,
10766      {"Transmit Staggered Sounding", "wlan_mgt.txbf.txss",
10767       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000004,
10768       "Transmit staggered sounding", HFILL }},
10769
10770     {&txbf_rcv_ndp,
10771      {"Receive Null Data packet (NDP)", "wlan_mgt.txbf.rxndp",
10772       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000008,
10773       "Receive Null Data packet (NDP)", HFILL }},
10774
10775     {&txbf_tx_ndp,
10776      {"Transmit Null Data packet (NDP)", "wlan_mgt.txbf.txndp",
10777       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000010,
10778       "Transmit Null Data packet (NDP)", HFILL }},
10779
10780     {&txbf_impl_txbf,
10781      {"Implicit TxBF capable", "wlan_mgt.txbf.impltxbf",
10782       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000020,
10783       "Implicit Transmit Beamforming (TxBF) capable", HFILL }},
10784
10785     {&txbf_calib,
10786      {"Calibration", "wlan_mgt.txbf.calibration",
10787       FT_UINT32, BASE_HEX, VALS (&txbf_calib_flag), 0x000000c0,
10788       "Calibration", HFILL }},
10789
10790     {&txbf_expl_csi,
10791      {"STA can apply TxBF using CSI explicit feedback", "wlan_mgt.txbf.csi",
10792       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000100,
10793       "Station can apply TxBF using CSI explicit feedback", HFILL }},
10794
10795     {&txbf_expl_uncomp_fm,
10796      {"STA can apply TxBF using uncompressed beamforming feedback matrix", "wlan_mgt.txbf.fm.uncompressed.tbf",
10797       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000200,
10798       "Station can apply TxBF using uncompressed beamforming feedback matrix", HFILL }},
10799
10800     {&txbf_expl_comp_fm,
10801      {"STA can apply TxBF using compressed beamforming feedback matrix", "wlan_mgt.txbf.fm.compressed.tbf",
10802       FT_BOOLEAN, 32, TFS (&ht_tf_flag), 0x00000400,
10803       "Station can apply TxBF using compressed beamforming feedback matrix", HFILL }},
10804
10805     {&txbf_expl_bf_csi,
10806      {"Receiver can return explicit CSI feedback", "wlan_mgt.txbf.rcsi",
10807       FT_UINT32, BASE_HEX, VALS (&txbf_feedback_flags), 0x00001800,
10808       "Receiver can return explicit CSI feedback", HFILL }},
10809
10810     {&txbf_expl_uncomp_fm_feed,
10811      {"Receiver can return explicit uncompressed Beamforming Feedback Matrix", "wlan_mgt.txbf.fm.uncompressed.rbf",
10812       FT_UINT32, BASE_HEX, VALS (&txbf_feedback_flags), 0x00006000,
10813       "Receiver can return explicit uncompressed Beamforming Feedback Matrix", HFILL }},
10814
10815     {&txbf_expl_comp_fm_feed,
10816      {"STA can compress and use compressed Beamforming Feedback Matrix", "wlan_mgt.txbf.fm.compressed.bf",
10817       FT_UINT32, BASE_HEX, VALS (&txbf_feedback_flags), 0x00018000,
10818       "Station can compress and use compressed Beamforming Feedback Matrix", HFILL }},
10819
10820     {&txbf_min_group,
10821      {"Minimal grouping used for explicit feedback reports", "wlan_mgt.txbf.mingroup",
10822       FT_UINT32, BASE_HEX, VALS (&txbf_min_group_flags), 0x00060000,
10823       "Minimal grouping used for explicit feedback reports", HFILL }},
10824
10825     {&txbf_csi_num_bf_ant,
10826      {"Max antennae STA can support when CSI feedback required", "wlan_mgt.txbf.csinumant",
10827       FT_UINT32, BASE_HEX, VALS (&txbf_antenna_flags), 0x00180000,
10828       "Max antennae station can support when CSI feedback required", HFILL }},
10829
10830     {&txbf_uncomp_sm_bf_ant,
10831      {"Max antennae STA can support when uncompressed Beamforming feedback required", "wlan_mgt.txbf.fm.uncompressed.maxant",
10832       FT_UINT32, BASE_HEX, VALS (&txbf_antenna_flags), 0x00600000,
10833       "Max antennae station can support when uncompressed Beamforming feedback required", HFILL }},
10834
10835     {&txbf_comp_sm_bf_ant,
10836      {"Max antennae STA can support when compressed Beamforming feedback required", "wlan_mgt.txbf.fm.compressed.maxant",
10837       FT_UINT32, BASE_HEX, VALS (&txbf_antenna_flags), 0x01800000,
10838       "Max antennae station can support when compressed Beamforming feedback required", HFILL }},
10839
10840     {&txbf_csi_max_rows_bf,
10841      {"Maximum number of rows of CSI explicit feeback", "wlan_mgt.txbf.csi.maxrows",
10842       FT_UINT32, BASE_HEX, VALS (&txbf_csi_max_rows_bf_flags), 0x06000000,
10843       "Maximum number of rows of CSI explicit feeback", HFILL }},
10844
10845     {&txbf_chan_est,
10846      {"Maximum number of space time streams for which channel dimensions can be simultaneously estimated", "wlan_mgt.txbf.channelest",
10847       FT_UINT32, BASE_HEX, VALS (&txbf_chan_est_flags), 0x18000000,
10848       "Maximum number of space time streams for which channel dimensions can be simultaneously estimated", HFILL }},
10849
10850     {&txbf_resrv,
10851      {"Reserved", "wlan_mgt.txbf.reserved",
10852       FT_UINT32, BASE_HEX, NULL, 0xe0000000,
10853       "Reserved", HFILL }},
10854
10855     {&hta_cap,
10856      {"HT Additional Capabilities", "wlan_mgt.hta.capabilities", FT_UINT16, BASE_HEX,
10857       NULL, 0, "HT Additional Capability information", HFILL }},
10858
10859     {&hta_ext_chan_offset,
10860      {"Extension Channel Offset", "wlan_mgt.hta.capabilities.extchan",
10861       FT_UINT16, BASE_HEX, VALS (&hta_ext_chan_offset_flag), 0x0003,
10862       "Extension Channel Offset", HFILL }},
10863
10864     {&hta_rec_tx_width,
10865      {"Recommended Tx Channel Width", "wlan_mgt.hta.capabilities.rectxwidth",
10866       FT_BOOLEAN, 16, TFS (&hta_rec_tx_width_flag), 0x0004,
10867       "Recommended Transmit Channel Width", HFILL }},
10868
10869     {&hta_rifs_mode,
10870      {"Reduced Interframe Spacing (RIFS) Mode", "wlan_mgt.hta.capabilities.rifsmode",
10871       FT_BOOLEAN, 16, TFS (&hta_rifs_mode_flag), 0x0008,
10872       "Reduced Interframe Spacing (RIFS) Mode", HFILL }},
10873
10874     {&hta_controlled_access,
10875      {"Controlled Access Only", "wlan_mgt.hta.capabilities.controlledaccess",
10876       FT_BOOLEAN, 16, TFS (&hta_controlled_access_flag), 0x0010,
10877       "Controlled Access Only", HFILL }},
10878
10879     {&hta_service_interval,
10880      {"Service Interval Granularity", "wlan_mgt.hta.capabilities.serviceinterval",
10881       FT_UINT16, BASE_HEX, VALS (&hta_service_interval_flag), 0x00E0,
10882       "Service Interval Granularity", HFILL }},
10883
10884     {&hta_operating_mode,
10885      {"Operating Mode", "wlan_mgt.hta.capabilities.operatingmode",
10886       FT_UINT16, BASE_HEX, VALS (&hta_operating_mode_flag), 0x0003,
10887       "Operating Mode", HFILL }},
10888
10889     {&hta_non_gf_devices,
10890      {"Non Greenfield (GF) devices Present", "wlan_mgt.hta.capabilities.nongfdevices",
10891       FT_BOOLEAN, 16, TFS (&hta_non_gf_devices_flag), 0x0004,
10892       "on Greenfield (GF) devices Present", HFILL }},
10893
10894     {&hta_basic_stbc_mcs,
10895      {"Basic STB Modulation and Coding Scheme (MCS)", "wlan_mgt.hta.capabilities.",
10896       FT_UINT16, BASE_HEX, NULL , 0x007f,
10897       "Basic STB Modulation and Coding Scheme (MCS)", HFILL }},
10898
10899     {&hta_dual_stbc_protection,
10900      {"Dual Clear To Send (CTS) Protection", "wlan_mgt.hta.capabilities.",
10901       FT_BOOLEAN, 16, TFS (&hta_dual_stbc_protection_flag), 0x0080,
10902       "Dual Clear To Send (CTS) Protection", HFILL }},
10903
10904     {&hta_secondary_beacon,
10905      {"Secondary Beacon", "wlan_mgt.hta.capabilities.",
10906       FT_BOOLEAN, 16, TFS (&hta_secondary_beacon_flag), 0x0100,
10907       "Secondary Beacon", HFILL }},
10908
10909     {&hta_lsig_txop_protection,
10910      {"L-SIG TXOP Protection Support", "wlan_mgt.hta.capabilities.",
10911       FT_BOOLEAN, 16, TFS (&hta_lsig_txop_protection_flag), 0x0200,
10912       "L-SIG TXOP Protection Support", HFILL }},
10913
10914     {&hta_pco_active,
10915      {"Phased Coexistence Operation (PCO) Active", "wlan_mgt.hta.capabilities.",
10916       FT_BOOLEAN, 16, TFS (&hta_pco_active_flag), 0x0400,
10917       "Phased Coexistence Operation (PCO) Active", HFILL }},
10918
10919     {&hta_pco_phase,
10920      {"Phased Coexistence Operation (PCO) Phase", "wlan_mgt.hta.capabilities.",
10921       FT_BOOLEAN, 16, TFS (&hta_pco_phase_flag), 0x0800,
10922       "Phased Coexistence Operation (PCO) Phase", HFILL }},
10923
10924     {&antsel,
10925      {"Antenna Selection (ASEL) Capabilities", "wlan_mgt.asel",
10926       FT_UINT8, BASE_HEX, NULL, 0, "Antenna Selection (ASEL) Capabilities", HFILL }},
10927
10928     {&antsel_vs,
10929      {"Antenna Selection (ASEL) Capabilities (VS)", "wlan_mgt.vs.asel",
10930       FT_UINT8, BASE_HEX, NULL, 0, "Vendor Specific Antenna Selection (ASEL) Capabilities", HFILL }},
10931
10932     {&antsel_b0,
10933      {"Antenna Selection Capable", "wlan_mgt.asel.capable",
10934       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x01, "Antenna Selection Capable", HFILL }},
10935
10936     {&antsel_b1,
10937      {"Explicit CSI Feedback Based Tx ASEL", "wlan_mgt.asel.txcsi",
10938       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x02, "Explicit CSI Feedback Based Tx ASEL", HFILL }},
10939
10940     {&antsel_b2,
10941      {"Antenna Indices Feedback Based Tx ASEL", "wlan_mgt.asel.txif",
10942       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x04, "Antenna Indices Feedback Based Tx ASEL", HFILL }},
10943
10944     {&antsel_b3,
10945      {"Explicit CSI Feedback", "wlan_mgt.asel.csi",
10946       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x08, "Explicit CSI Feedback", HFILL }},
10947
10948     {&antsel_b4,
10949      {"Antenna Indices Feedback", "wlan_mgt.asel.if",
10950       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x10, "Antenna Indices Feedback", HFILL }},
10951
10952     {&antsel_b5,
10953      {"Rx ASEL", "wlan_mgt.asel.rx",
10954       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x20, "Rx ASEL", HFILL }},
10955
10956     {&antsel_b6,
10957      {"Tx Sounding PPDUs", "wlan_mgt.asel.sppdu",
10958       FT_BOOLEAN, 8, TFS (&ht_tf_flag), 0x40, "Tx Sounding PPDUs", HFILL }},
10959
10960     {&antsel_b7,
10961      {"Reserved", "wlan_mgt.asel.reserved",
10962       FT_UINT8, BASE_HEX, NULL, 0x80, "Reserved", HFILL }},
10963
10964     {&ht_info_delimiter1,
10965      {"HT Information Delimiter #1", "wlan_mgt.ht.info.delim1",
10966       FT_UINT8, BASE_HEX, NULL, 0xff, "HT Information Delimiter #1", HFILL }},
10967
10968     {&ht_info_primary_channel,
10969      {"Primary Channel", "wlan_mgt.ht.info.primarychannel",
10970       FT_UINT8, BASE_DEC, NULL, 0, "Primary Channel", HFILL }},
10971
10972     {&ht_info_secondary_channel_offset,
10973      {"Secondary channel offset", "wlan_mgt.ht.info.secchanoffset",
10974       FT_UINT8, BASE_HEX, VALS (&ht_info_secondary_channel_offset_flags), 0x03, "Secondary channel offset", HFILL }},
10975
10976     {&ht_info_channel_width,
10977      {"Supported channel width", "wlan_mgt.ht.info.chanwidth",
10978       FT_BOOLEAN, 8, TFS (&ht_info_channel_width_flag), 0x04, "Supported channel width", HFILL }},
10979
10980     {&ht_info_rifs_mode,
10981      {"Reduced Interframe Spacing (RIFS)", "wlan_mgt.ht.info.rifs",
10982       FT_BOOLEAN, 8, TFS (&ht_info_rifs_mode_flag), 0x08, "Reduced Interframe Spacing (RIFS)", HFILL }},
10983
10984     {&ht_info_psmp_stas_only,
10985      {"Power Save Multi-Poll (PSMP) stations only", "wlan_mgt.ht.info.psmponly",
10986       FT_BOOLEAN, 8, TFS (&ht_info_psmp_stas_only_flag), 0x10, "Power Save Multi-Poll (PSMP) stations only", HFILL }},
10987
10988     {&ht_info_service_interval_granularity,
10989      {"Shortest service interval", "wlan_mgt.ht.info.",
10990       FT_UINT8, BASE_HEX, VALS (&ht_info_service_interval_granularity_flags), 0xe0, "Shortest service interval", HFILL }},
10991
10992     {&ht_info_delimiter2,
10993      {"HT Information Delimiter #2", "wlan_mgt.ht.info.delim2",
10994       FT_UINT16, BASE_HEX, NULL, 0xffff, "HT Information Delimiter #2", HFILL }},
10995
10996     {&ht_info_operating_mode,
10997      {"Operating mode of BSS", "wlan_mgt.ht.info.operatingmode",
10998       FT_UINT16, BASE_HEX, VALS (&ht_info_operating_mode_flags), 0x0003, "Operating mode of BSS", HFILL }},
10999
11000     {&ht_info_non_greenfield_sta_present,
11001      {"Non-greenfield STAs present", "wlan_mgt.ht.info.greenfield",
11002       FT_BOOLEAN, 16, TFS (&ht_info_non_greenfield_sta_present_flag), 0x0004, "Non-greenfield STAs present", HFILL }},
11003
11004     {&ht_info_transmit_burst_limit,
11005      {"Transmit burst limit", "wlan_mgt.ht.info.burstlim",
11006       FT_BOOLEAN, 16, TFS (&ht_info_transmit_burst_limit_flag), 0x0008, "Transmit burst limit", HFILL }},
11007
11008     {&ht_info_obss_non_ht_stas_present,
11009      {"OBSS non-HT STAs present", "wlan_mgt.ht.info.obssnonht",
11010       FT_BOOLEAN, 16, TFS (&ht_info_obss_non_ht_stas_present_flag), 0x0010, "OBSS non-HT STAs present", HFILL }},
11011
11012     {&ht_info_reserved_1,
11013      {"Reserved", "wlan_mgt.ht.info.reserved1",
11014       FT_UINT16, BASE_HEX, NULL, 0xffe0, "Reserved", HFILL }},
11015
11016     {&ht_info_delimiter3,
11017      {"HT Information Delimiter #3", "wlan_mgt.ht.info.delim3",
11018       FT_UINT16, BASE_HEX, NULL, 0xffff, "HT Information Delimiter #3", HFILL }},
11019
11020     {&ht_info_reserved_2,
11021      {"Reserved", "wlan_mgt.ht.info.reserved2",
11022       FT_UINT16, BASE_HEX, NULL, 0x003f, "Reserved", HFILL }},
11023
11024     {&ht_info_dual_beacon,
11025      {"Dual beacon", "wlan_mgt.ht.info.dualbeacon",
11026       FT_BOOLEAN, 16, TFS (&ht_info_dual_beacon_flag), 0x0040, "Dual beacon", HFILL }},
11027
11028     {&ht_info_dual_cts_protection,
11029      {"Dual Clear To Send (CTS) protection", "wlan_mgt.ht.info.dualcts",
11030       FT_BOOLEAN, 16, TFS (&ht_info_dual_cts_protection_flag), 0x0080, "Dual Clear To Send (CTS) protection", HFILL }},
11031
11032     {&ht_info_secondary_beacon,
11033      {"Beacon ID", "wlan_mgt.ht.info.secondarybeacon",
11034       FT_BOOLEAN, 16, TFS (&ht_info_secondary_beacon_flag), 0x0100, "Beacon ID", HFILL }},
11035
11036     {&ht_info_lsig_txop_protection_full_support,
11037      {"L-SIG TXOP Protection Full Support", "wlan_mgt.ht.info.lsigprotsupport",
11038       FT_BOOLEAN, 16, TFS (&ht_info_lsig_txop_protection_full_support_flag), 0x0200, "L-SIG TXOP Protection Full Support", HFILL }},
11039
11040     {&ht_info_pco_active,
11041      {"Phased Coexistence Operation (PCO)", "wlan_mgt.ht.info.pco.active",
11042       FT_BOOLEAN, 16, TFS (&ht_info_pco_active_flag), 0x0400, "Phased Coexistence Operation (PCO)", HFILL }},
11043
11044     {&ht_info_pco_phase,
11045      {"Phased Coexistence Operation (PCO) Phase", "wlan_mgt.ht.info.pco.phase",
11046       FT_BOOLEAN, 16, TFS (&ht_info_pco_phase_flag), 0x0800, "Phased Coexistence Operation (PCO) Phase", HFILL }},
11047
11048     {&ht_info_reserved_3,
11049      {"Reserved", "wlan_mgt.ht.info.reserved3",
11050       FT_UINT16, BASE_HEX, NULL, 0xf000, "Reserved", HFILL }},
11051
11052     {&hf_tag_secondary_channel_offset,
11053      {"Secondary Channel Offset", "wlan_mgt.secchanoffset",
11054       FT_UINT8, BASE_HEX, VALS (&hf_tag_secondary_channel_offset_flags), 0,
11055       "Secondary Channel Offset", HFILL }},
11056
11057     /*** Begin: Power Capability Tag - Dustin Johnson ***/
11058     {&hf_tag_power_capability_min,
11059      {"Minimum Transmit Power", "wlan_mgt.powercap.min",
11060       FT_UINT8, BASE_HEX, NULL, 0, "Minimum Transmit Power", HFILL }},
11061
11062     {&hf_tag_power_capability_max,
11063      {"Maximum Transmit Power", "wlan_mgt.powercap.max",
11064       FT_UINT8, BASE_HEX, NULL, 0, "Maximum Transmit Power", HFILL }},
11065     /*** End: Power Capability Tag - Dustin Johnson ***/
11066     {&hf_tag_tpc_report_trsmt_pow,
11067      {"Transmit Power", "wlan_mgt.tcprep.trsmt_pow",
11068       FT_INT8, BASE_DEC, NULL, 0, "Transmit Power", HFILL }},
11069     {&hf_tag_tpc_report_link_mrg,
11070      {"Link Margin", "wlan_mgt.tcprep.link_mrg",
11071       FT_INT8, BASE_DEC, NULL, 0, "Link Margin", HFILL }},
11072     /*** Begin: Supported Channels Tag - Dustin Johnson ***/
11073     {&hf_tag_supported_channels,
11074      {"Supported Channels Set", "wlan_mgt.supchan",
11075       FT_UINT8, BASE_DEC, NULL, 0, "Supported Channels Set", HFILL }},
11076
11077     {&hf_tag_supported_channels_first,
11078      {"First Supported Channel", "wlan_mgt.supchan.first",
11079       FT_UINT8, BASE_HEX, NULL, 0, "First Supported Channel", HFILL }},
11080
11081     {&hf_tag_supported_channels_range,
11082      {"Supported Channel Range", "wlan_mgt.supchan.range",
11083       FT_UINT8, BASE_HEX, NULL, 0, "Supported Channel Range", HFILL }},
11084     /*** End: Supported Channels Tag - Dustin Johnson ***/
11085
11086     /*** Start: Measurement Request Tag  - Dustin Johnson***/
11087     {&hf_tag_measure_request_measurement_token,
11088      {"Measurement Token", "wlan_mgt.measure.req.measuretoken",
11089       FT_UINT8, BASE_HEX, NULL, 0xff, "Measurement Token", HFILL }},
11090
11091     {&hf_tag_measure_request_mode,
11092      {"Measurement Request Mode", "wlan_mgt.measure.req.reqmode",
11093       FT_UINT8, BASE_HEX, NULL, 0xff, "Measurement Request Mode", HFILL }},
11094
11095     {&hf_tag_measure_request_mode_reserved1,
11096      {"Reserved", "wlan_mgt.measure.req.reqmode.reserved1",
11097       FT_UINT8, BASE_HEX, NULL, 0x01, "Reserved", HFILL }},
11098
11099     {&hf_tag_measure_request_mode_enable,
11100      {"Measurement Request Mode Field", "wlan_mgt.measure.req.reqmode.enable",
11101       FT_BOOLEAN, 8, TFS (&hf_tag_measure_enable_flag), 0x02, "Measurement Request Mode Field", HFILL }},
11102
11103     {&hf_tag_measure_request_mode_request,
11104      {"Measurement Reports", "wlan_mgt.measure.req.reqmode.request",
11105       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x04, "Measurement Reports", HFILL }},
11106
11107     {&hf_tag_measure_request_mode_report,
11108      {"Autonomous Measurement Reports", "wlan_mgt.measure.req.reqmode.report",
11109       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x08, "Autonomous Measurement Reports", HFILL }},
11110
11111     {&hf_tag_measure_request_mode_reserved2,
11112      {"Reserved", "wlan_mgt.measure.req.reqmode.reserved2",
11113       FT_UINT8, BASE_HEX, NULL, 0xf0, "Reserved", HFILL }},
11114
11115     {&hf_tag_measure_request_type,
11116      {"Measurement Request Type", "wlan_mgt.measure.req.reqtype",
11117       FT_UINT8, BASE_HEX, VALS (&hf_tag_measure_request_type_flags), 0x00, "Measurement Request Type", HFILL }},
11118
11119     {&hf_tag_measure_request_channel_number,
11120      {"Measurement Channel Number", "wlan_mgt.measure.req.channelnumber",
11121       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Channel Number", HFILL }},
11122
11123     {&hf_tag_measure_request_start_time,
11124      {"Measurement Start Time", "wlan_mgt.measure.req.starttime",
11125       FT_UINT64, BASE_HEX, NULL, 0, "Measurement Start Time", HFILL }},
11126
11127     {&hf_tag_measure_request_duration,
11128      {"Measurement Duration", "wlan_mgt.measure.req.channelnumber",
11129       FT_UINT16, BASE_HEX, NULL, 0, "Measurement Duration", HFILL }},
11130
11131     {&hf_tag_measure_request_regulatory_class,
11132      {"Measurement Channel Number", "wlan_mgt.measure.req.regclass",
11133       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Channel Number", HFILL }},
11134
11135     {&hf_tag_measure_request_randomization_interval,
11136      {"Randomization Interval", "wlan_mgt.measure.req.randint",
11137       FT_UINT16, BASE_HEX, NULL, 0, "Randomization Interval", HFILL }},
11138
11139     {&hf_tag_measure_request_measurement_mode,
11140      {"Measurement Mode", "wlan_mgt.measure.req.measurementmode",
11141       FT_UINT8, BASE_HEX, VALS(&hf_tag_measure_request_measurement_mode_flags), 0, "Measurement Mode", HFILL }},
11142
11143     {&hf_tag_measure_request_bssid,
11144      {"BSSID", "wlan_mgt.measure.req.bssid",
11145       FT_ETHER, BASE_NONE, NULL, 0, "BSSID", HFILL }},
11146
11147     {&hf_tag_measure_request_reporting_condition,
11148      {"Reporting Condition", "wlan_mgt.measure.req.repcond",
11149       FT_UINT8, BASE_HEX, VALS(&hf_tag_measure_request_reporting_condition_flags), 0, "Reporting Condition", HFILL }},
11150
11151     {&hf_tag_measure_request_threshold_offset_unsigned,
11152      {"Threshold/Offset", "wlan_mgt.measure.req.threshold",
11153       FT_UINT8, BASE_HEX, 0, 0, "Threshold/Offset", HFILL }},
11154
11155     {&hf_tag_measure_request_threshold_offset_signed,
11156      {"Threshold/Offset", "wlan_mgt.measure.req.threshold",
11157       FT_UINT8, BASE_HEX, 0, 0, "Threshold/Offset", HFILL }},
11158
11159     {&hf_tag_measure_request_report_mac,
11160      {"MAC on wich to gather data", "wlan_mgt.measure.req.reportmac",
11161       FT_ETHER, BASE_NONE, NULL, 0, "MAC on wich to gather data", HFILL }},
11162
11163     {&hf_tag_measure_request_group_id,
11164      {"Group ID", "wlan_mgt.measure.req.groupid",
11165       FT_UINT8, BASE_HEX, VALS(&hf_tag_measure_request_group_id_flags), 0, "Group ID", HFILL }},
11166     /*** End: Measurement Request Tag  - Dustin Johnson***/
11167
11168     /*** Start: Measurement Report Tag  - Dustin Johnson***/
11169     {&hf_tag_measure_report_measurement_token,
11170      {"Measurement Token", "wlan_mgt.measure.req.clr",
11171       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Token", HFILL }},
11172
11173     {&hf_tag_measure_report_mode,
11174      {"Measurement Report Mode", "wlan_mgt.measure.req.clr",
11175       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Report Mode", HFILL }},
11176
11177     {&hf_tag_measure_report_mode_late,
11178      {"Measurement Report Mode Field", "wlan_mgt.measure.rep.repmode.late",
11179       FT_BOOLEAN, 8, TFS (&hf_tag_measure_enable_flag), 0x01, "Measurement Report Mode Field", HFILL }},
11180
11181     {&hf_tag_measure_report_mode_incapable,
11182      {"Measurement Reports", "wlan_mgt.measure.rep.repmode.incapable",
11183       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x02, "Measurement Reports", HFILL }},
11184
11185     {&hf_tag_measure_report_mode_refused,
11186      {"Autonomous Measurement Reports", "wlan_mgt.measure.rep.repmode.refused",
11187       FT_BOOLEAN, 8, TFS (&hf_tag_measure_acc_not_acc), 0x04, "Autonomous Measurement Reports", HFILL }},
11188
11189     {&hf_tag_measure_report_mode_reserved,
11190      {"Reserved", "wlan_mgt.measure.rep.repmode.reserved",
11191       FT_UINT8, BASE_HEX, NULL, 0xf8, "Reserved", HFILL }},
11192
11193     {&hf_tag_measure_report_type,
11194      {"Measurement Report Type", "wlan_mgt.measure.rep.reptype",
11195       FT_UINT8, BASE_HEX, VALS (&hf_tag_measure_report_type_flags), 0x00, "Measurement Report Type", HFILL }},
11196
11197     {&hf_tag_measure_report_channel_number,
11198      {"Measurement Channel Number", "wlan_mgt.measure.rep.channelnumber",
11199       FT_UINT8, BASE_HEX, NULL, 0, "Measurement Channel Number", HFILL }},
11200
11201     {&hf_tag_measure_report_start_time,
11202      {"Measurement Start Time", "wlan_mgt.measure.rep.starttime",
11203       FT_UINT64, BASE_HEX, NULL, 0, "Measurement Start Time", HFILL }},
11204
11205     {&hf_tag_measure_report_duration,
11206      {"Measurement Duration", "wlan_mgt.measure.rep.channelnumber",
11207       FT_UINT16, BASE_HEX, NULL, 0, "Measurement Duration", HFILL }},
11208
11209     {&hf_tag_measure_cca_busy_fraction,
11210      {"CCA Busy Fraction", "wlan_mgt.measure.rep.ccabusy",
11211       FT_UINT8, BASE_HEX, NULL, 0, "CCA Busy Fraction", HFILL }},
11212
11213     {&hf_tag_measure_basic_map_field,
11214      {"Map Field", "wlan_mgt.measure.rep.mapfield",
11215       FT_UINT8, BASE_HEX, NULL, 0, "Map Field", HFILL }},
11216
11217     {&hf_tag_measure_map_field_bss,
11218      {"BSS", "wlan_mgt.measure.rep.repmode.mapfield.bss",
11219       FT_BOOLEAN, 8, TFS (&hf_tag_measure_map_field_bss_flag), 0x01, "BSS", HFILL }},
11220
11221     {&hf_tag_measure_map_field_odfm,
11222      {"Orthogonal Frequency Division Multiplexing (ODFM) Preamble", "wlan_mgt.measure.rep.repmode.mapfield.bss",
11223       FT_BOOLEAN, 8, TFS (&hf_tag_measure_detected_not_detected), 0x02, "Orthogonal Frequency Division Multiplexing (ODFM) Preamble", HFILL }},
11224
11225     {&hf_tag_measure_map_field_unident_signal,
11226      {"Unidentified Signal", "wlan_mgt.measure.rep.repmode.mapfield.unidentsig",
11227       FT_BOOLEAN, 8, TFS (&hf_tag_measure_detected_not_detected), 0x04, "Unidentified Signal", HFILL }},
11228
11229     {&hf_tag_measure_map_field_radar,
11230      {"Radar", "wlan_mgt.measure.rep.repmode.mapfield.radar",
11231       FT_BOOLEAN, 8, TFS (&hf_tag_measure_detected_not_detected), 0x08, "Radar", HFILL }},
11232
11233     {&hf_tag_measure_map_field_unmeasured,
11234      {"Unmeasured", "wlan_mgt.measure.rep.repmode.mapfield.unmeasured",
11235       FT_BOOLEAN, 8, TFS (&hf_tag_measure_true_false), 0x10, "Unmeasured", HFILL }},
11236
11237     {&hf_tag_measure_map_field_reserved,
11238      {"Reserved", "wlan_mgt.measure.rep.repmode.mapfield.reserved",
11239       FT_UINT8, BASE_HEX, NULL, 0xe0, "Reserved", HFILL }},
11240
11241     {&hf_tag_measure_rpi_histogram_report,
11242      {"Receive Power Indicator (RPI) Histogram Report", "wlan_mgt.measure.rep.rpi.histogram_report",
11243       FT_STRING, BASE_NONE, NULL, 0, "Receive Power Indicator (RPI) Histogram Report", HFILL }},
11244
11245     {&hf_tag_measure_rpi_histogram_report_0,
11246      {"RPI 0 Density", "wlan_mgt.measure.rep.rpi.rpi0density",
11247       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 0 Density", HFILL }},
11248
11249     {&hf_tag_measure_rpi_histogram_report_1,
11250      {"RPI 1 Density", "wlan_mgt.measure.rep.rpi.rpi1density",
11251       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 1 Density", HFILL }},
11252
11253     {&hf_tag_measure_rpi_histogram_report_2,
11254      {"RPI 2 Density", "wlan_mgt.measure.rep.rpi.rpi2density",
11255       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 2 Density", HFILL }},
11256
11257     {&hf_tag_measure_rpi_histogram_report_3,
11258      {"RPI 3 Density", "wlan_mgt.measure.rep.rpi.rpi3density",
11259       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 3 Density", HFILL }},
11260
11261     {&hf_tag_measure_rpi_histogram_report_4,
11262      {"RPI 4 Density", "wlan_mgt.measure.rep.rpi.rpi4density",
11263       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 4 Density", HFILL }},
11264
11265     {&hf_tag_measure_rpi_histogram_report_5,
11266      {"RPI 5 Density", "wlan_mgt.measure.rep.rpi.rpi5density",
11267       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 5 Density", HFILL }},
11268
11269     {&hf_tag_measure_rpi_histogram_report_6,
11270      {"RPI 6 Density", "wlan_mgt.measure.rep.rpi.rpi6density",
11271       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 6 Density", HFILL }},
11272
11273     {&hf_tag_measure_rpi_histogram_report_7,
11274      {"RPI 7 Density", "wlan_mgt.measure.rep.rpi.rpi7density",
11275       FT_UINT8, BASE_HEX, NULL, 0, "Receive Power Indicator (RPI) 7 Density", HFILL }},
11276
11277     {&hf_tag_measure_report_regulatory_class,
11278      {"Regulatory Class", "wlan_mgt.measure.rep.regclass",
11279       FT_UINT8, BASE_HEX, NULL, 0, "Regulatory Class", HFILL }},
11280
11281     {&hf_tag_measure_report_channel_load,
11282      {"Channel Load", "wlan_mgt.measure.rep.chanload",
11283       FT_UINT8, BASE_HEX, NULL, 0, "Channel Load", HFILL }},
11284
11285     {&hf_tag_measure_report_frame_info,
11286      {"Reported Frame Information", "wlan_mgt.measure.rep.frameinfo",
11287       FT_UINT8, BASE_HEX, NULL, 0, "Reported Frame Information", HFILL }},
11288
11289     {&hf_tag_measure_report_frame_info_phy_type,
11290      {"Condensed PHY", "wlan_mgt.measure.rep.frameinfo.phytype",
11291       FT_UINT8, BASE_HEX, NULL, 0x7F, "Condensed PHY", HFILL }},
11292
11293     {&hf_tag_measure_report_frame_info_frame_type,
11294      {"Reported Frame Type", "wlan_mgt.measure.rep.frameinfo.frametype",
11295       FT_UINT8, BASE_HEX, TFS(&hf_tag_measure_report_frame_info_frame_type_flag), 0x80, "Reported Frame Type", HFILL }},
11296
11297     {&hf_tag_measure_report_rcpi,
11298      {"Received Channel Power Indicator (RCPI)", "wlan_mgt.measure.rep.rcpi",
11299       FT_UINT8, BASE_HEX, NULL, 0, "Received Channel Power Indicator (RCPI)", HFILL }},
11300
11301     {&hf_tag_measure_report_rsni,
11302      {"Received Signal to Noise Indicator (RSNI)", "wlan_mgt.measure.rep.rsni",
11303       FT_UINT8, BASE_HEX, NULL, 0, "Received Signal to Noise Indicator (RSNI)", HFILL }},
11304
11305     {&hf_tag_measure_report_bssid,
11306      {"BSSID Being Reported", "wlan_mgt.measure.rep.bssid",
11307       FT_ETHER, BASE_NONE, NULL, 0, "BSSID Being Reported", HFILL }},
11308
11309     {&hf_tag_measure_report_ant_id,
11310      {"Antenna ID", "wlan_mgt.measure.rep.antid",
11311       FT_UINT8, BASE_HEX, NULL, 0, "Antenna ID", HFILL }},
11312
11313     {&hf_tag_measure_report_parent_tsf,
11314      {"Parent Timing Synchronization Function (TSF)", "wlan_mgt.measure.rep.parenttsf",
11315       FT_UINT32, BASE_HEX, NULL, 0, "Parent Timing Synchronization Function (TSF)", HFILL }},
11316     /*** End: Measurement Report Tag  - Dustin Johnson***/
11317
11318     /*** Begin: Extended Capabilities Tag - Dustin Johnson ***/
11319     /* Table 7-35a\97Capabilities field */
11320     {&hf_tag_extended_capabilities,
11321      {"Extended Capabilities", "wlan_mgt.extcap",
11322       FT_UINT8, BASE_HEX, NULL, 0, "Extended Capabilities", HFILL }},
11323
11324     /* P802.11n/D6.0 */
11325     {&hf_tag_extended_capabilities_b0,
11326      {"20/40 BSS Coexistence Management Support", "wlan_mgt.extcap.infoexchange.b0",
11327       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0001, "HT Information Exchange Support", HFILL }},
11328
11329     /* P802.11p/D4.0 */
11330     {&hf_tag_extended_capabilities_b1,
11331      {"On-demand beacon", "wlan_mgt.extcap.infoexchange.b1",
11332       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0002, "On-demand beacon", HFILL }},
11333
11334     {&hf_tag_extended_capabilities_b2,
11335      {"Extended Channel Switching", "wlan_mgt.extcap.infoexchange.b2",
11336       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0004, "Extended Channel Switching", HFILL }},
11337
11338     {&hf_tag_extended_capabilities_b3,
11339      {"WAVE indication", "wlan_mgt.extcap.infoexchange.b3",
11340       FT_BOOLEAN, 8, TFS(&hf_tag_extended_capabilities_flag), 0x0008, "WAVE indication", HFILL }},
11341     /*End: P802.11p/D4.0 */
11342
11343     /*** End: Extended Capabilities Tag - Dustin Johnson ***/
11344
11345     /*** Begin: Neighbor Report Tag - Dustin Johnson ***/
11346     {&hf_tag_neighbor_report_bssid,
11347      {"BSSID", "wlan_mgt.nreport.bssid",
11348       FT_ETHER, BASE_NONE, NULL, 0, "BSSID", HFILL }},
11349
11350     {&hf_tag_neighbor_report_bssid_info,
11351      {"BSSID Information", "wlan_mgt.nreport.bssid.info",
11352       FT_UINT32, BASE_HEX, NULL, 0, "BSSID Information", HFILL }},
11353
11354     {&hf_tag_neighbor_report_bssid_info_reachability,
11355      {"AP Reachability", "wlan_mgt.nreport.bssid.info.reachability",
11356       FT_UINT16, BASE_HEX, NULL, 0x0003, "AP Reachability", HFILL }},
11357
11358     {&hf_tag_neighbor_report_bssid_info_security,
11359      {"Security", "wlan_mgt.nreport.bssid.info.security",
11360       FT_UINT16, BASE_HEX, NULL, 0x0004, "Security", HFILL }},
11361
11362     {&hf_tag_neighbor_report_bssid_info_key_scope,
11363      {"Key Scope", "wlan_mgt.nreport.bssid.info.keyscope",
11364       FT_UINT16, BASE_HEX, NULL, 0x0008, "Key Scope", HFILL }},
11365
11366     {&hf_tag_neighbor_report_bssid_info_capability_spec_mng,
11367      {"Capability: Spectrum Management", "wlan_mgt.nreport.bssid.info.capability.specmngt",
11368       FT_UINT16, BASE_HEX, NULL, 0x0010, "Capability: Spectrum Management", HFILL }},
11369
11370     {&hf_tag_neighbor_report_bssid_info_capability_qos,
11371      {"Capability: QoS", "wlan_mgt.nreport.bssid.info.capability.qos",
11372       FT_UINT16, BASE_HEX, NULL, 0x0020, "Capability: QoS", HFILL }},
11373
11374     {&hf_tag_neighbor_report_bssid_info_capability_apsd,
11375      {"Capability: APSD", "wlan_mgt.nreport.bssid.info.capability.apsd",
11376       FT_UINT16, BASE_HEX, NULL, 0x0040, "Capability: APSD", HFILL }},
11377
11378     {&hf_tag_neighbor_report_bssid_info_capability_radio_msnt,
11379      {"Capability: Radio Measurement", "wlan_mgt.nreport.bssid.info.capability.radiomsnt",
11380       FT_UINT16, BASE_HEX, NULL, 0x0080, "Capability: Radio Measurement", HFILL }},
11381
11382     {&hf_tag_neighbor_report_bssid_info_capability_dback,
11383      {"Capability: Delayed Block Ack", "wlan_mgt.nreport.bssid.info.capability.dback",
11384       FT_UINT16, BASE_HEX, NULL, 0x0100, "Capability: Delayed Block Ack", HFILL }},
11385
11386     {&hf_tag_neighbor_report_bssid_info_capability_iback,
11387      {"Capability: Immediate Block Ack", "wlan_mgt.nreport.bssid.info.capability.iback",
11388       FT_UINT16, BASE_HEX, NULL, 0x0200, "Capability: Immediate Block Ack", HFILL }},
11389
11390     {&hf_tag_neighbor_report_bssid_info_mobility_domain,
11391      {"Mobility Domain", "wlan_mgt.nreport.bssid.info.mobilitydomain",
11392       FT_UINT16, BASE_HEX, NULL, 0x0400, "Mobility Domain", HFILL }},
11393
11394     {&hf_tag_neighbor_report_bssid_info_high_throughput,
11395      {"High Throughput", "wlan_mgt.nreport.bssid.info.hthoughput",
11396       FT_UINT16, BASE_HEX, NULL, 0x0800, "High Throughput", HFILL }},
11397
11398     {&hf_tag_neighbor_report_bssid_info_reserved,
11399      {"Reserved", "wlan_mgt.nreport.bssid.info.reserved",
11400       FT_UINT32, BASE_HEX, NULL, 0, "Reserved", HFILL }},
11401
11402     {&hf_tag_neighbor_report_reg_class,
11403      {"Regulatory Class", "wlan_mgt.nreport.regclass",
11404       FT_UINT8, BASE_HEX, NULL, 0, "Regulatory Class", HFILL }},
11405
11406     {&hf_tag_neighbor_report_channel_number,
11407      {"Channel Number", "wlan_mgt.nreport.channumber",
11408       FT_UINT8, BASE_HEX, NULL, 0, "Channel Number", HFILL }},
11409
11410     {&hf_tag_neighbor_report_phy_type,
11411      {"PHY Type", "wlan_mgt.nreport.phytype",
11412       FT_UINT8, BASE_HEX, NULL, 0, "PHY Type", HFILL }},
11413     /*** End: Neighbor Report Tag - Dustin Johnson ***/
11414
11415     /*** Begin: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
11416     {&hf_tag_ext_channel_switch_announcement_switch_mode,
11417      {"Channel Switch Mode", "wlan_mgt.extchanswitch.switchmode",
11418       FT_UINT8, BASE_HEX, VALS (&hf_tag_ext_channel_switch_announcement_switch_mode_flags), 0, "Channel Switch Mode", HFILL }},
11419
11420     {&hf_tag_ext_channel_switch_announcement_new_reg_class,
11421      {"New Regulatory Class", "wlan_mgt.extchanswitch.new.regclass",
11422       FT_UINT8, BASE_HEX, NULL, 0, "New Regulatory Class", HFILL }},
11423
11424     {&hf_tag_ext_channel_switch_announcement_new_chan_number,
11425      {"New Channel Number", "wlan_mgt.extchanswitch.new.channumber",
11426       FT_UINT8, BASE_HEX, NULL, 0, "New Channel Number", HFILL }},
11427
11428     {&hf_tag_ext_channel_switch_announcement_switch_count,
11429      {"Channel Switch Count", "wlan_mgt.extchanswitch.switchcount",
11430       FT_UINT8, BASE_HEX, NULL, 0, "Channel Switch Count", HFILL }},
11431     /*** End: Extended Channel Switch Announcement Tag - Dustin Johnson ***/
11432
11433     /*** Begin: Supported Regulatory Classes Tag - Dustin Johnson ***/
11434     {&hf_tag_supported_reg_classes_current,
11435      {"Current Regulatory Class", "wlan_mgt.supregclass.current",
11436       FT_UINT8, BASE_HEX, NULL, 0, "Current Regulatory Class", HFILL }},
11437
11438     {&hf_tag_supported_reg_classes_alternate,
11439      {"Alternate Regulatory Classes", "wlan_mgt.supregclass.alt",
11440       FT_STRING, BASE_NONE, NULL, 0, "Alternate Regulatory Classes", HFILL }},
11441     /*** End: Supported Regulatory Classes Tag - Dustin Johnson ***/
11442
11443     {&hf_marvell_ie_type,
11444      {"Type", "wlan_mgt.marvell.ie.type",
11445       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11446
11447     {&hf_marvell_ie_mesh_subtype,
11448      {"Subtype", "wlan_mgt.marvell.ie.subtype",
11449       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11450
11451     {&hf_marvell_ie_mesh_version,
11452      {"Version", "wlan_mgt.marvell.ie.version",
11453       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11454
11455     {&hf_marvell_ie_mesh_active_proto_id,
11456      {"Path Selection Protocol", "wlan_mgt.marvell.ie.proto_id",
11457       FT_UINT8, BASE_HEX, VALS(mesh_path_selection_codes), 0, "", HFILL }},
11458
11459     {&hf_marvell_ie_mesh_active_metric_id,
11460      {"Path Selection Metric", "wlan_mgt.marvell.ie.metric_id",
11461       FT_UINT8, BASE_HEX, VALS(mesh_metric_codes), 0, "", HFILL }},
11462
11463     {&hf_marvell_ie_mesh_cap,
11464      {"Mesh Capabilities", "wlan_mgt.marvell.ie.cap",
11465       FT_UINT8, BASE_HEX, NULL, 0, "", HFILL }},
11466
11467     {&hf_marvell_ie_data,
11468       { "Marvell IE data", "wlan_mgt.marvell.data",
11469         FT_BYTES, BASE_NONE, NULL, 0x0, "Marvell IE data", HFILL }},
11470
11471     {&hf_aironet_ie_type,
11472      {"Aironet IE type", "wlan_mgt.aironet.type",
11473       FT_UINT8, BASE_DEC, VALS(aironet_ie_type_vals), 0, "Aironet IE type", HFILL }},
11474
11475     {&hf_aironet_ie_version,
11476      {"Aironet IE CCX version?", "wlan_mgt.aironet.version",
11477       FT_UINT8, BASE_DEC, NULL, 0, "Aironet IE CCX version?", HFILL }},
11478
11479     {&hf_aironet_ie_data,
11480       { "Aironet IE data", "wlan_mgt.aironet.data",
11481         FT_BYTES, BASE_NONE, NULL, 0x0, "Aironet IE data", HFILL }},
11482
11483     {&hf_qbss_version,
11484      {"QBSS Version", "wlan_mgt.qbss.version",
11485       FT_UINT8, BASE_DEC, NULL, 0, "QBSS Version", HFILL }},
11486
11487     {&hf_qbss_scount,
11488      {"Station Count", "wlan_mgt.qbss.scount",
11489       FT_UINT16, BASE_DEC, NULL, 0, "Station Count", HFILL }},
11490
11491     {&hf_qbss_cu,
11492      {"Channel Utilization", "wlan_mgt.qbss.cu",
11493        FT_UINT8, BASE_DEC, NULL, 0, "Channel Utilization", HFILL }},
11494
11495     {&hf_qbss_adc,
11496      {"Available Admission Capabilities", "wlan_mgt.qbss.adc",
11497      FT_UINT8, BASE_DEC, NULL, 0, "Available Admission Capabilities", HFILL }},
11498
11499     {&hf_qbss2_cu,
11500      {"Channel Utilization", "wlan_mgt.qbss2.cu",
11501        FT_UINT8, BASE_DEC, NULL, 0, "Channel Utilization", HFILL }},
11502
11503     {&hf_qbss2_gl,
11504      {"G.711 CU Quantum", "wlan_mgt.qbss2.glimit",
11505       FT_UINT8, BASE_DEC, NULL, 0, "G.711 CU Quantum", HFILL }},
11506
11507     {&hf_qbss2_cal,
11508      {"Call Admission Limit", "wlan_mgt.qbss2.cal",
11509       FT_UINT8, BASE_DEC, NULL, 0, "Call Admission Limit", HFILL }},
11510
11511     {&hf_qbss2_scount,
11512      {"Station Count", "wlan_mgt.qbss2.scount",
11513       FT_UINT16, BASE_DEC, NULL, 0, "Station Count", HFILL }},
11514
11515     {&hf_aironet_ie_qos_unk1,
11516      {"Aironet IE QoS unknown 1", "wlan_mgt.aironet.qos.unk1",
11517       FT_UINT8, BASE_HEX, NULL, 0, "Aironet IE QoS unknown 1", HFILL }},
11518
11519     {&hf_aironet_ie_qos_paramset,
11520      {"Aironet IE QoS paramset", "wlan_mgt.aironet.qos.paramset",
11521       FT_UINT8, BASE_DEC, NULL, 0, "Aironet IE QoS paramset", HFILL }},
11522
11523     {&hf_aironet_ie_qos_val,
11524      {"Aironet IE QoS valueset", "wlan_mgt.aironet.qos.val",
11525       FT_BYTES, BASE_NONE, NULL, 0, "Aironet IE QoS valueset", HFILL }},
11526
11527     {&hf_ts_info,
11528      {"Traffic Stream (TS) Info", "wlan_mgt.ts_info",
11529       FT_UINT24, BASE_HEX, NULL, 0, "Traffic Stream (TS) Info field", HFILL }},
11530
11531     {&hf_tsinfo_type,
11532      {"Traffic Type", "wlan_mgt.ts_info.type", FT_UINT8, BASE_DEC,
11533       VALS (&tsinfo_type), 0, "Traffic Stream (TS) Info Traffic Type", HFILL }},
11534
11535     {&hf_tsinfo_tsid,
11536      {"Traffic Stream ID (TSID)", "wlan_mgt.ts_info.tsid",
11537       FT_UINT8, BASE_DEC, NULL, 0, "Traffic Stream ID (TSID) Info TSID", HFILL }},
11538
11539     {&hf_tsinfo_dir,
11540      {"Direction", "wlan_mgt.ts_info.dir", FT_UINT8, BASE_DEC,
11541       VALS (&tsinfo_direction), 0, "Traffic Stream (TS) Info Direction", HFILL }},
11542
11543     {&hf_tsinfo_access,
11544      {"Access Policy", "wlan_mgt.ts_info.dir", FT_UINT8, BASE_DEC,
11545       VALS (&tsinfo_access), 0, "Traffic Stream (TS) Info Access Policy", HFILL }},
11546
11547     {&hf_tsinfo_agg,
11548      {"Aggregation", "wlan_mgt.ts_info.agg", FT_UINT8, BASE_DEC,
11549       NULL, 0, "Traffic Stream (TS) Info Access Policy", HFILL }},
11550
11551     {&hf_tsinfo_apsd,
11552      {"Automatic Power-Save Delivery (APSD)", "wlan_mgt.ts_info.apsd", FT_UINT8, BASE_DEC,
11553       NULL, 0, "Traffic Stream (TS) Info Automatic Power-Save Delivery (APSD)", HFILL }},
11554
11555     {&hf_tsinfo_up,
11556      {"User Priority", "wlan_mgt.ts_info.up", FT_UINT8, BASE_DEC,
11557       VALS (&qos_up), 0, "Traffic Stream (TS) Info User Priority", HFILL }},
11558
11559     {&hf_tsinfo_ack,
11560      {"Ack Policy", "wlan_mgt.ts_info.ack", FT_UINT8, BASE_DEC,
11561       VALS (&ack_policy), 0, "Traffic Stream (TS) Info Ack Policy", HFILL }},
11562
11563     {&hf_tsinfo_sched,
11564      {"Schedule", "wlan_mgt.ts_info.sched", FT_UINT8, BASE_DEC,
11565       NULL, 0, "Traffic Stream (TS) Info Schedule", HFILL }},
11566
11567     {&tspec_nor_msdu,
11568      {"Normal MSDU Size", "wlan_mgt.tspec.nor_msdu",
11569       FT_UINT16, BASE_DEC, NULL, 0, "Normal MSDU Size", HFILL }},
11570
11571     {&tspec_max_msdu,
11572      {"Maximum MSDU Size", "wlan_mgt.tspec.max_msdu",
11573       FT_UINT16, BASE_DEC, NULL, 0, "Maximum MSDU Size", HFILL }},
11574
11575     {&tspec_min_srv,
11576      {"Minimum Service Interval", "wlan_mgt.tspec.min_srv",
11577       FT_UINT32, BASE_DEC, NULL, 0, "Minimum Service Interval", HFILL }},
11578
11579     {&tspec_max_srv,
11580      {"Maximum Service Interval", "wlan_mgt.tspec.max_srv",
11581       FT_UINT32, BASE_DEC, NULL, 0, "Maximum Service Interval", HFILL }},
11582
11583     {&tspec_inact_int,
11584      {"Inactivity Interval", "wlan_mgt.tspec.inact_int",
11585       FT_UINT32, BASE_DEC, NULL, 0, "Inactivity Interval", HFILL }},
11586
11587     {&tspec_susp_int,
11588      {"Suspension Interval", "wlan_mgt.tspec.susp_int",
11589       FT_UINT32, BASE_DEC, NULL, 0, "Suspension Interval", HFILL }},
11590
11591     {&tspec_srv_start,
11592      {"Service Start Time", "wlan_mgt.tspec.srv_start",
11593       FT_UINT32, BASE_DEC, NULL, 0, "Service Start Time", HFILL }},
11594
11595     {&tspec_min_data,
11596      {"Minimum Data Rate", "wlan_mgt.tspec.min_data",
11597       FT_UINT32, BASE_DEC, NULL, 0, "Minimum Data Rate", HFILL }},
11598
11599     {&tspec_mean_data,
11600      {"Mean Data Rate", "wlan_mgt.tspec.mean_data",
11601       FT_UINT32, BASE_DEC, NULL, 0, "Mean Data Rate", HFILL }},
11602
11603     {&tspec_peak_data,
11604      {"Peak Data Rate", "wlan_mgt.tspec.peak_data",
11605       FT_UINT32, BASE_DEC, NULL, 0, "Peak Data Rate", HFILL }},
11606
11607     {&tspec_burst_size,
11608      {"Burst Size", "wlan_mgt.tspec.burst_size",
11609       FT_UINT32, BASE_DEC, NULL, 0, "Burst Size", HFILL }},
11610
11611     {&tspec_delay_bound,
11612      {"Delay Bound", "wlan_mgt.tspec.delay_bound",
11613       FT_UINT32, BASE_DEC, NULL, 0, "Delay Bound", HFILL }},
11614
11615     {&tspec_min_phy,
11616      {"Minimum PHY Rate", "wlan_mgt.tspec.min_phy",
11617       FT_UINT32, BASE_DEC, NULL, 0, "Minimum PHY Rate", HFILL }},
11618
11619     {&tspec_surplus,
11620      {"Surplus Bandwidth Allowance", "wlan_mgt.tspec.surplus",
11621       FT_UINT16, BASE_DEC, NULL, 0, "Surplus Bandwidth Allowance", HFILL }},
11622
11623     {&tspec_medium,
11624      {"Medium Time", "wlan_mgt.tspec.medium",
11625       FT_UINT16, BASE_DEC, NULL, 0, "Medium Time", HFILL }},
11626
11627     {&ts_delay,
11628      {"Traffic Stream (TS) Delay", "wlan_mgt.ts_delay",
11629       FT_UINT32, BASE_DEC, NULL, 0, "Traffic Stream (TS) Delay", HFILL }},
11630
11631     {&hf_class_type,
11632      {"Classifier Type", "wlan_mgt.tclas.class_type", FT_UINT8, BASE_DEC,
11633       VALS (classifier_type), 0, "Classifier Type", HFILL }},
11634
11635     {&hf_class_mask,
11636      {"Classifier Mask", "wlan_mgt.tclas.class_mask", FT_UINT8, BASE_HEX,
11637       NULL, 0, "Classifier Mask", HFILL }},
11638
11639     {&hf_ether_type,
11640      {"Ethernet Type", "wlan_mgt.tclas.params.type", FT_UINT8, BASE_DEC,
11641       NULL, 0, "Classifier Parameters Ethernet Type", HFILL }},
11642
11643     {&hf_tclas_process,
11644      {"Processing", "wlan_mgt.tclas_proc.processing", FT_UINT8, BASE_DEC,
11645       VALS (tclas_process), 0, "TCLAS Processing", HFILL }},
11646
11647     {&hf_sched_info,
11648      {"Schedule Info", "wlan_mgt.sched.sched_info",
11649       FT_UINT16, BASE_HEX, NULL, 0, "Schedule Info field", HFILL }},
11650
11651     {&hf_sched_srv_start,
11652      {"Service Start Time", "wlan_mgt.sched.srv_start",
11653       FT_UINT32, BASE_HEX, NULL, 0, "Service Start Time", HFILL }},
11654
11655     {&hf_sched_srv_int,
11656      {"Service Interval", "wlan_mgt.sched.srv_int",
11657       FT_UINT32, BASE_HEX, NULL, 0, "Service Interval", HFILL }},
11658
11659     {&hf_sched_spec_int,
11660      {"Specification Interval", "wlan_mgt.sched.spec_int",
11661       FT_UINT16, BASE_HEX, NULL, 0, "Specification Interval", HFILL }},
11662
11663     {&hf_action,
11664      {"Action", "wlan_mgt.fixed.action",
11665       FT_UINT8, BASE_HEX, NULL, 0, "Action", HFILL }},
11666
11667     {&cf_version,
11668      {"IP Version", "wlan_mgt.tclas.params.version",
11669       FT_UINT8, BASE_DEC, NULL, 0, "IP Version", HFILL }},
11670
11671     {&cf_ipv4_src,
11672      {"IPv4 Src Addr", "wlan_mgt.tclas.params.ipv4_src",
11673       FT_IPv4, BASE_NONE, NULL, 0, "IPv4 Src Addr", HFILL }},
11674
11675     {&cf_ipv4_dst,
11676      {"IPv4 Dst Addr", "wlan_mgt.tclas.params.ipv4_dst",
11677       FT_IPv4, BASE_NONE, NULL, 0, "IPv4 Dst Addr", HFILL }},
11678
11679     {&cf_src_port,
11680      {"Source Port", "wlan_mgt.tclas.params.src_port",
11681       FT_UINT16, BASE_DEC, NULL, 0, "Source Port", HFILL }},
11682
11683     {&cf_dst_port,
11684      {"Destination Port", "wlan_mgt.tclas.params.dst_port",
11685       FT_UINT16, BASE_DEC, NULL, 0, "Destination Port", HFILL }},
11686
11687     {&cf_dscp,
11688      {"IPv4 DSCP", "wlan_mgt.tclas.params.dscp",
11689       FT_UINT8, BASE_HEX, NULL, 0, "IPv4 Differentiated Services Code Point (DSCP) Field", HFILL }},
11690
11691     {&cf_protocol,
11692      {"Protocol", "wlan_mgt.tclas.params.protocol",
11693       FT_UINT8, BASE_HEX, NULL, 0, "IPv4 Protocol", HFILL }},
11694
11695     {&cf_ipv6_src,
11696      {"IPv6 Src Addr", "wlan_mgt.tclas.params.ipv6_src",
11697       FT_IPv6, BASE_NONE, NULL, 0, "IPv6 Src Addr", HFILL }},
11698
11699     {&cf_ipv6_dst,
11700      {"IPv6 Dst Addr", "wlan_mgt.tclas.params.ipv6_dst",
11701       FT_IPv6, BASE_NONE, NULL, 0, "IPv6 Dst Addr", HFILL }},
11702
11703     {&cf_flow,
11704      {"Flow Label", "wlan_mgt.tclas.params.flow",
11705       FT_UINT24, BASE_HEX, NULL, 0, "IPv6 Flow Label", HFILL }},
11706
11707     {&cf_tag_type,
11708      {"802.1Q Tag Type", "wlan_mgt.tclas.params.tag_type",
11709       FT_UINT16, BASE_HEX, NULL, 0, "802.1Q Tag Type", HFILL }},
11710
11711     {&cf_aruba,
11712      {"Aruba Type", "wlan_mgt.aruba_type",
11713       FT_UINT16, BASE_DEC, VALS(aruba_mgt_typevals), 0, "Aruba Management", HFILL }},
11714
11715     {&cf_aruba_hb_seq,
11716      {"Aruba Heartbeat Sequence", "wlan_mgt.aruba_heartbeat_sequence",
11717       FT_UINT64, BASE_DEC, NULL, 0, "Aruba Heartbeat Sequence", HFILL }},
11718
11719     {&cf_aruba_mtu,
11720      {"Aruba MTU Size", "wlan_mgt.aruba_mtu_size",
11721       FT_UINT16, BASE_DEC, NULL, 0, "Aruba MTU Size", HFILL }},
11722
11723     /* Start: HT Control (+HTC) */
11724     {&hf_htc,
11725      {"HT Control (+HTC)", "wlan_mgt.htc",
11726       FT_UINT32, BASE_HEX, NULL, 0, "High Throughput Control (+HTC)", HFILL }},
11727     {&hf_htc_lac,
11728      {"Link Adaptation Control (LAC)", "wlan_mgt.htc.lac",
11729       FT_UINT16, BASE_HEX, NULL, 0, "High Throughput Control Link Adaptation Control (LAC)", HFILL }},
11730     {&hf_htc_lac_reserved,
11731      {"Reserved", "wlan_mgt.htc.lac.reserved",
11732       FT_BOOLEAN, 16, NULL, 0x0001, "High Throughput Control Link Adaptation Control Reserved", HFILL }},
11733     {&hf_htc_lac_trq,
11734      {"Training Request (TRQ)", "wlan_mgt.htc.lac.trq",
11735       FT_BOOLEAN, 16, TFS(&htc_lac_trq_flag), 0x0002, "High Throughput Control Link Adaptation Control Training Request (TRQ)", HFILL }},
11736     {&hf_htc_lac_mai_aseli,
11737      {"Antenna Selection Indication (ASELI)", "wlan_mgt.htc.lac.mai.aseli",
11738       FT_UINT16, BASE_HEX, NULL, 0x003C, "High Throughput Control Link Adaptation Control MAI Antenna Selection Indication", HFILL }},
11739     {&hf_htc_lac_mai_mrq,
11740      {"MCS Request (MRQ)", "wlan_mgt.htc.lac.mai.mrq",
11741       FT_BOOLEAN, 16, TFS(&htc_lac_mai_mrq_flag), 0x0004, "High Throughput Control Link Adaptation Control MAI MCS Request", HFILL }},
11742     {&hf_htc_lac_mai_msi,
11743      {"MCS Request Sequence Identifier (MSI)", "wlan_mgt.htc.lac.mai.msi",
11744       FT_UINT16, BASE_HEX, NULL, 0x0038, "High Throughput Control Link Adaptation Control MAI MCS Request Sequence Identifier", HFILL }},
11745     {&hf_htc_lac_mai_reserved,
11746      {"Reserved", "wlan_mgt.htc.lac.mai.reserved",
11747       FT_UINT16, BASE_HEX, NULL, 0x0038, "High Throughput Control Link Adaptation Control MAI Reserved", HFILL }},
11748     {&hf_htc_lac_mfsi,
11749      {"MCS Feedback Sequence Identifier (MFSI)", "wlan_mgt.htc.lac.mfsi",
11750       FT_UINT16, BASE_DEC, NULL, 0x01C0, "High Throughput Control Link Adaptation Control MCS Feedback Sequence Identifier (MSI)", HFILL }},
11751     {&hf_htc_lac_asel_command,
11752      {"Antenna Selection (ASEL) Command", "wlan_mgt.htc.lac.asel.command",
11753       FT_UINT16, BASE_HEX, VALS (&hf_htc_lac_asel_command_flags), 0x0E00, "High Throughput Control Link Adaptation Control Antenna Selection (ASEL) Command", HFILL }},
11754     {&hf_htc_lac_asel_data,
11755      {"Antenna Selection (ASEL) Data", "wlan_mgt.htc.lac.asel.data",
11756       FT_UINT16, BASE_HEX, NULL, 0xF000, "High Throughput Control Link Adaptation Control Antenna Selection (ASEL) Data", HFILL }},
11757     {&hf_htc_lac_mfb,
11758      {"MCS Feedback (MFB)", "wlan_mgt.htc.lac.mfb",
11759       FT_UINT16, BASE_HEX, NULL, 0xFE00, "High Throughput Control Link Adaptation Control MCS Feedback", HFILL }},
11760     {&hf_htc_cal_pos,
11761      {"Calibration Position", "wlan_mgt.htc.cal.pos",
11762       FT_UINT16, BASE_DEC, VALS (&hf_htc_cal_pos_flags), 0x0003, "High Throughput Control Calibration Position", HFILL }},
11763     {&hf_htc_cal_seq,
11764      {"Calibration Sequence Identifier", "wlan_mgt.htc.cal.seq",
11765       FT_UINT16, BASE_DEC, NULL, 0x000C, "High Throughput Control Calibration Sequence Identifier", HFILL }},
11766     {&hf_htc_reserved1,
11767      {"Reserved", "wlan_mgt.htc.reserved1",
11768       FT_UINT16, BASE_DEC, NULL, 0x0030, "High Throughput Control Reserved", HFILL }},
11769     {&hf_htc_csi_steering,
11770      {"CSI/Steering", "wlan_mgt.htc.csi_steering",
11771       FT_UINT16, BASE_DEC, VALS (&hf_htc_csi_steering_flags), 0x00C0, "High Throughput Control CSI/Steering", HFILL }},
11772     {&hf_htc_ndp_announcement,
11773      {"NDP Announcement", "wlan_mgt.htc.ndp_announcement",
11774       FT_BOOLEAN, 16, TFS(&hf_htc_ndp_announcement_flag), 0x0100, "High Throughput Control NDP Announcement", HFILL }},
11775     {&hf_htc_reserved2,
11776      {"Reserved", "wlan_mgt.htc.reserved2",
11777       FT_UINT16, BASE_HEX, NULL, 0x3E00, "High Throughput Control Reserved", HFILL }},
11778     {&hf_htc_ac_constraint,
11779      {"AC Constraint", "wlan_mgt.htc.ac_constraint",
11780       FT_BOOLEAN, 16, NULL, 0x4000, "High Throughput Control AC Constraint", HFILL }},
11781     {&hf_htc_rdg_more_ppdu,
11782      {"RDG/More PPDU", "wlan_mgt.htc.rdg_more_ppdu",
11783       FT_BOOLEAN, 16, NULL, 0x8000, "High Throughput Control RDG/More PPDU", HFILL }}
11784     /* End: HT Control (+HTC) */
11785   };
11786
11787   static hf_register_info aggregate_fields[] = {
11788     {&amsdu_msdu_header_text,
11789      {"MAC Service Data Unit (MSDU)",   "wlan_aggregate.msduheader", FT_UINT16,
11790       BASE_DEC, 0, 0x0000, "MAC Service Data Unit (MSDU)", HFILL }}
11791   };
11792
11793   static gint *tree_array[] = {
11794     &ett_80211,
11795     &ett_fc_tree,
11796     &ett_proto_flags,
11797     &ett_fragments,
11798     &ett_fragment,
11799     &ett_block_ack,
11800     &ett_80211_mgt,
11801     &ett_fixed_parameters,
11802     &ett_tagged_parameters,
11803     &ett_qos_parameters,
11804     &ett_qos_ps_buf_state,
11805     &ett_wep_parameters,
11806     &ett_cap_tree,
11807     &ett_rsn_cap_tree,
11808     &ett_ht_cap_tree,
11809     &ett_ff_ba_param_tree,
11810     &ett_ff_qos_info,
11811     &ett_ff_sm_pwr_save,
11812     &ett_ff_psmp_param_set,
11813     &ett_ff_mimo_cntrl,
11814     &ett_ff_ant_sel,
11815     &ett_ff_chan_switch_announce,
11816     &ett_ff_ht_info,
11817     &ett_ff_psmp_sta_info,
11818     &ett_ff_delba_param_tree,
11819     &ett_ff_ba_ssc_tree,
11820     &ett_mimo_report,
11821     &ett_cntrl_wrapper_fc,
11822     &ett_cntrl_wrapper_payload,
11823     &ett_ht_info_delimiter1_tree,
11824     &ett_ht_info_delimiter2_tree,
11825     &ett_ht_info_delimiter3_tree,
11826     &ett_msdu_aggregation_parent_tree,
11827     &ett_msdu_aggregation_subframe_tree,
11828     &ett_tag_measure_request_tree,
11829         &ett_tag_ex_cap,
11830     &ett_tag_supported_channels,
11831     &ett_tag_neighbor_report_bssid_info_tree,
11832     &ett_tag_neighbor_report_bssid_info_capability_tree,
11833     &ett_tag_neighbor_report_sub_tag_tree,
11834     &ett_ampduparam_tree,
11835     &ett_mcsset_tree,
11836     &ett_mcsbit_tree,
11837     &ett_htex_cap_tree,
11838     &ett_txbf_tree,
11839     &ett_hta_cap_tree,
11840     &ett_hta_cap1_tree,
11841     &ett_hta_cap2_tree,
11842     &ett_htc_tree,
11843     &ett_antsel_tree,
11844     &ett_80211_mgt_ie,
11845     &ett_tsinfo_tree,
11846     &ett_sched_tree,
11847     &ett_fcs,
11848     &ett_radio,
11849     &ett_pst_tree,
11850     &ett_pst_cap_tree,
11851     &ett_chan_noc_tree,
11852     &ett_wave_chnl_tree
11853   };
11854   module_t *wlan_module;
11855
11856   memset (&wlan_stats, 0, sizeof wlan_stats);
11857
11858   proto_aggregate = proto_register_protocol("IEEE 802.11 wireless LAN aggregate frame",
11859       "IEEE 802.11 Aggregate Data", "wlan_aggregate");
11860   proto_register_field_array(proto_aggregate, aggregate_fields, array_length(aggregate_fields));
11861   proto_wlan = proto_register_protocol ("IEEE 802.11 wireless LAN",
11862       "IEEE 802.11", "wlan");
11863   proto_register_field_array (proto_wlan, hf, array_length (hf));
11864   proto_wlan_mgt = proto_register_protocol ("IEEE 802.11 wireless LAN management frame",
11865       "802.11 MGT", "wlan_mgt");
11866   proto_register_field_array (proto_wlan_mgt, ff, array_length (ff));
11867   proto_register_subtree_array (tree_array, array_length (tree_array));
11868
11869   register_dissector("wlan", dissect_ieee80211, proto_wlan);
11870   register_dissector("wlan_fixed", dissect_ieee80211_fixed, proto_wlan);
11871   register_dissector("wlan_bsfc", dissect_ieee80211_bsfc, proto_wlan);
11872   register_dissector("wlan_datapad", dissect_ieee80211_datapad, proto_wlan);
11873   register_dissector("wlan_ht", dissect_ieee80211_ht, proto_wlan);
11874   register_init_routine(wlan_defragment_init);
11875   register_init_routine(wlan_retransmit_init);
11876
11877   proto_radio = proto_register_protocol("802.11 radio information", "Radio", "radio");
11878
11879   proto_prism = proto_register_protocol("Prism capture header", "Prism", "prism");
11880   proto_register_field_array(proto_prism, hf_prism, array_length(hf_prism));
11881
11882   proto_wlancap = proto_register_protocol("AVS WLAN Capture header",
11883       "AVS WLANCAP", "wlancap");
11884   proto_register_field_array(proto_wlancap, hf_wlancap, array_length(hf_wlancap));
11885   register_dissector("wlancap", dissect_wlancap, proto_wlancap);
11886
11887   wlan_tap = register_tap("wlan");
11888
11889   /* Register configuration options */
11890   wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys);
11891   prefs_register_bool_preference(wlan_module, "defragment",
11892       "Reassemble fragmented 802.11 datagrams",
11893       "Whether fragmented 802.11 datagrams should be reassembled",
11894       &wlan_defragment);
11895
11896   prefs_register_bool_preference(wlan_module, "ignore_draft_ht",
11897     "Ignore vendor-specific HT elements",
11898     "Don't dissect 802.11n draft HT elements (which might contain duplicate information).",
11899     &wlan_ignore_draft_ht);
11900
11901   prefs_register_bool_preference(wlan_module, "retransmitted",
11902     "Call subdissector for retransmitted 802.11 frames",
11903     "Whether retransmitted 802.11 frames should be subdissected",
11904     &wlan_subdissector);
11905
11906   prefs_register_bool_preference(wlan_module, "check_fcs",
11907     "Assume packets have FCS",
11908     "Some 802.11 cards include the FCS at the end of a packet, others do not.",
11909     &wlan_check_fcs);
11910
11911   /* Davide Schiera (2006-11-26): changed "WEP bit" in "Protection bit"    */
11912   /*    (according to the document IEEE Std 802.11i-2004)              */
11913   prefs_register_enum_preference(wlan_module, "ignore_wep",
11914       "Ignore the Protection bit",
11915       "Some 802.11 cards leave the Protection bit set even though the packet is decrypted, "
11916       "and some also leave the IV (initialization vector).",
11917       &wlan_ignore_wep, wlan_ignore_wep_options, TRUE);
11918
11919 #ifndef USE_ENV
11920
11921   prefs_register_obsolete_preference(wlan_module, "wep_keys");
11922
11923 #ifdef HAVE_AIRPDCAP
11924   /* Davide Schiera (2006-11-26): added reference to WPA/WPA2 decryption    */
11925   prefs_register_bool_preference(wlan_module, "enable_decryption",
11926       "Enable decryption", "Enable WEP and WPA/WPA2 decryption",
11927       &enable_decryption);
11928 #else
11929   prefs_register_bool_preference(wlan_module, "enable_decryption",
11930       "Enable decryption", "Enable WEP decryption",
11931       &enable_decryption);
11932 #endif
11933
11934 #ifdef HAVE_AIRPDCAP
11935   prefs_register_static_text_preference(wlan_module, "info_decryption_key",
11936       "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
11937       "010203040506070809101111213 (104/128-bit WEP),\n"
11938       "wpa-pwd:MyPassword[:MyAP] (WPA + plaintext password [+ SSID]),\n"
11939       "wpa-psk:0102030405...6061626364 (WPA + 256-bit key).  "
11940       "Invalid keys will be ignored.",
11941       "Valid key formats");
11942 #else
11943   prefs_register_static_text_preference(wlan_module, "info_decryption_key",
11944       "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n"
11945       "010203040506070809101111213 (104/128-bit WEP)",
11946       "Valid key formats");
11947 #endif
11948
11949   for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
11950     key_name = g_string_new("");
11951     key_title = g_string_new("");
11952     key_desc = g_string_new("");
11953     wep_keystr[i] = NULL;
11954     /* prefs_register_*_preference() expects unique strings, so
11955      * we build them using g_string_printf and just leave them
11956      * allocated. */
11957 #ifdef HAVE_AIRPDCAP
11958     g_string_printf(key_name, "wep_key%d", i + 1);
11959     g_string_printf(key_title, "Key #%d", i + 1);
11960     /* Davide Schiera (2006-11-26): modified keys input tooltip          */
11961     g_string_printf(key_desc,
11962       "Key #%d string can be:"
11963       "   <wep hexadecimal key>;"
11964       "   wep:<wep hexadecimal key>;"
11965       "   wpa-pwd:<passphrase>[:<ssid>];"
11966       "   wpa-psk:<wpa hexadecimal key>", i + 1);
11967 #else
11968       g_string_printf(key_name, "wep_key%d", i + 1);
11969       g_string_printf(key_title, "WEP key #%d", i + 1);
11970       g_string_printf(key_desc, "WEP key #%d can be:"
11971         "   <wep hexadecimal key>;"
11972         "   wep:<wep hexadecimal key>", i + 1);
11973 #endif
11974
11975     prefs_register_string_preference(wlan_module, key_name->str,
11976         key_title->str, key_desc->str, (const char **) &wep_keystr[i]);
11977
11978     g_string_free(key_name, FALSE);
11979     g_string_free(key_title, FALSE);
11980     g_string_free(key_desc, FALSE);
11981   }
11982 #endif
11983 }
11984
11985 void
11986 proto_reg_handoff_ieee80211(void)
11987 {
11988   dissector_handle_t radio_handle;
11989   dissector_handle_t prism_handle;
11990
11991   /*
11992    * Get handles for the LLC, IPX and Ethernet  dissectors.
11993    */
11994   llc_handle = find_dissector("llc");
11995   ipx_handle = find_dissector("ipx");
11996   eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
11997   data_handle = find_dissector("data");
11998
11999   ieee80211_handle = find_dissector("wlan");
12000   dissector_add("wtap_encap", WTAP_ENCAP_IEEE_802_11, ieee80211_handle);
12001   dissector_add("ethertype", ETHERTYPE_CENTRINO_PROMISC, ieee80211_handle);
12002
12003   /* Register handoff to radio-header dissectors */
12004   radio_handle = create_dissector_handle(dissect_radio, proto_radio);
12005   dissector_add("wtap_encap", WTAP_ENCAP_IEEE_802_11_WITH_RADIO, radio_handle);
12006
12007   prism_handle = create_dissector_handle(dissect_prism, proto_prism);
12008   dissector_add("wtap_encap", WTAP_ENCAP_PRISM_HEADER, prism_handle);
12009
12010   wlancap_handle = create_dissector_handle(dissect_wlancap, proto_wlancap);
12011   dissector_add("wtap_encap", WTAP_ENCAP_IEEE_802_11_WLAN_AVS, wlancap_handle);
12012
12013   /* Register handoff to Aruba GRE */
12014   dissector_add("gre.proto", GRE_ARUBA_8200, ieee80211_handle);
12015   dissector_add("gre.proto", GRE_ARUBA_8210, ieee80211_handle);
12016   dissector_add("gre.proto", GRE_ARUBA_8220, ieee80211_handle);
12017   dissector_add("gre.proto", GRE_ARUBA_8230, ieee80211_handle);
12018   dissector_add("gre.proto", GRE_ARUBA_8240, ieee80211_handle);
12019   dissector_add("gre.proto", GRE_ARUBA_8250, ieee80211_handle);
12020   dissector_add("gre.proto", GRE_ARUBA_8260, ieee80211_handle);
12021   dissector_add("gre.proto", GRE_ARUBA_8270, ieee80211_handle);
12022   dissector_add("gre.proto", GRE_ARUBA_8280, ieee80211_handle);
12023   dissector_add("gre.proto", GRE_ARUBA_8290, ieee80211_handle);
12024   dissector_add("gre.proto", GRE_ARUBA_82A0, ieee80211_handle);
12025   dissector_add("gre.proto", GRE_ARUBA_82B0, ieee80211_handle);
12026   dissector_add("gre.proto", GRE_ARUBA_82C0, ieee80211_handle);
12027   dissector_add("gre.proto", GRE_ARUBA_82D0, ieee80211_handle);
12028   dissector_add("gre.proto", GRE_ARUBA_82E0, ieee80211_handle);
12029   dissector_add("gre.proto", GRE_ARUBA_82F0, ieee80211_handle);
12030   dissector_add("gre.proto", GRE_ARUBA_8300, ieee80211_handle);
12031   dissector_add("gre.proto", GRE_ARUBA_8310, ieee80211_handle);
12032   dissector_add("gre.proto", GRE_ARUBA_8320, ieee80211_handle);
12033   dissector_add("gre.proto", GRE_ARUBA_8330, ieee80211_handle);
12034   dissector_add("gre.proto", GRE_ARUBA_8340, ieee80211_handle);
12035   dissector_add("gre.proto", GRE_ARUBA_8350, ieee80211_handle);
12036   dissector_add("gre.proto", GRE_ARUBA_8360, ieee80211_handle);
12037   dissector_add("gre.proto", GRE_ARUBA_8370, ieee80211_handle);
12038 }
12039
12040 #ifdef HAVE_AIRPDCAP
12041 /* Davide Schiera (2006-11-26): this function will try to decrypt with WEP or  */
12042 /* WPA and return a tvb to the caller to add a new tab. It returns the    */
12043 /* algorithm used for decryption (WEP, TKIP, CCMP) and the header and    */
12044 /* trailer lengths.                                      */
12045 static tvbuff_t *
12046 try_decrypt(tvbuff_t *tvb, guint offset, guint len, guint8 *algorithm, guint32 *sec_header, guint32 *sec_trailer) {
12047   const guint8 *enc_data;
12048   guint8 *tmp = NULL;
12049   tvbuff_t *decr_tvb = NULL;
12050   guint32 dec_caplen;
12051   guchar dec_data[AIRPDCAP_MAX_CAPLEN];
12052   AIRPDCAP_KEY_ITEM used_key;
12053
12054   if (!enable_decryption)
12055     return NULL;
12056
12057   /* get the entire packet                                  */
12058   enc_data = tvb_get_ptr(tvb, 0, len+offset);
12059
12060   /*  process packet with AirPDcap                              */
12061   if (AirPDcapPacketProcess(&airpdcap_ctx, enc_data, offset, offset+len, dec_data, &dec_caplen, &used_key, FALSE, TRUE)==AIRPDCAP_RET_SUCCESS)
12062   {
12063     *algorithm=used_key.KeyType;
12064     switch (*algorithm) {
12065       case AIRPDCAP_KEY_TYPE_WEP:
12066         *sec_header=AIRPDCAP_WEP_HEADER;
12067         *sec_trailer=AIRPDCAP_WEP_TRAILER;
12068         break;
12069       case AIRPDCAP_KEY_TYPE_CCMP:
12070         *sec_header=AIRPDCAP_RSNA_HEADER;
12071         *sec_trailer=AIRPDCAP_CCMP_TRAILER;
12072         break;
12073       case AIRPDCAP_KEY_TYPE_TKIP:
12074         *sec_header=AIRPDCAP_RSNA_HEADER;
12075         *sec_trailer=AIRPDCAP_TKIP_TRAILER;
12076         break;
12077       default:
12078         return NULL;
12079     }
12080
12081     /* allocate buffer for decrypted payload                      */
12082     if ((tmp = g_malloc(dec_caplen-offset)) == NULL)
12083       return NULL;  /* krap! */
12084     memcpy(tmp, dec_data+offset, dec_caplen-offset);
12085
12086     len=dec_caplen-offset;
12087
12088     /* decrypt successful, let's set up a new data tvb.              */
12089     decr_tvb = tvb_new_real_data(tmp, len, len);
12090     tvb_set_free_cb(decr_tvb, g_free);
12091     tvb_set_child_real_data_tvbuff(tvb, decr_tvb);
12092   } else
12093     g_free(tmp);
12094
12095   return decr_tvb;
12096 }
12097 /*  Davide Schiera -----------------------------------------------------------  */
12098 #else
12099
12100 static tvbuff_t *try_decrypt_wep(tvbuff_t *tvb, guint32 offset, guint32 len) {
12101   const guint8 *enc_data;
12102   guint8 *tmp = NULL;
12103   int i;
12104   tvbuff_t *decr_tvb = NULL;
12105
12106   if (! enable_decryption)
12107     return NULL;
12108
12109   enc_data = tvb_get_ptr(tvb, offset, len);
12110
12111   if ((tmp = g_malloc(len)) == NULL)
12112     return NULL;  /* krap! */
12113
12114   /* try once with the key index in the packet, then look through our list. */
12115   for (i = 0; i < num_wepkeys; i++) {
12116     /* copy the encrypted data over to the tmp buffer */
12117 #if 0
12118     printf("trying %d\n", i);
12119 #endif
12120     memcpy(tmp, enc_data, len);
12121     if (wep_decrypt(tmp, len, i) == 0) {
12122
12123       /* decrypt successful, let's set up a new data tvb. */
12124       decr_tvb = tvb_new_real_data(tmp, len-8, len-8);
12125       tvb_set_free_cb(decr_tvb, g_free);
12126       tvb_set_child_real_data_tvbuff(tvb, decr_tvb);
12127
12128       break;
12129     }
12130   }
12131
12132   if ((!decr_tvb) && (tmp))    g_free(tmp);
12133
12134 #if 0
12135   printf("de-wep %p\n", decr_tvb);
12136 #endif
12137
12138   return decr_tvb;
12139 }
12140 #endif
12141
12142 /*
12143  * Convert a raw WEP key or one prefixed with "wep:" to a byte array.
12144  * Separators are allowed.
12145  */
12146 /* XXX This is duplicated in epan/airpdcap.c:parse_key_string() */
12147 static gboolean
12148 wep_str_to_bytes(const char *hex_str, GByteArray *bytes) {
12149   char *first_nibble = (char *) hex_str;
12150
12151   if (g_ascii_strncasecmp(hex_str, STRING_KEY_TYPE_WEP ":", 4) == 0) {
12152     first_nibble += 4;
12153   }
12154
12155   return hex_str_to_bytes(first_nibble, bytes, FALSE);
12156 }
12157
12158 /* Collect our WEP and WPA keys */
12159 #ifdef HAVE_AIRPDCAP
12160 static
12161 void set_airpdcap_keys(void)
12162 {
12163   guint i = 0;
12164   AIRPDCAP_KEY_ITEM key;
12165   PAIRPDCAP_KEYS_COLLECTION keys;
12166   decryption_key_t* dk = NULL;
12167   GByteArray *bytes = NULL;
12168   gboolean res;
12169   gchar* tmpk = NULL;
12170
12171   keys=(PAIRPDCAP_KEYS_COLLECTION)g_malloc(sizeof(AIRPDCAP_KEYS_COLLECTION));
12172   keys->nKeys = 0;
12173
12174   for(i = 0; i < MAX_ENCRYPTION_KEYS; i++)
12175   {
12176     tmpk = g_strdup(wep_keystr[i]);
12177
12178     dk = parse_key_string(tmpk);
12179
12180     if(dk != NULL)
12181     {
12182       if(dk->type == AIRPDCAP_KEY_TYPE_WEP)
12183       {
12184         key.KeyType = AIRPDCAP_KEY_TYPE_WEP;
12185
12186         bytes = g_byte_array_new();
12187         res = wep_str_to_bytes(dk->key->str, bytes);
12188
12189         if (dk->key->str && res && bytes->len > 0 && bytes->len <= AIRPDCAP_WEP_KEY_MAXLEN)
12190         {
12191           /*
12192            * WEP key is correct (well, the can be even or odd, so it is not
12193            * a real check, I think... is a check performed somewhere in the
12194            * AirPDcap function??? )
12195            */
12196           memcpy(key.KeyData.Wep.WepKey, bytes->data, bytes->len);
12197           key.KeyData.Wep.WepKeyLen = bytes->len;
12198           keys->Keys[keys->nKeys] = key;
12199           keys->nKeys++;
12200         }
12201       }
12202       else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PWD)
12203       {
12204         key.KeyType = AIRPDCAP_KEY_TYPE_WPA_PWD;
12205
12206         /* XXX - This just lops the end if the key off if it's too long.
12207          *       Should we handle this more gracefully? */
12208         g_strlcpy(key.UserPwd.Passphrase, dk->key->str, AIRPDCAP_WPA_PASSPHRASE_MAX_LEN);
12209
12210         key.UserPwd.SsidLen = 0;
12211         if(dk->ssid != NULL && dk->ssid->len <= AIRPDCAP_WPA_SSID_MAX_LEN)
12212         {
12213           memcpy(key.UserPwd.Ssid, dk->ssid->data, dk->ssid->len);
12214           key.UserPwd.SsidLen = dk->ssid->len;
12215         }
12216
12217         keys->Keys[keys->nKeys] = key;
12218         keys->nKeys++;
12219       }
12220       else if(dk->type == AIRPDCAP_KEY_TYPE_WPA_PMK)
12221       {
12222         key.KeyType = AIRPDCAP_KEY_TYPE_WPA_PMK;
12223
12224         bytes = g_byte_array_new();
12225         res = wep_str_to_bytes(dk->key->str, bytes);
12226
12227         /* XXX - Pass the correct array of bytes... */
12228         if (bytes-> len <= AIRPDCAP_WPA_PMK_LEN) {
12229           memcpy(key.KeyData.Wpa.Pmk, bytes->data, bytes->len);
12230
12231           keys->Keys[keys->nKeys] = key;
12232           keys->nKeys++;
12233         }
12234       }
12235     }
12236     if(tmpk != NULL) g_free(tmpk);
12237   }
12238
12239   /* Now set the keys */
12240   AirPDcapSetKeys(&airpdcap_ctx,keys->Keys,keys->nKeys);
12241   g_free(keys);
12242   if (bytes)
12243     g_byte_array_free(bytes, TRUE);
12244
12245 }
12246 #endif
12247
12248 #ifndef HAVE_AIRPDCAP
12249 /* de-weps the block.  if successful, buf* will point to the data start. */
12250 static int wep_decrypt(guint8 *buf, guint32 len, int keyidx) {
12251   guint32 i, j, k, crc, keylen;
12252   guint8 s[256], key[128], c_crc[4];
12253   guint8 *dpos, *cpos;
12254
12255   /* Needs to be at least 8 bytes of payload */
12256   if (len < 8)
12257     return -1;
12258
12259   /* initialize the first bytes of the key from the IV */
12260   key[0] = buf[0];
12261   key[1] = buf[1];
12262   key[2] = buf[2];
12263
12264   if (keyidx < 0 || keyidx >= num_wepkeys)
12265     return -1;
12266
12267   keylen = wep_keylens[keyidx];
12268
12269   if (keylen == 0)
12270     return -1;
12271   if (wep_keys[keyidx] == NULL)
12272     return -1;
12273
12274   keylen+=3;  /* add in ICV bytes */
12275
12276   /* copy the rest of the key over from the designated key */
12277   memcpy(key+3, wep_keys[keyidx], wep_keylens[keyidx]);
12278
12279 #if 0
12280   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]);
12281 #endif
12282
12283   /* set up the RC4 state */
12284   for (i = 0; i < 256; i++)
12285     s[i] = i;
12286   j = 0;
12287   for (i = 0; i < 256; i++) {
12288     j = (j + s[i] + key[i % keylen]) & 0xff;
12289     SSWAP(i,j);
12290   }
12291
12292   /* Apply the RC4 to the data, update the CRC32 */
12293   cpos = buf+4;
12294   dpos = buf;
12295   crc = ~0;
12296   i = j = 0;
12297   for (k = 0; k < (len -8); k++) {
12298     i = (i+1) & 0xff;
12299     j = (j+s[i]) & 0xff;
12300     SSWAP(i,j);
12301 #if 0
12302     printf("%d -- %02x ", k, *dpos);
12303 #endif
12304     *dpos = *cpos++ ^ s[(s[i] + s[j]) & 0xff];
12305 #if 0
12306     printf("%02x\n", *dpos);
12307 #endif
12308     crc = crc32_ccitt_table[(crc ^ *dpos++) & 0xff] ^ (crc >> 8);
12309   }
12310   crc = ~crc;
12311
12312   /* now let's check the crc */
12313   c_crc[0] = crc;
12314   c_crc[1] = crc >> 8;
12315   c_crc[2] = crc >> 16;
12316   c_crc[3] = crc >> 24;
12317
12318   for (k = 0; k < 4; k++) {
12319     i = (i + 1) & 0xff;
12320     j = (j+s[i]) & 0xff;
12321     SSWAP(i,j);
12322 #if 0
12323     printf("-- %02x %02x\n", *dpos, c_crc[k]);
12324 #endif
12325     if ((*cpos++ ^ s[(s[i] + s[j]) & 0xff]) != c_crc[k])
12326       return -1; /* ICV mismatch */
12327   }
12328
12329   return 0;
12330 }
12331 #endif
12332
12333 static void init_wepkeys(void) {
12334 #ifndef  HAVE_AIRPDCAP
12335   const char *tmp;
12336   int i, keyidx;
12337   GByteArray *bytes;
12338   gboolean res;
12339
12340   if (wep_keys) {
12341     for (i = 0; i < num_wepkeys; i++)
12342       g_free(wep_keys[i]);
12343     g_free(wep_keys);
12344   }
12345
12346   if (wep_keylens)
12347     g_free(wep_keylens);
12348
12349 #ifdef USE_ENV
12350   guint8 *buf;
12351
12352   tmp = getenv("WIRESHARK_WEPKEYNUM");
12353   if (!tmp) {
12354     num_wepkeys = 0;
12355     return;
12356   }
12357   num_wepkeys = atoi(tmp);
12358
12359   if (num_wepkeys < 1)
12360     return;
12361 #endif
12362
12363   /* Figure out how many valid keys we have */
12364   bytes = g_byte_array_new();
12365   num_wepkeys = 0;
12366   for ( i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
12367     g_strstrip(wep_keystr[i]);
12368     res = wep_str_to_bytes(wep_keystr[i], bytes);
12369     if (wep_keystr[i] && res && bytes-> len > 0) {
12370       num_wepkeys++;
12371     }
12372   }
12373
12374   wep_keys = g_malloc0(num_wepkeys * sizeof(guint8*));
12375   wep_keylens = g_malloc(num_wepkeys * sizeof(int));
12376
12377   for (i = 0, keyidx = 0; i < MAX_ENCRYPTION_KEYS && keyidx < num_wepkeys; i++) {
12378     wep_keys[keyidx] = NULL;
12379     wep_keylens[keyidx] = 0;
12380
12381 #ifdef USE_ENV
12382     buf=ep_alloc(128);
12383     g_snprintf(buf, 128, "WIRESHARK_WEPKEY%d", i+1);
12384     tmp = getenv(buf);
12385 #else
12386     tmp = wep_keystr[i];
12387 #endif
12388
12389     if (tmp) {
12390 #if 0
12391 #ifdef USE_ENV
12392       printf("%s -- %s\n", buf, tmp);
12393 #else
12394       printf("%d -- %s\n", i+1, tmp);
12395 #endif
12396 #endif
12397
12398       if (wep_keys[keyidx]) {
12399         g_free(wep_keys[keyidx]);
12400       }
12401
12402       res = wep_str_to_bytes(tmp, bytes);
12403       if (tmp && res && bytes->len > 0) {
12404         if (bytes->len > 32) {
12405           bytes->len = 32;
12406         }
12407         wep_keys[keyidx] = g_malloc0(32 * sizeof(guint8));
12408         memcpy(wep_keys[keyidx], bytes->data, bytes->len * sizeof(guint8));
12409         wep_keylens[keyidx] = bytes->len;
12410         keyidx++;
12411 #if 0
12412         printf("%d: %d bytes\n", i, bytes->len);
12413         printf("%d: %s\n", i, bytes_to_str(bytes->data, bytes->len));
12414 #endif
12415       } else {
12416 #if 0
12417         printf("res: %d  bytes->len: %d\n", res, bytes->len);
12418 #endif
12419         if (tmp[0] != 'w') /* Assume it begins with "wep:" or "wpa-*:" */
12420           g_warning("Could not parse WEP key %d: %s", i + 1, tmp);
12421       }
12422     }
12423   }
12424   g_byte_array_free(bytes, TRUE);
12425
12426 #else /* HAVE_AIRPDCAP defined */
12427
12428   /*
12429    * XXX - AirPDcap - That God sends it to us beautiful (che dio ce la mandi bona)
12430    * The next lines will add a key to the AirPDcap context. The keystring will be added
12431    * to the old WEP array too, but we don't care, because the packets will come here
12432    * already decrypted... One of these days we will fix this too
12433    */
12434   set_airpdcap_keys();
12435 #endif /* HAVE_AIRPDCAP */
12436 }
12437 /*
12438  * This code had been taken from AirSnort crack.c function classify()
12439  * Permission granted by snax <at> shmoo dot com
12440  * weak_iv - determine which key byte an iv is useful in resolving
12441  * parm     - p, pointer to the first byte of an IV
12442  * return   -  n - this IV is weak for byte n of a WEP key
12443  *            -1 - this IV is not weak for any key bytes
12444  *
12445  * This function tests for IVs that are known to satisfy the criteria
12446  * for a weak IV as specified in FMS section 7.1
12447  *
12448  */
12449 static int
12450 weak_iv(guchar *iv)
12451 {
12452         guchar sum, k;
12453
12454         if (iv[1] == 255 && iv[0] > 2 && iv[0] < 16) {
12455                 return iv[0] -3;
12456         }
12457
12458         sum = iv[0] + iv[1];
12459         if (sum == 1) {
12460                 if (iv[2] <= 0x0a) {
12461                         return iv[2] +2;
12462                 }
12463                 else if (iv[2] == 0xff){
12464                         return 0;
12465                 }
12466         }
12467         k = 0xfe - iv[2];
12468         if (sum == k  && (iv[2] >= 0xf2 && iv[2] <= 0xfe && iv[2] != 0xfd)){
12469                 return k;
12470         }
12471         return -1;
12472 }
12473
12474 /*
12475  * Editor modelines
12476  *
12477  * Local Variables:
12478  * c-basic-offset: 2
12479  * tab-width: 8
12480  * indent-tabs-mode: nil
12481  * End:
12482  *
12483  * ex: set shiftwidth=2 tabstop=8 expandtab
12484  * :indentSize=2:tabSize=8:noTabs=true:
12485  */