iPXE
802.11 link-layer protocol functions

Functions

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.
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)

Detailed Description

Function Documentation

◆ net80211_ll_push()

int net80211_ll_push ( struct net_device * netdev,
struct io_buffer * iobuf,
const void * ll_dest,
const void * ll_source,
uint16_t net_proto )
static

Add 802.11 link-layer header.

Parameters
netdevWrapping network device
iobufI/O buffer
ll_destLink-layer destination address
ll_sourceLink-layer source address
net_protoNetwork-layer protocol, in network byte order
Return values
rcReturn status code

This adds both the 802.11 frame header and the 802.2 LLC/SNAP header used on data packets.

We also check here for state of the link that would make it invalid to send a data packet; every data packet must pass through here, and no non-data packet (e.g. management frame) should.

Definition at line 484 of file net80211.c.

487{
488 struct net80211_device *dev = netdev->priv;
489 struct ieee80211_frame *hdr = iob_push ( iobuf,
492 struct ieee80211_llc_snap_header *lhdr =
494
495 /* We can't send data packets if we're not associated. */
496 if ( ! ( dev->state & NET80211_ASSOCIATED ) ) {
497 if ( dev->assoc_rc )
498 return dev->assoc_rc;
499 return -ENETUNREACH;
500 }
501
504
505 /* We don't send fragmented frames, so duration is the time
506 for an SIFS + 10-byte ACK. */
507 hdr->duration = net80211_duration ( dev, 10, dev->rates[dev->rate] );
508
509 memcpy ( hdr->addr1, dev->bssid, ETH_ALEN );
510 memcpy ( hdr->addr2, ll_source, ETH_ALEN );
511 memcpy ( hdr->addr3, ll_dest, ETH_ALEN );
512
513 hdr->seq = IEEE80211_MAKESEQ ( ++dev->last_tx_seqnr, 0 );
514
515 lhdr->dsap = IEEE80211_LLC_DSAP;
516 lhdr->ssap = IEEE80211_LLC_SSAP;
517 lhdr->ctrl = IEEE80211_LLC_CTRL;
518 memset ( lhdr->oui, 0x00, 3 );
519 lhdr->ethertype = net_proto;
520
521 return 0;
522}
struct golan_inbox_hdr hdr
Message header.
Definition CIB_PRM.h:0
static struct net_device * netdev
Definition gdbudp.c:53
#define IEEE80211_FC_TODS
802.11 Frame Control field: To Data System flag
Definition ieee80211.h:229
#define IEEE80211_TYPE_DATA
Type value for data frames.
Definition ieee80211.h:106
#define IEEE80211_THIS_VERSION
Expected value of Version bits in Frame Control.
Definition ieee80211.h:93
#define IEEE80211_STYPE_DATA
Subtype value for ordinary data frames, with no QoS or CF add-ons.
Definition ieee80211.h:219
#define IEEE80211_LLC_SSAP
Value for SSAP field in 802.2 LLC header for 802.11 frames: SNAP.
Definition ieee80211.h:340
#define IEEE80211_LLC_DSAP
Value for DSAP field in 802.2 LLC header for 802.11 frames: SNAP.
Definition ieee80211.h:337
#define IEEE80211_LLC_CTRL
Value for control field in 802.2 LLC header for 802.11 frames.
Definition ieee80211.h:346
#define IEEE80211_TYP_FRAME_HEADER_LEN
Frame header length for frames we might work with.
Definition ieee80211.h:60
#define IEEE80211_LLC_HEADER_LEN
Length of LLC/SNAP headers on data frames.
Definition ieee80211.h:31
#define IEEE80211_MAKESEQ(seqnr, frag)
Make 802.11 Sequence Control field from sequence and fragment numbers.
Definition ieee80211.h:286
u16 net80211_duration(struct net80211_device *dev, int bytes, u16 rate)
Calculate one frame's contribution to 802.11 duration field.
Definition net80211.c:442
#define NET80211_ASSOCIATED
Whether we have successfully associated with the network.
Definition net80211.h:201
#define ENETUNREACH
Network unreachable.
Definition errno.h:489
#define ETH_ALEN
Definition if_ether.h:9
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
#define iob_push(iobuf, len)
Definition iobuf.h:89
An 802.11 data or management frame without QoS or WDS header fields.
Definition ieee80211.h:301
The 802.2 LLC/SNAP header sent before actual data in a data frame.
Definition ieee80211.h:325
u8 dsap
Destination SAP ID.
Definition ieee80211.h:327
u8 ctrl
Control information.
Definition ieee80211.h:329
u8 ssap
Source SAP ID.
Definition ieee80211.h:328
u16 ethertype
Ethernet Type field.
Definition ieee80211.h:333
u8 oui[3]
Organization code, usually 0.
Definition ieee80211.h:332
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787
u16 last_tx_seqnr
The sequence number of the last packet we sent.
Definition net80211.h:997
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition net80211.h:818
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
u8 bssid[ETH_ALEN]
MAC address of the access point most recently associated.
Definition net80211.h:954
u8 rate
The rate currently in use, as an index into the rates array.
Definition net80211.h:824

References net80211_device::assoc_rc, net80211_device::bssid, ieee80211_llc_snap_header::ctrl, ieee80211_llc_snap_header::dsap, ENETUNREACH, ETH_ALEN, ieee80211_llc_snap_header::ethertype, hdr, IEEE80211_FC_TODS, IEEE80211_LLC_CTRL, IEEE80211_LLC_DSAP, IEEE80211_LLC_HEADER_LEN, IEEE80211_LLC_SSAP, IEEE80211_MAKESEQ, IEEE80211_STYPE_DATA, IEEE80211_THIS_VERSION, IEEE80211_TYP_FRAME_HEADER_LEN, IEEE80211_TYPE_DATA, iob_push, net80211_device::last_tx_seqnr, memcpy(), memset(), NET80211_ASSOCIATED, net80211_duration(), netdev, ieee80211_llc_snap_header::oui, net80211_device::rate, net80211_device::rates, ieee80211_llc_snap_header::ssap, and net80211_device::state.

◆ net80211_ll_pull()

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

References flags, len, netdev, reason, size, start, and u16.