Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Aug 2012 17:47:58 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r239659 - user/adrian/ath_radar_stuff/lib/libradarpkt
Message-ID:  <201208241747.q7OHlwPF078962@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Fri Aug 24 17:47:58 2012
New Revision: 239659
URL: http://svn.freebsd.org/changeset/base/239659

Log:
  * Add AR5212 radar parsing code
  * Due to API changes, ieee80211.h is now required.

Added:
  user/adrian/ath_radar_stuff/lib/libradarpkt/ar5212_radar.c   (contents, props changed)
  user/adrian/ath_radar_stuff/lib/libradarpkt/ar5212_radar.h   (contents, props changed)
Modified:
  user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile
  user/adrian/ath_radar_stuff/lib/libradarpkt/ar5416_radar.c
  user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c

Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile
==============================================================================
--- user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile	Fri Aug 24 17:39:57 2012	(r239658)
+++ user/adrian/ath_radar_stuff/lib/libradarpkt/Makefile	Fri Aug 24 17:47:58 2012	(r239659)
@@ -1,6 +1,6 @@
 LIB=	radarpkt
 
-SRCS=	ar9280_radar.c ar5416_radar.c
+SRCS=	ar5212_radar.c ar9280_radar.c ar5416_radar.c
 
 # Define 'ATH_ENABLE_RADIOTAP_VENDOR_EXT' as it's not enabled by default
 # in the configuration file.  Ideally this would just fake an "opt_ath.h"

Added: user/adrian/ath_radar_stuff/lib/libradarpkt/ar5212_radar.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar5212_radar.c	Fri Aug 24 17:47:58 2012	(r239659)
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2012 Adrian Chadd
+ * 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,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/endian.h>
+#include <string.h>	/* for memcpy() */
+
+/* Headers required for the ioctl interface */
+#include <sys/socket.h>
+#include <net/if.h>
+#include <sys/queue.h>
+
+#include "net80211/ieee80211.h"
+#include "net80211/ieee80211_radiotap.h"
+
+#include "dev/ath/if_athioctl.h"
+
+#include "pkt.h"
+
+#include "ar5212_radar.h"
+
+int
+ar5212_radar_decode(struct ieee80211_radiotap_header *rh,
+    const unsigned char *pkt, int len, struct radar_entry *re)
+{
+	uint64_t tsf;
+	int8_t rssi, nf;
+	struct ath_rx_radiotap_header *rx =
+	    (struct ath_rx_radiotap_header *) rh;
+
+	/* XXX we should really be implementing a real radiotap parser */
+	tsf = le64toh(rx->wr_tsf);
+
+	rssi = rx->wr_v.vh_rssi;
+	nf = rx->wr_antnoise;
+
+	/* Last byte is the pulse width */
+	if (len < 1) {
+		printf("short radar frame\n");
+		return (0);
+	}
+
+#if 0
+	printf("phyerr: %d ", rx->wr_v.vh_phyerr_code);
+	printf("ts: %lld", tsf);
+	printf("\tit_present: %x", le32toh(rh->it_present));
+	printf("\tlen: %d", len);
+	printf("\trssi: %d, nf: %d", rssi, nf);
+	printf("\tpri: %u", pkt[len - 1] & 0xff);
+	printf("\n");
+#endif
+
+	/*
+	 * If RSSI > 0x80, it's a negative RSSI. We store it signed
+	 * so we can at least log that it was negative in order to
+	 * plot it. The radar code IIRC just tosses it.
+	 */
+	re->re_rssi = rssi;
+
+	/*
+	 * XXX TODO:
+	 *
+	 * The radar event is timestamped by the MAC the end of the event.
+	 * To work around this particular issue, a "best guess" of the event
+	 * start time involves its duration.
+	 */
+
+	re->re_timestamp = tsf;
+	/* XXX TODO: re->re_freq */
+	re->re_dur = pkt[len - 1] & 0xff;
+	/* XXX TODO: also store ctl/ext RSSI, and some flags */
+	re->re_freq = 0;
+
+	return(1);
+}

Added: user/adrian/ath_radar_stuff/lib/libradarpkt/ar5212_radar.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar5212_radar.h	Fri Aug 24 17:47:58 2012	(r239659)
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2012 Adrian Chadd
+ * 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,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#ifndef	__AR5212_RADAR_H__
+#define	__AR5212_RADAR_H__
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define	CHIP_AR5212		3
+
+extern	int ar5212_radar_decode(struct ieee80211_radiotap_header *rh,
+	const unsigned char *pkt, int len, struct radar_entry *re);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* __AR5212_RADAR__ */

Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar5416_radar.c
==============================================================================
--- user/adrian/ath_radar_stuff/lib/libradarpkt/ar5416_radar.c	Fri Aug 24 17:39:57 2012	(r239658)
+++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar5416_radar.c	Fri Aug 24 17:47:58 2012	(r239659)
@@ -39,7 +39,7 @@
 #include <net/if.h>
 #include <sys/queue.h>
 
-//#include "net80211/ieee80211_var.h"
+#include "net80211/ieee80211.h"
 #include "net80211/ieee80211_radiotap.h"
 
 #include "dev/ath/if_athioctl.h"

Modified: user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c
==============================================================================
--- user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c	Fri Aug 24 17:39:57 2012	(r239658)
+++ user/adrian/ath_radar_stuff/lib/libradarpkt/ar9280_radar.c	Fri Aug 24 17:47:58 2012	(r239659)
@@ -37,6 +37,7 @@
 #include <sys/socket.h>
 #include <net/if.h>
 
+#include "net80211/ieee80211.h"
 #include "net80211/ieee80211_radiotap.h"
 
 #include "dev/ath/if_athioctl.h"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208241747.q7OHlwPF078962>