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 64*864ab114SAdrian Chadd #define IEEE80211_R_NF 0x0000001 /* global NF value valid */ 65*864ab114SAdrian Chadd #define IEEE80211_R_RSSI 0x0000002 /* global RSSI value valid */ 66*864ab114SAdrian Chadd #define IEEE80211_R_C_CHAIN 0x0000004 /* RX chain count valid */ 67*864ab114SAdrian Chadd #define IEEE80211_R_C_NF 0x0000008 /* per-chain NF value valid */ 68*864ab114SAdrian Chadd #define IEEE80211_R_C_RSSI 0x0000010 /* per-chain RSSI value valid */ 69*864ab114SAdrian Chadd #define IEEE80211_R_C_EVM 0x0000020 /* per-chain EVM valid */ 70*864ab114SAdrian Chadd #define IEEE80211_R_C_HT40 0x0000040 /* RX'ed packet is 40mhz, pilots 4,5 valid */ 71*864ab114SAdrian Chadd 72*864ab114SAdrian Chadd struct ieee80211_rx_stats { 73*864ab114SAdrian Chadd uint32_t r_flags; /* IEEE80211_R_* flags */ 74*864ab114SAdrian Chadd uint8_t c_chain; /* number of RX chains involved */ 75*864ab114SAdrian Chadd int16_t c_nf_ctl[IEEE80211_MAX_CHAINS]; /* per-chain NF */ 76*864ab114SAdrian Chadd int16_t c_nf_ext[IEEE80211_MAX_CHAINS]; /* per-chain NF */ 77*864ab114SAdrian Chadd int16_t c_rssi_ctl[IEEE80211_MAX_CHAINS]; /* per-chain RSSI */ 78*864ab114SAdrian Chadd int16_t c_rssi_ext[IEEE80211_MAX_CHAINS]; /* per-chain RSSI */ 79*864ab114SAdrian Chadd uint8_t nf; /* global NF */ 80*864ab114SAdrian Chadd uint8_t rssi; /* global RSSI */ 81*864ab114SAdrian Chadd uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS]; 82*864ab114SAdrian Chadd /* per-chain, per-pilot EVM values */ 83*864ab114SAdrian Chadd }; 84*864ab114SAdrian 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); 88*864ab114SAdrian Chadd 89*864ab114SAdrian Chadd int ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *, 90*864ab114SAdrian Chadd struct ieee80211_rx_stats *); 91*864ab114SAdrian Chadd int ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *, 92*864ab114SAdrian Chadd struct ieee80211_rx_stats *); 93*864ab114SAdrian 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 *, 100279aa3d4SKip Macy struct sockaddr *, struct route *ro); 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]); 104b032f27cSSam Leffler void ieee80211_start(struct ifnet *); 105f62121ceSSam Leffler int ieee80211_send_nulldata(struct ieee80211_node *); 106b032f27cSSam Leffler int ieee80211_classify(struct ieee80211_node *, struct mbuf *m); 107616190d0SSam Leffler struct mbuf *ieee80211_mbuf_adjust(struct ieee80211vap *, int, 108616190d0SSam Leffler struct ieee80211_key *, struct mbuf *); 109339ccfb3SSam Leffler struct mbuf *ieee80211_encap(struct ieee80211vap *, struct ieee80211_node *, 110339ccfb3SSam Leffler struct mbuf *); 111b032f27cSSam Leffler int ieee80211_send_mgmt(struct ieee80211_node *, int, int); 112b032f27cSSam Leffler struct ieee80211_appie; 11368e8e04eSSam Leffler int ieee80211_send_probereq(struct ieee80211_node *ni, 11468e8e04eSSam Leffler const uint8_t sa[IEEE80211_ADDR_LEN], 11568e8e04eSSam Leffler const uint8_t da[IEEE80211_ADDR_LEN], 11668e8e04eSSam Leffler const uint8_t bssid[IEEE80211_ADDR_LEN], 117b032f27cSSam Leffler const uint8_t *ssid, size_t ssidlen); 118b032f27cSSam Leffler /* 119b032f27cSSam Leffler * The formation of ProbeResponse frames requires guidance to 120b032f27cSSam Leffler * deal with legacy clients. When the client is identified as 121b032f27cSSam Leffler * "legacy 11b" ieee80211_send_proberesp is passed this token. 122b032f27cSSam Leffler */ 123b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY_11B 0x1 /* legacy 11b client */ 124b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY_11 0x2 /* other legacy client */ 125b032f27cSSam Leffler #define IEEE80211_SEND_LEGACY 0x3 /* any legacy client */ 126b032f27cSSam Leffler struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int); 127b032f27cSSam Leffler int ieee80211_send_proberesp(struct ieee80211vap *, 128b032f27cSSam Leffler const uint8_t da[IEEE80211_ADDR_LEN], int); 129b032f27cSSam Leffler struct mbuf *ieee80211_alloc_rts(struct ieee80211com *ic, 130b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], 131b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], uint16_t); 132b032f27cSSam Leffler struct mbuf *ieee80211_alloc_cts(struct ieee80211com *, 133b032f27cSSam Leffler const uint8_t [IEEE80211_ADDR_LEN], uint16_t); 1348a1b9b6aSSam Leffler 13559aa14a9SRui Paulo uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *); 13659aa14a9SRui Paulo uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *); 13759aa14a9SRui Paulo uint16_t ieee80211_getcapinfo(struct ieee80211vap *, 13859aa14a9SRui Paulo struct ieee80211_channel *); 13959aa14a9SRui Paulo 1400942c81cSSam Leffler void ieee80211_reset_erp(struct ieee80211com *); 1410942c81cSSam Leffler void ieee80211_set_shortslottime(struct ieee80211com *, int onoff); 142b032f27cSSam Leffler int ieee80211_iserp_rateset(const struct ieee80211_rateset *); 143b032f27cSSam Leffler void ieee80211_setbasicrates(struct ieee80211_rateset *, 144b032f27cSSam Leffler enum ieee80211_phymode); 145b032f27cSSam Leffler void ieee80211_addbasicrates(struct ieee80211_rateset *, 1468a1b9b6aSSam Leffler enum ieee80211_phymode); 1478a1b9b6aSSam Leffler 1488a1b9b6aSSam Leffler /* 1498a1b9b6aSSam Leffler * Return the size of the 802.11 header for a management or data frame. 1508a1b9b6aSSam Leffler */ 151a95fa8d3SSam Leffler static __inline int 1528a1b9b6aSSam Leffler ieee80211_hdrsize(const void *data) 1538a1b9b6aSSam Leffler { 1548a1b9b6aSSam Leffler const struct ieee80211_frame *wh = data; 1558a1b9b6aSSam Leffler int size = sizeof(struct ieee80211_frame); 1568a1b9b6aSSam Leffler 1578a1b9b6aSSam Leffler /* NB: we don't handle control frames */ 1588a1b9b6aSSam Leffler KASSERT((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL, 1598a1b9b6aSSam Leffler ("%s: control frame", __func__)); 16032bdd57bSSam Leffler if (IEEE80211_IS_DSTODS(wh)) 1618a1b9b6aSSam Leffler size += IEEE80211_ADDR_LEN; 1628a1b9b6aSSam Leffler if (IEEE80211_QOS_HAS_SEQ(wh)) 16368e8e04eSSam Leffler size += sizeof(uint16_t); 1648a1b9b6aSSam Leffler return size; 1658a1b9b6aSSam Leffler } 1668a1b9b6aSSam Leffler 1678a1b9b6aSSam Leffler /* 16868e8e04eSSam Leffler * Like ieee80211_hdrsize, but handles any type of frame. 1698a1b9b6aSSam Leffler */ 170a95fa8d3SSam Leffler static __inline int 1718a1b9b6aSSam Leffler ieee80211_anyhdrsize(const void *data) 1728a1b9b6aSSam Leffler { 1738a1b9b6aSSam Leffler const struct ieee80211_frame *wh = data; 1748a1b9b6aSSam Leffler 1758a1b9b6aSSam Leffler if ((wh->i_fc[0]&IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) { 1768a1b9b6aSSam Leffler switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { 1778a1b9b6aSSam Leffler case IEEE80211_FC0_SUBTYPE_CTS: 1788a1b9b6aSSam Leffler case IEEE80211_FC0_SUBTYPE_ACK: 1798a1b9b6aSSam Leffler return sizeof(struct ieee80211_frame_ack); 18068e8e04eSSam Leffler case IEEE80211_FC0_SUBTYPE_BAR: 18168e8e04eSSam Leffler return sizeof(struct ieee80211_frame_bar); 1828a1b9b6aSSam Leffler } 1838a1b9b6aSSam Leffler return sizeof(struct ieee80211_frame_min); 1848a1b9b6aSSam Leffler } else 1858a1b9b6aSSam Leffler return ieee80211_hdrsize(data); 1868a1b9b6aSSam Leffler } 1878a1b9b6aSSam Leffler 1888a1b9b6aSSam Leffler /* 1898a1b9b6aSSam Leffler * Template for an in-kernel authenticator. Authenticators 1908a1b9b6aSSam Leffler * register with the protocol code and are typically loaded 191b032f27cSSam Leffler * as separate modules as needed. One special authenticator 192b032f27cSSam Leffler * is xauth; it intercepts requests so that protocols like 193b032f27cSSam Leffler * WPA can be handled in user space. 1948a1b9b6aSSam Leffler */ 1958a1b9b6aSSam Leffler struct ieee80211_authenticator { 1968a1b9b6aSSam Leffler const char *ia_name; /* printable name */ 197b032f27cSSam Leffler int (*ia_attach)(struct ieee80211vap *); 198b032f27cSSam Leffler void (*ia_detach)(struct ieee80211vap *); 199b032f27cSSam Leffler void (*ia_node_join)(struct ieee80211_node *); 200b032f27cSSam Leffler void (*ia_node_leave)(struct ieee80211_node *); 2018a1b9b6aSSam Leffler }; 2020942c81cSSam Leffler void ieee80211_authenticator_register(int type, 2038a1b9b6aSSam Leffler const struct ieee80211_authenticator *); 2040942c81cSSam Leffler void ieee80211_authenticator_unregister(int type); 2050942c81cSSam Leffler const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth); 2068a1b9b6aSSam Leffler 207188757f5SSam Leffler struct ieee80211req; 2088a1b9b6aSSam Leffler /* 2098a1b9b6aSSam Leffler * Template for an MAC ACL policy module. Such modules 2108a1b9b6aSSam Leffler * register with the protocol code and are passed the sender's 211b032f27cSSam Leffler * address of each received auth frame for validation. 2128a1b9b6aSSam Leffler */ 2138a1b9b6aSSam Leffler struct ieee80211_aclator { 2148a1b9b6aSSam Leffler const char *iac_name; /* printable name */ 215b032f27cSSam Leffler int (*iac_attach)(struct ieee80211vap *); 216b032f27cSSam Leffler void (*iac_detach)(struct ieee80211vap *); 217b032f27cSSam Leffler int (*iac_check)(struct ieee80211vap *, 21868e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]); 219b032f27cSSam Leffler int (*iac_add)(struct ieee80211vap *, 22068e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]); 221b032f27cSSam Leffler int (*iac_remove)(struct ieee80211vap *, 22268e8e04eSSam Leffler const uint8_t mac[IEEE80211_ADDR_LEN]); 223b032f27cSSam Leffler int (*iac_flush)(struct ieee80211vap *); 224b032f27cSSam Leffler int (*iac_setpolicy)(struct ieee80211vap *, int); 225b032f27cSSam Leffler int (*iac_getpolicy)(struct ieee80211vap *); 226b032f27cSSam Leffler int (*iac_setioctl)(struct ieee80211vap *, struct ieee80211req *); 227b032f27cSSam Leffler int (*iac_getioctl)(struct ieee80211vap *, struct ieee80211req *); 2288a1b9b6aSSam Leffler }; 2290942c81cSSam Leffler void ieee80211_aclator_register(const struct ieee80211_aclator *); 2300942c81cSSam Leffler void ieee80211_aclator_unregister(const struct ieee80211_aclator *); 2310942c81cSSam Leffler const struct ieee80211_aclator *ieee80211_aclator_get(const char *name); 2328a1b9b6aSSam Leffler 2338a1b9b6aSSam Leffler /* flags for ieee80211_fix_rate() */ 2348a1b9b6aSSam Leffler #define IEEE80211_F_DOSORT 0x00000001 /* sort rate list */ 235b032f27cSSam Leffler #define IEEE80211_F_DOFRATE 0x00000002 /* use fixed legacy rate */ 2368a1b9b6aSSam Leffler #define IEEE80211_F_DONEGO 0x00000004 /* calc negotiated rate */ 2378a1b9b6aSSam Leffler #define IEEE80211_F_DODEL 0x00000008 /* delete ignore rate */ 23868e8e04eSSam Leffler #define IEEE80211_F_DOBRS 0x00000010 /* check basic rate set */ 23968e8e04eSSam Leffler #define IEEE80211_F_JOIN 0x00000020 /* sta joining our bss */ 240b032f27cSSam Leffler #define IEEE80211_F_DOFMCS 0x00000040 /* use fixed HT rate */ 24170e28b9aSSam Leffler int ieee80211_fix_rate(struct ieee80211_node *, 24270e28b9aSSam Leffler struct ieee80211_rateset *, int); 2438a1b9b6aSSam Leffler 2448a1b9b6aSSam Leffler /* 2458a1b9b6aSSam Leffler * WME/WMM support. 2468a1b9b6aSSam Leffler */ 2478a1b9b6aSSam Leffler struct wmeParams { 24868e8e04eSSam Leffler uint8_t wmep_acm; 24968e8e04eSSam Leffler uint8_t wmep_aifsn; 25068e8e04eSSam Leffler uint8_t wmep_logcwmin; /* log2(cwmin) */ 25168e8e04eSSam Leffler uint8_t wmep_logcwmax; /* log2(cwmax) */ 25268e8e04eSSam Leffler uint8_t wmep_txopLimit; 25368e8e04eSSam Leffler uint8_t wmep_noackPolicy; /* 0 (ack), 1 (no ack) */ 2548a1b9b6aSSam Leffler }; 2555a11fbcaSSam Leffler #define IEEE80211_TXOP_TO_US(_txop) ((_txop)<<5) 2565a11fbcaSSam Leffler #define IEEE80211_US_TO_TXOP(_us) ((_us)>>5) 2578a1b9b6aSSam Leffler 2588a1b9b6aSSam Leffler struct chanAccParams { 25968e8e04eSSam Leffler uint8_t cap_info; /* version of the current set */ 2608a1b9b6aSSam Leffler struct wmeParams cap_wmeParams[WME_NUM_AC]; 2618a1b9b6aSSam Leffler }; 2628a1b9b6aSSam Leffler 2638a1b9b6aSSam Leffler struct ieee80211_wme_state { 2648a1b9b6aSSam Leffler u_int wme_flags; 2658a1b9b6aSSam Leffler #define WME_F_AGGRMODE 0x00000001 /* STATUS: WME agressive mode */ 2668a1b9b6aSSam Leffler u_int wme_hipri_traffic; /* VI/VO frames in beacon interval */ 2678a1b9b6aSSam Leffler u_int wme_hipri_switch_thresh;/* agressive mode switch thresh */ 2688a1b9b6aSSam Leffler u_int wme_hipri_switch_hysteresis;/* agressive mode switch hysteresis */ 2698a1b9b6aSSam Leffler 2708a1b9b6aSSam Leffler struct wmeParams wme_params[4]; /* from assoc resp for each AC*/ 2718a1b9b6aSSam Leffler struct chanAccParams wme_wmeChanParams; /* WME params applied to self */ 2728a1b9b6aSSam Leffler struct chanAccParams wme_wmeBssChanParams;/* WME params bcast to stations */ 2738a1b9b6aSSam Leffler struct chanAccParams wme_chanParams; /* params applied to self */ 2748a1b9b6aSSam Leffler struct chanAccParams wme_bssChanParams; /* params bcast to stations */ 2758a1b9b6aSSam Leffler 2768a1b9b6aSSam Leffler int (*wme_update)(struct ieee80211com *); 2778a1b9b6aSSam Leffler }; 2788a1b9b6aSSam Leffler 279b032f27cSSam Leffler void ieee80211_wme_initparams(struct ieee80211vap *); 280b032f27cSSam Leffler void ieee80211_wme_updateparams(struct ieee80211vap *); 281b032f27cSSam Leffler void ieee80211_wme_updateparams_locked(struct ieee80211vap *); 2828a1b9b6aSSam Leffler 283b032f27cSSam Leffler /* 284b032f27cSSam Leffler * Return the WME TID from a QoS frame. If no TID 285b032f27cSSam Leffler * is present return the index for the "non-QoS" entry. 286b032f27cSSam Leffler */ 287b032f27cSSam Leffler static __inline uint8_t 288b032f27cSSam Leffler ieee80211_gettid(const struct ieee80211_frame *wh) 289b032f27cSSam Leffler { 290b032f27cSSam Leffler uint8_t tid; 291b032f27cSSam Leffler 292b032f27cSSam Leffler if (IEEE80211_QOS_HAS_SEQ(wh)) { 29332bdd57bSSam Leffler if (IEEE80211_IS_DSTODS(wh)) 29432bdd57bSSam Leffler tid = ((const struct ieee80211_qosframe_addr4 *)wh)-> 29532bdd57bSSam Leffler i_qos[0]; 29632bdd57bSSam Leffler else 29732bdd57bSSam Leffler tid = ((const struct ieee80211_qosframe *)wh)->i_qos[0]; 29832bdd57bSSam Leffler tid &= IEEE80211_QOS_TID; 299b032f27cSSam Leffler } else 300b032f27cSSam Leffler tid = IEEE80211_NONQOS_TID; 301b032f27cSSam Leffler return tid; 302b032f27cSSam Leffler } 303b032f27cSSam Leffler 304ae55932eSAndrew Thompson void ieee80211_waitfor_parent(struct ieee80211com *); 305b032f27cSSam Leffler void ieee80211_start_locked(struct ieee80211vap *); 306b032f27cSSam Leffler void ieee80211_init(void *); 307b032f27cSSam Leffler void ieee80211_start_all(struct ieee80211com *); 308b032f27cSSam Leffler void ieee80211_stop_locked(struct ieee80211vap *); 309b032f27cSSam Leffler void ieee80211_stop(struct ieee80211vap *); 310b032f27cSSam Leffler void ieee80211_stop_all(struct ieee80211com *); 3116076cbacSSam Leffler void ieee80211_suspend_all(struct ieee80211com *); 3126076cbacSSam Leffler void ieee80211_resume_all(struct ieee80211com *); 313b032f27cSSam Leffler void ieee80211_dturbo_switch(struct ieee80211vap *, int newflags); 314b032f27cSSam Leffler void ieee80211_swbmiss(void *arg); 315e701e041SSam Leffler void ieee80211_beacon_miss(struct ieee80211com *); 316b032f27cSSam Leffler int ieee80211_new_state(struct ieee80211vap *, enum ieee80211_state, int); 31768e8e04eSSam Leffler void ieee80211_print_essid(const uint8_t *, int); 31868e8e04eSSam Leffler void ieee80211_dump_pkt(struct ieee80211com *, 31968e8e04eSSam Leffler const uint8_t *, int, int, int); 320a11c9a5cSSam Leffler 32149aa47d6SSam Leffler extern const char *ieee80211_opmode_name[]; 322a11c9a5cSSam Leffler extern const char *ieee80211_state_name[IEEE80211_S_MAX]; 3238a1b9b6aSSam Leffler extern const char *ieee80211_wme_acnames[]; 3248a1b9b6aSSam Leffler 3258a1b9b6aSSam Leffler /* 3268a1b9b6aSSam Leffler * Beacon frames constructed by ieee80211_beacon_alloc 3278a1b9b6aSSam Leffler * have the following structure filled in so drivers 3288a1b9b6aSSam Leffler * can update the frame later w/ minimal overhead. 3298a1b9b6aSSam Leffler */ 3308a1b9b6aSSam Leffler struct ieee80211_beacon_offsets { 331b105a069SSam Leffler uint8_t bo_flags[4]; /* update/state flags */ 33268e8e04eSSam Leffler uint16_t *bo_caps; /* capabilities */ 333b105a069SSam Leffler uint8_t *bo_cfp; /* start of CFParms element */ 33468e8e04eSSam Leffler uint8_t *bo_tim; /* start of atim/dtim */ 33568e8e04eSSam Leffler uint8_t *bo_wme; /* start of WME parameters */ 33610ad9a77SSam Leffler uint8_t *bo_tdma; /* start of TDMA parameters */ 337b105a069SSam Leffler uint8_t *bo_tim_trailer;/* start of fixed-size trailer */ 33868e8e04eSSam Leffler uint16_t bo_tim_len; /* atim/dtim length in bytes */ 339b105a069SSam Leffler uint16_t bo_tim_trailer_len;/* tim trailer length in bytes */ 34068e8e04eSSam Leffler uint8_t *bo_erp; /* start of ERP element */ 34168e8e04eSSam Leffler uint8_t *bo_htinfo; /* start of HT info element */ 3424207227cSSam Leffler uint8_t *bo_ath; /* start of ATH parameters */ 343b105a069SSam Leffler uint8_t *bo_appie; /* start of AppIE element */ 344b105a069SSam Leffler uint16_t bo_appie_len; /* AppIE length in bytes */ 345d673ae81SAntoine Brodin uint16_t bo_csa_trailer_len; 346b105a069SSam Leffler uint8_t *bo_csa; /* start of CSA element */ 347d093681cSRui Paulo uint8_t *bo_meshconf; /* start of MESHCONF element */ 348d093681cSRui Paulo uint8_t *bo_spare[3]; 3498a1b9b6aSSam Leffler }; 350b105a069SSam Leffler struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *, 351b105a069SSam Leffler struct ieee80211_beacon_offsets *); 352b105a069SSam Leffler 353b105a069SSam Leffler /* 354b032f27cSSam Leffler * Beacon frame updates are signaled through calls to iv_update_beacon 355b105a069SSam Leffler * with one of the IEEE80211_BEACON_* tokens defined below. For devices 356b105a069SSam Leffler * that construct beacon frames on the host this can trigger a rebuild 357b105a069SSam Leffler * or defer the processing. For devices that offload beacon frame 358b105a069SSam Leffler * handling this callback can be used to signal a rebuild. The bo_flags 359b105a069SSam Leffler * array in the ieee80211_beacon_offsets structure is intended to record 360b105a069SSam Leffler * deferred processing requirements; ieee80211_beacon_update uses the 361b105a069SSam Leffler * state to optimize work. Since this structure is owned by the driver 362b032f27cSSam Leffler * and not visible to the 802.11 layer drivers must supply an iv_update_beacon 363b105a069SSam Leffler * callback that marks the flag bits and schedules (as necessary) an update. 364b105a069SSam Leffler */ 365b105a069SSam Leffler enum { 366b105a069SSam Leffler IEEE80211_BEACON_CAPS = 0, /* capabilities */ 367b105a069SSam Leffler IEEE80211_BEACON_TIM = 1, /* DTIM/ATIM */ 368b105a069SSam Leffler IEEE80211_BEACON_WME = 2, 369b105a069SSam Leffler IEEE80211_BEACON_ERP = 3, /* Extended Rate Phy */ 370b105a069SSam Leffler IEEE80211_BEACON_HTINFO = 4, /* HT Information */ 371b105a069SSam Leffler IEEE80211_BEACON_APPIE = 5, /* Application IE's */ 372b105a069SSam Leffler IEEE80211_BEACON_CFP = 6, /* CFParms */ 373b105a069SSam Leffler IEEE80211_BEACON_CSA = 7, /* Channel Switch Announcement */ 37410ad9a77SSam Leffler IEEE80211_BEACON_TDMA = 9, /* TDMA Info */ 3754207227cSSam Leffler IEEE80211_BEACON_ATH = 10, /* ATH parameters */ 376d093681cSRui Paulo IEEE80211_BEACON_MESHCONF = 11, /* Mesh Configuration */ 377b105a069SSam Leffler }; 378b105a069SSam Leffler int ieee80211_beacon_update(struct ieee80211_node *, 379b105a069SSam Leffler struct ieee80211_beacon_offsets *, struct mbuf *, int mcast); 3808a1b9b6aSSam Leffler 381b032f27cSSam Leffler void ieee80211_csa_startswitch(struct ieee80211com *, 382b032f27cSSam Leffler struct ieee80211_channel *, int mode, int count); 383b032f27cSSam Leffler void ieee80211_csa_completeswitch(struct ieee80211com *); 384c70761e6SSam Leffler void ieee80211_csa_cancelswitch(struct ieee80211com *); 385b032f27cSSam Leffler void ieee80211_cac_completeswitch(struct ieee80211vap *); 386b032f27cSSam Leffler 3878a1b9b6aSSam Leffler /* 3888a1b9b6aSSam Leffler * Notification methods called from the 802.11 state machine. 3898a1b9b6aSSam Leffler * Note that while these are defined here, their implementation 3908a1b9b6aSSam Leffler * is OS-specific. 3918a1b9b6aSSam Leffler */ 392b032f27cSSam Leffler void ieee80211_notify_node_join(struct ieee80211_node *, int newassoc); 393b032f27cSSam Leffler void ieee80211_notify_node_leave(struct ieee80211_node *); 394b032f27cSSam Leffler void ieee80211_notify_scan_done(struct ieee80211vap *); 395b032f27cSSam Leffler void ieee80211_notify_wds_discover(struct ieee80211_node *); 396b032f27cSSam Leffler void ieee80211_notify_csa(struct ieee80211com *, 397b032f27cSSam Leffler const struct ieee80211_channel *, int mode, int count); 398b032f27cSSam Leffler void ieee80211_notify_radar(struct ieee80211com *, 399b032f27cSSam Leffler const struct ieee80211_channel *); 400b032f27cSSam Leffler enum ieee80211_notify_cac_event { 401b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_START = 0, /* CAC timer started */ 402b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_STOP = 1, /* CAC intentionally stopped */ 403b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_RADAR = 2, /* CAC stopped due to radar detectio */ 404b032f27cSSam Leffler IEEE80211_NOTIFY_CAC_EXPIRE = 3, /* CAC expired w/o radar */ 405b032f27cSSam Leffler }; 406b032f27cSSam Leffler void ieee80211_notify_cac(struct ieee80211com *, 407b032f27cSSam Leffler const struct ieee80211_channel *, 408b032f27cSSam Leffler enum ieee80211_notify_cac_event); 409b032f27cSSam Leffler void ieee80211_notify_node_deauth(struct ieee80211_node *); 410b032f27cSSam Leffler void ieee80211_notify_node_auth(struct ieee80211_node *); 411b032f27cSSam Leffler void ieee80211_notify_country(struct ieee80211vap *, const uint8_t [], 412b032f27cSSam Leffler const uint8_t cc[2]); 413b032f27cSSam Leffler void ieee80211_notify_radio(struct ieee80211com *, int); 4141a1e1d21SSam Leffler #endif /* _NET80211_IEEE80211_PROTO_H_ */ 415