Re: net80211+atheros changes (updated)

From: John Hay <jhay_at_icomtek.csir.co.za>
Date: Thu, 11 Nov 2004 07:51:15 +0200
> 
> Let's try this again:
> 
> http://people.freebsd.org/~sam/net80211+ath-20041015.tgz
> 
> This applys cleanly to -current as of last night, builds, and boots. 
> Beware of applying this over old patches as patch -N doesn't always seem 
> to do the right thing with the new files.  I tested against a clean cvs co.
> 

For those interested, here is a patch so that one can use Sam's patches
on 5.3 too.

John
-- 
John Hay -- John.Hay_at_icomtek.csir.co.za / jhay_at_FreeBSD.org


Index: sys/net/ethernet.h
===================================================================
RCS file: /home/ncvs/src/sys/net/ethernet.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- sys/net/ethernet.h	2 Jun 2004 21:34:14 -0000	1.23
+++ sys/net/ethernet.h	5 Oct 2004 19:28:52 -0000	1.24
_at__at_ -1,7 +1,7 _at__at_
 /*
  * Fundamental constants relating to ethernet.
  *
- * $FreeBSD: src/sys/net/ethernet.h,v 1.23 2004/06/02 21:34:14 naddy Exp $
+ * $FreeBSD: src/sys/net/ethernet.h,v 1.24 2004/10/05 19:28:52 sam Exp $
  *
  */
 
_at__at_ -319,6 +319,7 _at__at_
 #define	ETHERTYPE_PPPOEDISC	0x8863	/* PPP Over Ethernet Discovery Stage */
 #define	ETHERTYPE_PPPOE		0x8864	/* PPP Over Ethernet Session Stage */
 #define	ETHERTYPE_LANPROBE	0x8888	/* HP LanProbe test? */
+#define	ETHERTYPE_PAE		0x888e	/* EAPOL PAE/802.1x */
 #define	ETHERTYPE_LOOPBACK	0x9000	/* Loopback: used to test interfaces */
 #define	ETHERTYPE_LBACK		ETHERTYPE_LOOPBACK	/* DEC MOP loopback */
 #define	ETHERTYPE_XNSSM		0x9001	/* 3Com (Formerly Bridge Communications), XNS Systems Management */
Index: sys/net/route.h
===================================================================
RCS file: /home/ncvs/src/sys/net/route.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- sys/net/route.h	28 Jul 2004 06:51:33 -0000	1.61
+++ sys/net/route.h	5 Oct 2004 19:48:33 -0000	1.62
_at__at_ -27,7 +27,7 _at__at_
  * SUCH DAMAGE.
  *
  *	_at_(#)route.h	8.4 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/net/route.h,v 1.61 2004/07/28 06:51:33 kan Exp $
+ * $FreeBSD: src/sys/net/route.h,v 1.62 2004/10/05 19:48:33 sam Exp $
  */
 
 #ifndef _NET_ROUTE_H_
_at__at_ -219,6 +219,7 _at__at_
 #define	RTM_NEWMADDR	0xf	/* mcast group membership being added to if */
 #define	RTM_DELMADDR	0x10	/* mcast group membership being deleted */
 #define	RTM_IFANNOUNCE	0x11	/* iface arrival/departure */
+#define	RTM_IEEE80211	0x12	/* IEEE80211 wireless event */
 
 /*
  * Bitmask values for rtm_inits and rmx_locks.
_at__at_ -319,6 +320,7 _at__at_
 struct ifmultiaddr;
 
 int	 rt_getifa(struct rt_addrinfo *);
+void	 rt_ieee80211msg(struct ifnet *, int, void *, size_t);
 void	 rt_ifannouncemsg(struct ifnet *, int);
 void	 rt_ifmsg(struct ifnet *);
 void	 rt_missmsg(int, struct rt_addrinfo *, int, int);
Index: sys/net/rtsock.c
===================================================================
RCS file: /home/ncvs/src/sys/net/rtsock.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- sys/net/rtsock.c	27 Aug 2004 18:33:07 -0000	1.117
+++ sys/net/rtsock.c	5 Oct 2004 19:48:33 -0000	1.118
_at__at_ -27,7 +27,7 _at__at_
  * SUCH DAMAGE.
  *
  *	_at_(#)rtsock.c	8.7 (Berkeley) 10/12/95
- * $FreeBSD: src/sys/net/rtsock.c,v 1.117 2004/08/27 18:33:07 andre Exp $
+ * $FreeBSD: src/sys/net/rtsock.c,v 1.118 2004/10/05 19:48:33 sam Exp $
  */
 
 #include <sys/param.h>
_at__at_ -675,6 +675,7 _at__at_
 		break;
 
 	case RTM_IFANNOUNCE:
+	case RTM_IEEE80211:
 		len = sizeof(struct if_announcemsghdr);
 		break;
 
_at__at_ -932,6 +933,67 _at__at_
 	rt_dispatch(m, ifma->ifma_addr);
 }
 
+static struct mbuf *
+rt_makeifannouncemsg(struct ifnet *ifp, int type, int what,
+	struct rt_addrinfo *info)
+{
+	struct if_announcemsghdr *ifan;
+	struct mbuf *m;
+
+	if (route_cb.any_count == 0)
+		return NULL;
+	bzero((caddr_t)info, sizeof(*info));
+	m = rt_msg1(type, info);
+	if (m != NULL) {
+		ifan = mtod(m, struct if_announcemsghdr *);
+		ifan->ifan_index = ifp->if_index;
+		strlcpy(ifan->ifan_name, ifp->if_xname,
+			sizeof(ifan->ifan_name));
+		ifan->ifan_what = what;
+	}
+	return m;
+}
+
+/*
+ * This is called to generate routing socket messages indicating
+ * IEEE80211 wireless events.
+ * XXX we piggyback on the RTM_IFANNOUNCE msg format in a clumsy way.
+ */
+void
+rt_ieee80211msg(struct ifnet *ifp, int what, void *data, size_t data_len)
+{
+	struct mbuf *m;
+	struct rt_addrinfo info;
+
+	m = rt_makeifannouncemsg(ifp, RTM_IEEE80211, what, &info);
+	if (m != NULL) {
+		/*
+		 * Append the ieee80211 data.  Try to stick it in the
+		 * mbuf containing the ifannounce msg; otherwise allocate
+		 * a new mbuf and append.
+		 *
+		 * NB: we assume m is a single mbuf.
+		 */
+		if (data_len > M_TRAILINGSPACE(m)) {
+			struct mbuf *n = m_get(M_NOWAIT, MT_DATA);
+			if (n == NULL) {
+				m_freem(m);
+				return;
+			}
+			bcopy(data, mtod(n, void *), data_len);
+			n->m_len = data_len;
+			m->m_next = n;
+		} else if (data_len > 0) {
+			bcopy(data, mtod(m, u_int8_t *) + m->m_len, data_len);
+			m->m_len += data_len;
+		}
+		if (m->m_flags & M_PKTHDR)
+			m->m_pkthdr.len += data_len;
+		mtod(m, struct if_announcemsghdr *)->ifan_msglen += data_len;
+		rt_dispatch(m, NULL);
+	}
+}
+
 /*
  * This is called to generate routing socket messages indicating
  * network interface arrival and departure.
_at__at_ -939,22 +1001,13 _at__at_
 void
 rt_ifannouncemsg(struct ifnet *ifp, int what)
 {
-	struct if_announcemsghdr *ifan;
 	struct mbuf *m;
 	struct rt_addrinfo info;
 
-	if (route_cb.any_count == 0)
-		return;
-	bzero((caddr_t)&info, sizeof(info));
-	m = rt_msg1(RTM_IFANNOUNCE, &info);
-	if (m == NULL)
-		return;
-	ifan = mtod(m, struct if_announcemsghdr *);
-	ifan->ifan_index = ifp->if_index;
-	strlcpy(ifan->ifan_name, ifp->if_xname, sizeof(ifan->ifan_name));
-	ifan->ifan_what = what;
-	rt_dispatch(m, NULL);
- }
+	m = rt_makeifannouncemsg(ifp, RTM_IFANNOUNCE, what, &info);
+	if (m != NULL)
+		rt_dispatch(m, NULL);
+}
 
 static void
 rt_dispatch(struct mbuf *m, const struct sockaddr *sa)
Received on Thu Nov 11 2004 - 04:51:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:21 UTC