xref: /openbsd-src/sys/net80211/ieee80211_node.h (revision 4e1ee0786f11cc571bd0be17d38e46f635c719fc)
1 /*	$OpenBSD: ieee80211_node.h,v 1.89 2021/10/11 09:01:06 stsp Exp $	*/
2 /*	$NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $	*/
3 
4 /*-
5  * Copyright (c) 2001 Atsushi Onoe
6  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * $FreeBSD: src/sys/net80211/ieee80211_node.h,v 1.10 2004/04/05 22:10:26 sam Exp $
32  */
33 #ifndef _NET80211_IEEE80211_NODE_H_
34 #define _NET80211_IEEE80211_NODE_H_
35 
36 #include <sys/tree.h>
37 
38 #define	IEEE80211_PSCAN_WAIT	5		/* passive scan wait */
39 #define	IEEE80211_TRANS_WAIT	5		/* transition wait */
40 #define	IEEE80211_INACT_WAIT	5		/* inactivity timer interval */
41 #define	IEEE80211_INACT_MAX	(300/IEEE80211_INACT_WAIT)
42 #define	IEEE80211_CACHE_SIZE	512
43 #define	IEEE80211_CACHE_WAIT	30
44 #define	IEEE80211_INACT_SCAN	10		/* for station mode */
45 
46 struct ieee80211_rateset {
47 	u_int8_t		rs_nrates;
48 	u_int8_t		rs_rates[IEEE80211_RATE_MAXSIZE];
49 };
50 
51 extern const struct ieee80211_rateset ieee80211_std_rateset_11a;
52 extern const struct ieee80211_rateset ieee80211_std_rateset_11b;
53 extern const struct ieee80211_rateset ieee80211_std_rateset_11g;
54 
55 /* Index into ieee80211_std_rateset_11n[] array. */
56 #define IEEE80211_HT_RATESET_SISO	0
57 #define IEEE80211_HT_RATESET_SISO_SGI	1
58 #define IEEE80211_HT_RATESET_MIMO2	2
59 #define IEEE80211_HT_RATESET_MIMO2_SGI	3
60 #define IEEE80211_HT_RATESET_MIMO3	4
61 #define IEEE80211_HT_RATESET_MIMO3_SGI	5
62 #define IEEE80211_HT_RATESET_MIMO4	6
63 #define IEEE80211_HT_RATESET_MIMO4_SGI	7
64 #define IEEE80211_HT_RATESET_SISO_40	8
65 #define IEEE80211_HT_RATESET_SISO_SGI40 9
66 #define IEEE80211_HT_RATESET_MIMO2_40	10
67 #define IEEE80211_HT_RATESET_MIMO2_SGI40 11
68 #define IEEE80211_HT_RATESET_MIMO3_40	12
69 #define IEEE80211_HT_RATESET_MIMO3_SGI40 13
70 #define IEEE80211_HT_RATESET_MIMO4_40	14
71 #define IEEE80211_HT_RATESET_MIMO4_SGI40 15
72 #define IEEE80211_HT_NUM_RATESETS	16
73 
74 /* Maximum number of rates in a HT rateset. */
75 #define IEEE80211_HT_RATESET_MAX_NRATES	8
76 
77 /* Number of MCS indices represented by struct ieee80211_ht_rateset. */
78 #define IEEE80211_HT_RATESET_NUM_MCS 32
79 
80 struct ieee80211_ht_rateset {
81 	uint32_t nrates;
82 	uint32_t rates[IEEE80211_HT_RATESET_MAX_NRATES]; /* 500 kbit/s units */
83 
84 	/*
85 	 * This bitmask can only express MCS 0 - MCS 31.
86 	 * IEEE 802.11 defined 77 HT MCS in total but common hardware
87 	 * implementations tend to support MCS index 0 through 31 only.
88 	 */
89 	uint32_t mcs_mask;
90 
91 	/* Range of MCS indices represented in this rateset. */
92 	int min_mcs;
93 	int max_mcs;
94 
95 	int chan40;
96 	int sgi;
97 };
98 
99 extern const struct ieee80211_ht_rateset ieee80211_std_ratesets_11n[];
100 
101 /* Index into ieee80211_std_rateset_11ac[] array. */
102 #define IEEE80211_VHT_RATESET_SISO		0
103 #define IEEE80211_VHT_RATESET_SISO_SGI		1
104 #define IEEE80211_VHT_RATESET_MIMO2		2
105 #define IEEE80211_VHT_RATESET_MIMO2_SGI		3
106 #define IEEE80211_VHT_RATESET_SISO_40		4
107 #define IEEE80211_VHT_RATESET_SISO_40_SGI	5
108 #define IEEE80211_VHT_RATESET_MIMO2_40		6
109 #define IEEE80211_VHT_RATESET_MIMO2_40_SGI	7
110 #define IEEE80211_VHT_RATESET_SISO_80		8
111 #define IEEE80211_VHT_RATESET_SISO_80_SGI	9
112 #define IEEE80211_VHT_RATESET_MIMO2_80		10
113 #define IEEE80211_VHT_RATESET_MIMO2_80_SGI	11
114 #define IEEE80211_VHT_NUM_RATESETS		12
115 
116 /* Maximum number of rates in a HT rateset. */
117 #define IEEE80211_VHT_RATESET_MAX_NRATES	10
118 
119 struct ieee80211_vht_rateset {
120 	uint32_t nrates;
121 	uint32_t rates[IEEE80211_VHT_RATESET_MAX_NRATES]; /* 500 kbit/s units */
122 
123 	/* Number of spatial streams used by rates in this rateset. */
124 	int num_ss;
125 
126 	int sgi;
127 };
128 
129 extern const struct ieee80211_vht_rateset ieee80211_std_ratesets_11ac[];
130 
131 enum ieee80211_node_state {
132 	IEEE80211_STA_CACHE,	/* cached node */
133 	IEEE80211_STA_BSS,	/* ic->ic_bss, the network we joined */
134 	IEEE80211_STA_AUTH,	/* successfully authenticated */
135 	IEEE80211_STA_ASSOC,	/* successfully associated */
136 	IEEE80211_STA_COLLECT	/* This node remains in the cache while
137 				 * the driver sends a de-auth message;
138 				 * afterward it should be freed to make room
139 				 * for a new node.
140 				 */
141 };
142 
143 #define	ieee80211_node_newstate(__ni, __state)	\
144 	do {					\
145 		(__ni)->ni_state = (__state);	\
146 	} while (0)
147 
148 enum ieee80211_node_psstate {
149 	IEEE80211_PS_AWAKE,
150 	IEEE80211_PS_DOZE
151 };
152 
153 #define	IEEE80211_PS_MAX_QUEUE	50	/* maximum saved packets */
154 
155 /* Authenticator state machine: 4-Way Handshake (see 8.5.6.1.1) */
156 enum {
157 	RSNA_INITIALIZE,
158 	RSNA_AUTHENTICATION,
159 	RSNA_AUTHENTICATION_2,
160 	RSNA_INITPMK,
161 	RSNA_INITPSK,
162 	RSNA_PTKSTART,
163 	RSNA_PTKCALCNEGOTIATING,
164 	RSNA_PTKCALCNEGOTIATING_2,
165 	RSNA_PTKINITNEGOTIATING,
166 	RSNA_PTKINITDONE,
167 	RSNA_DISCONNECT,
168 	RSNA_DISCONNECTED
169 };
170 
171 /* Authenticator state machine: Group Key Handshake (see 8.5.6.1.2) */
172 enum {
173 	RSNA_IDLE,
174 	RSNA_REKEYNEGOTIATING,
175 	RSNA_REKEYESTABLISHED,
176 	RSNA_KEYERROR
177 };
178 
179 /* Supplicant state machine: 4-Way Handshake (not documented in standard) */
180 enum {
181 	RSNA_SUPP_INITIALIZE,		/* not expecting any messages */
182 	RSNA_SUPP_PTKSTART,		/* awaiting handshake message 1 */
183 	RSNA_SUPP_PTKNEGOTIATING,	/* got message 1 and derived PTK */
184 	RSNA_SUPP_PTKDONE		/* got message 3 and authenticated AP */
185 };
186 
187 struct ieee80211_rxinfo {
188 	u_int32_t		rxi_flags;
189 	u_int32_t		rxi_tstamp;
190 	int			rxi_rssi;
191 };
192 #define IEEE80211_RXI_HWDEC		0x00000001
193 #define IEEE80211_RXI_AMPDU_DONE	0x00000002
194 #define IEEE80211_RXI_HWDEC_SAME_PN	0x00000004
195 #define IEEE80211_RXI_SAME_SEQ		0x00000008
196 
197 /* Block Acknowledgement Record */
198 struct ieee80211_tx_ba {
199 	struct ieee80211_node	*ba_ni;	/* backpointer for callbacks */
200 	struct timeout		ba_to;
201 	int			ba_timeout_val;
202 	int			ba_state;
203 #define IEEE80211_BA_INIT	0
204 #define IEEE80211_BA_REQUESTED	1
205 #define IEEE80211_BA_AGREED	2
206 
207 	/* ADDBA parameter set field for this BA agreement. */
208 	u_int16_t		ba_params;
209 
210 	/* These values are IEEE802.11 frame sequence numbers (0x0-0xfff) */
211 	u_int16_t		ba_winstart;
212 	u_int16_t		ba_winend;
213 
214 	/* Number of A-MPDU subframes in reorder buffer. */
215 	u_int16_t		ba_winsize;
216 #define IEEE80211_BA_MAX_WINSZ	64	/* corresponds to maximum ADDBA BUFSZ */
217 
218 	u_int8_t		ba_token;
219 
220 	/* Bitmap for ACK'd frames in the current BA window. */
221 	uint64_t		ba_bitmap;
222 };
223 
224 struct ieee80211_rx_ba {
225 	struct ieee80211_node	*ba_ni;	/* backpointer for callbacks */
226 	struct {
227 		struct mbuf		*m;
228 		struct ieee80211_rxinfo	rxi;
229 	}			*ba_buf;
230 	struct timeout		ba_to;
231 	int			ba_timeout_val;
232 	int			ba_state;
233 	u_int16_t		ba_params;
234 	u_int16_t		ba_winstart;
235 	u_int16_t		ba_winend;
236 	u_int16_t		ba_winsize;
237 	u_int16_t		ba_head;
238 	struct timeout		ba_gap_to;
239 #define IEEE80211_BA_GAP_TIMEOUT	300 /* msec */
240 
241 	/*
242 	 * Counter for frames forced to wait in the reordering buffer
243 	 * due to a leading gap caused by one or more missing frames.
244 	 */
245 	int			ba_gapwait;
246 
247 	/* Counter for consecutive frames which missed the BA window. */
248 	int			ba_winmiss;
249 	/* Sequence number of previous frame which missed the BA window. */
250 	uint16_t		ba_missedsn;
251 	/* Window moves forward after this many frames have missed it. */
252 #define IEEE80211_BA_MAX_WINMISS	8
253 
254 	uint8_t			ba_token;
255 };
256 
257 /*
258  * Node specific information.  Note that drivers are expected
259  * to derive from this structure to add device-specific per-node
260  * state.  This is done by overriding the ic_node_* methods in
261  * the ieee80211com structure.
262  */
263 struct ieee80211_node {
264 	RBT_ENTRY(ieee80211_node)	ni_node;
265 
266 	struct ieee80211com	*ni_ic;		/* back-pointer */
267 
268 	u_int			ni_refcnt;
269 	u_int			ni_scangen;	/* gen# for timeout scan */
270 
271 	/* hardware */
272 	u_int32_t		ni_rstamp;	/* recv timestamp */
273 	u_int8_t		ni_rssi;	/* recv ssi */
274 
275 	/* header */
276 	u_int8_t		ni_macaddr[IEEE80211_ADDR_LEN];
277 	u_int8_t		ni_bssid[IEEE80211_ADDR_LEN];
278 
279 	/* beacon, probe response */
280 	u_int8_t		ni_tstamp[8];	/* from last rcv'd beacon */
281 	u_int16_t		ni_intval;	/* beacon interval */
282 	u_int16_t		ni_capinfo;	/* capabilities */
283 	u_int8_t		ni_esslen;
284 	u_int8_t		ni_essid[IEEE80211_NWID_LEN];
285 	struct ieee80211_rateset ni_rates;	/* negotiated rate set */
286 	u_int8_t		*ni_country;	/* country information XXX */
287 	struct ieee80211_channel *ni_chan;
288 	u_int8_t		ni_erp;		/* 11g only */
289 
290 	/* DTIM and contention free period (CFP) */
291 	u_int8_t		ni_dtimcount;
292 	u_int8_t		ni_dtimperiod;
293 #ifdef notyet
294 	u_int8_t		ni_cfpperiod;	/* # of DTIMs between CFPs */
295 	u_int16_t		ni_cfpduremain;	/* remaining cfp duration */
296 	u_int16_t		ni_cfpmaxduration;/* max CFP duration in TU */
297 	u_int16_t		ni_nextdtim;	/* time to next DTIM */
298 	u_int16_t		ni_timoffset;
299 #endif
300 
301 	/* power saving mode */
302 	u_int8_t		ni_pwrsave;
303 	struct mbuf_queue	ni_savedq;	/* packets queued for pspoll */
304 
305 	/* RSN */
306 	struct timeout		ni_eapol_to;
307 	u_int			ni_rsn_state;
308 	u_int			ni_rsn_supp_state;
309 	u_int			ni_rsn_gstate;
310 	u_int			ni_rsn_retries;
311 	u_int			ni_supported_rsnprotos;
312 	u_int			ni_rsnprotos;
313 	u_int			ni_supported_rsnakms;
314 	u_int			ni_rsnakms;
315 	u_int			ni_rsnciphers;
316 	enum ieee80211_cipher	ni_rsngroupcipher;
317 	enum ieee80211_cipher	ni_rsngroupmgmtcipher;
318 	u_int16_t		ni_rsncaps;
319 	enum ieee80211_cipher	ni_rsncipher;
320 	u_int8_t		ni_nonce[EAPOL_KEY_NONCE_LEN];
321 	u_int8_t		ni_pmk[IEEE80211_PMK_LEN];
322 	u_int8_t		ni_pmkid[IEEE80211_PMKID_LEN];
323 	u_int64_t		ni_replaycnt;
324 	u_int8_t		ni_replaycnt_ok;
325 	u_int64_t		ni_reqreplaycnt;
326 	u_int8_t		ni_reqreplaycnt_ok;
327 	u_int8_t		*ni_rsnie;
328 	struct ieee80211_key	ni_pairwise_key;
329 	struct ieee80211_ptk	ni_ptk;
330 	u_int8_t		ni_key_count;
331 	int			ni_port_valid;
332 
333 	/* SA Query */
334 	u_int16_t		ni_sa_query_trid;
335 	struct timeout		ni_sa_query_to;
336 	int			ni_sa_query_count;
337 
338 	/* HT capabilities */
339 	uint16_t		ni_htcaps;
340 	uint8_t			ni_ampdu_param;
341 	uint8_t			ni_rxmcs[howmany(80,NBBY)];
342 	uint16_t		ni_max_rxrate;	/* in Mb/s, 0 <= rate <= 1023 */
343 	uint8_t			ni_tx_mcs_set;
344 	uint16_t		ni_htxcaps;
345 	uint32_t		ni_txbfcaps;
346 	uint8_t			ni_aselcaps;
347 
348 	/* HT operation */
349 	uint8_t			ni_primary_chan; /* XXX corresponds to ni_chan */
350 	uint8_t			ni_htop0;
351 	uint16_t		ni_htop1;
352 	uint16_t		ni_htop2;
353 	uint8_t			ni_basic_mcs[howmany(128,NBBY)];
354 
355 	/* Timeout handlers which trigger Tx Block Ack negotiation. */
356 	struct timeout		ni_addba_req_to[IEEE80211_NUM_TID];
357 	int			ni_addba_req_intval[IEEE80211_NUM_TID];
358 #define IEEE80211_ADDBA_REQ_INTVAL_MAX 30	/* in seconds */
359 
360 	/* Block Ack records */
361 	struct ieee80211_tx_ba	ni_tx_ba[IEEE80211_NUM_TID];
362 	struct ieee80211_rx_ba	ni_rx_ba[IEEE80211_NUM_TID];
363 
364 	int			ni_txmcs;	/* current MCS used for TX */
365 	int			ni_vht_ss;	/* VHT # spatial streams */
366 
367 	/* others */
368 	u_int16_t		ni_associd;	/* assoc response */
369 	u_int16_t		ni_txseq;	/* seq to be transmitted */
370 	u_int16_t		ni_rxseq;	/* seq previous received */
371 	u_int16_t		ni_qos_txseqs[IEEE80211_NUM_TID];
372 	u_int16_t		ni_qos_rxseqs[IEEE80211_NUM_TID];
373 	int			ni_fails;	/* failure count to associate */
374 	uint32_t		ni_assoc_fail;	/* assoc failure reasons */
375 #define IEEE80211_NODE_ASSOCFAIL_CHAN		0x01
376 #define IEEE80211_NODE_ASSOCFAIL_IBSS		0x02
377 #define IEEE80211_NODE_ASSOCFAIL_PRIVACY	0x04
378 #define IEEE80211_NODE_ASSOCFAIL_BASIC_RATE	0x08
379 #define IEEE80211_NODE_ASSOCFAIL_ESSID		0x10
380 #define IEEE80211_NODE_ASSOCFAIL_BSSID		0x20
381 #define IEEE80211_NODE_ASSOCFAIL_WPA_PROTO	0x40
382 #define IEEE80211_NODE_ASSOCFAIL_WPA_KEY	0x80
383 
384 	int			ni_inact;	/* inactivity mark count */
385 	int			ni_txrate;	/* index to ni_rates[] */
386 	int			ni_state;
387 
388 	u_int32_t		ni_flags;	/* special-purpose state */
389 #define IEEE80211_NODE_ERP		0x0001
390 #define IEEE80211_NODE_QOS		0x0002
391 #define IEEE80211_NODE_REKEY		0x0004	/* GTK rekeying in progress */
392 #define IEEE80211_NODE_RXPROT		0x0008	/* RX protection ON */
393 #define IEEE80211_NODE_TXPROT		0x0010	/* TX protection ON */
394 #define IEEE80211_NODE_TXRXPROT	\
395 	(IEEE80211_NODE_TXPROT | IEEE80211_NODE_RXPROT)
396 #define IEEE80211_NODE_RXMGMTPROT	0x0020	/* RX MMPDU protection ON */
397 #define IEEE80211_NODE_TXMGMTPROT	0x0040	/* TX MMPDU protection ON */
398 #define IEEE80211_NODE_MFP		0x0080	/* MFP negotiated */
399 #define IEEE80211_NODE_PMK		0x0100	/* ni_pmk set */
400 #define IEEE80211_NODE_PMKID		0x0200	/* ni_pmkid set */
401 #define IEEE80211_NODE_HT		0x0400	/* HT negotiated */
402 #define IEEE80211_NODE_SA_QUERY		0x0800	/* SA Query in progress */
403 #define IEEE80211_NODE_SA_QUERY_FAILED	0x1000	/* last SA Query failed */
404 #define IEEE80211_NODE_RSN_NEW_PTK	0x2000	/* expecting a new PTK */
405 #define IEEE80211_NODE_HT_SGI20		0x4000	/* SGI on 20 MHz negotiated */
406 #define IEEE80211_NODE_HT_SGI40		0x8000	/* SGI on 40 MHz negotiated */
407 #define IEEE80211_NODE_VHT		0x10000	/* VHT negotiated */
408 #define IEEE80211_NODE_HTCAP		0x20000	/* claims to support HT */
409 
410 	/* If not NULL, this function gets called when ni_refcnt hits zero. */
411 	void			(*ni_unref_cb)(struct ieee80211com *,
412 					struct ieee80211_node *);
413 	void *			ni_unref_arg;
414 	size_t 			ni_unref_arg_size;
415 };
416 
417 RBT_HEAD(ieee80211_tree, ieee80211_node);
418 
419 struct ieee80211_ess_rbt {
420 	RBT_ENTRY(ieee80211_ess_rbt)	 ess_rbt;
421 	u_int8_t			 esslen;
422 	u_int8_t			 essid[IEEE80211_NWID_LEN];
423 	struct ieee80211_node		*ni2;
424 	struct ieee80211_node		*ni5;
425 	struct ieee80211_node		*ni;
426 };
427 
428 RBT_HEAD(ieee80211_ess_tree, ieee80211_ess_rbt);
429 
430 static inline void
431 ieee80211_node_incref(struct ieee80211_node *ni)
432 {
433 	int		s;
434 
435 	s = splnet();
436 	ni->ni_refcnt++;
437 	splx(s);
438 }
439 
440 static inline u_int
441 ieee80211_node_decref(struct ieee80211_node *ni)
442 {
443 	u_int		refcnt;
444 	int 		s;
445 
446 	s = splnet();
447 	refcnt = --ni->ni_refcnt;
448 	splx(s);
449 	return refcnt;
450 }
451 
452 static inline struct ieee80211_node *
453 ieee80211_ref_node(struct ieee80211_node *ni)
454 {
455 	ieee80211_node_incref(ni);
456 	return ni;
457 }
458 
459 static inline void
460 ieee80211_unref_node(struct ieee80211_node **ni)
461 {
462 	ieee80211_node_decref(*ni);
463 	*ni = NULL;			/* guard against use */
464 }
465 
466 /*
467  * Check if the peer supports HT.
468  * Require a HT capabilities IE and at least one of the mandatory MCS.
469  * MCS 0-7 are mandatory but some APs have particular MCS disabled.
470  */
471 static inline int
472 ieee80211_node_supports_ht(struct ieee80211_node *ni)
473 {
474 	return ((ni->ni_flags & IEEE80211_NODE_HTCAP) &&
475 	    ni->ni_rxmcs[0] & 0xff);
476 }
477 
478 /* Check if the peer supports HT short guard interval (SGI) on 20 MHz. */
479 static inline int
480 ieee80211_node_supports_ht_sgi20(struct ieee80211_node *ni)
481 {
482 	return ieee80211_node_supports_ht(ni) &&
483 	    (ni->ni_htcaps & IEEE80211_HTCAP_SGI20);
484 }
485 
486 /* Check if the peer supports HT short guard interval (SGI) on 40 MHz. */
487 static inline int
488 ieee80211_node_supports_ht_sgi40(struct ieee80211_node *ni)
489 {
490 	return ieee80211_node_supports_ht(ni) &&
491 	    (ni->ni_htcaps & IEEE80211_HTCAP_SGI40);
492 }
493 
494 /* Check if the peer can receive frames sent on a 40 MHz channel. */
495 static inline int
496 ieee80211_node_supports_ht_chan40(struct ieee80211_node *ni)
497 {
498 	return (ieee80211_node_supports_ht(ni) &&
499 	    (ni->ni_htcaps & IEEE80211_HTCAP_CBW20_40) &&
500 	    (ni->ni_htop0 & IEEE80211_HTOP0_CHW));
501 }
502 
503 struct ieee80211com;
504 
505 typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
506 
507 void ieee80211_node_attach(struct ifnet *);
508 void ieee80211_node_lateattach(struct ifnet *);
509 void ieee80211_node_detach(struct ifnet *);
510 
511 void ieee80211_begin_scan(struct ifnet *);
512 void ieee80211_next_scan(struct ifnet *);
513 void ieee80211_end_scan(struct ifnet *);
514 void ieee80211_reset_scan(struct ifnet *);
515 struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *,
516 		const u_int8_t *);
517 struct ieee80211_node *ieee80211_dup_bss(struct ieee80211com *,
518 		const u_int8_t *);
519 struct ieee80211_node *ieee80211_find_node(struct ieee80211com *,
520 		const u_int8_t *);
521 void ieee80211_ba_del(struct ieee80211_node *);
522 struct ieee80211_node *ieee80211_find_rxnode(struct ieee80211com *,
523 		const struct ieee80211_frame *);
524 struct ieee80211_node *ieee80211_find_txnode(struct ieee80211com *,
525 		const u_int8_t *);
526 struct ieee80211_node *
527 		ieee80211_find_node_for_beacon(struct ieee80211com *,
528 		const u_int8_t *, const struct ieee80211_channel *,
529 		const char *, u_int8_t);
530 void ieee80211_release_node(struct ieee80211com *,
531 		struct ieee80211_node *);
532 void ieee80211_node_cleanup(struct ieee80211com *, struct ieee80211_node *);
533 void ieee80211_free_allnodes(struct ieee80211com *, int);
534 void ieee80211_iterate_nodes(struct ieee80211com *,
535 		ieee80211_iter_func *, void *);
536 void ieee80211_clean_cached(struct ieee80211com *);
537 void ieee80211_clean_nodes(struct ieee80211com *, int);
538 void ieee80211_setup_htcaps(struct ieee80211_node *, const uint8_t *,
539     uint8_t);
540 void ieee80211_clear_htcaps(struct ieee80211_node *);
541 int ieee80211_setup_htop(struct ieee80211_node *, const uint8_t *,
542     uint8_t, int);
543 int ieee80211_setup_rates(struct ieee80211com *,
544 	    struct ieee80211_node *, const u_int8_t *, const u_int8_t *, int);
545 void ieee80211_node_trigger_addba_req(struct ieee80211_node *, int);
546 int ieee80211_iserp_sta(const struct ieee80211_node *);
547 void ieee80211_count_longslotsta(void *, struct ieee80211_node *);
548 void ieee80211_count_nonerpsta(void *, struct ieee80211_node *);
549 void ieee80211_count_pssta(void *, struct ieee80211_node *);
550 void ieee80211_count_rekeysta(void *, struct ieee80211_node *);
551 void ieee80211_node_join(struct ieee80211com *,
552 		struct ieee80211_node *, int);
553 void ieee80211_node_leave(struct ieee80211com *,
554 		struct ieee80211_node *);
555 int ieee80211_match_bss(struct ieee80211com *, struct ieee80211_node *, int);
556 struct ieee80211_node *ieee80211_node_choose_bss(struct ieee80211com *, int,
557 		struct ieee80211_node **);
558 void ieee80211_node_join_bss(struct ieee80211com *, struct ieee80211_node *);
559 void ieee80211_create_ibss(struct ieee80211com* ,
560 		struct ieee80211_channel *);
561 void ieee80211_notify_dtim(struct ieee80211com *);
562 void ieee80211_set_tim(struct ieee80211com *, int, int);
563 void ieee80211_free_node(struct ieee80211com *, struct ieee80211_node *);
564 
565 int ieee80211_node_cmp(const struct ieee80211_node *,
566 		const struct ieee80211_node *);
567 int ieee80211_ess_cmp(const struct ieee80211_ess_rbt *,
568 		const struct ieee80211_ess_rbt *);
569 RBT_PROTOTYPE(ieee80211_tree, ieee80211_node, ni_node, ieee80211_node_cmp);
570 RBT_PROTOTYPE(ieee80211_ess_tree, ieee80211_ess_rbt, ess_rbt, ieee80211_ess_cmp);
571 
572 #endif /* _NET80211_IEEE80211_NODE_H_ */
573