xref: /netbsd-src/sys/net80211/ieee80211_node.h (revision f8570f8a97f412a33574ec77d412b16dbe332965)
1*f8570f8aSmrg /*	$NetBSD: ieee80211_node.h,v 1.32 2023/08/01 07:04:16 mrg Exp $	*/
240e261aaSdyoung /*-
340e261aaSdyoung  * Copyright (c) 2001 Atsushi Onoe
490634029Sdyoung  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
540e261aaSdyoung  * All rights reserved.
640e261aaSdyoung  *
740e261aaSdyoung  * Redistribution and use in source and binary forms, with or without
840e261aaSdyoung  * modification, are permitted provided that the following conditions
940e261aaSdyoung  * are met:
1040e261aaSdyoung  * 1. Redistributions of source code must retain the above copyright
1140e261aaSdyoung  *    notice, this list of conditions and the following disclaimer.
1240e261aaSdyoung  * 2. Redistributions in binary form must reproduce the above copyright
1340e261aaSdyoung  *    notice, this list of conditions and the following disclaimer in the
1440e261aaSdyoung  *    documentation and/or other materials provided with the distribution.
1540e261aaSdyoung  * 3. The name of the author may not be used to endorse or promote products
1640e261aaSdyoung  *    derived from this software without specific prior written permission.
1740e261aaSdyoung  *
1840e261aaSdyoung  * Alternatively, this software may be distributed under the terms of the
1940e261aaSdyoung  * GNU General Public License ("GPL") version 2 as published by the Free
2040e261aaSdyoung  * Software Foundation.
2140e261aaSdyoung  *
2240e261aaSdyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2340e261aaSdyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2440e261aaSdyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2540e261aaSdyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2640e261aaSdyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2740e261aaSdyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2840e261aaSdyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2940e261aaSdyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3040e261aaSdyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3140e261aaSdyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3240e261aaSdyoung  *
3387515e34Sskrll  * $FreeBSD: src/sys/net80211/ieee80211_node.h,v 1.22 2005/08/10 16:22:29 sam Exp $
3440e261aaSdyoung  */
3540e261aaSdyoung #ifndef _NET80211_IEEE80211_NODE_H_
3640e261aaSdyoung #define _NET80211_IEEE80211_NODE_H_
3740e261aaSdyoung 
382ed4138bSdyoung #include <sys/atomic.h>
3990634029Sdyoung #include <net80211/ieee80211_netbsd.h>
4090634029Sdyoung #include <net80211/ieee80211_ioctl.h>		/* for ieee80211_nodestats */
4190634029Sdyoung 
4236ed1d69Sdyoung #ifdef _KERNEL
4390634029Sdyoung /*
4490634029Sdyoung  * Each ieee80211com instance has a single timer that fires once a
4590634029Sdyoung  * second.  This is used to initiate various work depending on the
4690634029Sdyoung  * state of the instance: scanning (passive or active), ``transition''
4790634029Sdyoung  * (waiting for a response to a management frame when operating
4890634029Sdyoung  * as a station), and node inactivity processing (when operating
4990634029Sdyoung  * as an AP).  For inactivity processing each node has a timeout
50f0a7346dSsnj  * set in its ni_inact field that is decremented on each timeout
5190634029Sdyoung  * and the node is reclaimed when the counter goes to zero.  We
5290634029Sdyoung  * use different inactivity timeout values depending on whether
5390634029Sdyoung  * the node is associated and authorized (either by 802.1x or
5490634029Sdyoung  * open/shared key authentication) or associated but yet to be
5590634029Sdyoung  * authorized.  The latter timeout is shorter to more aggressively
5690634029Sdyoung  * reclaim nodes that leave part way through the 802.1x exchange.
5790634029Sdyoung  */
5890634029Sdyoung #define	IEEE80211_INACT_WAIT	15		/* inactivity interval (secs) */
5990634029Sdyoung #define	IEEE80211_INACT_INIT	(30/IEEE80211_INACT_WAIT)	/* initial */
6090634029Sdyoung #define	IEEE80211_INACT_AUTH	(180/IEEE80211_INACT_WAIT)	/* associated but not authorized */
6190634029Sdyoung #define	IEEE80211_INACT_RUN	(300/IEEE80211_INACT_WAIT)	/* authorized */
6290634029Sdyoung #define	IEEE80211_INACT_PROBE	(30/IEEE80211_INACT_WAIT)	/* probe */
6390634029Sdyoung #define	IEEE80211_INACT_SCAN	(300/IEEE80211_INACT_WAIT)	/* scanned */
6490634029Sdyoung 
6590634029Sdyoung #define	IEEE80211_TRANS_WAIT 	5		/* mgt frame tx timer (secs) */
6640e261aaSdyoung 
6740e261aaSdyoung #define	IEEE80211_NODE_HASHSIZE	32
6840e261aaSdyoung /* simple hash is enough for variation of macaddr */
6940e261aaSdyoung #define	IEEE80211_NODE_HASH(addr)	\
7090634029Sdyoung 	(((const u_int8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % \
7190634029Sdyoung 		IEEE80211_NODE_HASHSIZE)
7240e261aaSdyoung 
7390634029Sdyoung struct ieee80211_rsnparms {
7490634029Sdyoung 	u_int8_t	rsn_mcastcipher;	/* mcast/group cipher */
7590634029Sdyoung 	u_int8_t	rsn_mcastkeylen;	/* mcast key length */
7690634029Sdyoung 	u_int8_t	rsn_ucastcipherset;	/* unicast cipher set */
7790634029Sdyoung 	u_int8_t	rsn_ucastcipher;	/* selected unicast cipher */
7890634029Sdyoung 	u_int8_t	rsn_ucastkeylen;	/* unicast key length */
797f459241Sandvar 	u_int8_t	rsn_keymgmtset;		/* key management algorithms */
8090634029Sdyoung 	u_int8_t	rsn_keymgmt;		/* selected key mgmt algo */
8190634029Sdyoung 	u_int16_t	rsn_caps;		/* capabilities */
8240e261aaSdyoung };
8340e261aaSdyoung 
8490634029Sdyoung struct ieee80211_node_table;
8590634029Sdyoung struct ieee80211com;
868abb07d1Sdyoung 
8740e261aaSdyoung /*
8840e261aaSdyoung  * Node specific information.  Note that drivers are expected
8940e261aaSdyoung  * to derive from this structure to add device-specific per-node
9040e261aaSdyoung  * state.  This is done by overriding the ic_node_* methods in
9140e261aaSdyoung  * the ieee80211com structure.
9240e261aaSdyoung  */
9340e261aaSdyoung struct ieee80211_node {
9490634029Sdyoung 	struct ieee80211com	*ni_ic;
9590634029Sdyoung 	struct ieee80211_node_table *ni_table;
9640e261aaSdyoung 	TAILQ_ENTRY(ieee80211_node)	ni_list;
9740e261aaSdyoung 	LIST_ENTRY(ieee80211_node)	ni_hash;
9840e261aaSdyoung 	u_int			ni_refcnt;
999280f4b4Sdyoung 	u_int			ni_scangen;	/* gen# for timeout scan */
10090634029Sdyoung 	u_int8_t		ni_authmode;	/* authentication algorithm */
10190634029Sdyoung 	u_int16_t		ni_flags;	/* special-purpose state */
10290634029Sdyoung #define	IEEE80211_NODE_AUTH	0x0001		/* authorized for data */
10390634029Sdyoung #define	IEEE80211_NODE_QOS	0x0002		/* QoS enabled */
10490634029Sdyoung #define	IEEE80211_NODE_ERP	0x0004		/* ERP enabled */
10590634029Sdyoung /* NB: this must have the same value as IEEE80211_FC1_PWR_MGT */
10690634029Sdyoung #define	IEEE80211_NODE_PWR_MGT	0x0010		/* power save mode enabled */
10761fb42b7Sdyoung #define	IEEE80211_NODE_AREF	0x0020		/* authentication ref held */
10890634029Sdyoung 	u_int16_t		ni_associd;	/* assoc response */
10990634029Sdyoung 	u_int16_t		ni_txpower;	/* current transmit power */
11090634029Sdyoung 	u_int16_t		ni_vlan;	/* vlan tag */
11190634029Sdyoung 	u_int32_t		*ni_challenge;	/* shared-key challenge */
11290634029Sdyoung 	u_int8_t		*ni_wpa_ie;	/* captured WPA/RSN ie */
11390634029Sdyoung 	u_int8_t		*ni_wme_ie;	/* captured WME ie */
11490634029Sdyoung 	u_int16_t		ni_txseqs[17];	/* tx seq per-tid */
11590634029Sdyoung 	u_int16_t		ni_rxseqs[17];	/* rx seq previous per-tid*/
11690634029Sdyoung 	u_int32_t		ni_rxfragstamp;	/* time stamp of last rx frag */
11790634029Sdyoung 	struct mbuf		*ni_rxfrag[3];	/* rx frag reassembly */
11890634029Sdyoung 	struct ieee80211_rsnparms ni_rsn;	/* RSN/WPA parameters */
11990634029Sdyoung 	struct ieee80211_key	ni_ucastkey;	/* unicast key */
12040e261aaSdyoung 
12140e261aaSdyoung 	/* hardware */
12240e261aaSdyoung 	u_int32_t		ni_rstamp;	/* recv timestamp */
123111ee86dSroy 	u_int8_t		ni_rssi;	/* recv ssi */
12440e261aaSdyoung 
12540e261aaSdyoung 	/* header */
12640e261aaSdyoung 	u_int8_t		ni_macaddr[IEEE80211_ADDR_LEN];
12740e261aaSdyoung 	u_int8_t		ni_bssid[IEEE80211_ADDR_LEN];
12840e261aaSdyoung 
12940e261aaSdyoung 	/* beacon, probe response */
1305dc63778Sdyoung 	union {
13190634029Sdyoung 		u_int8_t	data[8];
13290634029Sdyoung 		u_int64_t	tsf;
13390634029Sdyoung 	} ni_tstamp;				/* from last rcv'd beacon */
13440e261aaSdyoung 	u_int16_t		ni_intval;	/* beacon interval */
13540e261aaSdyoung 	u_int16_t		ni_capinfo;	/* capabilities */
13640e261aaSdyoung 	u_int8_t		ni_esslen;
13740e261aaSdyoung 	u_int8_t		ni_essid[IEEE80211_NWID_LEN];
13840e261aaSdyoung 	struct ieee80211_rateset ni_rates;	/* negotiated rate set */
13987515e34Sskrll 	struct ieee80211_channel *ni_chan;	/* XXX multiple uses */
14040e261aaSdyoung 	u_int16_t		ni_fhdwell;	/* FH only */
14140e261aaSdyoung 	u_int8_t		ni_fhindex;	/* FH only */
14290634029Sdyoung 	u_int8_t		ni_erp;		/* ERP from beacon/probe resp */
14390634029Sdyoung 	u_int16_t		ni_timoff;	/* byte offset to TIM ie */
14461fb42b7Sdyoung 	u_int8_t		ni_dtim_period;	/* DTIM period */
14561fb42b7Sdyoung 	u_int8_t		ni_dtim_count;	/* DTIM count for last bcn */
146730331d5Sdyoung 
14740e261aaSdyoung 	/* others */
14840e261aaSdyoung 	int			ni_fails;	/* failure count to associate */
14990634029Sdyoung 	short			ni_inact;	/* inactivity mark count */
15090634029Sdyoung 	short			ni_inact_reload;/* inactivity reload value */
15140e261aaSdyoung 	int			ni_txrate;	/* index to ni_rates[] */
15290634029Sdyoung 	struct	ifqueue		ni_savedq;	/* ps-poll queue */
15390634029Sdyoung 	struct ieee80211_nodestats ni_stats;	/* per-node statistics */
15440e261aaSdyoung };
15590634029Sdyoung MALLOC_DECLARE(M_80211_NODE);
15640e261aaSdyoung 
15790634029Sdyoung #define	IEEE80211_NODE_AID(ni)	IEEE80211_AID(ni->ni_associd)
158608fc215Sdyoung 
15990634029Sdyoung #define	IEEE80211_NODE_STAT(ni,stat)	(ni->ni_stats.ns_##stat++)
16090634029Sdyoung #define	IEEE80211_NODE_STAT_ADD(ni,stat,v)	(ni->ni_stats.ns_##stat += v)
16190634029Sdyoung #define	IEEE80211_NODE_STAT_SET(ni,stat,v)	(ni->ni_stats.ns_##stat = v)
162608fc215Sdyoung 
16340e261aaSdyoung struct ieee80211com;
16440e261aaSdyoung 
16590634029Sdyoung void	ieee80211_node_attach(struct ieee80211com *);
16690634029Sdyoung void	ieee80211_node_lateattach(struct ieee80211com *);
16790634029Sdyoung void	ieee80211_node_detach(struct ieee80211com *);
16890634029Sdyoung 
16990634029Sdyoung static __inline int
ieee80211_node_is_authorized(const struct ieee80211_node * ni)17090634029Sdyoung ieee80211_node_is_authorized(const struct ieee80211_node *ni)
17190634029Sdyoung {
17290634029Sdyoung 	return (ni->ni_flags & IEEE80211_NODE_AUTH);
17390634029Sdyoung }
17490634029Sdyoung 
17587515e34Sskrll void	ieee80211_node_authorize(struct ieee80211_node *);
17687515e34Sskrll void	ieee80211_node_unauthorize(struct ieee80211_node *);
17790634029Sdyoung 
17890634029Sdyoung void	ieee80211_begin_scan(struct ieee80211com *, int);
17990634029Sdyoung int	ieee80211_next_scan(struct ieee80211com *);
1803fb751b1Stacha void	ieee80211_probe_curchan(struct ieee80211com *, int);
18190634029Sdyoung void	ieee80211_create_ibss(struct ieee80211com*, struct ieee80211_channel *);
18290634029Sdyoung void	ieee80211_reset_bss(struct ieee80211com *);
18390634029Sdyoung void	ieee80211_cancel_scan(struct ieee80211com *);
18490634029Sdyoung void	ieee80211_end_scan(struct ieee80211com *);
18587515e34Sskrll int	ieee80211_ibss_merge(struct ieee80211_node *);
18690634029Sdyoung int	ieee80211_sta_join(struct ieee80211com *, struct ieee80211_node *);
18790634029Sdyoung void	ieee80211_sta_leave(struct ieee80211com *, struct ieee80211_node *);
18890634029Sdyoung 
18990634029Sdyoung /*
19090634029Sdyoung  * Table of ieee80211_node instances.  Each ieee80211com
19190634029Sdyoung  * has at least one for holding the scan candidates.
19290634029Sdyoung  * When operating as an access point or in ibss mode there
19390634029Sdyoung  * is a second table for associated stations or neighbors.
19490634029Sdyoung  */
19590634029Sdyoung struct ieee80211_node_table {
19690634029Sdyoung 	struct ieee80211com	*nt_ic;		/* back reference */
19790634029Sdyoung 	ieee80211_node_lock_t	nt_nodelock;	/* on node table */
19890634029Sdyoung 	TAILQ_HEAD(, ieee80211_node) nt_node;	/* information of all nodes */
19990634029Sdyoung 	LIST_HEAD(, ieee80211_node) nt_hash[IEEE80211_NODE_HASHSIZE];
20090634029Sdyoung 	const char		*nt_name;	/* for debugging */
20190634029Sdyoung 	ieee80211_scan_lock_t	nt_scanlock;	/* on nt_scangen */
20290634029Sdyoung 	u_int			nt_scangen;	/* gen# for timeout scan */
20390634029Sdyoung 	int			nt_inact_timer;	/* inactivity timer */
20490634029Sdyoung 	int			nt_inact_init;	/* initial node inact setting */
20587515e34Sskrll 	struct ieee80211_node	**nt_keyixmap;	/* key ix -> node map */
20687515e34Sskrll 	int			nt_keyixmax;	/* keyixmap size */
20790634029Sdyoung 
20890634029Sdyoung 	void			(*nt_timeout)(struct ieee80211_node_table *);
20990634029Sdyoung };
21090634029Sdyoung void	ieee80211_node_table_reset(struct ieee80211_node_table *);
21190634029Sdyoung 
21290634029Sdyoung struct ieee80211_node *ieee80211_alloc_node(
21390634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *);
21487515e34Sskrll struct ieee80211_node *ieee80211_tmp_node(struct ieee80211com *,
21587515e34Sskrll 		const u_int8_t *macaddr);
21690634029Sdyoung struct ieee80211_node *ieee80211_dup_bss(struct ieee80211_node_table *,
21790634029Sdyoung 		const u_int8_t *);
21890634029Sdyoung #ifdef IEEE80211_DEBUG_REFCNT
21990634029Sdyoung void	ieee80211_free_node_debug(struct ieee80211_node *,
22090634029Sdyoung 		const char *func, int line);
22190634029Sdyoung struct ieee80211_node *ieee80211_find_node_debug(
22290634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *,
22390634029Sdyoung 		const char *func, int line);
22490634029Sdyoung struct ieee80211_node * ieee80211_find_rxnode_debug(
22590634029Sdyoung 		struct ieee80211com *, const struct ieee80211_frame_min *,
22690634029Sdyoung 		const char *func, int line);
22787515e34Sskrll struct ieee80211_node * ieee80211_find_rxnode_withkey_debug(
22887515e34Sskrll 		struct ieee80211com *,
22987515e34Sskrll 		const struct ieee80211_frame_min *, u_int16_t keyix,
23087515e34Sskrll 		const char *func, int line);
23190634029Sdyoung struct ieee80211_node *ieee80211_find_txnode_debug(
23290634029Sdyoung 		struct ieee80211com *, const u_int8_t *,
23390634029Sdyoung 		const char *func, int line);
23490634029Sdyoung struct ieee80211_node *ieee80211_find_node_with_channel_debug(
23590634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *macaddr,
23690634029Sdyoung 		struct ieee80211_channel *, const char *func, int line);
23790634029Sdyoung struct ieee80211_node *ieee80211_find_node_with_ssid_debug(
23890634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *macaddr,
23990634029Sdyoung 		u_int ssidlen, const u_int8_t *ssid,
24090634029Sdyoung 		const char *func, int line);
24190634029Sdyoung #define	ieee80211_free_node(ni) \
24290634029Sdyoung 	ieee80211_free_node_debug(ni, __func__, __LINE__)
24390634029Sdyoung #define	ieee80211_find_node(nt, mac) \
24490634029Sdyoung 	ieee80211_find_node_debug(nt, mac, __func__, __LINE__)
24590634029Sdyoung #define	ieee80211_find_rxnode(nt, wh) \
24690634029Sdyoung 	ieee80211_find_rxnode_debug(nt, wh, __func__, __LINE__)
24787515e34Sskrll #define	ieee80211_find_rxnode_withkey(nt, wh, keyix) \
24887515e34Sskrll 	ieee80211_find_rxnode_withkey_debug(nt, wh, keyix, __func__, __LINE__)
24990634029Sdyoung #define	ieee80211_find_txnode(nt, mac) \
25090634029Sdyoung 	ieee80211_find_txnode_debug(nt, mac, __func__, __LINE__)
25190634029Sdyoung #define	ieee80211_find_node_with_channel(nt, mac, c) \
25290634029Sdyoung 	ieee80211_find_node_with_channel_debug(nt, mac, c, __func__, __LINE__)
25390634029Sdyoung #define	ieee80211_find_node_with_ssid(nt, mac, sl, ss) \
25490634029Sdyoung 	ieee80211_find_node_with_ssid_debug(nt, mac, sl, ss, __func__, __LINE__)
25590634029Sdyoung #else
25690634029Sdyoung void	ieee80211_free_node(struct ieee80211_node *);
25790634029Sdyoung struct ieee80211_node *ieee80211_find_node(
25890634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *);
25990634029Sdyoung struct ieee80211_node * ieee80211_find_rxnode(
26090634029Sdyoung 		struct ieee80211com *, const struct ieee80211_frame_min *);
26187515e34Sskrll struct ieee80211_node * ieee80211_find_rxnode_withkey(struct ieee80211com *,
26287515e34Sskrll 		const struct ieee80211_frame_min *, u_int16_t keyix);
26390634029Sdyoung struct ieee80211_node *ieee80211_find_txnode(
26490634029Sdyoung 		struct ieee80211com *, const u_int8_t *);
26590634029Sdyoung struct ieee80211_node *ieee80211_find_node_with_channel(
26690634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *macaddr,
26790634029Sdyoung 		struct ieee80211_channel *);
26890634029Sdyoung struct ieee80211_node *ieee80211_find_node_with_ssid(
26990634029Sdyoung 		struct ieee80211_node_table *, const u_int8_t *macaddr,
27090634029Sdyoung 		u_int ssidlen, const u_int8_t *ssid);
271255f57a8Sdyoung #endif
27287515e34Sskrll int	ieee80211_node_delucastkey(struct ieee80211_node *);
273255f57a8Sdyoung 
27490634029Sdyoung struct ieee80211_node *ieee80211_refine_node_for_beacon(
27590634029Sdyoung 		struct ieee80211com *, struct ieee80211_node *,
27690634029Sdyoung 		struct ieee80211_channel *, const u_int8_t *ssid);
27740e261aaSdyoung typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
27890634029Sdyoung void	ieee80211_iterate_nodes(struct ieee80211_node_table *,
27940e261aaSdyoung 		ieee80211_iter_func *, void *);
28040e261aaSdyoung 
28190634029Sdyoung void	ieee80211_dump_node(struct ieee80211_node_table *,
282730331d5Sdyoung 		struct ieee80211_node *);
28390634029Sdyoung void	ieee80211_dump_nodes(struct ieee80211_node_table *);
28435515831Smycroft 
28590634029Sdyoung struct ieee80211_node *ieee80211_fakeup_adhoc_node(
286*f8570f8aSmrg 		struct ieee80211_node_table *,
287*f8570f8aSmrg 		const u_int8_t macaddr[IEEE80211_ADDR_LEN]);
28890634029Sdyoung void	ieee80211_node_join(struct ieee80211com *, struct ieee80211_node *,int);
28990634029Sdyoung void	ieee80211_node_leave(struct ieee80211com *, struct ieee80211_node *);
290111ee86dSroy u_int8_t ieee80211_getrssi(struct ieee80211com *ic);
29187515e34Sskrll 
29287515e34Sskrll /*
29387515e34Sskrll  * Parameters supplied when adding/updating an entry in a
29487515e34Sskrll  * scan cache.  Pointer variables should be set to NULL
29587515e34Sskrll  * if no data is available.  Pointer references can be to
29687515e34Sskrll  * local data; any information that is saved will be copied.
29787515e34Sskrll  * All multi-byte values must be in host byte order.
29887515e34Sskrll  */
29987515e34Sskrll struct ieee80211_scanparams {
3001df75eefSmaxv 	u_int16_t	sp_capinfo;	/* 802.11 capabilities */
3011df75eefSmaxv 	u_int16_t	sp_fhdwell;	/* FHSS dwell interval */
3021df75eefSmaxv 	u_int8_t	sp_chan;		/* */
3031df75eefSmaxv 	u_int8_t	sp_bchan;
3041df75eefSmaxv 	u_int8_t	sp_fhindex;
3051df75eefSmaxv 	u_int8_t	sp_erp;
3061df75eefSmaxv 	u_int16_t	sp_bintval;
3076cbd9d03Smaxv 	u_int16_t	sp_timoff;
3081df75eefSmaxv 	u_int8_t	*sp_tim;
3091df75eefSmaxv 	u_int8_t	*sp_tstamp;
3101df75eefSmaxv 	u_int8_t	*sp_country;
3111df75eefSmaxv 	u_int8_t	*sp_ssid;
3121df75eefSmaxv 	u_int8_t	*sp_rates;
3131df75eefSmaxv 	u_int8_t	*sp_xrates;
3141df75eefSmaxv 	u_int8_t	*sp_wpa;
3151df75eefSmaxv 	u_int8_t	*sp_wme;
31687515e34Sskrll };
31787515e34Sskrll 
3182ed4138bSdyoung /*
3192ed4138bSdyoung  * Node reference counting definitions.
3202ed4138bSdyoung  *
3212ed4138bSdyoung  * ieee80211_node_initref	initialize the reference count to 1
3222ed4138bSdyoung  * ieee80211_node_incref	add a reference
3232ed4138bSdyoung  * ieee80211_node_decref	remove a reference
3242ed4138bSdyoung  * ieee80211_node_dectestref	remove a reference and return 1 if this
3252ed4138bSdyoung  *				is the last reference, otherwise 0
3262ed4138bSdyoung  * ieee80211_node_refcnt	reference count for printing (only)
3272ed4138bSdyoung  */
3282ed4138bSdyoung 
32987fd18f8Schristos static __inline void
ieee80211_node_initref(struct ieee80211_node * ni)3302ed4138bSdyoung ieee80211_node_initref(struct ieee80211_node *ni)
3312ed4138bSdyoung {
3322ed4138bSdyoung 	ni->ni_refcnt = 1;
3332ed4138bSdyoung }
3342ed4138bSdyoung 
33587fd18f8Schristos static __inline void
ieee80211_node_incref(struct ieee80211_node * ni)3362ed4138bSdyoung ieee80211_node_incref(struct ieee80211_node *ni)
3372ed4138bSdyoung {
3382ed4138bSdyoung 	atomic_inc_uint(&ni->ni_refcnt);
3392ed4138bSdyoung }
3402ed4138bSdyoung 
34187fd18f8Schristos static __inline void
ieee80211_node_decref(struct ieee80211_node * ni)3422ed4138bSdyoung ieee80211_node_decref(struct ieee80211_node *ni)
3432ed4138bSdyoung {
3442ed4138bSdyoung 	atomic_dec_uint(&ni->ni_refcnt);
3452ed4138bSdyoung }
3462ed4138bSdyoung 
3472ed4138bSdyoung int ieee80211_node_dectestref(struct ieee80211_node *ni);
3482ed4138bSdyoung 
34987fd18f8Schristos static __inline unsigned int
ieee80211_node_refcnt(const struct ieee80211_node * ni)3502ed4138bSdyoung ieee80211_node_refcnt(const struct ieee80211_node *ni)
3512ed4138bSdyoung {
3522ed4138bSdyoung 	return ni->ni_refcnt;
3532ed4138bSdyoung }
3542ed4138bSdyoung 
3552ed4138bSdyoung static __inline struct ieee80211_node *
ieee80211_ref_node(struct ieee80211_node * ni)3562ed4138bSdyoung ieee80211_ref_node(struct ieee80211_node *ni)
3572ed4138bSdyoung {
3582ed4138bSdyoung 	ieee80211_node_incref(ni);
3592ed4138bSdyoung 	return ni;
3602ed4138bSdyoung }
3612ed4138bSdyoung 
3622ed4138bSdyoung static __inline void
ieee80211_unref_node(struct ieee80211_node ** ni)3632ed4138bSdyoung ieee80211_unref_node(struct ieee80211_node **ni)
3642ed4138bSdyoung {
3652ed4138bSdyoung 	ieee80211_node_decref(*ni);
3662ed4138bSdyoung 	*ni = NULL;			/* guard against use */
3672ed4138bSdyoung }
3682ed4138bSdyoung 
36987515e34Sskrll void	ieee80211_add_scan(struct ieee80211com *,
37087515e34Sskrll 		const struct ieee80211_scanparams *,
37187515e34Sskrll 		const struct ieee80211_frame *,
37287515e34Sskrll 		int subtype, int rssi, int rstamp);
373461cd4dbSdyoung void ieee80211_init_neighbor(struct ieee80211com *, struct ieee80211_node *,
374461cd4dbSdyoung 		const struct ieee80211_frame *,
375461cd4dbSdyoung 		const struct ieee80211_scanparams *, int);
37687515e34Sskrll struct ieee80211_node *ieee80211_add_neighbor(struct ieee80211com *,
37787515e34Sskrll 		const struct ieee80211_frame *,
37887515e34Sskrll 		const struct ieee80211_scanparams *);
37936ed1d69Sdyoung #endif /* _KERNEL */
380976bf6cfSelad #endif /* !_NET80211_IEEE80211_NODE_H_ */
381