Home | History | Annotate | Line # | Download | only in net80211
ieee80211_node.h revision 1.30.2.1
      1       1.1   dyoung /*-
      2  1.30.2.1     phil  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
      3  1.30.2.1     phil  *
      4       1.1   dyoung  * Copyright (c) 2001 Atsushi Onoe
      5  1.30.2.1     phil  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
      6       1.1   dyoung  * All rights reserved.
      7       1.1   dyoung  *
      8       1.1   dyoung  * Redistribution and use in source and binary forms, with or without
      9       1.1   dyoung  * modification, are permitted provided that the following conditions
     10       1.1   dyoung  * are met:
     11       1.1   dyoung  * 1. Redistributions of source code must retain the above copyright
     12       1.1   dyoung  *    notice, this list of conditions and the following disclaimer.
     13       1.1   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1   dyoung  *    notice, this list of conditions and the following disclaimer in the
     15       1.1   dyoung  *    documentation and/or other materials provided with the distribution.
     16       1.1   dyoung  *
     17       1.1   dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18       1.1   dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19       1.1   dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20       1.1   dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21       1.1   dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22       1.1   dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23       1.1   dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24       1.1   dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25       1.1   dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26       1.1   dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27       1.1   dyoung  *
     28  1.30.2.1     phil  * $FreeBSD$
     29       1.1   dyoung  */
     30       1.1   dyoung #ifndef _NET80211_IEEE80211_NODE_H_
     31       1.1   dyoung #define _NET80211_IEEE80211_NODE_H_
     32       1.1   dyoung 
     33      1.16   dyoung #include <net80211/ieee80211_ioctl.h>		/* for ieee80211_nodestats */
     34  1.30.2.1     phil #include <net80211/ieee80211_ht.h>		/* for aggregation state */
     35      1.16   dyoung 
     36      1.16   dyoung /*
     37  1.30.2.1     phil  * Each ieee80211com instance has a single timer that fires every
     38  1.30.2.1     phil  * IEEE80211_INACT_WAIT seconds to handle "inactivity processing".
     39  1.30.2.1     phil  * This is used to do node inactivity processing when operating
     40  1.30.2.1     phil  * as an AP, adhoc or mesh mode.  For inactivity processing each node
     41  1.30.2.1     phil  * has a timeout set in its ni_inact field that is decremented
     42  1.30.2.1     phil  * on each timeout and the node is reclaimed when the counter goes
     43  1.30.2.1     phil  * to zero.  We use different inactivity timeout values depending
     44  1.30.2.1     phil  * on whether the node is associated and authorized (either by
     45  1.30.2.1     phil  * 802.1x or open/shared key authentication) or associated but yet
     46  1.30.2.1     phil  * to be authorized.  The latter timeout is shorter to more aggressively
     47      1.16   dyoung  * reclaim nodes that leave part way through the 802.1x exchange.
     48      1.16   dyoung  */
     49      1.16   dyoung #define	IEEE80211_INACT_WAIT	15		/* inactivity interval (secs) */
     50      1.16   dyoung #define	IEEE80211_INACT_INIT	(30/IEEE80211_INACT_WAIT)	/* initial */
     51      1.16   dyoung #define	IEEE80211_INACT_AUTH	(180/IEEE80211_INACT_WAIT)	/* associated but not authorized */
     52      1.16   dyoung #define	IEEE80211_INACT_RUN	(300/IEEE80211_INACT_WAIT)	/* authorized */
     53      1.16   dyoung #define	IEEE80211_INACT_PROBE	(30/IEEE80211_INACT_WAIT)	/* probe */
     54      1.16   dyoung #define	IEEE80211_INACT_SCAN	(300/IEEE80211_INACT_WAIT)	/* scanned */
     55      1.16   dyoung 
     56  1.30.2.1     phil #define	IEEE80211_TRANS_WAIT 	2		/* mgt frame tx timer (secs) */
     57  1.30.2.1     phil 
     58  1.30.2.1     phil /* threshold for aging overlapping non-ERP bss */
     59  1.30.2.1     phil #define	IEEE80211_NONERP_PRESENT_AGE	msecs_to_ticks(60*1000)
     60       1.1   dyoung 
     61  1.30.2.1     phil #define	IEEE80211_NODE_HASHSIZE	32		/* NB: hash size must be pow2 */
     62       1.1   dyoung /* simple hash is enough for variation of macaddr */
     63  1.30.2.1     phil #define	IEEE80211_NODE_HASH(ic, addr)	\
     64  1.30.2.1     phil 	(((const uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % \
     65      1.16   dyoung 		IEEE80211_NODE_HASHSIZE)
     66       1.1   dyoung 
     67      1.16   dyoung struct ieee80211_node_table;
     68      1.16   dyoung struct ieee80211com;
     69  1.30.2.1     phil struct ieee80211vap;
     70  1.30.2.1     phil struct ieee80211_scanparams;
     71  1.30.2.1     phil 
     72  1.30.2.1     phil /*
     73  1.30.2.1     phil  * Information element ``blob''.  We use this structure
     74  1.30.2.1     phil  * to capture management frame payloads that need to be
     75  1.30.2.1     phil  * retained.  Information elements within the payload that
     76  1.30.2.1     phil  * we need to consult have references recorded.
     77  1.30.2.1     phil  */
     78  1.30.2.1     phil struct ieee80211_ies {
     79  1.30.2.1     phil 	/* the following are either NULL or point within data */
     80  1.30.2.1     phil 	uint8_t	*wpa_ie;	/* captured WPA ie */
     81  1.30.2.1     phil 	uint8_t	*rsn_ie;	/* captured RSN ie */
     82  1.30.2.1     phil 	uint8_t	*wme_ie;	/* captured WME ie */
     83  1.30.2.1     phil 	uint8_t	*ath_ie;	/* captured Atheros ie */
     84  1.30.2.1     phil 	uint8_t	*htcap_ie;	/* captured HTCAP ie */
     85  1.30.2.1     phil 	uint8_t	*htinfo_ie;	/* captured HTINFO ie */
     86  1.30.2.1     phil 	uint8_t	*tdma_ie;	/* captured TDMA ie */
     87  1.30.2.1     phil 	uint8_t *meshid_ie;	/* captured MESH ID ie */
     88  1.30.2.1     phil 	uint8_t	*vhtcap_ie;	/* captured VHTCAP ie */
     89  1.30.2.1     phil 	uint8_t	*vhtopmode_ie;	/* captured VHTOPMODE ie */
     90  1.30.2.1     phil 	uint8_t	*vhtpwrenv_ie;	/* captured VHTPWRENV ie */
     91  1.30.2.1     phil 	uint8_t	*apchanrep_ie;	/* captured APCHANREP ie */
     92  1.30.2.1     phil 	uint8_t	*bssload_ie;	/* captured BSSLOAD ie */
     93  1.30.2.1     phil 	uint8_t	*spare[4];
     94  1.30.2.1     phil 	/* NB: these must be the last members of this structure */
     95  1.30.2.1     phil 	uint8_t	*data;		/* frame data > 802.11 header */
     96  1.30.2.1     phil 	int	len;		/* data size in bytes */
     97  1.30.2.1     phil };
     98  1.30.2.1     phil 
     99  1.30.2.1     phil /*
    100  1.30.2.1     phil  * 802.11s (Mesh) Peer Link FSM state.
    101  1.30.2.1     phil  */
    102  1.30.2.1     phil enum ieee80211_mesh_mlstate {
    103  1.30.2.1     phil 	IEEE80211_NODE_MESH_IDLE	= 0,
    104  1.30.2.1     phil 	IEEE80211_NODE_MESH_OPENSNT	= 1,	/* open frame sent */
    105  1.30.2.1     phil 	IEEE80211_NODE_MESH_OPENRCV	= 2,	/* open frame received */
    106  1.30.2.1     phil 	IEEE80211_NODE_MESH_CONFIRMRCV	= 3,	/* confirm frame received */
    107  1.30.2.1     phil 	IEEE80211_NODE_MESH_ESTABLISHED	= 4,	/* link established */
    108  1.30.2.1     phil 	IEEE80211_NODE_MESH_HOLDING	= 5,	/* link closing */
    109  1.30.2.1     phil };
    110  1.30.2.1     phil #define	IEEE80211_MESH_MLSTATE_BITS \
    111  1.30.2.1     phil 	"\20\1IDLE\2OPENSNT\2OPENRCV\3CONFIRMRCV\4ESTABLISHED\5HOLDING"
    112      1.14   dyoung 
    113       1.1   dyoung /*
    114       1.1   dyoung  * Node specific information.  Note that drivers are expected
    115       1.1   dyoung  * to derive from this structure to add device-specific per-node
    116       1.1   dyoung  * state.  This is done by overriding the ic_node_* methods in
    117       1.1   dyoung  * the ieee80211com structure.
    118       1.1   dyoung  */
    119       1.1   dyoung struct ieee80211_node {
    120  1.30.2.1     phil 	struct ieee80211vap	*ni_vap;	/* associated vap */
    121  1.30.2.1     phil 	struct ieee80211com	*ni_ic;		/* copy from vap to save deref*/
    122  1.30.2.1     phil 	struct ieee80211_node_table *ni_table;	/* NB: may be NULL */
    123  1.30.2.1     phil 	TAILQ_ENTRY(ieee80211_node) ni_list;	/* list of all nodes */
    124  1.30.2.1     phil 	LIST_ENTRY(ieee80211_node) ni_hash;	/* hash collision list */
    125  1.30.2.1     phil 	u_int			ni_refcnt;	/* count of held references */
    126  1.30.2.1     phil 	u_int			ni_flags;
    127  1.30.2.1     phil #define	IEEE80211_NODE_AUTH	0x000001	/* authorized for data */
    128  1.30.2.1     phil #define	IEEE80211_NODE_QOS	0x000002	/* QoS enabled */
    129  1.30.2.1     phil #define	IEEE80211_NODE_ERP	0x000004	/* ERP enabled */
    130      1.16   dyoung /* NB: this must have the same value as IEEE80211_FC1_PWR_MGT */
    131  1.30.2.1     phil #define	IEEE80211_NODE_PWR_MGT	0x000010	/* power save mode enabled */
    132  1.30.2.1     phil #define	IEEE80211_NODE_AREF	0x000020	/* authentication ref held */
    133  1.30.2.1     phil #define	IEEE80211_NODE_HT	0x000040	/* HT enabled */
    134  1.30.2.1     phil #define	IEEE80211_NODE_HTCOMPAT	0x000080	/* HT setup w/ vendor OUI's */
    135  1.30.2.1     phil #define	IEEE80211_NODE_WPS	0x000100	/* WPS association */
    136  1.30.2.1     phil #define	IEEE80211_NODE_TSN	0x000200	/* TSN association */
    137  1.30.2.1     phil #define	IEEE80211_NODE_AMPDU_RX	0x000400	/* AMPDU rx enabled */
    138  1.30.2.1     phil #define	IEEE80211_NODE_AMPDU_TX	0x000800	/* AMPDU tx enabled */
    139  1.30.2.1     phil #define	IEEE80211_NODE_MIMO_PS	0x001000	/* MIMO power save enabled */
    140  1.30.2.1     phil #define	IEEE80211_NODE_MIMO_RTS	0x002000	/* send RTS in MIMO PS */
    141  1.30.2.1     phil #define	IEEE80211_NODE_RIFS	0x004000	/* RIFS enabled */
    142  1.30.2.1     phil #define	IEEE80211_NODE_SGI20	0x008000	/* Short GI in HT20 enabled */
    143  1.30.2.1     phil #define	IEEE80211_NODE_SGI40	0x010000	/* Short GI in HT40 enabled */
    144  1.30.2.1     phil #define	IEEE80211_NODE_ASSOCID	0x020000	/* xmit requires associd */
    145  1.30.2.1     phil #define	IEEE80211_NODE_AMSDU_RX	0x040000	/* AMSDU rx enabled */
    146  1.30.2.1     phil #define	IEEE80211_NODE_AMSDU_TX	0x080000	/* AMSDU tx enabled */
    147  1.30.2.1     phil #define	IEEE80211_NODE_VHT	0x100000	/* VHT enabled */
    148  1.30.2.1     phil #define	IEEE80211_NODE_LDPC	0x200000	/* LDPC enabled */
    149  1.30.2.1     phil 	uint16_t		ni_associd;	/* association ID */
    150  1.30.2.1     phil 	uint16_t		ni_vlan;	/* vlan tag */
    151  1.30.2.1     phil 	uint16_t		ni_txpower;	/* current transmit power */
    152  1.30.2.1     phil 	uint8_t			ni_authmode;	/* authentication algorithm */
    153  1.30.2.1     phil 	uint8_t			ni_ath_flags;	/* Atheros feature flags */
    154  1.30.2.1     phil 	/* NB: These must have the same values as IEEE80211_ATHC_* */
    155  1.30.2.1     phil #define IEEE80211_NODE_TURBOP	0x0001		/* Turbo prime enable */
    156  1.30.2.1     phil #define IEEE80211_NODE_COMP	0x0002		/* Compresssion enable */
    157  1.30.2.1     phil #define IEEE80211_NODE_FF	0x0004          /* Fast Frame capable */
    158  1.30.2.1     phil #define IEEE80211_NODE_XR	0x0008		/* Atheros WME enable */
    159  1.30.2.1     phil #define IEEE80211_NODE_AR	0x0010		/* AR capable */
    160  1.30.2.1     phil #define IEEE80211_NODE_BOOST	0x0080		/* Dynamic Turbo boosted */
    161  1.30.2.1     phil 	uint16_t		ni_ath_defkeyix;/* Atheros def key index */
    162  1.30.2.1     phil 	const struct ieee80211_txparam *ni_txparms;
    163  1.30.2.1     phil 	uint32_t		ni_jointime;	/* time of join (secs) */
    164  1.30.2.1     phil 	uint32_t		*ni_challenge;	/* shared-key challenge */
    165  1.30.2.1     phil 	struct ieee80211_ies	ni_ies;		/* captured ie's */
    166  1.30.2.1     phil 						/* tx seq per-tid */
    167  1.30.2.1     phil 	ieee80211_seq		ni_txseqs[IEEE80211_TID_SIZE];
    168  1.30.2.1     phil 						/* rx seq previous per-tid*/
    169  1.30.2.1     phil 	ieee80211_seq		ni_rxseqs[IEEE80211_TID_SIZE];
    170  1.30.2.1     phil 	uint32_t		ni_rxfragstamp;	/* time stamp of last rx frag */
    171      1.16   dyoung 	struct mbuf		*ni_rxfrag[3];	/* rx frag reassembly */
    172      1.16   dyoung 	struct ieee80211_key	ni_ucastkey;	/* unicast key */
    173       1.1   dyoung 
    174       1.1   dyoung 	/* hardware */
    175  1.30.2.1     phil 	uint32_t		ni_avgrssi;	/* recv ssi state */
    176  1.30.2.1     phil 	int8_t			ni_noise;	/* noise floor */
    177  1.30.2.1     phil 
    178  1.30.2.1     phil 	/* mimo statistics */
    179  1.30.2.1     phil 	uint32_t		ni_mimo_rssi_ctl[IEEE80211_MAX_CHAINS];
    180  1.30.2.1     phil 	uint32_t		ni_mimo_rssi_ext[IEEE80211_MAX_CHAINS];
    181  1.30.2.1     phil 	uint8_t			ni_mimo_noise_ctl[IEEE80211_MAX_CHAINS];
    182  1.30.2.1     phil 	uint8_t			ni_mimo_noise_ext[IEEE80211_MAX_CHAINS];
    183  1.30.2.1     phil 	uint8_t			ni_mimo_chains;
    184       1.1   dyoung 
    185       1.1   dyoung 	/* header */
    186  1.30.2.1     phil 	uint8_t			ni_macaddr[IEEE80211_ADDR_LEN];
    187  1.30.2.1     phil 	uint8_t			ni_bssid[IEEE80211_ADDR_LEN];
    188       1.1   dyoung 
    189       1.1   dyoung 	/* beacon, probe response */
    190      1.15   dyoung 	union {
    191  1.30.2.1     phil 		uint8_t		data[8];
    192      1.16   dyoung 		u_int64_t	tsf;
    193      1.16   dyoung 	} ni_tstamp;				/* from last rcv'd beacon */
    194  1.30.2.1     phil 	uint16_t		ni_intval;	/* beacon interval */
    195  1.30.2.1     phil 	uint16_t		ni_capinfo;	/* capabilities */
    196  1.30.2.1     phil 	uint8_t			ni_esslen;
    197  1.30.2.1     phil 	uint8_t			ni_essid[IEEE80211_NWID_LEN];
    198       1.1   dyoung 	struct ieee80211_rateset ni_rates;	/* negotiated rate set */
    199  1.30.2.1     phil 	struct ieee80211_channel *ni_chan;
    200  1.30.2.1     phil 	uint16_t		ni_fhdwell;	/* FH only */
    201  1.30.2.1     phil 	uint8_t			ni_fhindex;	/* FH only */
    202  1.30.2.1     phil 	uint16_t		ni_erp;		/* ERP from beacon/probe resp */
    203  1.30.2.1     phil 	uint16_t		ni_timoff;	/* byte offset to TIM ie */
    204  1.30.2.1     phil 	uint8_t			ni_dtim_period;	/* DTIM period */
    205  1.30.2.1     phil 	uint8_t			ni_dtim_count;	/* DTIM count for last bcn */
    206  1.30.2.1     phil 
    207  1.30.2.1     phil 	/* 11s state */
    208  1.30.2.1     phil 	uint8_t			ni_meshidlen;
    209  1.30.2.1     phil 	uint8_t			ni_meshid[IEEE80211_MESHID_LEN];
    210  1.30.2.1     phil 	enum ieee80211_mesh_mlstate ni_mlstate;	/* peering management state */
    211  1.30.2.1     phil 	uint16_t		ni_mllid;	/* link local ID */
    212  1.30.2.1     phil 	uint16_t		ni_mlpid;	/* link peer ID */
    213  1.30.2.1     phil 	struct callout		ni_mltimer;	/* link mesh timer */
    214  1.30.2.1     phil 	uint8_t			ni_mlrcnt;	/* link mesh retry counter */
    215  1.30.2.1     phil 	uint8_t			ni_mltval;	/* link mesh timer value */
    216  1.30.2.1     phil 	struct callout		ni_mlhtimer;	/* link mesh backoff timer */
    217  1.30.2.1     phil 	uint8_t			ni_mlhcnt;	/* link mesh holding counter */
    218  1.30.2.1     phil 
    219  1.30.2.1     phil 	/* 11n state */
    220  1.30.2.1     phil 	uint16_t		ni_htcap;	/* HT capabilities */
    221  1.30.2.1     phil 	uint8_t			ni_htparam;	/* HT params */
    222  1.30.2.1     phil 	uint8_t			ni_htctlchan;	/* HT control channel */
    223  1.30.2.1     phil 	uint8_t			ni_ht2ndchan;	/* HT 2nd channel */
    224  1.30.2.1     phil 	uint8_t			ni_htopmode;	/* HT operating mode */
    225  1.30.2.1     phil 	uint8_t			ni_htstbc;	/* HT */
    226  1.30.2.1     phil 	uint8_t			ni_chw;		/* negotiated channel width */
    227  1.30.2.1     phil 	struct ieee80211_htrateset ni_htrates;	/* negotiated ht rate set */
    228  1.30.2.1     phil 	struct ieee80211_tx_ampdu ni_tx_ampdu[WME_NUM_TID];
    229  1.30.2.1     phil 	struct ieee80211_rx_ampdu ni_rx_ampdu[WME_NUM_TID];
    230  1.30.2.1     phil 
    231  1.30.2.1     phil 	/* VHT state */
    232  1.30.2.1     phil 	uint32_t		ni_vhtcap;
    233  1.30.2.1     phil 	uint16_t		ni_vht_basicmcs;
    234  1.30.2.1     phil 	uint16_t		ni_vht_pad2;
    235  1.30.2.1     phil 	struct ieee80211_vht_mcs_info	ni_vht_mcsinfo;
    236  1.30.2.1     phil 	uint8_t			ni_vht_chan1;	/* 20/40/80/160 - VHT chan1 */
    237  1.30.2.1     phil 	uint8_t			ni_vht_chan2;	/* 80+80 - VHT chan2 */
    238  1.30.2.1     phil 	uint8_t			ni_vht_chanwidth;	/* IEEE80211_VHT_CHANWIDTH_ */
    239  1.30.2.1     phil 	uint8_t			ni_vht_pad1;
    240  1.30.2.1     phil 	uint32_t		ni_vht_spare[8];
    241  1.30.2.1     phil 
    242  1.30.2.1     phil 	/* fast-frames state */
    243  1.30.2.1     phil 	struct mbuf *		ni_tx_superg[WME_NUM_TID];
    244       1.5   dyoung 
    245       1.1   dyoung 	/* others */
    246      1.16   dyoung 	short			ni_inact;	/* inactivity mark count */
    247      1.16   dyoung 	short			ni_inact_reload;/* inactivity reload value */
    248  1.30.2.1     phil 	int			ni_txrate;	/* legacy rate/MCS */
    249  1.30.2.1     phil 	struct ieee80211_psq	ni_psq;		/* power save queue */
    250      1.16   dyoung 	struct ieee80211_nodestats ni_stats;	/* per-node statistics */
    251  1.30.2.1     phil 
    252  1.30.2.1     phil 	struct ieee80211vap	*ni_wdsvap;	/* associated WDS vap */
    253  1.30.2.1     phil 	void			*ni_rctls;	/* private ratectl state */
    254  1.30.2.1     phil 
    255  1.30.2.1     phil 	/* quiet time IE state for the given node */
    256  1.30.2.1     phil 	uint32_t		ni_quiet_ie_set;	/* Quiet time IE was seen */
    257  1.30.2.1     phil 	struct			ieee80211_quiet_ie ni_quiet_ie;	/* last seen quiet IE */
    258  1.30.2.1     phil 
    259  1.30.2.1     phil 	uint64_t		ni_spare[3];
    260       1.1   dyoung };
    261      1.16   dyoung MALLOC_DECLARE(M_80211_NODE);
    262  1.30.2.1     phil MALLOC_DECLARE(M_80211_NODE_IE);
    263  1.30.2.1     phil 
    264  1.30.2.1     phil #define	IEEE80211_NODE_ATH	(IEEE80211_NODE_FF | IEEE80211_NODE_TURBOP)
    265  1.30.2.1     phil #define	IEEE80211_NODE_AMPDU \
    266  1.30.2.1     phil 	(IEEE80211_NODE_AMPDU_RX | IEEE80211_NODE_AMPDU_TX)
    267  1.30.2.1     phil #define	IEEE80211_NODE_AMSDU \
    268  1.30.2.1     phil 	(IEEE80211_NODE_AMSDU_RX | IEEE80211_NODE_AMSDU_TX)
    269  1.30.2.1     phil #define	IEEE80211_NODE_HT_ALL \
    270  1.30.2.1     phil 	(IEEE80211_NODE_HT | IEEE80211_NODE_HTCOMPAT | \
    271  1.30.2.1     phil 	 IEEE80211_NODE_AMPDU | IEEE80211_NODE_AMSDU | \
    272  1.30.2.1     phil 	 IEEE80211_NODE_MIMO_PS | IEEE80211_NODE_MIMO_RTS | \
    273  1.30.2.1     phil 	 IEEE80211_NODE_RIFS | IEEE80211_NODE_SGI20 | IEEE80211_NODE_SGI40)
    274  1.30.2.1     phil 
    275  1.30.2.1     phil #define	IEEE80211_NODE_BITS \
    276  1.30.2.1     phil 	"\20\1AUTH\2QOS\3ERP\5PWR_MGT\6AREF\7HT\10HTCOMPAT\11WPS\12TSN" \
    277  1.30.2.1     phil 	"\13AMPDU_RX\14AMPDU_TX\15MIMO_PS\16MIMO_RTS\17RIFS\20SGI20\21SGI40" \
    278  1.30.2.1     phil 	"\22ASSOCID"
    279       1.1   dyoung 
    280      1.16   dyoung #define	IEEE80211_NODE_AID(ni)	IEEE80211_AID(ni->ni_associd)
    281       1.4   dyoung 
    282      1.16   dyoung #define	IEEE80211_NODE_STAT(ni,stat)	(ni->ni_stats.ns_##stat++)
    283      1.16   dyoung #define	IEEE80211_NODE_STAT_ADD(ni,stat,v)	(ni->ni_stats.ns_##stat += v)
    284      1.16   dyoung #define	IEEE80211_NODE_STAT_SET(ni,stat,v)	(ni->ni_stats.ns_##stat = v)
    285       1.4   dyoung 
    286  1.30.2.1     phil /*
    287  1.30.2.1     phil  * Filtered rssi calculation support.  The receive rssi is maintained
    288  1.30.2.1     phil  * as an average over the last 10 frames received using a low pass filter
    289  1.30.2.1     phil  * (all frames for now, possibly need to be more selective).  Calculations
    290  1.30.2.1     phil  * are designed such that a good compiler can optimize them.  The avg
    291  1.30.2.1     phil  * rssi state should be initialized to IEEE80211_RSSI_DUMMY_MARKER and
    292  1.30.2.1     phil  * each sample incorporated with IEEE80211_RSSI_LPF.  Use IEEE80211_RSSI_GET
    293  1.30.2.1     phil  * to extract the current value.
    294  1.30.2.1     phil  *
    295  1.30.2.1     phil  * Note that we assume rssi data are in the range [-127..127] and we
    296  1.30.2.1     phil  * discard values <-20.  This is consistent with assumptions throughout
    297  1.30.2.1     phil  * net80211 that signal strength data are in .5 dBm units relative to
    298  1.30.2.1     phil  * the current noise floor (linear, not log).
    299  1.30.2.1     phil  */
    300  1.30.2.1     phil #define IEEE80211_RSSI_LPF_LEN		10
    301  1.30.2.1     phil #define	IEEE80211_RSSI_DUMMY_MARKER	127
    302  1.30.2.1     phil /* NB: pow2 to optimize out * and / */
    303  1.30.2.1     phil #define	IEEE80211_RSSI_EP_MULTIPLIER	(1<<7)
    304  1.30.2.1     phil #define IEEE80211_RSSI_IN(x)		((x) * IEEE80211_RSSI_EP_MULTIPLIER)
    305  1.30.2.1     phil #define _IEEE80211_RSSI_LPF(x, y, len) \
    306  1.30.2.1     phil     (((x) != IEEE80211_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y))
    307  1.30.2.1     phil #define IEEE80211_RSSI_LPF(x, y) do {					\
    308  1.30.2.1     phil     if ((y) >= -20) {							\
    309  1.30.2.1     phil     	x = _IEEE80211_RSSI_LPF((x), IEEE80211_RSSI_IN((y)), 		\
    310  1.30.2.1     phil 		IEEE80211_RSSI_LPF_LEN);				\
    311  1.30.2.1     phil     }									\
    312  1.30.2.1     phil } while (0)
    313  1.30.2.1     phil #define	IEEE80211_RSSI_EP_RND(x, mul) \
    314  1.30.2.1     phil 	((((x) % (mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
    315  1.30.2.1     phil #define	IEEE80211_RSSI_GET(x) \
    316  1.30.2.1     phil 	IEEE80211_RSSI_EP_RND(x, IEEE80211_RSSI_EP_MULTIPLIER)
    317  1.30.2.1     phil 
    318  1.30.2.1     phil static __inline struct ieee80211_node *
    319  1.30.2.1     phil ieee80211_ref_node(struct ieee80211_node *ni)
    320  1.30.2.1     phil {
    321  1.30.2.1     phil 	ieee80211_node_incref(ni);
    322  1.30.2.1     phil 	return ni;
    323  1.30.2.1     phil }
    324  1.30.2.1     phil 
    325  1.30.2.1     phil static __inline void
    326  1.30.2.1     phil ieee80211_unref_node(struct ieee80211_node **ni)
    327  1.30.2.1     phil {
    328  1.30.2.1     phil 	ieee80211_node_decref(*ni);
    329  1.30.2.1     phil 	*ni = NULL;			/* guard against use */
    330  1.30.2.1     phil }
    331       1.1   dyoung 
    332      1.16   dyoung void	ieee80211_node_attach(struct ieee80211com *);
    333      1.16   dyoung void	ieee80211_node_lateattach(struct ieee80211com *);
    334      1.16   dyoung void	ieee80211_node_detach(struct ieee80211com *);
    335  1.30.2.1     phil void	ieee80211_node_vattach(struct ieee80211vap *);
    336  1.30.2.1     phil void	ieee80211_node_latevattach(struct ieee80211vap *);
    337  1.30.2.1     phil void	ieee80211_node_vdetach(struct ieee80211vap *);
    338      1.16   dyoung 
    339      1.16   dyoung static __inline int
    340      1.16   dyoung ieee80211_node_is_authorized(const struct ieee80211_node *ni)
    341      1.16   dyoung {
    342      1.16   dyoung 	return (ni->ni_flags & IEEE80211_NODE_AUTH);
    343      1.16   dyoung }
    344      1.16   dyoung 
    345      1.19    skrll void	ieee80211_node_authorize(struct ieee80211_node *);
    346      1.19    skrll void	ieee80211_node_unauthorize(struct ieee80211_node *);
    347      1.16   dyoung 
    348  1.30.2.1     phil void	ieee80211_node_setuptxparms(struct ieee80211_node *);
    349  1.30.2.1     phil void	ieee80211_node_set_chan(struct ieee80211_node *,
    350  1.30.2.1     phil 		struct ieee80211_channel *);
    351  1.30.2.1     phil void	ieee80211_create_ibss(struct ieee80211vap*, struct ieee80211_channel *);
    352  1.30.2.1     phil void	ieee80211_reset_bss(struct ieee80211vap *);
    353  1.30.2.1     phil void	ieee80211_sync_curchan(struct ieee80211com *);
    354  1.30.2.1     phil void	ieee80211_setupcurchan(struct ieee80211com *,
    355  1.30.2.1     phil 	    struct ieee80211_channel *);
    356  1.30.2.1     phil void	ieee80211_setcurchan(struct ieee80211com *, struct ieee80211_channel *);
    357  1.30.2.1     phil void	ieee80211_update_chw(struct ieee80211com *);
    358  1.30.2.1     phil int	ieee80211_ibss_merge_check(struct ieee80211_node *);
    359  1.30.2.1     phil int	ieee80211_ibss_node_check_new(struct ieee80211_node *ni,
    360  1.30.2.1     phil 	    const struct ieee80211_scanparams *);
    361      1.19    skrll int	ieee80211_ibss_merge(struct ieee80211_node *);
    362  1.30.2.1     phil struct ieee80211_scan_entry;
    363  1.30.2.1     phil int	ieee80211_sta_join(struct ieee80211vap *, struct ieee80211_channel *,
    364  1.30.2.1     phil 		const struct ieee80211_scan_entry *);
    365  1.30.2.1     phil void	ieee80211_sta_leave(struct ieee80211_node *);
    366  1.30.2.1     phil void	ieee80211_node_deauth(struct ieee80211_node *, int);
    367  1.30.2.1     phil 
    368  1.30.2.1     phil int	ieee80211_ies_init(struct ieee80211_ies *, const uint8_t *, int);
    369  1.30.2.1     phil void	ieee80211_ies_cleanup(struct ieee80211_ies *);
    370  1.30.2.1     phil void	ieee80211_ies_expand(struct ieee80211_ies *);
    371  1.30.2.1     phil #define	ieee80211_ies_setie(_ies, _ie, _off) do {		\
    372  1.30.2.1     phil 	(_ies)._ie = (_ies).data + (_off);			\
    373  1.30.2.1     phil } while (0)
    374      1.16   dyoung 
    375      1.16   dyoung /*
    376      1.16   dyoung  * Table of ieee80211_node instances.  Each ieee80211com
    377  1.30.2.1     phil  * has one that holds association stations (when operating
    378  1.30.2.1     phil  * as an ap) or neighbors (in ibss mode).
    379  1.30.2.1     phil  *
    380  1.30.2.1     phil  * XXX embed this in ieee80211com instead of indirect?
    381      1.16   dyoung  */
    382      1.16   dyoung struct ieee80211_node_table {
    383      1.16   dyoung 	struct ieee80211com	*nt_ic;		/* back reference */
    384      1.16   dyoung 	ieee80211_node_lock_t	nt_nodelock;	/* on node table */
    385      1.16   dyoung 	TAILQ_HEAD(, ieee80211_node) nt_node;	/* information of all nodes */
    386      1.16   dyoung 	LIST_HEAD(, ieee80211_node) nt_hash[IEEE80211_NODE_HASHSIZE];
    387  1.30.2.1     phil 	int			nt_count;	/* number of nodes */
    388      1.19    skrll 	struct ieee80211_node	**nt_keyixmap;	/* key ix -> node map */
    389      1.19    skrll 	int			nt_keyixmax;	/* keyixmap size */
    390  1.30.2.1     phil 	const char		*nt_name;	/* table name for debug msgs */
    391  1.30.2.1     phil 	int			nt_inact_init;	/* initial node inact setting */
    392      1.16   dyoung };
    393       1.9   dyoung 
    394  1.30.2.1     phil struct ieee80211_node *ieee80211_alloc_node(struct ieee80211_node_table *,
    395  1.30.2.1     phil 		struct ieee80211vap *,
    396  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    397  1.30.2.1     phil struct ieee80211_node *ieee80211_tmp_node(struct ieee80211vap *,
    398  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    399  1.30.2.1     phil struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *,
    400  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    401  1.30.2.1     phil struct ieee80211_node *ieee80211_node_create_wds(struct ieee80211vap *,
    402  1.30.2.1     phil 		const uint8_t bssid[IEEE80211_ADDR_LEN],
    403  1.30.2.1     phil 		struct ieee80211_channel *);
    404      1.16   dyoung #ifdef IEEE80211_DEBUG_REFCNT
    405      1.16   dyoung void	ieee80211_free_node_debug(struct ieee80211_node *,
    406      1.16   dyoung 		const char *func, int line);
    407  1.30.2.1     phil struct ieee80211_node *ieee80211_find_node_locked_debug(
    408  1.30.2.1     phil 		struct ieee80211_node_table *,
    409  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN],
    410  1.30.2.1     phil 		const char *func, int line);
    411  1.30.2.1     phil struct ieee80211_node *ieee80211_find_node_debug(struct ieee80211_node_table *,
    412  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN],
    413  1.30.2.1     phil 		const char *func, int line);
    414  1.30.2.1     phil struct ieee80211_node *ieee80211_find_vap_node_locked_debug(
    415  1.30.2.1     phil 		struct ieee80211_node_table *,
    416  1.30.2.1     phil 		const struct ieee80211vap *vap,
    417  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN],
    418      1.16   dyoung 		const char *func, int line);
    419  1.30.2.1     phil struct ieee80211_node *ieee80211_find_vap_node_debug(
    420  1.30.2.1     phil 		struct ieee80211_node_table *,
    421  1.30.2.1     phil 		const struct ieee80211vap *vap,
    422  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN],
    423  1.30.2.1     phil 		const char *func, int line);
    424  1.30.2.1     phil struct ieee80211_node * ieee80211_find_rxnode_debug(struct ieee80211com *,
    425  1.30.2.1     phil 		const struct ieee80211_frame_min *,
    426      1.16   dyoung 		const char *func, int line);
    427      1.19    skrll struct ieee80211_node * ieee80211_find_rxnode_withkey_debug(
    428      1.19    skrll 		struct ieee80211com *,
    429  1.30.2.1     phil 		const struct ieee80211_frame_min *, uint16_t keyix,
    430      1.16   dyoung 		const char *func, int line);
    431  1.30.2.1     phil struct ieee80211_node *ieee80211_find_txnode_debug(struct ieee80211vap *,
    432  1.30.2.1     phil 		const uint8_t *,
    433      1.16   dyoung 		const char *func, int line);
    434      1.16   dyoung #define	ieee80211_free_node(ni) \
    435      1.16   dyoung 	ieee80211_free_node_debug(ni, __func__, __LINE__)
    436  1.30.2.1     phil #define	ieee80211_find_node_locked(nt, mac) \
    437  1.30.2.1     phil 	ieee80211_find_node_locked_debug(nt, mac, __func__, __LINE__)
    438      1.16   dyoung #define	ieee80211_find_node(nt, mac) \
    439      1.16   dyoung 	ieee80211_find_node_debug(nt, mac, __func__, __LINE__)
    440  1.30.2.1     phil #define	ieee80211_find_vap_node_locked(nt, vap, mac) \
    441  1.30.2.1     phil 	ieee80211_find_vap_node_locked_debug(nt, vap, mac, __func__, __LINE__)
    442  1.30.2.1     phil #define	ieee80211_find_vap_node(nt, vap, mac) \
    443  1.30.2.1     phil 	ieee80211_find_vap_node_debug(nt, vap, mac, __func__, __LINE__)
    444  1.30.2.1     phil #define	ieee80211_find_rxnode(ic, wh) \
    445  1.30.2.1     phil 	ieee80211_find_rxnode_debug(ic, wh, __func__, __LINE__)
    446  1.30.2.1     phil #define	ieee80211_find_rxnode_withkey(ic, wh, keyix) \
    447  1.30.2.1     phil 	ieee80211_find_rxnode_withkey_debug(ic, wh, keyix, __func__, __LINE__)
    448  1.30.2.1     phil #define	ieee80211_find_txnode(vap, mac) \
    449  1.30.2.1     phil 	ieee80211_find_txnode_debug(vap, mac, __func__, __LINE__)
    450      1.16   dyoung #else
    451      1.16   dyoung void	ieee80211_free_node(struct ieee80211_node *);
    452  1.30.2.1     phil struct ieee80211_node *ieee80211_find_node_locked(struct ieee80211_node_table *,
    453  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    454  1.30.2.1     phil struct ieee80211_node *ieee80211_find_node(struct ieee80211_node_table *,
    455  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    456  1.30.2.1     phil struct ieee80211_node *ieee80211_find_vap_node_locked(
    457  1.30.2.1     phil 		struct ieee80211_node_table *, const struct ieee80211vap *,
    458  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    459  1.30.2.1     phil struct ieee80211_node *ieee80211_find_vap_node(
    460  1.30.2.1     phil 		struct ieee80211_node_table *, const struct ieee80211vap *,
    461  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    462  1.30.2.1     phil struct ieee80211_node * ieee80211_find_rxnode(struct ieee80211com *,
    463  1.30.2.1     phil 		const struct ieee80211_frame_min *);
    464      1.19    skrll struct ieee80211_node * ieee80211_find_rxnode_withkey(struct ieee80211com *,
    465  1.30.2.1     phil 		const struct ieee80211_frame_min *, uint16_t keyix);
    466  1.30.2.1     phil struct ieee80211_node *ieee80211_find_txnode(struct ieee80211vap *,
    467  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    468      1.16   dyoung #endif
    469      1.19    skrll int	ieee80211_node_delucastkey(struct ieee80211_node *);
    470  1.30.2.1     phil void	ieee80211_node_timeout(void *arg);
    471      1.11  mycroft 
    472       1.1   dyoung typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
    473  1.30.2.1     phil int	ieee80211_iterate_nodes_vap(struct ieee80211_node_table *,
    474  1.30.2.1     phil 		struct ieee80211vap *, ieee80211_iter_func *, void *);
    475      1.16   dyoung void	ieee80211_iterate_nodes(struct ieee80211_node_table *,
    476       1.1   dyoung 		ieee80211_iter_func *, void *);
    477       1.1   dyoung 
    478  1.30.2.1     phil void	ieee80211_notify_erp(struct ieee80211com *);
    479      1.16   dyoung void	ieee80211_dump_node(struct ieee80211_node_table *,
    480       1.5   dyoung 		struct ieee80211_node *);
    481      1.16   dyoung void	ieee80211_dump_nodes(struct ieee80211_node_table *);
    482      1.11  mycroft 
    483  1.30.2.1     phil struct ieee80211_node *ieee80211_fakeup_adhoc_node(struct ieee80211vap *,
    484  1.30.2.1     phil 		const uint8_t macaddr[IEEE80211_ADDR_LEN]);
    485  1.30.2.1     phil struct ieee80211_scanparams;
    486  1.30.2.1     phil void	ieee80211_init_neighbor(struct ieee80211_node *,
    487      1.19    skrll 		const struct ieee80211_frame *,
    488  1.30.2.1     phil 		const struct ieee80211_scanparams *);
    489  1.30.2.1     phil struct ieee80211_node *ieee80211_add_neighbor(struct ieee80211vap *,
    490      1.19    skrll 		const struct ieee80211_frame *,
    491      1.19    skrll 		const struct ieee80211_scanparams *);
    492  1.30.2.1     phil void	ieee80211_node_join(struct ieee80211_node *,int);
    493  1.30.2.1     phil void	ieee80211_node_leave(struct ieee80211_node *);
    494  1.30.2.1     phil int8_t	ieee80211_getrssi(struct ieee80211vap *);
    495  1.30.2.1     phil void	ieee80211_getsignal(struct ieee80211vap *, int8_t *, int8_t *);
    496  1.30.2.1     phil #endif /* _NET80211_IEEE80211_NODE_H_ */
    497