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