ieee80211_scan_sta.c (282742) | ieee80211_scan_sta.c (283538) |
---|---|
1/*- 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 --- 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-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 --- 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 282742 2015-05-10 22:07:53Z adrian $"); | 27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_scan_sta.c 283538 2015-05-25 19:18:16Z adrian $"); |
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> --- 118 unchanged lines hidden (view full) --- 154/* 155 * Attach prior to any scanning work. 156 */ 157static int 158sta_attach(struct ieee80211_scan_state *ss) 159{ 160 struct sta_table *st; 161 | 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> --- 118 unchanged lines hidden (view full) --- 154/* 155 * Attach prior to any scanning work. 156 */ 157static int 158sta_attach(struct ieee80211_scan_state *ss) 159{ 160 struct sta_table *st; 161 |
162 st = (struct sta_table *) malloc(sizeof(struct sta_table), 163 M_80211_SCAN, M_NOWAIT | M_ZERO); | 162 st = (struct sta_table *) IEEE80211_MALLOC(sizeof(struct sta_table), 163 M_80211_SCAN, 164 IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); |
164 if (st == NULL) 165 return 0; 166 IEEE80211_SCAN_TABLE_LOCK_INIT(st, "scantable"); 167 mtx_init(&st->st_scanlock, "scangen", "802.11 scangen", MTX_DEF); 168 TAILQ_INIT(&st->st_entry); 169 ss->ss_priv = st; 170 nrefs++; /* NB: we assume caller locking */ 171 return 1; --- 6 unchanged lines hidden (view full) --- 178sta_detach(struct ieee80211_scan_state *ss) 179{ 180 struct sta_table *st = ss->ss_priv; 181 182 if (st != NULL) { 183 sta_flush_table(st); 184 IEEE80211_SCAN_TABLE_LOCK_DESTROY(st); 185 mtx_destroy(&st->st_scanlock); | 165 if (st == NULL) 166 return 0; 167 IEEE80211_SCAN_TABLE_LOCK_INIT(st, "scantable"); 168 mtx_init(&st->st_scanlock, "scangen", "802.11 scangen", MTX_DEF); 169 TAILQ_INIT(&st->st_entry); 170 ss->ss_priv = st; 171 nrefs++; /* NB: we assume caller locking */ 172 return 1; --- 6 unchanged lines hidden (view full) --- 179sta_detach(struct ieee80211_scan_state *ss) 180{ 181 struct sta_table *st = ss->ss_priv; 182 183 if (st != NULL) { 184 sta_flush_table(st); 185 IEEE80211_SCAN_TABLE_LOCK_DESTROY(st); 186 mtx_destroy(&st->st_scanlock); |
186 free(st, M_80211_SCAN); | 187 IEEE80211_FREE(st, M_80211_SCAN); |
187 KASSERT(nrefs > 0, ("imbalanced attach/detach")); 188 nrefs--; /* NB: we assume caller locking */ 189 } 190 return 1; 191} 192 193/* 194 * Flush all per-scan state. --- 17 unchanged lines hidden (view full) --- 212sta_flush_table(struct sta_table *st) 213{ 214 struct sta_entry *se, *next; 215 216 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 217 TAILQ_REMOVE(&st->st_entry, se, se_list); 218 LIST_REMOVE(se, se_hash); 219 ieee80211_ies_cleanup(&se->base.se_ies); | 188 KASSERT(nrefs > 0, ("imbalanced attach/detach")); 189 nrefs--; /* NB: we assume caller locking */ 190 } 191 return 1; 192} 193 194/* 195 * Flush all per-scan state. --- 17 unchanged lines hidden (view full) --- 213sta_flush_table(struct sta_table *st) 214{ 215 struct sta_entry *se, *next; 216 217 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 218 TAILQ_REMOVE(&st->st_entry, se, se_list); 219 LIST_REMOVE(se, se_hash); 220 ieee80211_ies_cleanup(&se->base.se_ies); |
220 free(se, M_80211_SCAN); | 221 IEEE80211_FREE(se, M_80211_SCAN); |
221 } 222 memset(st->st_maxrssi, 0, sizeof(st->st_maxrssi)); 223} 224 225/* 226 * Process a beacon or probe response frame; create an 227 * entry in the scan cache or update any previous entry. 228 */ --- 18 unchanged lines hidden (view full) --- 247 int hash; 248 249 hash = STA_HASH(macaddr); 250 251 IEEE80211_SCAN_TABLE_LOCK(st); 252 LIST_FOREACH(se, &st->st_hash[hash], se_hash) 253 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr)) 254 goto found; | 222 } 223 memset(st->st_maxrssi, 0, sizeof(st->st_maxrssi)); 224} 225 226/* 227 * Process a beacon or probe response frame; create an 228 * entry in the scan cache or update any previous entry. 229 */ --- 18 unchanged lines hidden (view full) --- 248 int hash; 249 250 hash = STA_HASH(macaddr); 251 252 IEEE80211_SCAN_TABLE_LOCK(st); 253 LIST_FOREACH(se, &st->st_hash[hash], se_hash) 254 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr)) 255 goto found; |
255 se = (struct sta_entry *) malloc(sizeof(struct sta_entry), 256 M_80211_SCAN, M_NOWAIT | M_ZERO); | 256 se = (struct sta_entry *) IEEE80211_MALLOC(sizeof(struct sta_entry), 257 M_80211_SCAN, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); |
257 if (se == NULL) { 258 IEEE80211_SCAN_TABLE_UNLOCK(st); 259 return 0; 260 } 261 se->se_scangen = st->st_scaniter-1; 262 se->se_avgrssi = IEEE80211_RSSI_DUMMY_MARKER; 263 IEEE80211_ADDR_COPY(se->base.se_macaddr, macaddr); 264 TAILQ_INSERT_TAIL(&st->st_entry, se, se_list); --- 1410 unchanged lines hidden (view full) --- 1675 struct sta_entry *se, *next; 1676 1677 IEEE80211_SCAN_TABLE_LOCK(st); 1678 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 1679 if (se->se_notseen > STA_PURGE_SCANS) { 1680 TAILQ_REMOVE(&st->st_entry, se, se_list); 1681 LIST_REMOVE(se, se_hash); 1682 ieee80211_ies_cleanup(&se->base.se_ies); | 258 if (se == NULL) { 259 IEEE80211_SCAN_TABLE_UNLOCK(st); 260 return 0; 261 } 262 se->se_scangen = st->st_scaniter-1; 263 se->se_avgrssi = IEEE80211_RSSI_DUMMY_MARKER; 264 IEEE80211_ADDR_COPY(se->base.se_macaddr, macaddr); 265 TAILQ_INSERT_TAIL(&st->st_entry, se, se_list); --- 1410 unchanged lines hidden (view full) --- 1676 struct sta_entry *se, *next; 1677 1678 IEEE80211_SCAN_TABLE_LOCK(st); 1679 TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 1680 if (se->se_notseen > STA_PURGE_SCANS) { 1681 TAILQ_REMOVE(&st->st_entry, se, se_list); 1682 LIST_REMOVE(se, se_hash); 1683 ieee80211_ies_cleanup(&se->base.se_ies); |
1683 free(se, M_80211_SCAN); | 1684 IEEE80211_FREE(se, M_80211_SCAN); |
1684 } 1685 } 1686 IEEE80211_SCAN_TABLE_UNLOCK(st); 1687} 1688 1689static const struct ieee80211_scanner adhoc_default = { 1690 .scan_name = "default", 1691 .scan_attach = sta_attach, --- 271 unchanged lines hidden --- | 1685 } 1686 } 1687 IEEE80211_SCAN_TABLE_UNLOCK(st); 1688} 1689 1690static const struct ieee80211_scanner adhoc_default = { 1691 .scan_name = "default", 1692 .scan_attach = sta_attach, --- 271 unchanged lines hidden --- |