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)

Function Documentation

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:
netdev Wrapping network device
iobuf I/O buffer
ll_dest Link-layer destination address
ll_source Link-layer source address
net_proto Network-layer protocol, in network byte order
Return values:
rc Return 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 506 of file net80211.c.

References ieee80211_frame::addr1, ieee80211_frame::addr2, ieee80211_frame::addr3, net80211_device::assoc_rc, net80211_device::bssid, ieee80211_llc_snap_header::ctrl, ieee80211_llc_snap_header::dsap, ieee80211_frame::duration, ENETUNREACH, ETH_ALEN, ieee80211_llc_snap_header::ethertype, ieee80211_frame::fc, 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(), ieee80211_llc_snap_header::oui, net_device::priv, net80211_device::rate, net80211_device::rates, ieee80211_frame::seq, ieee80211_llc_snap_header::ssap, and net80211_device::state.

00509 {
00510         struct net80211_device *dev = netdev->priv;
00511         struct ieee80211_frame *hdr = iob_push ( iobuf,
00512                                                  IEEE80211_LLC_HEADER_LEN +
00513                                                  IEEE80211_TYP_FRAME_HEADER_LEN );
00514         struct ieee80211_llc_snap_header *lhdr =
00515                 ( void * ) hdr + IEEE80211_TYP_FRAME_HEADER_LEN;
00516 
00517         /* We can't send data packets if we're not associated. */
00518         if ( ! ( dev->state & NET80211_ASSOCIATED ) ) {
00519                 if ( dev->assoc_rc )
00520                         return dev->assoc_rc;
00521                 return -ENETUNREACH;
00522         }
00523 
00524         hdr->fc = IEEE80211_THIS_VERSION | IEEE80211_TYPE_DATA |
00525             IEEE80211_STYPE_DATA | IEEE80211_FC_TODS;
00526 
00527         /* We don't send fragmented frames, so duration is the time
00528            for an SIFS + 10-byte ACK. */
00529         hdr->duration = net80211_duration ( dev, 10, dev->rates[dev->rate] );
00530 
00531         memcpy ( hdr->addr1, dev->bssid, ETH_ALEN );
00532         memcpy ( hdr->addr2, ll_source, ETH_ALEN );
00533         memcpy ( hdr->addr3, ll_dest, ETH_ALEN );
00534 
00535         hdr->seq = IEEE80211_MAKESEQ ( ++dev->last_tx_seqnr, 0 );
00536 
00537         lhdr->dsap = IEEE80211_LLC_DSAP;
00538         lhdr->ssap = IEEE80211_LLC_SSAP;
00539         lhdr->ctrl = IEEE80211_LLC_CTRL;
00540         memset ( lhdr->oui, 0x00, 3 );
00541         lhdr->ethertype = net_proto;
00542 
00543         return 0;
00544 }

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 
) [static]


Generated on Tue Apr 6 20:01:57 2010 for gPXE by  doxygen 1.5.7.1