First pass at converting the net80211 infrastrcture from FreeBSD.
[dragonfly.git] / sys / netproto / 802_11 / ieee80211_dragonfly.h
1 /*-
2  * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * $FreeBSD: head/sys/net80211/ieee80211_freebsd.h 195618 2009-07-11 15:02:45Z rpaulo $
26  * $DragonFly$
27  */
28 #ifndef _NET80211_IEEE80211_DRAGONFLY_H_
29 #define _NET80211_IEEE80211_DRAGONFLY_H_
30
31 #ifdef _KERNEL
32 #include <sys/param.h>
33 #include <sys/types.h>
34 #include <sys/lock.h>
35 #include <sys/mutex2.h>
36 #include <sys/sysctl.h>
37 #include <sys/taskqueue.h>
38
39 /*
40  * Common state locking definitions.
41  */
42 typedef struct {
43         char            name[16];               /* e.g. "ath0_com_lock" */
44         struct lock     lock;
45 } ieee80211_com_lock_t;
46 #define IEEE80211_LOCK_INIT(_ic, _name) do {                            \
47         ieee80211_com_lock_t *cl = &(_ic)->ic_comlock;                  \
48         ksnprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name);    \
49         lockinit(&cl->lock, cl->name, 0, LK_CANRECURSE);                \
50 } while (0)
51 #define IEEE80211_LOCK_OBJ(_ic) (&(_ic)->ic_comlock.lock)
52 #define IEEE80211_LOCK_DESTROY(_ic) lockuninit(IEEE80211_LOCK_OBJ(_ic))
53 #define IEEE80211_LOCK(_ic) \
54         lockmgr(IEEE80211_LOCK_OBJ(_ic), LK_EXCLUSIVE)
55 #define IEEE80211_UNLOCK(_ic)      lockmgr(IEEE80211_LOCK_OBJ(_ic), LK_RELEASE)
56 #define IEEE80211_LOCK_ASSERT(_ic) \
57         KKASSERT(lockstatus(IEEE80211_LOCK_OBJ(_ic), curthread) == LK_EXCLUSIVE)
58
59 /*
60  * Node locking definitions.
61  */
62 typedef struct {
63         char            name[16];               /* e.g. "ath0_node_lock" */
64         struct lock     lock;
65 } ieee80211_node_lock_t;
66 #define IEEE80211_NODE_LOCK_INIT(_nt, _name) do {                       \
67         ieee80211_node_lock_t *nl = &(_nt)->nt_nodelock;                \
68         ksnprintf(nl->name, sizeof(nl->name), "%s_node_lock", _name);   \
69         lockinit(&nl->lock, nl->name, 0, LK_CANRECURSE);                \
70 } while (0)
71 #define IEEE80211_NODE_LOCK_OBJ(_nt)    (&(_nt)->nt_nodelock.lock)
72 #define IEEE80211_NODE_LOCK_DESTROY(_nt) \
73         lockuninit(IEEE80211_NODE_LOCK_OBJ(_nt))
74 #define IEEE80211_NODE_LOCK(_nt) \
75         lockmgr(IEEE80211_NODE_LOCK_OBJ(_nt), LK_EXCLUSIVE)
76 #define IEEE80211_NODE_IS_LOCKED(_nt) \
77         (lockstatus(IEEE80211_NODE_LOCK_OBJ(_nt), curthread) == LK_EXCLUSIVE)
78 #define IEEE80211_NODE_UNLOCK(_nt) \
79         lockmgr(IEEE80211_NODE_LOCK_OBJ(_nt), LK_RELEASE)
80 #define IEEE80211_NODE_LOCK_ASSERT(_nt) \
81         KKASSERT(lockstatus(IEEE80211_NODE_LOCK_OBJ(_nt), curthread) \
82             == LK_EXCLUSIVE)
83
84 /*
85  * Node table iteration locking definitions; this protects the
86  * scan generation # used to iterate over the station table
87  * while grabbing+releasing the node lock.
88  */
89 typedef struct {
90         char            name[16];               /* e.g. "ath0_scan_lock" */
91         struct lock     lock;
92 } ieee80211_scan_lock_t;
93 #define IEEE80211_NODE_ITERATE_LOCK_INIT(_nt, _name) do {               \
94         ieee80211_scan_lock_t *sl = &(_nt)->nt_scanlock;                \
95         ksnprintf(sl->name, sizeof(sl->name), "%s_scan_lock", _name);   \
96         lockinit(&sl->lock, sl->name, 0, 0);                            \
97 } while (0)
98 #define IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt)    (&(_nt)->nt_scanlock.lock)
99 #define IEEE80211_NODE_ITERATE_LOCK_DESTROY(_nt) \
100         lockuninit(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
101 #define IEEE80211_NODE_ITERATE_LOCK(_nt) \
102         lockmgr(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt), LK_EXCLUSIVE)
103 #define IEEE80211_NODE_ITERATE_UNLOCK(_nt) \
104         lockmgr(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt), LK_RELEASE)
105
106 /*
107  * Power-save queue definitions. 
108  */
109 typedef struct lock ieee80211_psq_lock_t;
110 #define IEEE80211_PSQ_INIT(_psq, _name) \
111         lockinit(&(_psq)->psq_lock, _name, 0, 0)
112 #define IEEE80211_PSQ_DESTROY(_psq)     lockuninit(&(_psq)->psq_lock)
113 #define IEEE80211_PSQ_LOCK(_psq)        lockmgr(&(_psq)->psq_lock, LK_EXCLUSIVE)
114 #define IEEE80211_PSQ_UNLOCK(_psq)      lockmgr(&(_psq)->psq_lock, LK_RELEASE)
115
116 #ifndef IF_PREPEND_LIST
117 #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {        \
118         (mtail)->m_nextpkt = (ifq)->ifq_head;                   \
119         if ((ifq)->ifq_tail == NULL)                            \
120                 (ifq)->ifq_tail = (mtail);                      \
121         (ifq)->ifq_head = (mhead);                              \
122         (ifq)->ifq_len += (mcount);                             \
123 } while (0)
124 #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {         \
125         IF_LOCK(ifq);                                           \
126         _IF_PREPEND_LIST(ifq, mhead, mtail, mcount);            \
127         IF_UNLOCK(ifq);                                         \
128 } while (0)
129 #endif /* IF_PREPEND_LIST */
130  
131 /*
132  * Age queue definitions.
133  */
134 typedef struct lock ieee80211_ageq_lock_t;
135 #define IEEE80211_AGEQ_INIT(_aq, _name) \
136         lockinit(&(_aq)->aq_lock, _name, 0, 0)
137 #define IEEE80211_AGEQ_DESTROY(_aq)     lockuninit(&(_aq)->aq_lock)
138 #define IEEE80211_AGEQ_LOCK(_aq)        lockmgr(&(_aq)->aq_lock, LK_EXCLUSIVE)
139 #define IEEE80211_AGEQ_UNLOCK(_aq)      lockmgr(&(_aq)->aq_lock, LK_RELEASE)
140
141 /*
142  * 802.1x MAC ACL database locking definitions.
143  */
144 typedef struct lock acl_lock_t;
145 #define ACL_LOCK_INIT(_as, _name) \
146         lockinit(&(_as)->as_lock, _name, 0, 0)
147 #define ACL_LOCK_DESTROY(_as)           lockuninit(&(_as)->as_lock)
148 #define ACL_LOCK(_as)                   lockmgr(&(_as)->as_lock, LK_EXCLUSIVE)
149 #define ACL_UNLOCK(_as)                 lockmgr(&(_as)->as_lock, LK_RELEASE)
150 #define ACL_LOCK_ASSERT(_as) \
151         KKASSERT(lockstatus(&(_as)->as_lock, curthread) == LK_EXCLUSIVE)
152
153 /*
154  * Node reference counting definitions.
155  *
156  * ieee80211_node_initref       initialize the reference count to 1
157  * ieee80211_node_incref        add a reference
158  * ieee80211_node_decref        remove a reference
159  * ieee80211_node_dectestref    remove a reference and return 1 if this
160  *                              is the last reference, otherwise 0
161  * ieee80211_node_refcnt        reference count for printing (only)
162  */
163 #include <machine/atomic.h>
164
165 #define ieee80211_node_initref(_ni) \
166         do { ((_ni)->ni_refcnt = 1); } while (0)
167 #define ieee80211_node_incref(_ni) \
168         atomic_add_int(&(_ni)->ni_refcnt, 1)
169 #define ieee80211_node_decref(_ni) \
170         atomic_subtract_int(&(_ni)->ni_refcnt, 1)
171 struct ieee80211_node;
172 int     ieee80211_node_dectestref(struct ieee80211_node *ni);
173 #define ieee80211_node_refcnt(_ni)      (_ni)->ni_refcnt
174
175 struct ifqueue;
176 struct ieee80211vap;
177 void    ieee80211_drain_ifq(struct ifqueue *);
178 void    ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
179
180 void    ieee80211_vap_destroy(struct ieee80211vap *);
181
182 #define IFNET_IS_UP_RUNNING(_ifp) \
183         (((_ifp)->if_flags & IFF_UP) && \
184          ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
185
186 #define msecs_to_ticks(ms)      (((ms)*hz)/1000)
187 #define ticks_to_msecs(t)       (1000*(t) / hz)
188 #define ticks_to_secs(t)        ((t) / hz)
189 #define time_after(a,b)         ((long)(b) - (long)(a) < 0)
190 #define time_before(a,b)        time_after(b,a)
191 #define time_after_eq(a,b)      ((long)(a) - (long)(b) >= 0)
192 #define time_before_eq(a,b)     time_after_eq(b,a)
193
194 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
195
196 /* tx path usage */
197 #define M_ENCAP         M_PROTO1                /* 802.11 encap done */
198 #define M_EAPOL         M_PROTO3                /* PAE/EAPOL frame */
199 #define M_PWR_SAV       M_PROTO4                /* bypass PS handling */
200 #define M_MORE_DATA     M_PROTO5                /* more data frames to follow */
201 #define M_FF            M_PROTO6                /* fast frame */
202 #define M_TXCB          M_PROTO7                /* do tx complete callback */
203 #define M_AMPDU_MPDU    M_PROTO8                /* ok for A-MPDU aggregation */
204 #define M_80211_TX \
205         (M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\
206          M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU)
207
208 /* rx path usage */
209 #define M_AMPDU         M_PROTO1                /* A-MPDU subframe */
210 #define M_WEP           M_PROTO2                /* WEP done by hardware */
211 #if 0
212 #define M_AMPDU_MPDU    M_PROTO8                /* A-MPDU re-order done */
213 #endif
214 #define M_80211_RX      (M_AMPDU|M_WEP|M_AMPDU_MPDU)
215
216 #define IEEE80211_MBUF_TX_FLAG_BITS \
217         "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_ENCAP\6M_WEP\7M_EAPOL" \
218         "\10M_PWR_SAV\11M_MORE_DATA\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
219         "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
220         "\23M_NOFREE\24M_FF\25M_TXCB\26M_AMPDU_MPDU\27M_FLOWID"
221
222 #define IEEE80211_MBUF_RX_FLAG_BITS \
223         "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_AMPDU\6M_WEP\7M_PROTO3" \
224         "\10M_PROTO4\11M_PROTO5\12M_BCAST\13M_MCAST\14M_FRAG\15M_FIRSTFRAG" \
225         "\16M_LASTFRAG\17M_SKIP_FIREWALL\20M_FREELIST\21M_VLANTAG\22M_PROMISC" \
226         "\23M_NOFREE\24M_PROTO6\25M_PROTO7\26M_AMPDU_MPDU\27M_FLOWID"
227
228 /*
229  * Store WME access control bits in the vlan tag.
230  * This is safe since it's done after the packet is classified
231  * (where we use any previous tag) and because it's passed
232  * directly in to the driver and there's no chance someone
233  * else will clobber them on us.
234  */
235 #define M_WME_SETAC(m, ac) \
236         ((m)->m_pkthdr.ether_vlantag = (ac))
237 #define M_WME_GETAC(m)  ((m)->m_pkthdr.ether_vlantag)
238
239 /*
240  * Mbufs on the power save queue are tagged with an age and
241  * timed out.  We reuse the hardware checksum field in the
242  * mbuf packet header to store this data.
243  */
244 #define M_AGE_SET(m,v)          (m->m_pkthdr.csum_data = v)
245 #define M_AGE_GET(m)            (m->m_pkthdr.csum_data)
246 #define M_AGE_SUB(m,adj)        (m->m_pkthdr.csum_data -= adj)
247
248 /*
249  * Store the sequence number.
250  */
251 #define M_SEQNO_SET(m, seqno) \
252         ((m)->m_pkthdr.tso_segsz = (seqno))
253 #define M_SEQNO_GET(m)  ((m)->m_pkthdr.tso_segsz)
254
255 #define MTAG_ABI_NET80211       1132948340      /* net80211 ABI */
256
257 struct ieee80211_cb {
258         void    (*func)(struct ieee80211_node *, void *, int status);
259         void    *arg;
260 };
261 #define NET80211_TAG_CALLBACK   0       /* xmit complete callback */
262 int     ieee80211_add_callback(struct mbuf *m,
263                 void (*func)(struct ieee80211_node *, void *, int), void *arg);
264 void    ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
265
266 void    get_random_bytes(void *, size_t);
267
268 struct ieee80211com;
269
270 void    ieee80211_sysctl_attach(struct ieee80211com *);
271 void    ieee80211_sysctl_detach(struct ieee80211com *);
272 void    ieee80211_sysctl_vattach(struct ieee80211vap *);
273 void    ieee80211_sysctl_vdetach(struct ieee80211vap *);
274
275 SYSCTL_DECL(_net_wlan);
276 int     ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
277
278 void    ieee80211_load_module(const char *);
279
280 /*
281  * A "policy module" is an adjunct module to net80211 that provides
282  * functionality that typically includes policy decisions.  This
283  * modularity enables extensibility and vendor-supplied functionality.
284  */
285 #define _IEEE80211_POLICY_MODULE(policy, name, version)                 \
286 typedef void (*policy##_setup)(int);                                    \
287 SET_DECLARE(policy##_set, policy##_setup);                              \
288 static int                                                              \
289 wlan_##name##_modevent(module_t mod, int type, void *unused)            \
290 {                                                                       \
291         policy##_setup * const *iter, f;                                \
292         switch (type) {                                                 \
293         case MOD_LOAD:                                                  \
294                 SET_FOREACH(iter, policy##_set) {                       \
295                         f = (void*) *iter;                              \
296                         f(type);                                        \
297                 }                                                       \
298                 return 0;                                               \
299         case MOD_UNLOAD:                                                \
300                 if (nrefs) {                                            \
301                         kprintf("wlan_##name: still in use (%u dynamic refs)\n",\
302                                 nrefs);                                 \
303                         return EBUSY;                                   \
304                 }                                                       \
305                 if (type == MOD_UNLOAD) {                               \
306                         SET_FOREACH(iter, policy##_set) {               \
307                                 f = (void*) *iter;                      \
308                                 f(type);                                \
309                         }                                               \
310                 }                                                       \
311                 return 0;                                               \
312         }                                                               \
313         return EINVAL;                                                  \
314 }                                                                       \
315 static moduledata_t name##_mod = {                                      \
316         "wlan_" #name,                                                  \
317         wlan_##name##_modevent,                                         \
318         0                                                               \
319 };                                                                      \
320 DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
321 MODULE_VERSION(wlan_##name, version);                                   \
322 MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
323
324 /*
325  * Crypto modules implement cipher support.
326  */
327 #define IEEE80211_CRYPTO_MODULE(name, version)                          \
328 _IEEE80211_POLICY_MODULE(crypto, name, version);                        \
329 static void                                                             \
330 name##_modevent(int type)                                               \
331 {                                                                       \
332         if (type == MOD_LOAD)                                           \
333                 ieee80211_crypto_register(&name);                       \
334         else                                                            \
335                 ieee80211_crypto_unregister(&name);                     \
336 }                                                                       \
337 TEXT_SET(crypto##_set, name##_modevent)
338
339 /*
340  * Scanner modules provide scanning policy.
341  */
342 #define IEEE80211_SCANNER_MODULE(name, version)                         \
343         _IEEE80211_POLICY_MODULE(scanner, name, version)
344
345 #define IEEE80211_SCANNER_ALG(name, alg, v)                             \
346 static void                                                             \
347 name##_modevent(int type)                                               \
348 {                                                                       \
349         if (type == MOD_LOAD)                                           \
350                 ieee80211_scanner_register(alg, &v);                    \
351         else                                                            \
352                 ieee80211_scanner_unregister(alg, &v);                  \
353 }                                                                       \
354 TEXT_SET(scanner_set, name##_modevent);                                 \
355
356 /*
357  * ACL modules implement acl policy.
358  */
359 #define IEEE80211_ACL_MODULE(name, alg, version)                        \
360 _IEEE80211_POLICY_MODULE(acl, name, version);                           \
361 static void                                                             \
362 alg##_modevent(int type)                                                \
363 {                                                                       \
364         if (type == MOD_LOAD)                                           \
365                 ieee80211_aclator_register(&alg);                       \
366         else                                                            \
367                 ieee80211_aclator_unregister(&alg);                     \
368 }                                                                       \
369 TEXT_SET(acl_set, alg##_modevent);                                      \
370
371 /*
372  * Authenticator modules handle 802.1x/WPA authentication.
373  */
374 #define IEEE80211_AUTH_MODULE(name, version)                            \
375         _IEEE80211_POLICY_MODULE(auth, name, version)
376
377 #define IEEE80211_AUTH_ALG(name, alg, v)                                \
378 static void                                                             \
379 name##_modevent(int type)                                               \
380 {                                                                       \
381         if (type == MOD_LOAD)                                           \
382                 ieee80211_authenticator_register(alg, &v);              \
383         else                                                            \
384                 ieee80211_authenticator_unregister(alg);                \
385 }                                                                       \
386 TEXT_SET(auth_set, name##_modevent)
387
388 /*
389  * Rate control modules provide tx rate control support.
390  */
391 #define IEEE80211_RATE_MODULE(alg, version)                             \
392 _IEEE80211_POLICY_MODULE(rate, alg, version);                           \
393 static void                                                             \
394 alg##_modevent(int type)                                                \
395 {                                                                       \
396         /* XXX nothing to do until the rate control framework arrives */\
397 }                                                                       \
398 TEXT_SET(rate##_set, alg##_modevent)
399
400 struct ieee80211req;
401 typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
402     struct ieee80211req *);
403 SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
404 #define IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
405
406 typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
407     struct ieee80211req *);
408 SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
409 #define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
410 #endif /* _KERNEL */
411
412 /* XXX this stuff belongs elsewhere */
413 /*
414  * Message formats for messages from the net80211 layer to user
415  * applications via the routing socket.  These messages are appended
416  * to an if_announcemsghdr structure.
417  */
418 struct ieee80211_join_event {
419         uint8_t         iev_addr[6];
420 };
421
422 struct ieee80211_leave_event {
423         uint8_t         iev_addr[6];
424 };
425
426 struct ieee80211_replay_event {
427         uint8_t         iev_src[6];     /* src MAC */
428         uint8_t         iev_dst[6];     /* dst MAC */
429         uint8_t         iev_cipher;     /* cipher type */
430         uint8_t         iev_keyix;      /* key id/index */
431         uint64_t        iev_keyrsc;     /* RSC from key */
432         uint64_t        iev_rsc;        /* RSC from frame */
433 };
434
435 struct ieee80211_michael_event {
436         uint8_t         iev_src[6];     /* src MAC */
437         uint8_t         iev_dst[6];     /* dst MAC */
438         uint8_t         iev_cipher;     /* cipher type */
439         uint8_t         iev_keyix;      /* key id/index */
440 };
441
442 struct ieee80211_wds_event {
443         uint8_t         iev_addr[6];
444 };
445
446 struct ieee80211_csa_event {
447         uint32_t        iev_flags;      /* channel flags */
448         uint16_t        iev_freq;       /* setting in Mhz */
449         uint8_t         iev_ieee;       /* IEEE channel number */
450         uint8_t         iev_mode;       /* CSA mode */
451         uint8_t         iev_count;      /* CSA count */
452 };
453
454 struct ieee80211_cac_event {
455         uint32_t        iev_flags;      /* channel flags */
456         uint16_t        iev_freq;       /* setting in Mhz */
457         uint8_t         iev_ieee;       /* IEEE channel number */
458         /* XXX timestamp? */
459         uint8_t         iev_type;       /* IEEE80211_NOTIFY_CAC_* */
460 };
461
462 struct ieee80211_radar_event {
463         uint32_t        iev_flags;      /* channel flags */
464         uint16_t        iev_freq;       /* setting in Mhz */
465         uint8_t         iev_ieee;       /* IEEE channel number */
466         /* XXX timestamp? */
467 };
468
469 struct ieee80211_auth_event {
470         uint8_t         iev_addr[6];
471 };
472
473 struct ieee80211_deauth_event {
474         uint8_t         iev_addr[6];
475 };
476
477 struct ieee80211_country_event {
478         uint8_t         iev_addr[6];
479         uint8_t         iev_cc[2];      /* ISO country code */
480 };
481
482 struct ieee80211_radio_event {
483         uint8_t         iev_state;      /* 1 on, 0 off */
484 };
485
486 #define RTM_IEEE80211_ASSOC     100     /* station associate (bss mode) */
487 #define RTM_IEEE80211_REASSOC   101     /* station re-associate (bss mode) */
488 #define RTM_IEEE80211_DISASSOC  102     /* station disassociate (bss mode) */
489 #define RTM_IEEE80211_JOIN      103     /* station join (ap mode) */
490 #define RTM_IEEE80211_LEAVE     104     /* station leave (ap mode) */
491 #define RTM_IEEE80211_SCAN      105     /* scan complete, results available */
492 #define RTM_IEEE80211_REPLAY    106     /* sequence counter replay detected */
493 #define RTM_IEEE80211_MICHAEL   107     /* Michael MIC failure detected */
494 #define RTM_IEEE80211_REJOIN    108     /* station re-associate (ap mode) */
495 #define RTM_IEEE80211_WDS       109     /* WDS discovery (ap mode) */
496 #define RTM_IEEE80211_CSA       110     /* Channel Switch Announcement event */
497 #define RTM_IEEE80211_RADAR     111     /* radar event */
498 #define RTM_IEEE80211_CAC       112     /* Channel Availability Check event */
499 #define RTM_IEEE80211_DEAUTH    113     /* station deauthenticate */
500 #define RTM_IEEE80211_AUTH      114     /* station authenticate (ap mode) */
501 #define RTM_IEEE80211_COUNTRY   115     /* discovered country code (sta mode) */
502 #define RTM_IEEE80211_RADIO     116     /* RF kill switch state change */
503
504 /*
505  * Structure prepended to raw packets sent through the bpf
506  * interface when set to DLT_IEEE802_11_RADIO.  This allows
507  * user applications to specify pretty much everything in
508  * an Atheros tx descriptor.  XXX need to generalize.
509  *
510  * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
511  * XXX sa_data area.
512  */
513 struct ieee80211_bpf_params {
514         uint8_t         ibp_vers;       /* version */
515 #define IEEE80211_BPF_VERSION   0
516         uint8_t         ibp_len;        /* header length in bytes */
517         uint8_t         ibp_flags;
518 #define IEEE80211_BPF_SHORTPRE  0x01    /* tx with short preamble */
519 #define IEEE80211_BPF_NOACK     0x02    /* tx with no ack */
520 #define IEEE80211_BPF_CRYPTO    0x04    /* tx with h/w encryption */
521 #define IEEE80211_BPF_FCS       0x10    /* frame incldues FCS */
522 #define IEEE80211_BPF_DATAPAD   0x20    /* frame includes data padding */
523 #define IEEE80211_BPF_RTS       0x40    /* tx with RTS/CTS */
524 #define IEEE80211_BPF_CTS       0x80    /* tx with CTS only */
525         uint8_t         ibp_pri;        /* WME/WMM AC+tx antenna */
526         uint8_t         ibp_try0;       /* series 1 try count */
527         uint8_t         ibp_rate0;      /* series 1 IEEE tx rate */
528         uint8_t         ibp_power;      /* tx power (device units) */
529         uint8_t         ibp_ctsrate;    /* IEEE tx rate for CTS */
530         uint8_t         ibp_try1;       /* series 2 try count */
531         uint8_t         ibp_rate1;      /* series 2 IEEE tx rate */
532         uint8_t         ibp_try2;       /* series 3 try count */
533         uint8_t         ibp_rate2;      /* series 3 IEEE tx rate */
534         uint8_t         ibp_try3;       /* series 4 try count */
535         uint8_t         ibp_rate3;      /* series 4 IEEE tx rate */
536 };
537 #endif /* _NET80211_IEEE80211_DRAGONFLY_H_ */