Deleted Added
full compact
ieee80211_scan_sta.c (186302) ieee80211_scan_sta.c (186904)
1/*-
1/*-
2 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 8 unchanged lines hidden (view full) ---

19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 8 unchanged lines hidden (view full) ---

19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_scan_sta.c 186302 2008-12-18 23:00:09Z sam $");
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_scan_sta.c 186904 2009-01-08 17:12:47Z sam $");
28
29/*
30 * IEEE 802.11 station scanning support.
31 */
32#include "opt_wlan.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>

--- 4 unchanged lines hidden (view full) ---

40
41#include <net/if.h>
42#include <net/if_media.h>
43#include <net/ethernet.h>
44
45#include <net80211/ieee80211_var.h>
46#include <net80211/ieee80211_input.h>
47#include <net80211/ieee80211_regdomain.h>
28
29/*
30 * IEEE 802.11 station scanning support.
31 */
32#include "opt_wlan.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>

--- 4 unchanged lines hidden (view full) ---

40
41#include <net/if.h>
42#include <net/if_media.h>
43#include <net/ethernet.h>
44
45#include <net80211/ieee80211_var.h>
46#include <net80211/ieee80211_input.h>
47#include <net80211/ieee80211_regdomain.h>
48#ifdef IEEE80211_SUPPORT_TDMA
49#include <net80211/ieee80211_tdma.h>
50#endif
48
49#include <net/bpf.h>
50
51/*
52 * Parameters for managing cache entries:
53 *
54 * o a station with STA_FAILS_MAX failures is not considered
55 * when picking a candidate

--- 58 unchanged lines hidden (view full) ---

114#define MATCH_PRIVACY 0x0004 /* privacy mismatch */
115#define MATCH_RATE 0x0008 /* rate set mismatch */
116#define MATCH_SSID 0x0010 /* ssid mismatch */
117#define MATCH_BSSID 0x0020 /* bssid mismatch */
118#define MATCH_FAILS 0x0040 /* too many failed auth attempts */
119#define MATCH_NOTSEEN 0x0080 /* not seen in recent scans */
120#define MATCH_RSSI 0x0100 /* rssi deemed too low to use */
121#define MATCH_CC 0x0200 /* country code mismatch */
51
52#include <net/bpf.h>
53
54/*
55 * Parameters for managing cache entries:
56 *
57 * o a station with STA_FAILS_MAX failures is not considered
58 * when picking a candidate

--- 58 unchanged lines hidden (view full) ---

117#define MATCH_PRIVACY 0x0004 /* privacy mismatch */
118#define MATCH_RATE 0x0008 /* rate set mismatch */
119#define MATCH_SSID 0x0010 /* ssid mismatch */
120#define MATCH_BSSID 0x0020 /* bssid mismatch */
121#define MATCH_FAILS 0x0040 /* too many failed auth attempts */
122#define MATCH_NOTSEEN 0x0080 /* not seen in recent scans */
123#define MATCH_RSSI 0x0100 /* rssi deemed too low to use */
124#define MATCH_CC 0x0200 /* country code mismatch */
125#define MATCH_TDMA_NOIE 0x0400 /* no TDMA ie */
126#define MATCH_TDMA_NOTMASTER 0x0800 /* not TDMA master */
127#define MATCH_TDMA_NOSLOT 0x1000 /* all TDMA slots occupied */
128#define MATCH_TDMA_LOCAL 0x2000 /* local address */
122static int match_bss(struct ieee80211vap *,
123 const struct ieee80211_scan_state *, struct sta_entry *, int);
124static void adhoc_age(struct ieee80211_scan_state *);
125
126static __inline int
127isocmp(const uint8_t cc1[], const uint8_t cc2[])
128{
129 return (cc1[0] == cc2[0] && cc1[1] == cc2[1]);

--- 735 unchanged lines hidden (view full) ---

865 for (i = 0; i < nssid; i++) {
866 if (ie[1] == ssids[i].len &&
867 memcmp(ie+2, ssids[i].ssid, ie[1]) == 0)
868 return 1;
869 }
870 return 0;
871}
872
129static int match_bss(struct ieee80211vap *,
130 const struct ieee80211_scan_state *, struct sta_entry *, int);
131static void adhoc_age(struct ieee80211_scan_state *);
132
133static __inline int
134isocmp(const uint8_t cc1[], const uint8_t cc2[])
135{
136 return (cc1[0] == cc2[0] && cc1[1] == cc2[1]);

--- 735 unchanged lines hidden (view full) ---

872 for (i = 0; i < nssid; i++) {
873 if (ie[1] == ssids[i].len &&
874 memcmp(ie+2, ssids[i].ssid, ie[1]) == 0)
875 return 1;
876 }
877 return 0;
878}
879
880#ifdef IEEE80211_SUPPORT_TDMA
881static int
882tdma_isfull(const struct ieee80211_tdma_param *tdma)
883{
884 int slot, slotcnt;
885
886 slotcnt = tdma->tdma_slotcnt;
887 for (slot = slotcnt-1; slot >= 0; slot--)
888 if (isclr(tdma->tdma_inuse, slot))
889 return 0;
890 return 1;
891}
892#endif /* IEEE80211_SUPPORT_TDMA */
893
873/*
874 * Test a scan candidate for suitability/compatibility.
875 */
876static int
877match_bss(struct ieee80211vap *vap,
878 const struct ieee80211_scan_state *ss, struct sta_entry *se0,
879 int debug)
880{

--- 14 unchanged lines hidden (view full) ---

895 */
896 if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
897 (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
898 chanflags[vap->iv_des_mode])
899 fail |= MATCH_CHANNEL;
900 if (vap->iv_opmode == IEEE80211_M_IBSS) {
901 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
902 fail |= MATCH_CAPINFO;
894/*
895 * Test a scan candidate for suitability/compatibility.
896 */
897static int
898match_bss(struct ieee80211vap *vap,
899 const struct ieee80211_scan_state *ss, struct sta_entry *se0,
900 int debug)
901{

--- 14 unchanged lines hidden (view full) ---

916 */
917 if (vap->iv_des_mode != IEEE80211_MODE_AUTO &&
918 (se->se_chan->ic_flags & IEEE80211_CHAN_ALLTURBO) !=
919 chanflags[vap->iv_des_mode])
920 fail |= MATCH_CHANNEL;
921 if (vap->iv_opmode == IEEE80211_M_IBSS) {
922 if ((se->se_capinfo & IEEE80211_CAPINFO_IBSS) == 0)
923 fail |= MATCH_CAPINFO;
924#ifdef IEEE80211_SUPPORT_TDMA
925 } else if (vap->iv_opmode == IEEE80211_M_AHDEMO) {
926 /*
927 * Adhoc demo network setup shouldn't really be scanning
928 * but just in case skip stations operating in IBSS or
929 * BSS mode.
930 */
931 if (se->se_capinfo & (IEEE80211_CAPINFO_IBSS|IEEE80211_CAPINFO_ESS))
932 fail |= MATCH_CAPINFO;
933 /*
934 * TDMA operation cannot coexist with a normal 802.11 network;
935 * skip if IBSS or ESS capabilities are marked and require
936 * the beacon have a TDMA ie present.
937 */
938 if (vap->iv_caps & IEEE80211_C_TDMA) {
939 const struct ieee80211_tdma_param *tdma =
940 (const struct ieee80211_tdma_param *)se->se_ies.tdma_ie;
941
942 if (tdma == NULL)
943 fail |= MATCH_TDMA_NOIE;
944 else if (tdma->tdma_slot != 0)
945 fail |= MATCH_TDMA_NOTMASTER;
946 else if (tdma_isfull(tdma))
947 fail |= MATCH_TDMA_NOSLOT;
948#if 0
949 else if (ieee80211_local_address(se->se_macaddr))
950 fail |= MATCH_TDMA_LOCAL;
951#endif
952 }
953#endif /* IEEE80211_SUPPORT_TDMA */
903 } else {
904 if ((se->se_capinfo & IEEE80211_CAPINFO_ESS) == 0)
905 fail |= MATCH_CAPINFO;
906 /*
907 * If 11d is enabled and we're attempting to join a bss
908 * that advertises it's country code then compare our
909 * current settings to what we fetched from the country ie.
910 * If our country code is unspecified or different then do

--- 61 unchanged lines hidden (view full) ---

972 if (se->se_rssi < STA_RSSI_MIN)
973 fail |= MATCH_RSSI;
974#ifdef IEEE80211_DEBUG
975 if (ieee80211_msg(vap, debug)) {
976 printf(" %c %s",
977 fail & MATCH_FAILS ? '=' :
978 fail & MATCH_NOTSEEN ? '^' :
979 fail & MATCH_CC ? '$' :
954 } else {
955 if ((se->se_capinfo & IEEE80211_CAPINFO_ESS) == 0)
956 fail |= MATCH_CAPINFO;
957 /*
958 * If 11d is enabled and we're attempting to join a bss
959 * that advertises it's country code then compare our
960 * current settings to what we fetched from the country ie.
961 * If our country code is unspecified or different then do

--- 61 unchanged lines hidden (view full) ---

1023 if (se->se_rssi < STA_RSSI_MIN)
1024 fail |= MATCH_RSSI;
1025#ifdef IEEE80211_DEBUG
1026 if (ieee80211_msg(vap, debug)) {
1027 printf(" %c %s",
1028 fail & MATCH_FAILS ? '=' :
1029 fail & MATCH_NOTSEEN ? '^' :
1030 fail & MATCH_CC ? '$' :
1031#ifdef IEEE80211_SUPPORT_TDMA
1032 fail & MATCH_TDMA_NOIE ? '&' :
1033 fail & MATCH_TDMA_NOTMASTER ? ':' :
1034 fail & MATCH_TDMA_NOSLOT ? '@' :
1035 fail & MATCH_TDMA_LOCAL ? '#' :
1036#endif
980 fail ? '-' : '+', ether_sprintf(se->se_macaddr));
981 printf(" %s%c", ether_sprintf(se->se_bssid),
982 fail & MATCH_BSSID ? '!' : ' ');
983 printf(" %3d%c", ieee80211_chan2ieee(ic, se->se_chan),
984 fail & MATCH_CHANNEL ? '!' : ' ');
985 printf(" %+4d%c", se->se_rssi, fail & MATCH_RSSI ? '!' : ' ');
986 printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2,
987 fail & MATCH_RATE ? '!' : ' ');

--- 456 unchanged lines hidden (view full) ---

1444 */
1445 /* NB: unlocked read should be ok */
1446 if (TAILQ_FIRST(&st->st_entry) == NULL) {
1447 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
1448 "%s: no scan candidate\n", __func__);
1449 if (ss->ss_flags & IEEE80211_SCAN_NOJOIN)
1450 return 0;
1451notfound:
1037 fail ? '-' : '+', ether_sprintf(se->se_macaddr));
1038 printf(" %s%c", ether_sprintf(se->se_bssid),
1039 fail & MATCH_BSSID ? '!' : ' ');
1040 printf(" %3d%c", ieee80211_chan2ieee(ic, se->se_chan),
1041 fail & MATCH_CHANNEL ? '!' : ' ');
1042 printf(" %+4d%c", se->se_rssi, fail & MATCH_RSSI ? '!' : ' ');
1043 printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2,
1044 fail & MATCH_RATE ? '!' : ' ');

--- 456 unchanged lines hidden (view full) ---

1501 */
1502 /* NB: unlocked read should be ok */
1503 if (TAILQ_FIRST(&st->st_entry) == NULL) {
1504 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
1505 "%s: no scan candidate\n", __func__);
1506 if (ss->ss_flags & IEEE80211_SCAN_NOJOIN)
1507 return 0;
1508notfound:
1509 /* NB: never auto-start a tdma network for slot !0 */
1510#ifdef IEEE80211_SUPPORT_TDMA
1511 if (vap->iv_des_nssid &&
1512 ((vap->iv_caps & IEEE80211_C_TDMA) == 0 ||
1513 ieee80211_tdma_getslot(vap) == 0)) {
1514#else
1452 if (vap->iv_des_nssid) {
1515 if (vap->iv_des_nssid) {
1516#endif
1453 /*
1454 * No existing adhoc network to join and we have
1455 * an ssid; start one up. If no channel was
1456 * specified, try to select a channel.
1457 */
1458 if (vap->iv_des_chan == IEEE80211_CHAN_ANYC ||
1459 IEEE80211_IS_CHAN_RADAR(vap->iv_des_chan)) {
1460 struct ieee80211com *ic = vap->iv_ic;

--- 233 unchanged lines hidden ---
1517 /*
1518 * No existing adhoc network to join and we have
1519 * an ssid; start one up. If no channel was
1520 * specified, try to select a channel.
1521 */
1522 if (vap->iv_des_chan == IEEE80211_CHAN_ANYC ||
1523 IEEE80211_IS_CHAN_RADAR(vap->iv_des_chan)) {
1524 struct ieee80211com *ic = vap->iv_ic;

--- 233 unchanged lines hidden ---