]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/net80211/ieee80211_freebsd.h
Merge vendor/file/dist@192348, bringing FILE 5.03 to 8-CURRENT.
[FreeBSD/FreeBSD.git] / sys / net80211 / ieee80211_freebsd.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$
26  */
27 #ifndef _NET80211_IEEE80211_FREEBSD_H_
28 #define _NET80211_IEEE80211_FREEBSD_H_
29
30 #ifdef _KERNEL
31 #include <sys/param.h>
32 #include <sys/lock.h>
33 #include <sys/mutex.h>
34 #include <sys/rwlock.h>
35 #include <sys/taskqueue.h>
36
37 /*
38  * Common state locking definitions.
39  */
40 typedef struct {
41         char            name[16];               /* e.g. "ath0_com_lock" */
42         struct mtx      mtx;
43 } ieee80211_com_lock_t;
44 #define IEEE80211_LOCK_INIT(_ic, _name) do {                            \
45         ieee80211_com_lock_t *cl = &(_ic)->ic_comlock;                  \
46         snprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name);     \
47         mtx_init(&cl->mtx, cl->name, NULL, MTX_DEF | MTX_RECURSE);      \
48 } while (0)
49 #define IEEE80211_LOCK_OBJ(_ic) (&(_ic)->ic_comlock.mtx)
50 #define IEEE80211_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_LOCK_OBJ(_ic))
51 #define IEEE80211_LOCK(_ic)        mtx_lock(IEEE80211_LOCK_OBJ(_ic))
52 #define IEEE80211_UNLOCK(_ic)      mtx_unlock(IEEE80211_LOCK_OBJ(_ic))
53 #define IEEE80211_LOCK_ASSERT(_ic) \
54         mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED)
55
56 /*
57  * Node locking definitions.
58  */
59 typedef struct {
60         char            name[16];               /* e.g. "ath0_node_lock" */
61         struct mtx      mtx;
62 } ieee80211_node_lock_t;
63 #define IEEE80211_NODE_LOCK_INIT(_nt, _name) do {                       \
64         ieee80211_node_lock_t *nl = &(_nt)->nt_nodelock;                \
65         snprintf(nl->name, sizeof(nl->name), "%s_node_lock", _name);    \
66         mtx_init(&nl->mtx, nl->name, NULL, MTX_DEF | MTX_RECURSE);      \
67 } while (0)
68 #define IEEE80211_NODE_LOCK_OBJ(_nt)    (&(_nt)->nt_nodelock.mtx)
69 #define IEEE80211_NODE_LOCK_DESTROY(_nt) \
70         mtx_destroy(IEEE80211_NODE_LOCK_OBJ(_nt))
71 #define IEEE80211_NODE_LOCK(_nt) \
72         mtx_lock(IEEE80211_NODE_LOCK_OBJ(_nt))
73 #define IEEE80211_NODE_IS_LOCKED(_nt) \
74         mtx_owned(IEEE80211_NODE_LOCK_OBJ(_nt))
75 #define IEEE80211_NODE_UNLOCK(_nt) \
76         mtx_unlock(IEEE80211_NODE_LOCK_OBJ(_nt))
77 #define IEEE80211_NODE_LOCK_ASSERT(_nt) \
78         mtx_assert(IEEE80211_NODE_LOCK_OBJ(_nt), MA_OWNED)
79
80 /*
81  * Node table iteration locking definitions; this protects the
82  * scan generation # used to iterate over the station table
83  * while grabbing+releasing the node lock.
84  */
85 typedef struct {
86         char            name[16];               /* e.g. "ath0_scan_lock" */
87         struct mtx      mtx;
88 } ieee80211_scan_lock_t;
89 #define IEEE80211_NODE_ITERATE_LOCK_INIT(_nt, _name) do {               \
90         ieee80211_scan_lock_t *sl = &(_nt)->nt_scanlock;                \
91         snprintf(sl->name, sizeof(sl->name), "%s_scan_lock", _name);    \
92         mtx_init(&sl->mtx, sl->name, NULL, MTX_DEF);                    \
93 } while (0)
94 #define IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt)    (&(_nt)->nt_scanlock.mtx)
95 #define IEEE80211_NODE_ITERATE_LOCK_DESTROY(_nt) \
96         mtx_destroy(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
97 #define IEEE80211_NODE_ITERATE_LOCK(_nt) \
98         mtx_lock(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
99 #define IEEE80211_NODE_ITERATE_UNLOCK(_nt) \
100         mtx_unlock(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
101
102 #define _AGEQ_ENQUEUE(_ifq, _m, _qlen, _age) do {               \
103         (_m)->m_nextpkt = NULL;                                 \
104         if ((_ifq)->ifq_tail != NULL) {                         \
105                 _age -= M_AGE_GET((_ifq)->ifq_head);            \
106                 (_ifq)->ifq_tail->m_nextpkt = (_m);             \
107         } else {                                                \
108                 (_ifq)->ifq_head = (_m);                        \
109         }                                                       \
110         M_AGE_SET(_m, _age);                                    \
111         (_ifq)->ifq_tail = (_m);                                \
112         (_qlen) = ++(_ifq)->ifq_len;                            \
113 } while (0)
114
115 /*
116  * Power-save queue definitions. 
117  */
118 typedef struct mtx ieee80211_psq_lock_t;
119 #define IEEE80211_PSQ_INIT(_psq, _name) \
120         mtx_init(&(_psq)->psq_lock, _name, "802.11 ps q", MTX_DEF);
121 #define IEEE80211_PSQ_DESTROY(_psq)     mtx_destroy(&(_psq)->psq_lock)
122 #define IEEE80211_PSQ_LOCK(_psq)        mtx_lock(&(_psq)->psq_lock)
123 #define IEEE80211_PSQ_UNLOCK(_psq)      mtx_unlock(&(_psq)->psq_lock)
124
125 #ifndef IF_PREPEND_LIST
126 #define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {        \
127         (mtail)->m_nextpkt = (ifq)->ifq_head;                   \
128         if ((ifq)->ifq_tail == NULL)                            \
129                 (ifq)->ifq_tail = (mtail);                      \
130         (ifq)->ifq_head = (mhead);                              \
131         (ifq)->ifq_len += (mcount);                             \
132 } while (0)
133 #define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do {         \
134         IF_LOCK(ifq);                                           \
135         _IF_PREPEND_LIST(ifq, mhead, mtail, mcount);            \
136         IF_UNLOCK(ifq);                                         \
137 } while (0)
138 #endif /* IF_PREPEND_LIST */
139
140 /* XXX temporary */
141 #define IEEE80211_NODE_WDSQ_INIT(_ni, _name) do {               \
142         mtx_init(&(_ni)->ni_wdsq.ifq_mtx, _name, "802.11 wds queue", MTX_DEF);\
143         (_ni)->ni_wdsq.ifq_maxlen = IEEE80211_PS_MAX_QUEUE;     \
144 } while (0)
145 #define IEEE80211_NODE_WDSQ_DESTROY(_ni) do { \
146         mtx_destroy(&(_ni)->ni_wdsq.ifq_mtx); \
147 } while (0)
148 #define IEEE80211_NODE_WDSQ_QLEN(_ni)   _IF_QLEN(&(_ni)->ni_wdsq)
149 #define IEEE80211_NODE_WDSQ_LOCK(_ni)   IF_LOCK(&(_ni)->ni_wdsq)
150 #define IEEE80211_NODE_WDSQ_UNLOCK(_ni) IF_UNLOCK(&(_ni)->ni_wdsq)
151 #define _IEEE80211_NODE_WDSQ_DEQUEUE_HEAD(_ni, _m) do {         \
152         _IF_DEQUEUE(&(_ni)->ni_wdsq, m);                        \
153 } while (0)
154 #define _IEEE80211_NODE_WDSQ_ENQUEUE(_ni, _m, _qlen, _age) do { \
155         _AGEQ_ENQUEUE(&ni->ni_wdsq, _m, _qlen, _age);           \
156 } while (0)
157
158 /*
159  * 802.1x MAC ACL database locking definitions.
160  */
161 typedef struct mtx acl_lock_t;
162 #define ACL_LOCK_INIT(_as, _name) \
163         mtx_init(&(_as)->as_lock, _name, "802.11 ACL", MTX_DEF)
164 #define ACL_LOCK_DESTROY(_as)           mtx_destroy(&(_as)->as_lock)
165 #define ACL_LOCK(_as)                   mtx_lock(&(_as)->as_lock)
166 #define ACL_UNLOCK(_as)                 mtx_unlock(&(_as)->as_lock)
167 #define ACL_LOCK_ASSERT(_as) \
168         mtx_assert((&(_as)->as_lock), MA_OWNED)
169
170 /*
171  * Node reference counting definitions.
172  *
173  * ieee80211_node_initref       initialize the reference count to 1
174  * ieee80211_node_incref        add a reference
175  * ieee80211_node_decref        remove a reference
176  * ieee80211_node_dectestref    remove a reference and return 1 if this
177  *                              is the last reference, otherwise 0
178  * ieee80211_node_refcnt        reference count for printing (only)
179  */
180 #include <machine/atomic.h>
181
182 #define ieee80211_node_initref(_ni) \
183         do { ((_ni)->ni_refcnt = 1); } while (0)
184 #define ieee80211_node_incref(_ni) \
185         atomic_add_int(&(_ni)->ni_refcnt, 1)
186 #define ieee80211_node_decref(_ni) \
187         atomic_subtract_int(&(_ni)->ni_refcnt, 1)
188 struct ieee80211_node;
189 int     ieee80211_node_dectestref(struct ieee80211_node *ni);
190 #define ieee80211_node_refcnt(_ni)      (_ni)->ni_refcnt
191
192 struct ifqueue;
193 struct ieee80211vap;
194 void    ieee80211_drain_ifq(struct ifqueue *);
195 void    ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
196
197 void    ieee80211_vap_destroy(struct ieee80211vap *);
198
199 #define IFNET_IS_UP_RUNNING(_ifp) \
200         (((_ifp)->if_flags & IFF_UP) && \
201          ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
202
203 #define msecs_to_ticks(ms)      (((ms)*hz)/1000)
204 #define ticks_to_msecs(t)       (1000*(t) / hz)
205 #define ticks_to_secs(t)        ((t) / hz)
206 #define time_after(a,b)         ((long)(b) - (long)(a) < 0)
207 #define time_before(a,b)        time_after(b,a)
208 #define time_after_eq(a,b)      ((long)(a) - (long)(b) >= 0)
209 #define time_before_eq(a,b)     time_after_eq(b,a)
210
211 struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
212
213 /* tx path usage */
214 #define M_ENCAP         M_PROTO1                /* 802.11 encap done */
215 #define M_EAPOL         M_PROTO3                /* PAE/EAPOL frame */
216 #define M_PWR_SAV       M_PROTO4                /* bypass PS handling */
217 #define M_MORE_DATA     M_PROTO5                /* more data frames to follow */
218 #define M_FF            M_PROTO6                /* fast frame */
219 #define M_TXCB          M_PROTO7                /* do tx complete callback */
220 #define M_AMPDU_MPDU    M_PROTO8                /* ok for A-MPDU aggregation */
221 #define M_80211_TX \
222         (M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_ENCAP|M_EAPOL|M_PWR_SAV|\
223          M_MORE_DATA|M_FF|M_TXCB|M_AMPDU_MPDU)
224
225 /* rx path usage */
226 #define M_AMPDU         M_PROTO1                /* A-MPDU subframe */
227 #define M_WEP           M_PROTO2                /* WEP done by hardware */
228 #if 0
229 #define M_AMPDU_MPDU    M_PROTO8                /* A-MPDU re-order done */
230 #endif
231 #define M_80211_RX      (M_AMPDU|M_WEP|M_AMPDU_MPDU)
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_vtag = (ac))
241 #define M_WME_GETAC(m)  ((m)->m_pkthdr.ether_vtag)
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.tso_segsz = (seqno))
257 #define M_SEQNO_GET(m)  ((m)->m_pkthdr.tso_segsz)
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 void    ieee80211_load_module(const char *);
280
281 /*
282  * A "policy module" is an adjunct module to net80211 that provides
283  * functionality that typically includes policy decisions.  This
284  * modularity enables extensibility and vendor-supplied functionality.
285  */
286 #define _IEEE80211_POLICY_MODULE(policy, name, version)                 \
287 typedef void (*policy##_setup)(int);                                    \
288 SET_DECLARE(policy##_set, policy##_setup);                              \
289 static int                                                              \
290 wlan_##name##_modevent(module_t mod, int type, void *unused)            \
291 {                                                                       \
292         policy##_setup * const *iter, f;                                \
293         switch (type) {                                                 \
294         case MOD_LOAD:                                                  \
295                 SET_FOREACH(iter, policy##_set) {                       \
296                         f = (void*) *iter;                              \
297                         f(type);                                        \
298                 }                                                       \
299                 return 0;                                               \
300         case MOD_UNLOAD:                                                \
301         case MOD_QUIESCE:                                               \
302                 if (nrefs) {                                            \
303                         printf("wlan_##name: still in use (%u dynamic refs)\n",\
304                                 nrefs);                                 \
305                         return EBUSY;                                   \
306                 }                                                       \
307                 if (type == MOD_UNLOAD) {                               \
308                         SET_FOREACH(iter, policy##_set) {               \
309                                 f = (void*) *iter;                      \
310                                 f(type);                                \
311                         }                                               \
312                 }                                                       \
313                 return 0;                                               \
314         }                                                               \
315         return EINVAL;                                                  \
316 }                                                                       \
317 static moduledata_t name##_mod = {                                      \
318         "wlan_" #name,                                                  \
319         wlan_##name##_modevent,                                         \
320         0                                                               \
321 };                                                                      \
322 DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
323 MODULE_VERSION(wlan_##name, version);                                   \
324 MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
325
326 /*
327  * Crypto modules implement cipher support.
328  */
329 #define IEEE80211_CRYPTO_MODULE(name, version)                          \
330 _IEEE80211_POLICY_MODULE(crypto, name, version);                        \
331 static void                                                             \
332 name##_modevent(int type)                                               \
333 {                                                                       \
334         if (type == MOD_LOAD)                                           \
335                 ieee80211_crypto_register(&name);                       \
336         else                                                            \
337                 ieee80211_crypto_unregister(&name);                     \
338 }                                                                       \
339 TEXT_SET(crypto##_set, name##_modevent)
340
341 /*
342  * Scanner modules provide scanning policy.
343  */
344 #define IEEE80211_SCANNER_MODULE(name, version)                         \
345         _IEEE80211_POLICY_MODULE(scanner, name, version)
346
347 #define IEEE80211_SCANNER_ALG(name, alg, v)                             \
348 static void                                                             \
349 name##_modevent(int type)                                               \
350 {                                                                       \
351         if (type == MOD_LOAD)                                           \
352                 ieee80211_scanner_register(alg, &v);                    \
353         else                                                            \
354                 ieee80211_scanner_unregister(alg, &v);                  \
355 }                                                                       \
356 TEXT_SET(scanner_set, name##_modevent);                                 \
357
358 /*
359  * ACL modules implement acl policy.
360  */
361 #define IEEE80211_ACL_MODULE(name, alg, version)                        \
362 _IEEE80211_POLICY_MODULE(acl, name, version);                           \
363 static void                                                             \
364 alg##_modevent(int type)                                                \
365 {                                                                       \
366         if (type == MOD_LOAD)                                           \
367                 ieee80211_aclator_register(&alg);                       \
368         else                                                            \
369                 ieee80211_aclator_unregister(&alg);                     \
370 }                                                                       \
371 TEXT_SET(acl_set, alg##_modevent);                                      \
372
373 /*
374  * Authenticator modules handle 802.1x/WPA authentication.
375  */
376 #define IEEE80211_AUTH_MODULE(name, version)                            \
377         _IEEE80211_POLICY_MODULE(auth, name, version)
378
379 #define IEEE80211_AUTH_ALG(name, alg, v)                                \
380 static void                                                             \
381 name##_modevent(int type)                                               \
382 {                                                                       \
383         if (type == MOD_LOAD)                                           \
384                 ieee80211_authenticator_register(alg, &v);              \
385         else                                                            \
386                 ieee80211_authenticator_unregister(alg);                \
387 }                                                                       \
388 TEXT_SET(auth_set, name##_modevent)
389
390 /*
391  * Rate control modules provide tx rate control support.
392  */
393 #define IEEE80211_RATE_MODULE(alg, version)                             \
394 _IEEE80211_POLICY_MODULE(rate, alg, version);                           \
395 static void                                                             \
396 alg##_modevent(int type)                                                \
397 {                                                                       \
398         /* XXX nothing to do until the rate control framework arrives */\
399 }                                                                       \
400 TEXT_SET(rate##_set, alg##_modevent)
401
402 struct ieee80211req;
403 typedef int ieee80211_ioctl_getfunc(struct ieee80211vap *,
404     struct ieee80211req *);
405 SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
406 #define IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
407
408 typedef int ieee80211_ioctl_setfunc(struct ieee80211vap *,
409     struct ieee80211req *);
410 SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
411 #define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
412 #endif /* _KERNEL */
413
414 /* XXX this stuff belongs elsewhere */
415 /*
416  * Message formats for messages from the net80211 layer to user
417  * applications via the routing socket.  These messages are appended
418  * to an if_announcemsghdr structure.
419  */
420 struct ieee80211_join_event {
421         uint8_t         iev_addr[6];
422 };
423
424 struct ieee80211_leave_event {
425         uint8_t         iev_addr[6];
426 };
427
428 struct ieee80211_replay_event {
429         uint8_t         iev_src[6];     /* src MAC */
430         uint8_t         iev_dst[6];     /* dst MAC */
431         uint8_t         iev_cipher;     /* cipher type */
432         uint8_t         iev_keyix;      /* key id/index */
433         uint64_t        iev_keyrsc;     /* RSC from key */
434         uint64_t        iev_rsc;        /* RSC from frame */
435 };
436
437 struct ieee80211_michael_event {
438         uint8_t         iev_src[6];     /* src MAC */
439         uint8_t         iev_dst[6];     /* dst MAC */
440         uint8_t         iev_cipher;     /* cipher type */
441         uint8_t         iev_keyix;      /* key id/index */
442 };
443
444 struct ieee80211_wds_event {
445         uint8_t         iev_addr[6];
446 };
447
448 struct ieee80211_csa_event {
449         uint32_t        iev_flags;      /* channel flags */
450         uint16_t        iev_freq;       /* setting in Mhz */
451         uint8_t         iev_ieee;       /* IEEE channel number */
452         uint8_t         iev_mode;       /* CSA mode */
453         uint8_t         iev_count;      /* CSA count */
454 };
455
456 struct ieee80211_cac_event {
457         uint32_t        iev_flags;      /* channel flags */
458         uint16_t        iev_freq;       /* setting in Mhz */
459         uint8_t         iev_ieee;       /* IEEE channel number */
460         /* XXX timestamp? */
461         uint8_t         iev_type;       /* IEEE80211_NOTIFY_CAC_* */
462 };
463
464 struct ieee80211_radar_event {
465         uint32_t        iev_flags;      /* channel flags */
466         uint16_t        iev_freq;       /* setting in Mhz */
467         uint8_t         iev_ieee;       /* IEEE channel number */
468         /* XXX timestamp? */
469 };
470
471 struct ieee80211_auth_event {
472         uint8_t         iev_addr[6];
473 };
474
475 struct ieee80211_deauth_event {
476         uint8_t         iev_addr[6];
477 };
478
479 struct ieee80211_country_event {
480         uint8_t         iev_addr[6];
481         uint8_t         iev_cc[2];      /* ISO country code */
482 };
483
484 struct ieee80211_radio_event {
485         uint8_t         iev_state;      /* 1 on, 0 off */
486 };
487
488 #define RTM_IEEE80211_ASSOC     100     /* station associate (bss mode) */
489 #define RTM_IEEE80211_REASSOC   101     /* station re-associate (bss mode) */
490 #define RTM_IEEE80211_DISASSOC  102     /* station disassociate (bss mode) */
491 #define RTM_IEEE80211_JOIN      103     /* station join (ap mode) */
492 #define RTM_IEEE80211_LEAVE     104     /* station leave (ap mode) */
493 #define RTM_IEEE80211_SCAN      105     /* scan complete, results available */
494 #define RTM_IEEE80211_REPLAY    106     /* sequence counter replay detected */
495 #define RTM_IEEE80211_MICHAEL   107     /* Michael MIC failure detected */
496 #define RTM_IEEE80211_REJOIN    108     /* station re-associate (ap mode) */
497 #define RTM_IEEE80211_WDS       109     /* WDS discovery (ap mode) */
498 #define RTM_IEEE80211_CSA       110     /* Channel Switch Announcement event */
499 #define RTM_IEEE80211_RADAR     111     /* radar event */
500 #define RTM_IEEE80211_CAC       112     /* Channel Availability Check event */
501 #define RTM_IEEE80211_DEAUTH    113     /* station deauthenticate */
502 #define RTM_IEEE80211_AUTH      114     /* station authenticate (ap mode) */
503 #define RTM_IEEE80211_COUNTRY   115     /* discovered country code (sta mode) */
504 #define RTM_IEEE80211_RADIO     116     /* RF kill switch state change */
505
506 /*
507  * Structure prepended to raw packets sent through the bpf
508  * interface when set to DLT_IEEE802_11_RADIO.  This allows
509  * user applications to specify pretty much everything in
510  * an Atheros tx descriptor.  XXX need to generalize.
511  *
512  * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
513  * XXX sa_data area.
514  */
515 struct ieee80211_bpf_params {
516         uint8_t         ibp_vers;       /* version */
517 #define IEEE80211_BPF_VERSION   0
518         uint8_t         ibp_len;        /* header length in bytes */
519         uint8_t         ibp_flags;
520 #define IEEE80211_BPF_SHORTPRE  0x01    /* tx with short preamble */
521 #define IEEE80211_BPF_NOACK     0x02    /* tx with no ack */
522 #define IEEE80211_BPF_CRYPTO    0x04    /* tx with h/w encryption */
523 #define IEEE80211_BPF_FCS       0x10    /* frame incldues FCS */
524 #define IEEE80211_BPF_DATAPAD   0x20    /* frame includes data padding */
525 #define IEEE80211_BPF_RTS       0x40    /* tx with RTS/CTS */
526 #define IEEE80211_BPF_CTS       0x80    /* tx with CTS only */
527         uint8_t         ibp_pri;        /* WME/WMM AC+tx antenna */
528         uint8_t         ibp_try0;       /* series 1 try count */
529         uint8_t         ibp_rate0;      /* series 1 IEEE tx rate */
530         uint8_t         ibp_power;      /* tx power (device units) */
531         uint8_t         ibp_ctsrate;    /* IEEE tx rate for CTS */
532         uint8_t         ibp_try1;       /* series 2 try count */
533         uint8_t         ibp_rate1;      /* series 2 IEEE tx rate */
534         uint8_t         ibp_try2;       /* series 3 try count */
535         uint8_t         ibp_rate2;      /* series 3 IEEE tx rate */
536         uint8_t         ibp_try3;       /* series 4 try count */
537         uint8_t         ibp_rate3;      /* series 4 IEEE tx rate */
538 };
539 #endif /* _NET80211_IEEE80211_FREEBSD_H_ */