iPXE
Network device interface functions

Functions

static int net80211_netdev_open (struct net_device *netdev)
 Open 802.11 device and start association.
static void net80211_netdev_close (struct net_device *netdev)
 Close 802.11 device.
static int net80211_netdev_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet on 802.11 device.
static void net80211_netdev_poll (struct net_device *netdev)
 Poll 802.11 device for received packets and completed transmissions.
static void net80211_netdev_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts for 802.11 device.

Detailed Description

Function Documentation

◆ net80211_netdev_open()

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

258{
259 struct net80211_device *dev = netdev->priv;
260 int rc = 0;
261
262 if ( dev->op == &net80211_null_ops )
263 return -EFAULT;
264
265 if ( dev->op->open )
266 rc = dev->op->open ( dev );
267
268 if ( rc < 0 )
269 return rc;
270
271 if ( ! ( dev->state & NET80211_NO_ASSOC ) )
273
274 return 0;
275}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static struct net_device * netdev
Definition gdbudp.c:53
void net80211_autoassociate(struct net80211_device *dev)
Start 802.11 association process.
Definition net80211.c:1930
#define NET80211_NO_ASSOC
Whether the auto-association task should be suppressed.
Definition net80211.h:223
#define EFAULT
Bad address.
Definition errno.h:394
static struct net80211_device_operations net80211_null_ops
Set of device operations that does nothing.
Definition net80211.c:51
int(* open)(struct net80211_device *dev)
Open 802.11 device.
Definition net80211.h:305
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787
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, rc, and net80211_device::state.

◆ net80211_netdev_close()

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

285{
286 struct net80211_device *dev = netdev->priv;
287
288 if ( dev->state & NET80211_WORKING )
289 process_del ( &dev->proc_assoc );
290
291 /* Send disassociation frame to AP, to be polite */
292 if ( dev->state & NET80211_ASSOCIATED )
294
295 if ( dev->handshaker && dev->handshaker->stop &&
296 dev->handshaker->started )
297 dev->handshaker->stop ( dev );
298
299 free ( dev->crypto );
300 free ( dev->handshaker );
301 dev->crypto = NULL;
302 dev->handshaker = NULL;
303
305 dev->state = 0;
306
307 if ( dev->op->close )
308 dev->op->close ( dev );
309}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define IEEE80211_REASON_LEAVING
Definition ieee80211.h:514
static int net80211_send_disassoc(struct net80211_device *dev, int reason, int deauth)
Send 802.11 disassociation frame.
Definition net80211.c:2362
#define NET80211_WORKING
Whether the auto-association task is running.
Definition net80211.h:212
#define NET80211_ASSOCIATED
Whether we have successfully associated with the network.
Definition net80211.h:201
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
void process_del(struct process *process)
Remove process from process list.
Definition process.c:80
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
void(* close)(struct net80211_device *dev)
Close 802.11 network device.
Definition net80211.h:315
struct net80211_crypto * crypto
802.11 cryptosystem for our current network
Definition net80211.h:940
struct net80211_handshaker * handshaker
Security handshaker being used.
Definition net80211.h:879
struct process proc_assoc
The asynchronous association process.
Definition net80211.h:858
int started
Whether start has been called.
Definition net80211.h:665
void(* stop)(struct net80211_device *dev)
Stop security handshaking handlers.
Definition net80211.h:650

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, net80211_device::proc_assoc, process_del(), net80211_handshaker::started, net80211_device::state, and net80211_handshaker::stop.

◆ net80211_netdev_transmit()

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

323{
324 struct net80211_device *dev = netdev->priv;
325 struct ieee80211_frame *hdr = iobuf->data;
326 int rc = -ENOSYS;
327
328 if ( dev->crypto && ! ( hdr->fc & IEEE80211_FC_PROTECTED ) &&
329 ( ( hdr->fc & IEEE80211_FC_TYPE ) == IEEE80211_TYPE_DATA ) ) {
330 struct io_buffer *niob = dev->crypto->encrypt ( dev->crypto,
331 iobuf );
332 if ( ! niob )
333 return -ENOMEM; /* only reason encryption could fail */
334
335 /* Free the non-encrypted iob */
336 netdev_tx_complete ( netdev, iobuf );
337
338 /* Transmit the encrypted iob; the Protected flag is
339 set, so we won't recurse into here again */
340 netdev_tx ( netdev, niob );
341
342 /* Don't transmit the freed packet */
343 return 0;
344 }
345
346 if ( dev->op->transmit )
347 rc = dev->op->transmit ( dev, iobuf );
348
349 return rc;
350}
struct golan_inbox_hdr hdr
Message header.
Definition CIB_PRM.h:0
#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
#define IEEE80211_TYPE_DATA
Type value for data frames.
Definition ieee80211.h:106
#define ENOSYS
Function not implemented.
Definition errno.h:565
#define ENOMEM
Not enough space.
Definition errno.h:535
int netdev_tx(struct net_device *netdev, struct io_buffer *iobuf)
Transmit raw packet via network device.
Definition netdevice.c:335
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
An 802.11 data or management frame without QoS or WDS header fields.
Definition ieee80211.h:301
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53
struct io_buffer *(* encrypt)(struct net80211_crypto *crypto, struct io_buffer *iob)
Encrypt a frame using the cryptosystem.
Definition net80211.h:733
int(* transmit)(struct net80211_device *dev, struct io_buffer *iobuf)
Transmit packet on 802.11 network device.
Definition net80211.h:341

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, rc, and net80211_device_operations::transmit.

◆ net80211_netdev_poll()

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

358{
359 struct net80211_device *dev = netdev->priv;
360
361 if ( dev->op->poll )
362 dev->op->poll ( dev );
363}
void(* poll)(struct net80211_device *dev)
Poll for completed and received packets.
Definition net80211.h:357

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

◆ net80211_netdev_irq()

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

372{
373 struct net80211_device *dev = netdev->priv;
374
375 if ( dev->op->irq )
376 dev->op->irq ( dev, enable );
377}
void(* irq)(struct net80211_device *dev, int enable)
Enable or disable interrupts.
Definition net80211.h:364

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