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