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

Function Documentation

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.

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

{
        struct net80211_device *dev = netdev->priv;
        int rc = 0;

        if ( dev->op == &net80211_null_ops )
                return -EFAULT;

        if ( dev->op->open )
                rc = dev->op->open ( dev );

        if ( rc < 0 )
                return rc;

        if ( ! ( dev->state & NET80211_NO_ASSOC ) )
                net80211_autoassociate ( dev );

        return 0;
}
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.

References net80211_device_operations::close, net80211_device::crypto, free, net80211_device::handshaker, IEEE80211_REASON_LEAVING, NET80211_ASSOCIATED, net80211_send_disassoc(), NET80211_WORKING, 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.

{
        struct net80211_device *dev = netdev->priv;

        if ( dev->state & NET80211_WORKING )
                process_del ( &dev->proc_assoc );

        /* Send disassociation frame to AP, to be polite */
        if ( dev->state & NET80211_ASSOCIATED )
                net80211_send_disassoc ( dev, IEEE80211_REASON_LEAVING, 0 );

        if ( dev->handshaker && dev->handshaker->stop &&
             dev->handshaker->started )
                dev->handshaker->stop ( dev );

        free ( dev->crypto );
        free ( dev->handshaker );
        dev->crypto = NULL;
        dev->handshaker = NULL;

        netdev_link_down ( netdev );
        dev->state = 0;

        if ( dev->op->close )
                dev->op->close ( dev );
}
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.

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

{
        struct net80211_device *dev = netdev->priv;
        struct ieee80211_frame *hdr = iobuf->data;
        int rc = -ENOSYS;

        if ( dev->crypto && ! ( hdr->fc & IEEE80211_FC_PROTECTED ) &&
             ( ( hdr->fc & IEEE80211_FC_TYPE ) == IEEE80211_TYPE_DATA ) ) {
                struct io_buffer *niob = dev->crypto->encrypt ( dev->crypto,
                                                                iobuf );
                if ( ! niob )
                        return -ENOMEM; /* only reason encryption could fail */

                /* Free the non-encrypted iob */
                netdev_tx_complete ( netdev, iobuf );

                /* Transmit the encrypted iob; the Protected flag is
                   set, so we won't recurse into here again */
                netdev_tx ( netdev, niob );

                /* Don't transmit the freed packet */
                return 0;
        }

        if ( dev->op->transmit )
                rc = dev->op->transmit ( dev, iobuf );

        return rc;
}
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.

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

{
        struct net80211_device *dev = netdev->priv;

        if ( dev->op->poll )
                dev->op->poll ( dev );
}
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.

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

{
        struct net80211_device *dev = netdev->priv;

        if ( dev->op->irq )
                dev->op->irq ( dev, enable );
}