support the new capture header type.

This commit is contained in:
solomon 2002-11-01 20:43:46 +00:00
parent ef2f3ad094
commit ca5aa7a270
7 changed files with 290 additions and 63 deletions

View File

@ -41,6 +41,8 @@
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
- Add support for the new sniff frame capture.
- Get rid of some bitrot with the sniffing code.
- Populate the tx dropped frames statistics.
-pre5
- Fixes for host scan when not currently joined.

160
doc/capturefrm.txt Normal file
View File

@ -0,0 +1,160 @@
AVS Capture Frame Format
Version 2
1. Introduction
The original header format for "monitor mode" or capturing frames was
a considerable hack. The document covers a redesign of that format.
2. Frame Format
All sniff frames follow the same format:
Offset Name Size Description
--------------------------------------------------------------------
0 CaptureHeader AVS capture metadata header
56 802.11Header [10-30] 802.11 frame header
?? 802.11Payload [0-2312] 802.11 frame payload
?? 802.11FCS 4 802.11 frame check sequence
Note that the header and payload are variable length and the payload
may be empty.
3. Byte Order
All multibyte fields of the capture header are in "network" byte
order. The "host to network" and "network to host" functions should
work just fine. All the remaining multibyte fields are ordered
according to their respective standards.
4. Capture Header Format
The following fields make up the AVS capture header:
Offset Name Type
------------------------------
0 version uint32
4 length uint32
8 mactime uint64
16 hosttime uint64
24 phytype uint32
28 channel uint32
32 datarate uint32
36 antenna uint32
40 priority uint32
44 ssi_type uint32
48 ssi_signal int32
52 ssi_noise int32
56 preamble uint32
60 encoding uint32
------------------------------
64
The following subsections detail the fields of the capture header.
4.1 version
The version field identifies this type of frame as a subtype of
ETH_P_802111_CAPTURE as received by an ARPHRD_IEEE80211_PRISM or
an ARPHRD_IEEE80211_CAPTURE device. The value of this field shall be ???????
4.2 length
The length field contains the length of the entire AVS capture header,
in bytes.
4.3 mactime
Many WLAN devices supply a relatively high resolution frame reception
time value. This field contains the value supplied by the device. If
the device does not supply a receive time value, this field shall be
set to zero.
4.4 hosttime
The hosttime field is set to the current value of the host maintained
clock variable when the frame is received.
4.5 phytype
The phytype field identifies what type of PHY is employed by the WLAN
device used to capture this frame. The valid values are:
PhyType Value
----------------------------------
phytype_fhss_dot11_97 1
phytype_dsss_dot11_97 2
phytype_irbaseband 3
phytype_dsss_dot11_b 4
phytype_pbcc_dot11_b 5
phytype_ofdm_dot11_g 6
phytype_pbcc_dot11_g 7
phytype_ofdm_dot11_a 8
4.6 channel
For all PHY types except FH, this field is just an unsigned integer
and will be set to the current receiver channel number at the time
the frame was received. For frequency hopping radios, this field
is broken in to the following subfields:
Byte Subfield
------------------------
Byte0 Hop Set
Byte1 Hop Pattern
Byte2 Hop Index
Byte3 reserved
4.7 datarate
The data rate field contains the rate at which the frame was received
in units of 100kbps.
4.8 antenna
For WLAN devices that indicate the receive antenna for each frame, the
antenna field shall contain an index value into the dot11AntennaList.
If the device does not indicate a receive antenna value, this field
shall be set to zero.
4.9 priority
The priority field indicates the receive priority of the frame. The
value is in the range [0-15] with the value 0 reserved to indicate
contention period and the value 6 reserved to indicate contention free
period.
4.10 ssi_type
The ssi_type field is used to indicate what type of signal strength
information is present: "None", "Normalized RSSI" or "dBm". "None"
indicates that the underlying WLAN device does not supply any signal
strength at all and the ssi_* values are unset. "Normalized RSSI"
values are integers in the range [0-1000] where higher numbers
indicate stronger signal. "dBm" values indicate an actual signal
strength measurement quantity and are usually in the range [-108 - 10].
The following values indicate the three types:
Value Description
---------------------------------------------
0 None
1 Normalized RSSI
2 dBm
4.11 ssi_signal
The ssi_signal field contains the signal strength value reported by
the WLAN device for this frame. Note that this is a signed quantity
and if the ssi_type value is "dBm" that the value may be negative.
4.12 ssi_noise
The ssi_noise field contains the noise or "silence" value reported by
the WLAN device. This value is commonly defined to be the "signal
strength reported immediately prior to the baseband processor lock on
the frame preamble".
4.12 preamble
For PHYs that support variable preamble lengths, the preamble field
indicates the preamble type used for this frame. The values are:
Value Description
---------------------------------------------
0 Undefined
1 Short Preamble
2 Long Preamble
4.13 encoding
This specifies the encoding of the received packet. For PHYs that support
multiple encoding types, this will tell us which one was used.
Value Description
---------------------------------------------
0 Unknown
1 CCK
2 PBCC
3 OFDM

View File

@ -67,6 +67,7 @@
#define WLAN_MAX_ETHFRM_LEN 1514
#define WLAN_ETHHDR_LEN 14
#define P80211CAPTURE_VERSION 0x80211001
/*================================================================*/
/* Macros */
@ -75,6 +76,29 @@
/*================================================================*/
/* Types */
/*
* Frame capture header. (See doc/capturefrm.txt)
*/
__WLAN_PRAGMA_PACK1__
typedef struct p80211_caphdr
{
UINT32 version __WLAN_ATTRIB_PACK__;
UINT32 length __WLAN_ATTRIB_PACK__;
UINT64 mactime __WLAN_ATTRIB_PACK__;
UINT64 hosttime __WLAN_ATTRIB_PACK__;
UINT32 phytype __WLAN_ATTRIB_PACK__;
UINT32 channel __WLAN_ATTRIB_PACK__;
UINT32 datarate __WLAN_ATTRIB_PACK__;
UINT32 antenna __WLAN_ATTRIB_PACK__;
UINT32 priority __WLAN_ATTRIB_PACK__;
UINT32 ssi_type __WLAN_ATTRIB_PACK__;
INT32 ssi_signal __WLAN_ATTRIB_PACK__;
INT32 ssi_noise __WLAN_ATTRIB_PACK__;
UINT32 preamble __WLAN_ATTRIB_PACK__;
UINT32 encoding __WLAN_ATTRIB_PACK__;
} p80211_caphdr_t;
__WLAN_PRAGMA_PACKDFLT__
/* buffer free method pointer type */
typedef void (* freebuf_method_t)(void *buf, int size);

View File

@ -3966,7 +3966,6 @@ void hfa384x_int_rxmonitor( wlandevice_t *wlandev, UINT16 rxfid, hfa384x_rx_fram
UINT datalen = 0;
UINT skblen = 0;
UINT truncated = 0;
p80211msg_lnxind_wlansniffrm_t *msg;
UINT8 *datap;
UINT16 fc;
struct sk_buff *skb;
@ -4028,66 +4027,88 @@ void hfa384x_int_rxmonitor( wlandevice_t *wlandev, UINT16 rxfid, hfa384x_rx_fram
}
/* only prepend the prism header if in the right mode */
if (wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) {
datap = skb_put(skb, sizeof(p80211msg_lnxind_wlansniffrm_t));
msg = (p80211msg_lnxind_wlansniffrm_t*) datap;
if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
(hw->sniffhdr == 0)) {
p80211msg_lnxind_wlansniffrm_t *msg;
datap = skb_put(skb, sizeof(p80211msg_lnxind_wlansniffrm_t));
msg = (p80211msg_lnxind_wlansniffrm_t*) datap;
/* Initialize the message members */
msg->msgcode = DIDmsg_lnxind_wlansniffrm;
msg->msglen = sizeof(p80211msg_lnxind_wlansniffrm_t);
strcpy(msg->devname, wlandev->name);
msg->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
msg->hosttime.status = 0;
msg->hosttime.len = 4;
msg->hosttime.data = jiffies;
msg->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
msg->mactime.status = 0;
msg->mactime.len = 4;
msg->mactime.data = rxdesc->time;
msg->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
msg->channel.status = 0;
msg->channel.len = 4;
msg->channel.data = hw->sniff_channel;
msg->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
msg->rssi.status = P80211ENUM_msgitem_status_no_value;
msg->rssi.len = 4;
msg->rssi.data = 0;
msg->sq.did = DIDmsg_lnxind_wlansniffrm_sq;
msg->sq.status = P80211ENUM_msgitem_status_no_value;
msg->sq.len = 4;
msg->sq.data = 0;
msg->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
msg->signal.status = 0;
msg->signal.len = 4;
msg->signal.data = rxdesc->signal;
msg->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
msg->noise.status = 0;
msg->noise.len = 4;
msg->noise.data = rxdesc->silence;
msg->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
msg->rate.status = 0;
msg->rate.len = 4;
msg->rate.data = rxdesc->rate / 5; /* set to 802.11 units */
msg->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
msg->istx.status = 0;
msg->istx.len = 4;
msg->istx.data = P80211ENUM_truth_false;
msg->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
msg->frmlen.status = 0;
msg->frmlen.len = 4;
msg->frmlen.data = hdrlen + datalen + WLAN_CRC_LEN;
}
/* Initialize the message members */
msg->msgcode = DIDmsg_lnxind_wlansniffrm;
msg->msglen = sizeof(p80211msg_lnxind_wlansniffrm_t);
strcpy(msg->devname, wlandev->name);
msg->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
msg->hosttime.status = 0;
msg->hosttime.len = 4;
msg->hosttime.data = jiffies;
msg->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
msg->mactime.status = 0;
msg->mactime.len = 4;
msg->mactime.data = rxdesc->time;
msg->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
msg->channel.status = 0;
msg->channel.len = 4;
msg->channel.data = hw->sniff_channel;
msg->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
msg->rssi.status = P80211ENUM_msgitem_status_no_value;
msg->rssi.len = 4;
msg->rssi.data = 0;
msg->sq.did = DIDmsg_lnxind_wlansniffrm_sq;
msg->sq.status = P80211ENUM_msgitem_status_no_value;
msg->sq.len = 4;
msg->sq.data = 0;
msg->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
msg->signal.status = 0;
msg->signal.len = 4;
msg->signal.data = rxdesc->signal;
msg->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
msg->noise.status = 0;
msg->noise.len = 4;
msg->noise.data = rxdesc->silence;
msg->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
msg->rate.status = 0;
msg->rate.len = 4;
msg->rate.data = rxdesc->rate / 5; /* set to 802.11 units */
msg->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
msg->istx.status = 0;
msg->istx.len = 4;
msg->istx.data = P80211ENUM_truth_false;
msg->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
msg->frmlen.status = 0;
msg->frmlen.len = 4;
msg->frmlen.data = hdrlen + datalen + WLAN_CRC_LEN;
} else if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
(hw->sniffhdr != 0)) {
p80211_caphdr_t *caphdr;
/* The NEW header format! */
datap = skb_put(skb, sizeof(p80211_caphdr_t));
caphdr = (p80211_caphdr_t*) datap;
caphdr->version = htonl(P80211CAPTURE_VERSION);
caphdr->length = htonl(sizeof(p80211_caphdr_t));
caphdr->mactime = __cpu_to_be64(hfa384x2host_32(rxdesc->time));
caphdr->hosttime = __cpu_to_be64(jiffies);
caphdr->phytype = htonl(4); /* dss_dot11_b */
caphdr->channel = htonl(hw->sniff_channel);
caphdr->datarate = htonl(rxdesc->rate);
caphdr->antenna = htonl(0); /* unknown */
caphdr->priority = htonl(0); /* unknown */
caphdr->ssi_type = htonl(3); /* rssi_raw */
caphdr->ssi_signal = htonl(rxdesc->signal);
caphdr->ssi_noise = htonl(rxdesc->silence);
caphdr->preamble = htonl(0); /* unknown */
caphdr->encoding = htonl(1); /* cck */
}
/* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */
datap = skb_put(skb, hdrlen);
memcpy( datap, &(rxdesc->frame_control), hdrlen);

View File

@ -3014,10 +3014,15 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
}
/* Set the driver state */
/* Do we want the prism2 header? */
if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true))
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
else
wlandev->netdev->type = ARPHRD_IEEE80211;
if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 0;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else if ((msg->wlanheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->wlanheader.data == P80211ENUM_truth_true)) {
hw->sniffhdr = 1;
wlandev->netdev->type = ARPHRD_IEEE80211_PRISM;
} else {
wlandev->netdev->type = ARPHRD_IEEE80211;
}
msg->resultcode.data = P80211ENUM_resultcode_success;
result = 0;

View File

@ -2400,6 +2400,7 @@ typedef struct hfa384x
int sniff_fcs;
int sniff_channel;
int sniff_truncate;
int sniffhdr;
wait_queue_head_t cmdq; /* wait queue itself */

View File

@ -2810,6 +2810,20 @@ p80211meta_t MKREQMETANAME(lnxreq_wlansniff)[] = {
/* fromtextptr */ p80211_fromtext_enumint,
/* validfunptr */ p80211_isvalid_enumint
},
{
/* name */ MKITEMNAME("wlanheader"),
/* did */ 0,
/* flags */ P80211ITEM_SETFLAGS(0UL, ISREQUEST, 0UL),
/* min */ 0,
/* max */ 0,
/* maxlen */ 0,
/* minlen */ 0,
/* enumptr */ &MKENUMNAME(truth),
/* collptr */ NULL,
/* totextptr */ p80211_totext_enumint,
/* fromtextptr */ p80211_fromtext_enumint,
/* validfunptr */ p80211_isvalid_enumint
},
{
/* name */ MKITEMNAME("keepwepflags"),
/* did */ 0,