3 * Fortress Technologies, Inc. All rights reserved.
4 * Charlie Lenahan (clenahan@fortresstech.com)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that: (1) source code distributions
8 * retain the above copyright notice and this paragraph in its entirety, (2)
9 * distributions including binary code include the above copyright notice and
10 * this paragraph in its entirety in the documentation or other materials
11 * provided with the distribution, and (3) all advertising materials mentioning
12 * features or use of this software display the following acknowledgement:
13 * ``This product includes software developed by the University of California,
14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 * the University nor the names of its contributors may be used to endorse
16 * or promote products derived from this software without specific prior
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 #include <tcpdump-stdinc.h>
31 #include "interface.h"
32 #include "addrtoname.h"
39 /* Lengths of 802.11 header components. */
40 #define IEEE802_11_FC_LEN 2
41 #define IEEE802_11_DUR_LEN 2
42 #define IEEE802_11_DA_LEN 6
43 #define IEEE802_11_SA_LEN 6
44 #define IEEE802_11_BSSID_LEN 6
45 #define IEEE802_11_RA_LEN 6
46 #define IEEE802_11_TA_LEN 6
47 #define IEEE802_11_ADDR1_LEN 6
48 #define IEEE802_11_SEQ_LEN 2
49 #define IEEE802_11_CTL_LEN 2
50 #define IEEE802_11_CARRIED_FC_LEN 2
51 #define IEEE802_11_HT_CONTROL_LEN 4
52 #define IEEE802_11_IV_LEN 3
53 #define IEEE802_11_KID_LEN 1
55 /* Frame check sequence length. */
56 #define IEEE802_11_FCS_LEN 4
58 /* Lengths of beacon components. */
59 #define IEEE802_11_TSTAMP_LEN 8
60 #define IEEE802_11_BCNINT_LEN 2
61 #define IEEE802_11_CAPINFO_LEN 2
62 #define IEEE802_11_LISTENINT_LEN 2
64 #define IEEE802_11_AID_LEN 2
65 #define IEEE802_11_STATUS_LEN 2
66 #define IEEE802_11_REASON_LEN 2
68 /* Length of previous AP in reassocation frame */
69 #define IEEE802_11_AP_LEN 6
71 #define T_MGMT 0x0 /* management */
72 #define T_CTRL 0x1 /* control */
73 #define T_DATA 0x2 /* data */
74 #define T_RESV 0x3 /* reserved */
76 #define ST_ASSOC_REQUEST 0x0
77 #define ST_ASSOC_RESPONSE 0x1
78 #define ST_REASSOC_REQUEST 0x2
79 #define ST_REASSOC_RESPONSE 0x3
80 #define ST_PROBE_REQUEST 0x4
81 #define ST_PROBE_RESPONSE 0x5
86 #define ST_DISASSOC 0xA
93 static const struct tok st_str
[] = {
94 { ST_ASSOC_REQUEST
, "Assoc Request" },
95 { ST_ASSOC_RESPONSE
, "Assoc Response" },
96 { ST_REASSOC_REQUEST
, "ReAssoc Request" },
97 { ST_REASSOC_RESPONSE
, "ReAssoc Response" },
98 { ST_PROBE_REQUEST
, "Probe Request" },
99 { ST_PROBE_RESPONSE
, "Probe Response" },
100 { ST_BEACON
, "Beacon" },
102 { ST_DISASSOC
, "Disassociation" },
103 { ST_AUTH
, "Authentication" },
104 { ST_DEAUTH
, "DeAuthentication" },
105 { ST_ACTION
, "Action" },
109 #define CTRL_CONTROL_WRAPPER 0x7
112 #define CTRL_PS_POLL 0xA
116 #define CTRL_CF_END 0xE
117 #define CTRL_END_ACK 0xF
119 static const struct tok ctrl_str
[] = {
120 { CTRL_CONTROL_WRAPPER
, "Control Wrapper" },
123 { CTRL_PS_POLL
, "Power Save-Poll" },
124 { CTRL_RTS
, "Request-To-Send" },
125 { CTRL_CTS
, "Clear-To-Send" },
126 { CTRL_ACK
, "Acknowledgment" },
127 { CTRL_CF_END
, "CF-End" },
128 { CTRL_END_ACK
, "CF-End+CF-Ack" },
132 #define DATA_DATA 0x0
133 #define DATA_DATA_CF_ACK 0x1
134 #define DATA_DATA_CF_POLL 0x2
135 #define DATA_DATA_CF_ACK_POLL 0x3
136 #define DATA_NODATA 0x4
137 #define DATA_NODATA_CF_ACK 0x5
138 #define DATA_NODATA_CF_POLL 0x6
139 #define DATA_NODATA_CF_ACK_POLL 0x7
141 #define DATA_QOS_DATA 0x8
142 #define DATA_QOS_DATA_CF_ACK 0x9
143 #define DATA_QOS_DATA_CF_POLL 0xA
144 #define DATA_QOS_DATA_CF_ACK_POLL 0xB
145 #define DATA_QOS_NODATA 0xC
146 #define DATA_QOS_CF_POLL_NODATA 0xE
147 #define DATA_QOS_CF_ACK_POLL_NODATA 0xF
150 * The subtype field of a data frame is, in effect, composed of 4 flag
151 * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
152 * any data), and QoS.
154 #define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
155 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
156 #define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
157 #define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
160 * Bits in the frame control field.
162 #define FC_VERSION(fc) ((fc) & 0x3)
163 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
164 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
165 #define FC_TO_DS(fc) ((fc) & 0x0100)
166 #define FC_FROM_DS(fc) ((fc) & 0x0200)
167 #define FC_MORE_FLAG(fc) ((fc) & 0x0400)
168 #define FC_RETRY(fc) ((fc) & 0x0800)
169 #define FC_POWER_MGMT(fc) ((fc) & 0x1000)
170 #define FC_MORE_DATA(fc) ((fc) & 0x2000)
171 #define FC_PROTECTED(fc) ((fc) & 0x4000)
172 #define FC_ORDER(fc) ((fc) & 0x8000)
174 struct mgmt_header_t
{
177 uint8_t da
[IEEE802_11_DA_LEN
];
178 uint8_t sa
[IEEE802_11_SA_LEN
];
179 uint8_t bssid
[IEEE802_11_BSSID_LEN
];
183 #define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
184 IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
185 IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
187 #define CAPABILITY_ESS(cap) ((cap) & 0x0001)
188 #define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
189 #define CAPABILITY_CFP(cap) ((cap) & 0x0004)
190 #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
191 #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
196 u_char ssid
[33]; /* 32 + 1 for null */
208 uint8_t text
[254]; /* 1-253 + 1 for null */
231 uint16_t max_duration
;
232 uint16_t dur_remaing
;
240 uint8_t bitmap_control
;
262 #define E_CHALLENGE 16
271 uint8_t timestamp
[IEEE802_11_TSTAMP_LEN
];
272 uint16_t beacon_interval
;
273 uint16_t listen_interval
;
274 uint16_t status_code
;
276 u_char ap
[IEEE802_11_AP_LEN
];
277 uint16_t reason_code
;
279 uint16_t auth_trans_seq_num
;
280 int challenge_present
;
281 struct challenge_t challenge
;
282 uint16_t capability_info
;
286 struct rates_t rates
;
297 struct ctrl_control_wrapper_hdr_t
{
300 uint8_t addr1
[IEEE802_11_ADDR1_LEN
];
301 uint16_t carried_fc
[IEEE802_11_CARRIED_FC_LEN
];
302 uint16_t ht_control
[IEEE802_11_HT_CONTROL_LEN
];
305 #define CTRL_CONTROL_WRAPPER_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
306 IEEE802_11_ADDR1_LEN+\
307 IEEE802_11_CARRIED_FC_LEN+\
308 IEEE802_11_HT_CONTROL_LEN)
310 struct ctrl_rts_hdr_t
{
313 uint8_t ra
[IEEE802_11_RA_LEN
];
314 uint8_t ta
[IEEE802_11_TA_LEN
];
317 #define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
318 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
320 struct ctrl_cts_hdr_t
{
323 uint8_t ra
[IEEE802_11_RA_LEN
];
326 #define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
328 struct ctrl_ack_hdr_t
{
331 uint8_t ra
[IEEE802_11_RA_LEN
];
334 #define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
336 struct ctrl_ps_poll_hdr_t
{
339 uint8_t bssid
[IEEE802_11_BSSID_LEN
];
340 uint8_t ta
[IEEE802_11_TA_LEN
];
343 #define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
344 IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
346 struct ctrl_end_hdr_t
{
349 uint8_t ra
[IEEE802_11_RA_LEN
];
350 uint8_t bssid
[IEEE802_11_BSSID_LEN
];
353 #define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
354 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
356 struct ctrl_end_ack_hdr_t
{
359 uint8_t ra
[IEEE802_11_RA_LEN
];
360 uint8_t bssid
[IEEE802_11_BSSID_LEN
];
363 #define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
364 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
366 struct ctrl_ba_hdr_t
{
369 uint8_t ra
[IEEE802_11_RA_LEN
];
372 #define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
374 struct ctrl_bar_hdr_t
{
377 uint8_t ra
[IEEE802_11_RA_LEN
];
378 uint8_t ta
[IEEE802_11_TA_LEN
];
383 #define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
384 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
385 IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
396 #define IV_IV(iv) ((iv) & 0xFFFFFF)
397 #define IV_PAD(iv) (((iv) >> 24) & 0x3F)
398 #define IV_KEYID(iv) (((iv) >> 30) & 0x03)
400 /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
401 /* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
404 * Copyright (c) 2003, 2004 David Young. All rights reserved.
406 * Redistribution and use in source and binary forms, with or without
407 * modification, are permitted provided that the following conditions
409 * 1. Redistributions of source code must retain the above copyright
410 * notice, this list of conditions and the following disclaimer.
411 * 2. Redistributions in binary form must reproduce the above copyright
412 * notice, this list of conditions and the following disclaimer in the
413 * documentation and/or other materials provided with the distribution.
414 * 3. The name of David Young may not be used to endorse or promote
415 * products derived from this software without specific prior
416 * written permission.
418 * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
419 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
420 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
421 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
422 * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
423 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
424 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
425 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
426 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
427 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
428 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
432 /* A generic radio capture format is desirable. It must be
433 * rigidly defined (e.g., units for fields should be given),
434 * and easily extensible.
436 * The following is an extensible radio capture format. It is
437 * based on a bitmap indicating which fields are present.
439 * I am trying to describe precisely what the application programmer
440 * should expect in the following, and for that reason I tell the
441 * units and origin of each measurement (where it applies), or else I
442 * use sufficiently weaselly language ("is a monotonically nondecreasing
443 * function of...") that I cannot set false expectations for lawyerly
448 * The radio capture header precedes the 802.11 header.
450 * Note well: all radiotap fields are little-endian.
452 struct ieee80211_radiotap_header
{
453 uint8_t it_version
; /* Version 0. Only increases
454 * for drastic changes,
455 * introduction of compatible
456 * new fields does not count.
459 uint16_t it_len
; /* length of the whole
460 * header in bytes, including
461 * it_version, it_pad,
462 * it_len, and data fields.
464 uint32_t it_present
; /* A bitmap telling which
465 * fields are present. Set bit 31
466 * (0x80000000) to extend the
467 * bitmap by another 32 bits.
468 * Additional extensions are made
473 /* Name Data type Units
474 * ---- --------- -----
476 * IEEE80211_RADIOTAP_TSFT uint64_t microseconds
478 * Value in microseconds of the MAC's 64-bit 802.11 Time
479 * Synchronization Function timer when the first bit of the
480 * MPDU arrived at the MAC. For received frames, only.
482 * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
484 * Tx/Rx frequency in MHz, followed by flags (see below).
485 * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
486 * represent an HT channel as there is not enough room in
489 * IEEE80211_RADIOTAP_FHSS uint16_t see below
491 * For frequency-hopping radios, the hop set (first byte)
492 * and pattern (second byte).
494 * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index
496 * Tx/Rx data rate. If bit 0x80 is set then it represents an
497 * an MCS index and not an IEEE rate.
499 * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
500 * one milliwatt (dBm)
502 * RF signal power at the antenna, decibel difference from
505 * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
506 * one milliwatt (dBm)
508 * RF noise power at the antenna, decibel difference from one
511 * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
513 * RF signal power at the antenna, decibel difference from an
514 * arbitrary, fixed reference.
516 * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
518 * RF noise power at the antenna, decibel difference from an
519 * arbitrary, fixed reference point.
521 * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
523 * Quality of Barker code lock. Unitless. Monotonically
524 * nondecreasing with "better" lock strength. Called "Signal
525 * Quality" in datasheets. (Is there a standard way to measure
528 * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
530 * Transmit power expressed as unitless distance from max
531 * power set at factory calibration. 0 is max power.
532 * Monotonically nondecreasing with lower power levels.
534 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
536 * Transmit power expressed as decibel distance from max power
537 * set at factory calibration. 0 is max power. Monotonically
538 * nondecreasing with lower power levels.
540 * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
541 * one milliwatt (dBm)
543 * Transmit power expressed as dBm (decibels from a 1 milliwatt
544 * reference). This is the absolute power level measured at
547 * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap
549 * Properties of transmitted and received frames. See flags
552 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
554 * Unitless indication of the Rx/Tx antenna for this packet.
555 * The first antenna is antenna 0.
557 * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
559 * Properties of received frames. See flags defined below.
561 * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap
563 * uint8_t channel number
566 * Extended channel specification: flags (see below) followed by
567 * frequency in MHz, the corresponding IEEE channel number, and
568 * finally the maximum regulatory transmit power cap in .5 dBm
569 * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
570 * and only one of the two should be present.
572 * IEEE80211_RADIOTAP_MCS uint8_t known
576 * Bitset indicating which fields have known values, followed
577 * by bitset of flag values, followed by the MCS rate index as
580 * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
585 * The Vendor Namespace Field contains three sub-fields. The first
586 * sub-field is 3 bytes long. It contains the vendor's IEEE 802
587 * Organizationally Unique Identifier (OUI). The fourth byte is a
588 * vendor-specific "namespace selector."
591 enum ieee80211_radiotap_type
{
592 IEEE80211_RADIOTAP_TSFT
= 0,
593 IEEE80211_RADIOTAP_FLAGS
= 1,
594 IEEE80211_RADIOTAP_RATE
= 2,
595 IEEE80211_RADIOTAP_CHANNEL
= 3,
596 IEEE80211_RADIOTAP_FHSS
= 4,
597 IEEE80211_RADIOTAP_DBM_ANTSIGNAL
= 5,
598 IEEE80211_RADIOTAP_DBM_ANTNOISE
= 6,
599 IEEE80211_RADIOTAP_LOCK_QUALITY
= 7,
600 IEEE80211_RADIOTAP_TX_ATTENUATION
= 8,
601 IEEE80211_RADIOTAP_DB_TX_ATTENUATION
= 9,
602 IEEE80211_RADIOTAP_DBM_TX_POWER
= 10,
603 IEEE80211_RADIOTAP_ANTENNA
= 11,
604 IEEE80211_RADIOTAP_DB_ANTSIGNAL
= 12,
605 IEEE80211_RADIOTAP_DB_ANTNOISE
= 13,
606 IEEE80211_RADIOTAP_RX_FLAGS
= 14,
607 /* NB: gap for netbsd definitions */
608 IEEE80211_RADIOTAP_XCHANNEL
= 18,
609 IEEE80211_RADIOTAP_MCS
= 19,
610 IEEE80211_RADIOTAP_NAMESPACE
= 29,
611 IEEE80211_RADIOTAP_VENDOR_NAMESPACE
= 30,
612 IEEE80211_RADIOTAP_EXT
= 31
615 /* channel attributes */
616 #define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
617 #define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
618 #define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
619 #define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
620 #define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
621 #define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
622 #define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
623 #define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
624 #define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
625 #define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
626 #define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
627 #define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
628 #define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
629 #define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
630 #define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
632 /* Useful combinations of channel characteristics, borrowed from Ethereal */
633 #define IEEE80211_CHAN_A \
634 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
635 #define IEEE80211_CHAN_B \
636 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
637 #define IEEE80211_CHAN_G \
638 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
639 #define IEEE80211_CHAN_TA \
640 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
641 #define IEEE80211_CHAN_TG \
642 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
645 /* For IEEE80211_RADIOTAP_FLAGS */
646 #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
649 #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
653 #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
654 * with WEP encryption
656 #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
659 #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
660 #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
661 * 802.11 header and payload
662 * (to 32-bit boundary)
664 #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
666 /* For IEEE80211_RADIOTAP_RX_FLAGS */
667 #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
668 #define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
670 /* For IEEE80211_RADIOTAP_MCS known */
671 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
672 #define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
673 #define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
674 #define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
675 #define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
676 #define IEEE80211_RADIOTAP_MCS_STBC_KNOWN 0x20
678 /* For IEEE80211_RADIOTAP_MCS flags */
679 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
680 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
681 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
682 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
683 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
684 #define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
685 #define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
686 #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
687 #define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60
688 #define IEEE80211_RADIOTAP_MCS_STBC_1 1
689 #define IEEE80211_RADIOTAP_MCS_STBC_2 2
690 #define IEEE80211_RADIOTAP_MCS_STBC_3 3
691 #define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5
693 static const char tstr
[] = "[|802.11]";
696 /* This is used to save state when parsing/processing parameters */
697 struct radiotap_state
704 #define PRINT_SSID(p) \
705 if (p.ssid_present) { \
706 ND_PRINT((ndo, " (")); \
707 fn_print(ndo, p.ssid.ssid, NULL); \
708 ND_PRINT((ndo, ")")); \
711 #define PRINT_RATE(_sep, _r, _suf) \
712 ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf))
713 #define PRINT_RATES(p) \
714 if (p.rates_present) { \
716 const char *sep = " ["; \
717 for (z = 0; z < p.rates.length ; z++) { \
718 PRINT_RATE(sep, p.rates.rate[z], \
719 (p.rates.rate[z] & 0x80 ? "*" : "")); \
722 if (p.rates.length != 0) \
723 ND_PRINT((ndo, " Mbit]")); \
726 #define PRINT_DS_CHANNEL(p) \
728 ND_PRINT((ndo, " CH: %u", p.ds.channel)); \
729 ND_PRINT((ndo, "%s", \
730 CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : ""));
732 #define MAX_MCS_INDEX 76
737 * the MCS index (0-76);
739 * 0 for 20 MHz, 1 for 40 MHz;
741 * 0 for a long guard interval, 1 for a short guard interval.
743 static const float ieee80211_float_htrates
[MAX_MCS_INDEX
+1][2][2] = {
745 { /* 20 Mhz */ { 6.5, /* SGI */ 7.2, },
746 /* 40 Mhz */ { 13.5, /* SGI */ 15.0, },
750 { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
751 /* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
755 { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
756 /* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
760 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
761 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
765 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
766 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
770 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
771 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
775 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
776 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
780 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
781 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
785 { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
786 /* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
790 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
791 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
795 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
796 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
800 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
801 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
805 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
806 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
810 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
811 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
815 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
816 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
820 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
821 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
825 { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
826 /* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
830 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
831 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
835 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
836 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
840 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
841 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
845 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
846 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
850 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
851 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
855 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
856 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
860 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
861 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
865 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
866 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
870 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
871 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
875 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
876 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
880 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
881 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
885 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
886 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
890 { /* 20 Mhz */ { 208.0, /* SGI */ 231.1, },
891 /* 40 Mhz */ { 432.0, /* SGI */ 480.0, },
895 { /* 20 Mhz */ { 234.0, /* SGI */ 260.0, },
896 /* 40 Mhz */ { 486.0, /* SGI */ 540.0, },
900 { /* 20 Mhz */ { 260.0, /* SGI */ 288.9, },
901 /* 40 Mhz */ { 540.0, /* SGI */ 600.0, },
905 { /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */
906 /* 40 Mhz */ { 6.0, /* SGI */ 6.7, },
910 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
911 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
915 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
916 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
920 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
921 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
925 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
926 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
930 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
931 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
935 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
936 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
940 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
941 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
945 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
946 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
950 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
951 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
955 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
956 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
960 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
961 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
965 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
966 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
970 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
971 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
975 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
976 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
980 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
981 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
985 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
986 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
990 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
991 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
995 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
996 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1000 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1001 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1005 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1006 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1010 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
1011 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
1015 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
1016 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
1020 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
1021 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
1025 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
1026 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
1030 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
1031 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
1035 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
1036 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
1040 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1041 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1045 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
1046 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
1050 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1051 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1055 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
1056 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
1060 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
1061 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
1065 { /* 20 Mhz */ { 143.0, /* SGI */ 158.9, },
1066 /* 40 Mhz */ { 297.0, /* SGI */ 330.0, },
1070 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
1071 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
1075 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1076 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1080 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1081 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1085 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1086 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1090 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1091 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1095 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1096 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1100 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
1101 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
1105 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1106 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1110 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
1111 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
1115 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
1116 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
1120 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
1121 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
1125 { /* 20 Mhz */ { 214.5, /* SGI */ 238.3, },
1126 /* 40 Mhz */ { 445.5, /* SGI */ 495.0, },
1130 static const char *auth_alg_text
[]={"Open System","Shared Key","EAP"};
1131 #define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
1133 static const char *status_text
[] = {
1134 "Successful", /* 0 */
1135 "Unspecified failure", /* 1 */
1144 "Cannot Support all requested capabilities in the Capability "
1145 "Information field", /* 10 */
1146 "Reassociation denied due to inability to confirm that association "
1148 "Association denied due to reason outside the scope of the "
1149 "standard", /* 12 */
1150 "Responding station does not support the specified authentication "
1151 "algorithm ", /* 13 */
1152 "Received an Authentication frame with authentication transaction "
1153 "sequence number out of expected sequence", /* 14 */
1154 "Authentication rejected because of challenge failure", /* 15 */
1155 "Authentication rejected due to timeout waiting for next frame in "
1156 "sequence", /* 16 */
1157 "Association denied because AP is unable to handle additional"
1158 "associated stations", /* 17 */
1159 "Association denied due to requesting station not supporting all of "
1160 "the data rates in BSSBasicRateSet parameter", /* 18 */
1161 "Association denied due to requesting station not supporting "
1162 "short preamble operation", /* 19 */
1163 "Association denied due to requesting station not supporting "
1164 "PBCC encoding", /* 20 */
1165 "Association denied due to requesting station not supporting "
1166 "channel agility", /* 21 */
1167 "Association request rejected because Spectrum Management "
1168 "capability is required", /* 22 */
1169 "Association request rejected because the information in the "
1170 "Power Capability element is unacceptable", /* 23 */
1171 "Association request rejected because the information in the "
1172 "Supported Channels element is unacceptable", /* 24 */
1173 "Association denied due to requesting station not supporting "
1174 "short slot operation", /* 25 */
1175 "Association denied due to requesting station not supporting "
1176 "DSSS-OFDM operation", /* 26 */
1177 "Association denied because the requested STA does not support HT "
1178 "features", /* 27 */
1179 "Reserved", /* 28 */
1180 "Association denied because the requested STA does not support "
1181 "the PCO transition time required by the AP", /* 29 */
1182 "Reserved", /* 30 */
1183 "Reserved", /* 31 */
1184 "Unspecified, QoS-related failure", /* 32 */
1185 "Association denied due to QAP having insufficient bandwidth "
1186 "to handle another QSTA", /* 33 */
1187 "Association denied due to excessive frame loss rates and/or "
1188 "poor conditions on current operating channel", /* 34 */
1189 "Association (with QBSS) denied due to requesting station not "
1190 "supporting the QoS facility", /* 35 */
1191 "Association denied due to requesting station not supporting "
1192 "Block Ack", /* 36 */
1193 "The request has been declined", /* 37 */
1194 "The request has not been successful as one or more parameters "
1195 "have invalid values", /* 38 */
1196 "The TS has not been created because the request cannot be honored. "
1197 "Try again with the suggested changes to the TSPEC", /* 39 */
1198 "Invalid Information Element", /* 40 */
1199 "Group Cipher is not valid", /* 41 */
1200 "Pairwise Cipher is not valid", /* 42 */
1201 "AKMP is not valid", /* 43 */
1202 "Unsupported RSN IE version", /* 44 */
1203 "Invalid RSN IE Capabilities", /* 45 */
1204 "Cipher suite is rejected per security policy", /* 46 */
1205 "The TS has not been created. However, the HC may be capable of "
1206 "creating a TS, in response to a request, after the time indicated "
1207 "in the TS Delay element", /* 47 */
1208 "Direct Link is not allowed in the BSS by policy", /* 48 */
1209 "Destination STA is not present within this QBSS.", /* 49 */
1210 "The Destination STA is not a QSTA.", /* 50 */
1213 #define NUM_STATUSES (sizeof status_text / sizeof status_text[0])
1215 static const char *reason_text
[] = {
1217 "Unspecified reason", /* 1 */
1218 "Previous authentication no longer valid", /* 2 */
1219 "Deauthenticated because sending station is leaving (or has left) "
1220 "IBSS or ESS", /* 3 */
1221 "Disassociated due to inactivity", /* 4 */
1222 "Disassociated because AP is unable to handle all currently "
1223 " associated stations", /* 5 */
1224 "Class 2 frame received from nonauthenticated station", /* 6 */
1225 "Class 3 frame received from nonassociated station", /* 7 */
1226 "Disassociated because sending station is leaving "
1227 "(or has left) BSS", /* 8 */
1228 "Station requesting (re)association is not authenticated with "
1229 "responding station", /* 9 */
1230 "Disassociated because the information in the Power Capability "
1231 "element is unacceptable", /* 10 */
1232 "Disassociated because the information in the SupportedChannels "
1233 "element is unacceptable", /* 11 */
1234 "Invalid Information Element", /* 12 */
1235 "Reserved", /* 13 */
1236 "Michael MIC failure", /* 14 */
1237 "4-Way Handshake timeout", /* 15 */
1238 "Group key update timeout", /* 16 */
1239 "Information element in 4-Way Handshake different from (Re)Association"
1240 "Request/Probe Response/Beacon", /* 17 */
1241 "Group Cipher is not valid", /* 18 */
1242 "AKMP is not valid", /* 20 */
1243 "Unsupported RSN IE version", /* 21 */
1244 "Invalid RSN IE Capabilities", /* 22 */
1245 "IEEE 802.1X Authentication failed", /* 23 */
1246 "Cipher suite is rejected per security policy", /* 24 */
1247 "Reserved", /* 25 */
1248 "Reserved", /* 26 */
1249 "Reserved", /* 27 */
1250 "Reserved", /* 28 */
1251 "Reserved", /* 29 */
1252 "Reserved", /* 30 */
1253 "TS deleted because QoS AP lacks sufficient bandwidth for this "
1254 "QoS STA due to a change in BSS service characteristics or "
1255 "operational mode (e.g. an HT BSS change from 40 MHz channel "
1256 "to 20 MHz channel)", /* 31 */
1257 "Disassociated for unspecified, QoS-related reason", /* 32 */
1258 "Disassociated because QoS AP lacks sufficient bandwidth for this "
1260 "Disassociated because of excessive number of frames that need to be "
1261 "acknowledged, but are not acknowledged for AP transmissions "
1262 "and/or poor channel conditions", /* 34 */
1263 "Disassociated because STA is transmitting outside the limits "
1264 "of its TXOPs", /* 35 */
1265 "Requested from peer STA as the STA is leaving the BSS "
1266 "(or resetting)", /* 36 */
1267 "Requested from peer STA as it does not want to use the "
1268 "mechanism", /* 37 */
1269 "Requested from peer STA as the STA received frames using the "
1270 "mechanism for which a set up is required", /* 38 */
1271 "Requested from peer STA due to time out", /* 39 */
1272 "Reserved", /* 40 */
1273 "Reserved", /* 41 */
1274 "Reserved", /* 42 */
1275 "Reserved", /* 43 */
1276 "Reserved", /* 44 */
1277 "Peer STA does not support the requested cipher suite", /* 45 */
1278 "Association denied due to requesting STA not supporting HT "
1279 "features", /* 46 */
1281 #define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
1284 wep_print(netdissect_options
*ndo
,
1289 if (!ND_TTEST2(*p
, IEEE802_11_IV_LEN
+ IEEE802_11_KID_LEN
))
1291 iv
= EXTRACT_LE_32BITS(p
);
1293 ND_PRINT((ndo
, " IV:%3x Pad %x KeyID %x", IV_IV(iv
), IV_PAD(iv
),
1300 parse_elements(netdissect_options
*ndo
,
1301 struct mgmt_body_t
*pbody
, const u_char
*p
, int offset
,
1306 struct challenge_t challenge
;
1307 struct rates_t rates
;
1313 * We haven't seen any elements yet.
1315 pbody
->challenge_present
= 0;
1316 pbody
->ssid_present
= 0;
1317 pbody
->rates_present
= 0;
1318 pbody
->ds_present
= 0;
1319 pbody
->cf_present
= 0;
1320 pbody
->tim_present
= 0;
1322 while (length
!= 0) {
1323 /* Make sure we at least have the element ID and length. */
1324 if (!ND_TTEST2(*(p
+ offset
), 2))
1328 elementlen
= *(p
+ offset
+ 1);
1330 /* Make sure we have the entire element. */
1331 if (!ND_TTEST2(*(p
+ offset
+ 2), elementlen
))
1333 if (length
< elementlen
+ 2)
1336 switch (*(p
+ offset
)) {
1338 memcpy(&ssid
, p
+ offset
, 2);
1341 if (ssid
.length
!= 0) {
1342 if (ssid
.length
> sizeof(ssid
.ssid
) - 1)
1344 if (!ND_TTEST2(*(p
+ offset
), ssid
.length
))
1346 if (length
< ssid
.length
)
1348 memcpy(&ssid
.ssid
, p
+ offset
, ssid
.length
);
1349 offset
+= ssid
.length
;
1350 length
-= ssid
.length
;
1352 ssid
.ssid
[ssid
.length
] = '\0';
1354 * Present and not truncated.
1356 * If we haven't already seen an SSID IE,
1357 * copy this one, otherwise ignore this one,
1358 * so we later report the first one we saw.
1360 if (!pbody
->ssid_present
) {
1362 pbody
->ssid_present
= 1;
1366 memcpy(&challenge
, p
+ offset
, 2);
1369 if (challenge
.length
!= 0) {
1370 if (challenge
.length
>
1371 sizeof(challenge
.text
) - 1)
1373 if (!ND_TTEST2(*(p
+ offset
), challenge
.length
))
1375 if (length
< challenge
.length
)
1377 memcpy(&challenge
.text
, p
+ offset
,
1379 offset
+= challenge
.length
;
1380 length
-= challenge
.length
;
1382 challenge
.text
[challenge
.length
] = '\0';
1384 * Present and not truncated.
1386 * If we haven't already seen a challenge IE,
1387 * copy this one, otherwise ignore this one,
1388 * so we later report the first one we saw.
1390 if (!pbody
->challenge_present
) {
1391 pbody
->challenge
= challenge
;
1392 pbody
->challenge_present
= 1;
1396 memcpy(&rates
, p
+ offset
, 2);
1399 if (rates
.length
!= 0) {
1400 if (rates
.length
> sizeof rates
.rate
)
1402 if (!ND_TTEST2(*(p
+ offset
), rates
.length
))
1404 if (length
< rates
.length
)
1406 memcpy(&rates
.rate
, p
+ offset
, rates
.length
);
1407 offset
+= rates
.length
;
1408 length
-= rates
.length
;
1411 * Present and not truncated.
1413 * If we haven't already seen a rates IE,
1414 * copy this one if it's not zero-length,
1415 * otherwise ignore this one, so we later
1416 * report the first one we saw.
1418 * We ignore zero-length rates IEs as some
1419 * devices seem to put a zero-length rates
1420 * IE, followed by an SSID IE, followed by
1421 * a non-zero-length rates IE into frames,
1422 * even though IEEE Std 802.11-2007 doesn't
1423 * seem to indicate that a zero-length rates
1426 if (!pbody
->rates_present
&& rates
.length
!= 0) {
1427 pbody
->rates
= rates
;
1428 pbody
->rates_present
= 1;
1432 memcpy(&ds
, p
+ offset
, 2);
1435 if (ds
.length
!= 1) {
1436 offset
+= ds
.length
;
1437 length
-= ds
.length
;
1440 ds
.channel
= *(p
+ offset
);
1444 * Present and not truncated.
1446 * If we haven't already seen a DS IE,
1447 * copy this one, otherwise ignore this one,
1448 * so we later report the first one we saw.
1450 if (!pbody
->ds_present
) {
1452 pbody
->ds_present
= 1;
1456 memcpy(&cf
, p
+ offset
, 2);
1459 if (cf
.length
!= 6) {
1460 offset
+= cf
.length
;
1461 length
-= cf
.length
;
1464 memcpy(&cf
.count
, p
+ offset
, 6);
1468 * Present and not truncated.
1470 * If we haven't already seen a CF IE,
1471 * copy this one, otherwise ignore this one,
1472 * so we later report the first one we saw.
1474 if (!pbody
->cf_present
) {
1476 pbody
->cf_present
= 1;
1480 memcpy(&tim
, p
+ offset
, 2);
1483 if (tim
.length
<= 3) {
1484 offset
+= tim
.length
;
1485 length
-= tim
.length
;
1488 if (tim
.length
- 3 > (int)sizeof tim
.bitmap
)
1490 memcpy(&tim
.count
, p
+ offset
, 3);
1494 memcpy(tim
.bitmap
, p
+ (tim
.length
- 3),
1496 offset
+= tim
.length
- 3;
1497 length
-= tim
.length
- 3;
1499 * Present and not truncated.
1501 * If we haven't already seen a TIM IE,
1502 * copy this one, otherwise ignore this one,
1503 * so we later report the first one we saw.
1505 if (!pbody
->tim_present
) {
1507 pbody
->tim_present
= 1;
1512 ND_PRINT((ndo
, "(1) unhandled element_id (%d) ",
1515 offset
+= 2 + elementlen
;
1516 length
-= 2 + elementlen
;
1521 /* No problems found. */
1525 /*********************************************************************************
1526 * Print Handle functions for the management frame types
1527 *********************************************************************************/
1530 handle_beacon(netdissect_options
*ndo
,
1531 const u_char
*p
, u_int length
)
1533 struct mgmt_body_t pbody
;
1537 memset(&pbody
, 0, sizeof(pbody
));
1539 if (!ND_TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1540 IEEE802_11_CAPINFO_LEN
))
1542 if (length
< IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1543 IEEE802_11_CAPINFO_LEN
)
1545 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
1546 offset
+= IEEE802_11_TSTAMP_LEN
;
1547 length
-= IEEE802_11_TSTAMP_LEN
;
1548 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
1549 offset
+= IEEE802_11_BCNINT_LEN
;
1550 length
-= IEEE802_11_BCNINT_LEN
;
1551 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
1552 offset
+= IEEE802_11_CAPINFO_LEN
;
1553 length
-= IEEE802_11_CAPINFO_LEN
;
1555 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1559 ND_PRINT((ndo
, " %s",
1560 CAPABILITY_ESS(pbody
.capability_info
) ? "ESS" : "IBSS"));
1561 PRINT_DS_CHANNEL(pbody
);
1567 handle_assoc_request(netdissect_options
*ndo
,
1568 const u_char
*p
, u_int length
)
1570 struct mgmt_body_t pbody
;
1574 memset(&pbody
, 0, sizeof(pbody
));
1576 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
))
1578 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
)
1580 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1581 offset
+= IEEE802_11_CAPINFO_LEN
;
1582 length
-= IEEE802_11_CAPINFO_LEN
;
1583 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
1584 offset
+= IEEE802_11_LISTENINT_LEN
;
1585 length
-= IEEE802_11_LISTENINT_LEN
;
1587 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1595 handle_assoc_response(netdissect_options
*ndo
,
1596 const u_char
*p
, u_int length
)
1598 struct mgmt_body_t pbody
;
1602 memset(&pbody
, 0, sizeof(pbody
));
1604 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
1605 IEEE802_11_AID_LEN
))
1607 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
1610 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1611 offset
+= IEEE802_11_CAPINFO_LEN
;
1612 length
-= IEEE802_11_CAPINFO_LEN
;
1613 pbody
.status_code
= EXTRACT_LE_16BITS(p
+offset
);
1614 offset
+= IEEE802_11_STATUS_LEN
;
1615 length
-= IEEE802_11_STATUS_LEN
;
1616 pbody
.aid
= EXTRACT_LE_16BITS(p
+offset
);
1617 offset
+= IEEE802_11_AID_LEN
;
1618 length
-= IEEE802_11_AID_LEN
;
1620 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1622 ND_PRINT((ndo
, " AID(%x) :%s: %s", ((uint16_t)(pbody
.aid
<< 2 )) >> 2 ,
1623 CAPABILITY_PRIVACY(pbody
.capability_info
) ? " PRIVACY " : "",
1624 (pbody
.status_code
< NUM_STATUSES
1625 ? status_text
[pbody
.status_code
]
1632 handle_reassoc_request(netdissect_options
*ndo
,
1633 const u_char
*p
, u_int length
)
1635 struct mgmt_body_t pbody
;
1639 memset(&pbody
, 0, sizeof(pbody
));
1641 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
1644 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
1647 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1648 offset
+= IEEE802_11_CAPINFO_LEN
;
1649 length
-= IEEE802_11_CAPINFO_LEN
;
1650 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
1651 offset
+= IEEE802_11_LISTENINT_LEN
;
1652 length
-= IEEE802_11_LISTENINT_LEN
;
1653 memcpy(&pbody
.ap
, p
+offset
, IEEE802_11_AP_LEN
);
1654 offset
+= IEEE802_11_AP_LEN
;
1655 length
-= IEEE802_11_AP_LEN
;
1657 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1660 ND_PRINT((ndo
, " AP : %s", etheraddr_string(ndo
, pbody
.ap
)));
1666 handle_reassoc_response(netdissect_options
*ndo
,
1667 const u_char
*p
, u_int length
)
1669 /* Same as a Association Reponse */
1670 return handle_assoc_response(ndo
, p
, length
);
1674 handle_probe_request(netdissect_options
*ndo
,
1675 const u_char
*p
, u_int length
)
1677 struct mgmt_body_t pbody
;
1681 memset(&pbody
, 0, sizeof(pbody
));
1683 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1692 handle_probe_response(netdissect_options
*ndo
,
1693 const u_char
*p
, u_int length
)
1695 struct mgmt_body_t pbody
;
1699 memset(&pbody
, 0, sizeof(pbody
));
1701 if (!ND_TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1702 IEEE802_11_CAPINFO_LEN
))
1704 if (length
< IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1705 IEEE802_11_CAPINFO_LEN
)
1707 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
1708 offset
+= IEEE802_11_TSTAMP_LEN
;
1709 length
-= IEEE802_11_TSTAMP_LEN
;
1710 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
1711 offset
+= IEEE802_11_BCNINT_LEN
;
1712 length
-= IEEE802_11_BCNINT_LEN
;
1713 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
1714 offset
+= IEEE802_11_CAPINFO_LEN
;
1715 length
-= IEEE802_11_CAPINFO_LEN
;
1717 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1721 PRINT_DS_CHANNEL(pbody
);
1729 /* the frame body for ATIM is null. */
1734 handle_disassoc(netdissect_options
*ndo
,
1735 const u_char
*p
, u_int length
)
1737 struct mgmt_body_t pbody
;
1739 memset(&pbody
, 0, sizeof(pbody
));
1741 if (!ND_TTEST2(*p
, IEEE802_11_REASON_LEN
))
1743 if (length
< IEEE802_11_REASON_LEN
)
1745 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
1747 ND_PRINT((ndo
, ": %s",
1748 (pbody
.reason_code
< NUM_REASONS
)
1749 ? reason_text
[pbody
.reason_code
]
1756 handle_auth(netdissect_options
*ndo
,
1757 const u_char
*p
, u_int length
)
1759 struct mgmt_body_t pbody
;
1763 memset(&pbody
, 0, sizeof(pbody
));
1765 if (!ND_TTEST2(*p
, 6))
1769 pbody
.auth_alg
= EXTRACT_LE_16BITS(p
);
1772 pbody
.auth_trans_seq_num
= EXTRACT_LE_16BITS(p
+ offset
);
1775 pbody
.status_code
= EXTRACT_LE_16BITS(p
+ offset
);
1779 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1781 if ((pbody
.auth_alg
== 1) &&
1782 ((pbody
.auth_trans_seq_num
== 2) ||
1783 (pbody
.auth_trans_seq_num
== 3))) {
1784 ND_PRINT((ndo
, " (%s)-%x [Challenge Text] %s",
1785 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
1786 ? auth_alg_text
[pbody
.auth_alg
]
1788 pbody
.auth_trans_seq_num
,
1789 ((pbody
.auth_trans_seq_num
% 2)
1790 ? ((pbody
.status_code
< NUM_STATUSES
)
1791 ? status_text
[pbody
.status_code
]
1795 ND_PRINT((ndo
, " (%s)-%x: %s",
1796 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
1797 ? auth_alg_text
[pbody
.auth_alg
]
1799 pbody
.auth_trans_seq_num
,
1800 (pbody
.auth_trans_seq_num
% 2)
1801 ? ((pbody
.status_code
< NUM_STATUSES
)
1802 ? status_text
[pbody
.status_code
]
1810 handle_deauth(netdissect_options
*ndo
,
1811 const uint8_t *src
, const u_char
*p
, u_int length
)
1813 struct mgmt_body_t pbody
;
1814 const char *reason
= NULL
;
1816 memset(&pbody
, 0, sizeof(pbody
));
1818 if (!ND_TTEST2(*p
, IEEE802_11_REASON_LEN
))
1820 if (length
< IEEE802_11_REASON_LEN
)
1822 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
1824 reason
= (pbody
.reason_code
< NUM_REASONS
)
1825 ? reason_text
[pbody
.reason_code
]
1828 if (ndo
->ndo_eflag
) {
1829 ND_PRINT((ndo
, ": %s", reason
));
1831 ND_PRINT((ndo
, " (%s): %s", etheraddr_string(ndo
, src
), reason
));
1836 #define PRINT_HT_ACTION(v) (\
1837 (v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \
1838 (v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \
1839 ND_PRINT((ndo, "Act#%d", (v))) \
1841 #define PRINT_BA_ACTION(v) (\
1842 (v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \
1843 (v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \
1844 (v) == 2 ? ND_PRINT((ndo, "DELBA")) : \
1845 ND_PRINT((ndo, "Act#%d", (v))) \
1847 #define PRINT_MESHLINK_ACTION(v) (\
1848 (v) == 0 ? ND_PRINT((ndo, "Request")) : \
1849 (v) == 1 ? ND_PRINT((ndo, "Report")) : \
1850 ND_PRINT((ndo, "Act#%d", (v))) \
1852 #define PRINT_MESHPEERING_ACTION(v) (\
1853 (v) == 0 ? ND_PRINT((ndo, "Open")) : \
1854 (v) == 1 ? ND_PRINT((ndo, "Confirm")) : \
1855 (v) == 2 ? ND_PRINT((ndo, "Close")) : \
1856 ND_PRINT((ndo, "Act#%d", (v))) \
1858 #define PRINT_MESHPATH_ACTION(v) (\
1859 (v) == 0 ? ND_PRINT((ndo, "Request")) : \
1860 (v) == 1 ? ND_PRINT((ndo, "Report")) : \
1861 (v) == 2 ? ND_PRINT((ndo, "Error")) : \
1862 (v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \
1863 ND_PRINT((ndo, "Act#%d", (v))) \
1866 #define PRINT_MESH_ACTION(v) (\
1867 (v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \
1868 (v) == 1 ? ND_PRINT((ndo, "HWMP")) : \
1869 (v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \
1870 (v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \
1871 (v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \
1872 (v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \
1873 (v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \
1874 (v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \
1875 (v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \
1876 (v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \
1877 (v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \
1878 ND_PRINT((ndo, "Act#%d", (v))) \
1880 #define PRINT_MULTIHOP_ACTION(v) (\
1881 (v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \
1882 (v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \
1883 ND_PRINT((ndo, "Act#%d", (v))) \
1885 #define PRINT_SELFPROT_ACTION(v) (\
1886 (v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \
1887 (v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \
1888 (v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \
1889 (v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \
1890 (v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \
1891 ND_PRINT((ndo, "Act#%d", (v))) \
1895 handle_action(netdissect_options
*ndo
,
1896 const uint8_t *src
, const u_char
*p
, u_int length
)
1898 if (!ND_TTEST2(*p
, 2))
1902 if (ndo
->ndo_eflag
) {
1903 ND_PRINT((ndo
, ": "));
1905 ND_PRINT((ndo
, " (%s): ", etheraddr_string(ndo
, src
)));
1908 case 0: ND_PRINT((ndo
, "Spectrum Management Act#%d", p
[1])); break;
1909 case 1: ND_PRINT((ndo
, "QoS Act#%d", p
[1])); break;
1910 case 2: ND_PRINT((ndo
, "DLS Act#%d", p
[1])); break;
1911 case 3: ND_PRINT((ndo
, "BA ")); PRINT_BA_ACTION(p
[1]); break;
1912 case 7: ND_PRINT((ndo
, "HT ")); PRINT_HT_ACTION(p
[1]); break;
1913 case 13: ND_PRINT((ndo
, "MeshAction ")); PRINT_MESH_ACTION(p
[1]); break;
1915 ND_PRINT((ndo
, "MultiohopAction "));
1916 PRINT_MULTIHOP_ACTION(p
[1]); break;
1918 ND_PRINT((ndo
, "SelfprotectAction "));
1919 PRINT_SELFPROT_ACTION(p
[1]); break;
1920 case 127: ND_PRINT((ndo
, "Vendor Act#%d", p
[1])); break;
1922 ND_PRINT((ndo
, "Reserved(%d) Act#%d", p
[0], p
[1]));
1929 /*********************************************************************************
1931 *********************************************************************************/
1935 mgmt_body_print(netdissect_options
*ndo
,
1936 uint16_t fc
, const uint8_t *src
, const u_char
*p
, u_int length
)
1938 ND_PRINT((ndo
, "%s", tok2str(st_str
, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc
))));
1940 /* There may be a problem w/ AP not having this bit set */
1941 if (FC_PROTECTED(fc
))
1942 return wep_print(ndo
, p
);
1943 switch (FC_SUBTYPE(fc
)) {
1944 case ST_ASSOC_REQUEST
:
1945 return handle_assoc_request(ndo
, p
, length
);
1946 case ST_ASSOC_RESPONSE
:
1947 return handle_assoc_response(ndo
, p
, length
);
1948 case ST_REASSOC_REQUEST
:
1949 return handle_reassoc_request(ndo
, p
, length
);
1950 case ST_REASSOC_RESPONSE
:
1951 return handle_reassoc_response(ndo
, p
, length
);
1952 case ST_PROBE_REQUEST
:
1953 return handle_probe_request(ndo
, p
, length
);
1954 case ST_PROBE_RESPONSE
:
1955 return handle_probe_response(ndo
, p
, length
);
1957 return handle_beacon(ndo
, p
, length
);
1959 return handle_atim();
1961 return handle_disassoc(ndo
, p
, length
);
1963 return handle_auth(ndo
, p
, length
);
1965 return handle_deauth(ndo
, src
, p
, length
);
1967 return handle_action(ndo
, src
, p
, length
);
1974 /*********************************************************************************
1975 * Handles printing all the control frame types
1976 *********************************************************************************/
1979 ctrl_body_print(netdissect_options
*ndo
,
1980 uint16_t fc
, const u_char
*p
)
1982 ND_PRINT((ndo
, "%s", tok2str(ctrl_str
, "Unknown Ctrl Subtype", FC_SUBTYPE(fc
))));
1983 switch (FC_SUBTYPE(fc
)) {
1984 case CTRL_CONTROL_WRAPPER
:
1985 /* XXX - requires special handling */
1988 if (!ND_TTEST2(*p
, CTRL_BAR_HDRLEN
))
1990 if (!ndo
->ndo_eflag
)
1991 ND_PRINT((ndo
, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
1992 etheraddr_string(ndo
, ((const struct ctrl_bar_hdr_t
*)p
)->ra
),
1993 etheraddr_string(ndo
, ((const struct ctrl_bar_hdr_t
*)p
)->ta
),
1994 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t
*)p
)->ctl
)),
1995 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t
*)p
)->seq
))));
1998 if (!ND_TTEST2(*p
, CTRL_BA_HDRLEN
))
2000 if (!ndo
->ndo_eflag
)
2001 ND_PRINT((ndo
, " RA:%s ",
2002 etheraddr_string(ndo
, ((const struct ctrl_ba_hdr_t
*)p
)->ra
)));
2005 if (!ND_TTEST2(*p
, CTRL_PS_POLL_HDRLEN
))
2007 ND_PRINT((ndo
, " AID(%x)",
2008 EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_hdr_t
*)p
)->aid
))));
2011 if (!ND_TTEST2(*p
, CTRL_RTS_HDRLEN
))
2013 if (!ndo
->ndo_eflag
)
2014 ND_PRINT((ndo
, " TA:%s ",
2015 etheraddr_string(ndo
, ((const struct ctrl_rts_hdr_t
*)p
)->ta
)));
2018 if (!ND_TTEST2(*p
, CTRL_CTS_HDRLEN
))
2020 if (!ndo
->ndo_eflag
)
2021 ND_PRINT((ndo
, " RA:%s ",
2022 etheraddr_string(ndo
, ((const struct ctrl_cts_hdr_t
*)p
)->ra
)));
2025 if (!ND_TTEST2(*p
, CTRL_ACK_HDRLEN
))
2027 if (!ndo
->ndo_eflag
)
2028 ND_PRINT((ndo
, " RA:%s ",
2029 etheraddr_string(ndo
, ((const struct ctrl_ack_hdr_t
*)p
)->ra
)));
2032 if (!ND_TTEST2(*p
, CTRL_END_HDRLEN
))
2034 if (!ndo
->ndo_eflag
)
2035 ND_PRINT((ndo
, " RA:%s ",
2036 etheraddr_string(ndo
, ((const struct ctrl_end_hdr_t
*)p
)->ra
)));
2039 if (!ND_TTEST2(*p
, CTRL_END_ACK_HDRLEN
))
2041 if (!ndo
->ndo_eflag
)
2042 ND_PRINT((ndo
, " RA:%s ",
2043 etheraddr_string(ndo
, ((const struct ctrl_end_ack_hdr_t
*)p
)->ra
)));
2050 * Data Frame - Address field contents
2052 * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
2053 * 0 | 0 | DA | SA | BSSID | n/a
2054 * 0 | 1 | DA | BSSID | SA | n/a
2055 * 1 | 0 | BSSID | SA | DA | n/a
2056 * 1 | 1 | RA | TA | DA | SA
2060 * Function to get source and destination MAC addresses for a data frame.
2063 get_data_src_dst_mac(uint16_t fc
, const u_char
*p
, const uint8_t **srcp
,
2064 const uint8_t **dstp
)
2066 #define ADDR1 (p + 4)
2067 #define ADDR2 (p + 10)
2068 #define ADDR3 (p + 16)
2069 #define ADDR4 (p + 24)
2071 if (!FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2074 } else if (!FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2077 } else if (FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2080 } else if (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2092 get_mgmt_src_dst_mac(const u_char
*p
, const uint8_t **srcp
, const uint8_t **dstp
)
2094 const struct mgmt_header_t
*hp
= (const struct mgmt_header_t
*) p
;
2103 * Print Header funcs
2107 data_header_print(netdissect_options
*ndo
, uint16_t fc
, const u_char
*p
)
2109 u_int subtype
= FC_SUBTYPE(fc
);
2111 if (DATA_FRAME_IS_CF_ACK(subtype
) || DATA_FRAME_IS_CF_POLL(subtype
) ||
2112 DATA_FRAME_IS_QOS(subtype
)) {
2113 ND_PRINT((ndo
, "CF "));
2114 if (DATA_FRAME_IS_CF_ACK(subtype
)) {
2115 if (DATA_FRAME_IS_CF_POLL(subtype
))
2116 ND_PRINT((ndo
, "Ack/Poll"));
2118 ND_PRINT((ndo
, "Ack"));
2120 if (DATA_FRAME_IS_CF_POLL(subtype
))
2121 ND_PRINT((ndo
, "Poll"));
2123 if (DATA_FRAME_IS_QOS(subtype
))
2124 ND_PRINT((ndo
, "+QoS"));
2125 ND_PRINT((ndo
, " "));
2128 #define ADDR1 (p + 4)
2129 #define ADDR2 (p + 10)
2130 #define ADDR3 (p + 16)
2131 #define ADDR4 (p + 24)
2133 if (!FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2134 ND_PRINT((ndo
, "DA:%s SA:%s BSSID:%s ",
2135 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2136 etheraddr_string(ndo
, ADDR3
)));
2137 } else if (!FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2138 ND_PRINT((ndo
, "DA:%s BSSID:%s SA:%s ",
2139 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2140 etheraddr_string(ndo
, ADDR3
)));
2141 } else if (FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2142 ND_PRINT((ndo
, "BSSID:%s SA:%s DA:%s ",
2143 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2144 etheraddr_string(ndo
, ADDR3
)));
2145 } else if (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2146 ND_PRINT((ndo
, "RA:%s TA:%s DA:%s SA:%s ",
2147 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2148 etheraddr_string(ndo
, ADDR3
), etheraddr_string(ndo
, ADDR4
)));
2158 mgmt_header_print(netdissect_options
*ndo
, const u_char
*p
)
2160 const struct mgmt_header_t
*hp
= (const struct mgmt_header_t
*) p
;
2162 ND_PRINT((ndo
, "BSSID:%s DA:%s SA:%s ",
2163 etheraddr_string(ndo
, (hp
)->bssid
), etheraddr_string(ndo
, (hp
)->da
),
2164 etheraddr_string(ndo
, (hp
)->sa
)));
2168 ctrl_header_print(netdissect_options
*ndo
, uint16_t fc
, const u_char
*p
)
2170 switch (FC_SUBTYPE(fc
)) {
2172 ND_PRINT((ndo
, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
2173 etheraddr_string(ndo
, ((const struct ctrl_bar_hdr_t
*)p
)->ra
),
2174 etheraddr_string(ndo
, ((const struct ctrl_bar_hdr_t
*)p
)->ta
),
2175 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t
*)p
)->ctl
)),
2176 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t
*)p
)->seq
))));
2179 ND_PRINT((ndo
, "RA:%s ",
2180 etheraddr_string(ndo
, ((const struct ctrl_ba_hdr_t
*)p
)->ra
)));
2183 ND_PRINT((ndo
, "BSSID:%s TA:%s ",
2184 etheraddr_string(ndo
, ((const struct ctrl_ps_poll_hdr_t
*)p
)->bssid
),
2185 etheraddr_string(ndo
, ((const struct ctrl_ps_poll_hdr_t
*)p
)->ta
)));
2188 ND_PRINT((ndo
, "RA:%s TA:%s ",
2189 etheraddr_string(ndo
, ((const struct ctrl_rts_hdr_t
*)p
)->ra
),
2190 etheraddr_string(ndo
, ((const struct ctrl_rts_hdr_t
*)p
)->ta
)));
2193 ND_PRINT((ndo
, "RA:%s ",
2194 etheraddr_string(ndo
, ((const struct ctrl_cts_hdr_t
*)p
)->ra
)));
2197 ND_PRINT((ndo
, "RA:%s ",
2198 etheraddr_string(ndo
, ((const struct ctrl_ack_hdr_t
*)p
)->ra
)));
2201 ND_PRINT((ndo
, "RA:%s BSSID:%s ",
2202 etheraddr_string(ndo
, ((const struct ctrl_end_hdr_t
*)p
)->ra
),
2203 etheraddr_string(ndo
, ((const struct ctrl_end_hdr_t
*)p
)->bssid
)));
2206 ND_PRINT((ndo
, "RA:%s BSSID:%s ",
2207 etheraddr_string(ndo
, ((const struct ctrl_end_ack_hdr_t
*)p
)->ra
),
2208 etheraddr_string(ndo
, ((const struct ctrl_end_ack_hdr_t
*)p
)->bssid
)));
2211 /* We shouldn't get here - we should already have quit */
2217 extract_header_length(netdissect_options
*ndo
,
2222 switch (FC_TYPE(fc
)) {
2226 switch (FC_SUBTYPE(fc
)) {
2227 case CTRL_CONTROL_WRAPPER
:
2228 return CTRL_CONTROL_WRAPPER_HDRLEN
;
2230 return CTRL_BAR_HDRLEN
;
2232 return CTRL_BA_HDRLEN
;
2234 return CTRL_PS_POLL_HDRLEN
;
2236 return CTRL_RTS_HDRLEN
;
2238 return CTRL_CTS_HDRLEN
;
2240 return CTRL_ACK_HDRLEN
;
2242 return CTRL_END_HDRLEN
;
2244 return CTRL_END_ACK_HDRLEN
;
2246 ND_PRINT((ndo
, "unknown 802.11 ctrl frame subtype (%d)", FC_SUBTYPE(fc
)));
2250 len
= (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) ? 30 : 24;
2251 if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
)))
2255 ND_PRINT((ndo
, "unknown 802.11 frame type (%d)", FC_TYPE(fc
)));
2261 extract_mesh_header_length(const u_char
*p
)
2263 return (p
[0] &~ 3) ? 0 : 6*(1 + (p
[0] & 3));
2267 * Print the 802.11 MAC header.
2270 ieee_802_11_hdr_print(netdissect_options
*ndo
,
2271 uint16_t fc
, const u_char
*p
, u_int hdrlen
,
2274 if (ndo
->ndo_vflag
) {
2275 if (FC_MORE_DATA(fc
))
2276 ND_PRINT((ndo
, "More Data "));
2277 if (FC_MORE_FLAG(fc
))
2278 ND_PRINT((ndo
, "More Fragments "));
2279 if (FC_POWER_MGMT(fc
))
2280 ND_PRINT((ndo
, "Pwr Mgmt "));
2282 ND_PRINT((ndo
, "Retry "));
2284 ND_PRINT((ndo
, "Strictly Ordered "));
2285 if (FC_PROTECTED(fc
))
2286 ND_PRINT((ndo
, "Protected "));
2287 if (FC_TYPE(fc
) != T_CTRL
|| FC_SUBTYPE(fc
) != CTRL_PS_POLL
)
2288 ND_PRINT((ndo
, "%dus ",
2290 &((const struct mgmt_header_t
*)p
)->duration
)));
2292 if (meshdrlen
!= 0) {
2293 const struct meshcntl_t
*mc
=
2294 (const struct meshcntl_t
*)&p
[hdrlen
- meshdrlen
];
2295 int ae
= mc
->flags
& 3;
2297 ND_PRINT((ndo
, "MeshData (AE %d TTL %u seq %u", ae
, mc
->ttl
,
2298 EXTRACT_LE_32BITS(mc
->seq
)));
2300 ND_PRINT((ndo
, " A4:%s", etheraddr_string(ndo
, mc
->addr4
)));
2302 ND_PRINT((ndo
, " A5:%s", etheraddr_string(ndo
, mc
->addr5
)));
2304 ND_PRINT((ndo
, " A6:%s", etheraddr_string(ndo
, mc
->addr6
)));
2305 ND_PRINT((ndo
, ") "));
2308 switch (FC_TYPE(fc
)) {
2310 mgmt_header_print(ndo
, p
);
2313 ctrl_header_print(ndo
, fc
, p
);
2316 data_header_print(ndo
, fc
, p
);
2324 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
2328 ieee802_11_print(netdissect_options
*ndo
,
2329 const u_char
*p
, u_int length
, u_int orig_caplen
, int pad
,
2333 u_int caplen
, hdrlen
, meshdrlen
;
2334 const uint8_t *src
, *dst
;
2337 caplen
= orig_caplen
;
2338 /* Remove FCS, if present */
2339 if (length
< fcslen
) {
2340 ND_PRINT((ndo
, "%s", tstr
));
2344 if (caplen
> length
) {
2345 /* Amount of FCS in actual packet data, if any */
2346 fcslen
= caplen
- length
;
2348 ndo
->ndo_snapend
-= fcslen
;
2351 if (caplen
< IEEE802_11_FC_LEN
) {
2352 ND_PRINT((ndo
, "%s", tstr
));
2356 fc
= EXTRACT_LE_16BITS(p
);
2357 hdrlen
= extract_header_length(ndo
, fc
);
2359 /* Unknown frame type or control frame subtype; quit. */
2363 hdrlen
= roundup2(hdrlen
, 4);
2364 if (ndo
->ndo_Hflag
&& FC_TYPE(fc
) == T_DATA
&&
2365 DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
))) {
2366 meshdrlen
= extract_mesh_header_length(p
+hdrlen
);
2367 hdrlen
+= meshdrlen
;
2371 if (caplen
< hdrlen
) {
2372 ND_PRINT((ndo
, "%s", tstr
));
2377 ieee_802_11_hdr_print(ndo
, fc
, p
, hdrlen
, meshdrlen
);
2380 * Go past the 802.11 header.
2386 switch (FC_TYPE(fc
)) {
2388 get_mgmt_src_dst_mac(p
- hdrlen
, &src
, &dst
);
2389 if (!mgmt_body_print(ndo
, fc
, src
, p
, length
)) {
2390 ND_PRINT((ndo
, "%s", tstr
));
2395 if (!ctrl_body_print(ndo
, fc
, p
- hdrlen
)) {
2396 ND_PRINT((ndo
, "%s", tstr
));
2401 if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc
)))
2402 return hdrlen
; /* no-data frame */
2403 /* There may be a problem w/ AP not having this bit set */
2404 if (FC_PROTECTED(fc
)) {
2405 ND_PRINT((ndo
, "Data"));
2406 if (!wep_print(ndo
, p
)) {
2407 ND_PRINT((ndo
, "%s", tstr
));
2411 get_data_src_dst_mac(fc
, p
- hdrlen
, &src
, &dst
);
2412 llc_hdrlen
= llc_print(ndo
, p
, length
, caplen
, dst
, src
);
2413 if (llc_hdrlen
< 0) {
2415 * Some kinds of LLC packet we cannot
2416 * handle intelligently
2418 if (!ndo
->ndo_suppress_default_print
)
2419 ND_DEFAULTPRINT(p
, caplen
);
2420 llc_hdrlen
= -llc_hdrlen
;
2422 hdrlen
+= llc_hdrlen
;
2426 /* We shouldn't get here - we should already have quit */
2434 * This is the top level routine of the printer. 'p' points
2435 * to the 802.11 header of the packet, 'h->ts' is the timestamp,
2436 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
2437 * is the number of bytes actually captured.
2440 ieee802_11_if_print(netdissect_options
*ndo
,
2441 const struct pcap_pkthdr
*h
, const u_char
*p
)
2443 return ieee802_11_print(ndo
, p
, h
->len
, h
->caplen
, 0, 0);
2446 #define IEEE80211_CHAN_FHSS \
2447 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
2448 #define IEEE80211_CHAN_A \
2449 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
2450 #define IEEE80211_CHAN_B \
2451 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
2452 #define IEEE80211_CHAN_PUREG \
2453 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
2454 #define IEEE80211_CHAN_G \
2455 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
2457 #define IS_CHAN_FHSS(flags) \
2458 ((flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
2459 #define IS_CHAN_A(flags) \
2460 ((flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
2461 #define IS_CHAN_B(flags) \
2462 ((flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
2463 #define IS_CHAN_PUREG(flags) \
2464 ((flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
2465 #define IS_CHAN_G(flags) \
2466 ((flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
2467 #define IS_CHAN_ANYG(flags) \
2468 (IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
2471 print_chaninfo(netdissect_options
*ndo
,
2472 int freq
, int flags
)
2474 ND_PRINT((ndo
, "%u MHz", freq
));
2475 if (IS_CHAN_FHSS(flags
))
2476 ND_PRINT((ndo
, " FHSS"));
2477 if (IS_CHAN_A(flags
)) {
2478 if (flags
& IEEE80211_CHAN_HALF
)
2479 ND_PRINT((ndo
, " 11a/10Mhz"));
2480 else if (flags
& IEEE80211_CHAN_QUARTER
)
2481 ND_PRINT((ndo
, " 11a/5Mhz"));
2483 ND_PRINT((ndo
, " 11a"));
2485 if (IS_CHAN_ANYG(flags
)) {
2486 if (flags
& IEEE80211_CHAN_HALF
)
2487 ND_PRINT((ndo
, " 11g/10Mhz"));
2488 else if (flags
& IEEE80211_CHAN_QUARTER
)
2489 ND_PRINT((ndo
, " 11g/5Mhz"));
2491 ND_PRINT((ndo
, " 11g"));
2492 } else if (IS_CHAN_B(flags
))
2493 ND_PRINT((ndo
, " 11b"));
2494 if (flags
& IEEE80211_CHAN_TURBO
)
2495 ND_PRINT((ndo
, " Turbo"));
2496 if (flags
& IEEE80211_CHAN_HT20
)
2497 ND_PRINT((ndo
, " ht/20"));
2498 else if (flags
& IEEE80211_CHAN_HT40D
)
2499 ND_PRINT((ndo
, " ht/40-"));
2500 else if (flags
& IEEE80211_CHAN_HT40U
)
2501 ND_PRINT((ndo
, " ht/40+"));
2502 ND_PRINT((ndo
, " "));
2506 print_radiotap_field(netdissect_options
*ndo
,
2507 struct cpack_state
*s
, uint32_t bit
, uint8_t *flags
,
2508 struct radiotap_state
*state
, uint32_t presentflags
)
2521 case IEEE80211_RADIOTAP_FLAGS
:
2522 rc
= cpack_uint8(s
, &u
.u8
);
2527 case IEEE80211_RADIOTAP_RATE
:
2528 rc
= cpack_uint8(s
, &u
.u8
);
2532 /* Save state rate */
2535 case IEEE80211_RADIOTAP_DB_ANTSIGNAL
:
2536 case IEEE80211_RADIOTAP_DB_ANTNOISE
:
2537 case IEEE80211_RADIOTAP_ANTENNA
:
2538 rc
= cpack_uint8(s
, &u
.u8
);
2540 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL
:
2541 case IEEE80211_RADIOTAP_DBM_ANTNOISE
:
2542 rc
= cpack_int8(s
, &u
.i8
);
2544 case IEEE80211_RADIOTAP_CHANNEL
:
2545 rc
= cpack_uint16(s
, &u
.u16
);
2548 rc
= cpack_uint16(s
, &u2
.u16
);
2550 case IEEE80211_RADIOTAP_FHSS
:
2551 case IEEE80211_RADIOTAP_LOCK_QUALITY
:
2552 case IEEE80211_RADIOTAP_TX_ATTENUATION
:
2553 case IEEE80211_RADIOTAP_RX_FLAGS
:
2554 rc
= cpack_uint16(s
, &u
.u16
);
2556 case IEEE80211_RADIOTAP_DB_TX_ATTENUATION
:
2557 rc
= cpack_uint8(s
, &u
.u8
);
2559 case IEEE80211_RADIOTAP_DBM_TX_POWER
:
2560 rc
= cpack_int8(s
, &u
.i8
);
2562 case IEEE80211_RADIOTAP_TSFT
:
2563 rc
= cpack_uint64(s
, &u
.u64
);
2565 case IEEE80211_RADIOTAP_XCHANNEL
:
2566 rc
= cpack_uint32(s
, &u
.u32
);
2569 rc
= cpack_uint16(s
, &u2
.u16
);
2572 rc
= cpack_uint8(s
, &u3
.u8
);
2575 rc
= cpack_uint8(s
, &u4
.u8
);
2577 case IEEE80211_RADIOTAP_MCS
:
2578 rc
= cpack_uint8(s
, &u
.u8
);
2581 rc
= cpack_uint8(s
, &u2
.u8
);
2584 rc
= cpack_uint8(s
, &u3
.u8
);
2586 case IEEE80211_RADIOTAP_VENDOR_NAMESPACE
: {
2591 if ((cpack_align_and_reserve(s
, 2)) == NULL
) {
2596 rc
= cpack_uint8(s
, &vns
[0]);
2599 rc
= cpack_uint8(s
, &vns
[1]);
2602 rc
= cpack_uint8(s
, &vns
[2]);
2605 rc
= cpack_uint8(s
, &subspace
);
2608 rc
= cpack_uint16(s
, &length
);
2612 /* Skip up to length */
2613 s
->c_next
+= length
;
2617 /* this bit indicates a field whose
2618 * size we do not know, so we cannot
2619 * proceed. Just print the bit number.
2621 ND_PRINT((ndo
, "[bit %u] ", bit
));
2626 ND_PRINT((ndo
, "%s", tstr
));
2630 /* Preserve the state present flags */
2631 state
->present
= presentflags
;
2634 case IEEE80211_RADIOTAP_CHANNEL
:
2636 * If CHANNEL and XCHANNEL are both present, skip
2639 if (presentflags
& (1 << IEEE80211_RADIOTAP_XCHANNEL
))
2641 print_chaninfo(ndo
, u
.u16
, u2
.u16
);
2643 case IEEE80211_RADIOTAP_FHSS
:
2644 ND_PRINT((ndo
, "fhset %d fhpat %d ", u
.u16
& 0xff, (u
.u16
>> 8) & 0xff));
2646 case IEEE80211_RADIOTAP_RATE
:
2648 * XXX On FreeBSD rate & 0x80 means we have an MCS. On
2649 * Linux and AirPcap it does not. (What about
2650 * Mac OS X, NetBSD, OpenBSD, and DragonFly BSD?)
2652 * This is an issue either for proprietary extensions
2653 * to 11a or 11g, which do exist, or for 11n
2654 * implementations that stuff a rate value into
2655 * this field, which also appear to exist.
2657 * We currently handle that by assuming that
2658 * if the 0x80 bit is set *and* the remaining
2659 * bits have a value between 0 and 15 it's
2660 * an MCS value, otherwise it's a rate. If
2661 * there are cases where systems that use
2662 * "0x80 + MCS index" for MCS indices > 15,
2663 * or stuff a rate value here between 64 and
2664 * 71.5 Mb/s in here, we'll need a preference
2665 * setting. Such rates do exist, e.g. 11n
2666 * MCS 7 at 20 MHz with a long guard interval.
2668 if (u
.u8
>= 0x80 && u
.u8
<= 0x8f) {
2670 * XXX - we don't know the channel width
2671 * or guard interval length, so we can't
2672 * convert this to a data rate.
2674 * If you want us to show a data rate,
2675 * use the MCS field, not the Rate field;
2676 * the MCS field includes not only the
2677 * MCS index, it also includes bandwidth
2678 * and guard interval information.
2680 * XXX - can we get the channel width
2681 * from XChannel and the guard interval
2682 * information from Flags, at least on
2685 ND_PRINT((ndo
, "MCS %u ", u
.u8
& 0x7f));
2687 ND_PRINT((ndo
, "%2.1f Mb/s ", .5 * u
.u8
));
2689 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL
:
2690 ND_PRINT((ndo
, "%ddB signal ", u
.i8
));
2692 case IEEE80211_RADIOTAP_DBM_ANTNOISE
:
2693 ND_PRINT((ndo
, "%ddB noise ", u
.i8
));
2695 case IEEE80211_RADIOTAP_DB_ANTSIGNAL
:
2696 ND_PRINT((ndo
, "%ddB signal ", u
.u8
));
2698 case IEEE80211_RADIOTAP_DB_ANTNOISE
:
2699 ND_PRINT((ndo
, "%ddB noise ", u
.u8
));
2701 case IEEE80211_RADIOTAP_LOCK_QUALITY
:
2702 ND_PRINT((ndo
, "%u sq ", u
.u16
));
2704 case IEEE80211_RADIOTAP_TX_ATTENUATION
:
2705 ND_PRINT((ndo
, "%d tx power ", -(int)u
.u16
));
2707 case IEEE80211_RADIOTAP_DB_TX_ATTENUATION
:
2708 ND_PRINT((ndo
, "%ddB tx power ", -(int)u
.u8
));
2710 case IEEE80211_RADIOTAP_DBM_TX_POWER
:
2711 ND_PRINT((ndo
, "%ddBm tx power ", u
.i8
));
2713 case IEEE80211_RADIOTAP_FLAGS
:
2714 if (u
.u8
& IEEE80211_RADIOTAP_F_CFP
)
2715 ND_PRINT((ndo
, "cfp "));
2716 if (u
.u8
& IEEE80211_RADIOTAP_F_SHORTPRE
)
2717 ND_PRINT((ndo
, "short preamble "));
2718 if (u
.u8
& IEEE80211_RADIOTAP_F_WEP
)
2719 ND_PRINT((ndo
, "wep "));
2720 if (u
.u8
& IEEE80211_RADIOTAP_F_FRAG
)
2721 ND_PRINT((ndo
, "fragmented "));
2722 if (u
.u8
& IEEE80211_RADIOTAP_F_BADFCS
)
2723 ND_PRINT((ndo
, "bad-fcs "));
2725 case IEEE80211_RADIOTAP_ANTENNA
:
2726 ND_PRINT((ndo
, "antenna %d ", u
.u8
));
2728 case IEEE80211_RADIOTAP_TSFT
:
2729 ND_PRINT((ndo
, "%" PRIu64
"us tsft ", u
.u64
));
2731 case IEEE80211_RADIOTAP_RX_FLAGS
:
2732 /* Do nothing for now */
2734 case IEEE80211_RADIOTAP_XCHANNEL
:
2735 print_chaninfo(ndo
, u2
.u16
, u
.u32
);
2737 case IEEE80211_RADIOTAP_MCS
: {
2738 static const char *bandwidth
[4] = {
2746 if (u
.u8
& IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN
) {
2748 * We know the MCS index.
2750 if (u3
.u8
<= MAX_MCS_INDEX
) {
2752 * And it's in-range.
2754 if (u
.u8
& (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN
|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN
)) {
2756 * And we know both the bandwidth and
2757 * the guard interval, so we can look
2761 ieee80211_float_htrates \
2763 [((u2
.u8
& IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK
) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40
? 1 : 0)] \
2764 [((u2
.u8
& IEEE80211_RADIOTAP_MCS_SHORT_GI
) ? 1 : 0)];
2767 * We don't know both the bandwidth
2768 * and the guard interval, so we can
2769 * only report the MCS index.
2775 * The MCS value is out of range.
2779 if (htrate
!= 0.0) {
2784 ND_PRINT((ndo
, "%.1f Mb/s MCS %u ", htrate
, u3
.u8
));
2787 * We at least have the MCS index.
2790 ND_PRINT((ndo
, "MCS %u ", u3
.u8
));
2793 if (u
.u8
& IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN
) {
2794 ND_PRINT((ndo
, "%s ",
2795 bandwidth
[u2
.u8
& IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK
]));
2797 if (u
.u8
& IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN
) {
2798 ND_PRINT((ndo
, "%s GI ",
2799 (u2
.u8
& IEEE80211_RADIOTAP_MCS_SHORT_GI
) ?
2802 if (u
.u8
& IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN
) {
2803 ND_PRINT((ndo
, "%s ",
2804 (u2
.u8
& IEEE80211_RADIOTAP_MCS_HT_GREENFIELD
) ?
2805 "greenfield" : "mixed"));
2807 if (u
.u8
& IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN
) {
2808 ND_PRINT((ndo
, "%s FEC ",
2809 (u2
.u8
& IEEE80211_RADIOTAP_MCS_FEC_LDPC
) ?
2812 if (u
.u8
& IEEE80211_RADIOTAP_MCS_STBC_KNOWN
) {
2813 ND_PRINT((ndo
, "RX-STBC%u ",
2814 (u2
.u8
& IEEE80211_RADIOTAP_MCS_STBC_MASK
) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT
));
2824 ieee802_11_radio_print(netdissect_options
*ndo
,
2825 const u_char
*p
, u_int length
, u_int caplen
)
2827 #define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
2828 #define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
2829 #define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
2830 #define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
2831 #define BITNO_2(x) (((x) & 2) ? 1 : 0)
2832 #define BIT(n) (1U << n)
2833 #define IS_EXTENDED(__p) \
2834 (EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
2836 struct cpack_state cpacker
;
2837 struct ieee80211_radiotap_header
*hdr
;
2838 uint32_t present
, next_present
;
2839 uint32_t presentflags
= 0;
2840 uint32_t *presentp
, *last_presentp
;
2841 enum ieee80211_radiotap_type bit
;
2847 struct radiotap_state state
;
2849 if (caplen
< sizeof(*hdr
)) {
2850 ND_PRINT((ndo
, "%s", tstr
));
2854 hdr
= (struct ieee80211_radiotap_header
*)p
;
2856 len
= EXTRACT_LE_16BITS(&hdr
->it_len
);
2859 ND_PRINT((ndo
, "%s", tstr
));
2862 cpack_init(&cpacker
, (uint8_t *)hdr
, len
); /* align against header start */
2863 cpack_advance(&cpacker
, sizeof(*hdr
)); /* includes the 1st bitmap */
2864 for (last_presentp
= &hdr
->it_present
;
2865 IS_EXTENDED(last_presentp
) &&
2866 (u_char
*)(last_presentp
+ 1) <= p
+ len
;
2868 cpack_advance(&cpacker
, sizeof(hdr
->it_present
)); /* more bitmaps */
2870 /* are there more bitmap extensions than bytes in header? */
2871 if (IS_EXTENDED(last_presentp
)) {
2872 ND_PRINT((ndo
, "%s", tstr
));
2876 /* Assume no flags */
2878 /* Assume no Atheros padding between 802.11 header and body */
2880 /* Assume no FCS at end of frame */
2882 for (bit0
= 0, presentp
= &hdr
->it_present
; presentp
<= last_presentp
;
2883 presentp
++, bit0
+= 32) {
2884 presentflags
= EXTRACT_LE_32BITS(presentp
);
2887 memset(&state
, 0, sizeof(state
));
2889 for (present
= EXTRACT_LE_32BITS(presentp
); present
;
2890 present
= next_present
) {
2891 /* clear the least significant bit that is set */
2892 next_present
= present
& (present
- 1);
2894 /* extract the least significant bit that is set */
2895 bit
= (enum ieee80211_radiotap_type
)
2896 (bit0
+ BITNO_32(present
^ next_present
));
2898 if (print_radiotap_field(ndo
, &cpacker
, bit
, &flags
, &state
, presentflags
) != 0)
2904 if (flags
& IEEE80211_RADIOTAP_F_DATAPAD
)
2905 pad
= 1; /* Atheros padding */
2906 if (flags
& IEEE80211_RADIOTAP_F_FCS
)
2907 fcslen
= 4; /* FCS at end of packet */
2908 return len
+ ieee802_11_print(ndo
, p
+ len
, length
- len
, caplen
- len
, pad
,
2919 ieee802_11_avs_radio_print(netdissect_options
*ndo
,
2920 const u_char
*p
, u_int length
, u_int caplen
)
2922 uint32_t caphdr_len
;
2925 ND_PRINT((ndo
, "%s", tstr
));
2929 caphdr_len
= EXTRACT_32BITS(p
+ 4);
2930 if (caphdr_len
< 8) {
2932 * Yow! The capture header length is claimed not
2933 * to be large enough to include even the version
2934 * cookie or capture header length!
2936 ND_PRINT((ndo
, "%s", tstr
));
2940 if (caplen
< caphdr_len
) {
2941 ND_PRINT((ndo
, "%s", tstr
));
2945 return caphdr_len
+ ieee802_11_print(ndo
, p
+ caphdr_len
,
2946 length
- caphdr_len
, caplen
- caphdr_len
, 0, 0);
2949 #define PRISM_HDR_LEN 144
2951 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000
2952 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001
2953 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002
2956 * For DLT_PRISM_HEADER; like DLT_IEEE802_11, but with an extra header,
2957 * containing information such as radio information, which we
2960 * If, however, the packet begins with WLANCAP_MAGIC_COOKIE_V1 or
2961 * WLANCAP_MAGIC_COOKIE_V2, it's really DLT_IEEE802_11_RADIO_AVS
2962 * (currently, on Linux, there's no ARPHRD_ type for
2963 * DLT_IEEE802_11_RADIO_AVS, as there is a ARPHRD_IEEE80211_PRISM
2964 * for DLT_PRISM_HEADER, so ARPHRD_IEEE80211_PRISM is used for
2965 * the AVS header, and the first 4 bytes of the header are used to
2966 * indicate whether it's a Prism header or an AVS header).
2969 prism_if_print(netdissect_options
*ndo
,
2970 const struct pcap_pkthdr
*h
, const u_char
*p
)
2972 u_int caplen
= h
->caplen
;
2973 u_int length
= h
->len
;
2977 ND_PRINT((ndo
, "%s", tstr
));
2981 msgcode
= EXTRACT_32BITS(p
);
2982 if (msgcode
== WLANCAP_MAGIC_COOKIE_V1
||
2983 msgcode
== WLANCAP_MAGIC_COOKIE_V2
)
2984 return ieee802_11_avs_radio_print(ndo
, p
, length
, caplen
);
2986 if (caplen
< PRISM_HDR_LEN
) {
2987 ND_PRINT((ndo
, "%s", tstr
));
2991 return PRISM_HDR_LEN
+ ieee802_11_print(ndo
, p
+ PRISM_HDR_LEN
,
2992 length
- PRISM_HDR_LEN
, caplen
- PRISM_HDR_LEN
, 0, 0);
2996 * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra
2997 * header, containing information such as radio information.
3000 ieee802_11_radio_if_print(netdissect_options
*ndo
,
3001 const struct pcap_pkthdr
*h
, const u_char
*p
)
3003 return ieee802_11_radio_print(ndo
, p
, h
->len
, h
->caplen
);
3007 * For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an
3008 * extra header, containing information such as radio information,
3009 * which we currently ignore.
3012 ieee802_11_radio_avs_if_print(netdissect_options
*ndo
,
3013 const struct pcap_pkthdr
*h
, const u_char
*p
)
3015 return ieee802_11_avs_radio_print(ndo
, p
, h
->len
, h
->caplen
);