ieee80211_node.c (148323) | ieee80211_node.c (148432) |
---|---|
1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2005 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: --- 17 unchanged lines hidden (view full) --- 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> | 1/*- 2 * Copyright (c) 2001 Atsushi Onoe 3 * Copyright (c) 2002-2005 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: --- 17 unchanged lines hidden (view full) --- 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 148323 2005-07-23 00:16:46Z sam $"); | 34__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 148432 2005-07-27 02:53:09Z sam $"); |
35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/mbuf.h> 39#include <sys/malloc.h> 40#include <sys/kernel.h> 41 42#include <sys/socket.h> --- 398 unchanged lines hidden (view full) --- 441 ic->ic_bss = ieee80211_ref_node(ni); 442 if (obss != NULL) { 443 copy_bss(ni, obss); 444 ni->ni_intval = ic->ic_lintval; 445 ieee80211_free_node(obss); 446 } 447} 448 | 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/mbuf.h> 39#include <sys/malloc.h> 40#include <sys/kernel.h> 41 42#include <sys/socket.h> --- 398 unchanged lines hidden (view full) --- 441 ic->ic_bss = ieee80211_ref_node(ni); 442 if (obss != NULL) { 443 copy_bss(ni, obss); 444 ni->ni_intval = ic->ic_lintval; 445 ieee80211_free_node(obss); 446 } 447} 448 |
449/* XXX tunable */ 450#define STA_FAILS_MAX 2 /* assoc failures before ignored */ 451 |
|
449static int 450ieee80211_match_bss(struct ieee80211com *ic, struct ieee80211_node *ni) 451{ 452 u_int8_t rate; 453 int fail; 454 455 fail = 0; 456 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, ni->ni_chan))) --- 21 unchanged lines hidden (view full) --- 478 fail |= 0x08; 479 if (ic->ic_des_esslen != 0 && 480 (ni->ni_esslen != ic->ic_des_esslen || 481 memcmp(ni->ni_essid, ic->ic_des_essid, ic->ic_des_esslen) != 0)) 482 fail |= 0x10; 483 if ((ic->ic_flags & IEEE80211_F_DESBSSID) && 484 !IEEE80211_ADDR_EQ(ic->ic_des_bssid, ni->ni_bssid)) 485 fail |= 0x20; | 452static int 453ieee80211_match_bss(struct ieee80211com *ic, struct ieee80211_node *ni) 454{ 455 u_int8_t rate; 456 int fail; 457 458 fail = 0; 459 if (isclr(ic->ic_chan_active, ieee80211_chan2ieee(ic, ni->ni_chan))) --- 21 unchanged lines hidden (view full) --- 481 fail |= 0x08; 482 if (ic->ic_des_esslen != 0 && 483 (ni->ni_esslen != ic->ic_des_esslen || 484 memcmp(ni->ni_essid, ic->ic_des_essid, ic->ic_des_esslen) != 0)) 485 fail |= 0x10; 486 if ((ic->ic_flags & IEEE80211_F_DESBSSID) && 487 !IEEE80211_ADDR_EQ(ic->ic_des_bssid, ni->ni_bssid)) 488 fail |= 0x20; |
489 if (ni->ni_fails >= STA_FAILS_MAX) 490 fail |= 0x40; |
|
486#ifdef IEEE80211_DEBUG 487 if (ieee80211_msg_scan(ic)) { | 491#ifdef IEEE80211_DEBUG 492 if (ieee80211_msg_scan(ic)) { |
488 printf(" %c %s", fail ? '-' : '+', | 493 printf(" %c %s", 494 fail & 0x40 ? '=' : fail & 0x80 ? '^' : fail ? '-' : '+', |
489 ether_sprintf(ni->ni_macaddr)); 490 printf(" %s%c", ether_sprintf(ni->ni_bssid), 491 fail & 0x20 ? '!' : ' '); 492 printf(" %3d%c", ieee80211_chan2ieee(ic, ni->ni_chan), 493 fail & 0x01 ? '!' : ' '); 494 printf(" %+4d", ni->ni_rssi); 495 printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, 496 fail & 0x08 ? '!' : ' '); --- 30 unchanged lines hidden (view full) --- 527 */ 528static int 529ieee80211_node_compare(struct ieee80211com *ic, 530 const struct ieee80211_node *a, 531 const struct ieee80211_node *b) 532{ 533 u_int8_t maxa, maxb; 534 u_int8_t rssia, rssib; | 495 ether_sprintf(ni->ni_macaddr)); 496 printf(" %s%c", ether_sprintf(ni->ni_bssid), 497 fail & 0x20 ? '!' : ' '); 498 printf(" %3d%c", ieee80211_chan2ieee(ic, ni->ni_chan), 499 fail & 0x01 ? '!' : ' '); 500 printf(" %+4d", ni->ni_rssi); 501 printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, 502 fail & 0x08 ? '!' : ' '); --- 30 unchanged lines hidden (view full) --- 533 */ 534static int 535ieee80211_node_compare(struct ieee80211com *ic, 536 const struct ieee80211_node *a, 537 const struct ieee80211_node *b) 538{ 539 u_int8_t maxa, maxb; 540 u_int8_t rssia, rssib; |
541 int weight; |
|
535 536 /* privacy support preferred */ 537 if ((a->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) && 538 (b->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0) 539 return 1; 540 if ((a->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0 && 541 (b->ni_capinfo & IEEE80211_CAPINFO_PRIVACY)) 542 return -1; 543 | 542 543 /* privacy support preferred */ 544 if ((a->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) && 545 (b->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0) 546 return 1; 547 if ((a->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) == 0 && 548 (b->ni_capinfo & IEEE80211_CAPINFO_PRIVACY)) 549 return -1; 550 |
551 /* compare count of previous failures */ 552 weight = b->ni_fails - a->ni_fails; 553 if (abs(weight) > 1) 554 return weight; 555 |
|
544 rssia = ic->ic_node_getrssi(a); 545 rssib = ic->ic_node_getrssi(b); 546 if (abs(rssib - rssia) < 5) { 547 /* best/max rate preferred if signal level close enough XXX */ 548 maxa = maxrate(a); 549 maxb = maxrate(b); 550 if (maxa != maxb) 551 return maxa - maxb; --- 101 unchanged lines hidden (view full) --- 653 notfound: 654 if (ic->ic_opmode == IEEE80211_M_IBSS && 655 (ic->ic_flags & IEEE80211_F_IBSSON) && 656 ic->ic_des_esslen != 0) { 657 ieee80211_create_ibss(ic, ic->ic_ibss_chan); 658 return; 659 } 660 /* | 556 rssia = ic->ic_node_getrssi(a); 557 rssib = ic->ic_node_getrssi(b); 558 if (abs(rssib - rssia) < 5) { 559 /* best/max rate preferred if signal level close enough XXX */ 560 maxa = maxrate(a); 561 maxb = maxrate(b); 562 if (maxa != maxb) 563 return maxa - maxb; --- 101 unchanged lines hidden (view full) --- 665 notfound: 666 if (ic->ic_opmode == IEEE80211_M_IBSS && 667 (ic->ic_flags & IEEE80211_F_IBSSON) && 668 ic->ic_des_esslen != 0) { 669 ieee80211_create_ibss(ic, ic->ic_ibss_chan); 670 return; 671 } 672 /* |
673 * Decrement the failure counts so entries will be 674 * reconsidered the next time around. We really want 675 * to do this only for sta's where we've previously 676 had some success. 677 */ 678 IEEE80211_NODE_LOCK(nt); 679 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) 680 if (ni->ni_fails) 681 ni->ni_fails--; 682 IEEE80211_NODE_UNLOCK(nt); 683 /* |
|
661 * Reset the list of channels to scan and start again. 662 */ 663 ieee80211_reset_scan(ic); 664 ic->ic_flags |= IEEE80211_F_SCAN; 665 ieee80211_next_scan(ic); 666 return; 667 } 668 selbs = NULL; 669 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, "\t%s\n", 670 "macaddr bssid chan rssi rate flag wep essid"); 671 IEEE80211_NODE_LOCK(nt); 672 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { | 684 * Reset the list of channels to scan and start again. 685 */ 686 ieee80211_reset_scan(ic); 687 ic->ic_flags |= IEEE80211_F_SCAN; 688 ieee80211_next_scan(ic); 689 return; 690 } 691 selbs = NULL; 692 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, "\t%s\n", 693 "macaddr bssid chan rssi rate flag wep essid"); 694 IEEE80211_NODE_LOCK(nt); 695 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { |
673 if (ni->ni_fails) { 674 /* 675 * The configuration of the access points may change 676 * during my scan. So delete the entry for the AP 677 * and retry to associate if there is another beacon. 678 */ 679 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, 680 "%s: skip scan candidate %s, fails %u\n", 681 __func__, ether_sprintf(ni->ni_macaddr), 682 ni->ni_fails); 683 ni->ni_fails++; 684#if 0 685 if (ni->ni_fails++ > 2) 686 ieee80211_free_node(ni); 687#endif 688 continue; 689 } | |
690 if (ieee80211_match_bss(ic, ni) == 0) { 691 if (selbs == NULL) 692 selbs = ni; 693 else if (ieee80211_node_compare(ic, ni, selbs) > 0) 694 selbs = ni; 695 } 696 } 697 if (selbs != NULL) /* NB: grab ref while dropping lock */ --- 1231 unchanged lines hidden --- | 696 if (ieee80211_match_bss(ic, ni) == 0) { 697 if (selbs == NULL) 698 selbs = ni; 699 else if (ieee80211_node_compare(ic, ni, selbs) > 0) 700 selbs = ni; 701 } 702 } 703 if (selbs != NULL) /* NB: grab ref while dropping lock */ --- 1231 unchanged lines hidden --- |