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