aboutsummaryrefslogtreecommitdiff
path: root/net/tcpdump
diff options
context:
space:
mode:
authorBruce M Simpson <bms@FreeBSD.org>2003-12-11 14:03:35 +0000
committerBruce M Simpson <bms@FreeBSD.org>2003-12-11 14:03:35 +0000
commit64b3fe8cd69a1f3d3328fabd3d4cd81be74e16ee (patch)
tree6ffc29180d4baffb866d7697ed1d1f51aa41038c /net/tcpdump
parent98ba269341928861a0d51263888b6fb4ecad941e (diff)
downloadports-64b3fe8cd69a1f3d3328fabd3d4cd81be74e16ee.tar.gz
ports-64b3fe8cd69a1f3d3328fabd3d4cd81be74e16ee.zip
Add a new option, WITH_RADIOTAP. Import David Young's patches for using the
new net80211 radiotap interface. This can be activated once the tcpdump port is built and installed using the datalink type IEEE802_11_RADIO. Tested with a wi(4), OEM PRISM2, 1.4.9 STA firmware. Submitted by: David Young Sponsored by: consume.net
Notes
Notes: svn path=/head/; revision=95600
Diffstat (limited to 'net/tcpdump')
-rw-r--r--net/tcpdump/Makefile9
-rw-r--r--net/tcpdump/files/extra-patch-Makefile.in20
-rw-r--r--net/tcpdump/files/extra-patch-cpack.c184
-rw-r--r--net/tcpdump/files/extra-patch-cpack.h56
-rw-r--r--net/tcpdump/files/extra-patch-extract.h15
-rw-r--r--net/tcpdump/files/extra-patch-ieee802_11_radio.h204
-rw-r--r--net/tcpdump/files/extra-patch-print-802_11.c229
-rw-r--r--net/tcpdump/files/extra-patch-tcpdump.c15
8 files changed, 732 insertions, 0 deletions
diff --git a/net/tcpdump/Makefile b/net/tcpdump/Makefile
index db7bc0698ca3..1ee23e841214 100644
--- a/net/tcpdump/Makefile
+++ b/net/tcpdump/Makefile
@@ -30,6 +30,15 @@ CONFIGURE_ARGS+= --enable-ipv6
CONFIGURE_ARGS+= --without-crypto
.endif
+.if defined(WITH_RADIOTAP)
+EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-Makefile.in \
+ ${PATCHDIR}/extra-patch-cpack.c \
+ ${PATCHDIR}/extra-patch-cpack.h \
+ ${PATCHDIR}/extra-patch-extract.h \
+ ${PATCHDIR}/extra-patch-ieee802_11_radio.h \
+ ${PATCHDIR}/extra-patch-print-802_11.c
+.endif
+
LOCALPCAPDIR= ${WRKDIR}/libpcap-0.8.1
LOCALPCAPFILES= include/pcap.h include/pcap-namedb.h include/pcap-bpf.h \
lib/libpcap.a
diff --git a/net/tcpdump/files/extra-patch-Makefile.in b/net/tcpdump/files/extra-patch-Makefile.in
new file mode 100644
index 000000000000..05d73d0c186c
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-Makefile.in
@@ -0,0 +1,20 @@
+--- Makefile.in.orig Mon Oct 27 10:13:45 2003
++++ Makefile.in Wed Dec 10 18:59:23 2003
+@@ -65,7 +65,7 @@
+ @rm -f $@
+ $(CC) $(CFLAGS) -c $(srcdir)/$*.c
+
+-CSRC = addrtoname.c gmpls.c gmt2local.c machdep.c parsenfsfh.c \
++CSRC = addrtoname.c cpack.c gmpls.c gmt2local.c machdep.c parsenfsfh.c \
+ print-802_11.c print-ah.c print-arcnet.c print-aodv.c \
+ print-arp.c print-ascii.c print-atalk.c print-atm.c \
+ print-beep.c print-bfd.c print-bgp.c print-bootp.c print-cdp.c \
+@@ -95,7 +95,7 @@
+ # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
+ # hack the extra indirection
+ OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) $(LIBOBJS)
+-HDR = addrtoname.h appletalk.h bootp.h decnet.h \
++HDR = addrtoname.h appletalk.h bootp.h cpack.h decnet.h \
+ ethertype.h extract.h fddi.h gmt2local.h igrp.h interface.h \
+ ipx.h llc.h machdep.h mib.h nfsfh.h nfsv2.h ntp.h ospf.h \
+ setsignal.h \
diff --git a/net/tcpdump/files/extra-patch-cpack.c b/net/tcpdump/files/extra-patch-cpack.c
new file mode 100644
index 000000000000..df8ba5e8f07a
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-cpack.c
@@ -0,0 +1,184 @@
+--- cpack.c.orig Wed Dec 10 18:44:31 2003
++++ cpack.c Thu Aug 14 01:25:27 2003
+@@ -0,0 +1,181 @@
++/*-
++ * Copyright (c) 2003, 2004 David Young. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. The name of David Young may not be used to endorse or promote
++ * products derived from this software without specific prior
++ * written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
++ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
++ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
++ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
++ * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
++ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
++ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
++ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
++ * OF SUCH DAMAGE.
++ */
++
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++
++#include <stdlib.h>
++#include <tcpdump-stdinc.h>
++
++#include "cpack.h"
++
++static u_char *
++cpack_next_boundary(u_char *p, size_t alignment)
++{
++ size_t misalignment = (u_int)p % alignment;
++
++ if (misalignment == 0)
++ return p;
++
++ return p + (alignment - misalignment);
++}
++
++/* Advance to the next wordsize boundary. Return NULL if fewer than
++ * wordsize bytes remain in the buffer after the boundary. Otherwise,
++ * return a pointer to the boundary.
++ */
++static u_char *
++cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
++{
++ u_char *next;
++
++ /* Ensure alignment. */
++ next = cpack_next_boundary(cs->c_next, wordsize);
++
++ /* Too little space for wordsize bytes? */
++ if (next - cs->c_buf + wordsize > cs->c_len)
++ return NULL;
++
++ return next;
++}
++
++int
++cpack_init_in(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
++{
++ memset(cs, 0, sizeof(*cs));
++ cs->c_mode = CPACK_MODE_UNPACK;
++ cs->c_buf = buf;
++ cs->c_len = buflen;
++ cs->c_next = cs->c_buf;
++
++ return 0;
++}
++
++int
++cpack_init_out(struct cpack_state *cs, size_t buflen, size_t max_alignment)
++{
++ u_int8_t *buf;
++ size_t len;
++
++ memset(cs, 0, sizeof(*cs));
++ cs->c_mode = CPACK_MODE_PACK;
++ len = buflen + max_alignment - 1;
++
++ if ((cs->c_buf = malloc(len)) == NULL)
++ return -1;
++
++ /* Correct alignment. */
++ buf = cpack_next_boundary(cs->c_buf, max_alignment);
++ cs->c_len = len - (buf - cs->c_buf);
++ cs->c_buf = buf;
++ cs->c_next = cs->c_buf;
++
++ return 0;
++}
++
++/* (Un)pack a 64-bit unsigned integer. */
++int
++cpack_uint64(struct cpack_state *cs, u_int64_t *u)
++{
++ u_char *next;
++
++ if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
++ return -1;
++
++ /* (Un)pack depending on mode. */
++ if (cs->c_mode == CPACK_MODE_PACK)
++ *(u_int64_t*)next = *u;
++ else
++ *u = *(u_int64_t*)next;
++
++ /* Move pointer past the u_int64_t. */
++ cs->c_next = next + sizeof(*u);
++ return 0;
++}
++
++/* (Un)pack a 32-bit unsigned integer. */
++int
++cpack_uint32(struct cpack_state *cs, u_int32_t *u)
++{
++ u_char *next;
++
++ if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
++ return -1;
++
++ /* (Un)pack depending on mode. */
++ if (cs->c_mode == CPACK_MODE_PACK)
++ *(u_int32_t*)next = *u;
++ else
++ *u = *(u_int32_t*)next;
++
++ /* Move pointer past the u_int32_t. */
++ cs->c_next = next + sizeof(*u);
++ return 0;
++}
++
++/* (Un)pack a 16-bit unsigned integer. */
++int
++cpack_uint16(struct cpack_state *cs, u_int16_t *u)
++{
++ u_char *next;
++
++ if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
++ return -1;
++
++ /* (Un)pack depending on mode. */
++ if (cs->c_mode == CPACK_MODE_PACK)
++ *(u_int16_t*)next = *u;
++ else
++ *u = *(u_int16_t*)next;
++
++ /* Move pointer past the u_int16_t. */
++ cs->c_next = next + sizeof(*u);
++ return 0;
++}
++
++/* (Un)pack an 8-bit unsigned integer. */
++int
++cpack_uint8(struct cpack_state *cs, u_int8_t *u)
++{
++ /* No space left? */
++ if (cs->c_next - cs->c_buf >= cs->c_len)
++ return -1;
++
++ /* (Un)pack depending on mode. */
++ if (cs->c_mode == CPACK_MODE_PACK)
++ *cs->c_next = *u;
++ else
++ *u = *cs->c_next;
++
++ /* Move pointer past the u_int8_t. */
++ cs->c_next++;
++ return 0;
++}
++
diff --git a/net/tcpdump/files/extra-patch-cpack.h b/net/tcpdump/files/extra-patch-cpack.h
new file mode 100644
index 000000000000..026a7686e234
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-cpack.h
@@ -0,0 +1,56 @@
+--- cpack.h.orig Wed Dec 10 18:44:34 2003
++++ cpack.h Tue Nov 25 04:08:43 2003
+@@ -0,0 +1,53 @@
++/*-
++ * Copyright (c) 2003, 2004 David Young. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. The name of David Young may not be used to endorse or promote
++ * products derived from this software without specific prior
++ * written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
++ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
++ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
++ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
++ * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
++ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
++ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
++ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
++ * OF SUCH DAMAGE.
++ */
++
++#ifndef _CPACK_H
++#define _CPACK_H
++
++struct cpack_state {
++ u_int8_t *c_buf;
++ u_int8_t *c_next;
++ size_t c_len;
++ enum {CPACK_MODE_PACK, CPACK_MODE_UNPACK} c_mode;
++};
++
++int cpack_init_in(struct cpack_state *, u_int8_t *, size_t);
++int cpack_init_out(struct cpack_state *, size_t, size_t);
++
++int cpack_uint8(struct cpack_state *, u_int8_t *);
++int cpack_uint16(struct cpack_state *, u_int16_t *);
++int cpack_uint32(struct cpack_state *, u_int32_t *);
++int cpack_uint64(struct cpack_state *, u_int64_t *);
++
++#define cpack_int8(s, i) cpack_uint8((s), (u_int8_t*)(i))
++#define cpack_int16(s, i) cpack_uint16((s), (u_int16_t*)(i))
++#define cpack_int32(s, i) cpack_uint32((s), (u_int32_t*)(i))
++#define cpack_int64(s, i) cpack_uint64((s), (u_int64_t*)(i))
++
++#endif /* _CPACK_H */
diff --git a/net/tcpdump/files/extra-patch-extract.h b/net/tcpdump/files/extra-patch-extract.h
new file mode 100644
index 000000000000..143a27c6fd36
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-extract.h
@@ -0,0 +1,15 @@
+--- extract.h.orig Wed Dec 11 07:13:51 2002
++++ extract.h Wed Dec 10 18:45:34 2003
+@@ -96,3 +96,12 @@
+ (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 0)))
++#define EXTRACT_LE_64BITS(p) \
++ ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 7) << 56 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 6) << 48 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 5) << 40 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 4) << 32 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 3) << 24 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 2) << 16 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 1) << 8 | \
++ (u_int64_t)*((const u_int8_t *)(p) + 0)))
diff --git a/net/tcpdump/files/extra-patch-ieee802_11_radio.h b/net/tcpdump/files/extra-patch-ieee802_11_radio.h
new file mode 100644
index 000000000000..7b229b0a2313
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-ieee802_11_radio.h
@@ -0,0 +1,204 @@
+--- ieee802_11_radio.h.orig Wed Dec 10 18:44:53 2003
++++ ieee802_11_radio.h Sun Nov 30 04:54:28 2003
+@@ -0,0 +1,201 @@
++/* $FreeBSD: /tmp/pcvs/ports/net/tcpdump/files/Attic/extra-patch-ieee802_11_radio.h,v 1.1 2003-12-11 14:03:35 bms Exp $ */
++/* $NetBSD: ieee80211_radiotap.h,v 1.3 2003/11/16 09:02:42 dyoung Exp $ */
++/* $Header$ */
++
++/*-
++ * Copyright (c) 2003, 2004 David Young. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. The name of David Young may not be used to endorse or promote
++ * products derived from this software without specific prior
++ * written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
++ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
++ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
++ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
++ * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
++ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
++ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
++ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
++ * OF SUCH DAMAGE.
++ */
++#ifndef _NET_IF_IEEE80211RADIOTAP_H_
++#define _NET_IF_IEEE80211RADIOTAP_H_
++
++/* A generic radio capture format is desirable. There is one for
++ * Linux, but it is neither rigidly defined (there were not even
++ * units given for some fields) nor easily extensible.
++ *
++ * I suggest the following extensible radio capture format. It is
++ * based on a bitmap indicating which fields are present.
++ *
++ * I am trying to describe precisely what the application programmer
++ * should expect in the following, and for that reason I tell the
++ * units and origin of each measurement (where it applies), or else I
++ * use sufficiently weaselly language ("is a monotonically nondecreasing
++ * function of...") that I cannot set false expectations for lawyerly
++ * readers.
++ */
++#ifdef _KERNEL
++#ifndef DLT_IEEE802_11_RADIO
++#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */
++#endif
++#endif /* _KERNEL */
++
++/* The radio capture header precedes the 802.11 header. */
++struct ieee80211_radiotap_header {
++ u_int8_t it_version; /* Version 0. Only increases
++ * for drastic changes,
++ * introduction of compatible
++ * new fields does not count.
++ */
++ u_int8_t it_pad;
++ u_int16_t it_len; /* length of the whole
++ * header in bytes, including
++ * it_version, it_pad,
++ * it_len, and data fields.
++ */
++ u_int32_t it_present; /* A bitmap telling which
++ * fields are present. Set bit 31
++ * (0x80000000) to extend the
++ * bitmap by another 32 bits.
++ * Additional extensions are made
++ * by setting bit 31.
++ */
++} __attribute__((__packed__));
++
++/* Name Data type Units
++ * ---- --------- -----
++ *
++ * IEEE80211_RADIOTAP_TSFT u_int64_t microseconds
++ *
++ * Value in microseconds of the MAC's 64-bit 802.11 Time
++ * Synchronization Function timer when the first bit of the
++ * MPDU arrived at the MAC. For received frames, only.
++ *
++ * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap
++ *
++ * Tx/Rx frequency in MHz, followed by flags (see below).
++ *
++ * IEEE80211_RADIOTAP_FHSS u_int16_t see below
++ *
++ * For frequency-hopping radios, the hop set (first byte)
++ * and pattern (second byte).
++ *
++ * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s
++ *
++ * Tx/Rx data rate
++ *
++ * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
++ * one milliwatt (dBm)
++ *
++ * RF signal power at the antenna, decibel difference from
++ * one milliwatt.
++ *
++ * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
++ * one milliwatt (dBm)
++ *
++ * RF noise power at the antenna, decibel difference from one
++ * milliwatt.
++ *
++ * IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB)
++ *
++ * RF signal power at the antenna, decibel difference from an
++ * arbitrary, fixed reference.
++ *
++ * IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB)
++ *
++ * RF noise power at the antenna, decibel difference from an
++ * arbitrary, fixed reference point.
++ *
++ * IEEE80211_RADIOTAP_BARKER_CODE_LOCK u_int16_t unitless
++ *
++ * Quality of Barker code lock. Unitless. Monotonically
++ * nondecreasing with "better" lock strength. Called "Signal
++ * Quality" in datasheets. (Is there a standard way to measure
++ * this?)
++ *
++ * IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless
++ *
++ * Transmit power expressed as unitless distance from max
++ * power set at factory calibration. 0 is max power.
++ * Monotonically nondecreasing with lower power levels.
++ *
++ * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB)
++ *
++ * Transmit power expressed as decibel distance from max power
++ * set at factory calibration. 0 is max power. Monotonically
++ * nondecreasing with lower power levels.
++ *
++ * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
++ * one milliwatt (dBm)
++ *
++ * Transmit power expressed as dBm (decibels from a 1 milliwatt
++ * reference). This is the absolute power level measured at
++ * the antenna port.
++ *
++ * IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap
++ *
++ * Properties of transmitted and received frames. See flags
++ * defined below.
++ *
++ * IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index
++ *
++ * Unitless indication of the Rx/Tx antenna for this packet.
++ * The first antenna is antenna 0.
++ */
++enum ieee80211_radiotap_type {
++ IEEE80211_RADIOTAP_TSFT = 0,
++ IEEE80211_RADIOTAP_FLAGS = 1,
++ IEEE80211_RADIOTAP_RATE = 2,
++ IEEE80211_RADIOTAP_CHANNEL = 3,
++ IEEE80211_RADIOTAP_FHSS = 4,
++ IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
++ IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
++ IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
++ IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
++ IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
++ IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
++ IEEE80211_RADIOTAP_ANTENNA = 11,
++ IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
++ IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
++ IEEE80211_RADIOTAP_EXT = 31
++};
++
++#ifndef _KERNEL
++/* Channel flags. */
++#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
++#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
++#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
++#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
++#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
++#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
++#endif /* !_KERNEL */
++
++/* For IEEE80211_RADIOTAP_FLAGS */
++#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
++ * during CFP
++ */
++#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
++ * with short
++ * preamble
++ */
++#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
++ * with WEP encryption
++ */
++#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
++ * with fragmentation
++ */
++
++#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
diff --git a/net/tcpdump/files/extra-patch-print-802_11.c b/net/tcpdump/files/extra-patch-print-802_11.c
new file mode 100644
index 000000000000..fecd4dbbd1a0
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-print-802_11.c
@@ -0,0 +1,229 @@
+--- print-802_11.c.orig Tue Jul 22 18:36:57 2003
++++ print-802_11.c Wed Dec 10 18:56:16 2003
+@@ -41,15 +41,20 @@
+
+ #include "extract.h"
+
++#include "cpack.h"
++
+ #include "ieee802_11.h"
++#include "ieee802_11_radio.h"
+
++#define PRINT_RATE(_sep, _r, _suf) \
++ printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
+ #define PRINT_RATES(p) \
+ do { \
+ int z; \
+ const char *sep = " ["; \
+ for (z = 0; z < p.rates.length ; z++) { \
+- printf("%s%2.1f", sep, (.5 * (p.rates.rate[z] & 0x7f))); \
+- if (p.rates.rate[z] & 0x80) printf("*"); \
++ PRINT_RATE(sep, p.rates.rate[z], \
++ (p.rates.rate[z] & 0x80 ? "*" : "")); \
+ sep = " "; \
+ } \
+ if (p.rates.length != 0) \
+@@ -924,9 +929,194 @@
+ return ieee802_11_print(p, h->len, h->caplen);
+ }
+
++static int
++print_radiotap_field(struct cpack_state *s, u_int32_t bit)
++{
++ union {
++ int8_t i8;
++ u_int8_t u8;
++ int16_t i16;
++ u_int16_t u16;
++ u_int32_t u32;
++ u_int64_t u64;
++ } u, u2;
++ int rc;
++
++ switch (bit) {
++ case IEEE80211_RADIOTAP_FLAGS:
++ case IEEE80211_RADIOTAP_RATE:
++ case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
++ case IEEE80211_RADIOTAP_DB_ANTNOISE:
++ case IEEE80211_RADIOTAP_ANTENNA:
++ rc = cpack_uint8(s, &u.u8);
++ break;
++ case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
++ case IEEE80211_RADIOTAP_DBM_ANTNOISE:
++ rc = cpack_int8(s, &u.i8);
++ break;
++ case IEEE80211_RADIOTAP_CHANNEL:
++ rc = cpack_uint16(s, &u.u16);
++ if (rc != 0)
++ break;
++ rc = cpack_uint16(s, &u2.u16);
++ break;
++ case IEEE80211_RADIOTAP_FHSS:
++ case IEEE80211_RADIOTAP_LOCK_QUALITY:
++ case IEEE80211_RADIOTAP_TX_ATTENUATION:
++ rc = cpack_uint16(s, &u.u16);
++ break;
++ case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
++ rc = cpack_uint8(s, &u.u8);
++ break;
++ case IEEE80211_RADIOTAP_DBM_TX_POWER:
++ rc = cpack_uint8(s, &u.i8);
++ break;
++ case IEEE80211_RADIOTAP_TSFT:
++ rc = cpack_uint64(s, &u.u64);
++ break;
++ default:
++ /* this bit indicates a field whose
++ * size we do not know, so we cannot
++ * proceed.
++ */
++ printf("[0x%08x] ", bit);
++ return -1;
++ }
++
++ if (rc != 0) {
++ printf("[|802.11]");
++ return rc;
++ }
++
++ switch (bit) {
++ case IEEE80211_RADIOTAP_CHANNEL:
++ printf("%u MHz ", u.u16);
++ if (u2.u16 != 0)
++ printf("(0x%04x) ", u2.u16);
++ break;
++ case IEEE80211_RADIOTAP_FHSS:
++ printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
++ break;
++ case IEEE80211_RADIOTAP_RATE:
++ PRINT_RATE("", u.u8, " Mb/s ");
++ break;
++ case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
++ printf("%ddB signal ", u.i8);
++ break;
++ case IEEE80211_RADIOTAP_DBM_ANTNOISE:
++ printf("%ddB noise ", u.i8);
++ break;
++ case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
++ printf("%ddB signal ", u.u8);
++ break;
++ case IEEE80211_RADIOTAP_DB_ANTNOISE:
++ printf("%ddB noise ", u.u8);
++ break;
++ case IEEE80211_RADIOTAP_LOCK_QUALITY:
++ printf("%u sq ", u.u16);
++ break;
++ case IEEE80211_RADIOTAP_TX_ATTENUATION:
++ printf("%d tx power ", -(int)u.u16);
++ break;
++ case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
++ printf("%ddB tx power ", -(int)u.u8);
++ break;
++ case IEEE80211_RADIOTAP_DBM_TX_POWER:
++ printf("%ddBm tx power ", u.i8);
++ break;
++ case IEEE80211_RADIOTAP_FLAGS:
++ if (u.u8 & IEEE80211_RADIOTAP_F_CFP)
++ printf("cfp ");
++ if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE)
++ printf("short preamble ");
++ if (u.u8 & IEEE80211_RADIOTAP_F_WEP)
++ printf("wep ");
++ if (u.u8 & IEEE80211_RADIOTAP_F_FRAG)
++ printf("fragmented ");
++ break;
++ case IEEE80211_RADIOTAP_ANTENNA:
++ printf("antenna %d ", u.u8);
++ break;
++ case IEEE80211_RADIOTAP_TSFT:
++ printf("%lldus tsft ", (long long)u.u64);
++ break;
++ }
++ return 0;
++}
++
+ static u_int
+ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
+ {
++#define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
++#define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
++#define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
++#define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
++#define BITNO_2(x) (((x) & 2) ? 1 : 0)
++#define BIT(n) (1 << n)
++
++ struct cpack_state cpacker;
++ struct ieee80211_radiotap_header *hdr;
++ u_int32_t present, next_present;
++ u_int32_t *presentp, *last_presentp;
++ enum ieee80211_radiotap_type bit;
++ int bit0;
++ const u_char *iter;
++
++ if (caplen < sizeof(*hdr)) {
++ printf("[|802.11]");
++ return caplen;
++ }
++
++ hdr = (struct ieee80211_radiotap_header *)p;
++
++ if (caplen < hdr->it_len) {
++ printf("[|802.11]");
++ return caplen;
++ }
++
++ for (last_presentp = &hdr->it_present;
++ (*last_presentp & BIT(IEEE80211_RADIOTAP_EXT)) != 0 &&
++ (u_char*)(last_presentp + 1) <= p + hdr->it_len;
++ last_presentp++);
++
++ /* are there more bitmap extensions than bytes in header? */
++ if ((*last_presentp & BIT(IEEE80211_RADIOTAP_EXT)) != 0) {
++ printf("[|802.11]");
++ return caplen;
++ }
++
++ iter = (u_char*)(last_presentp + 1);
++
++ cpack_init_in(&cpacker, (u_int8_t*)iter, hdr->it_len - (iter - p));
++
++ for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
++ presentp++, bit0 += 32) {
++ for (present = *presentp; present; present = next_present) {
++ /* clear the least significant bit that is set */
++ next_present = present & (present - 1);
++
++ /* extract the least significant bit that is set */
++ bit = bit0 + BITNO_32(present ^ next_present);
++
++ if (print_radiotap_field(&cpacker, bit) != 0)
++ goto out;
++ }
++ }
++out:
++
++ return hdr->it_len + ieee802_11_print(p + hdr->it_len,
++ length - hdr->it_len, caplen - hdr->it_len);
++#undef BITNO_32
++#undef BITNO_16
++#undef BITNO_8
++#undef BITNO_4
++#undef BITNO_2
++#undef BIT
++}
++
++static u_int
++ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
++{
+ u_int32_t caphdr_len;
+
+ caphdr_len = EXTRACT_32BITS(p + 4);
+@@ -977,7 +1167,7 @@
+ }
+
+ if (EXTRACT_32BITS(p) == WLANCAP_MAGIC_COOKIE_V1)
+- return ieee802_11_radio_print(p, length, caplen);
++ return ieee802_11_avs_radio_print(p, length, caplen);
+
+ if (caplen < PRISM_HDR_LEN) {
+ printf("[|802.11]");
diff --git a/net/tcpdump/files/extra-patch-tcpdump.c b/net/tcpdump/files/extra-patch-tcpdump.c
new file mode 100644
index 000000000000..27a98224c6f6
--- /dev/null
+++ b/net/tcpdump/files/extra-patch-tcpdump.c
@@ -0,0 +1,15 @@
+--- tcpdump.c.orig Wed Dec 10 19:04:45 2003
++++ tcpdump.c Wed Dec 10 19:09:25 2003
+@@ -69,6 +69,12 @@
+ #include "gmt2local.h"
+ #include "pcap-missing.h"
+
++/*
++ * XXX: quick and dirty until FreeBSD defines DLT_IEEE802_11_RADIO in
++ * <net/bpf.h>. -bms
++ */
++#include "ieee802_11_radio.h"
++
+ int dflag; /* print filter code */
+ int eflag; /* print ethernet header */
+ int fflag; /* don't translate "foreign" IP address */