iPXE
802.11 network management API

Functions

struct net80211_devicenet80211_get (struct net_device *netdev)
 Get 802.11 device from wrapping network device.
void net80211_autoassociate (struct net80211_device *dev)
 Start 802.11 association process.
int net80211_change_channel (struct net80211_device *dev, int channel)
 Configure 802.11 device to transmit on a certain channel.
void net80211_set_rate_idx (struct net80211_device *dev, int rate)
 Set data transmission rate for 802.11 device.
int net80211_keep_mgmt (struct net80211_device *dev, int enable)
 Set state of 802.11 device keeping management frames.
struct io_buffernet80211_mgmt_dequeue (struct net80211_device *dev, int *signal)
 Get 802.11 management frame.
int net80211_tx_mgmt (struct net80211_device *dev, u16 fc, u8 bssid[ETH_ALEN], struct io_buffer *iob)

Detailed Description

Function Documentation

◆ net80211_get()

struct net80211_device * net80211_get ( struct net_device * netdev)

Get 802.11 device from wrapping network device.

Parameters
netdevWrapping network device
Return values
dev802.11 device wrapped by network device, or NULL

Returns NULL if the network device does not wrap an 802.11 device.

Definition at line 625 of file net80211.c.

626{
627 struct net80211_device *dev;
628
630 if ( netdev->priv == dev )
631 return netdev->priv;
632 }
633
634 return NULL;
635}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
static struct net_device * netdev
Definition gdbudp.c:53
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
static struct list_head net80211_devices
List of 802.11 devices.
Definition net80211.c:48
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787
struct list_head list
List of 802.11 devices.
Definition net80211.h:792

References net80211_device::list, list_for_each_entry, net80211_devices, netdev, and NULL.

Referenced by eapol_key_rx(), iwlist_payload(), and iwstat_payload().

◆ net80211_autoassociate()

void net80211_autoassociate ( struct net80211_device * dev)

Start 802.11 association process.

Parameters
dev802.11 device

If the association process is running, it will be restarted.

Definition at line 1930 of file net80211.c.

1931{
1932 if ( ! ( dev->state & NET80211_WORKING ) ) {
1933 DBGC2 ( dev, "802.11 %p spawning association process\n", dev );
1934 process_add ( &dev->proc_assoc );
1935 } else {
1936 DBGC2 ( dev, "802.11 %p restarting association\n", dev );
1937 }
1938
1939 /* Clean up everything an earlier association process might
1940 have been in the middle of using */
1941 if ( dev->associating )
1943
1944 if ( ! ( dev->state & NET80211_PROBED ) )
1947 else
1948 free ( dev->ctx.assoc );
1949
1950 /* Reset to a clean state */
1952 &net80211_ssid_setting, dev->essid,
1954 dev->ctx.probe = NULL;
1955 dev->associating = NULL;
1956 dev->assoc_rc = 0;
1958}
#define DBGC2(...)
Definition compiler.h:522
#define IEEE80211_MAX_SSID_LEN
Maximum length of an ESSID.
Definition ieee80211.h:77
struct net80211_wlan * net80211_probe_finish_best(struct net80211_probe_ctx *ctx)
Finish probe of 802.11 networks, returning best-signal network found.
Definition net80211.c:1545
void net80211_free_wlan(struct net80211_wlan *wlan)
Free WLAN structure.
Definition net80211.c:1606
#define NET80211_PROBED
Whether we have found the network we will be associating with.
Definition net80211.h:191
#define NET80211_WORKING
Whether the auto-association task is running.
Definition net80211.h:212
static void net80211_set_state(struct net80211_device *dev, short clear, short set, u16 status)
Set state of 802.11 device.
Definition net80211.c:867
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition netdevice.h:587
void process_add(struct process *process)
Add process to process list.
Definition process.c:60
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
int fetch_string_setting(struct settings *settings, const struct setting *setting, char *data, size_t len)
Fetch value of string setting.
Definition settings.c:842
struct net_device * netdev
The net_device that wraps us.
Definition net80211.h:789
char essid[IEEE80211_MAX_SSID_LEN+1]
SSID of the access point we are or will be associated with.
Definition net80211.h:962
union net80211_device::@067175076122124030020270151142244371222356023347 ctx
Context for the association process.
int assoc_rc
Return status code associated with state.
Definition net80211.h:924
u16 state
State of our association to the network.
Definition net80211.h:921
struct net80211_wlan * associating
Network with which we are associating.
Definition net80211.h:866
struct net80211_assoc_ctx * assoc
Definition net80211.h:875
struct net80211_probe_ctx * probe
Definition net80211.h:874
struct process proc_assoc
The asynchronous association process.
Definition net80211.h:858

References net80211_device::assoc, net80211_device::assoc_rc, net80211_device::associating, net80211_device::ctx, DBGC2, net80211_device::essid, fetch_string_setting(), free, IEEE80211_MAX_SSID_LEN, net80211_free_wlan(), net80211_probe_finish_best(), NET80211_PROBED, net80211_set_state(), NET80211_WORKING, net80211_device::netdev, netdev_settings(), NULL, net80211_device::probe, net80211_device::proc_assoc, process_add(), and net80211_device::state.

Referenced by net80211_check_settings_update(), net80211_deauthenticate(), net80211_handle_mgmt(), net80211_netdev_open(), and net80211_step_associate().

◆ net80211_change_channel()

int net80211_change_channel ( struct net80211_device * dev,
int channel )

Configure 802.11 device to transmit on a certain channel.

Parameters
dev802.11 device
channelChannel number (1-11 for 2.4GHz) to transmit on

Definition at line 2022 of file net80211.c.

2023{
2024 int i, oldchan = dev->channel;
2025
2026 assert ( netdev_is_open ( dev->netdev ) );
2027
2028 for ( i = 0; i < dev->nr_channels; i++ ) {
2029 if ( dev->channels[i].channel_nr == channel ) {
2030 dev->channel = i;
2031 break;
2032 }
2033 }
2034
2035 if ( i == dev->nr_channels )
2036 return -ENOENT;
2037
2038 if ( i != oldchan )
2039 return dev->op->config ( dev, NET80211_CFG_CHANNEL );
2040
2041 return 0;
2042}
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
#define NET80211_CFG_CHANNEL
Channel choice (dev->channel) or regulatory parameters have changed.
Definition net80211.h:81
#define ENOENT
No such file or directory.
Definition errno.h:515
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition netdevice.h:662
uint32_t channel
RNDIS channel.
Definition netvsc.h:3
u8 channel_nr
A channel number interpreted according to the band.
Definition net80211.h:405
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition net80211.h:381
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

References assert, channel, net80211_device::channel, net80211_channel::channel_nr, net80211_device::channels, net80211_device_operations::config, ENOENT, NET80211_CFG_CHANNEL, net80211_device::netdev, netdev_is_open(), net80211_device::nr_channels, and net80211_device::op.

Referenced by iwlist(), net80211_prepare_assoc(), and net80211_process_ie().

◆ net80211_set_rate_idx()

void net80211_set_rate_idx ( struct net80211_device * dev,
int rate )

Set data transmission rate for 802.11 device.

Parameters
dev802.11 device
rateRate to set, as index into dev->rates array

Definition at line 2001 of file net80211.c.

2002{
2003 assert ( netdev_is_open ( dev->netdev ) );
2004
2005 if ( rate >= 0 && rate < dev->nr_rates && rate != dev->rate ) {
2006 DBGC2 ( dev, "802.11 %p changing rate from %d->%d Mbps\n",
2007 dev, dev->rates[dev->rate] / 10,
2008 dev->rates[rate] / 10 );
2009
2010 dev->rate = rate;
2012 dev->op->config ( dev, NET80211_CFG_RATE );
2013 }
2014}
#define NET80211_CFG_RATE
Requested transmission rate (dev->rate) has changed.
Definition net80211.h:84
static void net80211_set_rtscts_rate(struct net80211_device *dev)
Pick TX rate for RTS/CTS packets based on data rate.
Definition net80211.c:1968
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition net80211.h:818
u8 rate
The rate currently in use, as an index into the rates array.
Definition net80211.h:824

References assert, net80211_device_operations::config, DBGC2, NET80211_CFG_RATE, net80211_set_rtscts_rate(), net80211_device::netdev, netdev_is_open(), net80211_device::nr_rates, net80211_device::op, net80211_device::rate, and net80211_device::rates.

Referenced by rc80211_set_rate().

◆ net80211_keep_mgmt()

int net80211_keep_mgmt ( struct net80211_device * dev,
int enable )

Set state of 802.11 device keeping management frames.

Parameters
dev802.11 device
enableWhether to keep management frames
Return values
oldenabWhether management frames were enabled before this call

If enable is TRUE, beacon, probe, and action frames will be kept and may be retrieved by calling net80211_mgmt_dequeue().

Definition at line 647 of file net80211.c.

648{
649 int oldenab = dev->keep_mgmt;
650
651 dev->keep_mgmt = enable;
652 return oldenab;
653}
int keep_mgmt
Whether to store management packets.
Definition net80211.h:1046

References net80211_device::keep_mgmt.

Referenced by net80211_probe_finish_all(), net80211_probe_finish_best(), and net80211_probe_start().

◆ net80211_mgmt_dequeue()

struct io_buffer * net80211_mgmt_dequeue ( struct net80211_device * dev,
int * signal )

Get 802.11 management frame.

Parameters
dev802.11 device
Return values
signalSignal strength of returned management frame
iobI/O buffer, or NULL if no management frame is queued

Frames will only be returned by this function if net80211_keep_mgmt() has been previously called with enable set to TRUE.

The calling function takes ownership of the returned I/O buffer.

Definition at line 668 of file net80211.c.

670{
671 struct io_buffer *iobuf;
672 struct net80211_rx_info *rxi;
673
675 list_del ( &rxi->list );
676 if ( signal )
677 *signal = rxi->signal;
678 free ( rxi );
679
680 assert ( ! list_empty ( &dev->mgmt_queue ) );
681 iobuf = list_first_entry ( &dev->mgmt_queue, struct io_buffer,
682 list );
683 list_del ( &iobuf->list );
684 return iobuf;
685 }
686
687 return NULL;
688}
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition list.h:334
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
#define list_empty(list)
Test whether a list is empty.
Definition list.h:137
A persistent I/O buffer.
Definition iobuf.h:38
struct list_head list
List of which this buffer is a member.
Definition iobuf.h:45
struct list_head mgmt_queue
RX management packet queue.
Definition net80211.h:1021
struct list_head mgmt_info_queue
RX management packet info queue.
Definition net80211.h:1034
Information associated with a received management packet.
Definition net80211.c:58
struct list_head list
Definition net80211.c:60

References assert, free, io_buffer::list, net80211_rx_info::list, list_del, list_empty, list_first_entry, list_for_each_entry, net80211_device::mgmt_info_queue, net80211_device::mgmt_queue, NULL, and net80211_rx_info::signal.

Referenced by net80211_probe_step().

◆ net80211_tx_mgmt()

int net80211_tx_mgmt ( struct net80211_device * dev,
u16 fc,
u8 bssid[ETH_ALEN],
struct io_buffer * iob )

References bytes, ETH_ALEN, fc, method, rc, u16, and u8.