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