new capture format

Gerald Britton gbritton
Wed Dec 25 19:43:17 PST 2002


I've completed an implementation of the new capture format included in
recent linux-wlan-ng.  It's attached.  This implements monitor_type 2
providing the new frame format with the arp type of ARPHRD_IEEE80211_PRISM,
The two frame types using this arp type place a unique 32bit word in the
first location of the packet, I used that value to determine which type is
used in an skb for the header_parse function and in my userspace code.

Merry Christmas.

				-- Gerald

-------------- next part --------------
diff -ruN hostap/driver/modules/hostap.c hostap.cap/driver/modules/hostap.c
--- hostap/driver/modules/hostap.c	2002-12-08 21:18:21.000000000 -0500
+++ hostap.cap/driver/modules/hostap.c	2002-12-25 20:55:52.000000000 -0500
@@ -596,8 +596,15 @@
 
 int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr)
 {
-	memcpy(haddr, skb->mac.raw + sizeof(struct linux_wlan_ng_prism_hdr) +
-	       10, ETH_ALEN); /* addr2 */
+	if (*(u32 *)skb->mac.raw == LWNG_CAP_DID_BASE) {
+		memcpy(haddr, skb->mac.raw +
+		       sizeof(struct linux_wlan_ng_prism_hdr) + 10,
+		       ETH_ALEN); /* addr2 */
+	} else { /* (*(u32 *)skb->mac.raw == htonl(LWNG_CAPHDR_VERSION)) */
+		memcpy(haddr, skb->mac.raw +
+		       sizeof(struct linux_wlan_ng_cap_hdr) + 10,
+		       ETH_ALEN); /* addr2 */
+	}
 	return ETH_ALEN;
 }
 
diff -ruN hostap/driver/modules/hostap_hw.c hostap.cap/driver/modules/hostap_hw.c
--- hostap/driver/modules/hostap_hw.c	2002-12-04 11:17:47.000000000 -0500
+++ hostap.cap/driver/modules/hostap_hw.c	2002-12-25 21:07:26.000000000 -0500
@@ -2079,6 +2079,7 @@
 static int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
 			   int type, char *extra, int extra_len)
 {
+	local_info_t *local = (local_info_t *) dev->priv;
 	int hdrlen, phdrlen, head_need, tail_need;
 	u16 len, fc;
 	int prism_header;
@@ -2091,7 +2092,18 @@
 	memcpy(&rxdesc, skb->data, sizeof(rxdesc));
 	skb_pull(skb, sizeof(rxdesc));
 
-	prism_header = dev->type == ARPHRD_IEEE80211_PRISM;
+	if (dev->type == ARPHRD_IEEE80211_PRISM) {
+		if (local->monitor_type == PRISM2_MONITOR_PRISM) {
+			prism_header = 1;
+			phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
+		} else { /* local->monitor_type == PRISM2_MONITOR_CAPHDR */
+			prism_header = 2;
+			phdrlen = sizeof(struct linux_wlan_ng_cap_hdr);
+		}
+	} else {
+		prism_header = 0;
+		phdrlen = 0;
+	}
 
 	fc = le16_to_cpu(rxdesc.frame_control);
 
@@ -2102,7 +2114,6 @@
 		return 0;
 	}
 
-	phdrlen = prism_header ? sizeof(struct linux_wlan_ng_prism_hdr) : 0;
 	hdrlen = hostap_80211_get_hdrlen(fc);
 
 	if (extra) {
@@ -2154,18 +2165,17 @@
 	 * the extra data */
 	memcpy(skb_push(skb, hdrlen), &rxdesc.frame_control, hdrlen);
 
-	if (prism_header) {
+	if (prism_header == 1) {
 		struct linux_wlan_ng_prism_hdr *hdr;
 		hdr = (struct linux_wlan_ng_prism_hdr *)
 			skb_push(skb, phdrlen);
 		memset(hdr, 0, phdrlen);
-#define LWNG_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
-		hdr->msgcode = LWNG_DID_BASE;
+		hdr->msgcode = LWNG_CAP_DID_BASE;
 		hdr->msglen = sizeof(*hdr);
 		memcpy(hdr->devname, dev->name, sizeof(hdr->devname));
 #define LWNG_SETVAL(f,i,s,l,d) \
-hdr->f.did = LWNG_DID_BASE | (i << 12); hdr->f.status = s; hdr->f.len = l; \
-hdr->f.data = d
+hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
+hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
 		LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
 		LWNG_SETVAL(mactime, 2, 0, 0, le32_to_cpu(rxdesc.time));
 		LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
@@ -2181,7 +2191,25 @@
 		LWNG_SETVAL(frmlen, 10, 0, 4, hdrlen + len);
 #endif /* PRISM2_ADD_BOGUS_CRC */
 #undef LWNG_SETVAL
-#undef LWNG_DID_BASE
+	} else if (prism_header == 2) {
+		struct linux_wlan_ng_cap_hdr *hdr;
+		hdr = (struct linux_wlan_ng_cap_hdr *)
+			skb_push(skb, phdrlen);
+		memset(hdr, 0, phdrlen);
+		hdr->version    = htonl(LWNG_CAPHDR_VERSION);
+		hdr->length     = htonl(phdrlen);
+		hdr->mactime    = __cpu_to_be64(rxdesc.time);
+		hdr->hosttime   = __cpu_to_be64(jiffies);
+		hdr->phytype    = htonl(4); /* dss_dot11_b */
+		hdr->channel    = htonl(0); /* unknown */
+		hdr->datarate   = htonl(rxdesc.rate);
+		hdr->antenna    = htonl(0); /* unknown */
+		hdr->priority   = htonl(0); /* unknown */
+		hdr->ssi_type   = htonl(3); /* raw */
+		hdr->ssi_signal = htonl(rxdesc.signal);
+		hdr->ssi_noise  = htonl(rxdesc.silence);
+		hdr->preamble   = htonl(0); /* unknown */
+		hdr->encoding   = htonl(1); /* cck */
 	}
 
 #ifdef PRISM2_ADD_BOGUS_CRC
diff -ruN hostap/driver/modules/hostap_ioctl.c hostap.cap/driver/modules/hostap_ioctl.c
--- hostap/driver/modules/hostap_ioctl.c	2002-12-08 03:54:53.000000000 -0500
+++ hostap.cap/driver/modules/hostap_ioctl.c	2002-12-25 21:10:12.000000000 -0500
@@ -731,7 +731,8 @@
 {
 	struct net_device *dev = local->dev;
 
-	if (local->monitor_type == PRISM2_MONITOR_PRISM) {
+	if (local->monitor_type == PRISM2_MONITOR_PRISM ||
+	    local->monitor_type == PRISM2_MONITOR_CAPHDR) {
 		dev->type = ARPHRD_IEEE80211_PRISM;
 		dev->hard_header_parse =
 			hostap_80211_prism_header_parse;
@@ -2094,6 +2095,7 @@
 
 	case PRISM2_PARAM_MONITOR_TYPE:
 		if (value != PRISM2_MONITOR_80211 &&
+		    value != PRISM2_MONITOR_CAPHDR &&
 		    value != PRISM2_MONITOR_PRISM) {
 			ret = -EINVAL;
 			break;
diff -ruN hostap/driver/modules/hostap_wlan.h hostap.cap/driver/modules/hostap_wlan.h
--- hostap/driver/modules/hostap_wlan.h	2002-12-03 22:56:55.000000000 -0500
+++ hostap.cap/driver/modules/hostap_wlan.h	2002-12-25 21:04:55.000000000 -0500
@@ -49,6 +49,25 @@
 		noise, rate, istx, frmlen;
 } __attribute__ ((packed));
 
+struct linux_wlan_ng_cap_hdr {
+	u32 version;
+	u32 length;
+	u64 mactime;
+	u64 hosttime;
+	u32 phytype;
+	u32 channel;
+	u32 datarate;
+	u32 antenna;
+	u32 priority;
+	u32 ssi_type;
+	s32 ssi_signal;
+	s32 ssi_noise;
+	u32 preamble;
+	u32 encoding;
+} __attribute__ ((packed));
+
+#define LWNG_CAP_DID_BASE   (4 | (1 << 6)) /* section 4, group 1 */
+#define LWNG_CAPHDR_VERSION 0x80211001
 
 struct hostap_ieee80211_hdr {
 	u16 frame_control;
@@ -1146,7 +1165,8 @@
 #endif /* WIRELESS_EXT > 13 */
 #endif /* WIRELESS_EXT */
 	enum {
-		PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1
+		PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
+		PRISM2_MONITOR_CAPHDR = 2
 	} monitor_type;
 	int (*saved_eth_header_parse)(struct sk_buff *skb,
 				      unsigned char *haddr);



More information about the Hostap mailing list