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 #include <sys/cdefs.h>
25 __RCSID("$NetBSD: print-802_11.c,v 1.5 2014/11/20 03:05:03 christos Exp $");
28 #define NETDISSECT_REWORKED
33 #include <tcpdump-stdinc.h>
37 #include "interface.h"
38 #include "addrtoname.h"
45 /* Lengths of 802.11 header components. */
46 #define IEEE802_11_FC_LEN 2
47 #define IEEE802_11_DUR_LEN 2
48 #define IEEE802_11_DA_LEN 6
49 #define IEEE802_11_SA_LEN 6
50 #define IEEE802_11_BSSID_LEN 6
51 #define IEEE802_11_RA_LEN 6
52 #define IEEE802_11_TA_LEN 6
53 #define IEEE802_11_SEQ_LEN 2
54 #define IEEE802_11_CTL_LEN 2
55 #define IEEE802_11_IV_LEN 3
56 #define IEEE802_11_KID_LEN 1
58 /* Frame check sequence length. */
59 #define IEEE802_11_FCS_LEN 4
61 /* Lengths of beacon components. */
62 #define IEEE802_11_TSTAMP_LEN 8
63 #define IEEE802_11_BCNINT_LEN 2
64 #define IEEE802_11_CAPINFO_LEN 2
65 #define IEEE802_11_LISTENINT_LEN 2
67 #define IEEE802_11_AID_LEN 2
68 #define IEEE802_11_STATUS_LEN 2
69 #define IEEE802_11_REASON_LEN 2
71 /* Length of previous AP in reassocation frame */
72 #define IEEE802_11_AP_LEN 6
74 #define T_MGMT 0x0 /* management */
75 #define T_CTRL 0x1 /* control */
76 #define T_DATA 0x2 /* data */
77 #define T_RESV 0x3 /* reserved */
79 #define ST_ASSOC_REQUEST 0x0
80 #define ST_ASSOC_RESPONSE 0x1
81 #define ST_REASSOC_REQUEST 0x2
82 #define ST_REASSOC_RESPONSE 0x3
83 #define ST_PROBE_REQUEST 0x4
84 #define ST_PROBE_RESPONSE 0x5
89 #define ST_DISASSOC 0xA
96 static const struct tok st_str
[] = {
97 { ST_ASSOC_REQUEST
, "Assoc Request" },
98 { ST_ASSOC_RESPONSE
, "Assoc Response" },
99 { ST_REASSOC_REQUEST
, "ReAssoc Request" },
100 { ST_REASSOC_RESPONSE
, "ReAssoc Response" },
101 { ST_PROBE_REQUEST
, "Probe Request" },
102 { ST_PROBE_RESPONSE
, "Probe Response" },
103 { ST_BEACON
, "Beacon" },
105 { ST_DISASSOC
, "Disassociation" },
106 { ST_AUTH
, "Authentication" },
107 { ST_DEAUTH
, "DeAuthentication" },
108 { ST_ACTION
, "Action" },
112 #define CTRL_CONTROL_WRAPPER 0x7
115 #define CTRL_PS_POLL 0xA
119 #define CTRL_CF_END 0xE
120 #define CTRL_END_ACK 0xF
122 static const struct tok ctrl_str
[] = {
123 { CTRL_CONTROL_WRAPPER
, "Control Wrapper" },
126 { CTRL_PS_POLL
, "Power Save-Poll" },
127 { CTRL_RTS
, "Request-To-Send" },
128 { CTRL_CTS
, "Clear-To-Send" },
129 { CTRL_ACK
, "Acknowledgment" },
130 { CTRL_CF_END
, "CF-End" },
131 { CTRL_END_ACK
, "CF-End+CF-Ack" },
135 #define DATA_DATA 0x0
136 #define DATA_DATA_CF_ACK 0x1
137 #define DATA_DATA_CF_POLL 0x2
138 #define DATA_DATA_CF_ACK_POLL 0x3
139 #define DATA_NODATA 0x4
140 #define DATA_NODATA_CF_ACK 0x5
141 #define DATA_NODATA_CF_POLL 0x6
142 #define DATA_NODATA_CF_ACK_POLL 0x7
144 #define DATA_QOS_DATA 0x8
145 #define DATA_QOS_DATA_CF_ACK 0x9
146 #define DATA_QOS_DATA_CF_POLL 0xA
147 #define DATA_QOS_DATA_CF_ACK_POLL 0xB
148 #define DATA_QOS_NODATA 0xC
149 #define DATA_QOS_CF_POLL_NODATA 0xE
150 #define DATA_QOS_CF_ACK_POLL_NODATA 0xF
153 * The subtype field of a data frame is, in effect, composed of 4 flag
154 * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
155 * any data), and QoS.
157 #define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
158 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
159 #define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
160 #define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
163 * Bits in the frame control field.
165 #define FC_VERSION(fc) ((fc) & 0x3)
166 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
167 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
168 #define FC_TO_DS(fc) ((fc) & 0x0100)
169 #define FC_FROM_DS(fc) ((fc) & 0x0200)
170 #define FC_MORE_FLAG(fc) ((fc) & 0x0400)
171 #define FC_RETRY(fc) ((fc) & 0x0800)
172 #define FC_POWER_MGMT(fc) ((fc) & 0x1000)
173 #define FC_MORE_DATA(fc) ((fc) & 0x2000)
174 #define FC_WEP(fc) ((fc) & 0x4000)
175 #define FC_ORDER(fc) ((fc) & 0x8000)
177 struct mgmt_header_t
{
186 #define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
187 IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
188 IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
190 #define CAPABILITY_ESS(cap) ((cap) & 0x0001)
191 #define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
192 #define CAPABILITY_CFP(cap) ((cap) & 0x0004)
193 #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
194 #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
199 u_char ssid
[33]; /* 32 + 1 for null */
211 uint8_t text
[254]; /* 1-253 + 1 for null */
234 uint16_t max_duration
;
235 uint16_t dur_remaing
;
243 uint8_t bitmap_control
;
265 #define E_CHALLENGE 16
274 uint8_t timestamp
[IEEE802_11_TSTAMP_LEN
];
275 uint16_t beacon_interval
;
276 uint16_t listen_interval
;
277 uint16_t status_code
;
279 u_char ap
[IEEE802_11_AP_LEN
];
280 uint16_t reason_code
;
282 uint16_t auth_trans_seq_num
;
283 int challenge_present
;
284 struct challenge_t challenge
;
285 uint16_t capability_info
;
289 struct rates_t rates
;
308 #define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
309 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
318 #define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
327 #define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
329 struct ctrl_ps_poll_t
{
337 #define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
338 IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
348 #define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
349 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
351 struct ctrl_end_ack_t
{
359 #define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
360 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
369 #define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
381 #define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
382 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
383 IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
394 #define IV_IV(iv) ((iv) & 0xFFFFFF)
395 #define IV_PAD(iv) (((iv) >> 24) & 0x3F)
396 #define IV_KEYID(iv) (((iv) >> 30) & 0x03)
398 /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
399 /* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
402 * Copyright (c) 2003, 2004 David Young. All rights reserved.
404 * Redistribution and use in source and binary forms, with or without
405 * modification, are permitted provided that the following conditions
407 * 1. Redistributions of source code must retain the above copyright
408 * notice, this list of conditions and the following disclaimer.
409 * 2. Redistributions in binary form must reproduce the above copyright
410 * notice, this list of conditions and the following disclaimer in the
411 * documentation and/or other materials provided with the distribution.
412 * 3. The name of David Young may not be used to endorse or promote
413 * products derived from this software without specific prior
414 * written permission.
416 * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
417 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
418 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
419 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
420 * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
421 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
422 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
423 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
424 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
425 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
426 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
430 /* A generic radio capture format is desirable. It must be
431 * rigidly defined (e.g., units for fields should be given),
432 * and easily extensible.
434 * The following is an extensible radio capture format. It is
435 * based on a bitmap indicating which fields are present.
437 * I am trying to describe precisely what the application programmer
438 * should expect in the following, and for that reason I tell the
439 * units and origin of each measurement (where it applies), or else I
440 * use sufficiently weaselly language ("is a monotonically nondecreasing
441 * function of...") that I cannot set false expectations for lawyerly
446 * The radio capture header precedes the 802.11 header.
448 * Note well: all radiotap fields are little-endian.
450 struct ieee80211_radiotap_header
{
451 uint8_t it_version
; /* Version 0. Only increases
452 * for drastic changes,
453 * introduction of compatible
454 * new fields does not count.
457 uint16_t it_len
; /* length of the whole
458 * header in bytes, including
459 * it_version, it_pad,
460 * it_len, and data fields.
462 uint32_t it_present
; /* A bitmap telling which
463 * fields are present. Set bit 31
464 * (0x80000000) to extend the
465 * bitmap by another 32 bits.
466 * Additional extensions are made
471 /* Name Data type Units
472 * ---- --------- -----
474 * IEEE80211_RADIOTAP_TSFT uint64_t microseconds
476 * Value in microseconds of the MAC's 64-bit 802.11 Time
477 * Synchronization Function timer when the first bit of the
478 * MPDU arrived at the MAC. For received frames, only.
480 * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
482 * Tx/Rx frequency in MHz, followed by flags (see below).
483 * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
484 * represent an HT channel as there is not enough room in
487 * IEEE80211_RADIOTAP_FHSS uint16_t see below
489 * For frequency-hopping radios, the hop set (first byte)
490 * and pattern (second byte).
492 * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index
494 * Tx/Rx data rate. If bit 0x80 is set then it represents an
495 * an MCS index and not an IEEE rate.
497 * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
498 * one milliwatt (dBm)
500 * RF signal power at the antenna, decibel difference from
503 * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
504 * one milliwatt (dBm)
506 * RF noise power at the antenna, decibel difference from one
509 * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
511 * RF signal power at the antenna, decibel difference from an
512 * arbitrary, fixed reference.
514 * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
516 * RF noise power at the antenna, decibel difference from an
517 * arbitrary, fixed reference point.
519 * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
521 * Quality of Barker code lock. Unitless. Monotonically
522 * nondecreasing with "better" lock strength. Called "Signal
523 * Quality" in datasheets. (Is there a standard way to measure
526 * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
528 * Transmit power expressed as unitless distance from max
529 * power set at factory calibration. 0 is max power.
530 * Monotonically nondecreasing with lower power levels.
532 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
534 * Transmit power expressed as decibel distance from max power
535 * set at factory calibration. 0 is max power. Monotonically
536 * nondecreasing with lower power levels.
538 * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
539 * one milliwatt (dBm)
541 * Transmit power expressed as dBm (decibels from a 1 milliwatt
542 * reference). This is the absolute power level measured at
545 * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap
547 * Properties of transmitted and received frames. See flags
550 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
552 * Unitless indication of the Rx/Tx antenna for this packet.
553 * The first antenna is antenna 0.
555 * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
557 * Properties of received frames. See flags defined below.
559 * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap
561 * uint8_t channel number
564 * Extended channel specification: flags (see below) followed by
565 * frequency in MHz, the corresponding IEEE channel number, and
566 * finally the maximum regulatory transmit power cap in .5 dBm
567 * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
568 * and only one of the two should be present.
570 * IEEE80211_RADIOTAP_MCS uint8_t known
574 * Bitset indicating which fields have known values, followed
575 * by bitset of flag values, followed by the MCS rate index as
578 * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
583 * The Vendor Namespace Field contains three sub-fields. The first
584 * sub-field is 3 bytes long. It contains the vendor's IEEE 802
585 * Organizationally Unique Identifier (OUI). The fourth byte is a
586 * vendor-specific "namespace selector."
589 enum ieee80211_radiotap_type
{
590 IEEE80211_RADIOTAP_TSFT
= 0,
591 IEEE80211_RADIOTAP_FLAGS
= 1,
592 IEEE80211_RADIOTAP_RATE
= 2,
593 IEEE80211_RADIOTAP_CHANNEL
= 3,
594 IEEE80211_RADIOTAP_FHSS
= 4,
595 IEEE80211_RADIOTAP_DBM_ANTSIGNAL
= 5,
596 IEEE80211_RADIOTAP_DBM_ANTNOISE
= 6,
597 IEEE80211_RADIOTAP_LOCK_QUALITY
= 7,
598 IEEE80211_RADIOTAP_TX_ATTENUATION
= 8,
599 IEEE80211_RADIOTAP_DB_TX_ATTENUATION
= 9,
600 IEEE80211_RADIOTAP_DBM_TX_POWER
= 10,
601 IEEE80211_RADIOTAP_ANTENNA
= 11,
602 IEEE80211_RADIOTAP_DB_ANTSIGNAL
= 12,
603 IEEE80211_RADIOTAP_DB_ANTNOISE
= 13,
604 IEEE80211_RADIOTAP_RX_FLAGS
= 14,
605 /* NB: gap for netbsd definitions */
606 IEEE80211_RADIOTAP_XCHANNEL
= 18,
607 IEEE80211_RADIOTAP_MCS
= 19,
608 IEEE80211_RADIOTAP_NAMESPACE
= 29,
609 IEEE80211_RADIOTAP_VENDOR_NAMESPACE
= 30,
610 IEEE80211_RADIOTAP_EXT
= 31
613 /* channel attributes */
614 #define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
615 #define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
616 #define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
617 #define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
618 #define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
619 #define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
620 #define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
621 #define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
622 #define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
623 #define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
624 #define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
625 #define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
626 #define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
627 #define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
628 #define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
630 /* Useful combinations of channel characteristics, borrowed from Ethereal */
631 #define IEEE80211_CHAN_A \
632 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
633 #define IEEE80211_CHAN_B \
634 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
635 #define IEEE80211_CHAN_G \
636 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
637 #define IEEE80211_CHAN_TA \
638 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
639 #define IEEE80211_CHAN_TG \
640 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
643 /* For IEEE80211_RADIOTAP_FLAGS */
644 #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
647 #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
651 #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
652 * with WEP encryption
654 #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
657 #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
658 #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
659 * 802.11 header and payload
660 * (to 32-bit boundary)
662 #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
664 /* For IEEE80211_RADIOTAP_RX_FLAGS */
665 #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
666 #define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
668 /* For IEEE80211_RADIOTAP_MCS known */
669 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
670 #define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
671 #define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
672 #define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
673 #define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
674 #define IEEE80211_RADIOTAP_MCS_STBC_KNOWN 0x20
676 /* For IEEE80211_RADIOTAP_MCS flags */
677 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
678 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
679 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
680 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
681 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
682 #define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
683 #define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
684 #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
685 #define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60
686 #define IEEE80211_RADIOTAP_MCS_STBC_1 1
687 #define IEEE80211_RADIOTAP_MCS_STBC_2 2
688 #define IEEE80211_RADIOTAP_MCS_STBC_3 3
689 #define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5
691 static const char tstr
[] = "[|802.11]";
694 /* This is used to save state when parsing/processing parameters */
695 struct radiotap_state
702 #define PRINT_SSID(p) \
703 if (p.ssid_present) { \
704 ND_PRINT((ndo, " (")); \
705 fn_print(ndo, p.ssid.ssid, NULL); \
706 ND_PRINT((ndo, ")")); \
709 #define PRINT_RATE(_sep, _r, _suf) \
710 ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf))
711 #define PRINT_RATES(p) \
712 if (p.rates_present) { \
714 const char *sep = " ["; \
715 for (z = 0; z < p.rates.length ; z++) { \
716 PRINT_RATE(sep, p.rates.rate[z], \
717 (p.rates.rate[z] & 0x80 ? "*" : "")); \
720 if (p.rates.length != 0) \
721 ND_PRINT((ndo, " Mbit]")); \
724 #define PRINT_DS_CHANNEL(p) \
726 ND_PRINT((ndo, " CH: %u", p.ds.channel)); \
727 ND_PRINT((ndo, "%s", \
728 CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : ""));
730 #define MAX_MCS_INDEX 76
735 * the MCS index (0-76);
737 * 0 for 20 MHz, 1 for 40 MHz;
739 * 0 for a long guard interval, 1 for a short guard interval.
741 static const float ieee80211_float_htrates
[MAX_MCS_INDEX
+1][2][2] = {
743 { /* 20 Mhz */ { 6.5, /* SGI */ 7.2, },
744 /* 40 Mhz */ { 13.5, /* SGI */ 15.0, },
748 { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
749 /* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
753 { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
754 /* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
758 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
759 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
763 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
764 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
768 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
769 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
773 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
774 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
778 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
779 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
783 { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, },
784 /* 40 Mhz */ { 27.0, /* SGI */ 30.0, },
788 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
789 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
793 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
794 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
798 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
799 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
803 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
804 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
808 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
809 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
813 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
814 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
818 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
819 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
823 { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, },
824 /* 40 Mhz */ { 40.5, /* SGI */ 45.0, },
828 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
829 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
833 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
834 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
838 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
839 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
843 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
844 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
848 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
849 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
853 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
854 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
858 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
859 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
863 { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, },
864 /* 40 Mhz */ { 54.0, /* SGI */ 60.0, },
868 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
869 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
873 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
874 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
878 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
879 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
883 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
884 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
888 { /* 20 Mhz */ { 208.0, /* SGI */ 231.1, },
889 /* 40 Mhz */ { 432.0, /* SGI */ 480.0, },
893 { /* 20 Mhz */ { 234.0, /* SGI */ 260.0, },
894 /* 40 Mhz */ { 486.0, /* SGI */ 540.0, },
898 { /* 20 Mhz */ { 260.0, /* SGI */ 288.9, },
899 /* 40 Mhz */ { 540.0, /* SGI */ 600.0, },
903 { /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */
904 /* 40 Mhz */ { 6.0, /* SGI */ 6.7, },
908 { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, },
909 /* 40 Mhz */ { 81.0, /* SGI */ 90.0, },
913 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
914 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
918 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
919 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
923 { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, },
924 /* 40 Mhz */ { 121.5, /* SGI */ 135.0, },
928 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
929 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
933 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
934 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
938 { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, },
939 /* 40 Mhz */ { 108.0, /* SGI */ 120.0, },
943 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
944 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
948 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
949 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
953 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
954 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
958 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
959 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
963 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
964 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
968 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
969 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
973 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
974 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
978 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
979 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
983 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
984 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
988 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
989 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
993 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
994 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
998 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
999 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1003 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1004 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1008 { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, },
1009 /* 40 Mhz */ { 135.0, /* SGI */ 150.0, },
1013 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
1014 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
1018 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
1019 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
1023 { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, },
1024 /* 40 Mhz */ { 162.0, /* SGI */ 180.0, },
1028 { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, },
1029 /* 40 Mhz */ { 189.0, /* SGI */ 210.0, },
1033 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
1034 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
1038 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1039 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1043 { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, },
1044 /* 40 Mhz */ { 216.0, /* SGI */ 240.0, },
1048 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1049 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1053 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
1054 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
1058 { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, },
1059 /* 40 Mhz */ { 270.0, /* SGI */ 300.0, },
1063 { /* 20 Mhz */ { 143.0, /* SGI */ 158.9, },
1064 /* 40 Mhz */ { 297.0, /* SGI */ 330.0, },
1068 { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, },
1069 /* 40 Mhz */ { 202.5, /* SGI */ 225.0, },
1073 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1074 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1078 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1079 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1083 { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, },
1084 /* 40 Mhz */ { 243.0, /* SGI */ 270.0, },
1088 { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, },
1089 /* 40 Mhz */ { 283.5, /* SGI */ 315.0, },
1093 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1094 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1098 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
1099 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
1103 { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, },
1104 /* 40 Mhz */ { 324.0, /* SGI */ 360.0, },
1108 { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, },
1109 /* 40 Mhz */ { 364.5, /* SGI */ 405.0, },
1113 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
1114 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
1118 { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, },
1119 /* 40 Mhz */ { 405.0, /* SGI */ 450.0, },
1123 { /* 20 Mhz */ { 214.5, /* SGI */ 238.3, },
1124 /* 40 Mhz */ { 445.5, /* SGI */ 495.0, },
1128 static const char *auth_alg_text
[]={"Open System","Shared Key","EAP"};
1129 #define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
1131 static const char *status_text
[] = {
1132 "Successful", /* 0 */
1133 "Unspecified failure", /* 1 */
1142 "Cannot Support all requested capabilities in the Capability "
1143 "Information field", /* 10 */
1144 "Reassociation denied due to inability to confirm that association "
1146 "Association denied due to reason outside the scope of the "
1147 "standard", /* 12 */
1148 "Responding station does not support the specified authentication "
1149 "algorithm ", /* 13 */
1150 "Received an Authentication frame with authentication transaction "
1151 "sequence number out of expected sequence", /* 14 */
1152 "Authentication rejected because of challenge failure", /* 15 */
1153 "Authentication rejected due to timeout waiting for next frame in "
1154 "sequence", /* 16 */
1155 "Association denied because AP is unable to handle additional"
1156 "associated stations", /* 17 */
1157 "Association denied due to requesting station not supporting all of "
1158 "the data rates in BSSBasicRateSet parameter", /* 18 */
1159 "Association denied due to requesting station not supporting "
1160 "short preamble operation", /* 19 */
1161 "Association denied due to requesting station not supporting "
1162 "PBCC encoding", /* 20 */
1163 "Association denied due to requesting station not supporting "
1164 "channel agility", /* 21 */
1165 "Association request rejected because Spectrum Management "
1166 "capability is required", /* 22 */
1167 "Association request rejected because the information in the "
1168 "Power Capability element is unacceptable", /* 23 */
1169 "Association request rejected because the information in the "
1170 "Supported Channels element is unacceptable", /* 24 */
1171 "Association denied due to requesting station not supporting "
1172 "short slot operation", /* 25 */
1173 "Association denied due to requesting station not supporting "
1174 "DSSS-OFDM operation", /* 26 */
1175 "Association denied because the requested STA does not support HT "
1176 "features", /* 27 */
1177 "Reserved", /* 28 */
1178 "Association denied because the requested STA does not support "
1179 "the PCO transition time required by the AP", /* 29 */
1180 "Reserved", /* 30 */
1181 "Reserved", /* 31 */
1182 "Unspecified, QoS-related failure", /* 32 */
1183 "Association denied due to QAP having insufficient bandwidth "
1184 "to handle another QSTA", /* 33 */
1185 "Association denied due to excessive frame loss rates and/or "
1186 "poor conditions on current operating channel", /* 34 */
1187 "Association (with QBSS) denied due to requesting station not "
1188 "supporting the QoS facility", /* 35 */
1189 "Association denied due to requesting station not supporting "
1190 "Block Ack", /* 36 */
1191 "The request has been declined", /* 37 */
1192 "The request has not been successful as one or more parameters "
1193 "have invalid values", /* 38 */
1194 "The TS has not been created because the request cannot be honored. "
1195 "Try again with the suggested changes to the TSPEC", /* 39 */
1196 "Invalid Information Element", /* 40 */
1197 "Group Cipher is not valid", /* 41 */
1198 "Pairwise Cipher is not valid", /* 42 */
1199 "AKMP is not valid", /* 43 */
1200 "Unsupported RSN IE version", /* 44 */
1201 "Invalid RSN IE Capabilities", /* 45 */
1202 "Cipher suite is rejected per security policy", /* 46 */
1203 "The TS has not been created. However, the HC may be capable of "
1204 "creating a TS, in response to a request, after the time indicated "
1205 "in the TS Delay element", /* 47 */
1206 "Direct Link is not allowed in the BSS by policy", /* 48 */
1207 "Destination STA is not present within this QBSS.", /* 49 */
1208 "The Destination STA is not a QSTA.", /* 50 */
1211 #define NUM_STATUSES (sizeof status_text / sizeof status_text[0])
1213 static const char *reason_text
[] = {
1215 "Unspecified reason", /* 1 */
1216 "Previous authentication no longer valid", /* 2 */
1217 "Deauthenticated because sending station is leaving (or has left) "
1218 "IBSS or ESS", /* 3 */
1219 "Disassociated due to inactivity", /* 4 */
1220 "Disassociated because AP is unable to handle all currently "
1221 " associated stations", /* 5 */
1222 "Class 2 frame received from nonauthenticated station", /* 6 */
1223 "Class 3 frame received from nonassociated station", /* 7 */
1224 "Disassociated because sending station is leaving "
1225 "(or has left) BSS", /* 8 */
1226 "Station requesting (re)association is not authenticated with "
1227 "responding station", /* 9 */
1228 "Disassociated because the information in the Power Capability "
1229 "element is unacceptable", /* 10 */
1230 "Disassociated because the information in the SupportedChannels "
1231 "element is unacceptable", /* 11 */
1232 "Invalid Information Element", /* 12 */
1233 "Reserved", /* 13 */
1234 "Michael MIC failure", /* 14 */
1235 "4-Way Handshake timeout", /* 15 */
1236 "Group key update timeout", /* 16 */
1237 "Information element in 4-Way Handshake different from (Re)Association"
1238 "Request/Probe Response/Beacon", /* 17 */
1239 "Group Cipher is not valid", /* 18 */
1240 "AKMP is not valid", /* 20 */
1241 "Unsupported RSN IE version", /* 21 */
1242 "Invalid RSN IE Capabilities", /* 22 */
1243 "IEEE 802.1X Authentication failed", /* 23 */
1244 "Cipher suite is rejected per security policy", /* 24 */
1245 "Reserved", /* 25 */
1246 "Reserved", /* 26 */
1247 "Reserved", /* 27 */
1248 "Reserved", /* 28 */
1249 "Reserved", /* 29 */
1250 "Reserved", /* 30 */
1251 "TS deleted because QoS AP lacks sufficient bandwidth for this "
1252 "QoS STA due to a change in BSS service characteristics or "
1253 "operational mode (e.g. an HT BSS change from 40 MHz channel "
1254 "to 20 MHz channel)", /* 31 */
1255 "Disassociated for unspecified, QoS-related reason", /* 32 */
1256 "Disassociated because QoS AP lacks sufficient bandwidth for this "
1258 "Disassociated because of excessive number of frames that need to be "
1259 "acknowledged, but are not acknowledged for AP transmissions "
1260 "and/or poor channel conditions", /* 34 */
1261 "Disassociated because STA is transmitting outside the limits "
1262 "of its TXOPs", /* 35 */
1263 "Requested from peer STA as the STA is leaving the BSS "
1264 "(or resetting)", /* 36 */
1265 "Requested from peer STA as it does not want to use the "
1266 "mechanism", /* 37 */
1267 "Requested from peer STA as the STA received frames using the "
1268 "mechanism for which a set up is required", /* 38 */
1269 "Requested from peer STA due to time out", /* 39 */
1270 "Reserved", /* 40 */
1271 "Reserved", /* 41 */
1272 "Reserved", /* 42 */
1273 "Reserved", /* 43 */
1274 "Reserved", /* 44 */
1275 "Peer STA does not support the requested cipher suite", /* 45 */
1276 "Association denied due to requesting STA not supporting HT "
1277 "features", /* 46 */
1279 #define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
1282 wep_print(netdissect_options
*ndo
,
1287 if (!ND_TTEST2(*p
, IEEE802_11_IV_LEN
+ IEEE802_11_KID_LEN
))
1289 iv
= EXTRACT_LE_32BITS(p
);
1291 ND_PRINT((ndo
, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv
), IV_PAD(iv
),
1298 parse_elements(netdissect_options
*ndo
,
1299 struct mgmt_body_t
*pbody
, const u_char
*p
, int offset
,
1304 struct challenge_t challenge
;
1305 struct rates_t rates
;
1311 * We haven't seen any elements yet.
1313 pbody
->challenge_present
= 0;
1314 pbody
->ssid_present
= 0;
1315 pbody
->rates_present
= 0;
1316 pbody
->ds_present
= 0;
1317 pbody
->cf_present
= 0;
1318 pbody
->tim_present
= 0;
1320 while (length
!= 0) {
1321 /* Make sure we at least have the element ID and length. */
1322 if (!ND_TTEST2(*(p
+ offset
), 2))
1326 elementlen
= *(p
+ offset
+ 1);
1328 /* Make sure we have the entire element. */
1329 if (!ND_TTEST2(*(p
+ offset
+ 2), elementlen
))
1331 if (length
< elementlen
+ 2)
1334 switch (*(p
+ offset
)) {
1336 memcpy(&ssid
, p
+ offset
, 2);
1339 if (ssid
.length
!= 0) {
1340 if (ssid
.length
> sizeof(ssid
.ssid
) - 1)
1342 if (!ND_TTEST2(*(p
+ offset
), ssid
.length
))
1344 if (length
< ssid
.length
)
1346 memcpy(&ssid
.ssid
, p
+ offset
, ssid
.length
);
1347 offset
+= ssid
.length
;
1348 length
-= ssid
.length
;
1350 ssid
.ssid
[ssid
.length
] = '\0';
1352 * Present and not truncated.
1354 * If we haven't already seen an SSID IE,
1355 * copy this one, otherwise ignore this one,
1356 * so we later report the first one we saw.
1358 if (!pbody
->ssid_present
) {
1360 pbody
->ssid_present
= 1;
1364 memcpy(&challenge
, p
+ offset
, 2);
1367 if (challenge
.length
!= 0) {
1368 if (challenge
.length
>
1369 sizeof(challenge
.text
) - 1)
1371 if (!ND_TTEST2(*(p
+ offset
), challenge
.length
))
1373 if (length
< challenge
.length
)
1375 memcpy(&challenge
.text
, p
+ offset
,
1377 offset
+= challenge
.length
;
1378 length
-= challenge
.length
;
1380 challenge
.text
[challenge
.length
] = '\0';
1382 * Present and not truncated.
1384 * If we haven't already seen a challenge IE,
1385 * copy this one, otherwise ignore this one,
1386 * so we later report the first one we saw.
1388 if (!pbody
->challenge_present
) {
1389 pbody
->challenge
= challenge
;
1390 pbody
->challenge_present
= 1;
1394 memcpy(&rates
, p
+ offset
, 2);
1397 if (rates
.length
!= 0) {
1398 if (rates
.length
> sizeof rates
.rate
)
1400 if (!ND_TTEST2(*(p
+ offset
), rates
.length
))
1402 if (length
< rates
.length
)
1404 memcpy(&rates
.rate
, p
+ offset
, rates
.length
);
1405 offset
+= rates
.length
;
1406 length
-= rates
.length
;
1409 * Present and not truncated.
1411 * If we haven't already seen a rates IE,
1412 * copy this one if it's not zero-length,
1413 * otherwise ignore this one, so we later
1414 * report the first one we saw.
1416 * We ignore zero-length rates IEs as some
1417 * devices seem to put a zero-length rates
1418 * IE, followed by an SSID IE, followed by
1419 * a non-zero-length rates IE into frames,
1420 * even though IEEE Std 802.11-2007 doesn't
1421 * seem to indicate that a zero-length rates
1424 if (!pbody
->rates_present
&& rates
.length
!= 0) {
1425 pbody
->rates
= rates
;
1426 pbody
->rates_present
= 1;
1430 memcpy(&ds
, p
+ offset
, 2);
1433 if (ds
.length
!= 1) {
1434 offset
+= ds
.length
;
1435 length
-= ds
.length
;
1438 ds
.channel
= *(p
+ offset
);
1442 * Present and not truncated.
1444 * If we haven't already seen a DS IE,
1445 * copy this one, otherwise ignore this one,
1446 * so we later report the first one we saw.
1448 if (!pbody
->ds_present
) {
1450 pbody
->ds_present
= 1;
1454 memcpy(&cf
, p
+ offset
, 2);
1457 if (cf
.length
!= 6) {
1458 offset
+= cf
.length
;
1459 length
-= cf
.length
;
1462 memcpy(&cf
.count
, p
+ offset
, 6);
1466 * Present and not truncated.
1468 * If we haven't already seen a CF IE,
1469 * copy this one, otherwise ignore this one,
1470 * so we later report the first one we saw.
1472 if (!pbody
->cf_present
) {
1474 pbody
->cf_present
= 1;
1478 memcpy(&tim
, p
+ offset
, 2);
1481 if (tim
.length
<= 3) {
1482 offset
+= tim
.length
;
1483 length
-= tim
.length
;
1486 if (tim
.length
- 3 > (int)sizeof tim
.bitmap
)
1488 memcpy(&tim
.count
, p
+ offset
, 3);
1492 memcpy(tim
.bitmap
, p
+ (tim
.length
- 3),
1494 offset
+= tim
.length
- 3;
1495 length
-= tim
.length
- 3;
1497 * Present and not truncated.
1499 * If we haven't already seen a TIM IE,
1500 * copy this one, otherwise ignore this one,
1501 * so we later report the first one we saw.
1503 if (!pbody
->tim_present
) {
1505 pbody
->tim_present
= 1;
1510 ND_PRINT((ndo
, "(1) unhandled element_id (%d) ",
1513 offset
+= 2 + elementlen
;
1514 length
-= 2 + elementlen
;
1519 /* No problems found. */
1523 /*********************************************************************************
1524 * Print Handle functions for the management frame types
1525 *********************************************************************************/
1528 handle_beacon(netdissect_options
*ndo
,
1529 const u_char
*p
, u_int length
)
1531 struct mgmt_body_t pbody
;
1535 memset(&pbody
, 0, sizeof(pbody
));
1537 if (!ND_TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1538 IEEE802_11_CAPINFO_LEN
))
1540 if (length
< IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1541 IEEE802_11_CAPINFO_LEN
)
1543 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
1544 offset
+= IEEE802_11_TSTAMP_LEN
;
1545 length
-= IEEE802_11_TSTAMP_LEN
;
1546 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
1547 offset
+= IEEE802_11_BCNINT_LEN
;
1548 length
-= IEEE802_11_BCNINT_LEN
;
1549 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
1550 offset
+= IEEE802_11_CAPINFO_LEN
;
1551 length
-= IEEE802_11_CAPINFO_LEN
;
1553 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1557 ND_PRINT((ndo
, " %s",
1558 CAPABILITY_ESS(pbody
.capability_info
) ? "ESS" : "IBSS"));
1559 PRINT_DS_CHANNEL(pbody
);
1565 handle_assoc_request(netdissect_options
*ndo
,
1566 const u_char
*p
, u_int length
)
1568 struct mgmt_body_t pbody
;
1572 memset(&pbody
, 0, sizeof(pbody
));
1574 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
))
1576 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
)
1578 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1579 offset
+= IEEE802_11_CAPINFO_LEN
;
1580 length
-= IEEE802_11_CAPINFO_LEN
;
1581 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
1582 offset
+= IEEE802_11_LISTENINT_LEN
;
1583 length
-= IEEE802_11_LISTENINT_LEN
;
1585 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1593 handle_assoc_response(netdissect_options
*ndo
,
1594 const u_char
*p
, u_int length
)
1596 struct mgmt_body_t pbody
;
1600 memset(&pbody
, 0, sizeof(pbody
));
1602 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
1603 IEEE802_11_AID_LEN
))
1605 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
1608 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1609 offset
+= IEEE802_11_CAPINFO_LEN
;
1610 length
-= IEEE802_11_CAPINFO_LEN
;
1611 pbody
.status_code
= EXTRACT_LE_16BITS(p
+offset
);
1612 offset
+= IEEE802_11_STATUS_LEN
;
1613 length
-= IEEE802_11_STATUS_LEN
;
1614 pbody
.aid
= EXTRACT_LE_16BITS(p
+offset
);
1615 offset
+= IEEE802_11_AID_LEN
;
1616 length
-= IEEE802_11_AID_LEN
;
1618 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1620 ND_PRINT((ndo
, " AID(%x) :%s: %s", ((uint16_t)(pbody
.aid
<< 2 )) >> 2 ,
1621 CAPABILITY_PRIVACY(pbody
.capability_info
) ? " PRIVACY " : "",
1622 (pbody
.status_code
< NUM_STATUSES
1623 ? status_text
[pbody
.status_code
]
1630 handle_reassoc_request(netdissect_options
*ndo
,
1631 const u_char
*p
, u_int length
)
1633 struct mgmt_body_t pbody
;
1637 memset(&pbody
, 0, sizeof(pbody
));
1639 if (!ND_TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
1642 if (length
< IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
1645 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
1646 offset
+= IEEE802_11_CAPINFO_LEN
;
1647 length
-= IEEE802_11_CAPINFO_LEN
;
1648 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
1649 offset
+= IEEE802_11_LISTENINT_LEN
;
1650 length
-= IEEE802_11_LISTENINT_LEN
;
1651 memcpy(&pbody
.ap
, p
+offset
, IEEE802_11_AP_LEN
);
1652 offset
+= IEEE802_11_AP_LEN
;
1653 length
-= IEEE802_11_AP_LEN
;
1655 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1658 ND_PRINT((ndo
, " AP : %s", etheraddr_string(ndo
, pbody
.ap
)));
1664 handle_reassoc_response(netdissect_options
*ndo
,
1665 const u_char
*p
, u_int length
)
1667 /* Same as a Association Reponse */
1668 return handle_assoc_response(ndo
, p
, length
);
1672 handle_probe_request(netdissect_options
*ndo
,
1673 const u_char
*p
, u_int length
)
1675 struct mgmt_body_t pbody
;
1679 memset(&pbody
, 0, sizeof(pbody
));
1681 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1690 handle_probe_response(netdissect_options
*ndo
,
1691 const u_char
*p
, u_int length
)
1693 struct mgmt_body_t pbody
;
1697 memset(&pbody
, 0, sizeof(pbody
));
1699 if (!ND_TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1700 IEEE802_11_CAPINFO_LEN
))
1702 if (length
< IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
1703 IEEE802_11_CAPINFO_LEN
)
1705 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
1706 offset
+= IEEE802_11_TSTAMP_LEN
;
1707 length
-= IEEE802_11_TSTAMP_LEN
;
1708 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
1709 offset
+= IEEE802_11_BCNINT_LEN
;
1710 length
-= IEEE802_11_BCNINT_LEN
;
1711 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
1712 offset
+= IEEE802_11_CAPINFO_LEN
;
1713 length
-= IEEE802_11_CAPINFO_LEN
;
1715 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1719 PRINT_DS_CHANNEL(pbody
);
1727 /* the frame body for ATIM is null. */
1732 handle_disassoc(netdissect_options
*ndo
,
1733 const u_char
*p
, u_int length
)
1735 struct mgmt_body_t pbody
;
1737 memset(&pbody
, 0, sizeof(pbody
));
1739 if (!ND_TTEST2(*p
, IEEE802_11_REASON_LEN
))
1741 if (length
< IEEE802_11_REASON_LEN
)
1743 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
1745 ND_PRINT((ndo
, ": %s",
1746 (pbody
.reason_code
< NUM_REASONS
)
1747 ? reason_text
[pbody
.reason_code
]
1754 handle_auth(netdissect_options
*ndo
,
1755 const u_char
*p
, u_int length
)
1757 struct mgmt_body_t pbody
;
1761 memset(&pbody
, 0, sizeof(pbody
));
1763 if (!ND_TTEST2(*p
, 6))
1767 pbody
.auth_alg
= EXTRACT_LE_16BITS(p
);
1770 pbody
.auth_trans_seq_num
= EXTRACT_LE_16BITS(p
+ offset
);
1773 pbody
.status_code
= EXTRACT_LE_16BITS(p
+ offset
);
1777 ret
= parse_elements(ndo
, &pbody
, p
, offset
, length
);
1779 if ((pbody
.auth_alg
== 1) &&
1780 ((pbody
.auth_trans_seq_num
== 2) ||
1781 (pbody
.auth_trans_seq_num
== 3))) {
1782 ND_PRINT((ndo
, " (%s)-%x [Challenge Text] %s",
1783 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
1784 ? auth_alg_text
[pbody
.auth_alg
]
1786 pbody
.auth_trans_seq_num
,
1787 ((pbody
.auth_trans_seq_num
% 2)
1788 ? ((pbody
.status_code
< NUM_STATUSES
)
1789 ? status_text
[pbody
.status_code
]
1793 ND_PRINT((ndo
, " (%s)-%x: %s",
1794 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
1795 ? auth_alg_text
[pbody
.auth_alg
]
1797 pbody
.auth_trans_seq_num
,
1798 (pbody
.auth_trans_seq_num
% 2)
1799 ? ((pbody
.status_code
< NUM_STATUSES
)
1800 ? status_text
[pbody
.status_code
]
1808 handle_deauth(netdissect_options
*ndo
,
1809 const struct mgmt_header_t
*pmh
, const u_char
*p
, u_int length
)
1811 struct mgmt_body_t pbody
;
1812 const char *reason
= NULL
;
1814 memset(&pbody
, 0, sizeof(pbody
));
1816 if (!ND_TTEST2(*p
, IEEE802_11_REASON_LEN
))
1818 if (length
< IEEE802_11_REASON_LEN
)
1820 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
1822 reason
= (pbody
.reason_code
< NUM_REASONS
)
1823 ? reason_text
[pbody
.reason_code
]
1826 if (ndo
->ndo_eflag
) {
1827 ND_PRINT((ndo
, ": %s", reason
));
1829 ND_PRINT((ndo
, " (%s): %s", etheraddr_string(ndo
, pmh
->sa
), reason
));
1834 #define PRINT_HT_ACTION(v) (\
1835 (v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \
1836 (v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \
1837 ND_PRINT((ndo, "Act#%d", (v))) \
1839 #define PRINT_BA_ACTION(v) (\
1840 (v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \
1841 (v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \
1842 (v) == 2 ? ND_PRINT((ndo, "DELBA")) : \
1843 ND_PRINT((ndo, "Act#%d", (v))) \
1845 #define PRINT_MESHLINK_ACTION(v) (\
1846 (v) == 0 ? ND_PRINT((ndo, "Request")) : \
1847 (v) == 1 ? ND_PRINT((ndo, "Report")) : \
1848 ND_PRINT((ndo, "Act#%d", (v))) \
1850 #define PRINT_MESHPEERING_ACTION(v) (\
1851 (v) == 0 ? ND_PRINT((ndo, "Open")) : \
1852 (v) == 1 ? ND_PRINT((ndo, "Confirm")) : \
1853 (v) == 2 ? ND_PRINT((ndo, "Close")) : \
1854 ND_PRINT((ndo, "Act#%d", (v))) \
1856 #define PRINT_MESHPATH_ACTION(v) (\
1857 (v) == 0 ? ND_PRINT((ndo, "Request")) : \
1858 (v) == 1 ? ND_PRINT((ndo, "Report")) : \
1859 (v) == 2 ? ND_PRINT((ndo, "Error")) : \
1860 (v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \
1861 ND_PRINT((ndo, "Act#%d", (v))) \
1864 #define PRINT_MESH_ACTION(v) (\
1865 (v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \
1866 (v) == 1 ? ND_PRINT((ndo, "HWMP")) : \
1867 (v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \
1868 (v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \
1869 (v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \
1870 (v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \
1871 (v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \
1872 (v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \
1873 (v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \
1874 (v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \
1875 (v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \
1876 ND_PRINT((ndo, "Act#%d", (v))) \
1878 #define PRINT_MULTIHOP_ACTION(v) (\
1879 (v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \
1880 (v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \
1881 ND_PRINT((ndo, "Act#%d", (v))) \
1883 #define PRINT_SELFPROT_ACTION(v) (\
1884 (v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \
1885 (v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \
1886 (v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \
1887 (v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \
1888 (v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \
1889 ND_PRINT((ndo, "Act#%d", (v))) \
1893 handle_action(netdissect_options
*ndo
,
1894 const struct mgmt_header_t
*pmh
, const u_char
*p
, u_int length
)
1896 if (!ND_TTEST2(*p
, 2))
1900 if (ndo
->ndo_eflag
) {
1901 ND_PRINT((ndo
, ": "));
1903 ND_PRINT((ndo
, " (%s): ", etheraddr_string(ndo
, pmh
->sa
)));
1906 case 0: ND_PRINT((ndo
, "Spectrum Management Act#%d", p
[1])); break;
1907 case 1: ND_PRINT((ndo
, "QoS Act#%d", p
[1])); break;
1908 case 2: ND_PRINT((ndo
, "DLS Act#%d", p
[1])); break;
1909 case 3: ND_PRINT((ndo
, "BA ")); PRINT_BA_ACTION(p
[1]); break;
1910 case 7: ND_PRINT((ndo
, "HT ")); PRINT_HT_ACTION(p
[1]); break;
1911 case 13: ND_PRINT((ndo
, "MeshAction ")); PRINT_MESH_ACTION(p
[1]); break;
1913 ND_PRINT((ndo
, "MultiohopAction "));
1914 PRINT_MULTIHOP_ACTION(p
[1]); break;
1916 ND_PRINT((ndo
, "SelfprotectAction "));
1917 PRINT_SELFPROT_ACTION(p
[1]); break;
1918 case 127: ND_PRINT((ndo
, "Vendor Act#%d", p
[1])); break;
1920 ND_PRINT((ndo
, "Reserved(%d) Act#%d", p
[0], p
[1]));
1927 /*********************************************************************************
1929 *********************************************************************************/
1933 mgmt_body_print(netdissect_options
*ndo
,
1934 uint16_t fc
, const struct mgmt_header_t
*pmh
,
1935 const u_char
*p
, u_int length
)
1937 ND_PRINT((ndo
, "%s", tok2str(st_str
, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc
))));
1938 switch (FC_SUBTYPE(fc
)) {
1939 case ST_ASSOC_REQUEST
:
1940 return handle_assoc_request(ndo
, p
, length
);
1941 case ST_ASSOC_RESPONSE
:
1942 return handle_assoc_response(ndo
, p
, length
);
1943 case ST_REASSOC_REQUEST
:
1944 return handle_reassoc_request(ndo
, p
, length
);
1945 case ST_REASSOC_RESPONSE
:
1946 return handle_reassoc_response(ndo
, p
, length
);
1947 case ST_PROBE_REQUEST
:
1948 return handle_probe_request(ndo
, p
, length
);
1949 case ST_PROBE_RESPONSE
:
1950 return handle_probe_response(ndo
, p
, length
);
1952 return handle_beacon(ndo
, p
, length
);
1954 return handle_atim();
1956 return handle_disassoc(ndo
, p
, length
);
1958 if (!ND_TTEST2(*p
, 3))
1960 if ((p
[0] == 0 ) && (p
[1] == 0) && (p
[2] == 0)) {
1961 ND_PRINT((ndo
, "Authentication (Shared-Key)-3 "));
1962 return wep_print(ndo
, p
);
1964 return handle_auth(ndo
, p
, length
);
1966 return handle_deauth(ndo
, pmh
, p
, length
);
1968 return handle_action(ndo
, pmh
, p
, length
);
1975 /*********************************************************************************
1976 * Handles printing all the control frame types
1977 *********************************************************************************/
1980 ctrl_body_print(netdissect_options
*ndo
,
1981 uint16_t fc
, const u_char
*p
)
1983 ND_PRINT((ndo
, "%s", tok2str(ctrl_str
, "Unknown Ctrl Subtype", FC_SUBTYPE(fc
))));
1984 switch (FC_SUBTYPE(fc
)) {
1985 case CTRL_CONTROL_WRAPPER
:
1986 /* XXX - requires special handling */
1989 if (!ND_TTEST2(*p
, CTRL_BAR_HDRLEN
))
1991 if (!ndo
->ndo_eflag
)
1992 ND_PRINT((ndo
, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
1993 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ra
),
1994 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ta
),
1995 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->ctl
)),
1996 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->seq
))));
1999 if (!ND_TTEST2(*p
, CTRL_BA_HDRLEN
))
2001 if (!ndo
->ndo_eflag
)
2002 ND_PRINT((ndo
, " RA:%s ",
2003 etheraddr_string(ndo
, ((const struct ctrl_ba_t
*)p
)->ra
)));
2006 if (!ND_TTEST2(*p
, CTRL_PS_POLL_HDRLEN
))
2008 ND_PRINT((ndo
, " AID(%x)",
2009 EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t
*)p
)->aid
))));
2012 if (!ND_TTEST2(*p
, CTRL_RTS_HDRLEN
))
2014 if (!ndo
->ndo_eflag
)
2015 ND_PRINT((ndo
, " TA:%s ",
2016 etheraddr_string(ndo
, ((const struct ctrl_rts_t
*)p
)->ta
)));
2019 if (!ND_TTEST2(*p
, CTRL_CTS_HDRLEN
))
2021 if (!ndo
->ndo_eflag
)
2022 ND_PRINT((ndo
, " RA:%s ",
2023 etheraddr_string(ndo
, ((const struct ctrl_cts_t
*)p
)->ra
)));
2026 if (!ND_TTEST2(*p
, CTRL_ACK_HDRLEN
))
2028 if (!ndo
->ndo_eflag
)
2029 ND_PRINT((ndo
, " RA:%s ",
2030 etheraddr_string(ndo
, ((const struct ctrl_ack_t
*)p
)->ra
)));
2033 if (!ND_TTEST2(*p
, CTRL_END_HDRLEN
))
2035 if (!ndo
->ndo_eflag
)
2036 ND_PRINT((ndo
, " RA:%s ",
2037 etheraddr_string(ndo
, ((const struct ctrl_end_t
*)p
)->ra
)));
2040 if (!ND_TTEST2(*p
, CTRL_END_ACK_HDRLEN
))
2042 if (!ndo
->ndo_eflag
)
2043 ND_PRINT((ndo
, " RA:%s ",
2044 etheraddr_string(ndo
, ((const struct ctrl_end_ack_t
*)p
)->ra
)));
2051 * Print Header funcs
2055 * Data Frame - Address field contents
2057 * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
2058 * 0 | 0 | DA | SA | BSSID | n/a
2059 * 0 | 1 | DA | BSSID | SA | n/a
2060 * 1 | 0 | BSSID | SA | DA | n/a
2061 * 1 | 1 | RA | TA | DA | SA
2065 data_header_print(netdissect_options
*ndo
,
2066 uint16_t fc
, const u_char
*p
, const uint8_t **srcp
,
2067 const uint8_t **dstp
)
2069 u_int subtype
= FC_SUBTYPE(fc
);
2071 if (DATA_FRAME_IS_CF_ACK(subtype
) || DATA_FRAME_IS_CF_POLL(subtype
) ||
2072 DATA_FRAME_IS_QOS(subtype
)) {
2073 ND_PRINT((ndo
, "CF "));
2074 if (DATA_FRAME_IS_CF_ACK(subtype
)) {
2075 if (DATA_FRAME_IS_CF_POLL(subtype
))
2076 ND_PRINT((ndo
, "Ack/Poll"));
2078 ND_PRINT((ndo
, "Ack"));
2080 if (DATA_FRAME_IS_CF_POLL(subtype
))
2081 ND_PRINT((ndo
, "Poll"));
2083 if (DATA_FRAME_IS_QOS(subtype
))
2084 ND_PRINT((ndo
, "+QoS"));
2085 ND_PRINT((ndo
, " "));
2088 #define ADDR1 (p + 4)
2089 #define ADDR2 (p + 10)
2090 #define ADDR3 (p + 16)
2091 #define ADDR4 (p + 24)
2093 if (!FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2098 if (!ndo
->ndo_eflag
)
2100 ND_PRINT((ndo
, "DA:%s SA:%s BSSID:%s ",
2101 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2102 etheraddr_string(ndo
, ADDR3
)));
2103 } else if (!FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2108 if (!ndo
->ndo_eflag
)
2110 ND_PRINT((ndo
, "DA:%s BSSID:%s SA:%s ",
2111 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2112 etheraddr_string(ndo
, ADDR3
)));
2113 } else if (FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
2118 if (!ndo
->ndo_eflag
)
2120 ND_PRINT((ndo
, "BSSID:%s SA:%s DA:%s ",
2121 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2122 etheraddr_string(ndo
, ADDR3
)));
2123 } else if (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
2128 if (!ndo
->ndo_eflag
)
2130 ND_PRINT((ndo
, "RA:%s TA:%s DA:%s SA:%s ",
2131 etheraddr_string(ndo
, ADDR1
), etheraddr_string(ndo
, ADDR2
),
2132 etheraddr_string(ndo
, ADDR3
), etheraddr_string(ndo
, ADDR4
)));
2142 mgmt_header_print(netdissect_options
*ndo
,
2143 const u_char
*p
, const uint8_t **srcp
, const uint8_t **dstp
)
2145 const struct mgmt_header_t
*hp
= (const struct mgmt_header_t
*) p
;
2151 if (!ndo
->ndo_eflag
)
2154 ND_PRINT((ndo
, "BSSID:%s DA:%s SA:%s ",
2155 etheraddr_string(ndo
, (hp
)->bssid
), etheraddr_string(ndo
, (hp
)->da
),
2156 etheraddr_string(ndo
, (hp
)->sa
)));
2160 ctrl_header_print(netdissect_options
*ndo
,
2161 uint16_t fc
, const u_char
*p
, const uint8_t **srcp
,
2162 const uint8_t **dstp
)
2168 if (!ndo
->ndo_eflag
)
2171 switch (FC_SUBTYPE(fc
)) {
2173 ND_PRINT((ndo
, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
2174 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ra
),
2175 etheraddr_string(ndo
, ((const struct ctrl_bar_t
*)p
)->ta
),
2176 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->ctl
)),
2177 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->seq
))));
2180 ND_PRINT((ndo
, "RA:%s ",
2181 etheraddr_string(ndo
, ((const struct ctrl_ba_t
*)p
)->ra
)));
2184 ND_PRINT((ndo
, "BSSID:%s TA:%s ",
2185 etheraddr_string(ndo
, ((const struct ctrl_ps_poll_t
*)p
)->bssid
),
2186 etheraddr_string(ndo
, ((const struct ctrl_ps_poll_t
*)p
)->ta
)));
2189 ND_PRINT((ndo
, "RA:%s TA:%s ",
2190 etheraddr_string(ndo
, ((const struct ctrl_rts_t
*)p
)->ra
),
2191 etheraddr_string(ndo
, ((const struct ctrl_rts_t
*)p
)->ta
)));
2194 ND_PRINT((ndo
, "RA:%s ",
2195 etheraddr_string(ndo
, ((const struct ctrl_cts_t
*)p
)->ra
)));
2198 ND_PRINT((ndo
, "RA:%s ",
2199 etheraddr_string(ndo
, ((const struct ctrl_ack_t
*)p
)->ra
)));
2202 ND_PRINT((ndo
, "RA:%s BSSID:%s ",
2203 etheraddr_string(ndo
, ((const struct ctrl_end_t
*)p
)->ra
),
2204 etheraddr_string(ndo
, ((const struct ctrl_end_t
*)p
)->bssid
)));
2207 ND_PRINT((ndo
, "RA:%s BSSID:%s ",
2208 etheraddr_string(ndo
, ((const struct ctrl_end_ack_t
*)p
)->ra
),
2209 etheraddr_string(ndo
, ((const struct ctrl_end_ack_t
*)p
)->bssid
)));
2212 ND_PRINT((ndo
, "(H) Unknown Ctrl Subtype"));
2218 extract_header_length(netdissect_options
*ndo
,
2223 switch (FC_TYPE(fc
)) {
2227 switch (FC_SUBTYPE(fc
)) {
2229 return CTRL_BAR_HDRLEN
;
2231 return CTRL_PS_POLL_HDRLEN
;
2233 return CTRL_RTS_HDRLEN
;
2235 return CTRL_CTS_HDRLEN
;
2237 return CTRL_ACK_HDRLEN
;
2239 return CTRL_END_HDRLEN
;
2241 return CTRL_END_ACK_HDRLEN
;
2246 len
= (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) ? 30 : 24;
2247 if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
)))
2251 ND_PRINT((ndo
, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc
)));
2257 extract_mesh_header_length(const u_char
*p
)
2259 return (p
[0] &~ 3) ? 0 : 6*(1 + (p
[0] & 3));
2263 * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
2264 * to point to the source and destination MAC addresses in any case if
2265 * "srcp" and "dstp" aren't null.
2268 ieee_802_11_hdr_print(netdissect_options
*ndo
,
2269 uint16_t fc
, const u_char
*p
, u_int hdrlen
,
2270 u_int meshdrlen
, const uint8_t **srcp
,
2271 const uint8_t **dstp
)
2273 if (ndo
->ndo_vflag
) {
2274 if (FC_MORE_DATA(fc
))
2275 ND_PRINT((ndo
, "More Data "));
2276 if (FC_MORE_FLAG(fc
))
2277 ND_PRINT((ndo
, "More Fragments "));
2278 if (FC_POWER_MGMT(fc
))
2279 ND_PRINT((ndo
, "Pwr Mgmt "));
2281 ND_PRINT((ndo
, "Retry "));
2283 ND_PRINT((ndo
, "Strictly Ordered "));
2285 ND_PRINT((ndo
, "WEP Encrypted "));
2286 if (FC_TYPE(fc
) != T_CTRL
|| FC_SUBTYPE(fc
) != CTRL_PS_POLL
)
2287 ND_PRINT((ndo
, "%dus ",
2289 &((const struct mgmt_header_t
*)p
)->duration
)));
2291 if (meshdrlen
!= 0) {
2292 const struct meshcntl_t
*mc
=
2293 (const struct meshcntl_t
*)&p
[hdrlen
- meshdrlen
];
2294 int ae
= mc
->flags
& 3;
2296 ND_PRINT((ndo
, "MeshData (AE %d TTL %u seq %u", ae
, mc
->ttl
,
2297 EXTRACT_LE_32BITS(mc
->seq
)));
2299 ND_PRINT((ndo
, " A4:%s", etheraddr_string(ndo
, mc
->addr4
)));
2301 ND_PRINT((ndo
, " A5:%s", etheraddr_string(ndo
, mc
->addr5
)));
2303 ND_PRINT((ndo
, " A6:%s", etheraddr_string(ndo
, mc
->addr6
)));
2304 ND_PRINT((ndo
, ") "));
2307 switch (FC_TYPE(fc
)) {
2309 mgmt_header_print(ndo
, p
, srcp
, dstp
);
2312 ctrl_header_print(ndo
, fc
, p
, srcp
, dstp
);
2315 data_header_print(ndo
, fc
, p
, srcp
, dstp
);
2318 ND_PRINT((ndo
, "(header) unknown IEEE802.11 frame type (%d)",
2327 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
2331 ieee802_11_print(netdissect_options
*ndo
,
2332 const u_char
*p
, u_int length
, u_int orig_caplen
, int pad
,
2336 u_int caplen
, hdrlen
, meshdrlen
;
2337 const uint8_t *src
, *dst
;
2338 u_short extracted_ethertype
;
2340 caplen
= orig_caplen
;
2341 /* Remove FCS, if present */
2342 if (length
< fcslen
) {
2343 ND_PRINT((ndo
, "%s", tstr
));
2347 if (caplen
> length
) {
2348 /* Amount of FCS in actual packet data, if any */
2349 fcslen
= caplen
- length
;
2351 ndo
->ndo_snapend
-= fcslen
;
2354 if (caplen
< IEEE802_11_FC_LEN
) {
2355 ND_PRINT((ndo
, "%s", tstr
));
2359 fc
= EXTRACT_LE_16BITS(p
);
2360 hdrlen
= extract_header_length(ndo
, fc
);
2362 hdrlen
= roundup2(hdrlen
, 4);
2363 if (ndo
->ndo_Hflag
&& FC_TYPE(fc
) == T_DATA
&&
2364 DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
))) {
2365 meshdrlen
= extract_mesh_header_length(p
+hdrlen
);
2366 hdrlen
+= meshdrlen
;
2371 if (caplen
< hdrlen
) {
2372 ND_PRINT((ndo
, "%s", tstr
));
2376 ieee_802_11_hdr_print(ndo
, fc
, p
, hdrlen
, meshdrlen
, &src
, &dst
);
2379 * Go past the 802.11 header.
2385 switch (FC_TYPE(fc
)) {
2387 if (!mgmt_body_print(ndo
, fc
,
2388 (const struct mgmt_header_t
*)(p
- hdrlen
), p
, length
)) {
2389 ND_PRINT((ndo
, "%s", tstr
));
2394 if (!ctrl_body_print(ndo
, fc
, p
- hdrlen
)) {
2395 ND_PRINT((ndo
, "%s", tstr
));
2400 if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc
)))
2401 return hdrlen
; /* no-data frame */
2402 /* There may be a problem w/ AP not having this bit set */
2404 if (!wep_print(ndo
, p
)) {
2405 ND_PRINT((ndo
, "%s", tstr
));
2408 } else if (llc_print(ndo
, p
, length
, caplen
, dst
, src
,
2409 &extracted_ethertype
) == 0) {
2411 * Some kinds of LLC packet we cannot
2412 * handle intelligently
2414 if (!ndo
->ndo_eflag
)
2415 ieee_802_11_hdr_print(ndo
, fc
, p
- hdrlen
, hdrlen
,
2416 meshdrlen
, NULL
, NULL
);
2417 if (extracted_ethertype
)
2418 ND_PRINT((ndo
, "(LLC %s) ",
2420 htons(extracted_ethertype
))));
2421 if (!ndo
->ndo_suppress_default_print
)
2422 ND_DEFAULTPRINT(p
, caplen
);
2426 ND_PRINT((ndo
, "unknown 802.11 frame type (%d)", FC_TYPE(fc
)));
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
);