iPXE
|
802.11 device management More...
#include <string.h>
#include <byteswap.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/settings.h>
#include <ipxe/if_arp.h>
#include <ipxe/ethernet.h>
#include <ipxe/ieee80211.h>
#include <ipxe/netdevice.h>
#include <ipxe/net80211.h>
#include <ipxe/sec80211.h>
#include <ipxe/timer.h>
#include <ipxe/nap.h>
#include <ipxe/errortab.h>
#include <ipxe/net80211_err.h>
Go to the source code of this file.
Data Structures | |
struct | net80211_rx_info |
Information associated with a received management packet. More... | |
struct | net80211_probe_ctx |
Context for a probe operation. More... | |
struct | net80211_assoc_ctx |
Context for the association task. More... | |
Macros | |
#define | NET80211_PROBE_GATHER 1 |
Seconds to wait after finding a network, to possibly find better APs for it. More... | |
#define | NET80211_PROBE_GATHER_ALL 2 |
Seconds to wait after finding a network, to possibly find other networks. More... | |
#define | NET80211_PROBE_TIMEOUT 6 |
Seconds to allow a probe to take if no network has been found. More... | |
#define | ASSOC_TIMEOUT TICKS_PER_SEC |
Number of ticks to wait for replies to association management frames. More... | |
#define | ASSOC_RETRIES 2 |
Number of times to try sending a particular association management frame. More... | |
#define | LQ_SMOOTH 7 |
Smoothing factor (1-7) for link quality calculation. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
__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. More... | |
static int | net80211_netdev_open (struct net_device *netdev) |
Open 802.11 device and start association. More... | |
static void | net80211_netdev_close (struct net_device *netdev) |
Close 802.11 device. More... | |
static int | net80211_netdev_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet on 802.11 device. More... | |
static void | net80211_netdev_poll (struct net_device *netdev) |
Poll 802.11 device for received packets and completed transmissions. More... | |
static void | net80211_netdev_irq (struct net_device *netdev, int enable) |
Enable or disable interrupts for 802.11 device. More... | |
static int | net80211_ll_push (struct net_device *netdev, struct io_buffer *iobuf, const void *ll_dest, const void *ll_source, uint16_t net_proto) |
Add 802.11 link-layer header. More... | |
static int | net80211_ll_pull (struct net_device *netdev, struct io_buffer *iobuf, const void **ll_dest, const void **ll_source, uint16_t *net_proto, unsigned int *flags) |
static void | net80211_add_channels (struct net80211_device *dev, int start, int len, int txpower) |
Add channels to 802.11 device. More... | |
static void | net80211_filter_hw_channels (struct net80211_device *dev) |
Filter 802.11 device channels for hardware capabilities. More... | |
static void | net80211_set_rtscts_rate (struct net80211_device *dev) |
Pick TX rate for RTS/CTS packets based on data rate. More... | |
static int | net80211_process_capab (struct net80211_device *dev, u16 capab) |
Update 802.11 device state to reflect received capabilities field. More... | |
static int | net80211_process_ie (struct net80211_device *dev, union ieee80211_ie *ie, void *ie_end) |
Update 802.11 device state to reflect received information elements. More... | |
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. More... | |
static void | net80211_step_associate (struct net80211_device *dev) |
Step 802.11 association process. More... | |
static void | net80211_handle_auth (struct net80211_device *dev, struct io_buffer *iob) |
Handle receipt of 802.11 authentication frame. More... | |
static void | net80211_handle_assoc_reply (struct net80211_device *dev, struct io_buffer *iob) |
Handle receipt of 802.11 association reply frame. More... | |
static int | net80211_send_disassoc (struct net80211_device *dev, int reason, int deauth) |
Send 802.11 disassociation frame. More... | |
static void | net80211_handle_mgmt (struct net80211_device *dev, struct io_buffer *iob, int signal) |
Handle receipt of 802.11 management frame. More... | |
static void | net80211_free_frags (struct net80211_device *dev, int fcid) |
Free buffers used by 802.11 fragment cache entry. More... | |
static struct io_buffer * | net80211_accum_frags (struct net80211_device *dev, int fcid, int nfrags, int size) |
Accumulate 802.11 fragments into one I/O buffer. More... | |
static void | net80211_rx_frag (struct net80211_device *dev, struct io_buffer *iob, int signal) |
Handle receipt of 802.11 fragment. More... | |
static int | net80211_check_settings_update (void) |
Check for 802.11 SSID or key updates. More... | |
const struct setting net80211_ssid_setting | __setting (SETTING_NETDEV_EXTRA, ssid) |
The network name to associate with. More... | |
const struct setting net80211_active_setting | __setting (SETTING_NETDEV_EXTRA, active-scan) |
Whether to use active scanning. More... | |
const struct setting net80211_key_setting | __setting (SETTING_NETDEV_EXTRA, key) |
The cryptographic key to use. More... | |
static int | net80211_rate_is_erp (u16 rate) |
Determine whether a transmission rate uses ERP/OFDM. More... | |
u16 | net80211_duration (struct net80211_device *dev, int bytes, u16 rate) |
Calculate one frame's contribution to 802.11 duration field. More... | |
static int | net80211_ll_pull (struct net_device *netdev __unused, struct io_buffer *iobuf, const void **ll_dest, const void **ll_source, uint16_t *net_proto, unsigned int *flags) |
Remove 802.11 link-layer header. More... | |
struct net80211_device * | net80211_get (struct net_device *netdev) |
Get 802.11 device from wrapping network device. More... | |
int | net80211_keep_mgmt (struct net80211_device *dev, int enable) |
Set state of 802.11 device keeping management frames. More... | |
struct io_buffer * | net80211_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 dest[6], struct io_buffer *iob) |
Transmit 802.11 management frame. More... | |
struct net80211_device * | net80211_alloc (size_t priv_size) |
Allocate 802.11 device. More... | |
int | net80211_register (struct net80211_device *dev, struct net80211_device_operations *ops, struct net80211_hw_info *hw) |
Register 802.11 device with network stack. More... | |
void | net80211_unregister (struct net80211_device *dev) |
Unregister 802.11 device from network stack. More... | |
void | net80211_free (struct net80211_device *dev) |
Free 802.11 device. More... | |
static void | net80211_set_state (struct net80211_device *dev, short clear, short set, u16 status) |
Set state of 802.11 device. More... | |
struct net80211_probe_ctx * | net80211_probe_start (struct net80211_device *dev, const char *essid, int active) |
Begin probe of 802.11 networks. More... | |
int | net80211_probe_step (struct net80211_probe_ctx *ctx) |
Continue probe of 802.11 networks. More... | |
struct net80211_wlan * | net80211_probe_finish_best (struct net80211_probe_ctx *ctx) |
Finish probe of 802.11 networks, returning best-signal network found. More... | |
struct list_head * | net80211_probe_finish_all (struct net80211_probe_ctx *ctx) |
Finish probe of 802.11 networks, returning all networks found. More... | |
void | net80211_free_wlan (struct net80211_wlan *wlan) |
Free WLAN structure. More... | |
void | net80211_free_wlanlist (struct list_head *list) |
Free list of WLAN structures. More... | |
void | net80211_autoassociate (struct net80211_device *dev) |
Start 802.11 association process. More... | |
void | net80211_set_rate_idx (struct net80211_device *dev, int rate) |
Set data transmission rate for 802.11 device. More... | |
int | net80211_change_channel (struct net80211_device *dev, int channel) |
Configure 802.11 device to transmit on a certain channel. More... | |
int | net80211_prepare_probe (struct net80211_device *dev, int band, int active) |
Prepare 802.11 device channel and rate set for scanning. More... | |
int | net80211_prepare_assoc (struct net80211_device *dev, struct net80211_wlan *wlan) |
Prepare 802.11 device channel and rate set for communication. More... | |
int | net80211_send_auth (struct net80211_device *dev, struct net80211_wlan *wlan, int method) |
Send 802.11 initial authentication frame. More... | |
int | net80211_send_assoc (struct net80211_device *dev, struct net80211_wlan *wlan) |
Send 802.11 association frame. More... | |
void | net80211_deauthenticate (struct net80211_device *dev, int rc) |
Deauthenticate from current network and try again. More... | |
static void | net80211_update_link_quality (struct net80211_device *dev, struct io_buffer *iob) |
Update link quality information based on received beacon. More... | |
void | net80211_rx (struct net80211_device *dev, struct io_buffer *iob, int signal, u16 rate) |
Handle receipt of 802.11 frame. More... | |
void | net80211_rx_err (struct net80211_device *dev, struct io_buffer *iob, int rc) |
Indicate an error in receiving a packet. More... | |
void | net80211_tx_complete (struct net80211_device *dev, struct io_buffer *iob, int retries, int rc) |
Indicate the completed transmission of a packet. More... | |
REQUIRING_SYMBOL (net80211_ll_protocol) | |
REQUIRE_OBJECT (config_net80211) | |
Variables | |
static struct list_head | net80211_devices = LIST_HEAD_INIT ( net80211_devices ) |
List of 802.11 devices. More... | |
static struct net80211_device_operations | net80211_null_ops |
Set of device operations that does nothing. More... | |
struct settings_applicator net80211_applicator | __settings_applicator |
802.11 settings applicator More... | |
static struct net_device_operations | net80211_netdev_ops |
Network device operations for a wrapped 802.11 device. More... | |
static struct ll_protocol net80211_ll_protocol | __ll_protocol |
802.11 link-layer protocol More... | |
static struct process_descriptor | net80211_process_desc |
802.11 association process descriptor More... | |
struct errortab common_wireless_errors [] | __errortab |
Common 802.11 errors. More... | |
802.11 device management
Definition in file net80211.c.
#define NET80211_PROBE_GATHER 1 |
Seconds to wait after finding a network, to possibly find better APs for it.
This is used when a specific SSID to scan for is specified.
Definition at line 1259 of file net80211.c.
#define NET80211_PROBE_GATHER_ALL 2 |
Seconds to wait after finding a network, to possibly find other networks.
This is used when an empty SSID is specified, to scan for all networks.
Definition at line 1266 of file net80211.c.
#define NET80211_PROBE_TIMEOUT 6 |
Seconds to allow a probe to take if no network has been found.
Definition at line 1269 of file net80211.c.
#define ASSOC_TIMEOUT TICKS_PER_SEC |
Number of ticks to wait for replies to association management frames.
Definition at line 1636 of file net80211.c.
#define ASSOC_RETRIES 2 |
Number of times to try sending a particular association management frame.
Definition at line 1639 of file net80211.c.
#define LQ_SMOOTH 7 |
Smoothing factor (1-7) for link quality calculation.
Definition at line 2401 of file net80211.c.
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
__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 at line 112 of file net80211.c.
References ENOTSUP.
Referenced by net80211_probe_step().
|
inlinestatic |
Determine whether a transmission rate uses ERP/OFDM.
rate | Rate in 100 kbps units |
is_erp | TRUE if the rate is an ERP/OFDM rate |
802.11b supports rates of 1.0, 2.0, 5.5, and 11.0 Mbps; any other rate than these on the 2.4GHz spectrum is an ERP (802.11g) rate.
Definition at line 399 of file net80211.c.
Referenced by net80211_duration().
|
static |
Remove 802.11 link-layer header.
netdev | Wrapping network device |
iobuf | I/O buffer |
ll_dest | Link-layer destination address |
ll_source | Link-layer source |
net_proto | Network-layer protocol, in network byte order |
flags | Packet flags |
rc | Return status code |
This expects and removes both the 802.11 frame header and the 802.2 LLC/SNAP header that are used on data packets.
Definition at line 537 of file net80211.c.
References ieee80211_llc_snap_header::ctrl, io_buffer::data, DBGC, ieee80211_llc_snap_header::dsap, EINVAL_PKT_LLC_HEADER, EINVAL_PKT_NOT_DATA, EINVAL_PKT_NOT_FROMDS, EINVAL_PKT_TOO_SHORT, EINVAL_PKT_VERSION, ieee80211_llc_snap_header::ethertype, flags, hdr, IEEE80211_FC_FROMDS, IEEE80211_FC_SUBTYPE, IEEE80211_FC_TODS, IEEE80211_FC_TYPE, IEEE80211_FC_VERSION, IEEE80211_LLC_CTRL, IEEE80211_LLC_DSAP, IEEE80211_LLC_HEADER_LEN, IEEE80211_LLC_SSAP, IEEE80211_STYPE_DATA, IEEE80211_THIS_VERSION, IEEE80211_TYP_FRAME_HEADER_LEN, IEEE80211_TYPE_DATA, iob_len(), iob_pull, is_broadcast_ether_addr(), is_multicast_ether_addr(), LL_BROADCAST, LL_MULTICAST, netdev, ieee80211_llc_snap_header::oui, net_device::priv, and ieee80211_llc_snap_header::ssap.
int net80211_tx_mgmt | ( | struct net80211_device * | dev, |
u16 | fc, | ||
u8 | dest[6], | ||
struct io_buffer * | iob | ||
) |
Transmit 802.11 management frame.
dev | 802.11 device |
fc | Frame Control flags for management frame |
dest | Destination access point |
iob | I/O buffer |
rc | Return status code |
The fc argument must contain at least an IEEE 802.11 management subtype number (e.g. IEEE80211_STYPE_PROBE_REQ). If it contains IEEE80211_FC_PROTECTED, the frame will be encrypted prior to transmission.
It is required that iob have at least 24 bytes of headroom reserved before its data start.
Definition at line 706 of file net80211.c.
References net80211_device::crypto, dest, EINVAL_CRYPTO_REQUEST, net80211_crypto::encrypt, ETH_ALEN, fc, free_iob(), hdr, IEEE80211_FC_PROTECTED, IEEE80211_MAKESEQ, IEEE80211_THIS_VERSION, IEEE80211_TYP_FRAME_HEADER_LEN, IEEE80211_TYPE_MGMT, iob_push, net80211_device::last_tx_seqnr, net_device::ll_addr, memcpy(), net80211_duration(), net80211_device::netdev, netdev_tx(), net80211_device::rate, and net80211_device::rates.
Referenced by net80211_probe_step(), net80211_send_assoc(), net80211_send_auth(), and net80211_send_disassoc().
|
inlinestatic |
Set state of 802.11 device.
dev | 802.11 device |
clear | Bitmask of flags to clear |
set | Bitmask of flags to set |
status | Status or reason code for most recent operation |
If status represents a reason code, it should be OR'ed with NET80211_IS_REASON.
Clearing authentication also clears association; clearing association also clears security handshaking state. Clearing association removes the link-up flag from the wrapping net_device, but setting it does not automatically set the flag; that is left to the judgment of higher-level code.
Definition at line 866 of file net80211.c.
References clear, net_device::dev, E80211_REASON, E80211_STATUS, NET80211_ASSOCIATED, NET80211_AUTHENTICATED, NET80211_CFG_ASSOC, NET80211_CRYPTO_SYNCED, NET80211_IS_REASON, NET80211_PROBED, NET80211_STATUS_MASK, netdev_link_down(), netdev_link_err(), set, and status.
Referenced by net80211_autoassociate(), net80211_handle_assoc_reply(), net80211_handle_auth(), net80211_handle_mgmt(), net80211_prepare_assoc(), net80211_send_assoc(), net80211_send_auth(), and net80211_send_disassoc().
|
static |
Update link quality information based on received beacon.
dev | 802.11 device |
iob | I/O buffer containing beacon |
rc | Return status code |
Definition at line 2410 of file net80211.c.
References io_buffer::data, hdr, ieee80211_beacon, net80211_device::last_beacon_timestamp, LQ_SMOOTH, NET80211_ASSOCIATED, net80211_device::rx_beacon_interval, and net80211_device::state.
Referenced by net80211_handle_mgmt().
REQUIRING_SYMBOL | ( | net80211_ll_protocol | ) |
REQUIRE_OBJECT | ( | config_net80211 | ) |
|
static |
List of 802.11 devices.
Definition at line 47 of file net80211.c.
Referenced by net80211_check_settings_update(), net80211_get(), and net80211_register().
|
static |
Set of device operations that does nothing.
Definition at line 50 of file net80211.c.
Referenced by net80211_alloc(), net80211_netdev_open(), and net80211_unregister().
|
static |
Network device operations for a wrapped 802.11 device.
Definition at line 379 of file net80211.c.
Referenced by net80211_alloc().
|
static |
802.11 link-layer protocol
Definition at line 597 of file net80211.c.
|
static |
802.11 association process descriptor
Definition at line 738 of file net80211.c.
Referenced by net80211_alloc().
struct errortab common_wireless_errors [] __errortab |
Common 802.11 errors.
Definition at line 2820 of file net80211.c.