Deleted Added
full compact
ieee80211_scan_sta.c (184205) ieee80211_scan_sta.c (184210)
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 184205 2008-10-23 15:53:51Z des $");
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_scan_sta.c 184210 2008-10-23 19:57:13Z des $");
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>

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

133/*
134 * Attach prior to any scanning work.
135 */
136static int
137sta_attach(struct ieee80211_scan_state *ss)
138{
139 struct sta_table *st;
140
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>

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

133/*
134 * Attach prior to any scanning work.
135 */
136static int
137sta_attach(struct ieee80211_scan_state *ss)
138{
139 struct sta_table *st;
140
141 st = malloc(sizeof(struct sta_table),
141 MALLOC(st, struct sta_table *, sizeof(struct sta_table),
142 M_80211_SCAN, M_NOWAIT | M_ZERO);
143 if (st == NULL)
144 return 0;
145 mtx_init(&st->st_lock, "scantable", "802.11 scan table", MTX_DEF);
146 mtx_init(&st->st_scanlock, "scangen", "802.11 scangen", MTX_DEF);
147 TAILQ_INIT(&st->st_entry);
148 ss->ss_priv = st;
149 nrefs++; /* NB: we assume caller locking */

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

157sta_detach(struct ieee80211_scan_state *ss)
158{
159 struct sta_table *st = ss->ss_priv;
160
161 if (st != NULL) {
162 sta_flush_table(st);
163 mtx_destroy(&st->st_lock);
164 mtx_destroy(&st->st_scanlock);
142 M_80211_SCAN, M_NOWAIT | M_ZERO);
143 if (st == NULL)
144 return 0;
145 mtx_init(&st->st_lock, "scantable", "802.11 scan table", MTX_DEF);
146 mtx_init(&st->st_scanlock, "scangen", "802.11 scangen", MTX_DEF);
147 TAILQ_INIT(&st->st_entry);
148 ss->ss_priv = st;
149 nrefs++; /* NB: we assume caller locking */

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

157sta_detach(struct ieee80211_scan_state *ss)
158{
159 struct sta_table *st = ss->ss_priv;
160
161 if (st != NULL) {
162 sta_flush_table(st);
163 mtx_destroy(&st->st_lock);
164 mtx_destroy(&st->st_scanlock);
165 free(st, M_80211_SCAN);
165 FREE(st, M_80211_SCAN);
166 KASSERT(nrefs > 0, ("imbalanced attach/detach"));
167 nrefs--; /* NB: we assume caller locking */
168 }
169 return 1;
170}
171
172/*
173 * Flush all per-scan state.

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

191sta_flush_table(struct sta_table *st)
192{
193 struct sta_entry *se, *next;
194
195 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) {
196 TAILQ_REMOVE(&st->st_entry, se, se_list);
197 LIST_REMOVE(se, se_hash);
198 ieee80211_ies_cleanup(&se->base.se_ies);
166 KASSERT(nrefs > 0, ("imbalanced attach/detach"));
167 nrefs--; /* NB: we assume caller locking */
168 }
169 return 1;
170}
171
172/*
173 * Flush all per-scan state.

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

191sta_flush_table(struct sta_table *st)
192{
193 struct sta_entry *se, *next;
194
195 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) {
196 TAILQ_REMOVE(&st->st_entry, se, se_list);
197 LIST_REMOVE(se, se_hash);
198 ieee80211_ies_cleanup(&se->base.se_ies);
199 free(se, M_80211_SCAN);
199 FREE(se, M_80211_SCAN);
200 }
201 memset(st->st_maxrssi, 0, sizeof(st->st_maxrssi));
202}
203
204/*
205 * Process a beacon or probe response frame; create an
206 * entry in the scan cache or update any previous entry.
207 */

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

224 int hash;
225
226 hash = STA_HASH(macaddr);
227
228 mtx_lock(&st->st_lock);
229 LIST_FOREACH(se, &st->st_hash[hash], se_hash)
230 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr))
231 goto found;
200 }
201 memset(st->st_maxrssi, 0, sizeof(st->st_maxrssi));
202}
203
204/*
205 * Process a beacon or probe response frame; create an
206 * entry in the scan cache or update any previous entry.
207 */

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

224 int hash;
225
226 hash = STA_HASH(macaddr);
227
228 mtx_lock(&st->st_lock);
229 LIST_FOREACH(se, &st->st_hash[hash], se_hash)
230 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr))
231 goto found;
232 se = malloc(sizeof(struct sta_entry),
232 MALLOC(se, struct sta_entry *, sizeof(struct sta_entry),
233 M_80211_SCAN, M_NOWAIT | M_ZERO);
234 if (se == NULL) {
235 mtx_unlock(&st->st_lock);
236 return 0;
237 }
238 se->se_scangen = st->st_scaniter-1;
239 se->se_avgrssi = IEEE80211_RSSI_DUMMY_MARKER;
240 IEEE80211_ADDR_COPY(se->base.se_macaddr, macaddr);

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

1434 struct sta_entry *se, *next;
1435
1436 mtx_lock(&st->st_lock);
1437 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) {
1438 if (se->se_notseen > STA_PURGE_SCANS) {
1439 TAILQ_REMOVE(&st->st_entry, se, se_list);
1440 LIST_REMOVE(se, se_hash);
1441 ieee80211_ies_cleanup(&se->base.se_ies);
233 M_80211_SCAN, M_NOWAIT | M_ZERO);
234 if (se == NULL) {
235 mtx_unlock(&st->st_lock);
236 return 0;
237 }
238 se->se_scangen = st->st_scaniter-1;
239 se->se_avgrssi = IEEE80211_RSSI_DUMMY_MARKER;
240 IEEE80211_ADDR_COPY(se->base.se_macaddr, macaddr);

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

1434 struct sta_entry *se, *next;
1435
1436 mtx_lock(&st->st_lock);
1437 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) {
1438 if (se->se_notseen > STA_PURGE_SCANS) {
1439 TAILQ_REMOVE(&st->st_entry, se, se_list);
1440 LIST_REMOVE(se, se_hash);
1441 ieee80211_ies_cleanup(&se->base.se_ies);
1442 free(se, M_80211_SCAN);
1442 FREE(se, M_80211_SCAN);
1443 }
1444 }
1445 mtx_unlock(&st->st_lock);
1446}
1447
1448static const struct ieee80211_scanner adhoc_default = {
1449 .scan_name = "default",
1450 .scan_attach = sta_attach,

--- 172 unchanged lines hidden ---
1443 }
1444 }
1445 mtx_unlock(&st->st_lock);
1446}
1447
1448static const struct ieee80211_scanner adhoc_default = {
1449 .scan_name = "default",
1450 .scan_attach = sta_attach,

--- 172 unchanged lines hidden ---