iPXE
Functions
802.11 network management API

Functions

struct net80211_devicenet80211_get (struct net_device *netdev)
 Get 802.11 device from wrapping network device. More...
 
void net80211_autoassociate (struct net80211_device *dev)
 Start 802.11 association process. More...
 
int net80211_change_channel (struct net80211_device *dev, int channel)
 Configure 802.11 device to transmit on a certain channel. More...
 
void net80211_set_rate_idx (struct net80211_device *dev, int rate)
 Set data transmission rate for 802.11 device. More...
 
int net80211_keep_mgmt (struct net80211_device *dev, int enable)
 Set state of 802.11 device keeping management frames. More...
 
struct io_buffernet80211_mgmt_dequeue (struct net80211_device *dev, int *signal)
 Get 802.11 management frame. More...
 
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 624 of file net80211.c.

625 {
626  struct net80211_device *dev;
627 
629  if ( netdev->priv == dev )
630  return netdev->priv;
631  }
632 
633  return NULL;
634 }
static struct list_head net80211_devices
List of 802.11 devices.
Definition: net80211.c:47
struct list_head list
List of 802.11 devices.
Definition: net80211.h:792
void * priv
Driver private data.
Definition: netdevice.h:431
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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

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 1929 of file net80211.c.

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

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 2021 of file net80211.c.

2022 {
2023  int i, oldchan = dev->channel;
2024 
2025  assert ( netdev_is_open ( dev->netdev ) );
2026 
2027  for ( i = 0; i < dev->nr_channels; i++ ) {
2028  if ( dev->channels[i].channel_nr == channel ) {
2029  dev->channel = i;
2030  break;
2031  }
2032  }
2033 
2034  if ( i == dev->nr_channels )
2035  return -ENOENT;
2036 
2037  if ( i != oldchan )
2038  return dev->op->config ( dev, NET80211_CFG_CHANNEL );
2039 
2040  return 0;
2041 }
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition: net80211.h:381
#define ENOENT
No such file or directory.
Definition: errno.h:514
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:658
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
u8 nr_channels
The number of channels in the channels array.
Definition: net80211.h:809
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
struct net_device * netdev
The net_device that wraps us.
Definition: net80211.h:789
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
#define NET80211_CFG_CHANNEL
Channel choice (dev->channel) or regulatory parameters have changed.
Definition: net80211.h:81
u8 channel_nr
A channel number interpreted according to the band.
Definition: net80211.h:405

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 2000 of file net80211.c.

2001 {
2002  assert ( netdev_is_open ( dev->netdev ) );
2003 
2004  if ( rate >= 0 && rate < dev->nr_rates && rate != dev->rate ) {
2005  DBGC2 ( dev, "802.11 %p changing rate from %d->%d Mbps\n",
2006  dev, dev->rates[dev->rate] / 10,
2007  dev->rates[rate] / 10 );
2008 
2009  dev->rate = rate;
2010  net80211_set_rtscts_rate ( dev );
2011  dev->op->config ( dev, NET80211_CFG_RATE );
2012  }
2013 }
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition: net80211.h:381
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:658
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
u8 nr_rates
The number of transmission rates in the rates array.
Definition: net80211.h:821
static void net80211_set_rtscts_rate(struct net80211_device *dev)
Pick TX rate for RTS/CTS packets based on data rate.
Definition: net80211.c:1967
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition: net80211.h:818
struct net_device * netdev
The net_device that wraps us.
Definition: net80211.h:789
#define DBGC2(...)
Definition: compiler.h:522
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
#define NET80211_CFG_RATE
Requested transmission rate (dev->rate) has changed.
Definition: net80211.h:84
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 646 of file net80211.c.

647 {
648  int oldenab = dev->keep_mgmt;
649 
650  dev->keep_mgmt = enable;
651  return oldenab;
652 }
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 667 of file net80211.c.

669 {
670  struct io_buffer *iobuf;
671  struct net80211_rx_info *rxi;
672 
673  list_for_each_entry ( rxi, &dev->mgmt_info_queue, list ) {
674  list_del ( &rxi->list );
675  if ( signal )
676  *signal = rxi->signal;
677  free ( rxi );
678 
679  assert ( ! list_empty ( &dev->mgmt_queue ) );
680  iobuf = list_first_entry ( &dev->mgmt_queue, struct io_buffer,
681  list );
682  list_del ( &iobuf->list );
683  return iobuf;
684  }
685 
686  return NULL;
687 }
struct list_head mgmt_info_queue
RX management packet info queue.
Definition: net80211.h:1034
struct list_head mgmt_queue
RX management packet queue.
Definition: net80211.h:1021
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
Information associated with a received management packet.
Definition: net80211.c:57
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct list_head list
Definition: net80211.c:59
struct list_head list
List of which this buffer is a member.
Definition: iobuf.h:40
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A persistent I/O buffer.
Definition: iobuf.h:33

References assert(), free, net80211_rx_info::list, io_buffer::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 
)