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.
23 #define NETDISSECT_REWORKED
28 #include <tcpdump-stdinc.h>
32 #include "interface.h"
33 #include "addrtoname.h"
40 /* Lengths of 802.11 header components. */
41 #define IEEE802_11_FC_LEN 2
42 #define IEEE802_11_DUR_LEN 2
43 #define IEEE802_11_DA_LEN 6
44 #define IEEE802_11_SA_LEN 6
45 #define IEEE802_11_BSSID_LEN 6
46 #define IEEE802_11_RA_LEN 6
47 #define IEEE802_11_TA_LEN 6
48 #define IEEE802_11_SEQ_LEN 2
49 #define IEEE802_11_CTL_LEN 2
50 #define IEEE802_11_IV_LEN 3
51 #define IEEE802_11_KID_LEN 1
53 /* Frame check sequence length. */
54 #define IEEE802_11_FCS_LEN 4
56 /* Lengths of beacon components. */
57 #define IEEE802_11_TSTAMP_LEN 8
58 #define IEEE802_11_BCNINT_LEN 2
59 #define IEEE802_11_CAPINFO_LEN 2
60 #define IEEE802_11_LISTENINT_LEN 2
62 #define IEEE802_11_AID_LEN 2
63 #define IEEE802_11_STATUS_LEN 2
64 #define IEEE802_11_REASON_LEN 2
66 /* Length of previous AP in reassocation frame */
67 #define IEEE802_11_AP_LEN 6
69 #define T_MGMT 0x0 /* management */
70 #define T_CTRL 0x1 /* control */
71 #define T_DATA 0x2 /* data */
72 #define T_RESV 0x3 /* reserved */
74 #define ST_ASSOC_REQUEST 0x0
75 #define ST_ASSOC_RESPONSE 0x1
76 #define ST_REASSOC_REQUEST 0x2
77 #define ST_REASSOC_RESPONSE 0x3
78 #define ST_PROBE_REQUEST 0x4
79 #define ST_PROBE_RESPONSE 0x5
84 #define ST_DISASSOC 0xA
91 static const struct tok st_str
[] = {
92 { ST_ASSOC_REQUEST
, "Assoc Request" },
93 { ST_ASSOC_RESPONSE
, "Assoc Response" },
94 { ST_REASSOC_REQUEST
, "ReAssoc Request" },
95 { ST_REASSOC_RESPONSE
, "ReAssoc Response" },
96 { ST_PROBE_REQUEST
, "Probe Request" },
97 { ST_PROBE_RESPONSE
, "Probe Response" },
98 { ST_BEACON
, "Beacon" },
100 { ST_DISASSOC
, "Disassociation" },
101 { ST_AUTH
, "Authentication" },
102 { ST_DEAUTH
, "DeAuthentication" },
103 { ST_ACTION
, "Action" },
107 #define CTRL_CONTROL_WRAPPER 0x7
110 #define CTRL_PS_POLL 0xA
114 #define CTRL_CF_END 0xE
115 #define CTRL_END_ACK 0xF
117 static const struct tok ctrl_str
[] = {
118 { CTRL_CONTROL_WRAPPER
, "Control Wrapper" },
121 { CTRL_PS_POLL
, "Power Save-Poll" },
122 { CTRL_RTS
, "Request-To-Send" },
123 { CTRL_CTS
, "Clear-To-Send" },
124 { CTRL_ACK
, "Acknowledgment" },
125 { CTRL_CF_END
, "CF-End" },
126 { CTRL_END_ACK
, "CF-End+CF-Ack" },
130 #define DATA_DATA 0x0
131 #define DATA_DATA_CF_ACK 0x1
132 #define DATA_DATA_CF_POLL 0x2
133 #define DATA_DATA_CF_ACK_POLL 0x3
134 #define DATA_NODATA 0x4
135 #define DATA_NODATA_CF_ACK 0x5
136 #define DATA_NODATA_CF_POLL 0x6
137 #define DATA_NODATA_CF_ACK_POLL 0x7
139 #define DATA_QOS_DATA 0x8
140 #define DATA_QOS_DATA_CF_ACK 0x9
141 #define DATA_QOS_DATA_CF_POLL 0xA
142 #define DATA_QOS_DATA_CF_ACK_POLL 0xB
143 #define DATA_QOS_NODATA 0xC
144 #define DATA_QOS_CF_POLL_NODATA 0xE
145 #define DATA_QOS_CF_ACK_POLL_NODATA 0xF
148 * The subtype field of a data frame is, in effect, composed of 4 flag
149 * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
150 * any data), and QoS.
152 #define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
153 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
154 #define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
155 #define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
158 * Bits in the frame control field.
160 #define FC_VERSION(fc) ((fc) & 0x3)
161 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
162 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
163 #define FC_TO_DS(fc) ((fc) & 0x0100)
164 #define FC_FROM_DS(fc) ((fc) & 0x0200)
165 #define FC_MORE_FLAG(fc) ((fc) & 0x0400)
166 #define FC_RETRY(fc) ((fc) & 0x0800)
167 #define FC_POWER_MGMT(fc) ((fc) & 0x1000)
168 #define FC_MORE_DATA(fc) ((fc) & 0x2000)
169 #define FC_WEP(fc) ((fc) & 0x4000)
170 #define FC_ORDER(fc) ((fc) & 0x8000)
172 struct mgmt_header_t
{
181 #define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
182 IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
183 IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
185 #define CAPABILITY_ESS(cap) ((cap) & 0x0001)
186 #define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
187 #define CAPABILITY_CFP(cap) ((cap) & 0x0004)
188 #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
189 #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
194 u_char ssid
[33]; /* 32 + 1 for null */
206 uint8_t text
[254]; /* 1-253 + 1 for null */
229 uint16_t max_duration
;
230 uint16_t dur_remaing
;
238 uint8_t bitmap_control
;
260 #define E_CHALLENGE 16
269 uint8_t timestamp
[IEEE802_11_TSTAMP_LEN
];
270 uint16_t beacon_interval
;
271 uint16_t listen_interval
;
272 uint16_t status_code
;
274 u_char ap
[IEEE802_11_AP_LEN
];
275 uint16_t reason_code
;
277 uint16_t auth_trans_seq_num
;
278 int challenge_present
;
279 struct challenge_t challenge
;
280 uint16_t capability_info
;
284 struct rates_t rates
;
303 #define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
304 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
313 #define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
322 #define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
324 struct ctrl_ps_poll_t
{
332 #define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
333 IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
343 #define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
344 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
346 struct ctrl_end_ack_t
{
354 #define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
355 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
364 #define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
376 #define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
377 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
378 IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
389 #define IV_IV(iv) ((iv) & 0xFFFFFF)
390 #define IV_PAD(iv) (((iv) >> 24) & 0x3F)
391 #define IV_KEYID(iv) (((iv) >> 30) & 0x03)
393 /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
394 /* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
397 * Copyright (c) 2003, 2004 David Young. All rights reserved.
399 * Redistribution and use in source and binary forms, with or without
400 * modification, are permitted provided that the following conditions
402 * 1. Redistributions of source code must retain the above copyright
403 * notice, this list of conditions and the following disclaimer.
404 * 2. Redistributions in binary form must reproduce the above copyright
405 * notice, this list of conditions and the following disclaimer in the
406 * documentation and/or other materials provided with the distribution.
407 * 3. The name of David Young may not be used to endorse or promote
408 * products derived from this software without specific prior
409 * written permission.
411 * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
412 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
413 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
414 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
415 * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
416 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
417 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
418 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
419 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
420 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
421 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
425 /* A generic radio capture format is desirable. It must be
426 * rigidly defined (e.g., units for fields should be given),
427 * and easily extensible.
429 * The following is an extensible radio capture format. It is
430 * based on a bitmap indicating which fields are present.
432 * I am trying to describe precisely what the application programmer
433 * should expect in the following, and for that reason I tell the
434 * units and origin of each measurement (where it applies), or else I
435 * use sufficiently weaselly language ("is a monotonically nondecreasing
436 * function of...") that I cannot set false expectations for lawyerly
441 * The radio capture header precedes the 802.11 header.
443 * Note well: all radiotap fields are little-endian.
445 struct ieee80211_radiotap_header
{
446 uint8_t it_version
; /* Version 0. Only increases
447 * for drastic changes,
448 * introduction of compatible
449 * new fields does not count.
452 uint16_t it_len
; /* length of the whole
453 * header in bytes, including
454 * it_version, it_pad,
455 * it_len, and data fields.
457 uint32_t it_present
; /* A bitmap telling which
458 * fields are present. Set bit 31
459 * (0x80000000) to extend the
460 * bitmap by another 32 bits.
461 * Additional extensions are made
466 /* Name Data type Units
467 * ---- --------- -----
469 * IEEE80211_RADIOTAP_TSFT uint64_t microseconds
471 * Value in microseconds of the MAC's 64-bit 802.11 Time
472 * Synchronization Function timer when the first bit of the
473 * MPDU arrived at the MAC. For received frames, only.
475 * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
477 * Tx/Rx frequency in MHz, followed by flags (see below).
478 * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
479 * represent an HT channel as there is not enough room in
482 * IEEE80211_RADIOTAP_FHSS uint16_t see below
484 * For frequency-hopping radios, the hop set (first byte)
485 * and pattern (second byte).
487 * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index
489 * Tx/Rx data rate. If bit 0x80 is set then it represents an
490 * an MCS index and not an IEEE rate.
492 * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
493 * one milliwatt (dBm)
495 * RF signal power at the antenna, decibel difference from
498 * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
499 * one milliwatt (dBm)
501 * RF noise power at the antenna, decibel difference from one
504 * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
506 * RF signal power at the antenna, decibel difference from an
507 * arbitrary, fixed reference.
509 * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
511 * RF noise power at the antenna, decibel difference from an
512 * arbitrary, fixed reference point.
514 * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
516 * Quality of Barker code lock. Unitless. Monotonically
517 * nondecreasing with "better" lock strength. Called "Signal
518 * Quality" in datasheets. (Is there a standard way to measure
521 * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
523 * Transmit power expressed as unitless distance from max
524 * power set at factory calibration. 0 is max power.
525 * Monotonically nondecreasing with lower power levels.
527 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
529 * Transmit power expressed as decibel distance from max power
530 * set at factory calibration. 0 is max power. Monotonically
531 * nondecreasing with lower power levels.
533 * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
534 * one milliwatt (dBm)
536 * Transmit power expressed as dBm (decibels from a 1 milliwatt
537 * reference). This is the absolute power level measured at
540 * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap
542 * Properties of transmitted and received frames. See flags
545 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
547 * Unitless indication of the Rx/Tx antenna for this packet.
548 * The first antenna is antenna 0.
550 * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
552 * Properties of received frames. See flags defined below.
554 * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap
556 * uint8_t channel number
559 * Extended channel specification: flags (see below) followed by
560 * frequency in MHz, the corresponding IEEE channel number, and
561 * finally the maximum regulatory transmit power cap in .5 dBm
562 * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
563 * and only one of the two should be present.
565 * IEEE80211_RADIOTAP_MCS uint8_t known
569 * Bitset indicating which fields have known values, followed
570 * by bitset of flag values, followed by the MCS rate index as
573 * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
578 * The Vendor Namespace Field contains three sub-fields. The first
579 * sub-field is 3 bytes long. It contains the vendor's IEEE 802
580 * Organizationally Unique Identifier (OUI). The fourth byte is a
581 * vendor-specific "namespace selector."
584 enum ieee80211_radiotap_type
{
585 IEEE80211_RADIOTAP_TSFT
= 0,
586 IEEE80211_RADIOTAP_FLAGS
= 1,
587 IEEE80211_RADIOTAP_RATE
= 2,
588 IEEE80211_RADIOTAP_CHANNEL
= 3,
589 IEEE80211_RADIOTAP_FHSS
= 4,
590 IEEE80211_RADIOTAP_DBM_ANTSIGNAL
= 5,
591 IEEE80211_RADIOTAP_DBM_ANTNOISE
= 6,
592 IEEE80211_RADIOTAP_LOCK_QUALITY
= 7,
593 IEEE80211_RADIOTAP_TX_ATTENUATION
= 8,
594 IEEE80211_RADIOTAP_DB_TX_ATTENUATION
= 9,
595 IEEE80211_RADIOTAP_DBM_TX_POWER
= 10,
596 IEEE80211_RADIOTAP_ANTENNA
= 11,
597 IEEE80211_RADIOTAP_DB_ANTSIGNAL
= 12,
598 IEEE80211_RADIOTAP_DB_ANTNOISE
= 13,
599 IEEE80211_RADIOTAP_RX_FLAGS
= 14,
600 /* NB: gap for netbsd definitions */
601 IEEE80211_RADIOTAP_XCHANNEL
= 18,
602 IEEE80211_RADIOTAP_MCS
= 19,
603 IEEE80211_RADIOTAP_NAMESPACE
= 29,
604 IEEE80211_RADIOTAP_VENDOR_NAMESPACE
= 30,
605 IEEE80211_RADIOTAP_EXT
= 31
608 /* channel attributes */
609 #define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
610 #define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
611 #define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
612 #define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
613 #define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
614 #define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
615 #define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
616 #define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
617 #define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
618 #define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
619 #define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
620 #define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
621 #define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
622 #define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
623 #define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
625 /* Useful combinations of channel characteristics, borrowed from Ethereal */
626 #define IEEE80211_CHAN_A \
627 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
628 #define IEEE80211_CHAN_B \
629 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
630 #define IEEE80211_CHAN_G \
631 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
632 #define IEEE80211_CHAN_TA \
633 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
634 #define IEEE80211_CHAN_TG \
635 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
638 /* For IEEE80211_RADIOTAP_FLAGS */
639 #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
642 #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
646 #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
647 * with WEP encryption
649 #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
652 #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
653 #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
654 * 802.11 header and payload
655 * (to 32-bit boundary)
657 #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
659 /* For IEEE80211_RADIOTAP_RX_FLAGS */
660 #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
661 #define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
663 /* For IEEE80211_RADIOTAP_MCS known */
664 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
665 #define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
666 #define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
667 #define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
668 #define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
669 #define IEEE80211_RADIOTAP_MCS_STBC_KNOWN 0x20
671 /* For IEEE80211_RADIOTAP_MCS flags */
672 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
673 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
674 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
675 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
676 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
677 #define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
678 #define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
679 #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
680 #define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60
681 #define IEEE80211_RADIOTAP_MCS_STBC_1 1
682 #define IEEE80211_RADIOTAP_MCS_STBC_2 2
683 #define IEEE80211_RADIOTAP_MCS_STBC_3 3
684 #define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5
686 static const char tstr
[] = "[|802.11]";
689 /* This is used to save state when parsing/processing parameters */
690 struct radiotap_state
697 #define PRINT_SSID(p) \
698 if (p.ssid_present) { \
699 ND_PRINT((ndo, " (")); \
700 fn_print(ndo, p.ssid.ssid, NULL); \
701 ND_PRINT((ndo, ")")); \
704 #define PRINT_RATE(_sep, _r, _suf) \
705 ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf))
706 #define PRINT_RATES(p) \
707 if (p.rates_present) { \
709 const char *sep = " ["; \
710 for (z = 0; z < p.rates.length ; z++) { \
711 PRINT_RATE(sep, p.rates.rate[z], \
712 (p.rates.rate[z] & 0x80 ? "*" : "")); \
715 if (p.rates.length != 0) \
716 ND_PRINT((ndo, " Mbit]")); \
719 #define PRINT_DS_CHANNEL(p) \
721 ND_PRINT((ndo, " CH: %u", p.ds.channel)); \
722 ND_PRINT((ndo, "%s", \
723 CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : ""));
725 #define MAX_MCS_INDEX 76
730 * the MCS index (0-76);
732 * 0 for 20 MHz, 1 for 40 MHz;
734 * 0 for a long guard interval, 1 for a short guard interval.
736 static const float ieee80211_float_htrates
[MAX_MCS_INDEX
+1][2][2] = {
738 { /* 20 Mhz */ { 6.5, /* SGI */ 7.2, },
739 /* 40 Mhz */ { 13.5, /* SGI */ 15.0, },
743 { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
744 /* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
748 { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
749 /* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
753 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
754 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
758 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
759 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
763 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
764 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
768 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
769 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
773 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
774 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
778 { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
779 /* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
783 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
784 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
788 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
789 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
793 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
794 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
798 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
799 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
803 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
804 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
808 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
809 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
813 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
814 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
818 { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
819 /* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
823 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
824 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
828 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
829 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
833 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
834 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
838 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
839 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
843 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
844 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
848 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
849 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
853 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
854 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
858 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
859 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
863 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
864 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
868 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
869 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
873 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
874 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
878 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
879 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
883 { /* 20 Mhz */ { 208.0, /* SGI */ 231.1, },
884 /* 40 Mhz */ { 432.0, /* SGI */ 480.0, },
888 { /* 20 Mhz */ { 234.0, /* SGI */ 260.0, },
889 /* 40 Mhz */ { 486.0, /* SGI */ 540.0, },
893 { /* 20 Mhz */ { 260.0, /* SGI */ 288.9, },
894 /* 40 Mhz */ { 540.0, /* SGI */ 600.0, },
898 { /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */
899 /* 40 Mhz */ { 6.0, /* SGI */ 6.7, },
903 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
904 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
908 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
909 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
913 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
914 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
918 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
919 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
923 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
924 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
928 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
929 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
933 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
934 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
938 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
939 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
943 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
944 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
948 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
949 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
953 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
954 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
958 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
959 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
963 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
964 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
968 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
969 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
973 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
974 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
978 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
979 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
983 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
984 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
988 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
989 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
993 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
994 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
998 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
999 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1003 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
1004 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
1008 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
1009 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
1013 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
1014 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
1018 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
1019 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
1023 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
1024 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
1028 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
1029 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
1033 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1034 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1038 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
1039 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
1043 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1044 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1048 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
1049 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
1053 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
1054 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
1058 { /* 20 Mhz */ { 143.0, /* SGI */ 158.9, },
1059 /* 40 Mhz */ { 297.0, /* SGI */ 330.0, },
1063 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
1064 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
1068 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1069 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1073 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1074 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1078 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1079 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1083 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1084 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1088 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1089 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1093 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
1094 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
1098 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1099 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1103 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
1104 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
1108 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
1109 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
1113 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
1114 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
1118 { /* 20 Mhz */ { 214.5, /* SGI */ 238.3, },
1119 /* 40 Mhz */ { 445.5, /* SGI */ 495.0, },
1123 static const char *auth_alg_text
[]={"Open System","Shared Key","EAP"};
1124 #define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
1126 static const char *status_text
[] = {
1127 "Successful", /* 0 */
1128 "Unspecified failure", /* 1 */
1137 "Cannot Support all requested capabilities in the Capability "
1138 "Information field", /* 10 */
1139 "Reassociation denied due to inability to confirm that association "
1141 "Association denied due to reason outside the scope of the "
1142 "standard", /* 12 */
1143 "Responding station does not support the specified authentication "
1144 "algorithm ", /* 13 */
1145 "Received an Authentication frame with authentication transaction "
1146 "sequence number out of expected sequence", /* 14 */
1147 "Authentication rejected because of challenge failure", /* 15 */
1148 "Authentication rejected due to timeout waiting for next frame in "
1149 "sequence", /* 16 */
1150 "Association denied because AP is unable to handle additional"
1151 "associated stations", /* 17 */
1152 "Association denied due to requesting station not supporting all of "
1153 "the data rates in BSSBasicRateSet parameter", /* 18 */
1154 "Association denied due to requesting station not supporting "
1155 "short preamble operation", /* 19 */
1156 "Association denied due to requesting station not supporting "
1157 "PBCC encoding", /* 20 */
1158 "Association denied due to requesting station not supporting "
1159 "channel agility", /* 21 */
1160 "Association request rejected because Spectrum Management "
1161 "capability is required", /* 22 */
1162 "Association request rejected because the information in the "
1163 "Power Capability element is unacceptable", /* 23 */
1164 "Association request rejected because the information in the "
1165 "Supported Channels element is unacceptable", /* 24 */
1166 "Association denied due to requesting station not supporting "
1167 "short slot operation", /* 25 */
1168 "Association denied due to requesting station not supporting "
1169 "DSSS-OFDM operation", /* 26 */
1170 "Association denied because the requested STA does not support HT "
1171 "features", /* 27 */
1172 "Reserved", /* 28 */
1173 "Association denied because the requested STA does not support "
1174 "the PCO transition time required by the AP", /* 29 */
1175 "Reserved", /* 30 */
1176 "Reserved", /* 31 */
1177 "Unspecified, QoS-related failure", /* 32 */
1178 "Association denied due to QAP having insufficient bandwidth "
1179 "to handle another QSTA", /* 33 */
1180 "Association denied due to excessive frame loss rates and/or "
1181 "poor conditions on current operating channel", /* 34 */
1182 "Association (with QBSS) denied due to requesting station not "
1183 "supporting the QoS facility", /* 35 */
1184 "Association denied due to requesting station not supporting "
1185 "Block Ack", /* 36 */
1186 "The request has been declined", /* 37 */
1187 "The request has not been successful as one or more parameters "
1188 "have invalid values", /* 38 */
1189 "The TS has not been created because the request cannot be honored. "
1190 "However, a suggested TSPEC is provided so that the initiating QSTA"
1191 "may attempt to set another TS with the suggested changes to the "
1193 "Invalid Information Element", /* 40 */
1194 "Group Cipher is not valid", /* 41 */
1195 "Pairwise Cipher is not valid", /* 42 */
1196 "AKMP is not valid", /* 43 */
1197 "Unsupported RSN IE version", /* 44 */
1198 "Invalid RSN IE Capabilities", /* 45 */
1199 "Cipher suite is rejected per security policy", /* 46 */
1200 "The TS has not been created. However, the HC may be capable of "
1201 "creating a TS, in response to a request, after the time indicated "
1202 "in the TS Delay element", /* 47 */
1203 "Direct Link is not allowed in the BSS by policy", /* 48 */
1204 "Destination STA is not present within this QBSS.", /* 49 */
1205 "The Destination STA is not a QSTA.", /* 50 */
1208 #define NUM_STATUSES (sizeof status_text / sizeof status_text[0])
1210 static const char *reason_text
[] = {
1212 "Unspecified reason", /* 1 */
1213 "Previous authentication no longer valid", /* 2 */
1214 "Deauthenticated because sending station is leaving (or has left) "
1215 "IBSS or ESS", /* 3 */
1216 "Disassociated due to inactivity", /* 4 */
1217 "Disassociated because AP is unable to handle all currently "
1218 " associated stations", /* 5 */
1219 "Class 2 frame received from nonauthenticated station", /* 6 */
1220 "Class 3 frame received from nonassociated station", /* 7 */
1221 "Disassociated because sending station is leaving "
1222 "(or has left) BSS", /* 8 */
1223 "Station requesting (re)association is not authenticated with "
1224 "responding station", /* 9 */
1225 "Disassociated because the information in the Power Capability "
1226 "element is unacceptable", /* 10 */
1227 "Disassociated because the information in the SupportedChannels "
1228 "element is unacceptable", /* 11 */
1229 "Invalid Information Element", /* 12 */
1230 "Reserved", /* 13 */
1231 "Michael MIC failure", /* 14 */
1232 "4-Way Handshake timeout", /* 15 */
1233 "Group key update timeout", /* 16 */
1234 "Information element in 4-Way Handshake different from (Re)Association"
1235 "Request/Probe Response/Beacon", /* 17 */
1236 "Group Cipher is not valid", /* 18 */
1237 "AKMP is not valid", /* 20 */
1238 "Unsupported RSN IE version", /* 21 */
1239 "Invalid RSN IE Capabilities", /* 22 */
1240 "IEEE 802.1X Authentication failed", /* 23 */
1241 "Cipher suite is rejected per security policy", /* 24 */
1242 "Reserved", /* 25 */
1243 "Reserved", /* 26 */
1244 "Reserved", /* 27 */
1245 "Reserved", /* 28 */
1246 "Reserved", /* 29 */
1247 "Reserved", /* 30 */
1248 "TS deleted because QoS AP lacks sufficient bandwidth for this "
1249 "QoS STA due to a change in BSS service characteristics or "
1250 "operational mode (e.g. an HT BSS change from 40 MHz channel "
1251 "to 20 MHz channel)", /* 31 */
1252 "Disassociated for unspecified, QoS-related reason", /* 32 */
1253 "Disassociated because QoS AP lacks sufficient bandwidth for this "
1255 "Disassociated because of excessive number of frames that need to be "
1256 "acknowledged, but are not acknowledged for AP transmissions "
1257 "and/or poor channel conditions", /* 34 */
1258 "Disassociated because STA is transmitting outside the limits "
1259 "of its TXOPs", /* 35 */
1260 "Requested from peer STA as the STA is leaving the BSS "
1261 "(or resetting)", /* 36 */
1262 "Requested from peer STA as it does not want to use the "
1263 "mechanism", /* 37 */
1264 "Requested from peer STA as the STA received frames using the "
1265 "mechanism for which a set up is required", /* 38 */
1266 "Requested from peer STA due to time out", /* 39 */
1267 "Reserved", /* 40 */
1268 "Reserved", /* 41 */
1269 "Reserved", /* 42 */
1270 "Reserved", /* 43 */
1271 "Reserved", /* 44 */
1272 "Peer STA does not support the requested cipher suite", /* 45 */
1273 "Association denied due to requesting STA not supporting HT "
1274 "features", /* 46 */
1276 #define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
1279 wep_print(netdissect_options
*ndo
,
1284 if (!ND_TTEST2(*p
, IEEE802_11_IV_LEN
+ IEEE802_11_KID_LEN
))
1286 iv
= EXTRACT_LE_32BITS(p
);
1288 ND_PRINT((ndo
, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv
), IV_PAD(iv
),
1295 parse_elements(netdissect_options
*ndo
,
1296 struct mgmt_body_t
*pbody
, const u_char
*p
, int offset
,
1301 struct challenge_t challenge
;
1302 struct rates_t rates
;
1308 * We haven't seen any elements yet.
1310 pbody
->challenge_present
= 0;
1311 pbody
->ssid_present
= 0;
1312 pbody
->rates_present
= 0;
1313 pbody
->ds_present
= 0;
1314 pbody
->cf_present
= 0;
1315 pbody
->tim_present
= 0;
1317 while (length
!= 0) {
1318 /* Make sure we at least have the element ID and length. */
1319 if (!ND_TTEST2(*(p
+ offset
), 2))
1323 elementlen
= *(p
+ offset
+ 1);
1325 /* Make sure we have the entire element. */
1326 if (!ND_TTEST2(*(p
+ offset
+ 2), elementlen
))
1328 if (length
< elementlen
+ 2)
1331 switch (*(p
+ offset
)) {
1333 memcpy(&ssid
, p
+ offset
, 2);
1336 if (ssid
.length
!= 0) {
1337 if (ssid
.length
> sizeof(ssid
.ssid
) - 1)
1339 if (!ND_TTEST2(*(p
+ offset
), ssid
.length
))
1341 if (length
< ssid
.length
)
1343 memcpy(&ssid
.ssid
, p
+ offset
, ssid
.length
);
1344 offset
+= ssid
.length
;
1345 length
-= ssid
.length
;
1347 ssid
.ssid
[ssid
.length
] = '\0';
1349 * Present and not truncated.
1351 * If we haven't already seen an SSID IE,
1352 * copy this one, otherwise ignore this one,
1353 * so we later report the first one we saw.
1355 if (!pbody
->ssid_present
) {
1357 pbody
->ssid_present
= 1;
1361 memcpy(&challenge
, p
+ offset
, 2);
1364 if (challenge
.length
!= 0) {
1365 if (challenge
.length
>
1366 sizeof(challenge
.text
) - 1)
1368 if (!ND_TTEST2(*(p
+ offset
), challenge
.length
))
1370 if (length
< challenge
.length
)
1372 memcpy(&challenge
.text
, p
+ offset
,
1374 offset
+= challenge
.length
;
1375 length
-= challenge
.length
;
1377 challenge
.text
[challenge
.length
] = '\0';
1379 * Present and not truncated.
1381 * If we haven't already seen a challenge IE,
1382 * copy this one, otherwise ignore this one,
1383 * so we later report the first one we saw.
1385 if (!pbody
->challenge_present
) {
1386 pbody
->challenge
= challenge
;
1387 pbody
->challenge_present
= 1;
1391 memcpy(&rates
, p
+ offset
, 2);
1394 if (rates
.length
!= 0) {
1395 if (rates
.length
> sizeof rates
.rate
)
1397 if (!ND_TTEST2(*(p
+ offset
), rates
.length
))
1399 if (length
< rates
.length
)
1401 memcpy(&rates
.rate
, p
+ offset
, rates
.length
);
1402 offset
+= rates
.length
;
1403 length
-= rates
.length
;
1406 * Present and not truncated.
1408 * If we haven't already seen a rates IE,
1409 * copy this one if it's not zero-length,
1410 * otherwise ignore this one, so we later
1411 * report the first one we saw.
1413 * We ignore zero-length rates IEs as some
1414 * devices seem to put a zero-length rates
1415 * IE, followed by an SSID IE, followed by
1416 * a non-zero-length rates IE into frames,
1417 * even though IEEE Std 802.11-2007 doesn't
1418 * seem to indicate that a zero-length rates
1421 if (!pbody
->rates_present
&& rates
.length
!= 0) {
1422 pbody
->rates
= rates
;
1423 pbody
->rates_present
= 1;
1427 memcpy(&ds
, p
+ offset
, 2);
1430 if (ds
.length
!= 1) {
1431 offset
+= ds
.length
;
1432 length
-= ds
.length
;
1435 ds
.channel
= *(p
+ offset
);
1439 * Present and not truncated.
1441 * If we haven't already seen a DS IE,
1442 * copy this one, otherwise ignore this one,
1443 * so we later report the first one we saw.
1445 if (!pbody
->ds_present
) {
1447 pbody
->ds_present
= 1;
1451 memcpy(&cf
, p
+ offset
, 2);
1454 if (cf
.length
!= 6) {
1455 offset
+= cf
.length
;
1456 length
-= cf
.length
;
1459 memcpy(&cf
.count
, p
+ offset
, 6);
1463 * Present and not truncated.
1465 * If we haven't already seen a CF IE,
1466 * copy this one, otherwise ignore this one,
1467 * so we later report the first one we saw.
1469 if (!pbody
->cf_present
) {
1471 pbody
->cf_present
= 1;
1475 memcpy(&tim
, p
+ offset
, 2);
1478 if (tim
.length
<= 3) {
1479 offset
+= tim
.length
;
1480 length
-= tim
.length
;
1483 if (tim
.length
- 3 > (int)sizeof tim
.bitmap
)
1485 memcpy(&tim
.count
, p
+ offset
, 3);
1489 memcpy(tim
.bitmap
, p
+ (tim
.length
- 3),
1491 offset
+= tim
.length
- 3;
1492 length
-= tim
.length
- 3;
1494 * Present and not truncated.
1496 * If we haven't already seen a TIM IE,
1497 * copy this one, otherwise ignore this one,
1498 * so we later report the first one we saw.
1500 if (!pbody
->tim_present
) {
1502 pbody
->tim_present
= 1;
1507 ND_PRINT((ndo
, "(1) unhandled element_id (%d) ",
1510 offset
+= 2 + elementlen
;
1511 length
-= 2 + elementlen
;
1516 /* No problems found. */
1520 /*********************************************************************************
1521 * Print Handle functions for the management frame types
1522 *********************************************************************************/
1525 handle_beacon(netdissect_options
*ndo
,
1526 const u_char
*p
, u_int length
)
1528 struct mgmt_body_t pbody
;
1532 memset(&pbody
, 0, sizeof(pbody
));
1534 if (!ND_TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1535 IEEE802_11_CAPINFO_LEN
))
1537 if (length
< IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1538 IEEE802_11_CAPINFO_LEN
)
1540 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
1541 offset
+= IEEE802_11_TSTAMP_LEN
;
1542 length
-= IEEE802_11_TSTAMP_LEN
;
1543 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
1544 offset
+= IEEE802_11_BCNINT_LEN
;
1545 length
-= IEEE802_11_BCNINT_LEN
;
1546 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
1547 offset
+= IEEE802_11_CAPINFO_LEN
;
1548 length
-= IEEE802_11_CAPINFO_LEN
;
1550 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1554 ND_PRINT((ndo
, " %s",
1555 CAPABILITY_ESS(pbody
.capability_info
) ? "ESS" : "IBSS"));
1556 PRINT_DS_CHANNEL(pbody
);
1562 handle_assoc_request(netdissect_options
*ndo
,
1563 const u_char
*p
, u_int length
)
1565 struct mgmt_body_t pbody
;
1569 memset(&pbody
, 0, sizeof(pbody
));
1571 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
))
1573 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
)
1575 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1576 offset
+= IEEE802_11_CAPINFO_LEN
;
1577 length
-= IEEE802_11_CAPINFO_LEN
;
1578 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
1579 offset
+= IEEE802_11_LISTENINT_LEN
;
1580 length
-= IEEE802_11_LISTENINT_LEN
;
1582 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1590 handle_assoc_response(netdissect_options
*ndo
,
1591 const u_char
*p
, u_int length
)
1593 struct mgmt_body_t pbody
;
1597 memset(&pbody
, 0, sizeof(pbody
));
1599 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
1600 IEEE802_11_AID_LEN
))
1602 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
1605 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1606 offset
+= IEEE802_11_CAPINFO_LEN
;
1607 length
-= IEEE802_11_CAPINFO_LEN
;
1608 pbody
.status_code
= EXTRACT_LE_16BITS(p
+offset
);
1609 offset
+= IEEE802_11_STATUS_LEN
;
1610 length
-= IEEE802_11_STATUS_LEN
;
1611 pbody
.aid
= EXTRACT_LE_16BITS(p
+offset
);
1612 offset
+= IEEE802_11_AID_LEN
;
1613 length
-= IEEE802_11_AID_LEN
;
1615 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1617 ND_PRINT((ndo
, " AID(%x) :%s: %s", ((uint16_t)(pbody
.aid
<< 2 )) >> 2 ,
1618 CAPABILITY_PRIVACY(pbody
.capability_info
) ? " PRIVACY " : "",
1619 (pbody
.status_code
< NUM_STATUSES
1620 ? status_text
[pbody
.status_code
]
1627 handle_reassoc_request(netdissect_options
*ndo
,
1628 const u_char
*p
, u_int length
)
1630 struct mgmt_body_t pbody
;
1634 memset(&pbody
, 0, sizeof(pbody
));
1636 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
1639 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
1642 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1643 offset
+= IEEE802_11_CAPINFO_LEN
;
1644 length
-= IEEE802_11_CAPINFO_LEN
;
1645 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
1646 offset
+= IEEE802_11_LISTENINT_LEN
;
1647 length
-= IEEE802_11_LISTENINT_LEN
;
1648 memcpy(&pbody
.ap
, p
+offset
, IEEE802_11_AP_LEN
);
1649 offset
+= IEEE802_11_AP_LEN
;
1650 length
-= IEEE802_11_AP_LEN
;
1652 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1655 ND_PRINT((ndo
, " AP : %s", etheraddr_string(ndo
, pbody
.ap
)));
1661 handle_reassoc_response(netdissect_options
*ndo
,
1662 const u_char
*p
, u_int length
)
1664 /* Same as a Association Reponse */
1665 return handle_assoc_response(ndo
, p
, length
);
1669 handle_probe_request(netdissect_options
*ndo
,
1670 const u_char
*p
, u_int length
)
1672 struct mgmt_body_t pbody
;
1676 memset(&pbody
, 0, sizeof(pbody
));
1678 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1687 handle_probe_response(netdissect_options
*ndo
,
1688 const u_char
*p
, u_int length
)
1690 struct mgmt_body_t pbody
;
1694 memset(&pbody
, 0, sizeof(pbody
));
1696 if (!ND_TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1697 IEEE802_11_CAPINFO_LEN
))
1699 if (length
< IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1700 IEEE802_11_CAPINFO_LEN
)
1702 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
1703 offset
+= IEEE802_11_TSTAMP_LEN
;
1704 length
-= IEEE802_11_TSTAMP_LEN
;
1705 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
1706 offset
+= IEEE802_11_BCNINT_LEN
;
1707 length
-= IEEE802_11_BCNINT_LEN
;
1708 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
1709 offset
+= IEEE802_11_CAPINFO_LEN
;
1710 length
-= IEEE802_11_CAPINFO_LEN
;
1712 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1716 PRINT_DS_CHANNEL(pbody
);
1724 /* the frame body for ATIM is null. */
1729 handle_disassoc(netdissect_options
*ndo
,
1730 const u_char
*p
, u_int length
)
1732 struct mgmt_body_t pbody
;
1734 memset(&pbody
, 0, sizeof(pbody
));
1736 if (!ND_TTEST2(*p
, IEEE802_11_REASON_LEN
))
1738 if (length
< IEEE802_11_REASON_LEN
)
1740 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
1742 ND_PRINT((ndo
, ": %s",
1743 (pbody
.reason_code
< NUM_REASONS
)
1744 ? reason_text
[pbody
.reason_code
]
1751 handle_auth(netdissect_options
*ndo
,
1752 const u_char
*p
, u_int length
)
1754 struct mgmt_body_t pbody
;
1758 memset(&pbody
, 0, sizeof(pbody
));
1760 if (!ND_TTEST2(*p
, 6))
1764 pbody
.auth_alg
= EXTRACT_LE_16BITS(p
);
1767 pbody
.auth_trans_seq_num
= EXTRACT_LE_16BITS(p
+ offset
);
1770 pbody
.status_code
= EXTRACT_LE_16BITS(p
+ offset
);
1774 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1776 if ((pbody
.auth_alg
== 1) &&
1777 ((pbody
.auth_trans_seq_num
== 2) ||
1778 (pbody
.auth_trans_seq_num
== 3))) {
1779 ND_PRINT((ndo
, " (%s)-%x [Challenge Text] %s",
1780 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
1781 ? auth_alg_text
[pbody
.auth_alg
]
1783 pbody
.auth_trans_seq_num
,
1784 ((pbody
.auth_trans_seq_num
% 2)
1785 ? ((pbody
.status_code
< NUM_STATUSES
)
1786 ? status_text
[pbody
.status_code
]
1790 ND_PRINT((ndo
, " (%s)-%x: %s",
1791 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
1792 ? auth_alg_text
[pbody
.auth_alg
]
1794 pbody
.auth_trans_seq_num
,
1795 (pbody
.auth_trans_seq_num
% 2)
1796 ? ((pbody
.status_code
< NUM_STATUSES
)
1797 ? status_text
[pbody
.status_code
]
1805 handle_deauth(netdissect_options
*ndo
,
1806 const struct mgmt_header_t
*pmh
, const u_char
*p
, u_int length
)
1808 struct mgmt_body_t pbody
;
1809 const char *reason
= NULL
;
1811 memset(&pbody
, 0, sizeof(pbody
));
1813 if (!ND_TTEST2(*p
, IEEE802_11_REASON_LEN
))
1815 if (length
< IEEE802_11_REASON_LEN
)
1817 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
1819 reason
= (pbody
.reason_code
< NUM_REASONS
)
1820 ? reason_text
[pbody
.reason_code
]
1823 if (ndo
->ndo_eflag
) {
1824 ND_PRINT((ndo
, ": %s", reason
));
1826 ND_PRINT((ndo
, " (%s): %s", etheraddr_string(ndo
, pmh
->sa
), reason
));
1831 #define PRINT_HT_ACTION(v) (\
1832 (v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \
1833 (v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \
1834 ND_PRINT((ndo, "Act#%d", (v))) \
1836 #define PRINT_BA_ACTION(v) (\
1837 (v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \
1838 (v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \
1839 (v) == 2 ? ND_PRINT((ndo, "DELBA")) : \
1840 ND_PRINT((ndo, "Act#%d", (v))) \
1842 #define PRINT_MESHLINK_ACTION(v) (\
1843 (v) == 0 ? ND_PRINT((ndo, "Request")) : \
1844 (v) == 1 ? ND_PRINT((ndo, "Report")) : \
1845 ND_PRINT((ndo, "Act#%d", (v))) \
1847 #define PRINT_MESHPEERING_ACTION(v) (\
1848 (v) == 0 ? ND_PRINT((ndo, "Open")) : \
1849 (v) == 1 ? ND_PRINT((ndo, "Confirm")) : \
1850 (v) == 2 ? ND_PRINT((ndo, "Close")) : \
1851 ND_PRINT((ndo, "Act#%d", (v))) \
1853 #define PRINT_MESHPATH_ACTION(v) (\
1854 (v) == 0 ? ND_PRINT((ndo, "Request")) : \
1855 (v) == 1 ? ND_PRINT((ndo, "Report")) : \
1856 (v) == 2 ? ND_PRINT((ndo, "Error")) : \
1857 (v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \
1858 ND_PRINT((ndo, "Act#%d", (v))) \
1861 #define PRINT_MESH_ACTION(v) (\
1862 (v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \
1863 (v) == 1 ? ND_PRINT((ndo, "HWMP")) : \
1864 (v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \
1865 (v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \
1866 (v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \
1867 (v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \
1868 (v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \
1869 (v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \
1870 (v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \
1871 (v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \
1872 (v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \
1873 ND_PRINT((ndo, "Act#%d", (v))) \
1875 #define PRINT_MULTIHOP_ACTION(v) (\
1876 (v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \
1877 (v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \
1878 ND_PRINT((ndo, "Act#%d", (v))) \
1880 #define PRINT_SELFPROT_ACTION(v) (\
1881 (v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \
1882 (v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \
1883 (v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \
1884 (v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \
1885 (v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \
1886 ND_PRINT((ndo, "Act#%d", (v))) \
1890 handle_action(netdissect_options
*ndo
,
1891 const struct mgmt_header_t
*pmh
, const u_char
*p
, u_int length
)
1893 if (!ND_TTEST2(*p
, 2))
1897 if (ndo
->ndo_eflag
) {
1898 ND_PRINT((ndo
, ": "));
1900 ND_PRINT((ndo
, " (%s): ", etheraddr_string(ndo
, pmh
->sa
)));
1903 case 0: ND_PRINT((ndo
, "Spectrum Management Act#%d", p
[1])); break;
1904 case 1: ND_PRINT((ndo
, "QoS Act#%d", p
[1])); break;
1905 case 2: ND_PRINT((ndo
, "DLS Act#%d", p
[1])); break;
1906 case 3: ND_PRINT((ndo
, "BA ")); PRINT_BA_ACTION(p
[1]); break;
1907 case 7: ND_PRINT((ndo
, "HT ")); PRINT_HT_ACTION(p
[1]); break;
1908 case 13: ND_PRINT((ndo
, "MeshAction ")); PRINT_MESH_ACTION(p
[1]); break;
1910 ND_PRINT((ndo
, "MultiohopAction "));
1911 PRINT_MULTIHOP_ACTION(p
[1]); break;
1913 ND_PRINT((ndo
, "SelfprotectAction "));
1914 PRINT_SELFPROT_ACTION(p
[1]); break;
1915 case 127: ND_PRINT((ndo
, "Vendor Act#%d", p
[1])); break;
1917 ND_PRINT((ndo
, "Reserved(%d) Act#%d", p
[0], p
[1]));
1924 /*********************************************************************************
1926 *********************************************************************************/
1930 mgmt_body_print(netdissect_options
*ndo
,
1931 uint16_t fc
, const struct mgmt_header_t
*pmh
,
1932 const u_char
*p
, u_int length
)
1934 ND_PRINT((ndo
, "%s", tok2str(st_str
, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc
))));
1935 switch (FC_SUBTYPE(fc
)) {
1936 case ST_ASSOC_REQUEST
:
1937 return handle_assoc_request(ndo
, p
, length
);
1938 case ST_ASSOC_RESPONSE
:
1939 return handle_assoc_response(ndo
, p
, length
);
1940 case ST_REASSOC_REQUEST
:
1941 return handle_reassoc_request(ndo
, p
, length
);
1942 case ST_REASSOC_RESPONSE
:
1943 return handle_reassoc_response(ndo
, p
, length
);
1944 case ST_PROBE_REQUEST
:
1945 return handle_probe_request(ndo
, p
, length
);
1946 case ST_PROBE_RESPONSE
:
1947 return handle_probe_response(ndo
, p
, length
);
1949 return handle_beacon(ndo
, p
, length
);
1951 return handle_atim();
1953 return handle_disassoc(ndo
, p
, length
);
1955 if (!ND_TTEST2(*p
, 3))
1957 if ((p
[0] == 0 ) && (p
[1] == 0) && (p
[2] == 0)) {
1958 ND_PRINT((ndo
, "Authentication (Shared-Key)-3 "));
1959 return wep_print(ndo
, p
);
1961 return handle_auth(ndo
, p
, length
);
1963 return handle_deauth(ndo
, pmh
, p
, length
);
1965 return handle_action(ndo
, pmh
, p
, length
);
1972 /*********************************************************************************
1973 * Handles printing all the control frame types
1974 *********************************************************************************/
1977 ctrl_body_print(netdissect_options
*ndo
,
1978 uint16_t fc
, const u_char
*p
)
1980 ND_PRINT((ndo
, "%s", tok2str(ctrl_str
, "Unknown Ctrl Subtype", FC_SUBTYPE(fc
))));
1981 switch (FC_SUBTYPE(fc
)) {
1982 case CTRL_CONTROL_WRAPPER
:
1983 /* XXX - requires special handling */
1986 if (!ND_TTEST2(*p
, CTRL_BAR_HDRLEN
))
1988 if (!ndo
->ndo_eflag
)
1989 ND_PRINT((ndo
, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
1990 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ra
),
1991 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ta
),
1992 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->ctl
)),
1993 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->seq
))));
1996 if (!ND_TTEST2(*p
, CTRL_BA_HDRLEN
))
1998 if (!ndo
->ndo_eflag
)
1999 ND_PRINT((ndo
, " RA:%s ",
2000 etheraddr_string(ndo
, ((const struct ctrl_ba_t
*)p
)->ra
)));
2003 if (!ND_TTEST2(*p
, CTRL_PS_POLL_HDRLEN
))
2005 ND_PRINT((ndo
, " AID(%x)",
2006 EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t
*)p
)->aid
))));
2009 if (!ND_TTEST2(*p
, CTRL_RTS_HDRLEN
))
2011 if (!ndo
->ndo_eflag
)
2012 ND_PRINT((ndo
, " TA:%s ",
2013 etheraddr_string(ndo
, ((const struct ctrl_rts_t
*)p
)->ta
)));
2016 if (!ND_TTEST2(*p
, CTRL_CTS_HDRLEN
))
2018 if (!ndo
->ndo_eflag
)
2019 ND_PRINT((ndo
, " RA:%s ",
2020 etheraddr_string(ndo
, ((const struct ctrl_cts_t
*)p
)->ra
)));
2023 if (!ND_TTEST2(*p
, CTRL_ACK_HDRLEN
))
2025 if (!ndo
->ndo_eflag
)
2026 ND_PRINT((ndo
, " RA:%s ",
2027 etheraddr_string(ndo
, ((const struct ctrl_ack_t
*)p
)->ra
)));
2030 if (!ND_TTEST2(*p
, CTRL_END_HDRLEN
))
2032 if (!ndo
->ndo_eflag
)
2033 ND_PRINT((ndo
, " RA:%s ",
2034 etheraddr_string(ndo
, ((const struct ctrl_end_t
*)p
)->ra
)));
2037 if (!ND_TTEST2(*p
, CTRL_END_ACK_HDRLEN
))
2039 if (!ndo
->ndo_eflag
)
2040 ND_PRINT((ndo
, " RA:%s ",
2041 etheraddr_string(ndo
, ((const struct ctrl_end_ack_t
*)p
)->ra
)));
2048 * Print Header funcs
2052 * Data Frame - Address field contents
2054 * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
2055 * 0 | 0 | DA | SA | BSSID | n/a
2056 * 0 | 1 | DA | BSSID | SA | n/a
2057 * 1 | 0 | BSSID | SA | DA | n/a
2058 * 1 | 1 | RA | TA | DA | SA
2062 data_header_print(netdissect_options
*ndo
,
2063 uint16_t fc
, const u_char
*p
, const uint8_t **srcp
,
2064 const uint8_t **dstp
)
2066 u_int subtype
= FC_SUBTYPE(fc
);
2068 if (DATA_FRAME_IS_CF_ACK(subtype
) || DATA_FRAME_IS_CF_POLL(subtype
) ||
2069 DATA_FRAME_IS_QOS(subtype
)) {
2070 ND_PRINT((ndo
, "CF "));
2071 if (DATA_FRAME_IS_CF_ACK(subtype
)) {
2072 if (DATA_FRAME_IS_CF_POLL(subtype
))
2073 ND_PRINT((ndo
, "Ack/Poll"));
2075 ND_PRINT((ndo
, "Ack"));
2077 if (DATA_FRAME_IS_CF_POLL(subtype
))
2078 ND_PRINT((ndo
, "Poll"));
2080 if (DATA_FRAME_IS_QOS(subtype
))
2081 ND_PRINT((ndo
, "+QoS"));
2082 ND_PRINT((ndo
, " "));
2085 #define ADDR1 (p + 4)
2086 #define ADDR2 (p + 10)
2087 #define ADDR3 (p + 16)
2088 #define ADDR4 (p + 24)
2090 if (!FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2095 if (!ndo
->ndo_eflag
)
2097 ND_PRINT((ndo
, "DA:%s SA:%s BSSID:%s ",
2098 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2099 etheraddr_string(ndo
, ADDR3
)));
2100 } else if (!FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2105 if (!ndo
->ndo_eflag
)
2107 ND_PRINT((ndo
, "DA:%s BSSID:%s SA:%s ",
2108 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2109 etheraddr_string(ndo
, ADDR3
)));
2110 } else if (FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2115 if (!ndo
->ndo_eflag
)
2117 ND_PRINT((ndo
, "BSSID:%s SA:%s DA:%s ",
2118 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2119 etheraddr_string(ndo
, ADDR3
)));
2120 } else if (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2125 if (!ndo
->ndo_eflag
)
2127 ND_PRINT((ndo
, "RA:%s TA:%s DA:%s SA:%s ",
2128 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2129 etheraddr_string(ndo
, ADDR3
), etheraddr_string(ndo
, ADDR4
)));
2139 mgmt_header_print(netdissect_options
*ndo
,
2140 const u_char
*p
, const uint8_t **srcp
, const uint8_t **dstp
)
2142 const struct mgmt_header_t
*hp
= (const struct mgmt_header_t
*) p
;
2148 if (!ndo
->ndo_eflag
)
2151 ND_PRINT((ndo
, "BSSID:%s DA:%s SA:%s ",
2152 etheraddr_string(ndo
, (hp
)->bssid
), etheraddr_string(ndo
, (hp
)->da
),
2153 etheraddr_string(ndo
, (hp
)->sa
)));
2157 ctrl_header_print(netdissect_options
*ndo
,
2158 uint16_t fc
, const u_char
*p
, const uint8_t **srcp
,
2159 const uint8_t **dstp
)
2165 if (!ndo
->ndo_eflag
)
2168 switch (FC_SUBTYPE(fc
)) {
2170 ND_PRINT((ndo
, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
2171 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ra
),
2172 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ta
),
2173 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->ctl
)),
2174 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->seq
))));
2177 ND_PRINT((ndo
, "RA:%s ",
2178 etheraddr_string(ndo
, ((const struct ctrl_ba_t
*)p
)->ra
)));
2181 ND_PRINT((ndo
, "BSSID:%s TA:%s ",
2182 etheraddr_string(ndo
, ((const struct ctrl_ps_poll_t
*)p
)->bssid
),
2183 etheraddr_string(ndo
, ((const struct ctrl_ps_poll_t
*)p
)->ta
)));
2186 ND_PRINT((ndo
, "RA:%s TA:%s ",
2187 etheraddr_string(ndo
, ((const struct ctrl_rts_t
*)p
)->ra
),
2188 etheraddr_string(ndo
, ((const struct ctrl_rts_t
*)p
)->ta
)));
2191 ND_PRINT((ndo
, "RA:%s ",
2192 etheraddr_string(ndo
, ((const struct ctrl_cts_t
*)p
)->ra
)));
2195 ND_PRINT((ndo
, "RA:%s ",
2196 etheraddr_string(ndo
, ((const struct ctrl_ack_t
*)p
)->ra
)));
2199 ND_PRINT((ndo
, "RA:%s BSSID:%s ",
2200 etheraddr_string(ndo
, ((const struct ctrl_end_t
*)p
)->ra
),
2201 etheraddr_string(ndo
, ((const struct ctrl_end_t
*)p
)->bssid
)));
2204 ND_PRINT((ndo
, "RA:%s BSSID:%s ",
2205 etheraddr_string(ndo
, ((const struct ctrl_end_ack_t
*)p
)->ra
),
2206 etheraddr_string(ndo
, ((const struct ctrl_end_ack_t
*)p
)->bssid
)));
2209 ND_PRINT((ndo
, "(H) Unknown Ctrl Subtype"));
2215 extract_header_length(netdissect_options
*ndo
,
2220 switch (FC_TYPE(fc
)) {
2224 switch (FC_SUBTYPE(fc
)) {
2226 return CTRL_BAR_HDRLEN
;
2228 return CTRL_PS_POLL_HDRLEN
;
2230 return CTRL_RTS_HDRLEN
;
2232 return CTRL_CTS_HDRLEN
;
2234 return CTRL_ACK_HDRLEN
;
2236 return CTRL_END_HDRLEN
;
2238 return CTRL_END_ACK_HDRLEN
;
2243 len
= (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) ? 30 : 24;
2244 if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
)))
2248 ND_PRINT((ndo
, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc
)));
2254 extract_mesh_header_length(const u_char
*p
)
2256 return (p
[0] &~ 3) ? 0 : 6*(1 + (p
[0] & 3));
2260 * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
2261 * to point to the source and destination MAC addresses in any case if
2262 * "srcp" and "dstp" aren't null.
2265 ieee_802_11_hdr_print(netdissect_options
*ndo
,
2266 uint16_t fc
, const u_char
*p
, u_int hdrlen
,
2267 u_int meshdrlen
, const uint8_t **srcp
,
2268 const uint8_t **dstp
)
2270 if (ndo
->ndo_vflag
) {
2271 if (FC_MORE_DATA(fc
))
2272 ND_PRINT((ndo
, "More Data "));
2273 if (FC_MORE_FLAG(fc
))
2274 ND_PRINT((ndo
, "More Fragments "));
2275 if (FC_POWER_MGMT(fc
))
2276 ND_PRINT((ndo
, "Pwr Mgmt "));
2278 ND_PRINT((ndo
, "Retry "));
2280 ND_PRINT((ndo
, "Strictly Ordered "));
2282 ND_PRINT((ndo
, "WEP Encrypted "));
2283 if (FC_TYPE(fc
) != T_CTRL
|| FC_SUBTYPE(fc
) != CTRL_PS_POLL
)
2284 ND_PRINT((ndo
, "%dus ",
2286 &((const struct mgmt_header_t
*)p
)->duration
)));
2288 if (meshdrlen
!= 0) {
2289 const struct meshcntl_t
*mc
=
2290 (const struct meshcntl_t
*)&p
[hdrlen
- meshdrlen
];
2291 int ae
= mc
->flags
& 3;
2293 ND_PRINT((ndo
, "MeshData (AE %d TTL %u seq %u", ae
, mc
->ttl
,
2294 EXTRACT_LE_32BITS(mc
->seq
)));
2296 ND_PRINT((ndo
, " A4:%s", etheraddr_string(ndo
, mc
->addr4
)));
2298 ND_PRINT((ndo
, " A5:%s", etheraddr_string(ndo
, mc
->addr5
)));
2300 ND_PRINT((ndo
, " A6:%s", etheraddr_string(ndo
, mc
->addr6
)));
2301 ND_PRINT((ndo
, ") "));
2304 switch (FC_TYPE(fc
)) {
2306 mgmt_header_print(ndo
, p
, srcp
, dstp
);
2309 ctrl_header_print(ndo
, fc
, p
, srcp
, dstp
);
2312 data_header_print(ndo
, fc
, p
, srcp
, dstp
);
2315 ND_PRINT((ndo
, "(header) unknown IEEE802.11 frame type (%d)",
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
;
2335 u_short extracted_ethertype
;
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 hdrlen
= roundup2(hdrlen
, 4);
2360 if (ndo
->ndo_Hflag
&& FC_TYPE(fc
) == T_DATA
&&
2361 DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
))) {
2362 meshdrlen
= extract_mesh_header_length(p
+hdrlen
);
2363 hdrlen
+= meshdrlen
;
2368 if (caplen
< hdrlen
) {
2369 ND_PRINT((ndo
, "%s", tstr
));
2373 ieee_802_11_hdr_print(ndo
, fc
, p
, hdrlen
, meshdrlen
, &src
, &dst
);
2376 * Go past the 802.11 header.
2382 switch (FC_TYPE(fc
)) {
2384 if (!mgmt_body_print(ndo
, fc
,
2385 (const struct mgmt_header_t
*)(p
- hdrlen
), p
, length
)) {
2386 ND_PRINT((ndo
, "%s", tstr
));
2391 if (!ctrl_body_print(ndo
, fc
, p
- hdrlen
)) {
2392 ND_PRINT((ndo
, "%s", tstr
));
2397 if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc
)))
2398 return hdrlen
; /* no-data frame */
2399 /* There may be a problem w/ AP not having this bit set */
2401 if (!wep_print(ndo
, p
)) {
2402 ND_PRINT((ndo
, "%s", tstr
));
2405 } else if (llc_print(ndo
, p
, length
, caplen
, dst
, src
,
2406 &extracted_ethertype
) == 0) {
2408 * Some kinds of LLC packet we cannot
2409 * handle intelligently
2411 if (!ndo
->ndo_eflag
)
2412 ieee_802_11_hdr_print(ndo
, fc
, p
- hdrlen
, hdrlen
,
2413 meshdrlen
, NULL
, NULL
);
2414 if (extracted_ethertype
)
2415 ND_PRINT((ndo
, "(LLC %s) ",
2417 htons(extracted_ethertype
))));
2418 if (!ndo
->ndo_suppress_default_print
)
2419 ND_DEFAULTPRINT(p
, caplen
);
2423 ND_PRINT((ndo
, "unknown 802.11 frame type (%d)", FC_TYPE(fc
)));
2431 * This is the top level routine of the printer. 'p' points
2432 * to the 802.11 header of the packet, 'h->ts' is the timestamp,
2433 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
2434 * is the number of bytes actually captured.
2437 ieee802_11_if_print(netdissect_options
*ndo
,
2438 const struct pcap_pkthdr
*h
, const u_char
*p
)
2440 return ieee802_11_print(ndo
, p
, h
->len
, h
->caplen
, 0, 0);
2443 #define IEEE80211_CHAN_FHSS \
2444 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
2445 #define IEEE80211_CHAN_A \
2446 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
2447 #define IEEE80211_CHAN_B \
2448 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
2449 #define IEEE80211_CHAN_PUREG \
2450 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
2451 #define IEEE80211_CHAN_G \
2452 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
2454 #define IS_CHAN_FHSS(flags) \
2455 ((flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
2456 #define IS_CHAN_A(flags) \
2457 ((flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
2458 #define IS_CHAN_B(flags) \
2459 ((flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
2460 #define IS_CHAN_PUREG(flags) \
2461 ((flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
2462 #define IS_CHAN_G(flags) \
2463 ((flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
2464 #define IS_CHAN_ANYG(flags) \
2465 (IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
2468 print_chaninfo(netdissect_options
*ndo
,
2469 int freq
, int flags
)
2471 ND_PRINT((ndo
, "%u MHz", freq
));
2472 if (IS_CHAN_FHSS(flags
))
2473 ND_PRINT((ndo
, " FHSS"));
2474 if (IS_CHAN_A(flags
)) {
2475 if (flags
& IEEE80211_CHAN_HALF
)
2476 ND_PRINT((ndo
, " 11a/10Mhz"));
2477 else if (flags
& IEEE80211_CHAN_QUARTER
)
2478 ND_PRINT((ndo
, " 11a/5Mhz"));
2480 ND_PRINT((ndo
, " 11a"));
2482 if (IS_CHAN_ANYG(flags
)) {
2483 if (flags
& IEEE80211_CHAN_HALF
)
2484 ND_PRINT((ndo
, " 11g/10Mhz"));
2485 else if (flags
& IEEE80211_CHAN_QUARTER
)
2486 ND_PRINT((ndo
, " 11g/5Mhz"));
2488 ND_PRINT((ndo
, " 11g"));
2489 } else if (IS_CHAN_B(flags
))
2490 ND_PRINT((ndo
, " 11b"));
2491 if (flags
& IEEE80211_CHAN_TURBO
)
2492 ND_PRINT((ndo
, " Turbo"));
2493 if (flags
& IEEE80211_CHAN_HT20
)
2494 ND_PRINT((ndo
, " ht/20"));
2495 else if (flags
& IEEE80211_CHAN_HT40D
)
2496 ND_PRINT((ndo
, " ht/40-"));
2497 else if (flags
& IEEE80211_CHAN_HT40U
)
2498 ND_PRINT((ndo
, " ht/40+"));
2499 ND_PRINT((ndo
, " "));
2503 print_radiotap_field(netdissect_options
*ndo
,
2504 struct cpack_state
*s
, uint32_t bit
, uint8_t *flags
,
2505 struct radiotap_state
*state
, uint32_t presentflags
)
2518 case IEEE80211_RADIOTAP_FLAGS
:
2519 rc
= cpack_uint8(s
, &u
.u8
);
2524 case IEEE80211_RADIOTAP_RATE
:
2525 rc
= cpack_uint8(s
, &u
.u8
);
2529 /* Save state rate */
2532 case IEEE80211_RADIOTAP_DB_ANTSIGNAL
:
2533 case IEEE80211_RADIOTAP_DB_ANTNOISE
:
2534 case IEEE80211_RADIOTAP_ANTENNA
:
2535 rc
= cpack_uint8(s
, &u
.u8
);
2537 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL
:
2538 case IEEE80211_RADIOTAP_DBM_ANTNOISE
:
2539 rc
= cpack_int8(s
, &u
.i8
);
2541 case IEEE80211_RADIOTAP_CHANNEL
:
2542 rc
= cpack_uint16(s
, &u
.u16
);
2545 rc
= cpack_uint16(s
, &u2
.u16
);
2547 case IEEE80211_RADIOTAP_FHSS
:
2548 case IEEE80211_RADIOTAP_LOCK_QUALITY
:
2549 case IEEE80211_RADIOTAP_TX_ATTENUATION
:
2550 case IEEE80211_RADIOTAP_RX_FLAGS
:
2551 rc
= cpack_uint16(s
, &u
.u16
);
2553 case IEEE80211_RADIOTAP_DB_TX_ATTENUATION
:
2554 rc
= cpack_uint8(s
, &u
.u8
);
2556 case IEEE80211_RADIOTAP_DBM_TX_POWER
:
2557 rc
= cpack_int8(s
, &u
.i8
);
2559 case IEEE80211_RADIOTAP_TSFT
:
2560 rc
= cpack_uint64(s
, &u
.u64
);
2562 case IEEE80211_RADIOTAP_XCHANNEL
:
2563 rc
= cpack_uint32(s
, &u
.u32
);
2566 rc
= cpack_uint16(s
, &u2
.u16
);
2569 rc
= cpack_uint8(s
, &u3
.u8
);
2572 rc
= cpack_uint8(s
, &u4
.u8
);
2574 case IEEE80211_RADIOTAP_MCS
:
2575 rc
= cpack_uint8(s
, &u
.u8
);
2578 rc
= cpack_uint8(s
, &u2
.u8
);
2581 rc
= cpack_uint8(s
, &u3
.u8
);
2583 case IEEE80211_RADIOTAP_VENDOR_NAMESPACE
: {
2588 if ((cpack_align_and_reserve(s
, 2)) == NULL
) {
2593 rc
= cpack_uint8(s
, &vns
[0]);
2596 rc
= cpack_uint8(s
, &vns
[1]);
2599 rc
= cpack_uint8(s
, &vns
[2]);
2602 rc
= cpack_uint8(s
, &subspace
);
2605 rc
= cpack_uint16(s
, &length
);
2609 /* Skip up to length */
2610 s
->c_next
+= length
;
2614 /* this bit indicates a field whose
2615 * size we do not know, so we cannot
2616 * proceed. Just print the bit number.
2618 ND_PRINT((ndo
, "[bit %u] ", bit
));
2623 ND_PRINT((ndo
, "%s", tstr
));
2627 /* Preserve the state present flags */
2628 state
->present
= presentflags
;
2631 case IEEE80211_RADIOTAP_CHANNEL
:
2633 * If CHANNEL and XCHANNEL are both present, skip
2636 if (presentflags
& (1 << IEEE80211_RADIOTAP_XCHANNEL
))
2638 print_chaninfo(ndo
, u
.u16
, u2
.u16
);
2640 case IEEE80211_RADIOTAP_FHSS
:
2641 ND_PRINT((ndo
, "fhset %d fhpat %d ", u
.u16
& 0xff, (u
.u16
>> 8) & 0xff));
2643 case IEEE80211_RADIOTAP_RATE
:
2645 * XXX On FreeBSD rate & 0x80 means we have an MCS. On
2646 * Linux and AirPcap it does not. (What about
2647 * Mac OS X, NetBSD, OpenBSD, and DragonFly BSD?)
2649 * This is an issue either for proprietary extensions
2650 * to 11a or 11g, which do exist, or for 11n
2651 * implementations that stuff a rate value into
2652 * this field, which also appear to exist.
2654 * We currently handle that by assuming that
2655 * if the 0x80 bit is set *and* the remaining
2656 * bits have a value between 0 and 15 it's
2657 * an MCS value, otherwise it's a rate. If
2658 * there are cases where systems that use
2659 * "0x80 + MCS index" for MCS indices > 15,
2660 * or stuff a rate value here between 64 and
2661 * 71.5 Mb/s in here, we'll need a preference
2662 * setting. Such rates do exist, e.g. 11n
2663 * MCS 7 at 20 MHz with a long guard interval.
2665 if (u
.u8
>= 0x80 && u
.u8
<= 0x8f) {
2667 * XXX - we don't know the channel width
2668 * or guard interval length, so we can't
2669 * convert this to a data rate.
2671 * If you want us to show a data rate,
2672 * use the MCS field, not the Rate field;
2673 * the MCS field includes not only the
2674 * MCS index, it also includes bandwidth
2675 * and guard interval information.
2677 * XXX - can we get the channel width
2678 * from XChannel and the guard interval
2679 * information from Flags, at least on
2682 ND_PRINT((ndo
, "MCS %u ", u
.u8
& 0x7f));
2684 ND_PRINT((ndo
, "%2.1f Mb/s ", .5 * u
.u8
));
2686 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL
:
2687 ND_PRINT((ndo
, "%ddB signal ", u
.i8
));
2689 case IEEE80211_RADIOTAP_DBM_ANTNOISE
:
2690 ND_PRINT((ndo
, "%ddB noise ", u
.i8
));
2692 case IEEE80211_RADIOTAP_DB_ANTSIGNAL
:
2693 ND_PRINT((ndo
, "%ddB signal ", u
.u8
));
2695 case IEEE80211_RADIOTAP_DB_ANTNOISE
:
2696 ND_PRINT((ndo
, "%ddB noise ", u
.u8
));
2698 case IEEE80211_RADIOTAP_LOCK_QUALITY
:
2699 ND_PRINT((ndo
, "%u sq ", u
.u16
));
2701 case IEEE80211_RADIOTAP_TX_ATTENUATION
:
2702 ND_PRINT((ndo
, "%d tx power ", -(int)u
.u16
));
2704 case IEEE80211_RADIOTAP_DB_TX_ATTENUATION
:
2705 ND_PRINT((ndo
, "%ddB tx power ", -(int)u
.u8
));
2707 case IEEE80211_RADIOTAP_DBM_TX_POWER
:
2708 ND_PRINT((ndo
, "%ddBm tx power ", u
.i8
));
2710 case IEEE80211_RADIOTAP_FLAGS
:
2711 if (u
.u8
& IEEE80211_RADIOTAP_F_CFP
)
2712 ND_PRINT((ndo
, "cfp "));
2713 if (u
.u8
& IEEE80211_RADIOTAP_F_SHORTPRE
)
2714 ND_PRINT((ndo
, "short preamble "));
2715 if (u
.u8
& IEEE80211_RADIOTAP_F_WEP
)
2716 ND_PRINT((ndo
, "wep "));
2717 if (u
.u8
& IEEE80211_RADIOTAP_F_FRAG
)
2718 ND_PRINT((ndo
, "fragmented "));
2719 if (u
.u8
& IEEE80211_RADIOTAP_F_BADFCS
)
2720 ND_PRINT((ndo
, "bad-fcs "));
2722 case IEEE80211_RADIOTAP_ANTENNA
:
2723 ND_PRINT((ndo
, "antenna %d ", u
.u8
));
2725 case IEEE80211_RADIOTAP_TSFT
:
2726 ND_PRINT((ndo
, "%" PRIu64
"us tsft ", u
.u64
));
2728 case IEEE80211_RADIOTAP_RX_FLAGS
:
2729 /* Do nothing for now */
2731 case IEEE80211_RADIOTAP_XCHANNEL
:
2732 print_chaninfo(ndo
, u2
.u16
, u
.u32
);
2734 case IEEE80211_RADIOTAP_MCS
: {
2735 static const char *bandwidth
[4] = {
2743 if (u
.u8
& IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN
) {
2745 * We know the MCS index.
2747 if (u3
.u8
<= MAX_MCS_INDEX
) {
2749 * And it's in-range.
2751 if (u
.u8
& (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN
|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN
)) {
2753 * And we know both the bandwidth and
2754 * the guard interval, so we can look
2758 ieee80211_float_htrates \
2760 [((u2
.u8
& IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK
) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40
? 1 : 0)] \
2761 [((u2
.u8
& IEEE80211_RADIOTAP_MCS_SHORT_GI
) ? 1 : 0)];
2764 * We don't know both the bandwidth
2765 * and the guard interval, so we can
2766 * only report the MCS index.
2772 * The MCS value is out of range.
2776 if (htrate
!= 0.0) {
2781 ND_PRINT((ndo
, "%.1f Mb/s MCS %u ", htrate
, u3
.u8
));
2784 * We at least have the MCS index.
2787 ND_PRINT((ndo
, "MCS %u ", u3
.u8
));
2790 if (u
.u8
& IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN
) {
2791 ND_PRINT((ndo
, "%s ",
2792 bandwidth
[u2
.u8
& IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK
]));
2794 if (u
.u8
& IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN
) {
2795 ND_PRINT((ndo
, "%s GI ",
2796 (u2
.u8
& IEEE80211_RADIOTAP_MCS_SHORT_GI
) ?
2799 if (u
.u8
& IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN
) {
2800 ND_PRINT((ndo
, "%s ",
2801 (u2
.u8
& IEEE80211_RADIOTAP_MCS_HT_GREENFIELD
) ?
2802 "greenfield" : "mixed"));
2804 if (u
.u8
& IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN
) {
2805 ND_PRINT((ndo
, "%s FEC ",
2806 (u2
.u8
& IEEE80211_RADIOTAP_MCS_FEC_LDPC
) ?
2809 if (u
.u8
& IEEE80211_RADIOTAP_MCS_STBC_KNOWN
) {
2810 ND_PRINT((ndo
, "RX-STBC%u ",
2811 (u2
.u8
& IEEE80211_RADIOTAP_MCS_STBC_MASK
) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT
));
2821 ieee802_11_radio_print(netdissect_options
*ndo
,
2822 const u_char
*p
, u_int length
, u_int caplen
)
2824 #define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
2825 #define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
2826 #define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
2827 #define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
2828 #define BITNO_2(x) (((x) & 2) ? 1 : 0)
2829 #define BIT(n) (1U << n)
2830 #define IS_EXTENDED(__p) \
2831 (EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
2833 struct cpack_state cpacker
;
2834 struct ieee80211_radiotap_header
*hdr
;
2835 uint32_t present
, next_present
;
2836 uint32_t presentflags
= 0;
2837 uint32_t *presentp
, *last_presentp
;
2838 enum ieee80211_radiotap_type bit
;
2844 struct radiotap_state state
;
2846 if (caplen
< sizeof(*hdr
)) {
2847 ND_PRINT((ndo
, "%s", tstr
));
2851 hdr
= (struct ieee80211_radiotap_header
*)p
;
2853 len
= EXTRACT_LE_16BITS(&hdr
->it_len
);
2856 ND_PRINT((ndo
, "%s", tstr
));
2859 cpack_init(&cpacker
, (uint8_t *)hdr
, len
); /* align against header start */
2860 cpack_advance(&cpacker
, sizeof(*hdr
)); /* includes the 1st bitmap */
2861 for (last_presentp
= &hdr
->it_present
;
2862 IS_EXTENDED(last_presentp
) &&
2863 (u_char
*)(last_presentp
+ 1) <= p
+ len
;
2865 cpack_advance(&cpacker
, sizeof(hdr
->it_present
)); /* more bitmaps */
2867 /* are there more bitmap extensions than bytes in header? */
2868 if (IS_EXTENDED(last_presentp
)) {
2869 ND_PRINT((ndo
, "%s", tstr
));
2873 /* Assume no flags */
2875 /* Assume no Atheros padding between 802.11 header and body */
2877 /* Assume no FCS at end of frame */
2879 for (bit0
= 0, presentp
= &hdr
->it_present
; presentp
<= last_presentp
;
2880 presentp
++, bit0
+= 32) {
2881 presentflags
= EXTRACT_LE_32BITS(presentp
);
2884 memset(&state
, 0, sizeof(state
));
2886 for (present
= EXTRACT_LE_32BITS(presentp
); present
;
2887 present
= next_present
) {
2888 /* clear the least significant bit that is set */
2889 next_present
= present
& (present
- 1);
2891 /* extract the least significant bit that is set */
2892 bit
= (enum ieee80211_radiotap_type
)
2893 (bit0
+ BITNO_32(present
^ next_present
));
2895 if (print_radiotap_field(ndo
, &cpacker
, bit
, &flags
, &state
, presentflags
) != 0)
2901 if (flags
& IEEE80211_RADIOTAP_F_DATAPAD
)
2902 pad
= 1; /* Atheros padding */
2903 if (flags
& IEEE80211_RADIOTAP_F_FCS
)
2904 fcslen
= 4; /* FCS at end of packet */
2905 return len
+ ieee802_11_print(ndo
, p
+ len
, length
- len
, caplen
- len
, pad
,
2916 ieee802_11_avs_radio_print(netdissect_options
*ndo
,
2917 const u_char
*p
, u_int length
, u_int caplen
)
2919 uint32_t caphdr_len
;
2922 ND_PRINT((ndo
, "%s", tstr
));
2926 caphdr_len
= EXTRACT_32BITS(p
+ 4);
2927 if (caphdr_len
< 8) {
2929 * Yow! The capture header length is claimed not
2930 * to be large enough to include even the version
2931 * cookie or capture header length!
2933 ND_PRINT((ndo
, "%s", tstr
));
2937 if (caplen
< caphdr_len
) {
2938 ND_PRINT((ndo
, "%s", tstr
));
2942 return caphdr_len
+ ieee802_11_print(ndo
, p
+ caphdr_len
,
2943 length
- caphdr_len
, caplen
- caphdr_len
, 0, 0);
2946 #define PRISM_HDR_LEN 144
2948 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000
2949 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001
2950 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002
2953 * For DLT_PRISM_HEADER; like DLT_IEEE802_11, but with an extra header,
2954 * containing information such as radio information, which we
2957 * If, however, the packet begins with WLANCAP_MAGIC_COOKIE_V1 or
2958 * WLANCAP_MAGIC_COOKIE_V2, it's really DLT_IEEE802_11_RADIO_AVS
2959 * (currently, on Linux, there's no ARPHRD_ type for
2960 * DLT_IEEE802_11_RADIO_AVS, as there is a ARPHRD_IEEE80211_PRISM
2961 * for DLT_PRISM_HEADER, so ARPHRD_IEEE80211_PRISM is used for
2962 * the AVS header, and the first 4 bytes of the header are used to
2963 * indicate whether it's a Prism header or an AVS header).
2966 prism_if_print(netdissect_options
*ndo
,
2967 const struct pcap_pkthdr
*h
, const u_char
*p
)
2969 u_int caplen
= h
->caplen
;
2970 u_int length
= h
->len
;
2974 ND_PRINT((ndo
, "%s", tstr
));
2978 msgcode
= EXTRACT_32BITS(p
);
2979 if (msgcode
== WLANCAP_MAGIC_COOKIE_V1
||
2980 msgcode
== WLANCAP_MAGIC_COOKIE_V2
)
2981 return ieee802_11_avs_radio_print(ndo
, p
, length
, caplen
);
2983 if (caplen
< PRISM_HDR_LEN
) {
2984 ND_PRINT((ndo
, "%s", tstr
));
2988 return PRISM_HDR_LEN
+ ieee802_11_print(ndo
, p
+ PRISM_HDR_LEN
,
2989 length
- PRISM_HDR_LEN
, caplen
- PRISM_HDR_LEN
, 0, 0);
2993 * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra
2994 * header, containing information such as radio information.
2997 ieee802_11_radio_if_print(netdissect_options
*ndo
,
2998 const struct pcap_pkthdr
*h
, const u_char
*p
)
3000 return ieee802_11_radio_print(ndo
, p
, h
->len
, h
->caplen
);
3004 * For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an
3005 * extra header, containing information such as radio information,
3006 * which we currently ignore.
3009 ieee802_11_radio_avs_if_print(netdissect_options
*ndo
,
3010 const struct pcap_pkthdr
*h
, const u_char
*p
)
3012 return ieee802_11_avs_radio_print(ndo
, p
, h
->len
, h
->caplen
);