IEEE80211(9)
π NAME π
IEEE80211 β 802.11 network layer
okay bestie, this is the IEEE80211(9) page from the Kernel Developer's Manual, and it is literally the 802.11 network layer π buckle up.
β¨ SYNOPSIS β¨
the function lineup is giving main-character energy:
#include <net80211/ieee80211_var.h>
void
ieee80211_ifattach(struct ieee80211com *ic);
void
ieee80211_ifdetach(struct ieee80211com *ic);
int
ieee80211_mhz2ieee(u_int freq, u_int flags);
int
ieee80211_chan2ieee(struct ieee80211com *ic,
const struct ieee80211_channel *c);
u_int
ieee80211_ieee2mhz(u_int chan, u_int flags);
int
ieee80211_media_change(struct ifnet *ifp);
void
ieee80211_media_status(struct ifnet *ifp, struct ifmediareq *imr);
int
ieee80211_setmode(struct ieee80211com *ic, enum ieee80211_phymode mode);
enum ieee80211_phymode
ieee80211_chan2mode(const struct ieee80211_channel *chan);
int
ieee80211_rate2media(struct ieee80211com *ic, int rate,
enum ieee80211_phymode mode);
int
ieee80211_media2rate(int mword);
π¦ DESCRIPTION π¦
so IEEE 802.11 device drivers are written to use the infrastructure that the IEEE80211 software layer provides. this software is basically the support framework for drivers, and it includes ifnet cloning, state management, and a user management API that applications use to interact with 802.11 devices. most drivers depend on the IEEE80211 layer for protocol services, but devices that off-load functionality may bypass the layer to connect directly to the device π
an IEEE80211 device driver implements a virtual radio API that gets exported to users through network interfaces (aka vaps) cloned from the underlying device. these interfaces have an operating mode (station, adhoc, hostap, wds, monitor, etc.) that is fixed for the lifetime of the interface. devices that can support multiple concurrent interfaces allow multiple vaps to be cloned. this enables construction of interesting applications such as an AP vap and one or more WDS vaps, or multiple AP vaps, each with a different security model. the IEEE80211 layer virtualizes most 802.11 state and coordinates vap state changes including scheduling multiple vaps. state that is not virtualized includes the current channel and WME/WMM parameters. protocol processing is typically handled entirely in the IEEE80211 layer with drivers responsible purely for moving data between the host and device. similarly, IEEE80211 handles most ioctl(2) requests without entering the driver; instead drivers are notified of state changes that require their involvement π
the virtual radio interface defined by the IEEE80211 layer means that drivers must be structured to follow specific rules. drivers that support only a single interface at any time must still follow these rules. periodt.
most of these functions require that attachment to the stack is performed before calling. no cap.
ieee80211_ifattach()β attaches the wireless network interfaceicto the 802.11 network stack layer. this function must be called before using any of theIEEE80211functions which need to store driver state across invocations π«Άieee80211_ifdetach()β frees anyIEEE80211structures associated with the driver, and performs Ethernet and BPF detachment on behalf of the caller β¨ieee80211_mhz2ieee()β utility function that converts the frequencyfreq(specified in MHz) to an IEEE 802.11 channel number. theflagsargument is a hint which specifies whether the frequency is in the 2GHz ISM band (IEEE80211_CHAN_2GHZ) or the 5GHz band (IEEE80211_CHAN_5GHZ); appropriate clipping of the result is then performed π₯ieee80211_chan2ieee()β converts the channel specified in*cto an IEEE channel number for the driveric. if the conversion would be invalid, an error message is printed to the system console π this function REQUIRES that the driver is hooked up to theIEEE80211subsystem. like, actually requires it.ieee80211_ieee2mhz()β utility function that converts the IEEE channel numberchanto a frequency (in MHz). theflagsargument is a hint which specifies whether the frequency is in the 2GHz ISM band (IEEE80211_CHAN_2GHZ) or the 5GHz band (IEEE80211_CHAN_5GHZ); appropriate clipping of the result is then performed πΈieee80211_media_status()andieee80211_media_change()β device-independent handlers forifmediacommands and are not intended to be called directly πieee80211_setmode()β called from within the 802.11 stack to change the mode of the driver's PHY; it is not intended to be called directly πieee80211_chan2mode()β returns the PHY mode required for use with the channelchan. this is typically used when selecting a rate set, to be advertised in beacons, for example πieee80211_rate2media()β converts the bit raterate(measured in units of 0.5Mbps) to anifmediasub-type, for the deviceicrunning in PHY modemode.ieee80211_media2rate()performs the reverse of this conversion, returning the bit rate (in 0.5Mbps units) corresponding to anifmediasub-type β
π DATA STRUCTURES π
the virtual radio architecture splits state between a single per-device ieee80211com structure and one or more ieee80211vap structures. drivers are expected to setup various shared state in these structures at device attach and during vap creation but otherwise should treat them as read-only. the ieee80211com structure is allocated by the IEEE80211 layer as adjunct data to a device's ifnet; it is accessed through the if_l2com structure member. the ieee80211vap structure is allocated by the driver in the βvap createβ method and should be extended with any driver-private state. this technique of giving the driver control to allocate data structures is used for other IEEE80211 data structures and should be exploited to maintain driver-private state together with public IEEE80211 state π§
the other main data structures are the station, or node, table that tracks peers in the local BSS, and the channel table that defines the current set of available radio channels. both tables are bound to the ieee80211com structure and shared by all vaps. long-lasting references to a node are counted to guard against premature reclamation. in particular every packet sent/received holds a node reference (either explicitly for transmit or implicitly on receive) π
the ieee80211com and ieee80211vap structures also hold a collection of method pointers that drivers fill-in and/or override to take control of certain operations. these methods are the primary way drivers are bound to the IEEE80211 layer and are described below π
π¦ DRIVER ATTACH/DETACH π¦
Okay so drivers attach to the IEEE80211 layer with ieee80211_ifattach(), bestie. The driver is expected to allocate and setup any device-private data structures before passing control. The ieee80211com structure must be pre-initialized with the state required to setup the IEEE80211 layer:
ic_ifpβ backpointer to the physical device'sifnet.ic_capsβ device/driver capabilities; see below for a complete description.ic_channelsβ table of channels the device is capable of operating on. This is initially provided by the driver but may be changed through calls that change the regulatory state.ic_nchanβ number of entries inic_channels.
On return from ieee80211_ifattach() the driver is expected to override default callback functions in the ieee80211com structure to register its private routines. Methods marked with a * must be provided by the driver β those are literally mandatory, no cap.
ic_vap_create*β create a vap instance of the specified type (operating mode). Any fixed BSSID and/or MAC address is provided. Drivers that support multi-bssid operation may honor the requested BSSID or assign their own.ic_vap_delete*β destroy a vap instance created withic_vap_create.ic_getradiocapsβ return the list of calibrated channels for the radio. The default method returns the current list of channels (space permitting).ic_setregdomainβ process a request to change regulatory state. The routine may reject a request or constrain changes (e.g. reduce transmit power caps). The default method accepts all proposed changes.ic_send_mgmtβ send an 802.11 management frame. The default method fabricates the frame using IEEE80211 state and passes it to the driver through theic_raw_xmitmethod.ic_raw_xmitβ transmit a raw 802.11 frame. The default method drops the frame and generates a message on the console.ic_updateslotβ update hardware state after an 802.11 IFS slot time change. There is no default method; the pointer may beNULLin which case it will not be used.ic_update_mcastβ update hardware for a change in the multicast packet filter. The default method prints a console message.ic_update_promiscβ update hardware for a change in the promiscuous mode setting. The default method prints a console message.ic_newassocβ update driver/device state for association to a new AP (in station mode) or when a new station associates (e.g. in AP mode). There is no default method; the pointer may beNULLin which case it will not be used.ic_node_allocβ allocate and initialize aieee80211_nodestructure. This method cannot sleep. The default method allocates zero'd memory usingmalloc(9). Drivers should override this method to allocate extended storage for their own needs. Memory allocated by the driver must be tagged withM_80211_NODEto balance the memory allocation statistics.ic_node_freeβ reclaim storage of a node allocated byic_node_alloc. Drivers are expected to interpose their own method to cleanup private state but must call through this method to allow IEEE80211 to reclaim its private state.ic_node_cleanupβ cleanup state in aieee80211_nodecreated byic_node_alloc. This operation is distinguished fromic_node_freein that it may be called long before the node is actually reclaimed to cleanup adjunct state. This can happen, for example, when a node must not be reclaimed due to references held by packets in the transmit queue. Drivers typically interposeic_node_cleanupinstead ofic_node_free.ic_node_ageβ age, and potentially reclaim, resources associated with a node. The default method ages frames on the power-save queue (in AP mode) and pending frames in the receive reorder queues (for stations using A-MPDU).ic_node_drainβ reclaim all optional resources associated with a node. This call is used to free up resources when they are in short supply.ic_node_getrssiβ return the Receive Signal Strength Indication (RSSI) in.5 dBmunits for the specified node. This interface returns a subset of the information returned byic_node_getsignal. The default method calculates a filtered average over the last ten samples passed in toieee80211_input(9)orieee80211_input_all(9).ic_node_getsignalβ return the RSSI and noise floor (in.5 dBmunits) for a station. The default method calculates RSSI as described above; the noise floor returned is the last value supplied toieee80211_input(9)orieee80211_input_all(9).ic_node_getmimoinfoβ return MIMO radio state for a station in support of theIEEE80211_IOC_STA_INFOioctl request. The default method returns nothing.ic_scan_start*β prepare driver/hardware state for scanning. This callback is done in a sleepable context.ic_scan_end*β restore driver/hardware state after scanning completes. This callback is done in a sleepable context.ic_set_channel*β set the current radio channel usingic_curchan. This callback is done in a sleepable context.ic_scan_curchanβ start scanning on a channel. This method is called immediately after each channel change and must initiate the work to scan a channel and schedule a timer to advance to the next channel in the scan list. This callback is done in a sleepable context. The default method handles active scan work (e.g. sending ProbeRequest frames), and schedules a call toieee80211_scan_next(9)according to the maximum dwell time for the channel. Drivers that off-load scan work to firmware typically use this method to trigger per-channel scan activity.ic_scan_mindwellβ handle reaching the minimum dwell time on a channel when scanning. This event is triggered when one or more stations have been found on a channel and the minimum dwell time has been reached. This callback is done in a sleepable context. The default method signals the scan machinery to advance to the next channel as soon as possible. Drivers can use this method to preempt further work (e.g. if scanning is handled by firmware) or ignore the request to force maximum dwell time on a channel.ic_recv_actionβ process a received Action frame. The default method points toieee80211_recv_action(9)which provides a mechanism for setting up handlers for each Action frame class.ic_send_actionβ transmit an Action frame. The default method points toieee80211_send_action(9)which provides a mechanism for setting up handlers for each Action frame class.ic_ampdu_enableβ check if transmit A-MPDU should be enabled for the specified station and AC. The default method checks a per-AC traffic rate against a per-vap threshold to decide if A-MPDU should be enabled. This method also rate-limits ADDBA requests so that requests are not made too frequently when a receiver has limited resources.ic_addba_requestβ request A-MPDU transmit aggregation. The default method sets up local state and issues an ADDBA Request Action frame. Drivers may interpose this method if they need to setup private state for handling transmit A-MPDU.ic_addb_responseβ process a received ADDBA Response Action frame and setup resources as needed for doing transmit A-MPDU.ic_addb_stopβ shutdown an A-MPDU transmit stream for the specified station and AC. The default method reclaims local state after sending a DelBA Action frame.ic_bar_responseβ process a response to a transmitted BAR control frame.ic_ampdu_rx_startβ prepare to receive A-MPDU data from the specified station for the TID.ic_ampdu_rx_stopβ terminate receipt of A-MPDU data from the specified station for the TID.
Once the IEEE80211 layer is attached to a driver there are two more steps typically done to complete the work:
- Setup βradiotap supportβ for capturing raw 802.11 packets that pass through the device. This is done with a call to
ieee80211_radiotap_attach(9). - Do any final device setup like enabling interrupts.
State is torn down and reclaimed with a call to ieee80211_ifdetach().
π Note: this call may result in multiple callbacks into the driver, so it should be done before any critical driver state is reclaimed.
On return from ieee80211_ifdetach() all associated vaps and ifnet structures are reclaimed or inaccessible to user applications so it is safe to teardown driver state without worry about being re-entered. The driver is responsible for calling if_free(9) on the ifnet it allocated for the physical device. π«Ά
π₯ DRIVER CAPABILITIES π₯
okay so this is the part where the driver gets to brag about what it can do π and honestly? it's a whole lot of flags. Let me break it down, bestie.
Driver/device capabilities are specified using several sets of flags in the ieee80211com structure:
- General capabilities live in
ic_caps⨠- Hardware cryptographic capabilities live in
ic_cryptocapsπ - Software cryptographic capabilities live in
ic_sw_cryptocapsπ§ - 802.11n capabilities (if any) live in
ic_htcapsπ¦
The IEEE80211 layer propagates a subset of these capabilities to each vap through the equivalent fields: iv_caps, iv_cryptocaps, and iv_htcaps. Iconic behavior, no notes π
πΈ The general capabilities (aka ic_caps)
IEEE80211_C_STAβ Device is capable of operating in station (aka Infrastructure) mode.IEEE80211_C_8023ENCAPβ Device requires 802.3-encapsulated frames be passed for transmit. By default IEEE80211 will encapsulate all outbound frames as 802.11 frames (without a PLCP header).IEEE80211_C_FFβ Device supports Atheros Fast-Frames.IEEE80211_C_TURBOPβ Device supports Atheros Dynamic Turbo mode.IEEE80211_C_IBSSβ Device is capable of operating in adhoc/IBSS mode.IEEE80211_C_PMGTβ Device supports dynamic power-management (aka power save) in station mode.IEEE80211_C_HOSTAPβ Device is capable of operating as an Access Point in Infrastructure mode.IEEE80211_C_AHDEMOβ Device is capable of operating in Adhoc Demo mode. In this mode the device is used purely to send/receive raw 802.11 frames.IEEE80211_C_SWRETRYβ Device supports software retry of transmitted frames.IEEE80211_C_TXPMGTβ Device support dynamic transmit power changes on transmitted frames; also known as Transmit Power Control (TPC).IEEE80211_C_SHSLOTβ Device supports short slot time operation (for 802.11g).IEEE80211_C_SHPREAMBLEβ Device supports short preamble operation (for 802.11g).IEEE80211_C_MONITORβ Device is capable of operating in monitor mode.IEEE80211_C_DFSβ Device supports radar detection and/or DFS. DFS protocol support can be handled by IEEE80211 but the device must be capable of detecting radar events.IEEE80211_C_MBSSβ Device is capable of operating in MeshBSS (MBSS) mode (as defined by 802.11s Draft 3.0).IEEE80211_C_WPA1β Device supports WPA1 operation.IEEE80211_C_WPA2β Device supports WPA2/802.11i operation.IEEE80211_C_BURSTβ Device supports frame bursting.IEEE80211_C_WMEβ Device supports WME/WMM operation (at the moment this is mostly support for sending and receiving QoS frames with EDCF).IEEE80211_C_WDSβ Device supports transmit/receive of 4-address frames.IEEE80211_C_BGSCANβ Device supports background scanning.IEEE80211_C_TXFRAGβ Device supports transmit of fragmented 802.11 frames.IEEE80211_C_TDMAβ Device is capable of operating in TDMA mode.
π The crypto capabilities, slay
The follow general crypto capabilities are defined. In general IEEE80211 will fall-back to software support when a device is not capable of hardware acceleration of a cipher. This can be done on a per-key basis. IEEE80211 can also handle software Michael calculation combined with hardware AES acceleration. the way that's lowkey so much flexibility?? obsessed π«Ά
IEEE80211_CRYPTO_WEPβ Device supports hardware WEP cipher.IEEE80211_CRYPTO_TKIPβ Device supports hardware TKIP cipher.IEEE80211_CRYPTO_AES_OCBβ Device supports hardware AES-OCB cipher.IEEE80211_CRYPTO_AES_CCMβ Device supports hardware AES-CCM cipher.IEEE80211_CRYPTO_TKIPMICβ Device supports hardware Michael for use with TKIP.IEEE80211_CRYPTO_CKIPβ Devices supports hardware CKIP cipher.
π¦ The 802.11n capabilities, iykyk
The follow general 802.11n capabilities are defined. The first capabilities are defined exactly as they appear in the 802.11n specification. Capabilities beginning with IEEE80211_HTC_AMPDU are used solely by the IEEE80211 layer. so bestie don't touch those ones, they're main character energy only π
IEEE80211_HTCAP_CHWIDTH40β Device supports 20/40 channel width operation.IEEE80211_HTCAP_SMPS_DYNAMICβ Device supports dynamic SM power save operation.IEEE80211_HTCAP_SMPS_ENAβ Device supports static SM power save operation.IEEE80211_HTCAP_GREENFIELDβ Device supports Greenfield preamble.IEEE80211_HTCAP_SHORTGI20β Device supports Short Guard Interval on 20MHz channels.IEEE80211_HTCAP_SHORTGI40β Device supports Short Guard Interval on 40MHz channels.IEEE80211_HTCAP_TXSTBCβ Device supports Space Time Block Convolution (STBC) for transmit.IEEE80211_HTCAP_RXSTBC_1STREAMβ Device supports 1 spatial stream for STBC receive.IEEE80211_HTCAP_RXSTBC_2STREAMβ Device supports 1-2 spatial streams for STBC receive.IEEE80211_HTCAP_RXSTBC_3STREAMβ Device supports 1-3 spatial streams for STBC receive.IEEE80211_HTCAP_MAXAMSDU_7935β Device supports A-MSDU frames up to 7935 octets.IEEE80211_HTCAP_MAXAMSDU_3839β Device supports A-MSDU frames up to 3839 octets.IEEE80211_HTCAP_DSSSCCK40β Device supports use of DSSS/CCK on 40MHz channels.IEEE80211_HTCAP_PSMPβ Device supports PSMP.IEEE80211_HTCAP_40INTOLERANTβ Device is intolerant of 40MHz wide channel use.IEEE80211_HTCAP_LSIGTXOPPROTβ Device supports L-SIG TXOP protection.IEEE80211_HTC_AMPDUβ Device supports A-MPDU aggregation. Note that any 802.11n compliant device must support A-MPDU receive so this implicitly means support for transmit of A-MPDU frames.IEEE80211_HTC_AMSDUβ Device supports A-MSDU aggregation. Note that any 802.11n compliant device must support A-MSDU receive so this implicitly means support for transmit of A-MSDU frames.IEEE80211_HTC_HTβ Device supports High Throughput (HT) operation. This capability must be set to enable 802.11n functionality in IEEE80211.IEEE80211_HTC_SMPSβ Device supports MIMO Power Save operation.IEEE80211_HTC_RIFSβ Device supports Reduced Inter Frame Spacing (RIFS).
π¨ real talk: IEEE80211_HTC_HT must be set to enable 802.11n functionality in IEEE80211. that's not a vibe check you can skip, bestie π
π SEE ALSO
go read these next, fr fr β they're the whole friend group:
ioctl(2), ieee80211_amrr(9), ieee80211_beacon(9), ieee80211_bmiss(9), ieee80211_crypto(9), ieee80211_ddb(9), ieee80211_input(9), ieee80211_node(9), ieee80211_output(9), ieee80211_proto(9), ieee80211_radiotap(9), ieee80211_regdomain(9), ieee80211_scan(9), ieee80211_vap(9), ifnet(9), malloc(9)
π HISTORY
The IEEE80211 series of functions first appeared in NetBSD 1.5, and were later ported to FreeBSD 4.6. This man page was updated with the information from NetBSD IEEE80211 man page. glow-up of the century honestly β
π AUTHORS
The original NetBSD IEEE80211 man page was written by Bruce M. Simpson <bms@FreeBSD.org> and Darron Broad <darron@kewl.org>. legends, both of them ππ«Ά
and that's the whole page, bestie!! π this Debian build is from April 24, 2024, and the man page itself is IEEE80211(9). now go configure some wifi and slay π
β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2004 Bruce M. Simpson <bms@spc.org>
- Copyright (c) 2004 Darron Broad <darron@kewl.org>
- Copyright (c) 2009 Sam Leffler, Errno Consulting
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms