ieee80211_node.c revision 121180
1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * Alternatively, this software may be distributed under the terms of the 18 * GNU General Public License ("GPL") version 2 as published by the Free 19 * Software Foundation. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> 34__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 121180 2003-10-17 23:15:30Z sam $"); 35 36#include "opt_inet.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/mbuf.h> 41#include <sys/malloc.h> 42#include <sys/kernel.h> 43#include <sys/socket.h> 44#include <sys/sockio.h> 45#include <sys/endian.h> 46#include <sys/errno.h> 47#include <sys/bus.h> 48#include <sys/proc.h> 49#include <sys/sysctl.h> 50 51#include <machine/atomic.h> 52 53#include <net/if.h> 54#include <net/if_dl.h> 55#include <net/if_media.h> 56#include <net/if_arp.h> 57#include <net/ethernet.h> 58#include <net/if_llc.h> 59 60#include <net80211/ieee80211_var.h> 61 62#include <net/bpf.h> 63 64#ifdef INET 65#include <netinet/in.h> 66#include <netinet/if_ether.h> 67#endif 68 69static struct ieee80211_node *ieee80211_node_alloc(struct ieee80211com *); 70static void ieee80211_node_free(struct ieee80211com *, struct ieee80211_node *); 71static void ieee80211_node_copy(struct ieee80211com *, 72 struct ieee80211_node *, const struct ieee80211_node *); 73static u_int8_t ieee80211_node_getrssi(struct ieee80211com *, 74 struct ieee80211_node *); 75 76static void ieee80211_setup_node(struct ieee80211com *ic, 77 struct ieee80211_node *ni, u_int8_t *macaddr); 78static void _ieee80211_free_node(struct ieee80211com *, 79 struct ieee80211_node *); 80 81MALLOC_DEFINE(M_80211_NODE, "node", "802.11 node state"); 82 83void 84ieee80211_node_attach(struct ifnet *ifp) 85{ 86 struct ieee80211com *ic = (void *)ifp; 87 88 /* XXX need unit */ 89 IEEE80211_NODE_LOCK_INIT(ic, ifp->if_name); 90 TAILQ_INIT(&ic->ic_node); 91 ic->ic_node_alloc = ieee80211_node_alloc; 92 ic->ic_node_free = ieee80211_node_free; 93 ic->ic_node_copy = ieee80211_node_copy; 94 ic->ic_node_getrssi = ieee80211_node_getrssi; 95 ic->ic_scangen = 1; 96} 97 98void 99ieee80211_node_lateattach(struct ifnet *ifp) 100{ 101 struct ieee80211com *ic = (void *)ifp; 102 103 ic->ic_bss = (*ic->ic_node_alloc)(ic); 104 KASSERT(ic->ic_bss != NULL, ("unable to setup inital BSS node")); 105 ic->ic_bss->ni_chan = IEEE80211_CHAN_ANYC; 106} 107 108void 109ieee80211_node_detach(struct ifnet *ifp) 110{ 111 struct ieee80211com *ic = (void *)ifp; 112 113 if (ic->ic_bss != NULL) 114 (*ic->ic_node_free)(ic, ic->ic_bss); 115 ieee80211_free_allnodes(ic); 116 IEEE80211_NODE_LOCK_DESTROY(ic); 117} 118 119/* 120 * AP scanning support. 121 */ 122 123/* 124 * Initialize the active channel set based on the set 125 * of available channels and the current PHY mode. 126 */ 127static void 128ieee80211_reset_scan(struct ifnet *ifp) 129{ 130 struct ieee80211com *ic = (void *)ifp; 131 132 memcpy(ic->ic_chan_scan, ic->ic_chan_active, 133 sizeof(ic->ic_chan_active)); 134 /* NB: hack, setup so next_scan starts with the first channel */ 135 if (ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC) 136 ic->ic_bss->ni_chan = &ic->ic_channels[IEEE80211_CHAN_MAX]; 137} 138 139/* 140 * Begin an active scan. 141 */ 142void 143ieee80211_begin_scan(struct ifnet *ifp) 144{ 145 struct ieee80211com *ic = (void *)ifp; 146 147 /* 148 * In all but hostap mode scanning starts off in 149 * an active mode before switching to passive. 150 */ 151 if (ic->ic_opmode != IEEE80211_M_HOSTAP) { 152 ic->ic_flags |= IEEE80211_F_ASCAN; 153 ic->ic_stats.is_scan_active++; 154 } else 155 ic->ic_stats.is_scan_passive++; 156 if (ifp->if_flags & IFF_DEBUG) 157 if_printf(ifp, "begin %s scan\n", 158 (ic->ic_flags & IEEE80211_F_ASCAN) ? 159 "active" : "passive"); 160 /* 161 * Clear scan state and flush any previously seen 162 * AP's. Note that the latter assumes we don't act 163 * as both an AP and a station, otherwise we'll 164 * potentially flush state of stations associated 165 * with us. 166 */ 167 ieee80211_reset_scan(ifp); 168 ieee80211_free_allnodes(ic); 169 170 /* Scan the next channel. */ 171 ieee80211_next_scan(ifp); 172} 173 174/* 175 * Switch to the next channel marked for scanning. 176 */ 177void 178ieee80211_next_scan(struct ifnet *ifp) 179{ 180 struct ieee80211com *ic = (void *)ifp; 181 struct ieee80211_channel *chan; 182 183 chan = ic->ic_bss->ni_chan; 184 for (;;) { 185 if (++chan > &ic->ic_channels[IEEE80211_CHAN_MAX]) 186 chan = &ic->ic_channels[0]; 187 if (isset(ic->ic_chan_scan, ieee80211_chan2ieee(ic, chan))) { 188 /* 189 * Honor channels marked passive-only 190 * during an active scan. 191 */ 192 if ((ic->ic_flags & IEEE80211_F_ASCAN) == 0 || 193 (chan->ic_flags & IEEE80211_CHAN_PASSIVE) == 0) 194 break; 195 } 196 if (chan == ic->ic_bss->ni_chan) { 197 ieee80211_end_scan(ifp); 198 return; 199 } 200 } 201 clrbit(ic->ic_chan_scan, ieee80211_chan2ieee(ic, chan)); 202 IEEE80211_DPRINTF(("ieee80211_next_scan: chan %d->%d\n", 203 ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan), 204 ieee80211_chan2ieee(ic, chan))); 205 ic->ic_bss->ni_chan = chan; 206 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); 207} 208 209void 210ieee80211_create_ibss(struct ieee80211com* ic, struct ieee80211_channel *chan) 211{ 212 struct ieee80211_node *ni; 213 struct ifnet *ifp = &ic->ic_if; 214 215 ni = ic->ic_bss; 216 if (ifp->if_flags & IFF_DEBUG) 217 if_printf(ifp, "creating ibss\n"); 218 ic->ic_flags |= IEEE80211_F_SIBSS; 219 ni->ni_chan = chan; 220 ni->ni_rates = ic->ic_sup_rates[ieee80211_chan2mode(ic, ni->ni_chan)]; 221 IEEE80211_ADDR_COPY(ni->ni_macaddr, ic->ic_myaddr); 222 IEEE80211_ADDR_COPY(ni->ni_bssid, ic->ic_myaddr); 223 if (ic->ic_opmode == IEEE80211_M_IBSS) 224 ni->ni_bssid[0] |= 0x02; /* local bit for IBSS */ 225 ni->ni_esslen = ic->ic_des_esslen; 226 memcpy(ni->ni_essid, ic->ic_des_essid, ni->ni_esslen); 227 ni->ni_rssi = 0; 228 ni->ni_rstamp = 0; 229 memset(ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); 230 ni->ni_intval = ic->ic_lintval; 231 ni->ni_capinfo = IEEE80211_CAPINFO_IBSS; 232 if (ic->ic_flags & IEEE80211_F_WEPON) 233 ni->ni_capinfo |= IEEE80211_CAPINFO_PRIVACY; 234 if (ic->ic_phytype == IEEE80211_T_FH) { 235 ni->ni_fhdwell = 200; /* XXX */ 236 ni->ni_fhindex = 1; 237 } 238 ieee80211_new_state(ic, IEEE80211_S_RUN, -1); 239} 240 241/* 242 * Complete a scan of potential channels. 243 */ 244void 245ieee80211_end_scan(struct ifnet *ifp) 246{ 247 struct ieee80211com *ic = (void *)ifp; 248 struct ieee80211_node *ni, *nextbs, *selbs; 249 u_int8_t rate; 250 int i, fail; 251 252 ic->ic_flags &= ~IEEE80211_F_ASCAN; 253 ni = TAILQ_FIRST(&ic->ic_node); 254 255 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 256 /* XXX off stack? */ 257 u_char occupied[roundup(IEEE80211_CHAN_MAX, NBBY)]; 258 /* 259 * The passive scan to look for existing AP's completed, 260 * select a channel to camp on. Identify the channels 261 * that already have one or more AP's and try to locate 262 * an unnoccupied one. If that fails, pick a random 263 * channel from the active set. 264 */ 265 for (; ni != NULL; ni = nextbs) { 266 ieee80211_ref_node(ni); 267 nextbs = TAILQ_NEXT(ni, ni_list); 268 setbit(occupied, ieee80211_chan2ieee(ic, ni->ni_chan)); 269 ieee80211_free_node(ic, ni); 270 } 271 for (i = 0; i < IEEE80211_CHAN_MAX; i++) 272 if (isset(ic->ic_chan_active, i) && isclr(occupied, i)) 273 break; 274 if (i == IEEE80211_CHAN_MAX) { 275 fail = arc4random() & 3; /* random 0-3 */ 276 for (i = 0; i < IEEE80211_CHAN_MAX; i++) 277 if (isset(ic->ic_chan_active, i) && fail-- == 0) 278 break; 279 } 280 ieee80211_create_ibss(ic, &ic->ic_channels[i]); 281 return; 282 } 283 if (ni == NULL) { 284 IEEE80211_DPRINTF(("%s: no scan candidate\n", __func__)); 285 notfound: 286 if (ic->ic_opmode == IEEE80211_M_IBSS && 287 (ic->ic_flags & IEEE80211_F_IBSSON) && 288 ic->ic_des_esslen != 0) { 289 ieee80211_create_ibss(ic, ic->ic_ibss_chan); 290 return; 291 } 292 /* 293 * Reset the list of channels to scan and start again. 294 */ 295 ieee80211_reset_scan(ifp); 296 ieee80211_next_scan(ifp); 297 return; 298 } 299 selbs = NULL; 300 if (ifp->if_flags & IFF_DEBUG) 301 if_printf(ifp, "\tmacaddr bssid chan rssi rate flag wep essid\n"); 302 for (; ni != NULL; ni = nextbs) { 303 ieee80211_ref_node(ni); 304 nextbs = TAILQ_NEXT(ni, ni_list); 305 if (ni->ni_fails) { 306 /* 307 * The configuration of the access points may change 308 * during my scan. So delete the entry for the AP 309 * and retry to associate if there is another beacon. 310 */ 311 if (ni->ni_fails++ > 2) 312 ieee80211_free_node(ic, ni); 313 continue; 314 } 315 fail = 0; 316 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, ni->ni_chan))) 317 fail |= 0x01; 318 if (ic->ic_des_chan != IEEE80211_CHAN_ANYC && 319 ni->ni_chan != ic->ic_des_chan) 320 fail |= 0x01; 321 if (ic->ic_opmode == IEEE80211_M_IBSS) { 322 if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0) 323 fail |= 0x02; 324 } else { 325 if ((ni->ni_capinfo & IEEE80211_CAPINFO_ESS) == 0) 326 fail |= 0x02; 327 } 328 if (ic->ic_flags & IEEE80211_F_WEPON) { 329 if ((ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0) 330 fail |= 0x04; 331 } else { 332 if (ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) 333 fail |= 0x04; 334 } 335 rate = ieee80211_fix_rate(ic, ni, IEEE80211_F_DONEGO); 336 if (rate & IEEE80211_RATE_BASIC) 337 fail |= 0x08; 338 if (ic->ic_des_esslen != 0 && 339 (ni->ni_esslen != ic->ic_des_esslen || 340 memcmp(ni->ni_essid, ic->ic_des_essid, 341 ic->ic_des_esslen != 0))) 342 fail |= 0x10; 343 if ((ic->ic_flags & IEEE80211_F_DESBSSID) && 344 !IEEE80211_ADDR_EQ(ic->ic_des_bssid, ni->ni_bssid)) 345 fail |= 0x20; 346 if (ifp->if_flags & IFF_DEBUG) { 347 printf(" %c %s", fail ? '-' : '+', 348 ether_sprintf(ni->ni_macaddr)); 349 printf(" %s%c", ether_sprintf(ni->ni_bssid), 350 fail & 0x20 ? '!' : ' '); 351 printf(" %3d%c", ieee80211_chan2ieee(ic, ni->ni_chan), 352 fail & 0x01 ? '!' : ' '); 353 printf(" %+4d", ni->ni_rssi); 354 printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, 355 fail & 0x08 ? '!' : ' '); 356 printf(" %4s%c", 357 (ni->ni_capinfo & IEEE80211_CAPINFO_ESS) ? "ess" : 358 (ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" : 359 "????", 360 fail & 0x02 ? '!' : ' '); 361 printf(" %3s%c ", 362 (ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) ? 363 "wep" : "no", 364 fail & 0x04 ? '!' : ' '); 365 ieee80211_print_essid(ni->ni_essid, ni->ni_esslen); 366 printf("%s\n", fail & 0x10 ? "!" : ""); 367 } 368 if (!fail) { 369 if (selbs == NULL) 370 selbs = ni; 371 else if (ni->ni_rssi > selbs->ni_rssi) { 372 ieee80211_unref_node(&selbs); 373 selbs = ni; 374 } else 375 ieee80211_unref_node(&ni); 376 } else { 377 ieee80211_unref_node(&ni); 378 } 379 } 380 if (selbs == NULL) 381 goto notfound; 382 (*ic->ic_node_copy)(ic, ic->ic_bss, selbs); 383 if (ic->ic_opmode == IEEE80211_M_IBSS) { 384 ieee80211_fix_rate(ic, ic->ic_bss, IEEE80211_F_DOFRATE | 385 IEEE80211_F_DONEGO | IEEE80211_F_DODEL); 386 if (ic->ic_bss->ni_rates.rs_nrates == 0) { 387 selbs->ni_fails++; 388 ieee80211_unref_node(&selbs); 389 goto notfound; 390 } 391 ieee80211_unref_node(&selbs); 392 ieee80211_new_state(ic, IEEE80211_S_RUN, -1); 393 } else { 394 ieee80211_unref_node(&selbs); 395 ieee80211_new_state(ic, IEEE80211_S_AUTH, -1); 396 } 397} 398 399static struct ieee80211_node * 400ieee80211_node_alloc(struct ieee80211com *ic) 401{ 402 return malloc(sizeof(struct ieee80211_node), M_80211_NODE, 403 M_NOWAIT | M_ZERO); 404} 405 406static void 407ieee80211_node_free(struct ieee80211com *ic, struct ieee80211_node *ni) 408{ 409 free(ni, M_80211_NODE); 410} 411 412static void 413ieee80211_node_copy(struct ieee80211com *ic, 414 struct ieee80211_node *dst, const struct ieee80211_node *src) 415{ 416 *dst = *src; 417} 418 419static u_int8_t 420ieee80211_node_getrssi(struct ieee80211com *ic, struct ieee80211_node *ni) 421{ 422 return ni->ni_rssi; 423} 424 425static void 426ieee80211_setup_node(struct ieee80211com *ic, 427 struct ieee80211_node *ni, u_int8_t *macaddr) 428{ 429 int hash; 430 431 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 432 hash = IEEE80211_NODE_HASH(macaddr); 433 ni->ni_refcnt = 1; /* mark referenced */ 434 IEEE80211_NODE_LOCK(ic); 435 TAILQ_INSERT_TAIL(&ic->ic_node, ni, ni_list); 436 LIST_INSERT_HEAD(&ic->ic_hash[hash], ni, ni_hash); 437 /* 438 * Note we don't enable the inactive timer when acting 439 * as a station. Nodes created in this mode represent 440 * AP's identified while scanning. If we time them out 441 * then several things happen: we can't return the data 442 * to users to show the list of AP's we encountered, and 443 * more importantly, we'll incorrectly deauthenticate 444 * ourself because the inactivity timer will kick us off. 445 */ 446 if (ic->ic_opmode != IEEE80211_M_STA) 447 ic->ic_inact_timer = IEEE80211_INACT_WAIT; 448 IEEE80211_NODE_UNLOCK(ic); 449} 450 451struct ieee80211_node * 452ieee80211_alloc_node(struct ieee80211com *ic, u_int8_t *macaddr) 453{ 454 struct ieee80211_node *ni = (*ic->ic_node_alloc)(ic); 455 if (ni != NULL) 456 ieee80211_setup_node(ic, ni, macaddr); 457 return ni; 458} 459 460struct ieee80211_node * 461ieee80211_dup_bss(struct ieee80211com *ic, u_int8_t *macaddr) 462{ 463 struct ieee80211_node *ni = (*ic->ic_node_alloc)(ic); 464 if (ni != NULL) { 465 memcpy(ni, ic->ic_bss, sizeof(struct ieee80211_node)); 466 ieee80211_setup_node(ic, ni, macaddr); 467 } 468 return ni; 469} 470 471struct ieee80211_node * 472ieee80211_find_node(struct ieee80211com *ic, u_int8_t *macaddr) 473{ 474 struct ieee80211_node *ni; 475 int hash; 476 477 hash = IEEE80211_NODE_HASH(macaddr); 478 IEEE80211_NODE_LOCK(ic); 479 LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) { 480 if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) { 481 atomic_add_int(&ni->ni_refcnt, 1); /* mark referenced */ 482 break; 483 } 484 } 485 IEEE80211_NODE_UNLOCK(ic); 486 return ni; 487} 488 489/* 490 * Like find but search based on the channel too. 491 */ 492struct ieee80211_node * 493ieee80211_lookup_node(struct ieee80211com *ic, 494 u_int8_t *macaddr, struct ieee80211_channel *chan) 495{ 496 struct ieee80211_node *ni; 497 int hash; 498 499 hash = IEEE80211_NODE_HASH(macaddr); 500 IEEE80211_NODE_LOCK(ic); 501 LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) { 502 if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_chan == chan) { 503 atomic_add_int(&ni->ni_refcnt, 1);/* mark referenced */ 504 break; 505 } 506 } 507 IEEE80211_NODE_UNLOCK(ic); 508 return ni; 509} 510 511static void 512_ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni) 513{ 514 KASSERT(ni != ic->ic_bss, ("freeing bss node")); 515 516 TAILQ_REMOVE(&ic->ic_node, ni, ni_list); 517 LIST_REMOVE(ni, ni_hash); 518 if (TAILQ_EMPTY(&ic->ic_node)) 519 ic->ic_inact_timer = 0; 520 (*ic->ic_node_free)(ic, ni); 521} 522 523void 524ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni) 525{ 526 KASSERT(ni != ic->ic_bss, ("freeing ic_bss")); 527 528 /* XXX need equivalent of atomic_dec_and_test */ 529 atomic_subtract_int(&ni->ni_refcnt, 1); 530 if (atomic_cmpset_int(&ni->ni_refcnt, 0, 1)) { 531 IEEE80211_NODE_LOCK(ic); 532 _ieee80211_free_node(ic, ni); 533 IEEE80211_NODE_UNLOCK(ic); 534 } 535} 536 537void 538ieee80211_free_allnodes(struct ieee80211com *ic) 539{ 540 struct ieee80211_node *ni; 541 542 IEEE80211_NODE_LOCK(ic); 543 while ((ni = TAILQ_FIRST(&ic->ic_node)) != NULL) 544 _ieee80211_free_node(ic, ni); 545 IEEE80211_NODE_UNLOCK(ic); 546} 547 548/* 549 * Timeout inactive nodes. Note that we cannot hold the node 550 * lock while sending a frame as this would lead to a LOR. 551 * Instead we use a generation number to mark nodes that we've 552 * scanned and drop the lock and restart a scan if we have to 553 * time out a node. Since we are single-threaded by virtue of 554 * controlling the inactivity timer we can be sure this will 555 * process each node only once. 556 */ 557void 558ieee80211_timeout_nodes(struct ieee80211com *ic) 559{ 560 struct ieee80211_node *ni; 561 u_int gen = ic->ic_scangen++; /* NB: ok 'cuz single-threaded*/ 562 563restart: 564 IEEE80211_NODE_LOCK(ic); 565 TAILQ_FOREACH(ni, &ic->ic_node, ni_list) { 566 if (ni->ni_scangen == gen) /* previously handled */ 567 continue; 568 ni->ni_scangen = gen; 569 if (++ni->ni_inact > IEEE80211_INACT_MAX) { 570 IEEE80211_DPRINTF(("station %s timed out " 571 "due to inactivity (%u secs)\n", 572 ether_sprintf(ni->ni_macaddr), 573 ni->ni_inact)); 574 /* 575 * Send a deauthenticate frame. 576 * 577 * Drop the node lock before sending the 578 * deauthentication frame in case the driver takes 579 * a lock, as this will result in a LOR between the 580 * node lock and the driver lock. 581 */ 582 IEEE80211_NODE_UNLOCK(ic); 583 IEEE80211_SEND_MGMT(ic, ni, 584 IEEE80211_FC0_SUBTYPE_DEAUTH, 585 IEEE80211_REASON_AUTH_EXPIRE); 586 ieee80211_free_node(ic, ni); 587 ic->ic_stats.is_node_timeout++; 588 goto restart; 589 } 590 } 591 if (!TAILQ_EMPTY(&ic->ic_node)) 592 ic->ic_inact_timer = IEEE80211_INACT_WAIT; 593 IEEE80211_NODE_UNLOCK(ic); 594} 595 596void 597ieee80211_iterate_nodes(struct ieee80211com *ic, ieee80211_iter_func *f, void *arg) 598{ 599 struct ieee80211_node *ni; 600 601 IEEE80211_NODE_LOCK(ic); 602 TAILQ_FOREACH(ni, &ic->ic_node, ni_list) 603 (*f)(arg, ni); 604 IEEE80211_NODE_UNLOCK(ic); 605} 606