ieee80211_node.c (140441) | ieee80211_node.c (140448) |
---|---|
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 140441 2005-01-18 19:59:40Z sam $"); | 34__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 140448 2005-01-18 20:21:29Z 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> --- 541 unchanged lines hidden (view full) --- 584} 585 586/* 587 * Complete a scan of potential channels. 588 */ 589void 590ieee80211_end_scan(struct ieee80211com *ic) 591{ | 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> --- 541 unchanged lines hidden (view full) --- 584} 585 586/* 587 * Complete a scan of potential channels. 588 */ 589void 590ieee80211_end_scan(struct ieee80211com *ic) 591{ |
592 struct ieee80211_node *ni, *nextbs, *selbs; 593 struct ieee80211_node_table *nt; | 592 struct ieee80211_node_table *nt = &ic->ic_scan; 593 struct ieee80211_node *ni, *selbs; |
594 595 ieee80211_cancel_scan(ic); 596 ieee80211_notify_scan_done(ic); 597 | 594 595 ieee80211_cancel_scan(ic); 596 ieee80211_notify_scan_done(ic); 597 |
598 nt = &ic->ic_scan; 599 ni = TAILQ_FIRST(&nt->nt_node); 600 | |
601 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 602 u_int8_t maxrssi[IEEE80211_CHAN_MAX]; /* XXX off stack? */ 603 int i, bestchan; 604 u_int8_t rssi; 605 606 /* 607 * The passive scan to look for existing AP's completed, 608 * select a channel to camp on. Identify the channels 609 * that already have one or more AP's and try to locate 610 * an unnoccupied one. If that fails, pick a channel that 611 * looks to be quietest. 612 */ 613 memset(maxrssi, 0, sizeof(maxrssi)); | 598 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 599 u_int8_t maxrssi[IEEE80211_CHAN_MAX]; /* XXX off stack? */ 600 int i, bestchan; 601 u_int8_t rssi; 602 603 /* 604 * The passive scan to look for existing AP's completed, 605 * select a channel to camp on. Identify the channels 606 * that already have one or more AP's and try to locate 607 * an unnoccupied one. If that fails, pick a channel that 608 * looks to be quietest. 609 */ 610 memset(maxrssi, 0, sizeof(maxrssi)); |
614 for (; ni != NULL; ni = nextbs) { 615 ieee80211_ref_node(ni); 616 nextbs = TAILQ_NEXT(ni, ni_list); | 611 IEEE80211_NODE_LOCK(nt); 612 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { |
617 rssi = ic->ic_node_getrssi(ni); 618 i = ieee80211_chan2ieee(ic, ni->ni_chan); 619 if (rssi > maxrssi[i]) 620 maxrssi[i] = rssi; | 613 rssi = ic->ic_node_getrssi(ni); 614 i = ieee80211_chan2ieee(ic, ni->ni_chan); 615 if (rssi > maxrssi[i]) 616 maxrssi[i] = rssi; |
621 ieee80211_unref_node(&ni); | |
622 } | 617 } |
618 IEEE80211_NODE_UNLOCK(nt); |
|
623 /* XXX select channel more intelligently */ 624 bestchan = -1; 625 for (i = 0; i < IEEE80211_CHAN_MAX; i++) 626 if (isset(ic->ic_chan_active, i)) { 627 /* 628 * If the channel is unoccupied the max rssi 629 * should be zero; just take it. Otherwise 630 * track the channel with the lowest rssi and --- 20 unchanged lines hidden (view full) --- 651 * initiate an association. 652 */ 653 if (ic->ic_roaming == IEEE80211_ROAMING_MANUAL) 654 return; 655 /* 656 * Automatic sequencing; look for a candidate and 657 * if found join the network. 658 */ | 619 /* XXX select channel more intelligently */ 620 bestchan = -1; 621 for (i = 0; i < IEEE80211_CHAN_MAX; i++) 622 if (isset(ic->ic_chan_active, i)) { 623 /* 624 * If the channel is unoccupied the max rssi 625 * should be zero; just take it. Otherwise 626 * track the channel with the lowest rssi and --- 20 unchanged lines hidden (view full) --- 647 * initiate an association. 648 */ 649 if (ic->ic_roaming == IEEE80211_ROAMING_MANUAL) 650 return; 651 /* 652 * Automatic sequencing; look for a candidate and 653 * if found join the network. 654 */ |
659 if (ni == NULL) { | 655 /* NB: unlocked read should be ok */ 656 if (TAILQ_FIRST(&nt->nt_node) == NULL) { |
660 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, 661 "%s: no scan candidate\n", __func__); 662 notfound: 663 if (ic->ic_opmode == IEEE80211_M_IBSS && 664 (ic->ic_flags & IEEE80211_F_IBSSON) && 665 ic->ic_des_esslen != 0) { 666 ieee80211_create_ibss(ic, ic->ic_ibss_chan); 667 return; --- 4 unchanged lines hidden (view full) --- 672 ieee80211_reset_scan(ic); 673 ic->ic_flags |= IEEE80211_F_SCAN; 674 ieee80211_next_scan(ic); 675 return; 676 } 677 selbs = NULL; 678 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, "\t%s\n", 679 "macaddr bssid chan rssi rate flag wep essid"); | 657 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, 658 "%s: no scan candidate\n", __func__); 659 notfound: 660 if (ic->ic_opmode == IEEE80211_M_IBSS && 661 (ic->ic_flags & IEEE80211_F_IBSSON) && 662 ic->ic_des_esslen != 0) { 663 ieee80211_create_ibss(ic, ic->ic_ibss_chan); 664 return; --- 4 unchanged lines hidden (view full) --- 669 ieee80211_reset_scan(ic); 670 ic->ic_flags |= IEEE80211_F_SCAN; 671 ieee80211_next_scan(ic); 672 return; 673 } 674 selbs = NULL; 675 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, "\t%s\n", 676 "macaddr bssid chan rssi rate flag wep essid"); |
680 for (; ni != NULL; ni = nextbs) { 681 ieee80211_ref_node(ni); 682 nextbs = TAILQ_NEXT(ni, ni_list); | 677 IEEE80211_NODE_LOCK(nt); 678 TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { |
683 if (ni->ni_fails) { 684 /* 685 * The configuration of the access points may change 686 * during my scan. So delete the entry for the AP 687 * and retry to associate if there is another beacon. 688 */ 689 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, 690 "%s: skip scan candidate %s, fails %u\n", 691 __func__, ether_sprintf(ni->ni_macaddr), 692 ni->ni_fails); | 679 if (ni->ni_fails) { 680 /* 681 * The configuration of the access points may change 682 * during my scan. So delete the entry for the AP 683 * and retry to associate if there is another beacon. 684 */ 685 IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, 686 "%s: skip scan candidate %s, fails %u\n", 687 __func__, ether_sprintf(ni->ni_macaddr), 688 ni->ni_fails); |
689 ni->ni_fails++; 690#if 0 |
|
693 if (ni->ni_fails++ > 2) 694 ieee80211_free_node(ni); | 691 if (ni->ni_fails++ > 2) 692 ieee80211_free_node(ni); |
693#endif |
|
695 continue; 696 } 697 if (ieee80211_match_bss(ic, ni) == 0) { 698 if (selbs == NULL) 699 selbs = ni; | 694 continue; 695 } 696 if (ieee80211_match_bss(ic, ni) == 0) { 697 if (selbs == NULL) 698 selbs = ni; |
700 else if (ieee80211_node_compare(ic, ni, selbs) > 0) { 701 ieee80211_unref_node(&selbs); | 699 else if (ieee80211_node_compare(ic, ni, selbs) > 0) |
702 selbs = ni; | 700 selbs = ni; |
703 } else 704 ieee80211_unref_node(&ni); 705 } else { 706 ieee80211_unref_node(&ni); | |
707 } 708 } | 701 } 702 } |
703 if (selbs != NULL) /* NB: grab ref while dropping lock */ 704 (void) ieee80211_ref_node(selbs); 705 IEEE80211_NODE_UNLOCK(nt); |
|
709 if (selbs == NULL) 710 goto notfound; 711 if (!ieee80211_sta_join(ic, selbs)) { | 706 if (selbs == NULL) 707 goto notfound; 708 if (!ieee80211_sta_join(ic, selbs)) { |
712 ieee80211_unref_node(&selbs); | 709 ieee80211_free_node(selbs); |
713 goto notfound; 714 } 715} 716 717/* 718 * Handle 802.11 ad hoc network merge. The 719 * convention, set by the Wireless Ethernet Compatibility Alliance 720 * (WECA), is that an 802.11 station will change its BSSID to match --- 1199 unchanged lines hidden --- | 710 goto notfound; 711 } 712} 713 714/* 715 * Handle 802.11 ad hoc network merge. The 716 * convention, set by the Wireless Ethernet Compatibility Alliance 717 * (WECA), is that an 802.11 station will change its BSSID to match --- 1199 unchanged lines hidden --- |