iPXE
Functions
Network device interface functions

Functions

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

Detailed Description

Function Documentation

◆ net80211_netdev_open()

static int net80211_netdev_open ( struct net_device netdev)
static

Open 802.11 device and start association.

Parameters
netdevWrapping network device
Return values
rcReturn status code

This sets up a default conservative set of channels for probing, and starts the auto-association task unless the NET80211_NO_ASSOC flag is set in the wrapped 802.11 device's state field.

Definition at line 256 of file net80211.c.

257 {
258  struct net80211_device *dev = netdev->priv;
259  int rc = 0;
260 
261  if ( dev->op == &net80211_null_ops )
262  return -EFAULT;
263 
264  if ( dev->op->open )
265  rc = dev->op->open ( dev );
266 
267  if ( rc < 0 )
268  return rc;
269 
270  if ( ! ( dev->state & NET80211_NO_ASSOC ) )
271  net80211_autoassociate ( dev );
272 
273  return 0;
274 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int(* open)(struct net80211_device *dev)
Open 802.11 device.
Definition: net80211.h:305
static struct net80211_device_operations net80211_null_ops
Set of device operations that does nothing.
Definition: net80211.c:50
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define EFAULT
Bad address.
Definition: errno.h:393
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
void net80211_autoassociate(struct net80211_device *dev)
Start 802.11 association process.
Definition: net80211.c:1929
#define NET80211_NO_ASSOC
Whether the auto-association task should be suppressed.
Definition: net80211.h:223
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
u16 state
State of our association to the network.
Definition: net80211.h:921

References EFAULT, net80211_autoassociate(), NET80211_NO_ASSOC, net80211_null_ops, netdev, net80211_device::op, net80211_device_operations::open, net_device::priv, rc, and net80211_device::state.

◆ net80211_netdev_close()

static void net80211_netdev_close ( struct net_device netdev)
static

Close 802.11 device.

Parameters
netdevWrapping network device.

If the association task is running, this will stop it.

Definition at line 283 of file net80211.c.

284 {
285  struct net80211_device *dev = netdev->priv;
286 
287  if ( dev->state & NET80211_WORKING )
288  process_del ( &dev->proc_assoc );
289 
290  /* Send disassociation frame to AP, to be polite */
291  if ( dev->state & NET80211_ASSOCIATED )
293 
294  if ( dev->handshaker && dev->handshaker->stop &&
295  dev->handshaker->started )
296  dev->handshaker->stop ( dev );
297 
298  free ( dev->crypto );
299  free ( dev->handshaker );
300  dev->crypto = NULL;
301  dev->handshaker = NULL;
302 
304  dev->state = 0;
305 
306  if ( dev->op->close )
307  dev->op->close ( dev );
308 }
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
static int net80211_send_disassoc(struct net80211_device *dev, int reason, int deauth)
Send 802.11 disassociation frame.
Definition: net80211.c:2361
#define NET80211_WORKING
Whether the auto-association task is running.
Definition: net80211.h:212
int started
Whether start has been called.
Definition: net80211.h:665
struct net80211_crypto * crypto
802.11 cryptosystem for our current network
Definition: net80211.h:940
struct process proc_assoc
The asynchronous association process.
Definition: net80211.h:858
void * priv
Driver private data.
Definition: netdevice.h:431
void(* stop)(struct net80211_device *dev)
Stop security handshaking handlers.
Definition: net80211.h:650
static struct net_device * netdev
Definition: gdbudp.c:52
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#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
struct net80211_handshaker * handshaker
Security handshaker being used.
Definition: net80211.h:879
#define IEEE80211_REASON_LEAVING
Definition: ieee80211.h:514
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
void(* close)(struct net80211_device *dev)
Close 802.11 network device.
Definition: net80211.h:315
u16 state
State of our association to the network.
Definition: net80211.h:921
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References net80211_device_operations::close, net80211_device::crypto, free, net80211_device::handshaker, IEEE80211_REASON_LEAVING, NET80211_ASSOCIATED, net80211_send_disassoc(), NET80211_WORKING, netdev, netdev_link_down(), NULL, net80211_device::op, net_device::priv, net80211_device::proc_assoc, process_del(), net80211_handshaker::started, net80211_device::state, and net80211_handshaker::stop.

◆ net80211_netdev_transmit()

static int net80211_netdev_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)
static

Transmit packet on 802.11 device.

Parameters
netdevWrapping network device
iobufI/O buffer
Return values
rcReturn status code

If encryption is enabled for the currently associated network, the packet will be encrypted prior to transmission.

Definition at line 320 of file net80211.c.

322 {
323  struct net80211_device *dev = netdev->priv;
324  struct ieee80211_frame *hdr = iobuf->data;
325  int rc = -ENOSYS;
326 
327  if ( dev->crypto && ! ( hdr->fc & IEEE80211_FC_PROTECTED ) &&
328  ( ( hdr->fc & IEEE80211_FC_TYPE ) == IEEE80211_TYPE_DATA ) ) {
329  struct io_buffer *niob = dev->crypto->encrypt ( dev->crypto,
330  iobuf );
331  if ( ! niob )
332  return -ENOMEM; /* only reason encryption could fail */
333 
334  /* Free the non-encrypted iob */
335  netdev_tx_complete ( netdev, iobuf );
336 
337  /* Transmit the encrypted iob; the Protected flag is
338  set, so we won't recurse into here again */
339  netdev_tx ( netdev, niob );
340 
341  /* Don't transmit the freed packet */
342  return 0;
343  }
344 
345  if ( dev->op->transmit )
346  rc = dev->op->transmit ( dev, iobuf );
347 
348  return rc;
349 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:752
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
An 802.11 data or management frame without QoS or WDS header fields.
Definition: ieee80211.h:300
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct net80211_crypto * crypto
802.11 cryptosystem for our current network
Definition: net80211.h:940
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
int(* transmit)(struct net80211_device *dev, struct io_buffer *iobuf)
Transmit packet on 802.11 network device.
Definition: net80211.h:341
#define IEEE80211_FC_PROTECTED
802.11 Frame Control field: Protected flag
Definition: ieee80211.h:264
#define IEEE80211_FC_TYPE
802.11 Frame Control field, Frame Type bitmask
Definition: ieee80211.h:97
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
int netdev_tx(struct net_device *netdev, struct io_buffer *iobuf)
Transmit raw packet via network device.
Definition: netdevice.c:334
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
void * data
Start of data.
Definition: iobuf.h:48
#define ENOSYS
Function not implemented.
Definition: errno.h:564
struct io_buffer *(* encrypt)(struct net80211_crypto *crypto, struct io_buffer *iob)
Encrypt a frame using the cryptosystem.
Definition: net80211.h:733
#define IEEE80211_TYPE_DATA
Type value for data frames.
Definition: ieee80211.h:106
A persistent I/O buffer.
Definition: iobuf.h:33

References net80211_device::crypto, io_buffer::data, net80211_crypto::encrypt, ENOMEM, ENOSYS, hdr, IEEE80211_FC_PROTECTED, IEEE80211_FC_TYPE, IEEE80211_TYPE_DATA, netdev, netdev_tx(), netdev_tx_complete(), net80211_device::op, net_device::priv, rc, and net80211_device_operations::transmit.

◆ net80211_netdev_poll()

static void net80211_netdev_poll ( struct net_device netdev)
static

Poll 802.11 device for received packets and completed transmissions.

Parameters
netdevWrapping network device

Definition at line 356 of file net80211.c.

357 {
358  struct net80211_device *dev = netdev->priv;
359 
360  if ( dev->op->poll )
361  dev->op->poll ( dev );
362 }
void(* poll)(struct net80211_device *dev)
Poll for completed and received packets.
Definition: net80211.h:357
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795

References netdev, net80211_device::op, net80211_device_operations::poll, and net_device::priv.

◆ net80211_netdev_irq()

static void net80211_netdev_irq ( struct net_device netdev,
int  enable 
)
static

Enable or disable interrupts for 802.11 device.

Parameters
netdevWrapping network device
enableWhether to enable interrupts

Definition at line 370 of file net80211.c.

371 {
372  struct net80211_device *dev = netdev->priv;
373 
374  if ( dev->op->irq )
375  dev->op->irq ( dev, enable );
376 }
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
void(* irq)(struct net80211_device *dev, int enable)
Enable or disable interrupts.
Definition: net80211.h:364
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795

References net80211_device_operations::irq, netdev, net80211_device::op, and net_device::priv.