FreeBSD kernel WLAN code
ieee80211_freebsd.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2003-2008 Sam Leffler, Errno Consulting
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $FreeBSD$
28 */
29#ifndef _NET80211_IEEE80211_FREEBSD_H_
30#define _NET80211_IEEE80211_FREEBSD_H_
31
32#ifdef _KERNEL
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/counter.h>
36#include <sys/lock.h>
37#include <sys/mutex.h>
38#include <sys/rwlock.h>
39#include <sys/sysctl.h>
40#include <sys/taskqueue.h>
41#include <sys/time.h>
42
43#include <net/debugnet.h>
44
45/*
46 * priv(9) NET80211 checks.
47 */
48struct ieee80211vap;
50 struct ifnet *);
52 struct ifnet *);
54 struct ifnet *);
56 struct ifnet *);
57
58/*
59 * Common state locking definitions.
60 */
61typedef struct {
62 char name[16]; /* e.g. "ath0_com_lock" */
63 struct mtx mtx;
65#define IEEE80211_LOCK_INIT(_ic, _name) do { \
66 ieee80211_com_lock_t *cl = &(_ic)->ic_comlock; \
67 snprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name); \
68 mtx_init(&cl->mtx, cl->name, NULL, MTX_DEF | MTX_RECURSE); \
69} while (0)
70#define IEEE80211_LOCK_OBJ(_ic) (&(_ic)->ic_comlock.mtx)
71#define IEEE80211_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_LOCK_OBJ(_ic))
72#define IEEE80211_LOCK(_ic) mtx_lock(IEEE80211_LOCK_OBJ(_ic))
73#define IEEE80211_UNLOCK(_ic) mtx_unlock(IEEE80211_LOCK_OBJ(_ic))
74#define IEEE80211_LOCK_ASSERT(_ic) \
75 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED)
76#define IEEE80211_UNLOCK_ASSERT(_ic) \
77 mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_NOTOWNED)
78
79/*
80 * Transmit lock.
81 *
82 * This is a (mostly) temporary lock designed to serialise all of the
83 * transmission operations throughout the stack.
84 */
85typedef struct {
86 char name[16]; /* e.g. "ath0_tx_lock" */
87 struct mtx mtx;
89#define IEEE80211_TX_LOCK_INIT(_ic, _name) do { \
90 ieee80211_tx_lock_t *cl = &(_ic)->ic_txlock; \
91 snprintf(cl->name, sizeof(cl->name), "%s_tx_lock", _name); \
92 mtx_init(&cl->mtx, cl->name, NULL, MTX_DEF); \
93} while (0)
94#define IEEE80211_TX_LOCK_OBJ(_ic) (&(_ic)->ic_txlock.mtx)
95#define IEEE80211_TX_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_TX_LOCK_OBJ(_ic))
96#define IEEE80211_TX_LOCK(_ic) mtx_lock(IEEE80211_TX_LOCK_OBJ(_ic))
97#define IEEE80211_TX_UNLOCK(_ic) mtx_unlock(IEEE80211_TX_LOCK_OBJ(_ic))
98#define IEEE80211_TX_LOCK_ASSERT(_ic) \
99 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_OWNED)
100#define IEEE80211_TX_UNLOCK_ASSERT(_ic) \
101 mtx_assert(IEEE80211_TX_LOCK_OBJ(_ic), MA_NOTOWNED)
102
103/*
104 * Stageq / ni_tx_superg lock
105 */
106typedef struct {
107 char name[16]; /* e.g. "ath0_ff_lock" */
108 struct mtx mtx;
110#define IEEE80211_FF_LOCK_INIT(_ic, _name) do { \
111 ieee80211_ff_lock_t *fl = &(_ic)->ic_fflock; \
112 snprintf(fl->name, sizeof(fl->name), "%s_ff_lock", _name); \
113 mtx_init(&fl->mtx, fl->name, NULL, MTX_DEF); \
114} while (0)
115#define IEEE80211_FF_LOCK_OBJ(_ic) (&(_ic)->ic_fflock.mtx)
116#define IEEE80211_FF_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_FF_LOCK_OBJ(_ic))
117#define IEEE80211_FF_LOCK(_ic) mtx_lock(IEEE80211_FF_LOCK_OBJ(_ic))
118#define IEEE80211_FF_UNLOCK(_ic) mtx_unlock(IEEE80211_FF_LOCK_OBJ(_ic))
119#define IEEE80211_FF_LOCK_ASSERT(_ic) \
120 mtx_assert(IEEE80211_FF_LOCK_OBJ(_ic), MA_OWNED)
121
122/*
123 * Node locking definitions.
124 */
125typedef struct {
126 char name[16]; /* e.g. "ath0_node_lock" */
127 struct mtx mtx;
129#define IEEE80211_NODE_LOCK_INIT(_nt, _name) do { \
130 ieee80211_node_lock_t *nl = &(_nt)->nt_nodelock; \
131 snprintf(nl->name, sizeof(nl->name), "%s_node_lock", _name); \
132 mtx_init(&nl->mtx, nl->name, NULL, MTX_DEF | MTX_RECURSE); \
133} while (0)
134#define IEEE80211_NODE_LOCK_OBJ(_nt) (&(_nt)->nt_nodelock.mtx)
135#define IEEE80211_NODE_LOCK_DESTROY(_nt) \
136 mtx_destroy(IEEE80211_NODE_LOCK_OBJ(_nt))
137#define IEEE80211_NODE_LOCK(_nt) \
138 mtx_lock(IEEE80211_NODE_LOCK_OBJ(_nt))
139#define IEEE80211_NODE_IS_LOCKED(_nt) \
140 mtx_owned(IEEE80211_NODE_LOCK_OBJ(_nt))
141#define IEEE80211_NODE_UNLOCK(_nt) \
142 mtx_unlock(IEEE80211_NODE_LOCK_OBJ(_nt))
143#define IEEE80211_NODE_LOCK_ASSERT(_nt) \
144 mtx_assert(IEEE80211_NODE_LOCK_OBJ(_nt), MA_OWNED)
145
146/*
147 * Power-save queue definitions.
148 */
149typedef struct mtx ieee80211_psq_lock_t;
150#define IEEE80211_PSQ_INIT(_psq, _name) \
151 mtx_init(&(_psq)->psq_lock, _name, "802.11 ps q", MTX_DEF)
152#define IEEE80211_PSQ_DESTROY(_psq) mtx_destroy(&(_psq)->psq_lock)
153#define IEEE80211_PSQ_LOCK(_psq) mtx_lock(&(_psq)->psq_lock)
154#define IEEE80211_PSQ_UNLOCK(_psq) mtx_unlock(&(_psq)->psq_lock)
155
156#ifndef IF_PREPEND_LIST
157#define _IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do { \
158 (mtail)->m_nextpkt = (ifq)->ifq_head; \
159 if ((ifq)->ifq_tail == NULL) \
160 (ifq)->ifq_tail = (mtail); \
161 (ifq)->ifq_head = (mhead); \
162 (ifq)->ifq_len += (mcount); \
163} while (0)
164#define IF_PREPEND_LIST(ifq, mhead, mtail, mcount) do { \
165 IF_LOCK(ifq); \
166 _IF_PREPEND_LIST(ifq, mhead, mtail, mcount); \
167 IF_UNLOCK(ifq); \
168} while (0)
169#endif /* IF_PREPEND_LIST */
170
171/*
172 * Age queue definitions.
173 */
174typedef struct mtx ieee80211_ageq_lock_t;
175#define IEEE80211_AGEQ_INIT(_aq, _name) \
176 mtx_init(&(_aq)->aq_lock, _name, "802.11 age q", MTX_DEF)
177#define IEEE80211_AGEQ_DESTROY(_aq) mtx_destroy(&(_aq)->aq_lock)
178#define IEEE80211_AGEQ_LOCK(_aq) mtx_lock(&(_aq)->aq_lock)
179#define IEEE80211_AGEQ_UNLOCK(_aq) mtx_unlock(&(_aq)->aq_lock)
180
181/*
182 * 802.1x MAC ACL database locking definitions.
183 */
184typedef struct mtx acl_lock_t;
185#define ACL_LOCK_INIT(_as, _name) \
186 mtx_init(&(_as)->as_lock, _name, "802.11 ACL", MTX_DEF)
187#define ACL_LOCK_DESTROY(_as) mtx_destroy(&(_as)->as_lock)
188#define ACL_LOCK(_as) mtx_lock(&(_as)->as_lock)
189#define ACL_UNLOCK(_as) mtx_unlock(&(_as)->as_lock)
190#define ACL_LOCK_ASSERT(_as) \
191 mtx_assert((&(_as)->as_lock), MA_OWNED)
192
193/*
194 * Scan table definitions.
195 */
197#define IEEE80211_SCAN_TABLE_LOCK_INIT(_st, _name) \
198 mtx_init(&(_st)->st_lock, _name, "802.11 scan table", MTX_DEF)
199#define IEEE80211_SCAN_TABLE_LOCK_DESTROY(_st) mtx_destroy(&(_st)->st_lock)
200#define IEEE80211_SCAN_TABLE_LOCK(_st) mtx_lock(&(_st)->st_lock)
201#define IEEE80211_SCAN_TABLE_UNLOCK(_st) mtx_unlock(&(_st)->st_lock)
202
203typedef struct mtx ieee80211_scan_iter_lock_t;
204#define IEEE80211_SCAN_ITER_LOCK_INIT(_st, _name) \
205 mtx_init(&(_st)->st_scanlock, _name, "802.11 scangen", MTX_DEF)
206#define IEEE80211_SCAN_ITER_LOCK_DESTROY(_st) mtx_destroy(&(_st)->st_scanlock)
207#define IEEE80211_SCAN_ITER_LOCK(_st) mtx_lock(&(_st)->st_scanlock)
208#define IEEE80211_SCAN_ITER_UNLOCK(_st) mtx_unlock(&(_st)->st_scanlock)
209
210/*
211 * Mesh node/routing definitions.
212 */
213typedef struct mtx ieee80211_rte_lock_t;
214#define MESH_RT_ENTRY_LOCK_INIT(_rt, _name) \
215 mtx_init(&(rt)->rt_lock, _name, "802.11s route entry", MTX_DEF)
216#define MESH_RT_ENTRY_LOCK_DESTROY(_rt) \
217 mtx_destroy(&(_rt)->rt_lock)
218#define MESH_RT_ENTRY_LOCK(rt) mtx_lock(&(rt)->rt_lock)
219#define MESH_RT_ENTRY_LOCK_ASSERT(rt) mtx_assert(&(rt)->rt_lock, MA_OWNED)
220#define MESH_RT_ENTRY_UNLOCK(rt) mtx_unlock(&(rt)->rt_lock)
221
222typedef struct mtx ieee80211_rt_lock_t;
223#define MESH_RT_LOCK(ms) mtx_lock(&(ms)->ms_rt_lock)
224#define MESH_RT_LOCK_ASSERT(ms) mtx_assert(&(ms)->ms_rt_lock, MA_OWNED)
225#define MESH_RT_UNLOCK(ms) mtx_unlock(&(ms)->ms_rt_lock)
226#define MESH_RT_LOCK_INIT(ms, name) \
227 mtx_init(&(ms)->ms_rt_lock, name, "802.11s routing table", MTX_DEF)
228#define MESH_RT_LOCK_DESTROY(ms) \
229 mtx_destroy(&(ms)->ms_rt_lock)
230
231/*
232 * Node reference counting definitions.
233 *
234 * ieee80211_node_initref initialize the reference count to 1
235 * ieee80211_node_incref add a reference
236 * ieee80211_node_decref remove a reference
237 * ieee80211_node_dectestref remove a reference and return 1 if this
238 * is the last reference, otherwise 0
239 * ieee80211_node_refcnt reference count for printing (only)
240 */
241#include <machine/atomic.h>
242
243struct ieee80211vap;
247
248#define ieee80211_node_initref(_ni) \
249 do { ((_ni)->ni_refcnt = 1); } while (0)
250#define ieee80211_node_incref(_ni) \
251 atomic_add_int(&(_ni)->ni_refcnt, 1)
252#define ieee80211_node_decref(_ni) \
253 atomic_subtract_int(&(_ni)->ni_refcnt, 1)
254struct ieee80211_node;
256#define ieee80211_node_refcnt(_ni) (_ni)->ni_refcnt
257
258struct ifqueue;
259void ieee80211_drain_ifq(struct ifqueue *);
260void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *);
261
263const char * ieee80211_get_vap_ifname(struct ieee80211vap *);
264
265#define IFNET_IS_UP_RUNNING(_ifp) \
266 (((_ifp)->if_flags & IFF_UP) && \
267 ((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
268
269#define msecs_to_ticks(ms) MSEC_2_TICKS(ms)
270#define ticks_to_msecs(t) TICKS_2_MSEC(t)
271#define ticks_to_secs(t) ((t) / hz)
272
273#define ieee80211_time_after(a,b) ((int)(b) - (int)(a) < 0)
274#define ieee80211_time_before(a,b) ieee80211_time_after(b,a)
275#define ieee80211_time_after_eq(a,b) ((int)(a) - (int)(b) >= 0)
276#define ieee80211_time_before_eq(a,b) ieee80211_time_after_eq(b,a)
277
278struct mbuf *ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen);
279
280/* tx path usage */
281#define M_ENCAP M_PROTO1 /* 802.11 encap done */
282#define M_EAPOL M_PROTO3 /* PAE/EAPOL frame */
283#define M_PWR_SAV M_PROTO4 /* bypass PS handling */
284#define M_MORE_DATA M_PROTO5 /* more data frames to follow */
285#define M_FF M_PROTO6 /* fast frame / A-MSDU */
286#define M_TXCB M_PROTO7 /* do tx complete callback */
287#define M_AMPDU_MPDU M_PROTO8 /* ok for A-MPDU aggregation */
288#define M_FRAG M_PROTO9 /* frame fragmentation */
289#define M_FIRSTFRAG M_PROTO10 /* first frame fragment */
290#define M_LASTFRAG M_PROTO11 /* last frame fragment */
291
292#define M_80211_TX \
293 (M_ENCAP|M_EAPOL|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB| \
294 M_AMPDU_MPDU|M_FRAG|M_FIRSTFRAG|M_LASTFRAG)
295
296/* rx path usage */
297#define M_AMPDU M_PROTO1 /* A-MPDU subframe */
298#define M_WEP M_PROTO2 /* WEP done by hardware */
299#if 0
300#define M_AMPDU_MPDU M_PROTO8 /* A-MPDU re-order done */
301#endif
302#define M_80211_RX (M_AMPDU|M_WEP|M_AMPDU_MPDU)
303
304#define IEEE80211_MBUF_TX_FLAG_BITS \
305 M_FLAG_BITS \
306 "\15M_ENCAP\17M_EAPOL\20M_PWR_SAV\21M_MORE_DATA\22M_FF\23M_TXCB" \
307 "\24M_AMPDU_MPDU\25M_FRAG\26M_FIRSTFRAG\27M_LASTFRAG"
308
309#define IEEE80211_MBUF_RX_FLAG_BITS \
310 M_FLAG_BITS \
311 "\15M_AMPDU\16M_WEP\24M_AMPDU_MPDU"
312
313/*
314 * Store WME access control bits in the vlan tag.
315 * This is safe since it's done after the packet is classified
316 * (where we use any previous tag) and because it's passed
317 * directly in to the driver and there's no chance someone
318 * else will clobber them on us.
319 */
320#define M_WME_SETAC(m, ac) \
321 ((m)->m_pkthdr.ether_vtag = (ac))
322#define M_WME_GETAC(m) ((m)->m_pkthdr.ether_vtag)
323
324/*
325 * Mbufs on the power save queue are tagged with an age and
326 * timed out. We reuse the hardware checksum field in the
327 * mbuf packet header to store this data.
328 */
329#define M_AGE_SET(m,v) (m->m_pkthdr.csum_data = v)
330#define M_AGE_GET(m) (m->m_pkthdr.csum_data)
331#define M_AGE_SUB(m,adj) (m->m_pkthdr.csum_data -= adj)
332
333/*
334 * Store the sequence number.
335 */
336#define M_SEQNO_SET(m, seqno) \
337 ((m)->m_pkthdr.tso_segsz = (seqno))
338#define M_SEQNO_GET(m) ((m)->m_pkthdr.tso_segsz)
339
340#define MTAG_ABI_NET80211 1132948340 /* net80211 ABI */
341
343 void (*func)(struct ieee80211_node *, void *, int status);
344 void *arg;
345};
346#define NET80211_TAG_CALLBACK 0 /* xmit complete callback */
347int ieee80211_add_callback(struct mbuf *m,
348 void (*func)(struct ieee80211_node *, void *, int), void *arg);
349void ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int);
350
351#define NET80211_TAG_XMIT_PARAMS 1
352/* See below; this is after the bpf_params definition */
353
354#define NET80211_TAG_RECV_PARAMS 2
355
356#define NET80211_TAG_TOA_PARAMS 3
357
358struct ieee80211com;
359int ieee80211_parent_xmitpkt(struct ieee80211com *, struct mbuf *);
360int ieee80211_vap_xmitpkt(struct ieee80211vap *, struct mbuf *);
361
362void net80211_get_random_bytes(void *, size_t);
363
368
369SYSCTL_DECL(_net_wlan);
370int ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS);
371
372void ieee80211_load_module(const char *);
373
374/*
375 * A "policy module" is an adjunct module to net80211 that provides
376 * functionality that typically includes policy decisions. This
377 * modularity enables extensibility and vendor-supplied functionality.
378 */
379#define _IEEE80211_POLICY_MODULE(policy, name, version) \
380typedef void (*policy##_setup)(int); \
381SET_DECLARE(policy##_set, policy##_setup); \
382static int \
383wlan_##name##_modevent(module_t mod, int type, void *unused) \
384{ \
385 policy##_setup * const *iter, f; \
386 switch (type) { \
387 case MOD_LOAD: \
388 SET_FOREACH(iter, policy##_set) { \
389 f = (void*) *iter; \
390 f(type); \
391 } \
392 return 0; \
393 case MOD_UNLOAD: \
394 case MOD_QUIESCE: \
395 if (nrefs) { \
396 printf("wlan_" #name ": still in use " \
397 "(%u dynamic refs)\n", nrefs); \
398 return EBUSY; \
399 } \
400 if (type == MOD_UNLOAD) { \
401 SET_FOREACH(iter, policy##_set) { \
402 f = (void*) *iter; \
403 f(type); \
404 } \
405 } \
406 return 0; \
407 } \
408 return EINVAL; \
409} \
410static moduledata_t name##_mod = { \
411 "wlan_" #name, \
412 wlan_##name##_modevent, \
413 0 \
414}; \
415DECLARE_MODULE(wlan_##name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
416MODULE_VERSION(wlan_##name, version); \
417MODULE_DEPEND(wlan_##name, wlan, 1, 1, 1)
418
419/*
420 * Crypto modules implement cipher support.
421 */
422#define IEEE80211_CRYPTO_MODULE(name, version) \
423_IEEE80211_POLICY_MODULE(crypto, name, version); \
424static void \
425name##_modevent(int type) \
426{ \
427 if (type == MOD_LOAD) \
428 ieee80211_crypto_register(&name); \
429 else \
430 ieee80211_crypto_unregister(&name); \
431} \
432TEXT_SET(crypto##_set, name##_modevent)
433
434/*
435 * Scanner modules provide scanning policy.
436 */
437#define IEEE80211_SCANNER_MODULE(name, version) \
438 _IEEE80211_POLICY_MODULE(scanner, name, version)
439
440#define IEEE80211_SCANNER_ALG(name, alg, v) \
441static void \
442name##_modevent(int type) \
443{ \
444 if (type == MOD_LOAD) \
445 ieee80211_scanner_register(alg, &v); \
446 else \
447 ieee80211_scanner_unregister(alg, &v); \
448} \
449TEXT_SET(scanner_set, name##_modevent); \
450
451/*
452 * ACL modules implement acl policy.
453 */
454#define IEEE80211_ACL_MODULE(name, alg, version) \
455_IEEE80211_POLICY_MODULE(acl, name, version); \
456static void \
457alg##_modevent(int type) \
458{ \
459 if (type == MOD_LOAD) \
460 ieee80211_aclator_register(&alg); \
461 else \
462 ieee80211_aclator_unregister(&alg); \
463} \
464TEXT_SET(acl_set, alg##_modevent); \
465
466/*
467 * Authenticator modules handle 802.1x/WPA authentication.
468 */
469#define IEEE80211_AUTH_MODULE(name, version) \
470 _IEEE80211_POLICY_MODULE(auth, name, version)
471
472#define IEEE80211_AUTH_ALG(name, alg, v) \
473static void \
474name##_modevent(int type) \
475{ \
476 if (type == MOD_LOAD) \
477 ieee80211_authenticator_register(alg, &v); \
478 else \
479 ieee80211_authenticator_unregister(alg); \
480} \
481TEXT_SET(auth_set, name##_modevent)
482
483/*
484 * Rate control modules provide tx rate control support.
485 */
486#define IEEE80211_RATECTL_MODULE(alg, version) \
487 _IEEE80211_POLICY_MODULE(ratectl, alg, version); \
488
489#define IEEE80211_RATECTL_ALG(name, alg, v) \
490static void \
491alg##_modevent(int type) \
492{ \
493 if (type == MOD_LOAD) \
494 ieee80211_ratectl_register(alg, &v); \
495 else \
496 ieee80211_ratectl_unregister(alg); \
497} \
498TEXT_SET(ratectl##_set, alg##_modevent)
499
500struct ieee80211req;
502 struct ieee80211req *);
503SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc);
504#define IEEE80211_IOCTL_GET(_name, _get) TEXT_SET(ieee80211_ioctl_getset, _get)
505
507 struct ieee80211req *);
508SET_DECLARE(ieee80211_ioctl_setset, ieee80211_ioctl_setfunc);
509#define IEEE80211_IOCTL_SET(_name, _set) TEXT_SET(ieee80211_ioctl_setset, _set)
510
511#ifdef DEBUGNET
512typedef void debugnet80211_init_t(struct ieee80211com *, int *nrxr, int *ncl,
513 int *clsize);
514typedef void debugnet80211_event_t(struct ieee80211com *, enum debugnet_ev);
515typedef int debugnet80211_poll_t(struct ieee80211com *, int);
516
517struct debugnet80211_methods {
518 debugnet80211_init_t *dn8_init;
519 debugnet80211_event_t *dn8_event;
520 debugnet80211_poll_t *dn8_poll;
521};
522
523#define DEBUGNET80211_DEFINE(driver) \
524 static debugnet80211_init_t driver##_debugnet80211_init; \
525 static debugnet80211_event_t driver##_debugnet80211_event; \
526 static debugnet80211_poll_t driver##_debugnet80211_poll; \
527 \
528 static struct debugnet80211_methods driver##_debugnet80211_methods = { \
529 .dn8_init = driver##_debugnet80211_init, \
530 .dn8_event = driver##_debugnet80211_event, \
531 .dn8_poll = driver##_debugnet80211_poll, \
532 }
533#define DEBUGNET80211_SET(ic, driver) \
534 (ic)->ic_debugnet_meth = &driver##_debugnet80211_methods
535#else
536#define DEBUGNET80211_DEFINE(driver)
537#define DEBUGNET80211_SET(ic, driver)
538#endif /* DEBUGNET */
539
540#endif /* _KERNEL */
541
542/* XXX this stuff belongs elsewhere */
543/*
544 * Message formats for messages from the net80211 layer to user
545 * applications via the routing socket. These messages are appended
546 * to an if_announcemsghdr structure.
547 */
549 uint8_t iev_addr[6];
550};
551
553 uint8_t iev_addr[6];
554};
555
557 uint8_t iev_src[6]; /* src MAC */
558 uint8_t iev_dst[6]; /* dst MAC */
559 uint8_t iev_cipher; /* cipher type */
560 uint8_t iev_keyix; /* key id/index */
561 uint64_t iev_keyrsc; /* RSC from key */
562 uint64_t iev_rsc; /* RSC from frame */
563};
564
566 uint8_t iev_src[6]; /* src MAC */
567 uint8_t iev_dst[6]; /* dst MAC */
568 uint8_t iev_cipher; /* cipher type */
569 uint8_t iev_keyix; /* key id/index */
570};
571
573 uint8_t iev_addr[6];
574};
575
577 uint32_t iev_flags; /* channel flags */
578 uint16_t iev_freq; /* setting in Mhz */
579 uint8_t iev_ieee; /* IEEE channel number */
580 uint8_t iev_mode; /* CSA mode */
581 uint8_t iev_count; /* CSA count */
582};
583
585 uint32_t iev_flags; /* channel flags */
586 uint16_t iev_freq; /* setting in Mhz */
587 uint8_t iev_ieee; /* IEEE channel number */
588 /* XXX timestamp? */
589 uint8_t iev_type; /* IEEE80211_NOTIFY_CAC_* */
590};
591
593 uint32_t iev_flags; /* channel flags */
594 uint16_t iev_freq; /* setting in Mhz */
595 uint8_t iev_ieee; /* IEEE channel number */
596 /* XXX timestamp? */
597};
598
600 uint8_t iev_addr[6];
601};
602
604 uint8_t iev_addr[6];
605};
606
608 uint8_t iev_addr[6];
609 uint8_t iev_cc[2]; /* ISO country code */
610};
611
613 uint8_t iev_state; /* 1 on, 0 off */
614};
615
616#define RTM_IEEE80211_ASSOC 100 /* station associate (bss mode) */
617#define RTM_IEEE80211_REASSOC 101 /* station re-associate (bss mode) */
618#define RTM_IEEE80211_DISASSOC 102 /* station disassociate (bss mode) */
619#define RTM_IEEE80211_JOIN 103 /* station join (ap mode) */
620#define RTM_IEEE80211_LEAVE 104 /* station leave (ap mode) */
621#define RTM_IEEE80211_SCAN 105 /* scan complete, results available */
622#define RTM_IEEE80211_REPLAY 106 /* sequence counter replay detected */
623#define RTM_IEEE80211_MICHAEL 107 /* Michael MIC failure detected */
624#define RTM_IEEE80211_REJOIN 108 /* station re-associate (ap mode) */
625#define RTM_IEEE80211_WDS 109 /* WDS discovery (ap mode) */
626#define RTM_IEEE80211_CSA 110 /* Channel Switch Announcement event */
627#define RTM_IEEE80211_RADAR 111 /* radar event */
628#define RTM_IEEE80211_CAC 112 /* Channel Availability Check event */
629#define RTM_IEEE80211_DEAUTH 113 /* station deauthenticate */
630#define RTM_IEEE80211_AUTH 114 /* station authenticate (ap mode) */
631#define RTM_IEEE80211_COUNTRY 115 /* discovered country code (sta mode) */
632#define RTM_IEEE80211_RADIO 116 /* RF kill switch state change */
633
634/*
635 * Structure prepended to raw packets sent through the bpf
636 * interface when set to DLT_IEEE802_11_RADIO. This allows
637 * user applications to specify pretty much everything in
638 * an Atheros tx descriptor. XXX need to generalize.
639 *
640 * XXX cannot be more than 14 bytes as it is copied to a sockaddr's
641 * XXX sa_data area.
642 */
644 uint8_t ibp_vers; /* version */
645#define IEEE80211_BPF_VERSION 0
646 uint8_t ibp_len; /* header length in bytes */
647 uint8_t ibp_flags;
648#define IEEE80211_BPF_SHORTPRE 0x01 /* tx with short preamble */
649#define IEEE80211_BPF_NOACK 0x02 /* tx with no ack */
650#define IEEE80211_BPF_CRYPTO 0x04 /* tx with h/w encryption */
651#define IEEE80211_BPF_FCS 0x10 /* frame incldues FCS */
652#define IEEE80211_BPF_DATAPAD 0x20 /* frame includes data padding */
653#define IEEE80211_BPF_RTS 0x40 /* tx with RTS/CTS */
654#define IEEE80211_BPF_CTS 0x80 /* tx with CTS only */
655 uint8_t ibp_pri; /* WME/WMM AC+tx antenna */
656 uint8_t ibp_try0; /* series 1 try count */
657 uint8_t ibp_rate0; /* series 1 IEEE tx rate */
658 uint8_t ibp_power; /* tx power (device units) */
659 uint8_t ibp_ctsrate; /* IEEE tx rate for CTS */
660 uint8_t ibp_try1; /* series 2 try count */
661 uint8_t ibp_rate1; /* series 2 IEEE tx rate */
662 uint8_t ibp_try2; /* series 3 try count */
663 uint8_t ibp_rate2; /* series 3 IEEE tx rate */
664 uint8_t ibp_try3; /* series 4 try count */
665 uint8_t ibp_rate3; /* series 4 IEEE tx rate */
666};
667
668#ifdef _KERNEL
671};
672int ieee80211_add_xmit_params(struct mbuf *m,
673 const struct ieee80211_bpf_params *);
674int ieee80211_get_xmit_params(struct mbuf *m,
675 struct ieee80211_bpf_params *);
676
678struct ieee80211_rx_stats;
679
680int ieee80211_add_rx_params(struct mbuf *m,
681 const struct ieee80211_rx_stats *rxs);
682int ieee80211_get_rx_params(struct mbuf *m,
683 struct ieee80211_rx_stats *rxs);
684const struct ieee80211_rx_stats * ieee80211_get_rx_params_ptr(struct mbuf *m);
685
688};
689int ieee80211_add_toa_params(struct mbuf *m,
690 const struct ieee80211_toa_params *p);
691int ieee80211_get_toa_params(struct mbuf *m,
692 struct ieee80211_toa_params *p);
693
694#define IEEE80211_F_SURVEY_TIME 0x00000001
695#define IEEE80211_F_SURVEY_TIME_BUSY 0x00000002
696#define IEEE80211_F_SURVEY_NOISE_DBM 0x00000004
697#define IEEE80211_F_SURVEY_TSC 0x00000008
699 uint32_t s_flags;
700 uint32_t s_time;
701 uint32_t s_time_busy;
702 int32_t s_noise;
703 uint64_t s_tsc;
704};
705
706#endif /* _KERNEL */
707
708/*
709 * Malloc API. Other BSD operating systems have slightly
710 * different malloc/free namings (eg DragonflyBSD.)
711 */
712#define IEEE80211_MALLOC malloc
713#define IEEE80211_FREE free
714
715/* XXX TODO: get rid of WAITOK, fix all the users of it? */
716#define IEEE80211_M_NOWAIT M_NOWAIT
717#define IEEE80211_M_WAITOK M_WAITOK
718#define IEEE80211_M_ZERO M_ZERO
719
720/* XXX TODO: the type fields */
721
722#endif /* _NET80211_IEEE80211_FREEBSD_H_ */
struct mtx ieee80211_rte_lock_t
int ieee80211_add_xmit_params(struct mbuf *m, const struct ieee80211_bpf_params *)
int ieee80211_priv_check_vap_setmac(u_long, struct ieee80211vap *, struct ifnet *)
int ieee80211_ioctl_setfunc(struct ieee80211vap *, struct ieee80211req *)
int ieee80211_sysctl_msecs_ticks(SYSCTL_HANDLER_ARGS)
int ieee80211_get_rx_params(struct mbuf *m, struct ieee80211_rx_stats *rxs)
struct mtx ieee80211_ageq_lock_t
struct mbuf * ieee80211_getmgtframe(uint8_t **frm, int headroom, int pktlen)
int ieee80211_priv_check_create_vap(u_long, struct ieee80211vap *, struct ifnet *)
void ieee80211_load_module(const char *)
int ieee80211_get_xmit_params(struct mbuf *m, struct ieee80211_bpf_params *)
int ieee80211_node_dectestref(struct ieee80211_node *ni)
void ieee80211_sysctl_vdetach(struct ieee80211vap *)
int ieee80211_ioctl_getfunc(struct ieee80211vap *, struct ieee80211req *)
void ieee80211_process_callback(struct ieee80211_node *, struct mbuf *, int)
const char * ieee80211_get_vap_ifname(struct ieee80211vap *)
int ieee80211_parent_xmitpkt(struct ieee80211com *, struct mbuf *)
int ieee80211_vap_xmitpkt(struct ieee80211vap *, struct mbuf *)
int ieee80211_add_rx_params(struct mbuf *m, const struct ieee80211_rx_stats *rxs)
void ieee80211_com_vdecref(struct ieee80211vap *)
void ieee80211_sysctl_attach(struct ieee80211com *)
void ieee80211_flush_ifq(struct ifqueue *, struct ieee80211vap *)
int ieee80211_add_callback(struct mbuf *m, void(*func)(struct ieee80211_node *, void *, int), void *arg)
int ieee80211_priv_check_vap_manage(u_long, struct ieee80211vap *, struct ifnet *)
int ieee80211_com_vincref(struct ieee80211vap *)
struct mtx ieee80211_psq_lock_t
const struct ieee80211_rx_stats * ieee80211_get_rx_params_ptr(struct mbuf *m)
void ieee80211_sysctl_vattach(struct ieee80211vap *)
void ieee80211_vap_destroy(struct ieee80211vap *)
struct mtx acl_lock_t
SYSCTL_DECL(_net_wlan)
struct mtx ieee80211_scan_iter_lock_t
void ieee80211_sysctl_detach(struct ieee80211com *)
int ieee80211_priv_check_vap_getkey(u_long, struct ieee80211vap *, struct ifnet *)
struct mtx ieee80211_scan_table_lock_t
struct mtx ieee80211_rt_lock_t
void ieee80211_drain_ifq(struct ifqueue *)
void net80211_get_random_bytes(void *, size_t)
int ieee80211_get_toa_params(struct mbuf *m, struct ieee80211_toa_params *p)
void ieee80211_com_vdetach(struct ieee80211vap *)
SET_DECLARE(ieee80211_ioctl_getset, ieee80211_ioctl_getfunc)
int ieee80211_add_toa_params(struct mbuf *m, const struct ieee80211_toa_params *p)
void(* func)(struct ieee80211_node *, void *, int status)
struct ieee80211_bpf_params params