xref: /freebsd/sys/net80211/ieee80211_proto.h (revision c79f192c095af3284e59367e99632020e445ddd1)
11a1e1d21SSam Leffler /*-
27535e66aSSam Leffler  * Copyright (c) 2001 Atsushi Onoe
310ad9a77SSam Leffler  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
41a1e1d21SSam Leffler  * All rights reserved.
51a1e1d21SSam Leffler  *
61a1e1d21SSam Leffler  * Redistribution and use in source and binary forms, with or without
71a1e1d21SSam Leffler  * modification, are permitted provided that the following conditions
81a1e1d21SSam Leffler  * are met:
91a1e1d21SSam Leffler  * 1. Redistributions of source code must retain the above copyright
101a1e1d21SSam Leffler  *    notice, this list of conditions and the following disclaimer.
111a1e1d21SSam Leffler  * 2. Redistributions in binary form must reproduce the above copyright
121a1e1d21SSam Leffler  *    notice, this list of conditions and the following disclaimer in the
131a1e1d21SSam Leffler  *    documentation and/or other materials provided with the distribution.
147535e66aSSam Leffler  *
157535e66aSSam Leffler  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
167535e66aSSam Leffler  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
177535e66aSSam Leffler  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
187535e66aSSam Leffler  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
197535e66aSSam Leffler  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
207535e66aSSam Leffler  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
217535e66aSSam Leffler  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
227535e66aSSam Leffler  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
237535e66aSSam Leffler  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
247535e66aSSam Leffler  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251a1e1d21SSam Leffler  *
261a1e1d21SSam Leffler  * $FreeBSD$
271a1e1d21SSam Leffler  */
281a1e1d21SSam Leffler #ifndef _NET80211_IEEE80211_PROTO_H_
291a1e1d21SSam Leffler #define _NET80211_IEEE80211_PROTO_H_
301a1e1d21SSam Leffler 
311a1e1d21SSam Leffler /*
321a1e1d21SSam Leffler  * 802.11 protocol implementation definitions.
331a1e1d21SSam Leffler  */
341a1e1d21SSam Leffler 
351a1e1d21SSam Leffler enum ieee80211_state {
36a11c9a5cSSam Leffler 	IEEE80211_S_INIT	= 0,	/* default state */
37a11c9a5cSSam Leffler 	IEEE80211_S_SCAN	= 1,	/* scanning */
38a11c9a5cSSam Leffler 	IEEE80211_S_AUTH	= 2,	/* try to authenticate */
39a11c9a5cSSam Leffler 	IEEE80211_S_ASSOC	= 3,	/* try to assoc */
4014fb6b8fSSam Leffler 	IEEE80211_S_CAC		= 4,	/* doing channel availability check */
4114fb6b8fSSam Leffler 	IEEE80211_S_RUN		= 5,	/* operational (e.g. associated) */
4214fb6b8fSSam Leffler 	IEEE80211_S_CSA		= 6,	/* channel switch announce pending */
4314fb6b8fSSam Leffler 	IEEE80211_S_SLEEP	= 7,	/* power save */
441a1e1d21SSam Leffler };
4514fb6b8fSSam Leffler #define	IEEE80211_S_MAX		(IEEE80211_S_SLEEP+1)
461a1e1d21SSam Leffler 
47b032f27cSSam Leffler #define	IEEE80211_SEND_MGMT(_ni,_type,_arg) \
48b032f27cSSam Leffler 	((*(_ni)->ni_ic->ic_send_mgmt)(_ni, _type, _arg))
491b6167d2SSam Leffler 
501a1e1d21SSam Leffler extern	const char *ieee80211_mgt_subtype_name[];
51e8f5c7a8SSam Leffler extern	const char *ieee80211_phymode_name[IEEE80211_MODE_MAX];
52c43feedeSSam Leffler extern	const int ieee80211_opcap[IEEE80211_OPMODE_MAX];
531a1e1d21SSam Leffler 
540942c81cSSam Leffler void	ieee80211_proto_attach(struct ieee80211com *);
550942c81cSSam Leffler void	ieee80211_proto_detach(struct ieee80211com *);
56b032f27cSSam Leffler void	ieee80211_proto_vattach(struct ieee80211vap *);
57b032f27cSSam Leffler void	ieee80211_proto_vdetach(struct ieee80211vap *);
581a1e1d21SSam Leffler 
59b032f27cSSam Leffler void	ieee80211_syncifflag_locked(struct ieee80211com *, int flag);
60b032f27cSSam Leffler void	ieee80211_syncflag(struct ieee80211vap *, int flag);
612bfc8a91SSam Leffler void	ieee80211_syncflag_ht(struct ieee80211vap *, int flag);
62b032f27cSSam Leffler void	ieee80211_syncflag_ext(struct ieee80211vap *, int flag);
63b032f27cSSam Leffler 
64864ab114SAdrian Chadd #define	IEEE80211_R_NF		0x0000001	/* global NF value valid */
65864ab114SAdrian Chadd #define	IEEE80211_R_RSSI	0x0000002	/* global RSSI value valid */
66864ab114SAdrian Chadd #define	IEEE80211_R_C_CHAIN	0x0000004	/* RX chain count valid */
67864ab114SAdrian Chadd #define	IEEE80211_R_C_NF	0x0000008	/* per-chain NF value valid */
68864ab114SAdrian Chadd #define	IEEE80211_R_C_RSSI	0x0000010	/* per-chain RSSI value valid */
69864ab114SAdrian Chadd #define	IEEE80211_R_C_EVM	0x0000020	/* per-chain EVM valid */
70864ab114SAdrian Chadd #define	IEEE80211_R_C_HT40	0x0000040	/* RX'ed packet is 40mhz, pilots 4,5 valid */
71*c79f192cSAdrian Chadd #define	IEEE80211_R_FREQ	0x0000080	/* Freq value populated, MHz */
72*c79f192cSAdrian Chadd #define	IEEE80211_R_IEEE	0x0000100	/* IEEE value populated */
73*c79f192cSAdrian Chadd #define	IEEE80211_R_BAND	0x0000200	/* Frequency band populated */
74864ab114SAdrian Chadd 
75864ab114SAdrian Chadd struct ieee80211_rx_stats {
76864ab114SAdrian Chadd 	uint32_t r_flags;		/* IEEE80211_R_* flags */
77864ab114SAdrian Chadd 	uint8_t c_chain;		/* number of RX chains involved */
78864ab114SAdrian Chadd 	int16_t	c_nf_ctl[IEEE80211_MAX_CHAINS];	/* per-chain NF */
79864ab114SAdrian Chadd 	int16_t	c_nf_ext[IEEE80211_MAX_CHAINS];	/* per-chain NF */
80864ab114SAdrian Chadd 	int16_t	c_rssi_ctl[IEEE80211_MAX_CHAINS];	/* per-chain RSSI */
81864ab114SAdrian Chadd 	int16_t	c_rssi_ext[IEEE80211_MAX_CHAINS];	/* per-chain RSSI */
82864ab114SAdrian Chadd 	uint8_t nf;			/* global NF */
83864ab114SAdrian Chadd 	uint8_t rssi;			/* global RSSI */
84864ab114SAdrian Chadd 	uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS];
85864ab114SAdrian Chadd 					/* per-chain, per-pilot EVM values */
86*c79f192cSAdrian Chadd 	uint16_t c_freq;
87*c79f192cSAdrian Chadd 	uint8_t c_ieee;
88864ab114SAdrian Chadd };
89864ab114SAdrian Chadd 
905463c4a4SSam Leffler #define	ieee80211_input(ni, m, rssi, nf) \
91*c79f192cSAdrian Chadd 	((ni)->ni_vap->iv_input(ni, m, NULL, rssi, nf))
925463c4a4SSam Leffler int	ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int);
93864ab114SAdrian Chadd 
94864ab114SAdrian Chadd int	ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *,
95864ab114SAdrian Chadd 	    struct ieee80211_rx_stats *);
96864ab114SAdrian Chadd int	ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *,
97864ab114SAdrian Chadd 	    struct ieee80211_rx_stats *);
98864ab114SAdrian Chadd 
9999f1b25cSSam Leffler struct ieee80211_bpf_params;
1008ac160cdSSam Leffler int	ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int,
1018ac160cdSSam Leffler 		struct ieee80211_bpf_params *);
102246b5467SSam Leffler int	ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *,
103246b5467SSam Leffler 		const struct ieee80211_bpf_params *);
104cc80eae5SAdrian Chadd #if __FreeBSD_version >= 1000031
105246b5467SSam Leffler int	ieee80211_output(struct ifnet *, struct mbuf *,
10647e8d432SGleb Smirnoff                const struct sockaddr *, struct route *ro);
107cc80eae5SAdrian Chadd #else
108cc80eae5SAdrian Chadd int	ieee80211_output(struct ifnet *, struct mbuf *,
109cc80eae5SAdrian Chadd                struct sockaddr *, struct route *ro);
110cc80eae5SAdrian Chadd #endif
1110e20ac38SAdrian Chadd int	ieee80211_vap_pkt_send_dest(struct ieee80211vap *, struct mbuf *,
1120e20ac38SAdrian Chadd 		struct ieee80211_node *);
1135cda6006SAdrian Chadd int	ieee80211_raw_output(struct ieee80211vap *, struct ieee80211_node *,
1145cda6006SAdrian Chadd 		struct mbuf *, const struct ieee80211_bpf_params *);
11559aa14a9SRui Paulo void	ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int,
11659aa14a9SRui Paulo         const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
11759aa14a9SRui Paulo         const uint8_t [IEEE80211_ADDR_LEN]);
118e7495198SAdrian Chadd int	ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m);
119e7495198SAdrian Chadd void	ieee80211_vap_qflush(struct ifnet *ifp);
120f62121ceSSam Leffler int	ieee80211_send_nulldata(struct ieee80211_node *);
121b032f27cSSam Leffler int	ieee80211_classify(struct ieee80211_node *, struct mbuf *m);
122616190d0SSam Leffler struct mbuf *ieee80211_mbuf_adjust(struct ieee80211vap *, int,
123616190d0SSam Leffler 		struct ieee80211_key *, struct mbuf *);
124339ccfb3SSam Leffler struct mbuf *ieee80211_encap(struct ieee80211vap *, struct ieee80211_node *,
125339ccfb3SSam Leffler 		struct mbuf *);
126b032f27cSSam Leffler int	ieee80211_send_mgmt(struct ieee80211_node *, int, int);
127b032f27cSSam Leffler struct ieee80211_appie;
12868e8e04eSSam Leffler int	ieee80211_send_probereq(struct ieee80211_node *ni,
12968e8e04eSSam Leffler 		const uint8_t sa[IEEE80211_ADDR_LEN],
13068e8e04eSSam Leffler 		const uint8_t da[IEEE80211_ADDR_LEN],
13168e8e04eSSam Leffler 		const uint8_t bssid[IEEE80211_ADDR_LEN],
132b032f27cSSam Leffler 		const uint8_t *ssid, size_t ssidlen);
13374b4c76eSAdrian Chadd struct mbuf *	ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *,
13474b4c76eSAdrian Chadd 		const struct ether_header *);
13536ee7775SAdrian Chadd void	ieee80211_tx_complete(struct ieee80211_node *,
13636ee7775SAdrian Chadd 		struct mbuf *, int);
13774b4c76eSAdrian Chadd 
138b032f27cSSam Leffler /*
139b032f27cSSam Leffler  * The formation of ProbeResponse frames requires guidance to
140b032f27cSSam Leffler  * deal with legacy clients.  When the client is identified as
141b032f27cSSam Leffler  * "legacy 11b" ieee80211_send_proberesp is passed this token.
142b032f27cSSam Leffler  */
143b032f27cSSam Leffler #define	IEEE80211_SEND_LEGACY_11B	0x1	/* legacy 11b client */
144b032f27cSSam Leffler #define	IEEE80211_SEND_LEGACY_11	0x2	/* other legacy client */
145b032f27cSSam Leffler #define	IEEE80211_SEND_LEGACY		0x3	/* any legacy client */
146b032f27cSSam Leffler struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int);
147b032f27cSSam Leffler int	ieee80211_send_proberesp(struct ieee80211vap *,
148b032f27cSSam Leffler 		const uint8_t da[IEEE80211_ADDR_LEN], int);
149b032f27cSSam Leffler struct mbuf *ieee80211_alloc_rts(struct ieee80211com *ic,
150b032f27cSSam Leffler 		const uint8_t [IEEE80211_ADDR_LEN],
151b032f27cSSam Leffler 		const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
152b032f27cSSam Leffler struct mbuf *ieee80211_alloc_cts(struct ieee80211com *,
153b032f27cSSam Leffler 		const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
1548a1b9b6aSSam Leffler 
15559aa14a9SRui Paulo uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *);
15659aa14a9SRui Paulo uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *);
157de981aecSAdrian Chadd uint8_t *ieee80211_add_ssid(uint8_t *, const uint8_t *, u_int);
158d8df5f3dSRui Paulo uint8_t *ieee80211_add_wpa(uint8_t *, const struct ieee80211vap *);
159d8df5f3dSRui Paulo uint8_t *ieee80211_add_rsn(uint8_t *, const struct ieee80211vap *);
160d8df5f3dSRui Paulo uint8_t *ieee80211_add_qos(uint8_t *, const struct ieee80211_node *);
16159aa14a9SRui Paulo uint16_t ieee80211_getcapinfo(struct ieee80211vap *,
16259aa14a9SRui Paulo 		struct ieee80211_channel *);
16359aa14a9SRui Paulo 
1640942c81cSSam Leffler void	ieee80211_reset_erp(struct ieee80211com *);
1650942c81cSSam Leffler void	ieee80211_set_shortslottime(struct ieee80211com *, int onoff);
166b032f27cSSam Leffler int	ieee80211_iserp_rateset(const struct ieee80211_rateset *);
167b032f27cSSam Leffler void	ieee80211_setbasicrates(struct ieee80211_rateset *,
168b032f27cSSam Leffler 		enum ieee80211_phymode);
169b032f27cSSam Leffler void	ieee80211_addbasicrates(struct ieee80211_rateset *,
1708a1b9b6aSSam Leffler 		enum ieee80211_phymode);
1718a1b9b6aSSam Leffler 
1728a1b9b6aSSam Leffler /*
1738a1b9b6aSSam Leffler  * Return the size of the 802.11 header for a management or data frame.
1748a1b9b6aSSam Leffler  */
175a95fa8d3SSam Leffler static __inline int
1768a1b9b6aSSam Leffler ieee80211_hdrsize(const void *data)
1778a1b9b6aSSam Leffler {
1788a1b9b6aSSam Leffler 	const struct ieee80211_frame *wh = data;
1798a1b9b6aSSam Leffler 	int size = sizeof(struct ieee80211_frame);
1808a1b9b6aSSam Leffler 
1818a1b9b6aSSam Leffler 	/* NB: we don't handle control frames */
1828a1b9b6aSSam Leffler 	KASSERT((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL,
1838a1b9b6aSSam Leffler 		("%s: control frame", __func__));
18432bdd57bSSam Leffler 	if (IEEE80211_IS_DSTODS(wh))
1858a1b9b6aSSam Leffler 		size += IEEE80211_ADDR_LEN;
1868a1b9b6aSSam Leffler 	if (IEEE80211_QOS_HAS_SEQ(wh))
18768e8e04eSSam Leffler 		size += sizeof(uint16_t);
1888a1b9b6aSSam Leffler 	return size;
1898a1b9b6aSSam Leffler }
1908a1b9b6aSSam Leffler 
1918a1b9b6aSSam Leffler /*
19268e8e04eSSam Leffler  * Like ieee80211_hdrsize, but handles any type of frame.
1938a1b9b6aSSam Leffler  */
194a95fa8d3SSam Leffler static __inline int
1958a1b9b6aSSam Leffler ieee80211_anyhdrsize(const void *data)
1968a1b9b6aSSam Leffler {
1978a1b9b6aSSam Leffler 	const struct ieee80211_frame *wh = data;
1988a1b9b6aSSam Leffler 
1998a1b9b6aSSam Leffler 	if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) {
2008a1b9b6aSSam Leffler 		switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) {
2018a1b9b6aSSam Leffler 		case IEEE80211_FC0_SUBTYPE_CTS:
2028a1b9b6aSSam Leffler 		case IEEE80211_FC0_SUBTYPE_ACK:
2038a1b9b6aSSam Leffler 			return sizeof(struct ieee80211_frame_ack);
20468e8e04eSSam Leffler 		case IEEE80211_FC0_SUBTYPE_BAR:
20568e8e04eSSam Leffler 			return sizeof(struct ieee80211_frame_bar);
2068a1b9b6aSSam Leffler 		}
2078a1b9b6aSSam Leffler 		return sizeof(struct ieee80211_frame_min);
2088a1b9b6aSSam Leffler 	} else
2098a1b9b6aSSam Leffler 		return ieee80211_hdrsize(data);
2108a1b9b6aSSam Leffler }
2118a1b9b6aSSam Leffler 
2128a1b9b6aSSam Leffler /*
2138a1b9b6aSSam Leffler  * Template for an in-kernel authenticator.  Authenticators
2148a1b9b6aSSam Leffler  * register with the protocol code and are typically loaded
215b032f27cSSam Leffler  * as separate modules as needed.  One special authenticator
216b032f27cSSam Leffler  * is xauth; it intercepts requests so that protocols like
217b032f27cSSam Leffler  * WPA can be handled in user space.
2188a1b9b6aSSam Leffler  */
2198a1b9b6aSSam Leffler struct ieee80211_authenticator {
2208a1b9b6aSSam Leffler 	const char *ia_name;		/* printable name */
221b032f27cSSam Leffler 	int	(*ia_attach)(struct ieee80211vap *);
222b032f27cSSam Leffler 	void	(*ia_detach)(struct ieee80211vap *);
223b032f27cSSam Leffler 	void	(*ia_node_join)(struct ieee80211_node *);
224b032f27cSSam Leffler 	void	(*ia_node_leave)(struct ieee80211_node *);
2258a1b9b6aSSam Leffler };
2260942c81cSSam Leffler void	ieee80211_authenticator_register(int type,
2278a1b9b6aSSam Leffler 		const struct ieee80211_authenticator *);
2280942c81cSSam Leffler void	ieee80211_authenticator_unregister(int type);
2290942c81cSSam Leffler const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth);
2308a1b9b6aSSam Leffler 
231188757f5SSam Leffler struct ieee80211req;
2328a1b9b6aSSam Leffler /*
2338a1b9b6aSSam Leffler  * Template for an MAC ACL policy module.  Such modules
2348a1b9b6aSSam Leffler  * register with the protocol code and are passed the sender's
235b032f27cSSam Leffler  * address of each received auth frame for validation.
2368a1b9b6aSSam Leffler  */
2378a1b9b6aSSam Leffler struct ieee80211_aclator {
2388a1b9b6aSSam Leffler 	const char *iac_name;		/* printable name */
239b032f27cSSam Leffler 	int	(*iac_attach)(struct ieee80211vap *);
240b032f27cSSam Leffler 	void	(*iac_detach)(struct ieee80211vap *);
241b032f27cSSam Leffler 	int	(*iac_check)(struct ieee80211vap *,
2425a8801b0SBernhard Schmidt 			const struct ieee80211_frame *wh);
243b032f27cSSam Leffler 	int	(*iac_add)(struct ieee80211vap *,
24468e8e04eSSam Leffler 			const uint8_t mac[IEEE80211_ADDR_LEN]);
245b032f27cSSam Leffler 	int	(*iac_remove)(struct ieee80211vap *,
24668e8e04eSSam Leffler 			const uint8_t mac[IEEE80211_ADDR_LEN]);
247b032f27cSSam Leffler 	int	(*iac_flush)(struct ieee80211vap *);
248b032f27cSSam Leffler 	int	(*iac_setpolicy)(struct ieee80211vap *, int);
249b032f27cSSam Leffler 	int	(*iac_getpolicy)(struct ieee80211vap *);
250b032f27cSSam Leffler 	int	(*iac_setioctl)(struct ieee80211vap *, struct ieee80211req *);
251b032f27cSSam Leffler 	int	(*iac_getioctl)(struct ieee80211vap *, struct ieee80211req *);
2528a1b9b6aSSam Leffler };
2530942c81cSSam Leffler void	ieee80211_aclator_register(const struct ieee80211_aclator *);
2540942c81cSSam Leffler void	ieee80211_aclator_unregister(const struct ieee80211_aclator *);
2550942c81cSSam Leffler const struct ieee80211_aclator *ieee80211_aclator_get(const char *name);
2568a1b9b6aSSam Leffler 
2578a1b9b6aSSam Leffler /* flags for ieee80211_fix_rate() */
2588a1b9b6aSSam Leffler #define	IEEE80211_F_DOSORT	0x00000001	/* sort rate list */
259b032f27cSSam Leffler #define	IEEE80211_F_DOFRATE	0x00000002	/* use fixed legacy rate */
2608a1b9b6aSSam Leffler #define	IEEE80211_F_DONEGO	0x00000004	/* calc negotiated rate */
2618a1b9b6aSSam Leffler #define	IEEE80211_F_DODEL	0x00000008	/* delete ignore rate */
26268e8e04eSSam Leffler #define	IEEE80211_F_DOBRS	0x00000010	/* check basic rate set */
26368e8e04eSSam Leffler #define	IEEE80211_F_JOIN	0x00000020	/* sta joining our bss */
264b032f27cSSam Leffler #define	IEEE80211_F_DOFMCS	0x00000040	/* use fixed HT rate */
26570e28b9aSSam Leffler int	ieee80211_fix_rate(struct ieee80211_node *,
26670e28b9aSSam Leffler 		struct ieee80211_rateset *, int);
2678a1b9b6aSSam Leffler 
2688a1b9b6aSSam Leffler /*
2698a1b9b6aSSam Leffler  * WME/WMM support.
2708a1b9b6aSSam Leffler  */
2718a1b9b6aSSam Leffler struct wmeParams {
27268e8e04eSSam Leffler 	uint8_t		wmep_acm;
27368e8e04eSSam Leffler 	uint8_t		wmep_aifsn;
27468e8e04eSSam Leffler 	uint8_t		wmep_logcwmin;		/* log2(cwmin) */
27568e8e04eSSam Leffler 	uint8_t		wmep_logcwmax;		/* log2(cwmax) */
27668e8e04eSSam Leffler 	uint8_t		wmep_txopLimit;
27768e8e04eSSam Leffler 	uint8_t		wmep_noackPolicy;	/* 0 (ack), 1 (no ack) */
2788a1b9b6aSSam Leffler };
2795a11fbcaSSam Leffler #define	IEEE80211_TXOP_TO_US(_txop)	((_txop)<<5)
2805a11fbcaSSam Leffler #define	IEEE80211_US_TO_TXOP(_us)	((_us)>>5)
2818a1b9b6aSSam Leffler 
2828a1b9b6aSSam Leffler struct chanAccParams {
28368e8e04eSSam Leffler 	uint8_t		cap_info;		/* version of the current set */
2848a1b9b6aSSam Leffler 	struct wmeParams cap_wmeParams[WME_NUM_AC];
2858a1b9b6aSSam Leffler };
2868a1b9b6aSSam Leffler 
2878a1b9b6aSSam Leffler struct ieee80211_wme_state {
2888a1b9b6aSSam Leffler 	u_int	wme_flags;
2898a1b9b6aSSam Leffler #define	WME_F_AGGRMODE	0x00000001	/* STATUS: WME agressive mode */
2908a1b9b6aSSam Leffler 	u_int	wme_hipri_traffic;	/* VI/VO frames in beacon interval */
2918a1b9b6aSSam Leffler 	u_int	wme_hipri_switch_thresh;/* agressive mode switch thresh */
2928a1b9b6aSSam Leffler 	u_int	wme_hipri_switch_hysteresis;/* agressive mode switch hysteresis */
2938a1b9b6aSSam Leffler 
2948a1b9b6aSSam Leffler 	struct wmeParams wme_params[4];		/* from assoc resp for each AC*/
2958a1b9b6aSSam Leffler 	struct chanAccParams wme_wmeChanParams;	/* WME params applied to self */
2968a1b9b6aSSam Leffler 	struct chanAccParams wme_wmeBssChanParams;/* WME params bcast to stations */
2978a1b9b6aSSam Leffler 	struct chanAccParams wme_chanParams;	/* params applied to self */
2988a1b9b6aSSam Leffler 	struct chanAccParams wme_bssChanParams;	/* params bcast to stations */
2998a1b9b6aSSam Leffler 
3008a1b9b6aSSam Leffler 	int	(*wme_update)(struct ieee80211com *);
3018a1b9b6aSSam Leffler };
3028a1b9b6aSSam Leffler 
303b032f27cSSam Leffler void	ieee80211_wme_initparams(struct ieee80211vap *);
304b032f27cSSam Leffler void	ieee80211_wme_updateparams(struct ieee80211vap *);
305b032f27cSSam Leffler void	ieee80211_wme_updateparams_locked(struct ieee80211vap *);
3068a1b9b6aSSam Leffler 
307b032f27cSSam Leffler /*
308b032f27cSSam Leffler  * Return the WME TID from a QoS frame.  If no TID
309b032f27cSSam Leffler  * is present return the index for the "non-QoS" entry.
310b032f27cSSam Leffler  */
311b032f27cSSam Leffler static __inline uint8_t
312b032f27cSSam Leffler ieee80211_gettid(const struct ieee80211_frame *wh)
313b032f27cSSam Leffler {
314b032f27cSSam Leffler 	uint8_t tid;
315b032f27cSSam Leffler 
316b032f27cSSam Leffler 	if (IEEE80211_QOS_HAS_SEQ(wh)) {
31732bdd57bSSam Leffler 		if (IEEE80211_IS_DSTODS(wh))
31832bdd57bSSam Leffler 			tid = ((const struct ieee80211_qosframe_addr4 *)wh)->
31932bdd57bSSam Leffler 				i_qos[0];
32032bdd57bSSam Leffler 		else
32132bdd57bSSam Leffler 			tid = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
32232bdd57bSSam Leffler 		tid &= IEEE80211_QOS_TID;
323b032f27cSSam Leffler 	} else
324b032f27cSSam Leffler 		tid = IEEE80211_NONQOS_TID;
325b032f27cSSam Leffler 	return tid;
326b032f27cSSam Leffler }
327b032f27cSSam Leffler 
328ae55932eSAndrew Thompson void	ieee80211_waitfor_parent(struct ieee80211com *);
329b032f27cSSam Leffler void	ieee80211_start_locked(struct ieee80211vap *);
330b032f27cSSam Leffler void	ieee80211_init(void *);
331b032f27cSSam Leffler void	ieee80211_start_all(struct ieee80211com *);
332b032f27cSSam Leffler void	ieee80211_stop_locked(struct ieee80211vap *);
333b032f27cSSam Leffler void	ieee80211_stop(struct ieee80211vap *);
334b032f27cSSam Leffler void	ieee80211_stop_all(struct ieee80211com *);
3356076cbacSSam Leffler void	ieee80211_suspend_all(struct ieee80211com *);
3366076cbacSSam Leffler void	ieee80211_resume_all(struct ieee80211com *);
337b032f27cSSam Leffler void	ieee80211_dturbo_switch(struct ieee80211vap *, int newflags);
338b032f27cSSam Leffler void	ieee80211_swbmiss(void *arg);
339e701e041SSam Leffler void	ieee80211_beacon_miss(struct ieee80211com *);
340b032f27cSSam Leffler int	ieee80211_new_state(struct ieee80211vap *, enum ieee80211_state, int);
341e94527beSAdrian Chadd int	ieee80211_new_state_locked(struct ieee80211vap *, enum ieee80211_state,
342e94527beSAdrian Chadd 		int);
34368e8e04eSSam Leffler void	ieee80211_print_essid(const uint8_t *, int);
34468e8e04eSSam Leffler void	ieee80211_dump_pkt(struct ieee80211com *,
34568e8e04eSSam Leffler 		const uint8_t *, int, int, int);
346a11c9a5cSSam Leffler 
34749aa47d6SSam Leffler extern 	const char *ieee80211_opmode_name[];
348a11c9a5cSSam Leffler extern	const char *ieee80211_state_name[IEEE80211_S_MAX];
3498a1b9b6aSSam Leffler extern	const char *ieee80211_wme_acnames[];
3508a1b9b6aSSam Leffler 
3518a1b9b6aSSam Leffler /*
3528a1b9b6aSSam Leffler  * Beacon frames constructed by ieee80211_beacon_alloc
3538a1b9b6aSSam Leffler  * have the following structure filled in so drivers
3548a1b9b6aSSam Leffler  * can update the frame later w/ minimal overhead.
3558a1b9b6aSSam Leffler  */
3568a1b9b6aSSam Leffler struct ieee80211_beacon_offsets {
357b105a069SSam Leffler 	uint8_t		bo_flags[4];	/* update/state flags */
35868e8e04eSSam Leffler 	uint16_t	*bo_caps;	/* capabilities */
359b105a069SSam Leffler 	uint8_t		*bo_cfp;	/* start of CFParms element */
36068e8e04eSSam Leffler 	uint8_t		*bo_tim;	/* start of atim/dtim */
36168e8e04eSSam Leffler 	uint8_t		*bo_wme;	/* start of WME parameters */
36210ad9a77SSam Leffler 	uint8_t		*bo_tdma;	/* start of TDMA parameters */
363b105a069SSam Leffler 	uint8_t		*bo_tim_trailer;/* start of fixed-size trailer */
36468e8e04eSSam Leffler 	uint16_t	bo_tim_len;	/* atim/dtim length in bytes */
365b105a069SSam Leffler 	uint16_t	bo_tim_trailer_len;/* tim trailer length in bytes */
36668e8e04eSSam Leffler 	uint8_t		*bo_erp;	/* start of ERP element */
36768e8e04eSSam Leffler 	uint8_t		*bo_htinfo;	/* start of HT info element */
3684207227cSSam Leffler 	uint8_t		*bo_ath;	/* start of ATH parameters */
369b105a069SSam Leffler 	uint8_t		*bo_appie;	/* start of AppIE element */
370b105a069SSam Leffler 	uint16_t	bo_appie_len;	/* AppIE length in bytes */
371d673ae81SAntoine Brodin 	uint16_t	bo_csa_trailer_len;
372b105a069SSam Leffler 	uint8_t		*bo_csa;	/* start of CSA element */
37332b0e64bSAdrian Chadd 	uint8_t		*bo_quiet;	/* start of Quiet element */
374d093681cSRui Paulo 	uint8_t		*bo_meshconf;	/* start of MESHCONF element */
375d093681cSRui Paulo 	uint8_t		*bo_spare[3];
3768a1b9b6aSSam Leffler };
377b105a069SSam Leffler struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *,
378b105a069SSam Leffler 		struct ieee80211_beacon_offsets *);
379b105a069SSam Leffler 
380b105a069SSam Leffler /*
381b032f27cSSam Leffler  * Beacon frame updates are signaled through calls to iv_update_beacon
382b105a069SSam Leffler  * with one of the IEEE80211_BEACON_* tokens defined below.  For devices
383b105a069SSam Leffler  * that construct beacon frames on the host this can trigger a rebuild
384b105a069SSam Leffler  * or defer the processing.  For devices that offload beacon frame
385b105a069SSam Leffler  * handling this callback can be used to signal a rebuild.  The bo_flags
386b105a069SSam Leffler  * array in the ieee80211_beacon_offsets structure is intended to record
387b105a069SSam Leffler  * deferred processing requirements; ieee80211_beacon_update uses the
388b105a069SSam Leffler  * state to optimize work.  Since this structure is owned by the driver
389b032f27cSSam Leffler  * and not visible to the 802.11 layer drivers must supply an iv_update_beacon
390b105a069SSam Leffler  * callback that marks the flag bits and schedules (as necessary) an update.
391b105a069SSam Leffler  */
392b105a069SSam Leffler enum {
393b105a069SSam Leffler 	IEEE80211_BEACON_CAPS	= 0,	/* capabilities */
394b105a069SSam Leffler 	IEEE80211_BEACON_TIM	= 1,	/* DTIM/ATIM */
395b105a069SSam Leffler 	IEEE80211_BEACON_WME	= 2,
396b105a069SSam Leffler 	IEEE80211_BEACON_ERP	= 3,	/* Extended Rate Phy */
397b105a069SSam Leffler 	IEEE80211_BEACON_HTINFO	= 4,	/* HT Information */
398b105a069SSam Leffler 	IEEE80211_BEACON_APPIE	= 5,	/* Application IE's */
399b105a069SSam Leffler 	IEEE80211_BEACON_CFP	= 6,	/* CFParms */
400b105a069SSam Leffler 	IEEE80211_BEACON_CSA	= 7,	/* Channel Switch Announcement */
40110ad9a77SSam Leffler 	IEEE80211_BEACON_TDMA	= 9,	/* TDMA Info */
4024207227cSSam Leffler 	IEEE80211_BEACON_ATH	= 10,	/* ATH parameters */
403d093681cSRui Paulo 	IEEE80211_BEACON_MESHCONF = 11,	/* Mesh Configuration */
404b105a069SSam Leffler };
405b105a069SSam Leffler int	ieee80211_beacon_update(struct ieee80211_node *,
406b105a069SSam Leffler 		struct ieee80211_beacon_offsets *, struct mbuf *, int mcast);
4078a1b9b6aSSam Leffler 
408b032f27cSSam Leffler void	ieee80211_csa_startswitch(struct ieee80211com *,
409b032f27cSSam Leffler 		struct ieee80211_channel *, int mode, int count);
410b032f27cSSam Leffler void	ieee80211_csa_completeswitch(struct ieee80211com *);
411c70761e6SSam Leffler void	ieee80211_csa_cancelswitch(struct ieee80211com *);
412b032f27cSSam Leffler void	ieee80211_cac_completeswitch(struct ieee80211vap *);
413b032f27cSSam Leffler 
4148a1b9b6aSSam Leffler /*
4158a1b9b6aSSam Leffler  * Notification methods called from the 802.11 state machine.
4168a1b9b6aSSam Leffler  * Note that while these are defined here, their implementation
4178a1b9b6aSSam Leffler  * is OS-specific.
4188a1b9b6aSSam Leffler  */
419b032f27cSSam Leffler void	ieee80211_notify_node_join(struct ieee80211_node *, int newassoc);
420b032f27cSSam Leffler void	ieee80211_notify_node_leave(struct ieee80211_node *);
421b032f27cSSam Leffler void	ieee80211_notify_scan_done(struct ieee80211vap *);
422b032f27cSSam Leffler void	ieee80211_notify_wds_discover(struct ieee80211_node *);
423b032f27cSSam Leffler void	ieee80211_notify_csa(struct ieee80211com *,
424b032f27cSSam Leffler 		const struct ieee80211_channel *, int mode, int count);
425b032f27cSSam Leffler void	ieee80211_notify_radar(struct ieee80211com *,
426b032f27cSSam Leffler 		const struct ieee80211_channel *);
427b032f27cSSam Leffler enum ieee80211_notify_cac_event {
428b032f27cSSam Leffler 	IEEE80211_NOTIFY_CAC_START  = 0, /* CAC timer started */
429b032f27cSSam Leffler 	IEEE80211_NOTIFY_CAC_STOP   = 1, /* CAC intentionally stopped */
430b032f27cSSam Leffler 	IEEE80211_NOTIFY_CAC_RADAR  = 2, /* CAC stopped due to radar detectio */
431b032f27cSSam Leffler 	IEEE80211_NOTIFY_CAC_EXPIRE = 3, /* CAC expired w/o radar */
432b032f27cSSam Leffler };
433b032f27cSSam Leffler void	ieee80211_notify_cac(struct ieee80211com *,
434b032f27cSSam Leffler 		const struct ieee80211_channel *,
435b032f27cSSam Leffler 		enum ieee80211_notify_cac_event);
436b032f27cSSam Leffler void	ieee80211_notify_node_deauth(struct ieee80211_node *);
437b032f27cSSam Leffler void	ieee80211_notify_node_auth(struct ieee80211_node *);
438b032f27cSSam Leffler void	ieee80211_notify_country(struct ieee80211vap *, const uint8_t [],
439b032f27cSSam Leffler 		const uint8_t cc[2]);
440b032f27cSSam Leffler void	ieee80211_notify_radio(struct ieee80211com *, int);
4411a1e1d21SSam Leffler #endif /* _NET80211_IEEE80211_PROTO_H_ */
442