FreeBSD kernel WLAN code
ieee80211_node.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2001 Atsushi Onoe
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include "opt_wlan.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/mbuf.h>
37#include <sys/malloc.h>
38#include <sys/kernel.h>
39
40#include <sys/socket.h>
41
42#include <net/if.h>
43#include <net/if_var.h>
44#include <net/if_media.h>
45#include <net/ethernet.h>
46
49#ifdef IEEE80211_SUPPORT_SUPERG
51#endif
52#ifdef IEEE80211_SUPPORT_TDMA
54#endif
59
60#include <net/bpf.h>
61
62/*
63 * IEEE80211_NODE_HASHSIZE must be a power of 2.
64 */
66
67/*
68 * Association id's are managed with a bit vector.
69 */
70#define IEEE80211_AID_SET(_vap, b) \
71 ((_vap)->iv_aid_bitmap[IEEE80211_AID(b) / 32] |= \
72 (1 << (IEEE80211_AID(b) % 32)))
73#define IEEE80211_AID_CLR(_vap, b) \
74 ((_vap)->iv_aid_bitmap[IEEE80211_AID(b) / 32] &= \
75 ~(1 << (IEEE80211_AID(b) % 32)))
76#define IEEE80211_AID_ISSET(_vap, b) \
77 ((_vap)->iv_aid_bitmap[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32)))
78
79static int ieee80211_sta_join1(struct ieee80211_node *);
80
81static struct ieee80211_node *node_alloc(struct ieee80211vap *,
82 const uint8_t [IEEE80211_ADDR_LEN]);
83static int node_init(struct ieee80211_node *);
84static void node_cleanup(struct ieee80211_node *);
85static void node_free(struct ieee80211_node *);
86static void node_age(struct ieee80211_node *);
87static int8_t node_getrssi(const struct ieee80211_node *);
88static void node_getsignal(const struct ieee80211_node *, int8_t *, int8_t *);
89static void node_getmimoinfo(const struct ieee80211_node *,
90 struct ieee80211_mimo_info *);
91
92static void _ieee80211_free_node(struct ieee80211_node *);
93
94static void node_reclaim(struct ieee80211_node_table *nt,
95 struct ieee80211_node *ni);
96static void ieee80211_node_table_init(struct ieee80211com *ic,
97 struct ieee80211_node_table *nt, const char *name,
98 int inact, int keymaxix);
100 struct ieee80211vap *);
102static void ieee80211_vap_erp_timeout(struct ieee80211vap *);
103
104MALLOC_DEFINE(M_80211_NODE, "80211node", "802.11 node state");
105MALLOC_DEFINE(M_80211_NODE_IE, "80211nodeie", "802.11 node ie");
106
107void
109{
110 /* XXX really want maxlen enforced per-sta */
112 "802.11 staging q");
113 ieee80211_node_table_init(ic, &ic->ic_sta, "station",
115 callout_init(&ic->ic_inact, 1);
116 callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz,
118
123 ic->ic_node_age = node_age;
124 ic->ic_node_drain = node_age; /* NB: same as age */
128
129 /*
130 * Set flags to be propagated to all vap's;
131 * these define default behaviour/configuration.
132 */
133 ic->ic_flags_ext |= IEEE80211_FEXT_INACT; /* inactivity processing */
134}
135
136void
138{
139
140 callout_drain(&ic->ic_inact);
144}
145
146void
148{
149 /* NB: driver can override */
151
152 /* default station inactivity timer settings */
157
159 "%s: init %u auth %u run %u probe %u\n", __func__,
160 vap->iv_inact_init, vap->iv_inact_auth,
161 vap->iv_inact_run, vap->iv_inact_probe);
162}
163
164void
166{
167 if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
168 /* XXX should we allow max aid to be zero? */
169 if (vap->iv_max_aid < IEEE80211_AID_MIN) {
171 if_printf(vap->iv_ifp,
172 "WARNING: max aid too small, changed to %d\n",
173 vap->iv_max_aid);
174 }
175 vap->iv_aid_bitmap = (uint32_t *) IEEE80211_MALLOC(
176 howmany(vap->iv_max_aid, 32) * sizeof(uint32_t),
177 M_80211_NODE,
179 if (vap->iv_aid_bitmap == NULL) {
180 /* XXX no way to recover */
181 printf("%s: no memory for AID bitmap, max aid %d!\n",
182 __func__, vap->iv_max_aid);
183 vap->iv_max_aid = 0;
184 }
185 }
186
188
190}
191
192void
194{
195 struct ieee80211com *ic = vap->iv_ic;
196
198 if (vap->iv_bss != NULL) {
200 vap->iv_bss = NULL;
201 }
202 if (vap->iv_aid_bitmap != NULL) {
203 IEEE80211_FREE(vap->iv_aid_bitmap, M_80211_NODE);
204 vap->iv_aid_bitmap = NULL;
205 }
206}
207
208/*
209 * Port authorize/unauthorize interfaces for use by an authenticator.
210 */
211
212void
214{
215 struct ieee80211vap *vap = ni->ni_vap;
216
218 ni->ni_inact_reload = vap->iv_inact_run;
219 ni->ni_inact = ni->ni_inact_reload;
220
222 "%s: inact_reload %u", __func__, ni->ni_inact_reload);
223}
224
225void
227{
228 struct ieee80211vap *vap = ni->ni_vap;
229
230 ni->ni_flags &= ~IEEE80211_NODE_AUTH;
232 if (ni->ni_inact > ni->ni_inact_reload)
233 ni->ni_inact = ni->ni_inact_reload;
234
236 "%s: inact_reload %u inact %u", __func__,
237 ni->ni_inact_reload, ni->ni_inact);
238}
239
240/*
241 * Fix tx parameters for a node according to ``association state''.
242 */
243void
245{
246 struct ieee80211vap *vap = ni->ni_vap;
247 enum ieee80211_phymode mode;
248
249 if (ni->ni_flags & IEEE80211_NODE_VHT) {
252 else
254 } else if (ni->ni_flags & IEEE80211_NODE_HT) {
256 mode = IEEE80211_MODE_11NA;
257 else
258 mode = IEEE80211_MODE_11NG;
259 } else { /* legacy rate handling */
262 else if (IEEE80211_IS_CHAN_HALF(ni->ni_chan))
263 mode = IEEE80211_MODE_HALF;
266 /* NB: 108A should be handled as 11a */
267 else if (IEEE80211_IS_CHAN_A(ni->ni_chan))
268 mode = IEEE80211_MODE_11A;
269 else if (IEEE80211_IS_CHAN_108G(ni->ni_chan) ||
271 mode = IEEE80211_MODE_11G;
272 else
273 mode = IEEE80211_MODE_11B;
274 }
275 ni->ni_txparms = &vap->iv_txparms[mode];
276}
277
278/*
279 * Set/change the channel. The rate set is also updated as
280 * to insure a consistent view by drivers.
281 * XXX should be private but hostap needs it to deal with CSA
282 */
283void
285 struct ieee80211_channel *chan)
286{
287 struct ieee80211com *ic = ni->ni_ic;
288 struct ieee80211vap *vap = ni->ni_vap;
289 enum ieee80211_phymode mode;
290
291 KASSERT(chan != IEEE80211_CHAN_ANYC, ("no channel"));
292
293 ni->ni_chan = chan;
294 mode = ieee80211_chan2mode(chan);
295 if (IEEE80211_IS_CHAN_HT(chan)) {
296 /*
297 * We must install the legacy rate est in ni_rates and the
298 * HT rate set in ni_htrates.
299 */
300 ni->ni_htrates = *ieee80211_get_suphtrates(ic, chan);
301 /*
302 * Setup bss tx parameters based on operating mode. We
303 * use legacy rates when operating in a mixed HT+non-HT bss
304 * and non-ERP rates in 11g for mixed ERP+non-ERP bss.
305 */
306 if (mode == IEEE80211_MODE_11NA &&
307 (vap->iv_flags_ht & IEEE80211_FHT_PUREN) == 0)
308 mode = IEEE80211_MODE_11A;
309 else if (mode == IEEE80211_MODE_11NG &&
310 (vap->iv_flags_ht & IEEE80211_FHT_PUREN) == 0)
311 mode = IEEE80211_MODE_11G;
312 if (mode == IEEE80211_MODE_11G &&
313 (vap->iv_flags & IEEE80211_F_PUREG) == 0)
314 mode = IEEE80211_MODE_11B;
315 }
316 ni->ni_txparms = &vap->iv_txparms[mode];
317 ni->ni_rates = *ieee80211_get_suprates(ic, chan);
318}
319
320static __inline void
321copy_bss(struct ieee80211_node *nbss, const struct ieee80211_node *obss)
322{
323 /* propagate useful state */
324 nbss->ni_authmode = obss->ni_authmode;
325 nbss->ni_txpower = obss->ni_txpower;
326 nbss->ni_vlan = obss->ni_vlan;
327 /* XXX statistics? */
328 /* XXX legacy WDS bssid? */
329}
330
331void
333{
334 struct ieee80211com *ic = vap->iv_ic;
335 struct ieee80211_node *ni;
336
338 "%s: creating %s on channel %u%c flags 0x%08x\n", __func__,
340 ieee80211_chan2ieee(ic, chan),
342 chan->ic_flags);
343
344 ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr);
345 if (ni == NULL) {
346 /* XXX recovery? */
347 return;
348 }
350 ni->ni_esslen = vap->iv_des_ssid[0].len;
351 memcpy(ni->ni_essid, vap->iv_des_ssid[0].ssid, ni->ni_esslen);
352 if (vap->iv_bss != NULL)
353 copy_bss(ni, vap->iv_bss);
354 ni->ni_intval = ic->ic_bintval;
355 if (vap->iv_flags & IEEE80211_F_PRIVACY)
357 if (ic->ic_phytype == IEEE80211_T_FH) {
358 ni->ni_fhdwell = 200; /* XXX */
359 ni->ni_fhindex = 1;
360 }
361 if (vap->iv_opmode == IEEE80211_M_IBSS) {
362 ni->ni_capinfo |= IEEE80211_CAPINFO_IBSS; /* XXX */
365 else {
368 /* clear group bit, add local bit */
369 ni->ni_bssid[0] = (ni->ni_bssid[0] &~ 0x01) | 0x02;
370 }
371 } else if (vap->iv_opmode == IEEE80211_M_AHDEMO) {
374 else
375#ifdef IEEE80211_SUPPORT_TDMA
376 if ((vap->iv_caps & IEEE80211_C_TDMA) == 0)
377#endif
378 memset(ni->ni_bssid, 0, IEEE80211_ADDR_LEN);
379#ifdef IEEE80211_SUPPORT_MESH
380 } else if (vap->iv_opmode == IEEE80211_M_MBSS) {
381 ni->ni_meshidlen = vap->iv_mesh->ms_idlen;
382 memcpy(ni->ni_meshid, vap->iv_mesh->ms_id, ni->ni_meshidlen);
383#endif
384 }
385 /*
386 * Fix the channel and related attributes.
387 */
388 /* clear DFS CAC state on previous channel */
389 if (ic->ic_bsschan != IEEE80211_CHAN_ANYC &&
390 ic->ic_bsschan->ic_freq != chan->ic_freq &&
393 ic->ic_bsschan = chan;
394 ieee80211_node_set_chan(ni, chan);
396 /*
397 * Do mode-specific setup.
398 */
399 if (IEEE80211_IS_CHAN_FULL(chan)) {
400 if (IEEE80211_IS_CHAN_ANYG(chan)) {
401 /*
402 * Use a mixed 11b/11g basic rate set.
403 */
406 if (vap->iv_flags & IEEE80211_F_PUREG) {
407 /*
408 * Also mark OFDM rates basic so 11b
409 * stations do not join (WiFi compliance).
410 */
413 }
414 } else if (IEEE80211_IS_CHAN_B(chan)) {
415 /*
416 * Force pure 11b rate set.
417 */
420 }
421 }
422
423 /* XXX TODO: other bits and pieces - eg fast-frames? */
424
425 /* If we're an 11n channel then initialise the 11n bits */
427 /* XXX what else? */
430 } else if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) {
431 /* XXX what else? */
433 }
434
436}
437
438/*
439 * Reset bss state on transition to the INIT state.
440 * Clear any stations from the table (they have been
441 * deauth'd) and reset the bss node (clears key, rate
442 * etc. state).
443 */
444void
446{
447 struct ieee80211com *ic = vap->iv_ic;
448 struct ieee80211_node *ni, *obss;
449
451 /* XXX multi-bss: wrong */
453
454 ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr);
455 KASSERT(ni != NULL, ("unable to setup initial BSS node"));
456 obss = vap->iv_bss;
457 vap->iv_bss = ieee80211_ref_node(ni);
458 if (obss != NULL) {
459 copy_bss(ni, obss);
460 ni->ni_intval = ic->ic_bintval;
462 } else
464}
465
466static int
467match_ssid(const struct ieee80211_node *ni,
468 int nssid, const struct ieee80211_scan_ssid ssids[])
469{
470 int i;
471
472 for (i = 0; i < nssid; i++) {
473 if (ni->ni_esslen == ssids[i].len &&
474 memcmp(ni->ni_essid, ssids[i].ssid, ni->ni_esslen) == 0)
475 return 1;
476 }
477 return 0;
478}
479
480/*
481 * Test a node for suitability/compatibility.
482 */
483static int
484check_bss(struct ieee80211vap *vap, struct ieee80211_node *ni)
485{
486 struct ieee80211com *ic = ni->ni_ic;
487 uint8_t rate;
488
489 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, ni->ni_chan)))
490 return 0;
491 if (vap->iv_opmode == IEEE80211_M_IBSS) {
492 if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
493 return 0;
494 } else {
495 if ((ni->ni_capinfo & IEEE80211_CAPINFO_ESS) == 0)
496 return 0;
497 }
498 if (vap->iv_flags & IEEE80211_F_PRIVACY) {
499 if ((ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0)
500 return 0;
501 } else {
502 /* XXX does this mean privacy is supported or required? */
504 return 0;
505 }
506 rate = ieee80211_fix_rate(ni, &ni->ni_rates,
508 if (rate & IEEE80211_RATE_BASIC)
509 return 0;
510 if (vap->iv_des_nssid != 0 &&
511 !match_ssid(ni, vap->iv_des_nssid, vap->iv_des_ssid))
512 return 0;
513 if ((vap->iv_flags & IEEE80211_F_DESBSSID) &&
515 return 0;
516 return 1;
517}
518
519#ifdef IEEE80211_DEBUG
520/*
521 * Display node suitability/compatibility.
522 */
523static void
524check_bss_debug(struct ieee80211vap *vap, struct ieee80211_node *ni)
525{
526 struct ieee80211com *ic = ni->ni_ic;
527 uint8_t rate;
528 int fail;
529
530 fail = 0;
531 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, ni->ni_chan)))
532 fail |= 0x01;
533 if (vap->iv_opmode == IEEE80211_M_IBSS) {
534 if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
535 fail |= 0x02;
536 } else {
537 if ((ni->ni_capinfo & IEEE80211_CAPINFO_ESS) == 0)
538 fail |= 0x02;
539 }
540 if (vap->iv_flags & IEEE80211_F_PRIVACY) {
541 if ((ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0)
542 fail |= 0x04;
543 } else {
544 /* XXX does this mean privacy is supported or required? */
546 fail |= 0x04;
547 }
548 rate = ieee80211_fix_rate(ni, &ni->ni_rates,
550 if (rate & IEEE80211_RATE_BASIC)
551 fail |= 0x08;
552 if (vap->iv_des_nssid != 0 &&
553 !match_ssid(ni, vap->iv_des_nssid, vap->iv_des_ssid))
554 fail |= 0x10;
555 if ((vap->iv_flags & IEEE80211_F_DESBSSID) &&
557 fail |= 0x20;
558
559 printf(" %c %s", fail ? '-' : '+', ether_sprintf(ni->ni_macaddr));
560 printf(" %s%c", ether_sprintf(ni->ni_bssid), fail & 0x20 ? '!' : ' ');
561 printf(" %3d%c",
562 ieee80211_chan2ieee(ic, ni->ni_chan), fail & 0x01 ? '!' : ' ');
563 printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2,
564 fail & 0x08 ? '!' : ' ');
565 printf(" %4s%c",
566 (ni->ni_capinfo & IEEE80211_CAPINFO_ESS) ? "ess" :
567 (ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" :
568 "????",
569 fail & 0x02 ? '!' : ' ');
570 printf(" %3s%c ",
571 (ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) ? "wep" : "no",
572 fail & 0x04 ? '!' : ' ');
574 printf("%s\n", fail & 0x10 ? "!" : "");
575}
576#endif /* IEEE80211_DEBUG */
577
578int
580{
581 struct ieee80211vap *vap = ni->ni_vap;
582
583 if (ni == vap->iv_bss ||
585 /* unchanged, nothing to do */
586 return 0;
587 }
588
589 if (!check_bss(vap, ni)) {
590 /* capabilities mismatch */
592 "%s: merge failed, capabilities mismatch\n", __func__);
593#ifdef IEEE80211_DEBUG
594 if (ieee80211_msg_assoc(vap))
595 check_bss_debug(vap, ni);
596#endif
598 return 0;
599 }
600
601 return 1;
602}
603
604/*
605 * Check if the given node should populate the node table.
606 *
607 * We need to be in "see all beacons for all ssids" mode in order
608 * to do IBSS merges, however this means we will populate nodes for
609 * /all/ IBSS SSIDs, versus just the one we care about.
610 *
611 * So this check ensures the node can actually belong to our IBSS
612 * configuration. For now it simply checks the SSID.
613 */
614int
616 const struct ieee80211_scanparams *scan)
617{
618 struct ieee80211vap *vap = ni->ni_vap;
619 int i;
620
621 /*
622 * If we have no SSID and no scan SSID, return OK.
623 */
624 if (vap->iv_des_nssid == 0 && scan->ssid == NULL)
625 goto ok;
626
627 /*
628 * If we have one of (SSID, scan SSID) then return error.
629 */
630 if (!! (vap->iv_des_nssid == 0) != !! (scan->ssid == NULL))
631 goto mismatch;
632
633 /*
634 * Double-check - we need scan SSID.
635 */
636 if (scan->ssid == NULL)
637 goto mismatch;
638
639 /*
640 * Check if the scan SSID matches the SSID list for the VAP.
641 */
642 for (i = 0; i < vap->iv_des_nssid; i++) {
643 /* Sanity length check */
644 if (vap->iv_des_ssid[i].len != scan->ssid[1])
645 continue;
646
647 /* Note: SSID in the scan entry is the IE format */
648 if (memcmp(vap->iv_des_ssid[i].ssid, scan->ssid + 2,
649 vap->iv_des_ssid[i].len) == 0)
650 goto ok;
651 }
652
653mismatch:
654 return (0);
655ok:
656 return (1);
657}
658
659/*
660 * Handle 802.11 ad hoc network merge. The
661 * convention, set by the Wireless Ethernet Compatibility Alliance
662 * (WECA), is that an 802.11 station will change its BSSID to match
663 * the "oldest" 802.11 ad hoc network, on the same channel, that
664 * has the station's desired SSID. The "oldest" 802.11 network
665 * sends beacons with the greatest TSF timestamp.
666 *
667 * The caller is assumed to validate TSF's before attempting a merge.
668 *
669 * Return !0 if the BSSID changed, 0 otherwise.
670 */
671int
673{
674#ifdef IEEE80211_DEBUG
675 struct ieee80211vap *vap = ni->ni_vap;
676#endif
677
679 return 0;
680
682 "%s: new bssid %s: %s preamble, %s slot time%s\n", __func__,
683 ether_sprintf(ni->ni_bssid),
684 vap->iv_flags&IEEE80211_F_SHPREAMBLE ? "short" : "long",
685 vap->iv_flags&IEEE80211_F_SHSLOT ? "short" : "long",
686 vap->iv_flags&IEEE80211_F_USEPROT ? ", protection" : ""
687 );
689}
690
691/*
692 * Calculate HT channel promotion flags for all vaps.
693 * This assumes ni_chan have been setup for each vap.
694 */
695static int
697{
698 struct ieee80211vap *vap;
699 int flags;
700
701 flags = 0;
702 /* XXX locking */
703 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
704 if (vap->iv_state < IEEE80211_S_RUN)
705 continue;
706 switch (vap->iv_opmode) {
707 case IEEE80211_M_WDS:
708 case IEEE80211_M_STA:
711 case IEEE80211_M_IBSS:
712 case IEEE80211_M_MBSS:
713 flags |= ieee80211_htchanflags(vap->iv_bss->ni_chan);
714 break;
715 default:
716 break;
717 }
718 }
719 return flags;
720}
721
722/*
723 * Calculate VHT channel promotion flags for all vaps.
724 * This assumes ni_chan have been setup for each vap.
725 */
726static int
728{
729 struct ieee80211vap *vap;
730 int flags;
731
732 flags = 0;
733 /* XXX locking */
734 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
735 if (vap->iv_state < IEEE80211_S_RUN)
736 continue;
737 switch (vap->iv_opmode) {
738 case IEEE80211_M_WDS:
739 case IEEE80211_M_STA:
742 case IEEE80211_M_IBSS:
743 case IEEE80211_M_MBSS:
744 flags |= ieee80211_vhtchanflags(vap->iv_bss->ni_chan);
745 break;
746 default:
747 break;
748 }
749 }
750 return flags;
751}
752
753/*
754 * Check if the current channel needs to change based on whether
755 * any vap's are using HT20/HT40. This is used to sync the state
756 * of ic_curchan after a channel width change on a running vap.
757 *
758 * Same applies for VHT.
759 */
760void
762{
763 struct ieee80211_channel *c;
764
767
768 if (c != ic->ic_curchan) {
769 ic->ic_curchan = c;
773 ic->ic_set_channel(ic);
775 IEEE80211_LOCK(ic);
776 }
777}
778
779/*
780 * Setup the current channel. The request channel may be
781 * promoted if other vap's are operating with HT20/HT40.
782 */
783void
785{
786 if (ic->ic_htcaps & IEEE80211_HTC_HT) {
787 int flags = gethtadjustflags(ic);
788 /*
789 * Check for channel promotion required to support the
790 * set of running vap's. This assumes we are called
791 * after ni_chan is setup for each vap.
792 */
793 /* XXX VHT? */
794 /* NB: this assumes IEEE80211_FHT_USEHT40 > IEEE80211_FHT_HT */
795 if (flags > ieee80211_htchanflags(c))
796 c = ieee80211_ht_adjust_channel(ic, c, flags);
797 }
798
799 /*
800 * VHT promotion - this will at least promote to VHT20/40
801 * based on what HT has done; it may further promote the
802 * channel to VHT80 or above.
803 */
804 if (ic->ic_vhtcaps != 0) {
805 int flags = getvhtadjustflags(ic);
806 if (flags > ieee80211_vhtchanflags(c))
807 c = ieee80211_vht_adjust_channel(ic, c, flags);
808 }
809
810 ic->ic_bsschan = ic->ic_curchan = c;
813}
814
815/*
816 * Change the current channel. The channel change is guaranteed to have
817 * happened before the next state change.
818 */
819void
821{
824}
825
826void
828{
829
832}
833
834/*
835 * Join the specified IBSS/BSS network. The node is assumed to
836 * be passed in with a held reference.
837 */
838static int
840{
841 struct ieee80211vap *vap = selbs->ni_vap;
842 struct ieee80211com *ic = selbs->ni_ic;
843 struct ieee80211_node *obss;
844 int canreassoc;
845
846 /*
847 * Committed to selbs, setup state.
848 */
849 obss = vap->iv_bss;
850 /*
851 * Check if old+new node have the same address in which
852 * case we can reassociate when operating in sta mode.
853 */
854 canreassoc = (obss != NULL &&
855 vap->iv_state == IEEE80211_S_RUN &&
857 vap->iv_bss = selbs; /* NB: caller assumed to bump refcnt */
858 if (obss != NULL) {
859 struct ieee80211_node_table *nt = obss->ni_table;
860
861 copy_bss(selbs, obss);
862 ieee80211_node_decref(obss); /* iv_bss reference */
863
865 node_reclaim(nt, obss); /* station table reference */
867
868 obss = NULL; /* NB: guard against later use */
869 }
870
871 /*
872 * Delete unusable rates; we've already checked
873 * that the negotiated rate set is acceptable.
874 */
877
878 ieee80211_setcurchan(ic, selbs->ni_chan);
879 /*
880 * Set the erp state (mostly the slot time) to deal with
881 * the auto-select case; this should be redundant if the
882 * mode is locked.
883 */
886
887 if (vap->iv_opmode == IEEE80211_M_STA) {
888 if (canreassoc) {
889 /* Reassociate */
891 } else {
892 /*
893 * Act as if we received a DEAUTH frame in case we
894 * are invoked from the RUN state. This will cause
895 * us to try to re-authenticate if we are operating
896 * as a station.
897 */
899 "%s %p<%s> -> AUTH, FC0_SUBTYPE_DEAUTH\n",
900 __func__, selbs, ether_sprintf(selbs->ni_macaddr));
903 }
904 } else
906 return 1;
907}
908
909int
911 const struct ieee80211_scan_entry *se)
912{
913 struct ieee80211com *ic = vap->iv_ic;
914 struct ieee80211_node *ni;
915 int do_ht = 0;
916
917 ni = ieee80211_alloc_node(&ic->ic_sta, vap, se->se_macaddr);
918 if (ni == NULL) {
919 /* XXX msg */
920 return 0;
921 }
922
923 /*
924 * Expand scan state into node's format.
925 * XXX may not need all this stuff
926 */
928 ni->ni_esslen = se->se_ssid[1];
929 memcpy(ni->ni_essid, se->se_ssid+2, ni->ni_esslen);
930 ni->ni_tstamp.tsf = se->se_tstamp.tsf;
931 ni->ni_intval = se->se_intval;
932 ni->ni_capinfo = se->se_capinfo;
933 ni->ni_chan = chan;
934 ni->ni_timoff = se->se_timoff;
935 ni->ni_fhdwell = se->se_fhdwell;
936 ni->ni_fhindex = se->se_fhindex;
937 ni->ni_erp = se->se_erp;
939 ni->ni_noise = se->se_noise;
940 if (vap->iv_opmode == IEEE80211_M_STA) {
941 /* NB: only infrastructure mode requires an associd */
943 }
944
945 if (ieee80211_ies_init(&ni->ni_ies, se->se_ies.data, se->se_ies.len)) {
947#ifdef IEEE80211_SUPPORT_SUPERG
948 if (ni->ni_ies.ath_ie != NULL)
950#endif
951 if (ni->ni_ies.htcap_ie != NULL)
953 if (ni->ni_ies.htinfo_ie != NULL)
955#ifdef IEEE80211_SUPPORT_MESH
956 if (ni->ni_ies.meshid_ie != NULL)
958#endif
959#ifdef IEEE80211_SUPPORT_TDMA
960 if (ni->ni_ies.tdma_ie != NULL)
962#endif
963 if (ni->ni_ies.vhtcap_ie != NULL)
965 if (ni->ni_ies.vhtopmode_ie != NULL)
967
968 /* XXX parse BSSLOAD IE */
969 /* XXX parse TXPWRENV IE */
970 /* XXX parse APCHANREP IE */
971 }
972
973 vap->iv_dtim_period = se->se_dtimperiod;
974 vap->iv_dtim_count = 0;
975
976 /* NB: must be after ni_chan is setup */
981
982 /*
983 * Setup HT state for this node if it's available, otherwise
984 * non-STA modes won't pick this state up.
985 *
986 * For IBSS and related modes that don't go through an
987 * association request/response, the only appropriate place
988 * to setup the HT state is here.
989 */
990 if (ni->ni_ies.htinfo_ie != NULL &&
991 ni->ni_ies.htcap_ie != NULL &&
995 ni->ni_ies.htcap_ie,
996 ni->ni_ies.htinfo_ie);
997 do_ht = 1;
998 }
999
1000 /*
1001 * Setup VHT state for this node if it's available.
1002 * Same as the above.
1003 *
1004 * For now, don't allow 2GHz VHT operation.
1005 */
1006 if (ni->ni_ies.vhtopmode_ie != NULL &&
1007 ni->ni_ies.vhtcap_ie != NULL &&
1010 printf("%s: BSS %6D: 2GHz channel, VHT info; ignoring\n",
1011 __func__,
1012 ni->ni_macaddr,
1013 ":");
1014 } else {
1017 ni->ni_ies.vhtcap_ie,
1018 ni->ni_ies.vhtopmode_ie);
1020 ni->ni_ies.vhtopmode_ie);
1021 do_ht = 1;
1022 }
1023 }
1024
1025 /* Finally do the node channel change */
1026 if (do_ht) {
1028 ni->ni_ies.htinfo_ie);
1032 }
1033
1034 /* XXX else check for ath FF? */
1035 /* XXX QoS? Difficult given that WME config is specific to a master */
1036
1039
1041}
1042
1043/*
1044 * Leave the specified IBSS/BSS network. The node is assumed to
1045 * be passed in with a held reference.
1046 */
1047void
1049{
1050 struct ieee80211com *ic = ni->ni_ic;
1051
1052 ic->ic_node_cleanup(ni);
1054}
1055
1056/*
1057 * Send a deauthenticate frame and drop the station.
1058 */
1059void
1061{
1062 /* NB: bump the refcnt to be sure temporary nodes are not reclaimed */
1064 if (ni->ni_associd != 0)
1068}
1069
1070static struct ieee80211_node *
1071node_alloc(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
1072{
1073 struct ieee80211_node *ni;
1074
1075 ni = (struct ieee80211_node *) IEEE80211_MALLOC(sizeof(struct ieee80211_node),
1076 M_80211_NODE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO);
1077 return ni;
1078}
1079
1080static int
1082{
1083 return 0;
1084}
1085
1086/*
1087 * Initialize an ie blob with the specified data. If previous
1088 * data exists re-use the data block. As a side effect we clear
1089 * all references to specific ie's; the caller is required to
1090 * recalculate them.
1091 */
1092int
1093ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len)
1094{
1095 /* NB: assumes data+len are the last fields */
1096 memset(ies, 0, offsetof(struct ieee80211_ies, data));
1097 if (ies->data != NULL && ies->len != len) {
1098 /* data size changed */
1099 IEEE80211_FREE(ies->data, M_80211_NODE_IE);
1100 ies->data = NULL;
1101 }
1102 if (ies->data == NULL) {
1103 ies->data = (uint8_t *) IEEE80211_MALLOC(len, M_80211_NODE_IE,
1105 if (ies->data == NULL) {
1106 ies->len = 0;
1107 /* NB: pointers have already been zero'd above */
1108 return 0;
1109 }
1110 }
1111 memcpy(ies->data, data, len);
1112 ies->len = len;
1113 return 1;
1114}
1115
1116/*
1117 * Reclaim storage for an ie blob.
1118 */
1119void
1121{
1122 if (ies->data != NULL)
1123 IEEE80211_FREE(ies->data, M_80211_NODE_IE);
1124}
1125
1126/*
1127 * Expand an ie blob data contents and to fillin individual
1128 * ie pointers. The data blob is assumed to be well-formed;
1129 * we don't do any validity checking of ie lengths.
1130 */
1131void
1133{
1134 uint8_t *ie;
1135 int ielen;
1136
1137 ie = ies->data;
1138 ielen = ies->len;
1139 while (ielen > 1) {
1140 switch (ie[0]) {
1142 if (iswpaoui(ie))
1143 ies->wpa_ie = ie;
1144 else if (iswmeoui(ie))
1145 ies->wme_ie = ie;
1146#ifdef IEEE80211_SUPPORT_SUPERG
1147 else if (isatherosoui(ie))
1148 ies->ath_ie = ie;
1149#endif
1150#ifdef IEEE80211_SUPPORT_TDMA
1151 else if (istdmaoui(ie))
1152 ies->tdma_ie = ie;
1153#endif
1154 break;
1156 ies->rsn_ie = ie;
1157 break;
1159 ies->htcap_ie = ie;
1160 break;
1162 ies->htinfo_ie = ie;
1163 break;
1164#ifdef IEEE80211_SUPPORT_MESH
1166 ies->meshid_ie = ie;
1167 break;
1168#endif
1170 ies->vhtcap_ie = ie;
1171 break;
1173 ies->vhtopmode_ie = ie;
1174 break;
1176 ies->vhtpwrenv_ie = ie;
1177 break;
1179 ies->bssload_ie = ie;
1180 break;
1182 ies->apchanrep_ie = ie;
1183 break;
1184 }
1185 ielen -= 2 + ie[1];
1186 ie += 2 + ie[1];
1187 }
1188}
1189
1190/*
1191 * Reclaim any resources in a node and reset any critical
1192 * state. Typically nodes are free'd immediately after,
1193 * but in some cases the storage may be reused so we need
1194 * to insure consistent state (should probably fix that).
1195 */
1196static void
1198{
1199 struct ieee80211vap *vap = ni->ni_vap;
1200 struct ieee80211com *ic = ni->ni_ic;
1201 int i;
1202
1203 /* NB: preserve ni_table */
1204 if (ni->ni_flags & IEEE80211_NODE_PWR_MGT) {
1205 if (vap->iv_opmode != IEEE80211_M_STA)
1206 vap->iv_ps_sta--;
1207 ni->ni_flags &= ~IEEE80211_NODE_PWR_MGT;
1209 "power save mode off, %u sta's in ps mode", vap->iv_ps_sta);
1210 }
1211 /*
1212 * Cleanup any VHT and HT-related state.
1213 */
1214 if (ni->ni_flags & IEEE80211_NODE_VHT)
1216 if (ni->ni_flags & IEEE80211_NODE_HT)
1218#ifdef IEEE80211_SUPPORT_SUPERG
1219 /* Always do FF node cleanup; for A-MSDU */
1221#endif
1222#ifdef IEEE80211_SUPPORT_MESH
1223 /*
1224 * Cleanup any mesh-related state.
1225 */
1226 if (vap->iv_opmode == IEEE80211_M_MBSS)
1228#endif
1229 /*
1230 * Clear any staging queue entries.
1231 */
1233
1234 /*
1235 * Clear AREF flag that marks the authorization refcnt bump
1236 * has happened. This is probably not needed as the node
1237 * should always be removed from the table so not found but
1238 * do it just in case.
1239 * Likewise clear the ASSOCID flag as these flags are intended
1240 * to be managed in tandem.
1241 */
1243
1244 /*
1245 * Drain power save queue and, if needed, clear TIM.
1246 */
1247 if (ieee80211_node_psq_drain(ni) != 0 && vap->iv_set_tim != NULL)
1248 vap->iv_set_tim(ni, 0);
1249
1250 ni->ni_associd = 0;
1251 if (ni->ni_challenge != NULL) {
1252 IEEE80211_FREE(ni->ni_challenge, M_80211_NODE);
1253 ni->ni_challenge = NULL;
1254 }
1255 /*
1256 * Preserve SSID, WPA, and WME ie's so the bss node is
1257 * reusable during a re-auth/re-assoc state transition.
1258 * If we remove these data they will not be recreated
1259 * because they come from a probe-response or beacon frame
1260 * which cannot be expected prior to the association-response.
1261 * This should not be an issue when operating in other modes
1262 * as stations leaving always go through a full state transition
1263 * which will rebuild this state.
1264 *
1265 * XXX does this leave us open to inheriting old state?
1266 */
1267 for (i = 0; i < nitems(ni->ni_rxfrag); i++)
1268 if (ni->ni_rxfrag[i] != NULL) {
1269 m_freem(ni->ni_rxfrag[i]);
1270 ni->ni_rxfrag[i] = NULL;
1271 }
1272 /*
1273 * Must be careful here to remove any key map entry w/o a LOR.
1274 */
1276}
1277
1278static void
1280{
1281 struct ieee80211com *ic = ni->ni_ic;
1282
1284 ic->ic_node_cleanup(ni);
1287 IEEE80211_FREE(ni, M_80211_NODE);
1288}
1289
1290static void
1292{
1293 struct ieee80211vap *vap = ni->ni_vap;
1294
1295 /*
1296 * Age frames on the power save queue.
1297 */
1298 if (ieee80211_node_psq_age(ni) != 0 &&
1299 ni->ni_psq.psq_len == 0 && vap->iv_set_tim != NULL)
1300 vap->iv_set_tim(ni, 0);
1301 /*
1302 * Age out HT resources (e.g. frames on the
1303 * A-MPDU reorder queues).
1304 */
1305 if (ni->ni_associd != 0 && (ni->ni_flags & IEEE80211_NODE_HT))
1307}
1308
1309static int8_t
1311{
1312 uint32_t avgrssi = ni->ni_avgrssi;
1313 int32_t rssi;
1314
1315 if (avgrssi == IEEE80211_RSSI_DUMMY_MARKER)
1316 return 0;
1317 rssi = IEEE80211_RSSI_GET(avgrssi);
1318 return rssi < 0 ? 0 : rssi > 127 ? 127 : rssi;
1319}
1320
1321static void
1322node_getsignal(const struct ieee80211_node *ni, int8_t *rssi, int8_t *noise)
1323{
1324 *rssi = node_getrssi(ni);
1325 *noise = ni->ni_noise;
1326}
1327
1328static void
1330 struct ieee80211_mimo_info *info)
1331{
1332 int i;
1333 uint32_t avgrssi;
1334 int32_t rssi;
1335
1336 bzero(info, sizeof(*info));
1337
1338 for (i = 0; i < MIN(IEEE80211_MAX_CHAINS, ni->ni_mimo_chains); i++) {
1339 /* Note: for now, just pri20 channel info */
1340 avgrssi = ni->ni_mimo_rssi_ctl[i];
1341 if (avgrssi == IEEE80211_RSSI_DUMMY_MARKER) {
1342 info->ch[i].rssi[0] = 0;
1343 } else {
1344 rssi = IEEE80211_RSSI_GET(avgrssi);
1345 info->ch[i].rssi[0] = rssi < 0 ? 0 : rssi > 127 ? 127 : rssi;
1346 }
1347 info->ch[i].noise[0] = ni->ni_mimo_noise_ctl[i];
1348 }
1349
1350 /* XXX ext radios? */
1351
1352 /* XXX EVM? */
1353}
1354
1355static void
1357 struct ieee80211_node *ni)
1358{
1359 struct ieee80211com *ic = nt->nt_ic;
1360 int hash;
1361
1363
1364 hash = IEEE80211_NODE_HASH(ic, ni->ni_macaddr);
1365 (void) ic; /* XXX IEEE80211_NODE_HASH */
1366 TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list);
1367 LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash);
1368 nt->nt_count++;
1369 ni->ni_table = nt;
1370}
1371
1372static void
1374 struct ieee80211_node *ni)
1375{
1376
1378
1379 TAILQ_REMOVE(&nt->nt_node, ni, ni_list);
1380 LIST_REMOVE(ni, ni_hash);
1381 nt->nt_count--;
1382 KASSERT(nt->nt_count >= 0,
1383 ("nt_count is negative (%d)!\n", nt->nt_count));
1384 ni->ni_table = NULL;
1385}
1386
1387struct ieee80211_node *
1389 struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
1390{
1391 struct ieee80211com *ic = nt->nt_ic;
1392 struct ieee80211_node *ni;
1393
1394 ni = ic->ic_node_alloc(vap, macaddr);
1395 if (ni == NULL) {
1397 return NULL;
1398 }
1399
1401 "%s %p<%s> in %s table\n", __func__, ni,
1402 ether_sprintf(macaddr), nt->nt_name);
1403
1404 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr);
1405 ieee80211_node_initref(ni); /* mark referenced */
1408 ni->ni_txpower = ic->ic_txpowlimit; /* max power */
1413 ni->ni_inact = ni->ni_inact_reload;
1414 ni->ni_ath_defkeyix = 0x7fff;
1415 ieee80211_psq_init(&ni->ni_psq, "unknown");
1416#ifdef IEEE80211_SUPPORT_MESH
1417 if (vap->iv_opmode == IEEE80211_M_MBSS)
1418 ieee80211_mesh_node_init(vap, ni);
1419#endif
1421 ieee80211_add_node_nt(nt, ni);
1422 ni->ni_vap = vap;
1423 ni->ni_ic = ic;
1425
1426 /* handle failure; free node state */
1427 if (ic->ic_node_init(ni) != 0) {
1432 return NULL;
1433 }
1434
1436 "%s: inact_reload %u", __func__, ni->ni_inact_reload);
1437
1438 return ni;
1439}
1440
1441/*
1442 * Craft a temporary node suitable for sending a management frame
1443 * to the specified station. We craft only as much state as we
1444 * need to do the work since the node will be immediately reclaimed
1445 * once the send completes.
1446 */
1447struct ieee80211_node *
1449 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1450{
1451 struct ieee80211com *ic = vap->iv_ic;
1452 struct ieee80211_node *ni;
1453
1454 ni = ic->ic_node_alloc(vap, macaddr);
1455 if (ni != NULL) {
1456 struct ieee80211_node *bss = vap->iv_bss;
1457
1459 "%s %p<%s>\n", __func__, ni, ether_sprintf(macaddr));
1460
1461 ni->ni_table = NULL; /* NB: pedantic */
1462 ni->ni_ic = ic; /* NB: needed to set channel */
1463 ni->ni_vap = vap;
1464
1465 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr);
1467 ieee80211_node_initref(ni); /* mark referenced */
1468 /* NB: required by ieee80211_fix_rate */
1472 ni->ni_txpower = bss->ni_txpower;
1473 /* XXX optimize away */
1474 ieee80211_psq_init(&ni->ni_psq, "unknown");
1475
1477
1478 /* handle failure; free node state */
1479 if (ic->ic_node_init(ni) != 0) {
1484 return NULL;
1485 }
1486
1487 } else {
1488 /* XXX msg */
1490 }
1491 return ni;
1492}
1493
1494struct ieee80211_node *
1496 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1497{
1498 struct ieee80211com *ic = vap->iv_ic;
1499 struct ieee80211_node *ni;
1500
1501 ni = ieee80211_alloc_node(&ic->ic_sta, vap, macaddr);
1502 if (ni != NULL) {
1503 struct ieee80211_node *bss = vap->iv_bss;
1504 /*
1505 * Inherit from iv_bss.
1506 */
1507 copy_bss(ni, bss);
1510 }
1511 return ni;
1512}
1513
1514/*
1515 * Create a bss node for a legacy WDS vap. The far end does
1516 * not associate so we just create create a new node and
1517 * simulate an association. The caller is responsible for
1518 * installing the node as the bss node and handling any further
1519 * setup work like authorizing the port.
1520 */
1521struct ieee80211_node *
1523 const uint8_t bssid[IEEE80211_ADDR_LEN], struct ieee80211_channel *chan)
1524{
1525 struct ieee80211com *ic = vap->iv_ic;
1526 struct ieee80211_node *ni;
1527
1528 /* XXX check if node already in sta table? */
1529 ni = ieee80211_alloc_node(&ic->ic_sta, vap, bssid);
1530 if (ni != NULL) {
1531 ni->ni_wdsvap = vap;
1532 IEEE80211_ADDR_COPY(ni->ni_bssid, bssid);
1533 /*
1534 * Inherit any manually configured settings.
1535 */
1536 copy_bss(ni, vap->iv_bss);
1537 ieee80211_node_set_chan(ni, chan);
1538 /* NB: propagate ssid so available to WPA supplicant */
1539 ni->ni_esslen = vap->iv_des_ssid[0].len;
1540 memcpy(ni->ni_essid, vap->iv_des_ssid[0].ssid, ni->ni_esslen);
1541 /* NB: no associd for peer */
1542 /*
1543 * There are no management frames to use to
1544 * discover neighbor capabilities, so blindly
1545 * propagate the local configuration.
1546 */
1547 if (vap->iv_flags & IEEE80211_F_WME)
1549#ifdef IEEE80211_SUPPORT_SUPERG
1550 if (vap->iv_flags & IEEE80211_F_FF)
1552#endif
1553 /* XXX VHT */
1554 if ((ic->ic_htcaps & IEEE80211_HTC_HT) &&
1555 (vap->iv_flags_ht & IEEE80211_FHT_HT)) {
1556 /*
1557 * Device is HT-capable and HT is enabled for
1558 * the vap; setup HT operation. On return
1559 * ni_chan will be adjusted to an HT channel.
1560 */
1562 if (vap->iv_flags_vht & IEEE80211_FVHT_VHT) {
1563 printf("%s: TODO: vht_wds_init\n", __func__);
1564 }
1565 } else {
1566 struct ieee80211_channel *c = ni->ni_chan;
1567 /*
1568 * Force a legacy channel to be used.
1569 */
1572 KASSERT(c != NULL, ("no legacy channel, %u/%x",
1573 ni->ni_chan->ic_freq, ni->ni_chan->ic_flags));
1574 ni->ni_chan = c;
1575 }
1576 }
1577 return ni;
1578}
1579
1580struct ieee80211_node *
1581#ifdef IEEE80211_DEBUG_REFCNT
1582ieee80211_find_node_locked_debug(struct ieee80211_node_table *nt,
1583 const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *func, int line)
1584#else
1586 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1587#endif
1588{
1589 struct ieee80211_node *ni;
1590 int hash;
1591
1593
1594 hash = IEEE80211_NODE_HASH(nt->nt_ic, macaddr);
1595 LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
1596 if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
1597 ieee80211_ref_node(ni); /* mark referenced */
1598#ifdef IEEE80211_DEBUG_REFCNT
1600 "%s (%s:%u) %p<%s> refcnt %d\n", __func__,
1601 func, line,
1602 ni, ether_sprintf(ni->ni_macaddr),
1604#endif
1605 return ni;
1606 }
1607 }
1608 return NULL;
1609}
1610
1611struct ieee80211_node *
1612#ifdef IEEE80211_DEBUG_REFCNT
1613ieee80211_find_node_debug(struct ieee80211_node_table *nt,
1614 const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *func, int line)
1615#else
1617 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1618#endif
1619{
1620 struct ieee80211_node *ni;
1621
1623 ni = ieee80211_find_node_locked(nt, macaddr);
1625 return ni;
1626}
1627
1628struct ieee80211_node *
1629#ifdef IEEE80211_DEBUG_REFCNT
1630ieee80211_find_vap_node_locked_debug(struct ieee80211_node_table *nt,
1631 const struct ieee80211vap *vap,
1632 const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *func, int line)
1633#else
1635 const struct ieee80211vap *vap,
1636 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1637#endif
1638{
1639 struct ieee80211_node *ni;
1640 int hash;
1641
1643
1644 hash = IEEE80211_NODE_HASH(nt->nt_ic, macaddr);
1645 LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) {
1646 if (ni->ni_vap == vap &&
1647 IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
1648 ieee80211_ref_node(ni); /* mark referenced */
1649#ifdef IEEE80211_DEBUG_REFCNT
1651 "%s (%s:%u) %p<%s> refcnt %d\n", __func__,
1652 func, line,
1653 ni, ether_sprintf(ni->ni_macaddr),
1655#endif
1656 return ni;
1657 }
1658 }
1659 return NULL;
1660}
1661
1662struct ieee80211_node *
1663#ifdef IEEE80211_DEBUG_REFCNT
1664ieee80211_find_vap_node_debug(struct ieee80211_node_table *nt,
1665 const struct ieee80211vap *vap,
1666 const uint8_t macaddr[IEEE80211_ADDR_LEN], const char *func, int line)
1667#else
1669 const struct ieee80211vap *vap,
1670 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1671#endif
1672{
1673 struct ieee80211_node *ni;
1674
1676 ni = ieee80211_find_vap_node_locked(nt, vap, macaddr);
1678 return ni;
1679}
1680
1681/*
1682 * Fake up a node; this handles node discovery in adhoc mode.
1683 * Note that for the driver's benefit we we treat this like
1684 * an association so the driver has an opportunity to setup
1685 * it's private state.
1686 */
1687struct ieee80211_node *
1689 const uint8_t macaddr[IEEE80211_ADDR_LEN])
1690{
1691 struct ieee80211_node *ni;
1692
1694 "%s: mac<%s>\n", __func__, ether_sprintf(macaddr));
1695 ni = ieee80211_dup_bss(vap, macaddr);
1696 if (ni != NULL) {
1697 struct ieee80211com *ic = vap->iv_ic;
1698
1699 /* XXX no rate negotiation; just dup */
1700 ni->ni_rates = vap->iv_bss->ni_rates;
1703 if (vap->iv_opmode == IEEE80211_M_AHDEMO) {
1704 /*
1705 * In adhoc demo mode there are no management
1706 * frames to use to discover neighbor capabilities,
1707 * so blindly propagate the local configuration
1708 * so we can do interesting things (e.g. use
1709 * WME to disable ACK's).
1710 */
1711 /*
1712 * XXX TODO: 11n?
1713 */
1714 if (vap->iv_flags & IEEE80211_F_WME)
1716#ifdef IEEE80211_SUPPORT_SUPERG
1717 if (vap->iv_flags & IEEE80211_F_FF)
1719#endif
1720 }
1723
1724 /*
1725 * XXX TODO: 11n? At least 20MHz, at least A-MPDU RX,
1726 * not A-MPDU TX; not 11n rates, etc. We'll cycle
1727 * that after we hear that we can indeed do 11n
1728 * (either by a beacon frame or by a probe response.)
1729 */
1730
1731 /*
1732 * This is the first time we see the node.
1733 */
1734 if (ic->ic_newassoc != NULL)
1735 ic->ic_newassoc(ni, 1);
1736
1737 /*
1738 * Kick off a probe request to the given node;
1739 * we will then use the probe response to update
1740 * 11n/etc configuration state.
1741 *
1742 * XXX TODO: this isn't guaranteed, and until we get
1743 * a probe response, we won't be able to actually
1744 * do anything 802.11n related to the node.
1745 * So if this does indeed work, maybe we should hold
1746 * off on sending responses until we get the probe
1747 * response, or just default to some sensible subset
1748 * of 802.11n behaviour (eg always allow aggregation
1749 * negotiation TO us, but not FROM us, etc) so we
1750 * aren't entirely busted.
1751 */
1752 if (vap->iv_opmode == IEEE80211_M_IBSS) {
1753 ieee80211_send_probereq(ni, /* node */
1754 vap->iv_myaddr, /* SA */
1755 ni->ni_macaddr, /* DA */
1756 vap->iv_bss->ni_bssid, /* BSSID */
1757 vap->iv_bss->ni_essid,
1758 vap->iv_bss->ni_esslen); /* SSID */
1759 }
1760
1761 /* XXX not right for 802.1x/WPA */
1763 }
1764 return ni;
1765}
1766
1767void
1769 const struct ieee80211_frame *wh,
1770 const struct ieee80211_scanparams *sp)
1771{
1772 int do_ht_setup = 0, do_vht_setup = 0;
1773
1774 ni->ni_esslen = sp->ssid[1];
1775 memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]);
1777 memcpy(ni->ni_tstamp.data, sp->tstamp, sizeof(ni->ni_tstamp));
1778 ni->ni_intval = sp->bintval;
1779 ni->ni_capinfo = sp->capinfo;
1780 ni->ni_chan = ni->ni_ic->ic_curchan;
1781 ni->ni_fhdwell = sp->fhdwell;
1782 ni->ni_fhindex = sp->fhindex;
1783 ni->ni_erp = sp->erp;
1784 ni->ni_timoff = sp->timoff;
1785#ifdef IEEE80211_SUPPORT_MESH
1786 if (ni->ni_vap->iv_opmode == IEEE80211_M_MBSS)
1787 ieee80211_mesh_init_neighbor(ni, wh, sp);
1788#endif
1789 if (ieee80211_ies_init(&ni->ni_ies, sp->ies, sp->ies_len)) {
1791 if (ni->ni_ies.wme_ie != NULL)
1793 else
1794 ni->ni_flags &= ~IEEE80211_NODE_QOS;
1795#ifdef IEEE80211_SUPPORT_SUPERG
1796 if (ni->ni_ies.ath_ie != NULL)
1798#endif
1799 if (ni->ni_ies.htcap_ie != NULL)
1801 if (ni->ni_ies.htinfo_ie != NULL)
1803
1804 if (ni->ni_ies.vhtcap_ie != NULL)
1806 if (ni->ni_ies.vhtopmode_ie != NULL)
1808
1809 if ((ni->ni_ies.htcap_ie != NULL) &&
1810 (ni->ni_ies.htinfo_ie != NULL) &&
1812 do_ht_setup = 1;
1813 }
1814
1815 if ((ni->ni_ies.vhtcap_ie != NULL) &&
1816 (ni->ni_ies.vhtopmode_ie != NULL) &&
1818 do_vht_setup = 1;
1819 }
1820 }
1821
1822 /* NB: must be after ni_chan is setup */
1823 ieee80211_setup_rates(ni, sp->rates, sp->xrates,
1826
1827 /*
1828 * If the neighbor is HT compatible, flip that on.
1829 */
1830 if (do_ht_setup) {
1832 "%s: doing HT setup\n", __func__);
1835 ni->ni_ies.htcap_ie,
1836 ni->ni_ies.htinfo_ie);
1837
1838 if (do_vht_setup) {
1840 printf("%s: BSS %6D: 2GHz channel, VHT info; ignoring\n",
1841 __func__,
1842 ni->ni_macaddr,
1843 ":");
1844 } else {
1847 ni->ni_ies.vhtcap_ie,
1848 ni->ni_ies.vhtopmode_ie);
1850 ni->ni_ies.vhtcap_ie,
1851 ni->ni_ies.vhtopmode_ie);
1852 }
1853 }
1854
1855 /*
1856 * Finally do the channel upgrade/change based
1857 * on the HT/VHT configuration.
1858 */
1860 ni->ni_ies.htinfo_ie);
1862 ni->ni_ies.htcap_ie,
1865 ni->ni_ies.htinfo_ie);
1866
1869
1870 /* Reassociate; we're now 11n/11ac */
1871 /*
1872 * XXX TODO: this is the wrong thing to do -
1873 * we're calling it with isnew=1 so the ath(4)
1874 * driver reinitialises the rate tables.
1875 * This "mostly" works for ath(4), but it won't
1876 * be right for firmware devices which allocate
1877 * node states.
1878 *
1879 * So, do we just create a new node and delete
1880 * the old one? Or?
1881 */
1882 if (ni->ni_ic->ic_newassoc)
1883 ni->ni_ic->ic_newassoc(ni, 1);
1884 }
1885}
1886
1887/*
1888 * Do node discovery in adhoc mode on receipt of a beacon
1889 * or probe response frame. Note that for the driver's
1890 * benefit we we treat this like an association so the
1891 * driver has an opportunity to setup it's private state.
1892 */
1893struct ieee80211_node *
1895 const struct ieee80211_frame *wh,
1896 const struct ieee80211_scanparams *sp)
1897{
1898 struct ieee80211_node *ni;
1899
1901 "%s: mac<%s>\n", __func__, ether_sprintf(wh->i_addr2));
1902 ni = ieee80211_dup_bss(vap, wh->i_addr2);/* XXX alloc_node? */
1903 if (ni != NULL) {
1904 struct ieee80211com *ic = vap->iv_ic;
1905
1906 ieee80211_init_neighbor(ni, wh, sp);
1911 if (ic->ic_newassoc != NULL)
1912 ic->ic_newassoc(ni, 1);
1913 /* XXX not right for 802.1x/WPA */
1915 }
1916 return ni;
1917}
1918
1919#define IS_PROBEREQ(wh) \
1920 ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK|IEEE80211_FC0_SUBTYPE_MASK)) \
1921 == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_REQ))
1922#define IS_BCAST_PROBEREQ(wh) \
1923 (IS_PROBEREQ(wh) && IEEE80211_IS_MULTICAST( \
1924 ((const struct ieee80211_frame *)(wh))->i_addr3))
1925
1926static __inline struct ieee80211_node *
1928 const struct ieee80211_frame_min *wh)
1929{
1930 if (IS_BCAST_PROBEREQ(wh))
1931 return NULL; /* spam bcast probe req to all vap's */
1932 return ieee80211_find_node_locked(nt, wh->i_addr2);
1933}
1934
1935/*
1936 * Locate the node for sender, track state, and then pass the
1937 * (referenced) node up to the 802.11 layer for its use. Note
1938 * we can return NULL if the sender is not in the table.
1939 */
1940struct ieee80211_node *
1941#ifdef IEEE80211_DEBUG_REFCNT
1942ieee80211_find_rxnode_debug(struct ieee80211com *ic,
1943 const struct ieee80211_frame_min *wh, const char *func, int line)
1944#else
1946 const struct ieee80211_frame_min *wh)
1947#endif
1948{
1949 struct ieee80211_node_table *nt;
1950 struct ieee80211_node *ni;
1951
1952 nt = &ic->ic_sta;
1954 ni = _find_rxnode(nt, wh);
1956
1957 return ni;
1958}
1959
1960/*
1961 * Like ieee80211_find_rxnode but use the supplied h/w
1962 * key index as a hint to locate the node in the key
1963 * mapping table. If an entry is present at the key
1964 * index we return it; otherwise do a normal lookup and
1965 * update the mapping table if the station has a unicast
1966 * key assigned to it.
1967 */
1968struct ieee80211_node *
1969#ifdef IEEE80211_DEBUG_REFCNT
1970ieee80211_find_rxnode_withkey_debug(struct ieee80211com *ic,
1971 const struct ieee80211_frame_min *wh, ieee80211_keyix keyix,
1972 const char *func, int line)
1973#else
1975 const struct ieee80211_frame_min *wh, ieee80211_keyix keyix)
1976#endif
1977{
1978 struct ieee80211_node_table *nt;
1979 struct ieee80211_node *ni;
1980
1981 nt = &ic->ic_sta;
1983 if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax)
1984 ni = nt->nt_keyixmap[keyix];
1985 else
1986 ni = NULL;
1987 if (ni == NULL) {
1988 ni = _find_rxnode(nt, wh);
1989 if (ni != NULL && nt->nt_keyixmap != NULL) {
1990 /*
1991 * If the station has a unicast key cache slot
1992 * assigned update the key->node mapping table.
1993 */
1994 keyix = ni->ni_ucastkey.wk_rxkeyix;
1995 /* XXX can keyixmap[keyix] != NULL? */
1996 if (keyix < nt->nt_keyixmax &&
1997 nt->nt_keyixmap[keyix] == NULL) {
2000 "%s: add key map entry %p<%s> refcnt %d\n",
2001 __func__, ni, ether_sprintf(ni->ni_macaddr),
2002 ieee80211_node_refcnt(ni)+1);
2003 nt->nt_keyixmap[keyix] = ieee80211_ref_node(ni);
2004 }
2005 }
2006 } else {
2007 if (IS_BCAST_PROBEREQ(wh))
2008 ni = NULL; /* spam bcast probe req to all vap's */
2009 else
2011 }
2013
2014 return ni;
2015}
2016#undef IS_BCAST_PROBEREQ
2017#undef IS_PROBEREQ
2018
2019/*
2020 * Return a reference to the appropriate node for sending
2021 * a data frame. This handles node discovery in adhoc networks.
2022 */
2023struct ieee80211_node *
2024#ifdef IEEE80211_DEBUG_REFCNT
2025ieee80211_find_txnode_debug(struct ieee80211vap *vap,
2026 const uint8_t macaddr[IEEE80211_ADDR_LEN],
2027 const char *func, int line)
2028#else
2030 const uint8_t macaddr[IEEE80211_ADDR_LEN])
2031#endif
2032{
2033 struct ieee80211_node_table *nt = &vap->iv_ic->ic_sta;
2034 struct ieee80211_node *ni;
2035
2036 /*
2037 * The destination address should be in the node table
2038 * unless this is a multicast/broadcast frame. We can
2039 * also optimize station mode operation, all frames go
2040 * to the bss node.
2041 */
2042 /* XXX can't hold lock across dup_bss 'cuz of recursive locking */
2044 if (vap->iv_opmode == IEEE80211_M_STA ||
2045 vap->iv_opmode == IEEE80211_M_WDS ||
2046 IEEE80211_IS_MULTICAST(macaddr))
2047 ni = ieee80211_ref_node(vap->iv_bss);
2048 else
2049 ni = ieee80211_find_node_locked(nt, macaddr);
2051
2052 if (ni == NULL) {
2053 if (vap->iv_opmode == IEEE80211_M_IBSS ||
2054 vap->iv_opmode == IEEE80211_M_AHDEMO) {
2055 /*
2056 * In adhoc mode cons up a node for the destination.
2057 * Note that we need an additional reference for the
2058 * caller to be consistent with
2059 * ieee80211_find_node_locked.
2060 */
2061 /*
2062 * XXX TODO: this doesn't fake up 11n state; we need
2063 * to find another way to get it upgraded.
2064 */
2065 ni = ieee80211_fakeup_adhoc_node(vap, macaddr);
2066 if (ni != NULL)
2067 (void) ieee80211_ref_node(ni);
2068 } else {
2070 "no node, discard frame (%s)", __func__);
2071 vap->iv_stats.is_tx_nonode++;
2072 }
2073 }
2074 return ni;
2075}
2076
2077static void
2079{
2080 struct ieee80211_node_table *nt = ni->ni_table;
2081
2082 /*
2083 * NB: careful about referencing the vap as it may be
2084 * gone if the last reference was held by a driver.
2085 * We know the com will always be present so it's safe
2086 * to use ni_ic below to reclaim resources.
2087 */
2088#if 0
2090 "%s %p<%s> in %s table\n", __func__, ni,
2091 ether_sprintf(ni->ni_macaddr),
2092 nt != NULL ? nt->nt_name : "<gone>");
2093#endif
2094 if (ni->ni_associd != 0) {
2095 struct ieee80211vap *vap = ni->ni_vap;
2096 if (vap->iv_aid_bitmap != NULL)
2097 IEEE80211_AID_CLR(vap, ni->ni_associd);
2098 }
2099 if (nt != NULL)
2100 ieee80211_del_node_nt(nt, ni);
2101 ni->ni_ic->ic_node_free(ni);
2102}
2103
2104/*
2105 * Clear any entry in the unicast key mapping table.
2106 */
2107static int
2109{
2110 ieee80211_keyix keyix;
2111
2112 keyix = ni->ni_ucastkey.wk_rxkeyix;
2113 if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax &&
2114 nt->nt_keyixmap[keyix] == ni) {
2116 "%s: %p<%s> clear key map entry %u\n",
2117 __func__, ni, ether_sprintf(ni->ni_macaddr), keyix);
2118 nt->nt_keyixmap[keyix] = NULL;
2120 return 1;
2121 }
2122
2123 return 0;
2124}
2125
2126void
2127#ifdef IEEE80211_DEBUG_REFCNT
2128ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line)
2129#else
2131#endif
2132{
2133 struct ieee80211_node_table *nt = ni->ni_table;
2134
2135#ifdef IEEE80211_DEBUG_REFCNT
2137 "%s (%s:%u) %p<%s> refcnt %d\n", __func__, func, line, ni,
2138 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni)-1);
2139#endif
2140 if (nt != NULL) {
2142 if (ieee80211_node_dectestref(ni)) {
2143 /*
2144 * Last reference, reclaim state.
2145 */
2147 } else if (ieee80211_node_refcnt(ni) == 1)
2148 if (node_clear_keyixmap(nt, ni))
2151 } else {
2154 }
2155}
2156
2157/*
2158 * Reclaim a unicast key and clear any key cache state.
2159 */
2160int
2162{
2163 struct ieee80211com *ic = ni->ni_ic;
2164 struct ieee80211_node_table *nt = &ic->ic_sta;
2165 struct ieee80211_node *nikey;
2166 ieee80211_keyix keyix;
2167 int isowned, status;
2168
2169 /*
2170 * NB: We must beware of LOR here; deleting the key
2171 * can cause the crypto layer to block traffic updates
2172 * which can generate a LOR against the node table lock;
2173 * grab it here and stash the key index for our use below.
2174 *
2175 * Must also beware of recursion on the node table lock.
2176 * When called from node_cleanup we may already have
2177 * the node table lock held. Unfortunately there's no
2178 * way to separate out this path so we must do this
2179 * conditionally.
2180 */
2181 isowned = IEEE80211_NODE_IS_LOCKED(nt);
2182 if (!isowned)
2184 nikey = NULL;
2185 status = 1; /* NB: success */
2187 keyix = ni->ni_ucastkey.wk_rxkeyix;
2188 status = ieee80211_crypto_delkey(ni->ni_vap, &ni->ni_ucastkey);
2189 if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax) {
2190 nikey = nt->nt_keyixmap[keyix];
2191 nt->nt_keyixmap[keyix] = NULL;
2192 }
2193 }
2194 if (!isowned)
2196
2197 if (nikey != NULL) {
2198 KASSERT(nikey == ni,
2199 ("key map out of sync, ni %p nikey %p", ni, nikey));
2201 "%s: delete key map entry %p<%s> refcnt %d\n",
2202 __func__, ni, ether_sprintf(ni->ni_macaddr),
2203 ieee80211_node_refcnt(ni)-1);
2205 }
2206 return status;
2207}
2208
2209/*
2210 * Reclaim a node. If this is the last reference count then
2211 * do the normal free work. Otherwise remove it from the node
2212 * table and mark it gone by clearing the back-reference.
2213 */
2214static void
2216{
2217
2219
2221 "%s: remove %p<%s> from %s table, refcnt %d\n",
2222 __func__, ni, ether_sprintf(ni->ni_macaddr),
2223 nt->nt_name, ieee80211_node_refcnt(ni)-1);
2224 /*
2225 * Clear any entry in the unicast key mapping table.
2226 * We need to do it here so rx lookups don't find it
2227 * in the mapping table even if it's not in the hash
2228 * table. We cannot depend on the mapping table entry
2229 * being cleared because the node may not be free'd.
2230 */
2231 (void)node_clear_keyixmap(nt, ni);
2232 if (!ieee80211_node_dectestref(ni)) {
2233 /*
2234 * Other references are present, just remove the
2235 * node from the table so it cannot be found. When
2236 * the references are dropped storage will be
2237 * reclaimed.
2238 */
2239 ieee80211_del_node_nt(nt, ni);
2240 } else
2242}
2243
2244/*
2245 * Node table support.
2246 */
2247
2248static void
2250 struct ieee80211_node_table *nt,
2251 const char *name, int inact, int keyixmax)
2252{
2253
2254 nt->nt_ic = ic;
2256 TAILQ_INIT(&nt->nt_node);
2257 nt->nt_count = 0;
2258 nt->nt_name = name;
2259 nt->nt_inact_init = inact;
2260 nt->nt_keyixmax = keyixmax;
2261 if (nt->nt_keyixmax > 0) {
2263 keyixmax * sizeof(struct ieee80211_node *),
2264 M_80211_NODE,
2266 if (nt->nt_keyixmap == NULL)
2267 ic_printf(ic,
2268 "Cannot allocate key index map with %u entries\n",
2269 keyixmax);
2270 } else
2271 nt->nt_keyixmap = NULL;
2272}
2273
2274static void
2276 struct ieee80211vap *match)
2277{
2278 struct ieee80211_node *ni, *next;
2279
2281 TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) {
2282 if (match != NULL && ni->ni_vap != match)
2283 continue;
2284 /* XXX can this happen? if so need's work */
2285 if (ni->ni_associd != 0) {
2286 struct ieee80211vap *vap = ni->ni_vap;
2287
2288 if (vap->iv_auth->ia_node_leave != NULL)
2289 vap->iv_auth->ia_node_leave(ni);
2290 if (vap->iv_aid_bitmap != NULL)
2291 IEEE80211_AID_CLR(vap, ni->ni_associd);
2292 }
2293 ni->ni_wdsvap = NULL; /* clear reference */
2294 node_reclaim(nt, ni);
2295 }
2296 if (match != NULL && match->iv_opmode == IEEE80211_M_WDS) {
2297 /*
2298 * Make a separate pass to clear references to this vap
2299 * held by DWDS entries. They will not be matched above
2300 * because ni_vap will point to the ap vap but we still
2301 * need to clear ni_wdsvap when the WDS vap is destroyed
2302 * and/or reset.
2303 */
2304 TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next)
2305 if (ni->ni_wdsvap == match)
2306 ni->ni_wdsvap = NULL;
2307 }
2309}
2310
2311static void
2313{
2315 if (nt->nt_keyixmap != NULL) {
2316#ifdef DIAGNOSTIC
2317 /* XXX verify all entries are NULL */
2318 int i;
2319 for (i = 0; i < nt->nt_keyixmax; i++)
2320 if (nt->nt_keyixmap[i] != NULL)
2321 printf("%s: %s[%u] still active\n", __func__,
2322 nt->nt_name, i);
2323#endif
2324 IEEE80211_FREE(nt->nt_keyixmap, M_80211_NODE);
2325 nt->nt_keyixmap = NULL;
2326 }
2328}
2329
2330static void
2331timeout_stations(void *arg __unused, struct ieee80211_node *ni)
2332{
2333 struct ieee80211com *ic = ni->ni_ic;
2334 struct ieee80211vap *vap = ni->ni_vap;
2335
2336 /*
2337 * Only process stations when in RUN state. This
2338 * insures, for example, that we don't timeout an
2339 * inactive station during CAC. Note that CSA state
2340 * is actually handled in ieee80211_node_timeout as
2341 * it applies to more than timeout processing.
2342 */
2343 if (vap->iv_state != IEEE80211_S_RUN)
2344 return;
2345 /*
2346 * Ignore entries for which have yet to receive an
2347 * authentication frame. These are transient and
2348 * will be reclaimed when the last reference to them
2349 * goes away (when frame xmits complete).
2350 */
2351 if ((vap->iv_opmode == IEEE80211_M_HOSTAP ||
2352 vap->iv_opmode == IEEE80211_M_STA) &&
2353 (ni->ni_flags & IEEE80211_NODE_AREF) == 0)
2354 return;
2355 /*
2356 * Free fragment if not needed anymore
2357 * (last fragment older than 1s).
2358 * XXX doesn't belong here, move to node_age
2359 */
2360 if (ni->ni_rxfrag[0] != NULL &&
2361 ticks > ni->ni_rxfragstamp + hz) {
2362 m_freem(ni->ni_rxfrag[0]);
2363 ni->ni_rxfrag[0] = NULL;
2364 }
2365 if (ni->ni_inact > 0) {
2366 ni->ni_inact--;
2368 "%s: inact %u inact_reload %u nrates %u",
2369 __func__, ni->ni_inact, ni->ni_inact_reload,
2370 ni->ni_rates.rs_nrates);
2371 }
2372 /*
2373 * Special case ourself; we may be idle for extended periods
2374 * of time and regardless reclaiming our state is wrong.
2375 * XXX run ic_node_age
2376 */
2377 /* XXX before inact decrement? */
2378 if (ni == vap->iv_bss)
2379 return;
2380 if (ni->ni_associd != 0 ||
2381 (vap->iv_opmode == IEEE80211_M_IBSS ||
2382 vap->iv_opmode == IEEE80211_M_AHDEMO)) {
2383 /*
2384 * Age/drain resources held by the station.
2385 */
2386 ic->ic_node_age(ni);
2387 /*
2388 * Probe the station before time it out. We
2389 * send a null data frame which may not be
2390 * universally supported by drivers (need it
2391 * for ps-poll support so it should be...).
2392 *
2393 * XXX don't probe the station unless we've
2394 * received a frame from them (and have
2395 * some idea of the rates they are capable
2396 * of); this will get fixed more properly
2397 * soon with better handling of the rate set.
2398 */
2399 if ((vap->iv_flags_ext & IEEE80211_FEXT_INACT) &&
2400 (0 < ni->ni_inact &&
2401 ni->ni_inact <= vap->iv_inact_probe) &&
2402 ni->ni_rates.rs_nrates != 0) {
2403 IEEE80211_NOTE(vap,
2405 ni, "%s",
2406 "probe station due to inactivity");
2407 /*
2408 * Grab a reference so the node cannot
2409 * be reclaimed before we send the frame.
2410 * ieee80211_send_nulldata understands
2411 * we've done this and reclaims the
2412 * ref for us as needed.
2413 */
2414 /* XXX fix this (not required anymore). */
2416 /* XXX useless */
2418 /* XXX stat? */
2419 return;
2420 }
2421 }
2422 if ((vap->iv_flags_ext & IEEE80211_FEXT_INACT) &&
2423 ni->ni_inact <= 0) {
2424 IEEE80211_NOTE(vap,
2426 "station timed out due to inactivity "
2427 "(refcnt %u)", ieee80211_node_refcnt(ni));
2428 /*
2429 * Send a deauthenticate frame and drop the station.
2430 * This is somewhat complicated due to reference counts
2431 * and locking. At this point a station will typically
2432 * have a reference count of 2. ieee80211_node_leave
2433 * will do a "free" of the node which will drop the
2434 * reference count. But in the meantime a reference
2435 * wil be held by the deauth frame. The actual reclaim
2436 * of the node will happen either after the tx is
2437 * completed or by ieee80211_node_leave.
2438 */
2439 if (ni->ni_associd != 0) {
2443 }
2446 }
2447}
2448
2449/*
2450 * Timeout inactive stations and do related housekeeping.
2451 */
2452static void
2454{
2455 struct ieee80211_node_table *nt = &ic->ic_sta;
2456
2458}
2459
2460/*
2461 * Aggressively reclaim resources. This should be used
2462 * only in a critical situation to reclaim mbuf resources.
2463 */
2464void
2466{
2467 struct ieee80211_node_table *nt = &ic->ic_sta;
2468 struct ieee80211vap *vap;
2469 struct ieee80211_node *ni;
2470
2472 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
2473 /*
2474 * Ignore entries for which have yet to receive an
2475 * authentication frame. These are transient and
2476 * will be reclaimed when the last reference to them
2477 * goes away (when frame xmits complete).
2478 */
2479 vap = ni->ni_vap;
2480 /*
2481 * Only process stations when in RUN state. This
2482 * insures, for example, that we don't timeout an
2483 * inactive station during CAC. Note that CSA state
2484 * is actually handled in ieee80211_node_timeout as
2485 * it applies to more than timeout processing.
2486 */
2487 if (vap->iv_state != IEEE80211_S_RUN)
2488 continue;
2489 /* XXX can vap be NULL? */
2490 if ((vap->iv_opmode == IEEE80211_M_HOSTAP ||
2491 vap->iv_opmode == IEEE80211_M_STA) &&
2492 (ni->ni_flags & IEEE80211_NODE_AREF) == 0)
2493 continue;
2494 /*
2495 * Free fragments.
2496 * XXX doesn't belong here, move to node_drain
2497 */
2498 if (ni->ni_rxfrag[0] != NULL) {
2499 m_freem(ni->ni_rxfrag[0]);
2500 ni->ni_rxfrag[0] = NULL;
2501 }
2502 /*
2503 * Drain resources held by the station.
2504 */
2505 ic->ic_node_drain(ni);
2506 }
2508}
2509
2510/*
2511 * Per-ieee80211vap inactivity timer callback.
2512 */
2513static void
2515{
2516
2518
2522}
2523
2524/*
2525 * Per-ieee80211com inactivity timer callback.
2526 */
2527void
2529{
2530 struct ieee80211com *ic = arg;
2531 struct ieee80211vap *vap;
2532
2533 /*
2534 * Defer timeout processing if a channel switch is pending.
2535 * We typically need to be mute so not doing things that
2536 * might generate frames is good to handle in one place.
2537 * Suppressing the station timeout processing may extend the
2538 * lifetime of inactive stations (by not decrementing their
2539 * idle counters) but this should be ok unless the CSA is
2540 * active for an unusually long time.
2541 */
2542 if ((ic->ic_flags & IEEE80211_F_CSAPENDING) == 0) {
2546
2547 IEEE80211_LOCK(ic);
2548 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
2550 IEEE80211_UNLOCK(ic);
2551 }
2552 callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz,
2554}
2555
2556/*
2557 * The same as ieee80211_iterate_nodes(), but for one vap only.
2558 */
2559int
2561 struct ieee80211vap *vap, ieee80211_iter_func *f, void *arg)
2562{
2563 struct ieee80211_node **ni_arr;
2564 struct ieee80211_node *ni;
2565 size_t size;
2566 int count, i;
2567
2568 /*
2569 * Iterate over the node table and save an array of ref'ed nodes.
2570 *
2571 * This is separated out from calling the actual node function so that
2572 * no LORs will occur.
2573 */
2575 count = nt->nt_count;
2576 size = count * sizeof(struct ieee80211_node *);
2577 ni_arr = (struct ieee80211_node **) IEEE80211_MALLOC(size, M_80211_NODE,
2579 if (ni_arr == NULL) {
2581 return (ENOMEM);
2582 }
2583
2584 i = 0;
2585 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
2586 if (vap != NULL && ni->ni_vap != vap)
2587 continue;
2588 KASSERT(i < count,
2589 ("node array overflow (vap %p, i %d, count %d)\n",
2590 vap, i, count));
2591 ni_arr[i] = ieee80211_ref_node(ni);
2592 i++;
2593 }
2595
2596 for (i = 0; i < count; i++) {
2597 if (ni_arr[i] == NULL) /* end of the list */
2598 break;
2599 (*f)(arg, ni_arr[i]);
2600 /* ieee80211_free_node() locks by itself */
2601 ieee80211_free_node(ni_arr[i]);
2602 }
2603
2604 IEEE80211_FREE(ni_arr, M_80211_NODE);
2605
2606 return (0);
2607}
2608
2609/*
2610 * Just a wrapper, so we don't have to change every ieee80211_iterate_nodes()
2611 * reference in the source.
2612 */
2613void
2615 ieee80211_iter_func *f, void *arg)
2616{
2617 /* XXX no way to pass error to the caller. */
2618 (void) ieee80211_iterate_nodes_vap(nt, NULL, f, arg);
2619}
2620
2621void
2623 struct ieee80211_node *ni)
2624{
2625 printf("%p: mac %s refcnt %d\n", ni,
2626 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni));
2627 printf("\tauthmode %u flags 0x%x\n",
2628 ni->ni_authmode, ni->ni_flags);
2629 printf("\tassocid 0x%x txpower %u vlan %u\n",
2630 ni->ni_associd, ni->ni_txpower, ni->ni_vlan);
2631 printf("\ttxseq %u rxseq %u fragno %u rxfragstamp %u\n",
2635 ni->ni_rxfragstamp);
2636 printf("\trssi %d noise %d intval %u capinfo 0x%x\n",
2637 node_getrssi(ni), ni->ni_noise,
2638 ni->ni_intval, ni->ni_capinfo);
2639 printf("\tbssid %s essid \"%.*s\" channel %u:0x%x\n",
2640 ether_sprintf(ni->ni_bssid),
2641 ni->ni_esslen, ni->ni_essid,
2642 ni->ni_chan->ic_freq, ni->ni_chan->ic_flags);
2643 printf("\tinact %u inact_reload %u txrate %u\n",
2644 ni->ni_inact, ni->ni_inact_reload, ni->ni_txrate);
2645 printf("\thtcap %x htparam %x htctlchan %u ht2ndchan %u\n",
2646 ni->ni_htcap, ni->ni_htparam,
2647 ni->ni_htctlchan, ni->ni_ht2ndchan);
2648 printf("\thtopmode %x htstbc %x htchw %u\n",
2649 ni->ni_htopmode, ni->ni_htstbc, ni->ni_chw);
2650 printf("\tvhtcap %x freq1 %d freq2 %d vhtbasicmcs %x\n",
2651 ni->ni_vhtcap, (int) ni->ni_vht_chan1, (int) ni->ni_vht_chan2,
2652 (int) ni->ni_vht_basicmcs);
2653 /* XXX VHT state */
2654}
2655
2656void
2658{
2661}
2662
2663/*
2664 * Iterate over the VAPs and update their ERP beacon IEs.
2665 *
2666 * Note this must be called from the deferred ERP update task paths.
2667 */
2668void
2670{
2671 struct ieee80211vap *vap;
2672
2674
2675 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
2676 if (vap->iv_opmode == IEEE80211_M_HOSTAP)
2678}
2679
2680/*
2681 * Handle a station joining an 11g network.
2682 */
2683static void
2685{
2686 struct ieee80211com *ic = ni->ni_ic;
2687 struct ieee80211vap *vap = ni->ni_vap;
2688
2690
2691 /*
2692 * Station isn't capable of short slot time. Bump
2693 * the count of long slot time stations and disable
2694 * use of short slot time. Note that the actual switch
2695 * over to long slot time use may not occur until the
2696 * next beacon transmission (per sec. 7.3.1.4 of 11g).
2697 */
2699 vap->iv_longslotsta++;
2701 "station needs long slot time, count %d",
2702 vap->iv_longslotsta);
2703 /*
2704 * XXX TODO: this may need all VAPs checked!
2705 */
2707 /*
2708 * Don't force slot time when switched to turbo
2709 * mode as non-ERP stations won't be present; this
2710 * need only be done when on the normal G channel.
2711 */
2713 }
2714 }
2715 /*
2716 * If the new station is not an ERP station
2717 * then bump the counter and enable protection
2718 * if configured.
2719 */
2720 if (!ieee80211_iserp_rateset(&ni->ni_rates)) {
2721 vap->iv_nonerpsta++;
2723 "station is !ERP, %d non-ERP stations associated",
2724 vap->iv_nonerpsta);
2725 /*
2726 * If station does not support short preamble
2727 * then we must enable use of Barker preamble.
2728 */
2731 "%s", "station needs long preamble");
2733 vap->iv_flags &= ~IEEE80211_F_SHPREAMBLE;
2735 }
2736 /*
2737 * If protection is configured and this is the first
2738 * indication we should use protection, enable it.
2739 */
2740 if (vap->iv_protmode != IEEE80211_PROT_NONE &&
2741 vap->iv_nonerpsta == 1 &&
2742 (vap->iv_flags_ext & IEEE80211_FEXT_NONERP_PR) == 0) {
2744 "%s: enable use of protection\n", __func__);
2747 }
2748 } else
2750}
2751
2752void
2754{
2755 struct ieee80211com *ic = ni->ni_ic;
2756 struct ieee80211vap *vap = ni->ni_vap;
2757 int newassoc;
2758
2759 if (ni->ni_associd == 0) {
2760 uint16_t aid;
2761
2762 KASSERT(vap->iv_aid_bitmap != NULL, ("no aid bitmap"));
2763 /*
2764 * It would be good to search the bitmap
2765 * more efficiently, but this will do for now.
2766 */
2767 for (aid = 1; aid < vap->iv_max_aid; aid++) {
2768 if (!IEEE80211_AID_ISSET(vap, aid))
2769 break;
2770 }
2771 if (aid >= vap->iv_max_aid) {
2774 return;
2775 }
2776 ni->ni_associd = aid | 0xc000;
2777 ni->ni_jointime = time_uptime;
2778 IEEE80211_LOCK(ic);
2779 IEEE80211_AID_SET(vap, ni->ni_associd);
2780 vap->iv_sta_assoc++;
2781
2789 IEEE80211_UNLOCK(ic);
2790
2791 newassoc = 1;
2792 } else
2793 newassoc = 0;
2794
2795 /*
2796 * XXX VHT - should log VHT channel width, etc
2797 */
2799 "station associated at aid %d: %s preamble, %s slot time%s%s%s%s%s%s%s%s%s",
2801 vap->iv_flags & IEEE80211_F_SHPREAMBLE ? "short" : "long",
2802 vap->iv_flags & IEEE80211_F_SHSLOT ? "short" : "long",
2803 vap->iv_flags & IEEE80211_F_USEPROT ? ", protection" : "",
2804 ni->ni_flags & IEEE80211_NODE_QOS ? ", QoS" : "",
2805 /* XXX update for VHT string */
2807 (ni->ni_chw == 40 ? ", HT40" : ", HT20") : "",
2808 ni->ni_flags & IEEE80211_NODE_AMPDU ? " (+AMPDU)" : "",
2809 ni->ni_flags & IEEE80211_NODE_AMSDU ? " (+AMSDU)" : "",
2810 ni->ni_flags & IEEE80211_NODE_MIMO_RTS ? " (+SMPS-DYN)" :
2811 ni->ni_flags & IEEE80211_NODE_MIMO_PS ? " (+SMPS)" : "",
2812 ni->ni_flags & IEEE80211_NODE_RIFS ? " (+RIFS)" : "",
2814 ", fast-frames" : "",
2816 ", turbo" : ""
2817 );
2818
2821 /* give driver a chance to setup state like ni_txrate */
2822 if (ic->ic_newassoc != NULL)
2823 ic->ic_newassoc(ni, newassoc);
2825 /* tell the authenticator about new station */
2826 if (vap->iv_auth->ia_node_join != NULL)
2827 vap->iv_auth->ia_node_join(ni);
2830}
2831
2832static void
2834{
2835 struct ieee80211com *ic = vap->iv_ic;
2836
2837 KASSERT(vap->iv_nonerpsta == 0 &&
2839 ("%d non ERP stations, flags 0x%x", vap->iv_nonerpsta,
2840 vap->iv_flags_ext));
2841
2842 vap->iv_flags &= ~IEEE80211_F_USEPROT;
2843 /* XXX verify mode? */
2844 if (ic->ic_caps & IEEE80211_C_SHPREAMBLE) {
2846 vap->iv_flags &= ~IEEE80211_F_USEBARKER;
2847 }
2850}
2851
2852/*
2853 * Handle a station leaving an 11g network.
2854 */
2855static void
2857{
2858 struct ieee80211com *ic = ni->ni_ic;
2859 struct ieee80211vap *vap = ni->ni_vap;
2860
2862
2864 ("not in 11g, bss %u:0x%x", ic->ic_bsschan->ic_freq,
2865 ic->ic_bsschan->ic_flags));
2866
2867 /*
2868 * If a long slot station do the slot time bookkeeping.
2869 */
2871 KASSERT(vap->iv_longslotsta > 0,
2872 ("bogus long slot station count %d", vap->iv_longslotsta));
2873 vap->iv_longslotsta--;
2875 "long slot time station leaves, count now %d",
2876 vap->iv_longslotsta);
2877 /*
2878 * XXX TODO: this may need all VAPs checked!
2879 */
2880 if (vap->iv_longslotsta == 0) {
2881 /*
2882 * Re-enable use of short slot time if supported
2883 * and not operating in IBSS mode (per spec).
2884 */
2885 if ((ic->ic_caps & IEEE80211_C_SHSLOT) &&
2886 ic->ic_opmode != IEEE80211_M_IBSS) {
2889 "%s: re-enable use of short slot time\n",
2890 __func__);
2892 }
2893 }
2894 }
2895 /*
2896 * If a non-ERP station do the protection-related bookkeeping.
2897 */
2898 if ((ni->ni_flags & IEEE80211_NODE_ERP) == 0) {
2899 KASSERT(vap->iv_nonerpsta > 0,
2900 ("bogus non-ERP station count %d", vap->iv_nonerpsta));
2901 vap->iv_nonerpsta--;
2903 "non-ERP station leaves, count now %d%s", vap->iv_nonerpsta,
2905 " (non-ERP sta present)" : "");
2906 if (vap->iv_nonerpsta == 0 &&
2907 (vap->iv_flags_ext & IEEE80211_FEXT_NONERP_PR) == 0) {
2909 "%s: disable use of protection\n", __func__);
2910 disable_protection(vap);
2911 }
2912 }
2913}
2914
2915/*
2916 * Time out presence of an overlapping bss with non-ERP
2917 * stations. When operating in hostap mode we listen for
2918 * beacons from other stations and if we identify a non-ERP
2919 * station is present we enable protection. To identify
2920 * when all non-ERP stations are gone we time out this
2921 * condition.
2922 */
2923static void
2925{
2926
2928
2932 "%s", "age out non-ERP sta present on channel");
2933 vap->iv_flags_ext &= ~IEEE80211_FEXT_NONERP_PR;
2934 if (vap->iv_nonerpsta == 0)
2935 disable_protection(vap);
2936 }
2937}
2938
2939/*
2940 * Handle bookkeeping for station deauthentication/disassociation
2941 * when operating as an ap.
2942 */
2943void
2945{
2946 struct ieee80211com *ic = ni->ni_ic;
2947 struct ieee80211vap *vap = ni->ni_vap;
2948 struct ieee80211_node_table *nt = ni->ni_table;
2949
2951 "station with aid %d leaves", IEEE80211_NODE_AID(ni));
2952
2953 KASSERT(vap->iv_opmode != IEEE80211_M_STA,
2954 ("unexpected operating mode %u", vap->iv_opmode));
2955 /*
2956 * If node wasn't previously associated all
2957 * we need to do is reclaim the reference.
2958 */
2959 /* XXX ibss mode bypasses 11g and notification */
2960 if (ni->ni_associd == 0)
2961 goto done;
2962 /*
2963 * Tell the authenticator the station is leaving.
2964 * Note that we must do this before yanking the
2965 * association id as the authenticator uses the
2966 * associd to locate it's state block.
2967 */
2968 if (vap->iv_auth->ia_node_leave != NULL)
2969 vap->iv_auth->ia_node_leave(ni);
2970
2971 IEEE80211_LOCK(ic);
2972 IEEE80211_AID_CLR(vap, ni->ni_associd);
2973 vap->iv_sta_assoc--;
2974
2982 IEEE80211_UNLOCK(ic);
2983 /*
2984 * Cleanup station state. In particular clear various
2985 * state that might otherwise be reused if the node
2986 * is reused before the reference count goes to zero
2987 * (and memory is reclaimed).
2988 */
2990done:
2991 /*
2992 * Remove the node from any table it's recorded in and
2993 * drop the caller's reference. Removal from the table
2994 * is important to insure the node is not reprocessed
2995 * for inactivity.
2996 */
2997 if (nt != NULL) {
2999 node_reclaim(nt, ni);
3001 } else
3003}
3004
3005struct rssiinfo {
3007 uint32_t rssi_total;
3008};
3009
3010static void
3011get_hostap_rssi(void *arg, struct ieee80211_node *ni)
3012{
3013 struct rssiinfo *info = arg;
3014 struct ieee80211vap *vap = ni->ni_vap;
3015 int8_t rssi;
3016
3017 /* only associated stations */
3018 if (ni->ni_associd == 0)
3019 return;
3020 rssi = vap->iv_ic->ic_node_getrssi(ni);
3021 if (rssi != 0) {
3022 info->rssi_samples++;
3023 info->rssi_total += rssi;
3024 }
3025}
3026
3027static void
3028get_adhoc_rssi(void *arg, struct ieee80211_node *ni)
3029{
3030 struct rssiinfo *info = arg;
3031 struct ieee80211vap *vap = ni->ni_vap;
3032 int8_t rssi;
3033
3034 /* only neighbors */
3035 /* XXX check bssid */
3036 if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
3037 return;
3038 rssi = vap->iv_ic->ic_node_getrssi(ni);
3039 if (rssi != 0) {
3040 info->rssi_samples++;
3041 info->rssi_total += rssi;
3042 }
3043}
3044
3045#ifdef IEEE80211_SUPPORT_MESH
3046static void
3047get_mesh_rssi(void *arg, struct ieee80211_node *ni)
3048{
3049 struct rssiinfo *info = arg;
3050 struct ieee80211vap *vap = ni->ni_vap;
3051 int8_t rssi;
3052
3053 /* only neighbors that peered successfully */
3055 return;
3056 rssi = vap->iv_ic->ic_node_getrssi(ni);
3057 if (rssi != 0) {
3058 info->rssi_samples++;
3059 info->rssi_total += rssi;
3060 }
3061}
3062#endif /* IEEE80211_SUPPORT_MESH */
3063
3064int8_t
3066{
3067#define NZ(x) ((x) == 0 ? 1 : (x))
3068 struct ieee80211com *ic = vap->iv_ic;
3069 struct rssiinfo info;
3070
3071 info.rssi_total = 0;
3072 info.rssi_samples = 0;
3073 switch (vap->iv_opmode) {
3074 case IEEE80211_M_IBSS: /* average of all ibss neighbors */
3075 case IEEE80211_M_AHDEMO: /* average of all neighbors */
3077 &info);
3078 break;
3079 case IEEE80211_M_HOSTAP: /* average of all associated stations */
3081 &info);
3082 break;
3083#ifdef IEEE80211_SUPPORT_MESH
3084 case IEEE80211_M_MBSS: /* average of all mesh neighbors */
3085 ieee80211_iterate_nodes_vap(&ic->ic_sta, vap, get_mesh_rssi,
3086 &info);
3087 break;
3088#endif
3089 case IEEE80211_M_MONITOR: /* XXX */
3090 case IEEE80211_M_STA: /* use stats from associated ap */
3091 default:
3092 if (vap->iv_bss != NULL)
3093 info.rssi_total = ic->ic_node_getrssi(vap->iv_bss);
3094 info.rssi_samples = 1;
3095 break;
3096 }
3097 return info.rssi_total / NZ(info.rssi_samples);
3098#undef NZ
3099}
3100
3101void
3102ieee80211_getsignal(struct ieee80211vap *vap, int8_t *rssi, int8_t *noise)
3103{
3104
3105 if (vap->iv_bss == NULL) /* NB: shouldn't happen */
3106 return;
3107 vap->iv_ic->ic_node_getsignal(vap->iv_bss, rssi, noise);
3108 /* for non-station mode return avg'd rssi accounting */
3109 if (vap->iv_opmode != IEEE80211_M_STA)
3110 *rssi = ieee80211_getrssi(vap);
3111}
ieee80211_phymode
Definition: _ieee80211.h:61
@ IEEE80211_MODE_11NG
Definition: _ieee80211.h:71
@ IEEE80211_MODE_11NA
Definition: _ieee80211.h:70
@ IEEE80211_MODE_11G
Definition: _ieee80211.h:65
@ IEEE80211_MODE_HALF
Definition: _ieee80211.h:72
@ IEEE80211_MODE_STURBO_A
Definition: _ieee80211.h:69
@ IEEE80211_MODE_VHT_2GHZ
Definition: _ieee80211.h:74
@ IEEE80211_MODE_QUARTER
Definition: _ieee80211.h:73
@ IEEE80211_MODE_11B
Definition: _ieee80211.h:64
@ IEEE80211_MODE_VHT_5GHZ
Definition: _ieee80211.h:75
@ IEEE80211_MODE_11A
Definition: _ieee80211.h:63
#define IEEE80211_C_TDMA
Definition: _ieee80211.h:502
#define IEEE80211_IS_CHAN_108G(_c)
Definition: _ieee80211.h:259
#define IEEE80211_C_SHSLOT
Definition: _ieee80211.h:484
#define IEEE80211_IS_CHAN_HT(_c)
Definition: _ieee80211.h:291
#define IEEE80211_IS_CHAN_CACDONE(_c)
Definition: _ieee80211.h:355
@ IEEE80211_PROT_NONE
Definition: _ieee80211.h:100
#define IEEE80211_CHAN_HT
Definition: _ieee80211.h:202
#define IEEE80211_IS_CHAN_A(_c)
Definition: _ieee80211.h:245
#define IEEE80211_IS_CHAN_B(_c)
Definition: _ieee80211.h:247
#define IEEE80211_AID_MIN
Definition: _ieee80211.h:377
#define IEEE80211_IS_CHAN_HALF(_c)
Definition: _ieee80211.h:283
#define IEEE80211_HTC_HT
Definition: _ieee80211.h:525
#define IEEE80211_MAX_CHAINS
Definition: _ieee80211.h:448
#define IEEE80211_NONQOS_TID
Definition: _ieee80211.h:367
@ IEEE80211_AUTH_OPEN
Definition: _ieee80211.h:114
#define IEEE80211_CHAN_ANYC
Definition: _ieee80211.h:165
#define IEEE80211_IS_CHAN_2GHZ(_c)
Definition: _ieee80211.h:262
#define IEEE80211_AID_DEF
Definition: _ieee80211.h:376
#define IEEE80211_IS_CHAN_FULL(_c)
Definition: _ieee80211.h:287
#define IEEE80211_IS_CHAN_QUARTER(_c)
Definition: _ieee80211.h:285
#define IEEE80211_IS_CHAN_ST(_c)
Definition: _ieee80211.h:255
@ IEEE80211_M_HOSTAP
Definition: _ieee80211.h:90
@ IEEE80211_M_AHDEMO
Definition: _ieee80211.h:89
@ IEEE80211_M_MBSS
Definition: _ieee80211.h:92
@ IEEE80211_M_STA
Definition: _ieee80211.h:87
@ IEEE80211_M_WDS
Definition: _ieee80211.h:88
@ IEEE80211_M_IBSS
Definition: _ieee80211.h:86
@ IEEE80211_M_MONITOR
Definition: _ieee80211.h:91
@ IEEE80211_T_FH
Definition: _ieee80211.h:44
#define IEEE80211_IS_CHAN_VHT(_c)
Definition: _ieee80211.h:316
#define IEEE80211_C_SHPREAMBLE
Definition: _ieee80211.h:485
#define IEEE80211_IS_CHAN_5GHZ(_c)
Definition: _ieee80211.h:264
#define IEEE80211_IS_CHAN_ANYG(_c)
Definition: _ieee80211.h:253
int ic_printf(struct ieee80211com *ic, const char *fmt,...)
Definition: ieee80211.c:278
int ieee80211_chan2ieee(struct ieee80211com *ic, const struct ieee80211_channel *c)
Definition: ieee80211.c:1076
const struct ieee80211_rateset * ieee80211_get_suprates(struct ieee80211com *ic, const struct ieee80211_channel *c)
Definition: ieee80211.c:2016
enum ieee80211_phymode ieee80211_chan2mode(const struct ieee80211_channel *chan)
Definition: ieee80211.c:2302
struct ieee80211_channel * ieee80211_find_channel(struct ieee80211com *ic, int freq, int flags)
Definition: ieee80211.c:1744
char ieee80211_channel_type_char(const struct ieee80211_channel *c)
Definition: ieee80211.c:2626
const struct ieee80211_htrateset * ieee80211_get_suphtrates(struct ieee80211com *ic, const struct ieee80211_channel *c)
Definition: ieee80211.c:2024
#define IEEE80211_CAPINFO_PRIVACY
Definition: ieee80211.h:571
#define IEEE80211_CAPINFO_ESS
Definition: ieee80211.h:567
#define IEEE80211_SEQ_SEQ_SHIFT
Definition: ieee80211.h:206
#define IEEE80211_ADDR_LEN
Definition: ieee80211.h:37
#define IEEE80211_CAPINFO_SHORT_SLOTTIME
Definition: ieee80211.h:577
#define IEEE80211_FC0_SUBTYPE_ASSOC_RESP
Definition: ieee80211.h:128
#define IEEE80211_FC0_SUBTYPE_DEAUTH
Definition: ieee80211.h:138
#define IEEE80211_RATE_VAL
Definition: ieee80211.h:1146
#define IEEE80211_SEQ_FRAG_MASK
Definition: ieee80211.h:203
#define IEEE80211_RATE_BASIC
Definition: ieee80211.h:1145
#define IEEE80211_IS_MULTICAST(_a)
Definition: ieee80211.h:39
#define IEEE80211_CAPINFO_SHORT_PREAMBLE
Definition: ieee80211.h:572
@ IEEE80211_STATUS_TOOMANY
Definition: ieee80211.h:1310
@ IEEE80211_STATUS_SUCCESS
Definition: ieee80211.h:1301
@ IEEE80211_REASON_AUTH_EXPIRE
Definition: ieee80211.h:1254
@ IEEE80211_ELEMID_VENDOR
Definition: ieee80211.h:980
@ IEEE80211_ELEMID_RSN
Definition: ieee80211.h:962
@ IEEE80211_ELEMID_BSSLOAD
Definition: ieee80211.h:943
@ IEEE80211_ELEMID_HTCAP
Definition: ieee80211.h:959
@ IEEE80211_ELEMID_VHT_OPMODE
Definition: ieee80211.h:1013
@ IEEE80211_ELEMID_VHT_PWR_ENV
Definition: ieee80211.h:1014
@ IEEE80211_ELEMID_APCHANREP
Definition: ieee80211.h:964
@ IEEE80211_ELEMID_HTINFO
Definition: ieee80211.h:966
@ IEEE80211_ELEMID_VHT_CAP
Definition: ieee80211.h:1012
@ IEEE80211_ELEMID_MESHID
Definition: ieee80211.h:989
#define IEEE80211_CAPINFO_IBSS
Definition: ieee80211.h:568
void ieee80211_ageq_cleanup(struct ieee80211_ageq *aq)
struct mbuf * ieee80211_ageq_age(struct ieee80211_ageq *aq, int quanta)
void ieee80211_ageq_init(struct ieee80211_ageq *aq, int maxlen, const char *name)
void ieee80211_ageq_drain_node(struct ieee80211_ageq *aq, struct ieee80211_node *ni)
void ieee80211_ageq_drain(struct ieee80211_ageq *aq)
int ieee80211_crypto_delkey(struct ieee80211vap *vap, struct ieee80211_key *key)
uint16_t ieee80211_keyix
static __inline void ieee80211_crypto_resetkey(struct ieee80211vap *vap, struct ieee80211_key *k, ieee80211_keyix ix)
#define IEEE80211_KEYIX_NONE
void ieee80211_dfs_cac_clear(struct ieee80211com *ic, const struct ieee80211_channel *chan)
int ieee80211_node_dectestref(struct ieee80211_node *ni)
void ieee80211_notify_node_join(struct ieee80211_node *ni, int newassoc)
void net80211_get_random_bytes(void *p, size_t n)
void ieee80211_notify_node_leave(struct ieee80211_node *ni)
#define IEEE80211_M_ZERO
#define ieee80211_node_decref(_ni)
#define ieee80211_node_initref(_ni)
#define ieee80211_time_after(a, b)
#define IEEE80211_MALLOC
#define IEEE80211_NODE_LOCK_DESTROY(_nt)
#define IEEE80211_M_NOWAIT
#define IEEE80211_UNLOCK(_ic)
#define IEEE80211_NODE_LOCK_INIT(_nt, _name)
#define IEEE80211_FREE
#define ieee80211_node_refcnt(_ni)
#define IEEE80211_LOCK_ASSERT(_ic)
#define IEEE80211_LOCK(_ic)
#define IEEE80211_NODE_IS_LOCKED(_nt)
#define IEEE80211_NODE_LOCK(_nt)
#define IEEE80211_NODE_UNLOCK(_nt)
#define IEEE80211_NODE_LOCK_ASSERT(_nt)
struct ieee80211_channel * ieee80211_ht_adjust_channel(struct ieee80211com *ic, struct ieee80211_channel *chan, int flags)
void ieee80211_parse_htcap(struct ieee80211_node *ni, const uint8_t *ie)
int ieee80211_ht_updateparams_final(struct ieee80211_node *ni, const uint8_t *htcapie, const uint8_t *htinfoie)
void ieee80211_ht_node_age(struct ieee80211_node *ni)
void ieee80211_ht_node_cleanup(struct ieee80211_node *ni)
void ieee80211_parse_htinfo(struct ieee80211_node *ni, const uint8_t *ie)
void ieee80211_ht_node_init(struct ieee80211_node *ni)
void ieee80211_ht_timeout(struct ieee80211vap *vap)
int ieee80211_setup_htrates(struct ieee80211_node *ni, const uint8_t *ie, int flags)
void ieee80211_setup_basic_htrates(struct ieee80211_node *ni, const uint8_t *ie)
void ieee80211_ht_node_join(struct ieee80211_node *ni)
void ieee80211_ht_updateparams(struct ieee80211_node *ni, const uint8_t *htcapie, const uint8_t *htinfoie)
void ieee80211_ht_wds_init(struct ieee80211_node *ni)
void ieee80211_ht_node_leave(struct ieee80211_node *ni)
int ieee80211_setup_rates(struct ieee80211_node *ni, const uint8_t *rates, const uint8_t *xrates, int flags)
static __inline int iswpaoui(const uint8_t *frm)
static __inline int iswmeoui(const uint8_t *frm)
static __inline int isatherosoui(const uint8_t *frm)
static __inline int istdmaoui(const uint8_t *frm)
void ieee80211_mesh_node_init(struct ieee80211vap *vap, struct ieee80211_node *ni)
void ieee80211_mesh_node_cleanup(struct ieee80211_node *ni)
void ieee80211_parse_meshid(struct ieee80211_node *ni, const uint8_t *ie)
void ieee80211_mesh_init_neighbor(struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_scanparams *sp)
int ieee80211_ibss_merge(struct ieee80211_node *ni)
void ieee80211_node_latevattach(struct ieee80211vap *vap)
#define IEEE80211_AID_SET(_vap, b)
static void node_reclaim(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
void ieee80211_node_set_chan(struct ieee80211_node *ni, struct ieee80211_channel *chan)
struct ieee80211_node * ieee80211_dup_bss(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
void ieee80211_free_node(struct ieee80211_node *ni)
static void ieee80211_node_table_reset(struct ieee80211_node_table *, struct ieee80211vap *)
struct ieee80211_node * ieee80211_fakeup_adhoc_node(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
void ieee80211_node_vdetach(struct ieee80211vap *vap)
void ieee80211_node_vattach(struct ieee80211vap *vap)
static void ieee80211_node_table_cleanup(struct ieee80211_node_table *nt)
static void get_adhoc_rssi(void *arg, struct ieee80211_node *ni)
void ieee80211_node_deauth(struct ieee80211_node *ni, int reason)
void ieee80211_iterate_nodes(struct ieee80211_node_table *nt, ieee80211_iter_func *f, void *arg)
CTASSERT((IEEE80211_NODE_HASHSIZE &(IEEE80211_NODE_HASHSIZE-1))==0)
void ieee80211_reset_bss(struct ieee80211vap *vap)
void ieee80211_node_detach(struct ieee80211com *ic)
int8_t ieee80211_getrssi(struct ieee80211vap *vap)
void ieee80211_node_unauthorize(struct ieee80211_node *ni)
static int node_clear_keyixmap(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
int ieee80211_ibss_merge_check(struct ieee80211_node *ni)
void ieee80211_node_attach(struct ieee80211com *ic)
struct ieee80211_node * ieee80211_find_vap_node(struct ieee80211_node_table *nt, const struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
static int check_bss(struct ieee80211vap *vap, struct ieee80211_node *ni)
static int8_t node_getrssi(const struct ieee80211_node *)
#define IEEE80211_AID_ISSET(_vap, b)
void ieee80211_node_timeout(void *arg)
static int node_init(struct ieee80211_node *)
static void node_getsignal(const struct ieee80211_node *, int8_t *, int8_t *)
static void timeout_stations(void *arg __unused, struct ieee80211_node *ni)
static int gethtadjustflags(struct ieee80211com *ic)
void ieee80211_node_setuptxparms(struct ieee80211_node *ni)
void ieee80211_node_authorize(struct ieee80211_node *ni)
void ieee80211_node_join(struct ieee80211_node *ni, int resp)
void ieee80211_init_neighbor(struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_scanparams *sp)
struct ieee80211_node * ieee80211_find_node_locked(struct ieee80211_node_table *nt, const uint8_t macaddr[IEEE80211_ADDR_LEN])
void ieee80211_ies_cleanup(struct ieee80211_ies *ies)
static void ieee80211_node_join_11g(struct ieee80211_node *ni)
void ieee80211_dump_node(struct ieee80211_node_table *nt __unused, struct ieee80211_node *ni)
__FBSDID("$FreeBSD$")
static void node_cleanup(struct ieee80211_node *)
static void ieee80211_node_table_init(struct ieee80211com *ic, struct ieee80211_node_table *nt, const char *name, int inact, int keymaxix)
void ieee80211_dump_nodes(struct ieee80211_node_table *nt)
struct ieee80211_node * ieee80211_alloc_node(struct ieee80211_node_table *nt, struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
static int match_ssid(const struct ieee80211_node *ni, int nssid, const struct ieee80211_scan_ssid ssids[])
void ieee80211_ies_expand(struct ieee80211_ies *ies)
void ieee80211_sta_leave(struct ieee80211_node *ni)
static void ieee80211_node_leave_11g(struct ieee80211_node *ni)
struct ieee80211_node * ieee80211_find_rxnode(struct ieee80211com *ic, const struct ieee80211_frame_min *wh)
static void ieee80211_vap_erp_timeout(struct ieee80211vap *)
int ieee80211_ies_init(struct ieee80211_ies *ies, const uint8_t *data, int len)
void ieee80211_setcurchan(struct ieee80211com *ic, struct ieee80211_channel *c)
static struct ieee80211_node * node_alloc(struct ieee80211vap *, const uint8_t[IEEE80211_ADDR_LEN])
#define IS_BCAST_PROBEREQ(wh)
void ieee80211_update_chw(struct ieee80211com *ic)
void ieee80211_notify_erp_locked(struct ieee80211com *ic)
static void node_free(struct ieee80211_node *)
void ieee80211_node_leave(struct ieee80211_node *ni)
static __inline struct ieee80211_node * _find_rxnode(struct ieee80211_node_table *nt, const struct ieee80211_frame_min *wh)
#define NZ(x)
struct ieee80211_node * ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *wh, const struct ieee80211_scanparams *sp)
int ieee80211_node_delucastkey(struct ieee80211_node *ni)
static void ieee80211_del_node_nt(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
static __inline void copy_bss(struct ieee80211_node *nbss, const struct ieee80211_node *obss)
void ieee80211_setupcurchan(struct ieee80211com *ic, struct ieee80211_channel *c)
void ieee80211_getsignal(struct ieee80211vap *vap, int8_t *rssi, int8_t *noise)
void ieee80211_drain(struct ieee80211com *ic)
static void node_getmimoinfo(const struct ieee80211_node *, struct ieee80211_mimo_info *)
struct ieee80211_node * ieee80211_find_txnode(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
int ieee80211_ibss_node_check_new(struct ieee80211_node *ni, const struct ieee80211_scanparams *scan)
struct ieee80211_node * ieee80211_find_node(struct ieee80211_node_table *nt, const uint8_t macaddr[IEEE80211_ADDR_LEN])
static void ieee80211_timeout_stations(struct ieee80211com *ic)
int ieee80211_iterate_nodes_vap(struct ieee80211_node_table *nt, struct ieee80211vap *vap, ieee80211_iter_func *f, void *arg)
struct ieee80211_node * ieee80211_find_rxnode_withkey(struct ieee80211com *ic, const struct ieee80211_frame_min *wh, ieee80211_keyix keyix)
struct ieee80211_node * ieee80211_tmp_node(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
void ieee80211_create_ibss(struct ieee80211vap *vap, struct ieee80211_channel *chan)
static void node_age(struct ieee80211_node *)
int ieee80211_sta_join(struct ieee80211vap *vap, struct ieee80211_channel *chan, const struct ieee80211_scan_entry *se)
void ieee80211_sync_curchan(struct ieee80211com *ic)
struct ieee80211_node * ieee80211_node_create_wds(struct ieee80211vap *vap, const uint8_t bssid[IEEE80211_ADDR_LEN], struct ieee80211_channel *chan)
static void get_hostap_rssi(void *arg, struct ieee80211_node *ni)
#define IEEE80211_AID_CLR(_vap, b)
static void _ieee80211_free_node(struct ieee80211_node *)
static void ieee80211_vap_timeout(struct ieee80211vap *vap)
MALLOC_DEFINE(M_80211_NODE, "80211node", "802.11 node state")
static int ieee80211_sta_join1(struct ieee80211_node *)
struct ieee80211_node * ieee80211_find_vap_node_locked(struct ieee80211_node_table *nt, const struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
static void disable_protection(struct ieee80211vap *vap)
static void ieee80211_add_node_nt(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
static int getvhtadjustflags(struct ieee80211com *ic)
#define IEEE80211_NODE_HASH(ic, addr)
#define IEEE80211_INACT_RUN
#define IEEE80211_INACT_AUTH
#define IEEE80211_RSSI_LPF(x, y)
#define IEEE80211_NODE_TURBOP
void ieee80211_iter_func(void *, struct ieee80211_node *)
#define IEEE80211_NODE_HASHSIZE
#define IEEE80211_INACT_PROBE
#define IEEE80211_INACT_WAIT
#define IEEE80211_NODE_ASSOCID
#define IEEE80211_NODE_FF
#define IEEE80211_NODE_AUTH
#define IEEE80211_NODE_MIMO_RTS
#define IEEE80211_NODE_AMSDU
#define IEEE80211_NODE_QOS
#define IEEE80211_NODE_PWR_MGT
#define IEEE80211_NODE_AID(ni)
#define IEEE80211_NODE_MIMO_PS
#define IEEE80211_RSSI_DUMMY_MARKER
#define IEEE80211_NODE_RIFS
static __inline struct ieee80211_node * ieee80211_ref_node(struct ieee80211_node *ni)
@ IEEE80211_NODE_MESH_ESTABLISHED
#define IEEE80211_NODE_ERP
#define IEEE80211_NONERP_PRESENT_AGE
#define IEEE80211_NODE_AMPDU
#define IEEE80211_NODE_HT
#define IEEE80211_NODE_AREF
#define IEEE80211_NODE_VHT
#define IEEE80211_INACT_INIT
#define IEEE80211_RSSI_GET(x)
int ieee80211_send_probereq(struct ieee80211_node *ni, const uint8_t sa[IEEE80211_ADDR_LEN], const uint8_t da[IEEE80211_ADDR_LEN], const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t *ssid, size_t ssidlen)
int ieee80211_send_nulldata(struct ieee80211_node *ni)
const struct ieee80211_rate_table * ieee80211_get_ratetable(struct ieee80211_channel *c)
void ieee80211_psq_cleanup(struct ieee80211_psq *psq)
int ieee80211_node_psq_drain(struct ieee80211_node *ni)
void ieee80211_psq_init(struct ieee80211_psq *psq, const char *name)
int ieee80211_node_psq_age(struct ieee80211_node *ni)
const struct ieee80211_authenticator * ieee80211_authenticator_get(int auth)
void ieee80211_addbasicrates(struct ieee80211_rateset *rs, enum ieee80211_phymode mode)
void ieee80211_setbasicrates(struct ieee80211_rateset *rs, enum ieee80211_phymode mode)
void ieee80211_vap_update_preamble(struct ieee80211vap *vap)
void ieee80211_print_essid(const uint8_t *essid, int len)
int ieee80211_iserp_rateset(const struct ieee80211_rateset *rs)
int ieee80211_new_state(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
void ieee80211_vap_update_erp_protmode(struct ieee80211vap *vap)
int ieee80211_fix_rate(struct ieee80211_node *ni, struct ieee80211_rateset *nrs, int flags)
void ieee80211_vap_reset_erp(struct ieee80211vap *vap)
void ieee80211_vap_set_shortslottime(struct ieee80211vap *vap, int onoff)
void ieee80211_wme_initparams(struct ieee80211vap *vap)
const char * ieee80211_opmode_name[IEEE80211_OPMODE_MAX]
#define IEEE80211_F_DODEL
#define IEEE80211_F_DONEGO
#define IEEE80211_F_DOBRS
@ IEEE80211_S_RUN
@ IEEE80211_S_AUTH
@ IEEE80211_S_ASSOC
#define IEEE80211_F_DOSORT
#define IEEE80211_F_JOIN
@ IEEE80211_BEACON_ERP
#define IEEE80211_SEND_MGMT(_ni, _type, _arg)
#define IEEE80211_F_DOFRATE
void ieee80211_radiotap_chan_change(struct ieee80211com *ic)
static __inline void ieee80211_ratectl_node_deinit(struct ieee80211_node *ni)
static __inline void ieee80211_ratectl_node_init(struct ieee80211_node *ni)
void ieee80211_scan_timeout(struct ieee80211com *ic)
void ieee80211_ff_node_cleanup(struct ieee80211_node *)
void ieee80211_parse_ath(struct ieee80211_node *, uint8_t *)
void ieee80211_parse_tdma(struct ieee80211_node *ni, const uint8_t *ie)
#define IEEE80211_MSG_AUTH
#define IEEE80211_ADDR_COPY(dst, src)
#define IEEE80211_F_PUREG
#define IEEE80211_F_DESBSSID
#define IEEE80211_MSG_OUTPUT
#define IEEE80211_F_WME
#define IEEE80211_FEXT_NONERP_PR
#define IEEE80211_FHT_HT
#define IEEE80211_MSG_SCAN
#define IEEE80211_MSG_INACT
#define IEEE80211_F_USEBARKER
#define IEEE80211_F_SHPREAMBLE
#define IEEE80211_F_FF
#define IEEE80211_FHT_PUREN
static __inline int ieee80211_htchanflags(const struct ieee80211_channel *c)
#define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt,...)
#define IEEE80211_F_CSAPENDING
static __inline int ieee80211_vhtchanflags(const struct ieee80211_channel *c)
#define IEEE80211_MSG_NODE
#define IEEE80211_ADDR_EQ(a1, a2)
#define IEEE80211_F_PRIVACY
#define IEEE80211_FEXT_INACT
#define IEEE80211_MSG_DEBUG
#define IEEE80211_NOTE(_vap, _m, _ni, _fmt,...)
#define IEEE80211_FVHT_VHT
#define IEEE80211_MSG_POWER
#define IEEE80211_F_USEPROT
static __inline void ieee80211_runtask(struct ieee80211com *ic, struct task *task)
#define IEEE80211_DPRINTF(_vap, _m, _fmt,...)
#define IEEE80211_ATH_CAP(vap, ni, bit)
#define IEEE80211_F_SHSLOT
static __inline void ieee80211_beacon_notify(struct ieee80211vap *vap, int what)
#define IEEE80211_MSG_ASSOC
void ieee80211_vht_node_init(struct ieee80211_node *ni)
void ieee80211_vht_timeout(struct ieee80211vap *vap)
void ieee80211_vht_node_join(struct ieee80211_node *ni)
void ieee80211_setup_vht_rates(struct ieee80211_node *ni, const uint8_t *vhtcap_ie, const uint8_t *vhtop_ie)
void ieee80211_parse_vhtopmode(struct ieee80211_node *ni, const uint8_t *ie)
int ieee80211_vht_updateparams(struct ieee80211_node *ni, const uint8_t *vhtcap_ie, const uint8_t *vhtop_ie)
void ieee80211_parse_vhtcap(struct ieee80211_node *ni, const uint8_t *ie)
void ieee80211_vht_node_leave(struct ieee80211_node *ni)
void ieee80211_vht_node_cleanup(struct ieee80211_node *ni)
struct ieee80211_channel * ieee80211_vht_adjust_channel(struct ieee80211com *ic, struct ieee80211_channel *chan, int flags)
void(* ia_node_join)(struct ieee80211_node *)
void(* ia_node_leave)(struct ieee80211_node *)
uint32_t ic_flags
Definition: _ieee80211.h:141
uint16_t ic_freq
Definition: _ieee80211.h:142
uint8_t i_addr2[IEEE80211_ADDR_LEN]
Definition: ieee80211.h:498
uint8_t i_addr2[IEEE80211_ADDR_LEN]
Definition: ieee80211.h:71
uint8_t i_addr3[IEEE80211_ADDR_LEN]
Definition: ieee80211.h:72
uint8_t * bssload_ie
uint8_t * htinfo_ie
uint8_t * tdma_ie
uint8_t * apchanrep_ie
uint8_t * vhtcap_ie
uint8_t * ath_ie
uint8_t * wpa_ie
uint8_t * meshid_ie
uint8_t * htcap_ie
uint8_t * vhtopmode_ie
uint8_t * vhtpwrenv_ie
uint8_t * wme_ie
uint8_t * data
uint8_t * rsn_ie
ieee80211_keyix wk_keyix
ieee80211_keyix wk_rxkeyix
uint8_t ms_id[IEEE80211_MESHID_LEN]
int8_t rssi[IEEE80211_MAX_CHAIN_PRISEC]
Definition: _ieee80211.h:461
int8_t noise[IEEE80211_MAX_CHAIN_PRISEC]
Definition: _ieee80211.h:462
struct ieee80211_mimo_chan_info ch[IEEE80211_MAX_CHAINS]
Definition: _ieee80211.h:466
struct ieee80211com * nt_ic
struct ieee80211_node ** nt_keyixmap
uint16_t ni_timoff
uint32_t * ni_challenge
struct ieee80211_psq ni_psq
uint8_t ni_meshid[IEEE80211_MESHID_LEN]
uint8_t ni_meshidlen
uint8_t ni_mimo_noise_ctl[IEEE80211_MAX_CHAINS]
struct ieee80211_rateset ni_rates
struct ieee80211com * ni_ic
uint8_t ni_macaddr[IEEE80211_ADDR_LEN]
struct ieee80211_node_table * ni_table
uint8_t ni_ht2ndchan
struct ieee80211_htrateset ni_htrates
uint8_t ni_bssid[IEEE80211_ADDR_LEN]
uint16_t ni_ath_defkeyix
struct ieee80211_key ni_ucastkey
struct ieee80211vap * ni_vap
const struct ieee80211_txparam * ni_txparms
uint8_t ni_vht_chan2
uint32_t ni_jointime
uint16_t ni_intval
uint16_t ni_capinfo
ieee80211_seq ni_rxseqs[IEEE80211_TID_SIZE]
uint16_t ni_vht_basicmcs
uint8_t ni_mimo_chains
uint8_t data[8]
enum ieee80211_mesh_mlstate ni_mlstate
uint8_t ni_htctlchan
struct ieee80211vap * ni_wdsvap
union ieee80211_node::@24 ni_tstamp
struct mbuf * ni_rxfrag[3]
ieee80211_seq ni_txseqs[IEEE80211_TID_SIZE]
uint32_t ni_avgrssi
struct ieee80211_ies ni_ies
uint16_t ni_fhdwell
uint8_t ni_vht_chan1
uint32_t ni_mimo_rssi_ctl[IEEE80211_MAX_CHAINS]
struct ieee80211_channel * ni_chan
uint32_t ni_rxfragstamp
uint16_t ni_txpower
uint16_t ni_associd
uint8_t ni_essid[IEEE80211_NWID_LEN]
uint32_t ni_vhtcap
uint8_t se_xrates[2+IEEE80211_RATE_MAXSIZE]
struct ieee80211_ies se_ies
uint16_t se_erp
uint8_t se_ssid[2+IEEE80211_NWID_LEN]
uint8_t se_dtimperiod
uint16_t se_capinfo
uint16_t se_intval
uint16_t se_timoff
uint8_t se_bssid[IEEE80211_ADDR_LEN]
uint8_t se_fhindex
uint8_t se_macaddr[IEEE80211_ADDR_LEN]
uint16_t se_fhdwell
union ieee80211_scan_entry::@29 se_tstamp
int8_t se_rssi
u_int64_t tsf
uint8_t se_rates[2+IEEE80211_RATE_MAXSIZE]
int8_t se_noise
uint8_t ssid[IEEE80211_NWID_LEN]
uint32_t is_rx_nodealloc
uint32_t is_node_timeout
uint32_t is_ibss_capmismatch
struct ieee80211_channel * ic_bsschan
void(* ic_node_getsignal)(const struct ieee80211_node *, int8_t *, int8_t *)
void(* ic_node_age)(struct ieee80211_node *)
enum ieee80211_opmode ic_opmode
uint16_t ic_bintval
uint16_t ic_txpowlimit
const char * ic_name
void(* ic_node_cleanup)(struct ieee80211_node *)
uint32_t ic_flags_ext
uint32_t ic_flags
int(* ic_node_init)(struct ieee80211_node *)
uint32_t ic_vhtcaps
uint8_t ic_curmode
uint32_t ic_htcaps
void(* ic_node_drain)(struct ieee80211_node *)
struct ieee80211_node *(* ic_node_alloc)(struct ieee80211vap *, const uint8_t[IEEE80211_ADDR_LEN])
struct ieee80211_node_table ic_sta
int8_t(* ic_node_getrssi)(const struct ieee80211_node *)
struct ieee80211_ageq ic_stageq
void(* ic_node_free)(struct ieee80211_node *)
struct task ic_chw_task
const struct ieee80211_rate_table * ic_rt
enum ieee80211_phytype ic_phytype
void(* ic_node_getmimoinfo)(const struct ieee80211_node *, struct ieee80211_mimo_info *)
uint8_t ic_chan_active[IEEE80211_CHAN_BYTES]
struct task ic_chan_task
uint32_t ic_caps
void(* ic_set_channel)(struct ieee80211com *)
struct ieee80211_channel * ic_curchan
struct callout ic_inact
void(* ic_newassoc)(struct ieee80211_node *, int)
struct ieee80211com * iv_ic
uint16_t iv_nonerpsta
struct ieee80211_node * iv_bss
enum ieee80211_opmode iv_opmode
enum ieee80211_protmode iv_protmode
uint8_t iv_myaddr[IEEE80211_ADDR_LEN]
uint32_t iv_flags_ht
uint16_t iv_sta_assoc
struct ieee80211_stats iv_stats
uint16_t iv_ps_sta
struct ieee80211_mesh_state * iv_mesh
int(* iv_set_tim)(struct ieee80211_node *, int)
const struct ieee80211_authenticator * iv_auth
uint8_t iv_dtim_count
uint32_t iv_caps
uint32_t iv_flags
uint32_t iv_flags_vht
uint32_t iv_flags_ext
uint8_t iv_des_bssid[IEEE80211_ADDR_LEN]
enum ieee80211_state iv_state
struct ieee80211_txparam iv_txparms[IEEE80211_MODE_MAX]
uint8_t iv_dtim_period
struct ifnet * iv_ifp
struct ieee80211_scan_ssid iv_des_ssid[1]
uint16_t iv_longslotsta
uint16_t iv_max_aid
uint32_t * iv_aid_bitmap
uint32_t rssi_total