Deleted Added
full compact
ieee80211_scan_sta.c (184302) ieee80211_scan_sta.c (186107)
1/*-
2 * Copyright (c) 2002-2008 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

--- 10 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>
1/*-
2 * Copyright (c) 2002-2008 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

--- 10 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 184302 2008-10-26 21:56:27Z sam $");
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_scan_sta.c 186107 2008-12-15 01:26:33Z 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>

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

82 u_int se_countrygen; /* gen# of last cc notify */
83};
84
85#define STA_HASHSIZE 32
86/* simple hash is enough for variation of macaddr */
87#define STA_HASH(addr) \
88 (((const uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % STA_HASHSIZE)
89
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>

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

82 u_int se_countrygen; /* gen# of last cc notify */
83};
84
85#define STA_HASHSIZE 32
86/* simple hash is enough for variation of macaddr */
87#define STA_HASH(addr) \
88 (((const uint8_t *)(addr))[IEEE80211_ADDR_LEN - 1] % STA_HASHSIZE)
89
90#define MAX_IEEE_CHAN 256 /* max acceptable IEEE chan # */
91CTASSERT(MAX_IEEE_CHAN >= 256);
92
90struct sta_table {
91 struct mtx st_lock; /* on scan table */
92 TAILQ_HEAD(, sta_entry) st_entry; /* all entries */
93 LIST_HEAD(, sta_entry) st_hash[STA_HASHSIZE];
94 struct mtx st_scanlock; /* on st_scaniter */
95 u_int st_scaniter; /* gen# for iterator */
96 u_int st_scangen; /* scan generation # */
97 int st_newscan;
98 /* ap-related state */
93struct sta_table {
94 struct mtx st_lock; /* on scan table */
95 TAILQ_HEAD(, sta_entry) st_entry; /* all entries */
96 LIST_HEAD(, sta_entry) st_hash[STA_HASHSIZE];
97 struct mtx st_scanlock; /* on st_scaniter */
98 u_int st_scaniter; /* gen# for iterator */
99 u_int st_scangen; /* scan generation # */
100 int st_newscan;
101 /* ap-related state */
99 int st_maxrssi[IEEE80211_CHAN_MAX];
102 int st_maxrssi[MAX_IEEE_CHAN];
100};
101
102static void sta_flush_table(struct sta_table *);
103/*
104 * match_bss returns a bitmask describing if an entry is suitable
105 * for use. If non-zero the entry was deemed not suitable and it's
106 * contents explains why. The following flags are or'd to to this
107 * mask and can be used to figure out why the entry was rejected.

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

338 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_SCAN, macaddr,
339 "%s: fails %u", __func__, se->se_fails);
340 }
341
342 se->se_lastupdate = ticks; /* update time */
343 se->se_seen = 1;
344 se->se_notseen = 0;
345
103};
104
105static void sta_flush_table(struct sta_table *);
106/*
107 * match_bss returns a bitmask describing if an entry is suitable
108 * for use. If non-zero the entry was deemed not suitable and it's
109 * contents explains why. The following flags are or'd to to this
110 * mask and can be used to figure out why the entry was rejected.

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

341 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_SCAN, macaddr,
342 "%s: fails %u", __func__, se->se_fails);
343 }
344
345 se->se_lastupdate = ticks; /* update time */
346 se->se_seen = 1;
347 se->se_notseen = 0;
348
349 KASSERT(sizeof(sp->bchan) == 1, ("bchan size"));
346 if (rssi > st->st_maxrssi[sp->bchan])
347 st->st_maxrssi[sp->bchan] = rssi;
348
349 mtx_unlock(&st->st_lock);
350
351 /*
352 * If looking for a quick choice and nothing's
353 * been found check here.

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

1599 */
1600 if (IEEE80211_IS_CHAN_RADAR(chan))
1601 continue;
1602 if (IEEE80211_IS_CHAN_NOHOSTAP(chan))
1603 continue;
1604 /* check channel attributes for band compatibility */
1605 if (flags != 0 && (chan->ic_flags & flags) != flags)
1606 continue;
350 if (rssi > st->st_maxrssi[sp->bchan])
351 st->st_maxrssi[sp->bchan] = rssi;
352
353 mtx_unlock(&st->st_lock);
354
355 /*
356 * If looking for a quick choice and nothing's
357 * been found check here.

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

1603 */
1604 if (IEEE80211_IS_CHAN_RADAR(chan))
1605 continue;
1606 if (IEEE80211_IS_CHAN_NOHOSTAP(chan))
1607 continue;
1608 /* check channel attributes for band compatibility */
1609 if (flags != 0 && (chan->ic_flags & flags) != flags)
1610 continue;
1611 KASSERT(sizeof(chan->ic_ieee) == 1, ("ic_chan size"));
1607 /* XXX channel have interference */
1608 if (st->st_maxrssi[chan->ic_ieee] == 0) {
1609 /* XXX use other considerations */
1610 return chan;
1611 }
1612 if (bestchan == NULL ||
1613 st->st_maxrssi[chan->ic_ieee] < st->st_maxrssi[bestchan->ic_ieee])
1614 bestchan = chan;

--- 74 unchanged lines hidden ---
1612 /* XXX channel have interference */
1613 if (st->st_maxrssi[chan->ic_ieee] == 0) {
1614 /* XXX use other considerations */
1615 return chan;
1616 }
1617 if (bestchan == NULL ||
1618 st->st_maxrssi[chan->ic_ieee] < st->st_maxrssi[bestchan->ic_ieee])
1619 bestchan = chan;

--- 74 unchanged lines hidden ---