iPXE
802.11 network location API

Functions

int net80211_prepare_probe (struct net80211_device *dev, int band, int active)
 Prepare 802.11 device channel and rate set for scanning.
struct net80211_probe_ctxnet80211_probe_start (struct net80211_device *dev, const char *essid, int active)
 Begin probe of 802.11 networks.
int net80211_probe_step (struct net80211_probe_ctx *ctx)
 Continue probe of 802.11 networks.
struct net80211_wlannet80211_probe_finish_best (struct net80211_probe_ctx *ctx)
 Finish probe of 802.11 networks, returning best-signal network found.
struct list_headnet80211_probe_finish_all (struct net80211_probe_ctx *ctx)
 Finish probe of 802.11 networks, returning all networks found.
void net80211_free_wlan (struct net80211_wlan *wlan)
 Free WLAN structure.
void net80211_free_wlanlist (struct list_head *list)
 Free list of WLAN structures.

Detailed Description

Function Documentation

◆ net80211_prepare_probe()

int net80211_prepare_probe ( struct net80211_device * dev,
int band,
int active )

Prepare 802.11 device channel and rate set for scanning.

Parameters
dev802.11 device
bandRF band(s) on which to prepare for scanning
activeWhether the scanning will be active
Return values
rcReturn status code

Definition at line 2052 of file net80211.c.

2054{
2055 assert ( netdev_is_open ( dev->netdev ) );
2056
2057 if ( active && ( band & NET80211_BAND_BIT_5GHZ ) ) {
2058 DBGC ( dev, "802.11 %p cannot perform active scanning on "
2059 "5GHz band\n", dev );
2060 return -EINVAL_ACTIVE_SCAN;
2061 }
2062
2063 if ( band == 0 ) {
2064 /* This can happen for a 5GHz-only card with 5GHz
2065 scanning masked out by an active request. */
2066 DBGC ( dev, "802.11 %p asked to prepare for scanning nothing\n",
2067 dev );
2068 return -EINVAL_ACTIVE_SCAN;
2069 }
2070
2071 dev->nr_channels = 0;
2072
2073 if ( active )
2075 else {
2076 if ( band & NET80211_BAND_BIT_2GHZ )
2077 net80211_add_channels ( dev, 1, 14,
2079 if ( band & NET80211_BAND_BIT_5GHZ )
2080 net80211_add_channels ( dev, 36, 8,
2082 }
2083
2085
2086 /* Use channel 1 for now */
2087 dev->channel = 0;
2088 dev->op->config ( dev, NET80211_CFG_CHANNEL );
2089
2090 /* Always do active probes at lowest (presumably first) speed */
2091 dev->rate = 0;
2092 dev->nr_rates = 1;
2093 dev->rates[0] = dev->hw->rates[dev->channels[0].band][0];
2094 dev->op->config ( dev, NET80211_CFG_RATE );
2095
2096 return 0;
2097}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
#define DBGC(...)
Definition compiler.h:505
#define NET80211_BAND_BIT_2GHZ
Bitmask for the 2GHz band.
Definition net80211.h:52
#define NET80211_BAND_BIT_5GHZ
Bitmask for the 5GHz band.
Definition net80211.h:54
#define NET80211_CFG_CHANNEL
Channel choice (dev->channel) or regulatory parameters have changed.
Definition net80211.h:81
#define NET80211_CFG_RATE
Requested transmission rate (dev->rate) has changed.
Definition net80211.h:84
static void net80211_add_channels(struct net80211_device *dev, int start, int len, int txpower)
Add channels to 802.11 device.
Definition net80211.c:918
static void net80211_filter_hw_channels(struct net80211_device *dev)
Filter 802.11 device channels for hardware capabilities.
Definition net80211.c:962
#define NET80211_REG_TXPOWER
Maximum TX power to allow (dBm), if we don't get a regulatory hint.
Definition net80211.h:287
#define EINVAL_ACTIVE_SCAN
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition netdevice.h:662
u8 band
The band with which this channel is associated.
Definition net80211.h:388
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition net80211.h:381
struct net_device * netdev
The net_device that wraps us.
Definition net80211.h:789
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition net80211.h:818
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition net80211.h:806
struct net80211_device_operations * op
802.11 device operations
Definition net80211.h:795
u8 channel
The channel currently in use, as an index into the channels array.
Definition net80211.h:812
u8 nr_channels
The number of channels in the channels array.
Definition net80211.h:809
u8 rate
The rate currently in use, as an index into the rates array.
Definition net80211.h:824
struct net80211_hw_info * hw
Information about the hardware, provided to net80211_register()
Definition net80211.h:801
u8 nr_rates
The number of transmission rates in the rates array.
Definition net80211.h:821
u16 rates[NET80211_NR_BANDS][NET80211_MAX_RATES]
List of transmission rates supported by the card, indexed by band.
Definition net80211.h:508

References assert, net80211_channel::band, net80211_device::channel, net80211_device::channels, net80211_device_operations::config, DBGC, EINVAL_ACTIVE_SCAN, net80211_device::hw, net80211_add_channels(), NET80211_BAND_BIT_2GHZ, NET80211_BAND_BIT_5GHZ, NET80211_CFG_CHANNEL, NET80211_CFG_RATE, net80211_filter_hw_channels(), NET80211_REG_TXPOWER, net80211_device::netdev, netdev_is_open(), net80211_device::nr_channels, net80211_device::nr_rates, net80211_device::op, net80211_device::rate, net80211_device::rates, and net80211_hw_info::rates.

Referenced by iwlist(), and net80211_step_associate().

◆ net80211_probe_start()

struct net80211_probe_ctx * net80211_probe_start ( struct net80211_device * dev,
const char * essid,
int active )

Begin probe of 802.11 networks.

Parameters
dev802.11 device
essidSSID to probe for, or "" to accept any (may not be NULL)
activeWhether to use active scanning
Return values
ctxProbe context

Active scanning may only be used on channels 1-11 in the 2.4GHz band, due to iPXE's lack of a complete regulatory database. If active scanning is used, probe packets will be sent on each channel; this can allow association with hidden-SSID networks if the SSID is properly specified.

A NULL return indicates an out-of-memory condition.

The returned context must be periodically passed to net80211_probe_step() until that function returns zero.

Definition at line 1291 of file net80211.c.

1294{
1295 struct net80211_probe_ctx *ctx = zalloc ( sizeof ( *ctx ) );
1296
1297 if ( ! ctx )
1298 return NULL;
1299
1301
1302 ctx->dev = dev;
1303 ctx->old_keep_mgmt = net80211_keep_mgmt ( dev, 1 );
1304 ctx->essid = essid;
1305 if ( dev->essid != ctx->essid )
1306 strcpy ( dev->essid, ctx->essid );
1307
1308 if ( active ) {
1309 struct ieee80211_probe_req *probe_req;
1310 union ieee80211_ie *ie;
1311
1312 ctx->probe = alloc_iob ( 128 );
1314 probe_req = ctx->probe->data;
1315
1317 probe_req->info_element );
1318
1319 iob_put ( ctx->probe, ( void * ) ie - ctx->probe->data );
1320 }
1321
1322 ctx->ticks_start = currticks();
1323 ctx->ticks_beacon = 0;
1324 ctx->ticks_channel = currticks();
1325 ctx->hop_time = TICKS_PER_SEC / ( active ? 2 : 6 );
1326
1327 /*
1328 * Channels on 2.4GHz overlap, and the most commonly used
1329 * are 1, 6, and 11. We'll get a result faster if we check
1330 * every 5 channels, but in order to hit all of them the
1331 * number of channels must be relatively prime to 5. If it's
1332 * not, tweak the hop.
1333 */
1334 ctx->hop_step = 5;
1335 while ( dev->nr_channels % ctx->hop_step == 0 && ctx->hop_step > 1 )
1336 ctx->hop_step--;
1337
1338 ctx->beacons = malloc ( sizeof ( *ctx->beacons ) );
1339 INIT_LIST_HEAD ( ctx->beacons );
1340
1341 dev->channel = 0;
1342 dev->op->config ( dev, NET80211_CFG_CHANNEL );
1343
1344 return ctx;
1345}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct golan_eq_context ctx
Definition CIB_PRM.h:0
#define IEEE80211_TYP_FRAME_HEADER_LEN
Frame header length for frames we might work with.
Definition ieee80211.h:60
static union ieee80211_ie * net80211_marshal_request_info(struct net80211_device *dev, union ieee80211_ie *ie)
Create information elements for outgoing probe or association packet.
Definition net80211.c:1203
int net80211_keep_mgmt(struct net80211_device *dev, int enable)
Set state of 802.11 device keeping management frames.
Definition net80211.c:647
#define TICKS_PER_SEC
Number of ticks per second.
Definition timer.h:16
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
#define iob_put(iobuf, len)
Definition iobuf.h:125
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition list.h:46
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
void * malloc(size_t size)
Allocate memory.
Definition malloc.c:621
char * strcpy(char *dest, const char *src)
Copy string.
Definition string.c:347
Probe request frame data.
Definition ieee80211.h:1132
union ieee80211_ie info_element[0]
List of information elements.
Definition ieee80211.h:1134
char essid[IEEE80211_MAX_SSID_LEN+1]
SSID of the access point we are or will be associated with.
Definition net80211.h:962
Context for a probe operation.
Definition net80211.c:64
const char * essid
If non-"", the ESSID to limit ourselves to.
Definition net80211.c:75
struct net80211_device * dev
802.11 device to probe on
Definition net80211.c:66
unsigned long currticks(void)
Get current system time in ticks.
Definition timer.c:43
Any 802.11 information element.
Definition ieee80211.h:973

References alloc_iob(), assert, net80211_device::channel, net80211_device_operations::config, ctx, currticks(), net80211_probe_ctx::dev, net80211_device::essid, net80211_probe_ctx::essid, IEEE80211_TYP_FRAME_HEADER_LEN, ieee80211_probe_req::info_element, INIT_LIST_HEAD, iob_put, iob_reserve, malloc(), NET80211_CFG_CHANNEL, net80211_keep_mgmt(), net80211_marshal_request_info(), net80211_device::netdev, netdev_is_open(), net80211_device::nr_channels, NULL, net80211_device::op, strcpy(), TICKS_PER_SEC, and zalloc().

Referenced by iwlist(), and net80211_step_associate().

◆ net80211_probe_step()

int net80211_probe_step ( struct net80211_probe_ctx * ctx)

Continue probe of 802.11 networks.

Parameters
ctxProbe context returned by net80211_probe_start()
Return values
rcProbe status

The return code will be 0 if the probe is still going on (and this function should be called again), a positive number if the probe completed successfully, or a negative error code if the probe failed for that reason.

Whether the probe succeeded or failed, you must call net80211_probe_finish_all() or net80211_probe_finish_best() (depending on whether you want information on all networks or just the best-signal one) in order to release the probe context. A failed probe may still have acquired some valid data.

Definition at line 1364 of file net80211.c.

1365{
1366 struct net80211_device *dev = ctx->dev;
1367 u32 start_timeout = NET80211_PROBE_TIMEOUT * TICKS_PER_SEC;
1368 u32 gather_timeout = TICKS_PER_SEC;
1369 u32 now = currticks();
1370 struct io_buffer *iob;
1371 int signal;
1372 int rc;
1373 char ssid[IEEE80211_MAX_SSID_LEN + 1];
1374
1375 gather_timeout *= ( ctx->essid[0] ? NET80211_PROBE_GATHER :
1377
1378 /* Time out if necessary */
1379 if ( now >= ctx->ticks_start + start_timeout )
1380 return list_empty ( ctx->beacons ) ? -ETIMEDOUT : +1;
1381
1382 if ( ctx->ticks_beacon > 0 && now >= ctx->ticks_start + gather_timeout )
1383 return +1;
1384
1385 /* Change channels if necessary */
1386 if ( now >= ctx->ticks_channel + ctx->hop_time ) {
1387 dev->channel = ( dev->channel + ctx->hop_step )
1388 % dev->nr_channels;
1389 dev->op->config ( dev, NET80211_CFG_CHANNEL );
1390 udelay ( dev->hw->channel_change_time );
1391
1392 ctx->ticks_channel = now;
1393
1394 if ( ctx->probe ) {
1395 struct io_buffer *siob = ctx->probe; /* to send */
1396
1397 /* make a copy for future use */
1398 iob = alloc_iob ( siob->tail - siob->head );
1399 iob_reserve ( iob, iob_headroom ( siob ) );
1400 memcpy ( iob_put ( iob, iob_len ( siob ) ),
1401 siob->data, iob_len ( siob ) );
1402
1403 ctx->probe = iob;
1406 iob_disown ( siob ) );
1407 if ( rc ) {
1408 DBGC ( dev, "802.11 %p send probe failed: "
1409 "%s\n", dev, strerror ( rc ) );
1410 return rc;
1411 }
1412 }
1413 }
1414
1415 /* Check for new management packets */
1416 while ( ( iob = net80211_mgmt_dequeue ( dev, &signal ) ) != NULL ) {
1417 struct ieee80211_frame *hdr;
1418 struct ieee80211_beacon *beacon;
1419 union ieee80211_ie *ie;
1420 struct net80211_wlan *wlan;
1421 u16 type;
1422
1423 hdr = iob->data;
1425 beacon = ( struct ieee80211_beacon * ) hdr->data;
1426
1427 if ( type != IEEE80211_STYPE_BEACON &&
1429 DBGC2 ( dev, "802.11 %p probe: non-beacon\n", dev );
1430 goto drop;
1431 }
1432
1433 if ( ( void * ) beacon->info_element >= iob->tail ) {
1434 DBGC ( dev, "802.11 %p probe: beacon with no IEs\n",
1435 dev );
1436 goto drop;
1437 }
1438
1439 ie = beacon->info_element;
1440
1441 if ( ! ieee80211_ie_bound ( ie, iob->tail ) )
1442 ie = NULL;
1443
1444 while ( ie && ie->id != IEEE80211_IE_SSID )
1445 ie = ieee80211_next_ie ( ie, iob->tail );
1446
1447 if ( ! ie ) {
1448 DBGC ( dev, "802.11 %p probe: beacon with no SSID\n",
1449 dev );
1450 goto drop;
1451 }
1452
1453 memcpy ( ssid, ie->ssid, ie->len );
1454 ssid[ie->len] = 0;
1455
1456 if ( ctx->essid[0] && strcmp ( ctx->essid, ssid ) != 0 ) {
1457 DBGC2 ( dev, "802.11 %p probe: beacon with wrong SSID "
1458 "(%s)\n", dev, ssid );
1459 goto drop;
1460 }
1461
1462 /* See if we've got an entry for this network */
1463 list_for_each_entry ( wlan, ctx->beacons, list ) {
1464 if ( strcmp ( wlan->essid, ssid ) != 0 )
1465 continue;
1466
1467 if ( signal < wlan->signal ) {
1468 DBGC2 ( dev, "802.11 %p probe: beacon for %s "
1469 "(%s) with weaker signal %d\n", dev,
1470 ssid, eth_ntoa ( hdr->addr3 ), signal );
1471 goto drop;
1472 }
1473
1474 goto fill;
1475 }
1476
1477 /* No entry yet - make one */
1478 wlan = zalloc ( sizeof ( *wlan ) );
1479 strcpy ( wlan->essid, ssid );
1480 list_add_tail ( &wlan->list, ctx->beacons );
1481
1482 /* Whether we're using an old entry or a new one, fill
1483 it with new data. */
1484 fill:
1485 memcpy ( wlan->bssid, hdr->addr3, ETH_ALEN );
1486 wlan->signal = signal;
1487 wlan->channel = dev->channels[dev->channel].channel_nr;
1488
1489 /* Copy this I/O buffer into a new wlan->beacon; the
1490 * iob we've got probably came from the device driver
1491 * and may have the full 2.4k allocation, which we
1492 * don't want to keep around wasting memory.
1493 */
1494 free_iob ( wlan->beacon );
1495 wlan->beacon = alloc_iob ( iob_len ( iob ) );
1496 memcpy ( iob_put ( wlan->beacon, iob_len ( iob ) ),
1497 iob->data, iob_len ( iob ) );
1498
1499 if ( ( rc = sec80211_detect ( wlan->beacon, &wlan->handshaking,
1500 &wlan->crypto ) ) == -ENOTSUP ) {
1501 struct ieee80211_beacon *beacon =
1502 ( struct ieee80211_beacon * ) hdr->data;
1503
1504 if ( beacon->capability & IEEE80211_CAPAB_PRIVACY ) {
1505 DBG ( "802.11 %p probe: secured network %s but "
1506 "encryption support not compiled in\n",
1507 dev, wlan->essid );
1508 wlan->handshaking = NET80211_SECPROT_UNKNOWN;
1509 wlan->crypto = NET80211_CRYPT_UNKNOWN;
1510 } else {
1511 wlan->handshaking = NET80211_SECPROT_NONE;
1512 wlan->crypto = NET80211_CRYPT_NONE;
1513 }
1514 } else if ( rc != 0 ) {
1515 DBGC ( dev, "802.11 %p probe warning: network "
1516 "%s with unidentifiable security "
1517 "settings: %s\n", dev, wlan->essid,
1518 strerror ( rc ) );
1519 }
1520
1521 ctx->ticks_beacon = now;
1522
1523 DBGC2 ( dev, "802.11 %p probe: good beacon for %s (%s)\n",
1524 dev, wlan->essid, eth_ntoa ( wlan->bssid ) );
1525
1526 drop:
1527 free_iob ( iob );
1528 }
1529
1530 return 0;
1531}
struct golan_inbox_hdr hdr
Message header.
Definition CIB_PRM.h:0
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static int fill
Definition string.h:209
uint32_t type
Operating system type.
Definition ena.h:1
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
uint8_t eth_broadcast[ETH_ALEN]
Ethernet broadcast MAC address.
Definition ethernet.c:48
#define DBGC2(...)
Definition compiler.h:522
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define IEEE80211_CAPAB_PRIVACY
Set if the network is encrypted (by any method)
Definition ieee80211.h:401
#define IEEE80211_FC_SUBTYPE
802.11 Frame Control field, Frame Subtype bitmask
Definition ieee80211.h:110
#define IEEE80211_STYPE_PROBE_RESP
Subtype value for probe-response management frames.
Definition ieee80211.h:157
#define IEEE80211_STYPE_BEACON
Subtype value for beacon management frames.
Definition ieee80211.h:168
#define IEEE80211_STYPE_PROBE_REQ
Subtype value for probe-request management frames.
Definition ieee80211.h:150
#define IEEE80211_IE_SSID
Information element ID for SSID information element.
Definition ieee80211.h:582
static int ieee80211_ie_bound(union ieee80211_ie *ie, void *end)
Check that 802.11 information element is bounded by buffer.
Definition ieee80211.h:1012
static union ieee80211_ie * ieee80211_next_ie(union ieee80211_ie *ie, void *end)
Advance to next 802.11 information element.
Definition ieee80211.h:1028
#define IEEE80211_MAX_SSID_LEN
Maximum length of an ESSID.
Definition ieee80211.h:77
#define ieee80211_beacon
Definition ieee80211.h:1069
struct io_buffer * net80211_mgmt_dequeue(struct net80211_device *dev, int *signal)
Get 802.11 management frame.
Definition net80211.c:668
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define ENOTSUP
Operation not supported.
Definition errno.h:590
char ssid[0]
SSID data, not NUL-terminated.
Definition ieee80211.h:2
#define ETH_ALEN
Definition if_ether.h:9
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
static size_t iob_headroom(struct io_buffer *iobuf)
Calculate available space at start of an I/O buffer.
Definition iobuf.h:170
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition iobuf.h:217
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition list.h:94
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
#define list_empty(list)
Test whether a list is empty.
Definition list.h:137
int net80211_tx_mgmt(struct net80211_device *dev, u16 fc, u8 dest[6], struct io_buffer *iob)
Transmit 802.11 management frame.
Definition net80211.c:707
#define NET80211_PROBE_GATHER_ALL
Seconds to wait after finding a network, to possibly find other networks.
Definition net80211.c:1267
__weak int sec80211_detect(struct io_buffer *iob __unused, enum net80211_security_proto *secprot __unused, enum net80211_crypto_alg *crypt __unused)
Detect secure 802.11 network when security support is not available.
Definition net80211.c:113
#define NET80211_PROBE_TIMEOUT
Seconds to allow a probe to take if no network has been found.
Definition net80211.c:1270
#define NET80211_PROBE_GATHER
Seconds to wait after finding a network, to possibly find better APs for it.
Definition net80211.c:1260
@ NET80211_SECPROT_UNKNOWN
Dummy value used when the handshaking type can't be detected.
Definition net80211.h:124
@ NET80211_SECPROT_NONE
No security handshaking.
Definition net80211.h:102
@ NET80211_CRYPT_NONE
No security, an "Open" network.
Definition net80211.h:131
@ NET80211_CRYPT_UNKNOWN
Dummy value used when the cryptosystem can't be detected.
Definition net80211.h:177
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
int strcmp(const char *first, const char *second)
Compare strings.
Definition string.c:174
An 802.11 data or management frame without QoS or WDS header fields.
Definition ieee80211.h:301
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53
void * tail
End of data.
Definition iobuf.h:55
void * head
Start of the buffer.
Definition iobuf.h:51
u8 channel_nr
A channel number interpreted according to the band.
Definition net80211.h:405
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787
unsigned channel_change_time
Estimate of the time required to change channels, in microseconds.
Definition net80211.h:518
Structure representing a probed network.
Definition net80211.h:1057
struct io_buffer * beacon
The complete beacon or probe-response frame received.
Definition net80211.h:1081
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21

References alloc_iob(), net80211_wlan::beacon, net80211_wlan::bssid, net80211_device::channel, net80211_wlan::channel, net80211_hw_info::channel_change_time, net80211_channel::channel_nr, net80211_device::channels, net80211_device_operations::config, net80211_wlan::crypto, ctx, currticks(), io_buffer::data, DBG, DBGC, DBGC2, ENOTSUP, net80211_wlan::essid, ETH_ALEN, eth_broadcast, eth_ntoa(), ETIMEDOUT, fill, free_iob(), net80211_wlan::handshaking, hdr, io_buffer::head, net80211_device::hw, ieee80211_ie::id, ieee80211_beacon, IEEE80211_CAPAB_PRIVACY, IEEE80211_FC_SUBTYPE, ieee80211_ie_bound(), IEEE80211_IE_SSID, IEEE80211_MAX_SSID_LEN, ieee80211_next_ie(), IEEE80211_STYPE_BEACON, IEEE80211_STYPE_PROBE_REQ, IEEE80211_STYPE_PROBE_RESP, iob_disown, iob_headroom(), iob_len(), iob_put, iob_reserve, ieee80211_ie::len, net80211_wlan::list, list_add_tail, list_empty, list_for_each_entry, memcpy(), NET80211_CFG_CHANNEL, NET80211_CRYPT_NONE, NET80211_CRYPT_UNKNOWN, net80211_mgmt_dequeue(), NET80211_PROBE_GATHER, NET80211_PROBE_GATHER_ALL, NET80211_PROBE_TIMEOUT, NET80211_SECPROT_NONE, NET80211_SECPROT_UNKNOWN, net80211_tx_mgmt(), net80211_device::nr_channels, NULL, net80211_device::op, rc, sec80211_detect(), net80211_wlan::signal, ieee80211_ie::ssid, ssid, strcmp(), strcpy(), strerror(), io_buffer::tail, TICKS_PER_SEC, type, u16, u32, udelay(), and zalloc().

Referenced by iwlist(), and net80211_step_associate().

◆ net80211_probe_finish_best()

struct net80211_wlan * net80211_probe_finish_best ( struct net80211_probe_ctx * ctx)

Finish probe of 802.11 networks, returning best-signal network found.

Parameters
ctxProbe context
Return values
wlanBest-signal network found, or NULL if none were found

If net80211_probe_start() was called with a particular SSID parameter as filter, only a network with that SSID (matching case-sensitively) can be returned from this function.

Definition at line 1545 of file net80211.c.

1546{
1547 struct net80211_wlan *best = NULL, *wlan;
1548
1549 if ( ! ctx )
1550 return NULL;
1551
1552 list_for_each_entry ( wlan, ctx->beacons, list ) {
1553 if ( ! best || best->signal < wlan->signal )
1554 best = wlan;
1555 }
1556
1557 if ( best )
1558 list_del ( &best->list );
1559 else
1560 DBGC ( ctx->dev, "802.11 %p probe: found nothing for '%s'\n",
1561 ctx->dev, ctx->essid );
1562
1563 net80211_free_wlanlist ( ctx->beacons );
1564
1565 net80211_keep_mgmt ( ctx->dev, ctx->old_keep_mgmt );
1566
1567 if ( ctx->probe )
1568 free_iob ( ctx->probe );
1569
1570 free ( ctx );
1571
1572 return best;
1573}
void net80211_free_wlanlist(struct list_head *list)
Free list of WLAN structures.
Definition net80211.c:1620
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
struct list_head list
Link to allow chaining multiple structures into a list to be returned from net80211_probe_finish_all(...
Definition net80211.h:1091
int signal
Signal strength of beacon frame from that access point.
Definition net80211.h:1070

References ctx, DBGC, free, free_iob(), net80211_wlan::list, list_del, list_for_each_entry, net80211_free_wlanlist(), net80211_keep_mgmt(), NULL, and net80211_wlan::signal.

Referenced by net80211_autoassociate(), and net80211_step_associate().

◆ net80211_probe_finish_all()

struct list_head * net80211_probe_finish_all ( struct net80211_probe_ctx * ctx)

Finish probe of 802.11 networks, returning all networks found.

Parameters
ctxProbe context
Return values
listList of net80211_wlan detailing networks found

If net80211_probe_start() was called with a particular SSID parameter as filter, this will always return either an empty or a one-element list.

Definition at line 1586 of file net80211.c.

1587{
1588 struct list_head *beacons = ctx->beacons;
1589
1590 net80211_keep_mgmt ( ctx->dev, ctx->old_keep_mgmt );
1591
1592 if ( ctx->probe )
1593 free_iob ( ctx->probe );
1594
1595 free ( ctx );
1596
1597 return beacons;
1598}
A doubly-linked list entry (or list head)
Definition list.h:19

References ctx, free, free_iob(), and net80211_keep_mgmt().

Referenced by iwlist().

◆ net80211_free_wlan()

void net80211_free_wlan ( struct net80211_wlan * wlan)

Free WLAN structure.

Parameters
wlanWLAN structure to free

Definition at line 1606 of file net80211.c.

1607{
1608 if ( wlan ) {
1609 free_iob ( wlan->beacon );
1610 free ( wlan );
1611 }
1612}

References net80211_wlan::beacon, free, and free_iob().

Referenced by net80211_autoassociate(), net80211_free_wlanlist(), and net80211_step_associate().

◆ net80211_free_wlanlist()

void net80211_free_wlanlist ( struct list_head * list)

Free list of WLAN structures.

Parameters
listList of WLAN structures to free

Definition at line 1620 of file net80211.c.

1621{
1622 struct net80211_wlan *wlan, *tmp;
1623
1624 if ( ! list )
1625 return;
1626
1628 list_del ( &wlan->list );
1629 net80211_free_wlan ( wlan );
1630 }
1631
1632 free ( list );
1633}
void net80211_free_wlan(struct net80211_wlan *wlan)
Free WLAN structure.
Definition net80211.c:1606
unsigned long tmp
Definition linux_pci.h:65
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition list.h:459

References free, net80211_wlan::list, list_del, list_for_each_entry_safe, net80211_free_wlan(), and tmp.

Referenced by iwlist(), and net80211_probe_finish_best().