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