11a1e1d21SSam Leffler /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni *
47535e66aSSam Leffler * Copyright (c) 2001 Atsushi Onoe
510ad9a77SSam Leffler * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
61a1e1d21SSam Leffler * All rights reserved.
71a1e1d21SSam Leffler *
81a1e1d21SSam Leffler * Redistribution and use in source and binary forms, with or without
91a1e1d21SSam Leffler * modification, are permitted provided that the following conditions
101a1e1d21SSam Leffler * are met:
111a1e1d21SSam Leffler * 1. Redistributions of source code must retain the above copyright
121a1e1d21SSam Leffler * notice, this list of conditions and the following disclaimer.
131a1e1d21SSam Leffler * 2. Redistributions in binary form must reproduce the above copyright
141a1e1d21SSam Leffler * notice, this list of conditions and the following disclaimer in the
151a1e1d21SSam Leffler * documentation and/or other materials provided with the distribution.
167535e66aSSam Leffler *
177535e66aSSam Leffler * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
187535e66aSSam Leffler * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
197535e66aSSam Leffler * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
207535e66aSSam Leffler * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
217535e66aSSam Leffler * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
227535e66aSSam Leffler * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237535e66aSSam Leffler * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247535e66aSSam Leffler * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257535e66aSSam Leffler * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
267535e66aSSam Leffler * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
504357a5d1SAndriy Voskoboinyk extern const char *mgt_subtype_name[];
514357a5d1SAndriy Voskoboinyk extern const char *ctl_subtype_name[];
52e8f5c7a8SSam Leffler extern const char *ieee80211_phymode_name[IEEE80211_MODE_MAX];
53c43feedeSSam Leffler extern const int ieee80211_opcap[IEEE80211_OPMODE_MAX];
541a1e1d21SSam Leffler
554357a5d1SAndriy Voskoboinyk static __inline const char *
ieee80211_mgt_subtype_name(uint8_t subtype)564357a5d1SAndriy Voskoboinyk ieee80211_mgt_subtype_name(uint8_t subtype)
574357a5d1SAndriy Voskoboinyk {
584357a5d1SAndriy Voskoboinyk return mgt_subtype_name[(subtype & IEEE80211_FC0_SUBTYPE_MASK) >>
594357a5d1SAndriy Voskoboinyk IEEE80211_FC0_SUBTYPE_SHIFT];
604357a5d1SAndriy Voskoboinyk }
614357a5d1SAndriy Voskoboinyk
624357a5d1SAndriy Voskoboinyk static __inline const char *
ieee80211_ctl_subtype_name(uint8_t subtype)634357a5d1SAndriy Voskoboinyk ieee80211_ctl_subtype_name(uint8_t subtype)
644357a5d1SAndriy Voskoboinyk {
654357a5d1SAndriy Voskoboinyk return ctl_subtype_name[(subtype & IEEE80211_FC0_SUBTYPE_MASK) >>
664357a5d1SAndriy Voskoboinyk IEEE80211_FC0_SUBTYPE_SHIFT];
674357a5d1SAndriy Voskoboinyk }
684357a5d1SAndriy Voskoboinyk
69d72d72d3SAndriy Voskoboinyk const char *ieee80211_reason_to_string(uint16_t);
70d72d72d3SAndriy Voskoboinyk
710942c81cSSam Leffler void ieee80211_proto_attach(struct ieee80211com *);
720942c81cSSam Leffler void ieee80211_proto_detach(struct ieee80211com *);
73b032f27cSSam Leffler void ieee80211_proto_vattach(struct ieee80211vap *);
74b032f27cSSam Leffler void ieee80211_proto_vdetach(struct ieee80211vap *);
751a1e1d21SSam Leffler
767a79cebfSGleb Smirnoff void ieee80211_promisc(struct ieee80211vap *, bool);
777a79cebfSGleb Smirnoff void ieee80211_allmulti(struct ieee80211vap *, bool);
78b032f27cSSam Leffler void ieee80211_syncflag(struct ieee80211vap *, int flag);
792bfc8a91SSam Leffler void ieee80211_syncflag_ht(struct ieee80211vap *, int flag);
808e71a4aaSAdrian Chadd void ieee80211_syncflag_vht(struct ieee80211vap *, int flag);
81b032f27cSSam Leffler void ieee80211_syncflag_ext(struct ieee80211vap *, int flag);
82b032f27cSSam Leffler
835463c4a4SSam Leffler #define ieee80211_input(ni, m, rssi, nf) \
84c79f192cSAdrian Chadd ((ni)->ni_vap->iv_input(ni, m, NULL, rssi, nf))
855463c4a4SSam Leffler int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int);
86864ab114SAdrian Chadd
87bdc7291eSAndriy Voskoboinyk int ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *);
88bdc7291eSAndriy Voskoboinyk int ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *);
89864ab114SAdrian Chadd
9099f1b25cSSam Leffler struct ieee80211_bpf_params;
918ac160cdSSam Leffler int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int,
928ac160cdSSam Leffler struct ieee80211_bpf_params *);
93246b5467SSam Leffler int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *,
94246b5467SSam Leffler const struct ieee80211_bpf_params *);
95246b5467SSam Leffler int ieee80211_output(struct ifnet *, struct mbuf *,
9647e8d432SGleb Smirnoff const struct sockaddr *, struct route *ro);
970e20ac38SAdrian Chadd int ieee80211_vap_pkt_send_dest(struct ieee80211vap *, struct mbuf *,
980e20ac38SAdrian Chadd struct ieee80211_node *);
995cda6006SAdrian Chadd int ieee80211_raw_output(struct ieee80211vap *, struct ieee80211_node *,
1005cda6006SAdrian Chadd struct mbuf *, const struct ieee80211_bpf_params *);
10159aa14a9SRui Paulo void ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int,
10259aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
10359aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]);
104e7495198SAdrian Chadd int ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m);
105e7495198SAdrian Chadd void ieee80211_vap_qflush(struct ifnet *ifp);
106f62121ceSSam Leffler int ieee80211_send_nulldata(struct ieee80211_node *);
107b032f27cSSam Leffler int ieee80211_classify(struct ieee80211_node *, struct mbuf *m);
108616190d0SSam Leffler struct mbuf *ieee80211_mbuf_adjust(struct ieee80211vap *, int,
109616190d0SSam Leffler struct ieee80211_key *, struct mbuf *);
110339ccfb3SSam Leffler struct mbuf *ieee80211_encap(struct ieee80211vap *, struct ieee80211_node *,
111339ccfb3SSam Leffler struct mbuf *);
112d07be335SAdrian Chadd void ieee80211_free_mbuf(struct mbuf *);
113b032f27cSSam Leffler int ieee80211_send_mgmt(struct ieee80211_node *, int, int);
114b032f27cSSam Leffler struct ieee80211_appie;
115c338cf2cSBjoern A. Zeeb int ieee80211_probereq_ie(struct ieee80211vap *, struct ieee80211com *,
116c338cf2cSBjoern A. Zeeb uint8_t **, uint32_t *, const uint8_t *, size_t, bool);
11768e8e04eSSam Leffler int ieee80211_send_probereq(struct ieee80211_node *ni,
11868e8e04eSSam Leffler const uint8_t sa[IEEE80211_ADDR_LEN],
11968e8e04eSSam Leffler const uint8_t da[IEEE80211_ADDR_LEN],
12068e8e04eSSam Leffler const uint8_t bssid[IEEE80211_ADDR_LEN],
121b032f27cSSam Leffler const uint8_t *ssid, size_t ssidlen);
12274b4c76eSAdrian Chadd struct mbuf * ieee80211_ff_encap1(struct ieee80211vap *, struct mbuf *,
12374b4c76eSAdrian Chadd const struct ether_header *);
12436ee7775SAdrian Chadd void ieee80211_tx_complete(struct ieee80211_node *,
12536ee7775SAdrian Chadd struct mbuf *, int);
12674b4c76eSAdrian Chadd
127b032f27cSSam Leffler /*
128b032f27cSSam Leffler * The formation of ProbeResponse frames requires guidance to
129b032f27cSSam Leffler * deal with legacy clients. When the client is identified as
130b032f27cSSam Leffler * "legacy 11b" ieee80211_send_proberesp is passed this token.
131b032f27cSSam Leffler */
132b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY_11B 0x1 /* legacy 11b client */
133b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY_11 0x2 /* other legacy client */
134b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY 0x3 /* any legacy client */
135b032f27cSSam Leffler struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int);
136b032f27cSSam Leffler int ieee80211_send_proberesp(struct ieee80211vap *,
137b032f27cSSam Leffler const uint8_t da[IEEE80211_ADDR_LEN], int);
138b032f27cSSam Leffler struct mbuf *ieee80211_alloc_rts(struct ieee80211com *ic,
139b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN],
140b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
141b032f27cSSam Leffler struct mbuf *ieee80211_alloc_cts(struct ieee80211com *,
142b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], uint16_t);
143d1b67106SAndriy Voskoboinyk struct mbuf *ieee80211_alloc_prot(struct ieee80211_node *,
144d1b67106SAndriy Voskoboinyk const struct mbuf *, uint8_t, int);
1458a1b9b6aSSam Leffler
14659aa14a9SRui Paulo uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *);
14759aa14a9SRui Paulo uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *);
148de981aecSAdrian Chadd uint8_t *ieee80211_add_ssid(uint8_t *, const uint8_t *, u_int);
149d8df5f3dSRui Paulo uint8_t *ieee80211_add_wpa(uint8_t *, const struct ieee80211vap *);
150d8df5f3dSRui Paulo uint8_t *ieee80211_add_rsn(uint8_t *, const struct ieee80211vap *);
151d8df5f3dSRui Paulo uint8_t *ieee80211_add_qos(uint8_t *, const struct ieee80211_node *);
15259aa14a9SRui Paulo uint16_t ieee80211_getcapinfo(struct ieee80211vap *,
15359aa14a9SRui Paulo struct ieee80211_channel *);
1544eadefc2SAdrian Chadd struct ieee80211_wme_state;
155bac852bbSAdrian Chadd uint8_t * ieee80211_add_wme_info(uint8_t *frm, struct ieee80211_wme_state *wme,
156bac852bbSAdrian Chadd struct ieee80211_node *ni);
15759aa14a9SRui Paulo
158d20ff6e6SAdrian Chadd void ieee80211_vap_reset_erp(struct ieee80211vap *);
1590942c81cSSam Leffler void ieee80211_reset_erp(struct ieee80211com *);
160d20ff6e6SAdrian Chadd void ieee80211_vap_set_shortslottime(struct ieee80211vap *, int onoff);
161b032f27cSSam Leffler int ieee80211_iserp_rateset(const struct ieee80211_rateset *);
162b032f27cSSam Leffler void ieee80211_setbasicrates(struct ieee80211_rateset *,
163b032f27cSSam Leffler enum ieee80211_phymode);
164b032f27cSSam Leffler void ieee80211_addbasicrates(struct ieee80211_rateset *,
1658a1b9b6aSSam Leffler enum ieee80211_phymode);
1668a1b9b6aSSam Leffler
1678a1b9b6aSSam Leffler /*
1688a1b9b6aSSam Leffler * Return the size of the 802.11 header for a management or data frame.
1698a1b9b6aSSam Leffler */
170a95fa8d3SSam Leffler static __inline int
ieee80211_hdrsize(const void * data)1718a1b9b6aSSam Leffler ieee80211_hdrsize(const void *data)
1728a1b9b6aSSam Leffler {
1738a1b9b6aSSam Leffler const struct ieee80211_frame *wh = data;
1748a1b9b6aSSam Leffler int size = sizeof(struct ieee80211_frame);
1758a1b9b6aSSam Leffler
1768a1b9b6aSSam Leffler /* NB: we don't handle control frames */
1778a1b9b6aSSam Leffler KASSERT((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL,
1788a1b9b6aSSam Leffler ("%s: control frame", __func__));
17932bdd57bSSam Leffler if (IEEE80211_IS_DSTODS(wh))
1808a1b9b6aSSam Leffler size += IEEE80211_ADDR_LEN;
1818a1b9b6aSSam Leffler if (IEEE80211_QOS_HAS_SEQ(wh))
18268e8e04eSSam Leffler size += sizeof(uint16_t);
1838a1b9b6aSSam Leffler return size;
1848a1b9b6aSSam Leffler }
1858a1b9b6aSSam Leffler
1868a1b9b6aSSam Leffler /*
18768e8e04eSSam Leffler * Like ieee80211_hdrsize, but handles any type of frame.
1888a1b9b6aSSam Leffler */
189a95fa8d3SSam Leffler static __inline int
ieee80211_anyhdrsize(const void * data)1908a1b9b6aSSam Leffler ieee80211_anyhdrsize(const void *data)
1918a1b9b6aSSam Leffler {
1928a1b9b6aSSam Leffler const struct ieee80211_frame *wh = data;
1938a1b9b6aSSam Leffler
1948a1b9b6aSSam Leffler if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) {
1958a1b9b6aSSam Leffler switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) {
1968a1b9b6aSSam Leffler case IEEE80211_FC0_SUBTYPE_CTS:
1978a1b9b6aSSam Leffler case IEEE80211_FC0_SUBTYPE_ACK:
1988a1b9b6aSSam Leffler return sizeof(struct ieee80211_frame_ack);
19968e8e04eSSam Leffler case IEEE80211_FC0_SUBTYPE_BAR:
20068e8e04eSSam Leffler return sizeof(struct ieee80211_frame_bar);
2018a1b9b6aSSam Leffler }
2028a1b9b6aSSam Leffler return sizeof(struct ieee80211_frame_min);
2038a1b9b6aSSam Leffler } else
2048a1b9b6aSSam Leffler return ieee80211_hdrsize(data);
2058a1b9b6aSSam Leffler }
2068a1b9b6aSSam Leffler
2078a1b9b6aSSam Leffler /*
2088a1b9b6aSSam Leffler * Template for an in-kernel authenticator. Authenticators
2098a1b9b6aSSam Leffler * register with the protocol code and are typically loaded
210b032f27cSSam Leffler * as separate modules as needed. One special authenticator
211b032f27cSSam Leffler * is xauth; it intercepts requests so that protocols like
212b032f27cSSam Leffler * WPA can be handled in user space.
2138a1b9b6aSSam Leffler */
2148a1b9b6aSSam Leffler struct ieee80211_authenticator {
2158a1b9b6aSSam Leffler const char *ia_name; /* printable name */
216b032f27cSSam Leffler int (*ia_attach)(struct ieee80211vap *);
217b032f27cSSam Leffler void (*ia_detach)(struct ieee80211vap *);
218b032f27cSSam Leffler void (*ia_node_join)(struct ieee80211_node *);
219b032f27cSSam Leffler void (*ia_node_leave)(struct ieee80211_node *);
2208a1b9b6aSSam Leffler };
2210942c81cSSam Leffler void ieee80211_authenticator_register(int type,
2228a1b9b6aSSam Leffler const struct ieee80211_authenticator *);
2230942c81cSSam Leffler void ieee80211_authenticator_unregister(int type);
2240942c81cSSam Leffler const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth);
2258a1b9b6aSSam Leffler
226188757f5SSam Leffler struct ieee80211req;
2278a1b9b6aSSam Leffler /*
2288a1b9b6aSSam Leffler * Template for an MAC ACL policy module. Such modules
2298a1b9b6aSSam Leffler * register with the protocol code and are passed the sender's
230b032f27cSSam Leffler * address of each received auth frame for validation.
2318a1b9b6aSSam Leffler */
2328a1b9b6aSSam Leffler struct ieee80211_aclator {
2338a1b9b6aSSam Leffler const char *iac_name; /* printable name */
234b032f27cSSam Leffler int (*iac_attach)(struct ieee80211vap *);
235b032f27cSSam Leffler void (*iac_detach)(struct ieee80211vap *);
236b032f27cSSam Leffler int (*iac_check)(struct ieee80211vap *,
2375a8801b0SBernhard Schmidt const struct ieee80211_frame *wh);
238b032f27cSSam Leffler int (*iac_add)(struct ieee80211vap *,
23968e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]);
240b032f27cSSam Leffler int (*iac_remove)(struct ieee80211vap *,
24168e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]);
242b032f27cSSam Leffler int (*iac_flush)(struct ieee80211vap *);
243b032f27cSSam Leffler int (*iac_setpolicy)(struct ieee80211vap *, int);
244b032f27cSSam Leffler int (*iac_getpolicy)(struct ieee80211vap *);
245b032f27cSSam Leffler int (*iac_setioctl)(struct ieee80211vap *, struct ieee80211req *);
246b032f27cSSam Leffler int (*iac_getioctl)(struct ieee80211vap *, struct ieee80211req *);
2478a1b9b6aSSam Leffler };
2480942c81cSSam Leffler void ieee80211_aclator_register(const struct ieee80211_aclator *);
2490942c81cSSam Leffler void ieee80211_aclator_unregister(const struct ieee80211_aclator *);
2500942c81cSSam Leffler const struct ieee80211_aclator *ieee80211_aclator_get(const char *name);
2518a1b9b6aSSam Leffler
2528a1b9b6aSSam Leffler /* flags for ieee80211_fix_rate() */
2538a1b9b6aSSam Leffler #define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */
254b032f27cSSam Leffler #define IEEE80211_F_DOFRATE 0x00000002 /* use fixed legacy rate */
2558a1b9b6aSSam Leffler #define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */
2568a1b9b6aSSam Leffler #define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */
25768e8e04eSSam Leffler #define IEEE80211_F_DOBRS 0x00000010 /* check basic rate set */
25868e8e04eSSam Leffler #define IEEE80211_F_JOIN 0x00000020 /* sta joining our bss */
259b032f27cSSam Leffler #define IEEE80211_F_DOFMCS 0x00000040 /* use fixed HT rate */
26070e28b9aSSam Leffler int ieee80211_fix_rate(struct ieee80211_node *,
26170e28b9aSSam Leffler struct ieee80211_rateset *, int);
2628a1b9b6aSSam Leffler
2638a1b9b6aSSam Leffler /*
2648a1b9b6aSSam Leffler * WME/WMM support.
2658a1b9b6aSSam Leffler */
2668a1b9b6aSSam Leffler struct wmeParams {
26768e8e04eSSam Leffler uint8_t wmep_acm;
26868e8e04eSSam Leffler uint8_t wmep_aifsn;
26968e8e04eSSam Leffler uint8_t wmep_logcwmin; /* log2(cwmin) */
27068e8e04eSSam Leffler uint8_t wmep_logcwmax; /* log2(cwmax) */
27168e8e04eSSam Leffler uint8_t wmep_txopLimit;
27268e8e04eSSam Leffler uint8_t wmep_noackPolicy; /* 0 (ack), 1 (no ack) */
2738a1b9b6aSSam Leffler };
2745a11fbcaSSam Leffler #define IEEE80211_TXOP_TO_US(_txop) ((_txop)<<5)
2755a11fbcaSSam Leffler #define IEEE80211_US_TO_TXOP(_us) ((_us)>>5)
2768a1b9b6aSSam Leffler
2778a1b9b6aSSam Leffler struct chanAccParams {
27868e8e04eSSam Leffler uint8_t cap_info; /* version of the current set */
2798a1b9b6aSSam Leffler struct wmeParams cap_wmeParams[WME_NUM_AC];
2808a1b9b6aSSam Leffler };
2818a1b9b6aSSam Leffler
2828a1b9b6aSSam Leffler struct ieee80211_wme_state {
2838a1b9b6aSSam Leffler u_int wme_flags;
284a4641f4eSPedro F. Giffuni #define WME_F_AGGRMODE 0x00000001 /* STATUS: WME aggressive mode */
2858a1b9b6aSSam Leffler u_int wme_hipri_traffic; /* VI/VO frames in beacon interval */
286a4641f4eSPedro F. Giffuni u_int wme_hipri_switch_thresh;/* aggressive mode switch thresh */
287a4641f4eSPedro F. Giffuni u_int wme_hipri_switch_hysteresis;/* aggressive mode switch hysteresis */
2888a1b9b6aSSam Leffler
28997648596SBjoern A. Zeeb struct wmeParams wme_params[WME_NUM_AC]; /* from assoc resp for each AC */
2908a1b9b6aSSam Leffler struct chanAccParams wme_wmeChanParams; /* WME params applied to self */
2918a1b9b6aSSam Leffler struct chanAccParams wme_wmeBssChanParams;/* WME params bcast to stations */
2928a1b9b6aSSam Leffler struct chanAccParams wme_chanParams; /* params applied to self */
2938a1b9b6aSSam Leffler struct chanAccParams wme_bssChanParams; /* params bcast to stations */
2948a1b9b6aSSam Leffler
2958a1b9b6aSSam Leffler int (*wme_update)(struct ieee80211com *);
2968a1b9b6aSSam Leffler };
2978a1b9b6aSSam Leffler
298b032f27cSSam Leffler void ieee80211_wme_initparams(struct ieee80211vap *);
299b032f27cSSam Leffler void ieee80211_wme_updateparams(struct ieee80211vap *);
300b032f27cSSam Leffler void ieee80211_wme_updateparams_locked(struct ieee80211vap *);
301d03baf35SAdrian Chadd void ieee80211_wme_vap_getparams(struct ieee80211vap *vap,
302d03baf35SAdrian Chadd struct chanAccParams *);
303d03baf35SAdrian Chadd void ieee80211_wme_ic_getparams(struct ieee80211com *ic,
304d03baf35SAdrian Chadd struct chanAccParams *);
3050c696036SAdrian Chadd int ieee80211_wme_vap_ac_is_noack(struct ieee80211vap *vap, int ac);
306f1481c8dSAdrian Chadd void ieee80211_vap_update_preamble(struct ieee80211vap *vap);
307f1481c8dSAdrian Chadd void ieee80211_vap_update_erp_protmode(struct ieee80211vap *vap);
308f1481c8dSAdrian Chadd void ieee80211_vap_update_ht_protmode(struct ieee80211vap *vap);
3098a1b9b6aSSam Leffler
310b032f27cSSam Leffler /*
311f3f08e16SAndriy Voskoboinyk * Return pointer to the QoS field from a Qos frame.
312f3f08e16SAndriy Voskoboinyk */
313f3f08e16SAndriy Voskoboinyk static __inline uint8_t *
ieee80211_getqos(void * data)314f3f08e16SAndriy Voskoboinyk ieee80211_getqos(void *data)
315f3f08e16SAndriy Voskoboinyk {
316f3f08e16SAndriy Voskoboinyk struct ieee80211_frame *wh = data;
317f3f08e16SAndriy Voskoboinyk
318f3f08e16SAndriy Voskoboinyk KASSERT(IEEE80211_QOS_HAS_SEQ(wh), ("QoS field is absent!"));
319f3f08e16SAndriy Voskoboinyk
320f3f08e16SAndriy Voskoboinyk if (IEEE80211_IS_DSTODS(wh))
321f3f08e16SAndriy Voskoboinyk return (((struct ieee80211_qosframe_addr4 *)wh)->i_qos);
322f3f08e16SAndriy Voskoboinyk else
323f3f08e16SAndriy Voskoboinyk return (((struct ieee80211_qosframe *)wh)->i_qos);
324f3f08e16SAndriy Voskoboinyk }
325f3f08e16SAndriy Voskoboinyk
326f3f08e16SAndriy Voskoboinyk /*
327b032f27cSSam Leffler * Return the WME TID from a QoS frame. If no TID
328b032f27cSSam Leffler * is present return the index for the "non-QoS" entry.
329b032f27cSSam Leffler */
330b032f27cSSam Leffler static __inline uint8_t
ieee80211_gettid(const struct ieee80211_frame * wh)331b032f27cSSam Leffler ieee80211_gettid(const struct ieee80211_frame *wh)
332b032f27cSSam Leffler {
333b032f27cSSam Leffler uint8_t tid;
334b032f27cSSam Leffler
335b032f27cSSam Leffler if (IEEE80211_QOS_HAS_SEQ(wh)) {
33632bdd57bSSam Leffler if (IEEE80211_IS_DSTODS(wh))
33732bdd57bSSam Leffler tid = ((const struct ieee80211_qosframe_addr4 *)wh)->
33832bdd57bSSam Leffler i_qos[0];
33932bdd57bSSam Leffler else
34032bdd57bSSam Leffler tid = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
34132bdd57bSSam Leffler tid &= IEEE80211_QOS_TID;
342b032f27cSSam Leffler } else
343b032f27cSSam Leffler tid = IEEE80211_NONQOS_TID;
344b032f27cSSam Leffler return tid;
345b032f27cSSam Leffler }
346b032f27cSSam Leffler
347ae55932eSAndrew Thompson void ieee80211_waitfor_parent(struct ieee80211com *);
348b032f27cSSam Leffler void ieee80211_start_locked(struct ieee80211vap *);
349b032f27cSSam Leffler void ieee80211_init(void *);
350b032f27cSSam Leffler void ieee80211_start_all(struct ieee80211com *);
351b032f27cSSam Leffler void ieee80211_stop_locked(struct ieee80211vap *);
352b032f27cSSam Leffler void ieee80211_stop(struct ieee80211vap *);
353b032f27cSSam Leffler void ieee80211_stop_all(struct ieee80211com *);
3546076cbacSSam Leffler void ieee80211_suspend_all(struct ieee80211com *);
3556076cbacSSam Leffler void ieee80211_resume_all(struct ieee80211com *);
3564061c639SAndriy Voskoboinyk void ieee80211_restart_all(struct ieee80211com *);
357b032f27cSSam Leffler void ieee80211_dturbo_switch(struct ieee80211vap *, int newflags);
358b032f27cSSam Leffler void ieee80211_swbmiss(void *arg);
359e701e041SSam Leffler void ieee80211_beacon_miss(struct ieee80211com *);
360b032f27cSSam Leffler int ieee80211_new_state(struct ieee80211vap *, enum ieee80211_state, int);
361e94527beSAdrian Chadd int ieee80211_new_state_locked(struct ieee80211vap *, enum ieee80211_state,
362e94527beSAdrian Chadd int);
36368e8e04eSSam Leffler void ieee80211_print_essid(const uint8_t *, int);
36468e8e04eSSam Leffler void ieee80211_dump_pkt(struct ieee80211com *,
36568e8e04eSSam Leffler const uint8_t *, int, int, int);
366a11c9a5cSSam Leffler
36749aa47d6SSam Leffler extern const char *ieee80211_opmode_name[];
368a11c9a5cSSam Leffler extern const char *ieee80211_state_name[IEEE80211_S_MAX];
3698a1b9b6aSSam Leffler extern const char *ieee80211_wme_acnames[];
3708a1b9b6aSSam Leffler
3718a1b9b6aSSam Leffler /*
3728a1b9b6aSSam Leffler * Beacon frames constructed by ieee80211_beacon_alloc
3738a1b9b6aSSam Leffler * have the following structure filled in so drivers
3748a1b9b6aSSam Leffler * can update the frame later w/ minimal overhead.
3758a1b9b6aSSam Leffler */
3768a1b9b6aSSam Leffler struct ieee80211_beacon_offsets {
377b105a069SSam Leffler uint8_t bo_flags[4]; /* update/state flags */
37868e8e04eSSam Leffler uint16_t *bo_caps; /* capabilities */
379b105a069SSam Leffler uint8_t *bo_cfp; /* start of CFParms element */
38068e8e04eSSam Leffler uint8_t *bo_tim; /* start of atim/dtim */
38168e8e04eSSam Leffler uint8_t *bo_wme; /* start of WME parameters */
38210ad9a77SSam Leffler uint8_t *bo_tdma; /* start of TDMA parameters */
383b105a069SSam Leffler uint8_t *bo_tim_trailer;/* start of fixed-size trailer */
38468e8e04eSSam Leffler uint16_t bo_tim_len; /* atim/dtim length in bytes */
385b105a069SSam Leffler uint16_t bo_tim_trailer_len;/* tim trailer length in bytes */
38668e8e04eSSam Leffler uint8_t *bo_erp; /* start of ERP element */
38768e8e04eSSam Leffler uint8_t *bo_htinfo; /* start of HT info element */
3884207227cSSam Leffler uint8_t *bo_ath; /* start of ATH parameters */
389b105a069SSam Leffler uint8_t *bo_appie; /* start of AppIE element */
390b105a069SSam Leffler uint16_t bo_appie_len; /* AppIE length in bytes */
391d673ae81SAntoine Brodin uint16_t bo_csa_trailer_len;
392b105a069SSam Leffler uint8_t *bo_csa; /* start of CSA element */
39332b0e64bSAdrian Chadd uint8_t *bo_quiet; /* start of Quiet element */
394d093681cSRui Paulo uint8_t *bo_meshconf; /* start of MESHCONF element */
3958e71a4aaSAdrian Chadd uint8_t *bo_vhtinfo; /* start of VHT info element (XXX VHTCAP?) */
3968e71a4aaSAdrian Chadd uint8_t *bo_spare[2];
3978a1b9b6aSSam Leffler };
398210ab3c2SAdrian Chadd struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *);
399b105a069SSam Leffler
400b105a069SSam Leffler /*
401b032f27cSSam Leffler * Beacon frame updates are signaled through calls to iv_update_beacon
402b105a069SSam Leffler * with one of the IEEE80211_BEACON_* tokens defined below. For devices
403b105a069SSam Leffler * that construct beacon frames on the host this can trigger a rebuild
404b105a069SSam Leffler * or defer the processing. For devices that offload beacon frame
405b105a069SSam Leffler * handling this callback can be used to signal a rebuild. The bo_flags
406b105a069SSam Leffler * array in the ieee80211_beacon_offsets structure is intended to record
407b105a069SSam Leffler * deferred processing requirements; ieee80211_beacon_update uses the
408b105a069SSam Leffler * state to optimize work. Since this structure is owned by the driver
409b032f27cSSam Leffler * and not visible to the 802.11 layer drivers must supply an iv_update_beacon
410b105a069SSam Leffler * callback that marks the flag bits and schedules (as necessary) an update.
411b105a069SSam Leffler */
412b105a069SSam Leffler enum {
413b105a069SSam Leffler IEEE80211_BEACON_CAPS = 0, /* capabilities */
414b105a069SSam Leffler IEEE80211_BEACON_TIM = 1, /* DTIM/ATIM */
415b105a069SSam Leffler IEEE80211_BEACON_WME = 2,
416b105a069SSam Leffler IEEE80211_BEACON_ERP = 3, /* Extended Rate Phy */
417b105a069SSam Leffler IEEE80211_BEACON_HTINFO = 4, /* HT Information */
418b105a069SSam Leffler IEEE80211_BEACON_APPIE = 5, /* Application IE's */
419b105a069SSam Leffler IEEE80211_BEACON_CFP = 6, /* CFParms */
420b105a069SSam Leffler IEEE80211_BEACON_CSA = 7, /* Channel Switch Announcement */
42110ad9a77SSam Leffler IEEE80211_BEACON_TDMA = 9, /* TDMA Info */
4224207227cSSam Leffler IEEE80211_BEACON_ATH = 10, /* ATH parameters */
423d093681cSRui Paulo IEEE80211_BEACON_MESHCONF = 11, /* Mesh Configuration */
4244d3dcce5SAdrian Chadd IEEE80211_BEACON_QUIET = 12, /* Quiet time IE */
4254d3dcce5SAdrian Chadd IEEE80211_BEACON_VHTINFO = 13, /* VHT information */
426b105a069SSam Leffler };
427b105a069SSam Leffler int ieee80211_beacon_update(struct ieee80211_node *,
428210ab3c2SAdrian Chadd struct mbuf *, int mcast);
4298a1b9b6aSSam Leffler
430b032f27cSSam Leffler void ieee80211_csa_startswitch(struct ieee80211com *,
431b032f27cSSam Leffler struct ieee80211_channel *, int mode, int count);
432b032f27cSSam Leffler void ieee80211_csa_completeswitch(struct ieee80211com *);
433c70761e6SSam Leffler void ieee80211_csa_cancelswitch(struct ieee80211com *);
434b032f27cSSam Leffler void ieee80211_cac_completeswitch(struct ieee80211vap *);
435b032f27cSSam Leffler
4368a1b9b6aSSam Leffler /*
4378a1b9b6aSSam Leffler * Notification methods called from the 802.11 state machine.
4388a1b9b6aSSam Leffler * Note that while these are defined here, their implementation
4398a1b9b6aSSam Leffler * is OS-specific.
4408a1b9b6aSSam Leffler */
441b032f27cSSam Leffler void ieee80211_notify_node_join(struct ieee80211_node *, int newassoc);
442b032f27cSSam Leffler void ieee80211_notify_node_leave(struct ieee80211_node *);
443b032f27cSSam Leffler void ieee80211_notify_scan_done(struct ieee80211vap *);
444b032f27cSSam Leffler void ieee80211_notify_wds_discover(struct ieee80211_node *);
445b032f27cSSam Leffler void ieee80211_notify_csa(struct ieee80211com *,
446b032f27cSSam Leffler const struct ieee80211_channel *, int mode, int count);
447b032f27cSSam Leffler void ieee80211_notify_radar(struct ieee80211com *,
448b032f27cSSam Leffler const struct ieee80211_channel *);
449b032f27cSSam Leffler enum ieee80211_notify_cac_event {
450b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_START = 0, /* CAC timer started */
451b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_STOP = 1, /* CAC intentionally stopped */
452b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_RADAR = 2, /* CAC stopped due to radar detectio */
453b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_EXPIRE = 3, /* CAC expired w/o radar */
454b032f27cSSam Leffler };
455b032f27cSSam Leffler void ieee80211_notify_cac(struct ieee80211com *,
456b032f27cSSam Leffler const struct ieee80211_channel *,
457b032f27cSSam Leffler enum ieee80211_notify_cac_event);
458b032f27cSSam Leffler void ieee80211_notify_node_deauth(struct ieee80211_node *);
459b032f27cSSam Leffler void ieee80211_notify_node_auth(struct ieee80211_node *);
4601f078120SJohn Baldwin void ieee80211_notify_country(struct ieee80211vap *,
4611f078120SJohn Baldwin const uint8_t [IEEE80211_ADDR_LEN], const uint8_t cc[2]);
462b032f27cSSam Leffler void ieee80211_notify_radio(struct ieee80211com *, int);
4631bcd230fSAlexander V. Chernikov void ieee80211_notify_ifnet_change(struct ieee80211vap *, int);
4641a1e1d21SSam Leffler #endif /* _NET80211_IEEE80211_PROTO_H_ */
465