MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sta_pick_bss

Function sta_pick_bss

freebsd/net80211/ieee80211_scan_sta.c:1258–1320  ·  view source on GitHub ↗

* Pick an ap or ibss network to join or find a channel * to use to start an ibss network. */

Source from the content-addressed store, hash-verified

1256 * to use to start an ibss network.
1257 */
1258static int
1259sta_pick_bss(struct ieee80211_scan_state *ss, struct ieee80211vap *vap)
1260{
1261 struct sta_table *st = ss->ss_priv;
1262 struct sta_entry *selbs;
1263 struct ieee80211_channel *chan;
1264
1265 KASSERT(vap->iv_opmode == IEEE80211_M_STA,
1266 ("wrong mode %u", vap->iv_opmode));
1267
1268 if (st->st_newscan) {
1269 sta_update_notseen(st);
1270 st->st_newscan = 0;
1271 }
1272 if (ss->ss_flags & IEEE80211_SCAN_NOPICK) {
1273 /*
1274 * Manual/background scan, don't select+join the
1275 * bss, just return. The scanning framework will
1276 * handle notification that this has completed.
1277 */
1278 ss->ss_flags &= ~IEEE80211_SCAN_NOPICK;
1279 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
1280 "%s: nopick; return 1\n", __func__);
1281 return 1;
1282 }
1283 /*
1284 * Automatic sequencing; look for a candidate and
1285 * if found join the network.
1286 */
1287 /* NB: unlocked read should be ok */
1288 if (TAILQ_FIRST(&st->st_entry) == NULL) {
1289 IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
1290 "%s: no scan candidate, join=%d, return 0\n",
1291 __func__,
1292 !! (ss->ss_flags & IEEE80211_SCAN_NOJOIN));
1293 if (ss->ss_flags & IEEE80211_SCAN_NOJOIN)
1294 return 0;
1295notfound:
1296 /*
1297 * If nothing suitable was found decrement
1298 * the failure counts so entries will be
1299 * reconsidered the next time around. We
1300 * really want to do this only for sta's
1301 * where we've previously had some success.
1302 */
1303 sta_dec_fails(st);
1304 st->st_newscan = 1;
1305 return 0; /* restart scan */
1306 }
1307 selbs = select_bss(ss, vap, IEEE80211_MSG_SCAN);
1308 if (ss->ss_flags & IEEE80211_SCAN_NOJOIN)
1309 return (selbs != NULL);
1310 if (selbs == NULL)
1311 goto notfound;
1312 chan = selbs->base.se_chan;
1313 if (selbs->se_flags & STA_DEMOTE11B)
1314 chan = demote11b(vap, chan);
1315 if (!ieee80211_sta_join(vap, chan, &selbs->base))

Callers

nothing calls this directly

Calls 5

sta_update_notseenFunction · 0.85
sta_dec_failsFunction · 0.85
select_bssFunction · 0.85
demote11bFunction · 0.85
ieee80211_sta_joinFunction · 0.85

Tested by

no test coverage detected