|
iPXE
|
The AF_PACKET driver. More...
#include <errno.h>#include <string.h>#include <stdio.h>#include <ipxe/linux_api.h>#include <ipxe/list.h>#include <ipxe/linux.h>#include <ipxe/malloc.h>#include <ipxe/device.h>#include <ipxe/netdevice.h>#include <ipxe/iobuf.h>#include <ipxe/ethernet.h>#include <ipxe/settings.h>#include <ipxe/socket.h>#include <linux/socket.h>#include <linux/if.h>#include <linux/if_ether.h>#include <linux/if_packet.h>#include <byteswap.h>Go to the source code of this file.
Data Structures | |
| struct | af_packet_nic |
Macros | |
| #define | _SYS_SOCKET_H |
| #define | __GLIBC__ 2 |
| #define | LINUX_AF_PACKET 17 |
| #define | LINUX_SOCK_RAW 3 |
| #define | LINUX_SIOCGIFINDEX 0x8933 |
| #define | LINUX_SIOCGIFHWADDR 0x8927 |
| #define | RX_BUF_SIZE 1536 |
Functions | |
| static int | af_packet_nic_open (struct net_device *netdev) |
| Open the linux interface. | |
| static void | af_packet_nic_close (struct net_device *netdev) |
| Close the packet socket. | |
| static int | af_packet_nic_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
| Transmit an ethernet packet. | |
| static void | af_packet_nic_poll (struct net_device *netdev) |
| Poll for new packets. | |
| static void | af_packet_nic_irq (struct net_device *netdev, int enable) |
| Set irq. | |
| static int | af_packet_update_properties (struct net_device *netdev) |
| static int | af_packet_nic_probe (struct linux_device *device, struct linux_device_request *request) |
| Handle a device request for the af_packet driver. | |
| static void | af_packet_nic_remove (struct linux_device *device) |
| Remove the device. | |
| LINUX_ROM ("af_packet", "AF_PACKET binding NIC") | |
Variables | |
| static struct net_device_operations | af_packet_nic_operations |
| AF_PACKET operations. | |
| struct linux_driver af_packet_nic_driver | __linux_driver |
| AF_PACKET linux_driver. | |
| #define _SYS_SOCKET_H |
Definition at line 34 of file af_packet.c.
| #define __GLIBC__ 2 |
Definition at line 35 of file af_packet.c.
| #define LINUX_AF_PACKET 17 |
Definition at line 44 of file af_packet.c.
Referenced by af_packet_nic_open(), af_packet_nic_transmit(), and af_packet_update_properties().
| #define LINUX_SOCK_RAW 3 |
Definition at line 45 of file af_packet.c.
Referenced by af_packet_nic_open(), and af_packet_update_properties().
| #define LINUX_SIOCGIFINDEX 0x8933 |
Definition at line 46 of file af_packet.c.
Referenced by af_packet_nic_open().
| #define LINUX_SIOCGIFHWADDR 0x8927 |
Definition at line 47 of file af_packet.c.
Referenced by af_packet_update_properties().
| #define RX_BUF_SIZE 1536 |
Definition at line 49 of file af_packet.c.
|
static |
Open the linux interface.
Definition at line 68 of file af_packet.c.
References DBGC, htons, LINUX_AF_PACKET, linux_bind(), linux_close(), linux_errno, linux_fcntl(), linux_ioctl(), LINUX_SIOCGIFINDEX, LINUX_SOCK_RAW, linux_socket(), linux_strerror(), memset(), netdev, and strncpy().
|
static |
Close the packet socket.
Definition at line 123 of file af_packet.c.
References linux_close(), and netdev.
|
static |
Transmit an ethernet packet.
The packet can be written to the socket and marked as complete immediately.
Definition at line 134 of file af_packet.c.
References io_buffer::data, DBGC2, ETH_ALEN, ethhdr::h_dest, LINUX_AF_PACKET, linux_sendto(), memcpy(), memset(), netdev, netdev_tx_complete(), rc, and io_buffer::tail.
|
static |
Poll for new packets.
Definition at line 161 of file af_packet.c.
References alloc_iob(), io_buffer::data, DBGC, DBGC2, free_iob(), iob_put, linux_errno, linux_poll(), linux_read(), linux_strerror(), netdev, netdev_rx(), r, and RX_BUF_SIZE.
|
static |
Set irq.
Not used on linux, provide a dummy implementation.
Definition at line 207 of file af_packet.c.
|
static |
Definition at line 215 of file af_packet.c.
References DBGC, ETH_ALEN, LINUX_AF_PACKET, linux_close(), linux_errno, linux_ioctl(), LINUX_SIOCGIFHWADDR, LINUX_SOCK_RAW, linux_socket(), linux_strerror(), memcpy(), memset(), netdev, and strncpy().
Referenced by af_packet_nic_probe().
|
static |
Handle a device request for the af_packet driver.
Definition at line 256 of file af_packet.c.
References af_packet_nic_operations, af_packet_update_properties(), alloc_etherdev(), linux_setting::applied, device_description::bus_type, BUS_TYPE_TAP, device::desc, EINVAL, ENOMEM, linux_apply_settings(), linux_find_setting(), linux_set_drvdata(), memset(), device::name, netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), printf(), rc, register_netdev(), request, snprintf(), unregister_netdev(), and linux_setting::value.
|
static |
Remove the device.
Definition at line 312 of file af_packet.c.
References linux_get_drvdata(), netdev, netdev_nullify(), netdev_put(), and unregister_netdev().
| LINUX_ROM | ( | "af_packet" | , |
| "AF_PACKET binding NIC" | ) |
|
static |
AF_PACKET operations.
Definition at line 247 of file af_packet.c.
Referenced by af_packet_nic_probe().
| struct linux_driver af_packet_nic_driver __linux_driver |
AF_PACKET linux_driver.
Definition at line 321 of file af_packet.c.