First pass at converting the net80211 infrastrcture from FreeBSD.
[dragonfly.git] / sys / netproto / 802_11 / ieee80211_dragonfly.h
index bc5c2fb..2e8355a 100644 (file)
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
+/*-
+ * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -10,8 +10,6 @@
  * 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 the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/net80211/ieee80211_freebsd.h,v 1.5.2.1 2005/09/03 22:40:02 sam Exp $
- * $DragonFly: src/sys/netproto/802_11/ieee80211_dragonfly.h,v 1.4 2007/08/22 13:24:44 sephe Exp $
+ * $FreeBSD: head/sys/net80211/ieee80211_freebsd.h 195618 2009-07-11 15:02:45Z rpaulo $
+ * $DragonFly$
  */
 #ifndef _NET80211_IEEE80211_DRAGONFLY_H_
 #define _NET80211_IEEE80211_DRAGONFLY_H_
 
+#ifdef _KERNEL
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/lock.h>
+#include <sys/mutex2.h>
+#include <sys/sysctl.h>
+#include <sys/taskqueue.h>
+
 /*
- * Per-node power-save queue definitions. 
+ * Common state locking definitions.
  */
-#define        IEEE80211_NODE_SAVEQ_INIT(_ni, _name) do {              \
-       (_ni)->ni_savedq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE;   \
+typedef struct {
+       char            name[16];               /* e.g. "ath0_com_lock" */
+       struct lock     lock;
+} ieee80211_com_lock_t;
+#define        IEEE80211_LOCK_INIT(_ic, _name) do {                            \
+       ieee80211_com_lock_t *cl = &(_ic)->ic_comlock;                  \
+       ksnprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name);    \
+       lockinit(&cl->lock, cl->name, 0, LK_CANRECURSE);                \
 } while (0)
-#define        IEEE80211_NODE_SAVEQ_DESTROY(_ni)       ((void)0)
-#define        IEEE80211_NODE_SAVEQ_QLEN(_ni)          IF_QLEN(&(_ni)->ni_savedq)
-#define        IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _m, _qlen) do {       \
-       IF_DEQUEUE(&(_ni)->ni_savedq, _m);                      \
-       (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni);               \
+#define        IEEE80211_LOCK_OBJ(_ic) (&(_ic)->ic_comlock.lock)
+#define        IEEE80211_LOCK_DESTROY(_ic) lockuninit(IEEE80211_LOCK_OBJ(_ic))
+#define        IEEE80211_LOCK(_ic) \
+       lockmgr(IEEE80211_LOCK_OBJ(_ic), LK_EXCLUSIVE)
+#define        IEEE80211_UNLOCK(_ic)      lockmgr(IEEE80211_LOCK_OBJ(_ic), LK_RELEASE)
+#define        IEEE80211_LOCK_ASSERT(_ic) \
+       KKASSERT(lockstatus(IEEE80211_LOCK_OBJ(_ic), curthread) == LK_EXCLUSIVE)
+
+/*
+ * Node locking definitions.
+ */
+typedef struct {
+       char            name[16];               /* e.g. "ath0_node_lock" */
+       struct lock     lock;
+} ieee80211_node_lock_t;
+#define        IEEE80211_NODE_LOCK_INIT(_nt, _name) do {                       \
+       ieee80211_node_lock_t *nl = &(_nt)->nt_nodelock;                \
+       ksnprintf(nl->name, sizeof(nl->name), "%s_node_lock", _name);   \
+       lockinit(&nl->lock, nl->name, 0, LK_CANRECURSE);                \
 } while (0)
-#define        IEEE80211_NODE_SAVEQ_DRAIN(_ni, _qlen) do {             \
-       (_qlen) = IEEE80211_NODE_SAVEQ_QLEN(_ni);               \
-       IF_DRAIN(&(_ni)->ni_savedq);                            \
+#define        IEEE80211_NODE_LOCK_OBJ(_nt)    (&(_nt)->nt_nodelock.lock)
+#define        IEEE80211_NODE_LOCK_DESTROY(_nt) \
+       lockuninit(IEEE80211_NODE_LOCK_OBJ(_nt))
+#define        IEEE80211_NODE_LOCK(_nt) \
+       lockmgr(IEEE80211_NODE_LOCK_OBJ(_nt), LK_EXCLUSIVE)
+#define        IEEE80211_NODE_IS_LOCKED(_nt) \
+       (lockstatus(IEEE80211_NODE_LOCK_OBJ(_nt), curthread) == LK_EXCLUSIVE)
+#define        IEEE80211_NODE_UNLOCK(_nt) \
+       lockmgr(IEEE80211_NODE_LOCK_OBJ(_nt), LK_RELEASE)
+#define        IEEE80211_NODE_LOCK_ASSERT(_nt) \
+       KKASSERT(lockstatus(IEEE80211_NODE_LOCK_OBJ(_nt), curthread) \
+           == LK_EXCLUSIVE)
+
+/*
+ * Node table iteration locking definitions; this protects the
+ * scan generation # used to iterate over the station table
+ * while grabbing+releasing the node lock.
+ */
+typedef struct {
+       char            name[16];               /* e.g. "ath0_scan_lock" */
+       struct lock     lock;
+} ieee80211_scan_lock_t;
+#define        IEEE80211_NODE_ITERATE_LOCK_INIT(_nt, _name) do {               \
+       ieee80211_scan_lock_t *sl = &(_nt)->nt_scanlock;                \
+       ksnprintf(sl->name, sizeof(sl->name), "%s_scan_lock", _name);   \
+       lockinit(&sl->lock, sl->name, 0, 0);                            \
 } while (0)
-/* XXX could be optimized */
-#define        _IEEE80211_NODE_SAVEQ_DEQUEUE_HEAD(_ni, _m) do {        \
-       IF_DEQUEUE(&(_ni)->ni_savedq, m);                       \
+#define        IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt)    (&(_nt)->nt_scanlock.lock)
+#define        IEEE80211_NODE_ITERATE_LOCK_DESTROY(_nt) \
+       lockuninit(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
+#define        IEEE80211_NODE_ITERATE_LOCK(_nt) \
+       lockmgr(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt), LK_EXCLUSIVE)
+#define        IEEE80211_NODE_ITERATE_UNLOCK(_nt) \
+       lockmgr(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt), LK_RELEASE)
+
+/*
+ * Power-save queue definitions. 
+ */
+typedef struct lock ieee80211_psq_lock_t;
+#define        IEEE80211_PSQ_INIT(_psq, _name) \
+       lockinit(&(_psq)->psq_lock, _name, 0, 0)
+#define        IEEE80211_PSQ_DESTROY(_psq)     lockuninit(&(_psq)->psq_lock)
+#define        IEEE80211_PSQ_LOCK(_psq)        lockmgr(&(_psq)->psq_lock, LK_EXCLUSIVE)
+#define        IEEE80211_PSQ_UNLOCK(_psq)      lockmgr(&(_psq)->psq_lock, LK_RELEASE)
+
+#ifndef IF_PREPEND_LIST
+#define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {       \
+       (mtail)->m_nextpkt = (ifq)->ifq_head;                   \
+       if ((ifq)->ifq_tail == NULL)                            \
+               (ifq)->ifq_tail = (mtail);                      \
+       (ifq)->ifq_head = (mhead);                              \
+       (ifq)->ifq_len += (mcount);                             \
 } while (0)
-#define        _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _m, _qlen, _age) do {\
-       (_m)->m_nextpkt = NULL;                                 \
-       if ((_ni)->ni_savedq.ifq_tail != NULL) {                \
-               _age -= M_AGE_GET((_ni)->ni_savedq.ifq_tail);   \
-               (_ni)->ni_savedq.ifq_tail->m_nextpkt = (_m);    \
-       } else {                                                \
-               (_ni)->ni_savedq.ifq_head = (_m);               \
-       }                                                       \
-       M_AGE_SET(_m, _age);                                    \
-       (_ni)->ni_savedq.ifq_tail = (_m);                       \
-       (_qlen) = ++(_ni)->ni_savedq.ifq_len;                   \
+#define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {                \
+       IF_LOCK(ifq);                                           \
+       _IF_PREPEND_LIST(ifq, mhead, mtail, mcount);            \
+       IF_UNLOCK(ifq);                                         \
 } while (0)
+#endif /* IF_PREPEND_LIST */
+/*
+ * Age queue definitions.
+ */
+typedef struct lock ieee80211_ageq_lock_t;
+#define        IEEE80211_AGEQ_INIT(_aq, _name) \
+       lockinit(&(_aq)->aq_lock, _name, 0, 0)
+#define        IEEE80211_AGEQ_DESTROY(_aq)     lockuninit(&(_aq)->aq_lock)
+#define        IEEE80211_AGEQ_LOCK(_aq)        lockmgr(&(_aq)->aq_lock, LK_EXCLUSIVE)
+#define        IEEE80211_AGEQ_UNLOCK(_aq)      lockmgr(&(_aq)->aq_lock, LK_RELEASE)
+
+/*
+ * 802.1x MAC ACL database locking definitions.
+ */
+typedef struct lock acl_lock_t;
+#define        ACL_LOCK_INIT(_as, _name) \
+       lockinit(&(_as)->as_lock, _name, 0, 0)
+#define        ACL_LOCK_DESTROY(_as)           lockuninit(&(_as)->as_lock)
+#define        ACL_LOCK(_as)                   lockmgr(&(_as)->as_lock, LK_EXCLUSIVE)
+#define        ACL_UNLOCK(_as)                 lockmgr(&(_as)->as_lock, LK_RELEASE)
+#define        ACL_LOCK_ASSERT(_as) \
+       KKASSERT(lockstatus(&(_as)->as_lock, curthread) == LK_EXCLUSIVE)
 
 /*
  * Node reference counting definitions.
@@ -85,27 +172,69 @@ struct ieee80211_node;
 int    ieee80211_node_dectestref(struct ieee80211_node *ni);
 #define        ieee80211_node_refcnt(_ni)      (_ni)->ni_refcnt
 
-struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, u_int pktlen);
+struct ifqueue;
+struct ieee80211vap;
+void   ieee80211_drain_ifq(struct ifqueue *);
+void   ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
+
+void   ieee80211_vap_destroy(struct ieee80211vap *);
+
+#define        IFNET_IS_UP_RUNNING(_ifp) \
+       (((_ifp)->if_flags & IFF_UP) && \
+        ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
+
+#define        msecs_to_ticks(ms)      (((ms)*hz)/1000)
+#define        ticks_to_msecs(t)       (1000*(t) / hz)
+#define        ticks_to_secs(t)        ((t) / hz)
+#define time_after(a,b)        ((long)(b) - (long)(a) < 0)
+#define time_before(a,b)       time_after(b,a)
+#define time_after_eq(a,b)     ((long)(a) - (long)(b) >= 0)
+#define time_before_eq(a,b)    time_after_eq(b,a)
 
-/* M_PROTO1 unused */
+struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
+
+/* tx path usage */
+#define        M_ENCAP         M_PROTO1                /* 802.11 encap done */
+#define        M_EAPOL         M_PROTO3                /* PAE/EAPOL frame */
 #define        M_PWR_SAV       M_PROTO4                /* bypass PS handling */
 #define        M_MORE_DATA     M_PROTO5                /* more data frames to follow */
-/*
- * Encode WME access control bits in the PROTO flags.
- * This is safe since it's passed directly in to the
- * driver and there's no chance someone else will clobber
- * them on us.
- */
-#define        M_WME_AC_MASK   (M_PROTO2|M_PROTO3)
-/* XXX 5 is wrong if M_PROTO* are redefined */
-#define        M_WME_AC_SHIFT  5
+#define        M_FF            M_PROTO6                /* fast frame */
+#define        M_TXCB          M_PROTO7                /* do tx complete callback */
+#define        M_AMPDU_MPDU    M_PROTO8                /* ok for A-MPDU aggregation */
+#define        M_80211_TX \
+       (M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\
+        M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU)
+
+/* rx path usage */
+#define        M_AMPDU         M_PROTO1                /* A-MPDU subframe */
+#define        M_WEP           M_PROTO2                /* WEP done by hardware */
+#if 0
+#define        M_AMPDU_MPDU    M_PROTO8                /* A-MPDU re-order done */
+#endif
+#define        M_80211_RX      (M_AMPDU|M_WEP|M_AMPDU_MPDU)
+
+#define        IEEE80211_MBUF_TX_FLAG_BITS \
+       "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \
+       "\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
+       "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
+       "\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
 
-#define M_IEEE80211    (M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5)
+#define        IEEE80211_MBUF_RX_FLAG_BITS \
+       "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \
+       "\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
+       "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
+       "\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
 
+/*
+ * Store WME access control bits in the vlan tag.
+ * This is safe since it's done after the packet is classified
+ * (where we use any previous tag) and because it's passed
+ * directly in to the driver and there's no chance someone
+ * else will clobber them on us.
+ */
 #define        M_WME_SETAC(m, ac) \
-       ((m)->m_flags = ((m)->m_flags &~ M_WME_AC_MASK) | \
-               ((ac) << M_WME_AC_SHIFT))
-#define        M_WME_GETAC(m)  (((m)->m_flags >> M_WME_AC_SHIFT) & 0x3)
+       ((m)->m_pkthdr.ether_vlantag = (ac))
+#define        M_WME_GETAC(m)  ((m)->m_pkthdr.ether_vlantag)
 
 /*
  * Mbufs on the power save queue are tagged with an age and
@@ -116,17 +245,169 @@ struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, u_int pktlen);
 #define        M_AGE_GET(m)            (m->m_pkthdr.csum_data)
 #define        M_AGE_SUB(m,adj)        (m->m_pkthdr.csum_data -= adj)
 
+/*
+ * Store the sequence number.
+ */
+#define        M_SEQNO_SET(m, seqno) \
+       ((m)->m_pkthdr.tso_segsz = (seqno))
+#define        M_SEQNO_GET(m)  ((m)->m_pkthdr.tso_segsz)
+
+#define        MTAG_ABI_NET80211       1132948340      /* net80211 ABI */
+
+struct ieee80211_cb {
+       void    (*func)(struct ieee80211_node *, void *, int status);
+       void    *arg;
+};
+#define        NET80211_TAG_CALLBACK   0       /* xmit complete callback */
+int    ieee80211_add_callback(struct mbuf *m,
+               void (*func)(struct ieee80211_node *, void *, int), void *arg);
+void   ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
+
 void   get_random_bytes(void *, size_t);
 
 struct ieee80211com;
 
 void   ieee80211_sysctl_attach(struct ieee80211com *);
 void   ieee80211_sysctl_detach(struct ieee80211com *);
+void   ieee80211_sysctl_vattach(struct ieee80211vap *);
+void   ieee80211_sysctl_vdetach(struct ieee80211vap *);
+
+SYSCTL_DECL(_net_wlan);
+int    ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
 
 void   ieee80211_load_module(const char *);
-int    ieee80211_mbuf_append(struct mbuf *, int, const uint8_t *);
-struct mbuf *ieee80211_mbuf_clone(struct mbuf *, int);
-void   ieee80211_drain_mgtq(struct ifqueue *);
+
+/*
+ * A "policy module" is an adjunct module to net80211 that provides
+ * functionality that typically includes policy decisions.  This
+ * modularity enables extensibility and vendor-supplied functionality.
+ */
+#define        _IEEE80211_POLICY_MODULE(policy, name, version)                 \
+typedef void (*policy##_setup)(int);                                   \
+SET_DECLARE(policy##_set, policy##_setup);                             \
+static int                                                             \
+wlan_##name##_modevent(module_t mod, int type, void *unused)           \
+{                                                                      \
+       policy##_setup * const *iter, f;                                \
+       switch (type) {                                                 \
+       case MOD_LOAD:                                                  \
+               SET_FOREACH(iter, policy##_set) {                       \
+                       f = (void*) *iter;                              \
+                       f(type);                                        \
+               }                                                       \
+               return 0;                                               \
+       case MOD_UNLOAD:                                                \
+               if (nrefs) {                                            \
+                       kprintf("wlan_##name: still in use (%u dynamic refs)\n",\
+                               nrefs);                                 \
+                       return EBUSY;                                   \
+               }                                                       \
+               if (type == MOD_UNLOAD) {                               \
+                       SET_FOREACH(iter, policy##_set) {               \
+                               f = (void*) *iter;                      \
+                               f(type);                                \
+                       }                                               \
+               }                                                       \
+               return 0;                                               \
+       }                                                               \
+       return EINVAL;                                                  \
+}                                                                      \
+static moduledata_t name##_mod = {                                     \
+       "wlan_" #name,                                                  \
+       wlan_##name##_modevent,                                         \
+       0                                                               \
+};                                                                     \
+DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
+MODULE_VERSION(wlan_##name, version);                                  \
+MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
+
+/*
+ * Crypto modules implement cipher support.
+ */
+#define        IEEE80211_CRYPTO_MODULE(name, version)                          \
+_IEEE80211_POLICY_MODULE(crypto, name, version);                       \
+static void                                                            \
+name##_modevent(int type)                                              \
+{                                                                      \
+       if (type == MOD_LOAD)                                           \
+               ieee80211_crypto_register(&name);                       \
+       else                                                            \
+               ieee80211_crypto_unregister(&name);                     \
+}                                                                      \
+TEXT_SET(crypto##_set, name##_modevent)
+
+/*
+ * Scanner modules provide scanning policy.
+ */
+#define        IEEE80211_SCANNER_MODULE(name, version)                         \
+       _IEEE80211_POLICY_MODULE(scanner, name, version)
+
+#define        IEEE80211_SCANNER_ALG(name, alg, v)                             \
+static void                                                            \
+name##_modevent(int type)                                              \
+{                                                                      \
+       if (type == MOD_LOAD)                                           \
+               ieee80211_scanner_register(alg, &v);                    \
+       else                                                            \
+               ieee80211_scanner_unregister(alg, &v);                  \
+}                                                                      \
+TEXT_SET(scanner_set, name##_modevent);                                        \
+
+/*
+ * ACL modules implement acl policy.
+ */
+#define        IEEE80211_ACL_MODULE(name, alg, version)                        \
+_IEEE80211_POLICY_MODULE(acl, name, version);                          \
+static void                                                            \
+alg##_modevent(int type)                                               \
+{                                                                      \
+       if (type == MOD_LOAD)                                           \
+               ieee80211_aclator_register(&alg);                       \
+       else                                                            \
+               ieee80211_aclator_unregister(&alg);                     \
+}                                                                      \
+TEXT_SET(acl_set, alg##_modevent);                                     \
+
+/*
+ * Authenticator modules handle 802.1x/WPA authentication.
+ */
+#define        IEEE80211_AUTH_MODULE(name, version)                            \
+       _IEEE80211_POLICY_MODULE(auth, name, version)
+
+#define        IEEE80211_AUTH_ALG(name, alg, v)                                \
+static void                                                            \
+name##_modevent(int type)                                              \
+{                                                                      \
+       if (type == MOD_LOAD)                                           \
+               ieee80211_authenticator_register(alg, &v);              \
+       else                                                            \
+               ieee80211_authenticator_unregister(alg);                \
+}                                                                      \
+TEXT_SET(auth_set, name##_modevent)
+
+/*
+ * Rate control modules provide tx rate control support.
+ */
+#define        IEEE80211_RATE_MODULE(alg, version)                             \
+_IEEE80211_POLICY_MODULE(rate, alg, version);                          \
+static void                                                            \
+alg##_modevent(int type)                                               \
+{                                                                      \
+       /* XXX nothing to do until the rate control framework arrives */\
+}                                                                      \
+TEXT_SET(rate##_set, alg##_modevent)
+
+struct ieee80211req;
+typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
+    struct ieee80211req *);
+SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
+#define        IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
+
+typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
+    struct ieee80211req *);
+SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
+#define        IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
+#endif /* _KERNEL */
 
 /* XXX this stuff belongs elsewhere */
 /*
@@ -158,6 +439,50 @@ struct ieee80211_michael_event {
        uint8_t         iev_keyix;      /* key id/index */
 };
 
+struct ieee80211_wds_event {
+       uint8_t         iev_addr[6];
+};
+
+struct ieee80211_csa_event {
+       uint32_t        iev_flags;      /* channel flags */
+       uint16_t        iev_freq;       /* setting in Mhz */
+       uint8_t         iev_ieee;       /* IEEE channel number */
+       uint8_t         iev_mode;       /* CSA mode */
+       uint8_t         iev_count;      /* CSA count */
+};
+
+struct ieee80211_cac_event {
+       uint32_t        iev_flags;      /* channel flags */
+       uint16_t        iev_freq;       /* setting in Mhz */
+       uint8_t         iev_ieee;       /* IEEE channel number */
+       /* XXX timestamp? */
+       uint8_t         iev_type;       /* IEEE80211_NOTIFY_CAC_* */
+};
+
+struct ieee80211_radar_event {
+       uint32_t        iev_flags;      /* channel flags */
+       uint16_t        iev_freq;       /* setting in Mhz */
+       uint8_t         iev_ieee;       /* IEEE channel number */
+       /* XXX timestamp? */
+};
+
+struct ieee80211_auth_event {
+       uint8_t         iev_addr[6];
+};
+
+struct ieee80211_deauth_event {
+       uint8_t         iev_addr[6];
+};
+
+struct ieee80211_country_event {
+       uint8_t         iev_addr[6];
+       uint8_t         iev_cc[2];      /* ISO country code */
+};
+
+struct ieee80211_radio_event {
+       uint8_t         iev_state;      /* 1 on, 0 off */
+};
+
 #define        RTM_IEEE80211_ASSOC     100     /* station associate (bss mode) */
 #define        RTM_IEEE80211_REASSOC   101     /* station re-associate (bss mode) */
 #define        RTM_IEEE80211_DISASSOC  102     /* station disassociate (bss mode) */
@@ -167,5 +492,46 @@ struct ieee80211_michael_event {
 #define        RTM_IEEE80211_REPLAY    106     /* sequence counter replay detected */
 #define        RTM_IEEE80211_MICHAEL   107     /* Michael MIC failure detected */
 #define        RTM_IEEE80211_REJOIN    108     /* station re-associate (ap mode) */
+#define        RTM_IEEE80211_WDS       109     /* WDS discovery (ap mode) */
+#define        RTM_IEEE80211_CSA       110     /* Channel Switch Announcement event */
+#define        RTM_IEEE80211_RADAR     111     /* radar event */
+#define        RTM_IEEE80211_CAC       112     /* Channel Availability Check event */
+#define        RTM_IEEE80211_DEAUTH    113     /* station deauthenticate */
+#define        RTM_IEEE80211_AUTH      114     /* station authenticate (ap mode) */
+#define        RTM_IEEE80211_COUNTRY   115     /* discovered country code (sta mode) */
+#define        RTM_IEEE80211_RADIO     116     /* RF kill switch state change */
 
+/*
+ * Structure prepended to raw packets sent through the bpf
+ * interface when set to DLT_IEEE802_11_RADIO.  This allows
+ * user applications to specify pretty much everything in
+ * an Atheros tx descriptor.  XXX need to generalize.
+ *
+ * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
+ * XXX sa_data area.
+ */
+struct ieee80211_bpf_params {
+       uint8_t         ibp_vers;       /* version */
+#define        IEEE80211_BPF_VERSION   0
+       uint8_t         ibp_len;        /* header length in bytes */
+       uint8_t         ibp_flags;
+#define        IEEE80211_BPF_SHORTPRE  0x01    /* tx with short preamble */
+#define        IEEE80211_BPF_NOACK     0x02    /* tx with no ack */
+#define        IEEE80211_BPF_CRYPTO    0x04    /* tx with h/w encryption */
+#define        IEEE80211_BPF_FCS       0x10    /* frame incldues FCS */
+#define        IEEE80211_BPF_DATAPAD   0x20    /* frame includes data padding */
+#define        IEEE80211_BPF_RTS       0x40    /* tx with RTS/CTS */
+#define        IEEE80211_BPF_CTS       0x80    /* tx with CTS only */
+       uint8_t         ibp_pri;        /* WME/WMM AC+tx antenna */
+       uint8_t         ibp_try0;       /* series 1 try count */
+       uint8_t         ibp_rate0;      /* series 1 IEEE tx rate */
+       uint8_t         ibp_power;      /* tx power (device units) */
+       uint8_t         ibp_ctsrate;    /* IEEE tx rate for CTS */
+       uint8_t         ibp_try1;       /* series 2 try count */
+       uint8_t         ibp_rate1;      /* series 2 IEEE tx rate */
+       uint8_t         ibp_try2;       /* series 3 try count */
+       uint8_t         ibp_rate2;      /* series 3 IEEE tx rate */
+       uint8_t         ibp_try3;       /* series 4 try count */
+       uint8_t         ibp_rate3;      /* series 4 IEEE tx rate */
+};
 #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */