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 */ 71864ab114SAdrian Chadd 72864ab114SAdrian Chadd struct ieee80211_rx_stats { 73864ab114SAdrian Chadd uint32_t r_flags; /* IEEE80211_R_* flags */ 74864ab114SAdrian Chadd uint8_t c_chain; /* number of RX chains involved */ 75864ab114SAdrian Chadd int16_t c_nf_ctl[IEEE80211_MAX_CHAINS]; /* per-chain NF */ 76864ab114SAdrian Chadd int16_t c_nf_ext[IEEE80211_MAX_CHAINS]; /* per-chain NF */ 77864ab114SAdrian Chadd int16_t c_rssi_ctl[IEEE80211_MAX_CHAINS]; /* per-chain RSSI */ 78864ab114SAdrian Chadd int16_t c_rssi_ext[IEEE80211_MAX_CHAINS]; /* per-chain RSSI */ 79864ab114SAdrian Chadd uint8_t nf; /* global NF */ 80864ab114SAdrian Chadd uint8_t rssi; /* global RSSI */ 81864ab114SAdrian Chadd uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS]; 82864ab114SAdrian Chadd /* per-chain, per-pilot EVM values */ 83864ab114SAdrian Chadd }; 84864ab114SAdrian Chadd 855463c4a4SSam Leffler #define ieee80211_input(ni, m, rssi, nf) \ 865463c4a4SSam Leffler ((ni)->ni_vap->iv_input(ni, m, rssi, nf)) 875463c4a4SSam Leffler int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int); 88864ab114SAdrian Chadd 89864ab114SAdrian Chadd int ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *, 90864ab114SAdrian Chadd struct ieee80211_rx_stats *); 91864ab114SAdrian Chadd int ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *, 92864ab114SAdrian Chadd struct ieee80211_rx_stats *); 93864ab114SAdrian Chadd 9499f1b25cSSam Leffler struct ieee80211_bpf_params; 958ac160cdSSam Leffler int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, 968ac160cdSSam Leffler struct ieee80211_bpf_params *); 97246b5467SSam Leffler int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, 98246b5467SSam Leffler const struct ieee80211_bpf_params *); 99246b5467SSam Leffler int ieee80211_output(struct ifnet *, struct mbuf *, 100*47e8d432SGleb Smirnoff const struct sockaddr *, struct route *ro); 1015cda6006SAdrian Chadd int ieee80211_raw_output(struct ieee80211vap *, struct ieee80211_node *, 1025cda6006SAdrian Chadd struct mbuf *, const struct ieee80211_bpf_params *); 10359aa14a9SRui Paulo void ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int, 10459aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], 10559aa14a9SRui Paulo const uint8_t [IEEE80211_ADDR_LEN]); 1065cda6006SAdrian Chadd void ieee80211_start(struct ifnet *ifp); 107f62121ceSSam Leffler int ieee80211_send_nulldata(struct ieee80211_node *); 108b032f27cSSam Leffler int ieee80211_classify(struct ieee80211_node *, struct mbuf *m); 109616190d0SSam Leffler struct mbuf *ieee80211_mbuf_adjust(struct ieee80211vap *, int, 110616190d0SSam Leffler struct ieee80211_key *, struct mbuf *); 111339ccfb3SSam Leffler struct mbuf *ieee80211_encap(struct ieee80211vap *, struct ieee80211_node *, 112339ccfb3SSam Leffler struct mbuf *); 113b032f27cSSam Leffler int ieee80211_send_mgmt(struct ieee80211_node *, int, int); 114b032f27cSSam Leffler struct ieee80211_appie; 11568e8e04eSSam Leffler int ieee80211_send_probereq(struct ieee80211_node *ni, 11668e8e04eSSam Leffler const uint8_t sa[IEEE80211_ADDR_LEN], 11768e8e04eSSam Leffler const uint8_t da[IEEE80211_ADDR_LEN], 11868e8e04eSSam Leffler const uint8_t bssid[IEEE80211_ADDR_LEN], 119b032f27cSSam Leffler const uint8_t *ssid, size_t ssidlen); 120b032f27cSSam Leffler /* 121b032f27cSSam Leffler * The formation of ProbeResponse frames requires guidance to 122b032f27cSSam Leffler * deal with legacy clients. When the client is identified as 123b032f27cSSam Leffler * "legacy 11b" ieee80211_send_proberesp is passed this token. 124b032f27cSSam Leffler */ 125b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY_11B 0x1 /* legacy 11b client */ 126b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY_11 0x2 /* other legacy client */ 127b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY 0x3 /* any legacy client */ 128b032f27cSSam Leffler struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int); 129b032f27cSSam Leffler int ieee80211_send_proberesp(struct ieee80211vap *, 130b032f27cSSam Leffler const uint8_t da[IEEE80211_ADDR_LEN], int); 131b032f27cSSam Leffler struct mbuf *ieee80211_alloc_rts(struct ieee80211com *ic, 132b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], 133b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], uint16_t); 134b032f27cSSam Leffler struct mbuf *ieee80211_alloc_cts(struct ieee80211com *, 135b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], uint16_t); 1368a1b9b6aSSam Leffler 13759aa14a9SRui Paulo uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *); 13859aa14a9SRui Paulo uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *); 13959aa14a9SRui Paulo uint16_t ieee80211_getcapinfo(struct ieee80211vap *, 14059aa14a9SRui Paulo struct ieee80211_channel *); 14159aa14a9SRui Paulo 1420942c81cSSam Leffler void ieee80211_reset_erp(struct ieee80211com *); 1430942c81cSSam Leffler void ieee80211_set_shortslottime(struct ieee80211com *, int onoff); 144b032f27cSSam Leffler int ieee80211_iserp_rateset(const struct ieee80211_rateset *); 145b032f27cSSam Leffler void ieee80211_setbasicrates(struct ieee80211_rateset *, 146b032f27cSSam Leffler enum ieee80211_phymode); 147b032f27cSSam Leffler void ieee80211_addbasicrates(struct ieee80211_rateset *, 1488a1b9b6aSSam Leffler enum ieee80211_phymode); 1498a1b9b6aSSam Leffler 1508a1b9b6aSSam Leffler /* 1518a1b9b6aSSam Leffler * Return the size of the 802.11 header for a management or data frame. 1528a1b9b6aSSam Leffler */ 153a95fa8d3SSam Leffler static __inline int 1548a1b9b6aSSam Leffler ieee80211_hdrsize(const void *data) 1558a1b9b6aSSam Leffler { 1568a1b9b6aSSam Leffler const struct ieee80211_frame *wh = data; 1578a1b9b6aSSam Leffler int size = sizeof(struct ieee80211_frame); 1588a1b9b6aSSam Leffler 1598a1b9b6aSSam Leffler /* NB: we don't handle control frames */ 1608a1b9b6aSSam Leffler KASSERT((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL, 1618a1b9b6aSSam Leffler ("%s: control frame", __func__)); 16232bdd57bSSam Leffler if (IEEE80211_IS_DSTODS(wh)) 1638a1b9b6aSSam Leffler size += IEEE80211_ADDR_LEN; 1648a1b9b6aSSam Leffler if (IEEE80211_QOS_HAS_SEQ(wh)) 16568e8e04eSSam Leffler size += sizeof(uint16_t); 1668a1b9b6aSSam Leffler return size; 1678a1b9b6aSSam Leffler } 1688a1b9b6aSSam Leffler 1698a1b9b6aSSam Leffler /* 17068e8e04eSSam Leffler * Like ieee80211_hdrsize, but handles any type of frame. 1718a1b9b6aSSam Leffler */ 172a95fa8d3SSam Leffler static __inline int 1738a1b9b6aSSam Leffler ieee80211_anyhdrsize(const void *data) 1748a1b9b6aSSam Leffler { 1758a1b9b6aSSam Leffler const struct ieee80211_frame *wh = data; 1768a1b9b6aSSam Leffler 1778a1b9b6aSSam Leffler if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) { 1788a1b9b6aSSam Leffler switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { 1798a1b9b6aSSam Leffler case IEEE80211_FC0_SUBTYPE_CTS: 1808a1b9b6aSSam Leffler case IEEE80211_FC0_SUBTYPE_ACK: 1818a1b9b6aSSam Leffler return sizeof(struct ieee80211_frame_ack); 18268e8e04eSSam Leffler case IEEE80211_FC0_SUBTYPE_BAR: 18368e8e04eSSam Leffler return sizeof(struct ieee80211_frame_bar); 1848a1b9b6aSSam Leffler } 1858a1b9b6aSSam Leffler return sizeof(struct ieee80211_frame_min); 1868a1b9b6aSSam Leffler } else 1878a1b9b6aSSam Leffler return ieee80211_hdrsize(data); 1888a1b9b6aSSam Leffler } 1898a1b9b6aSSam Leffler 1908a1b9b6aSSam Leffler /* 1918a1b9b6aSSam Leffler * Template for an in-kernel authenticator. Authenticators 1928a1b9b6aSSam Leffler * register with the protocol code and are typically loaded 193b032f27cSSam Leffler * as separate modules as needed. One special authenticator 194b032f27cSSam Leffler * is xauth; it intercepts requests so that protocols like 195b032f27cSSam Leffler * WPA can be handled in user space. 1968a1b9b6aSSam Leffler */ 1978a1b9b6aSSam Leffler struct ieee80211_authenticator { 1988a1b9b6aSSam Leffler const char *ia_name; /* printable name */ 199b032f27cSSam Leffler int (*ia_attach)(struct ieee80211vap *); 200b032f27cSSam Leffler void (*ia_detach)(struct ieee80211vap *); 201b032f27cSSam Leffler void (*ia_node_join)(struct ieee80211_node *); 202b032f27cSSam Leffler void (*ia_node_leave)(struct ieee80211_node *); 2038a1b9b6aSSam Leffler }; 2040942c81cSSam Leffler void ieee80211_authenticator_register(int type, 2058a1b9b6aSSam Leffler const struct ieee80211_authenticator *); 2060942c81cSSam Leffler void ieee80211_authenticator_unregister(int type); 2070942c81cSSam Leffler const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth); 2088a1b9b6aSSam Leffler 209188757f5SSam Leffler struct ieee80211req; 2108a1b9b6aSSam Leffler /* 2118a1b9b6aSSam Leffler * Template for an MAC ACL policy module. Such modules 2128a1b9b6aSSam Leffler * register with the protocol code and are passed the sender's 213b032f27cSSam Leffler * address of each received auth frame for validation. 2148a1b9b6aSSam Leffler */ 2158a1b9b6aSSam Leffler struct ieee80211_aclator { 2168a1b9b6aSSam Leffler const char *iac_name; /* printable name */ 217b032f27cSSam Leffler int (*iac_attach)(struct ieee80211vap *); 218b032f27cSSam Leffler void (*iac_detach)(struct ieee80211vap *); 219b032f27cSSam Leffler int (*iac_check)(struct ieee80211vap *, 2205a8801b0SBernhard Schmidt const struct ieee80211_frame *wh); 221b032f27cSSam Leffler int (*iac_add)(struct ieee80211vap *, 22268e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]); 223b032f27cSSam Leffler int (*iac_remove)(struct ieee80211vap *, 22468e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]); 225b032f27cSSam Leffler int (*iac_flush)(struct ieee80211vap *); 226b032f27cSSam Leffler int (*iac_setpolicy)(struct ieee80211vap *, int); 227b032f27cSSam Leffler int (*iac_getpolicy)(struct ieee80211vap *); 228b032f27cSSam Leffler int (*iac_setioctl)(struct ieee80211vap *, struct ieee80211req *); 229b032f27cSSam Leffler int (*iac_getioctl)(struct ieee80211vap *, struct ieee80211req *); 2308a1b9b6aSSam Leffler }; 2310942c81cSSam Leffler void ieee80211_aclator_register(const struct ieee80211_aclator *); 2320942c81cSSam Leffler void ieee80211_aclator_unregister(const struct ieee80211_aclator *); 2330942c81cSSam Leffler const struct ieee80211_aclator *ieee80211_aclator_get(const char *name); 2348a1b9b6aSSam Leffler 2358a1b9b6aSSam Leffler /* flags for ieee80211_fix_rate() */ 2368a1b9b6aSSam Leffler #define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */ 237b032f27cSSam Leffler #define IEEE80211_F_DOFRATE 0x00000002 /* use fixed legacy rate */ 2388a1b9b6aSSam Leffler #define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */ 2398a1b9b6aSSam Leffler #define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */ 24068e8e04eSSam Leffler #define IEEE80211_F_DOBRS 0x00000010 /* check basic rate set */ 24168e8e04eSSam Leffler #define IEEE80211_F_JOIN 0x00000020 /* sta joining our bss */ 242b032f27cSSam Leffler #define IEEE80211_F_DOFMCS 0x00000040 /* use fixed HT rate */ 24370e28b9aSSam Leffler int ieee80211_fix_rate(struct ieee80211_node *, 24470e28b9aSSam Leffler struct ieee80211_rateset *, int); 2458a1b9b6aSSam Leffler 2468a1b9b6aSSam Leffler /* 2478a1b9b6aSSam Leffler * WME/WMM support. 2488a1b9b6aSSam Leffler */ 2498a1b9b6aSSam Leffler struct wmeParams { 25068e8e04eSSam Leffler uint8_t wmep_acm; 25168e8e04eSSam Leffler uint8_t wmep_aifsn; 25268e8e04eSSam Leffler uint8_t wmep_logcwmin; /* log2(cwmin) */ 25368e8e04eSSam Leffler uint8_t wmep_logcwmax; /* log2(cwmax) */ 25468e8e04eSSam Leffler uint8_t wmep_txopLimit; 25568e8e04eSSam Leffler uint8_t wmep_noackPolicy; /* 0 (ack), 1 (no ack) */ 2568a1b9b6aSSam Leffler }; 2575a11fbcaSSam Leffler #define IEEE80211_TXOP_TO_US(_txop) ((_txop)<<5) 2585a11fbcaSSam Leffler #define IEEE80211_US_TO_TXOP(_us) ((_us)>>5) 2598a1b9b6aSSam Leffler 2608a1b9b6aSSam Leffler struct chanAccParams { 26168e8e04eSSam Leffler uint8_t cap_info; /* version of the current set */ 2628a1b9b6aSSam Leffler struct wmeParams cap_wmeParams[WME_NUM_AC]; 2638a1b9b6aSSam Leffler }; 2648a1b9b6aSSam Leffler 2658a1b9b6aSSam Leffler struct ieee80211_wme_state { 2668a1b9b6aSSam Leffler u_int wme_flags; 2678a1b9b6aSSam Leffler #define WME_F_AGGRMODE 0x00000001 /* STATUS: WME agressive mode */ 2688a1b9b6aSSam Leffler u_int wme_hipri_traffic; /* VI/VO frames in beacon interval */ 2698a1b9b6aSSam Leffler u_int wme_hipri_switch_thresh;/* agressive mode switch thresh */ 2708a1b9b6aSSam Leffler u_int wme_hipri_switch_hysteresis;/* agressive mode switch hysteresis */ 2718a1b9b6aSSam Leffler 2728a1b9b6aSSam Leffler struct wmeParams wme_params[4]; /* from assoc resp for each AC*/ 2738a1b9b6aSSam Leffler struct chanAccParams wme_wmeChanParams; /* WME params applied to self */ 2748a1b9b6aSSam Leffler struct chanAccParams wme_wmeBssChanParams;/* WME params bcast to stations */ 2758a1b9b6aSSam Leffler struct chanAccParams wme_chanParams; /* params applied to self */ 2768a1b9b6aSSam Leffler struct chanAccParams wme_bssChanParams; /* params bcast to stations */ 2778a1b9b6aSSam Leffler 2788a1b9b6aSSam Leffler int (*wme_update)(struct ieee80211com *); 2798a1b9b6aSSam Leffler }; 2808a1b9b6aSSam Leffler 281b032f27cSSam Leffler void ieee80211_wme_initparams(struct ieee80211vap *); 282b032f27cSSam Leffler void ieee80211_wme_updateparams(struct ieee80211vap *); 283b032f27cSSam Leffler void ieee80211_wme_updateparams_locked(struct ieee80211vap *); 2848a1b9b6aSSam Leffler 285b032f27cSSam Leffler /* 286b032f27cSSam Leffler * Return the WME TID from a QoS frame. If no TID 287b032f27cSSam Leffler * is present return the index for the "non-QoS" entry. 288b032f27cSSam Leffler */ 289b032f27cSSam Leffler static __inline uint8_t 290b032f27cSSam Leffler ieee80211_gettid(const struct ieee80211_frame *wh) 291b032f27cSSam Leffler { 292b032f27cSSam Leffler uint8_t tid; 293b032f27cSSam Leffler 294b032f27cSSam Leffler if (IEEE80211_QOS_HAS_SEQ(wh)) { 29532bdd57bSSam Leffler if (IEEE80211_IS_DSTODS(wh)) 29632bdd57bSSam Leffler tid = ((const struct ieee80211_qosframe_addr4 *)wh)-> 29732bdd57bSSam Leffler i_qos[0]; 29832bdd57bSSam Leffler else 29932bdd57bSSam Leffler tid = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; 30032bdd57bSSam Leffler tid &= IEEE80211_QOS_TID; 301b032f27cSSam Leffler } else 302b032f27cSSam Leffler tid = IEEE80211_NONQOS_TID; 303b032f27cSSam Leffler return tid; 304b032f27cSSam Leffler } 305b032f27cSSam Leffler 306ae55932eSAndrew Thompson void ieee80211_waitfor_parent(struct ieee80211com *); 307b032f27cSSam Leffler void ieee80211_start_locked(struct ieee80211vap *); 308b032f27cSSam Leffler void ieee80211_init(void *); 309b032f27cSSam Leffler void ieee80211_start_all(struct ieee80211com *); 310b032f27cSSam Leffler void ieee80211_stop_locked(struct ieee80211vap *); 311b032f27cSSam Leffler void ieee80211_stop(struct ieee80211vap *); 312b032f27cSSam Leffler void ieee80211_stop_all(struct ieee80211com *); 3136076cbacSSam Leffler void ieee80211_suspend_all(struct ieee80211com *); 3146076cbacSSam Leffler void ieee80211_resume_all(struct ieee80211com *); 315b032f27cSSam Leffler void ieee80211_dturbo_switch(struct ieee80211vap *, int newflags); 316b032f27cSSam Leffler void ieee80211_swbmiss(void *arg); 317e701e041SSam Leffler void ieee80211_beacon_miss(struct ieee80211com *); 318b032f27cSSam Leffler int ieee80211_new_state(struct ieee80211vap *, enum ieee80211_state, int); 31968e8e04eSSam Leffler void ieee80211_print_essid(const uint8_t *, int); 32068e8e04eSSam Leffler void ieee80211_dump_pkt(struct ieee80211com *, 32168e8e04eSSam Leffler const uint8_t *, int, int, int); 322a11c9a5cSSam Leffler 32349aa47d6SSam Leffler extern const char *ieee80211_opmode_name[]; 324a11c9a5cSSam Leffler extern const char *ieee80211_state_name[IEEE80211_S_MAX]; 3258a1b9b6aSSam Leffler extern const char *ieee80211_wme_acnames[]; 3268a1b9b6aSSam Leffler 3278a1b9b6aSSam Leffler /* 3288a1b9b6aSSam Leffler * Beacon frames constructed by ieee80211_beacon_alloc 3298a1b9b6aSSam Leffler * have the following structure filled in so drivers 3308a1b9b6aSSam Leffler * can update the frame later w/ minimal overhead. 3318a1b9b6aSSam Leffler */ 3328a1b9b6aSSam Leffler struct ieee80211_beacon_offsets { 333b105a069SSam Leffler uint8_t bo_flags[4]; /* update/state flags */ 33468e8e04eSSam Leffler uint16_t *bo_caps; /* capabilities */ 335b105a069SSam Leffler uint8_t *bo_cfp; /* start of CFParms element */ 33668e8e04eSSam Leffler uint8_t *bo_tim; /* start of atim/dtim */ 33768e8e04eSSam Leffler uint8_t *bo_wme; /* start of WME parameters */ 33810ad9a77SSam Leffler uint8_t *bo_tdma; /* start of TDMA parameters */ 339b105a069SSam Leffler uint8_t *bo_tim_trailer;/* start of fixed-size trailer */ 34068e8e04eSSam Leffler uint16_t bo_tim_len; /* atim/dtim length in bytes */ 341b105a069SSam Leffler uint16_t bo_tim_trailer_len;/* tim trailer length in bytes */ 34268e8e04eSSam Leffler uint8_t *bo_erp; /* start of ERP element */ 34368e8e04eSSam Leffler uint8_t *bo_htinfo; /* start of HT info element */ 3444207227cSSam Leffler uint8_t *bo_ath; /* start of ATH parameters */ 345b105a069SSam Leffler uint8_t *bo_appie; /* start of AppIE element */ 346b105a069SSam Leffler uint16_t bo_appie_len; /* AppIE length in bytes */ 347d673ae81SAntoine Brodin uint16_t bo_csa_trailer_len; 348b105a069SSam Leffler uint8_t *bo_csa; /* start of CSA element */ 34932b0e64bSAdrian Chadd uint8_t *bo_quiet; /* start of Quiet element */ 350d093681cSRui Paulo uint8_t *bo_meshconf; /* start of MESHCONF element */ 351d093681cSRui Paulo uint8_t *bo_spare[3]; 3528a1b9b6aSSam Leffler }; 353b105a069SSam Leffler struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *, 354b105a069SSam Leffler struct ieee80211_beacon_offsets *); 355b105a069SSam Leffler 356b105a069SSam Leffler /* 357b032f27cSSam Leffler * Beacon frame updates are signaled through calls to iv_update_beacon 358b105a069SSam Leffler * with one of the IEEE80211_BEACON_* tokens defined below. For devices 359b105a069SSam Leffler * that construct beacon frames on the host this can trigger a rebuild 360b105a069SSam Leffler * or defer the processing. For devices that offload beacon frame 361b105a069SSam Leffler * handling this callback can be used to signal a rebuild. The bo_flags 362b105a069SSam Leffler * array in the ieee80211_beacon_offsets structure is intended to record 363b105a069SSam Leffler * deferred processing requirements; ieee80211_beacon_update uses the 364b105a069SSam Leffler * state to optimize work. Since this structure is owned by the driver 365b032f27cSSam Leffler * and not visible to the 802.11 layer drivers must supply an iv_update_beacon 366b105a069SSam Leffler * callback that marks the flag bits and schedules (as necessary) an update. 367b105a069SSam Leffler */ 368b105a069SSam Leffler enum { 369b105a069SSam Leffler IEEE80211_BEACON_CAPS = 0, /* capabilities */ 370b105a069SSam Leffler IEEE80211_BEACON_TIM = 1, /* DTIM/ATIM */ 371b105a069SSam Leffler IEEE80211_BEACON_WME = 2, 372b105a069SSam Leffler IEEE80211_BEACON_ERP = 3, /* Extended Rate Phy */ 373b105a069SSam Leffler IEEE80211_BEACON_HTINFO = 4, /* HT Information */ 374b105a069SSam Leffler IEEE80211_BEACON_APPIE = 5, /* Application IE's */ 375b105a069SSam Leffler IEEE80211_BEACON_CFP = 6, /* CFParms */ 376b105a069SSam Leffler IEEE80211_BEACON_CSA = 7, /* Channel Switch Announcement */ 37710ad9a77SSam Leffler IEEE80211_BEACON_TDMA = 9, /* TDMA Info */ 3784207227cSSam Leffler IEEE80211_BEACON_ATH = 10, /* ATH parameters */ 379d093681cSRui Paulo IEEE80211_BEACON_MESHCONF = 11, /* Mesh Configuration */ 380b105a069SSam Leffler }; 381b105a069SSam Leffler int ieee80211_beacon_update(struct ieee80211_node *, 382b105a069SSam Leffler struct ieee80211_beacon_offsets *, struct mbuf *, int mcast); 3838a1b9b6aSSam Leffler 384b032f27cSSam Leffler void ieee80211_csa_startswitch(struct ieee80211com *, 385b032f27cSSam Leffler struct ieee80211_channel *, int mode, int count); 386b032f27cSSam Leffler void ieee80211_csa_completeswitch(struct ieee80211com *); 387c70761e6SSam Leffler void ieee80211_csa_cancelswitch(struct ieee80211com *); 388b032f27cSSam Leffler void ieee80211_cac_completeswitch(struct ieee80211vap *); 389b032f27cSSam Leffler 3908a1b9b6aSSam Leffler /* 3918a1b9b6aSSam Leffler * Notification methods called from the 802.11 state machine. 3928a1b9b6aSSam Leffler * Note that while these are defined here, their implementation 3938a1b9b6aSSam Leffler * is OS-specific. 3948a1b9b6aSSam Leffler */ 395b032f27cSSam Leffler void ieee80211_notify_node_join(struct ieee80211_node *, int newassoc); 396b032f27cSSam Leffler void ieee80211_notify_node_leave(struct ieee80211_node *); 397b032f27cSSam Leffler void ieee80211_notify_scan_done(struct ieee80211vap *); 398b032f27cSSam Leffler void ieee80211_notify_wds_discover(struct ieee80211_node *); 399b032f27cSSam Leffler void ieee80211_notify_csa(struct ieee80211com *, 400b032f27cSSam Leffler const struct ieee80211_channel *, int mode, int count); 401b032f27cSSam Leffler void ieee80211_notify_radar(struct ieee80211com *, 402b032f27cSSam Leffler const struct ieee80211_channel *); 403b032f27cSSam Leffler enum ieee80211_notify_cac_event { 404b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_START = 0, /* CAC timer started */ 405b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_STOP = 1, /* CAC intentionally stopped */ 406b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_RADAR = 2, /* CAC stopped due to radar detectio */ 407b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_EXPIRE = 3, /* CAC expired w/o radar */ 408b032f27cSSam Leffler }; 409b032f27cSSam Leffler void ieee80211_notify_cac(struct ieee80211com *, 410b032f27cSSam Leffler const struct ieee80211_channel *, 411b032f27cSSam Leffler enum ieee80211_notify_cac_event); 412b032f27cSSam Leffler void ieee80211_notify_node_deauth(struct ieee80211_node *); 413b032f27cSSam Leffler void ieee80211_notify_node_auth(struct ieee80211_node *); 414b032f27cSSam Leffler void ieee80211_notify_country(struct ieee80211vap *, const uint8_t [], 415b032f27cSSam Leffler const uint8_t cc[2]); 416b032f27cSSam Leffler void ieee80211_notify_radio(struct ieee80211com *, int); 4171a1e1d21SSam Leffler #endif /* _NET80211_IEEE80211_PROTO_H_ */ 418