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

Detailed Description

Function Documentation

◆ net80211_ll_push()

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

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

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, net_device::priv, net80211_device::rate, net80211_device::rates, ieee80211_llc_snap_header::ssap, and net80211_device::state.

◆ net80211_ll_pull()

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