36#include <linux/socket.h>
39#include <linux/if_ether.h>
40#include <linux/if_tun.h>
42#define RX_BUF_SIZE 1536
61 { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 };
76 memset(&ifr, 0,
sizeof(ifr));
78 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
79 strncpy(ifr.ifr_name,
nic->interface, IFNAMSIZ);
144 if ((pfd.revents & POLLIN) == 0)
181 DBGC(
nic,
"tap %p irq enable = %d\n",
nic, enable);
217 printf(
"tap missing a mandatory if setting\n");
struct arbelprm_rc_send_wqe rc
#define BUS_TYPE_TAP
TAP bus type.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
static struct net_device * netdev
#define EINVAL
Invalid argument.
#define ENOMEM
Not enough space.
u8 request[0]
List of IEs requested.
Linux devices, drivers and device requests.
static void linux_set_drvdata(struct linux_device *device, void *priv)
Set linux device driver-private data.
#define LINUX_ROM(_name, _desc)
Define build rules for a Linux driver.
void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block)
Apply a list of linux settings to a settings block.
#define __linux_driver
Declare a Linux driver.
static void * linux_get_drvdata(struct linux_device *device)
Get linux device driver-private data.
struct linux_setting * linux_find_setting(char *name, struct list_head *settings)
Look for the last occurrence of a setting with the specified name.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define iob_put(iobuf, len)
ssize_t __asmcall linux_write(int fd, const void *buf, size_t count)
int __asmcall linux_open(const char *pathname, int flags,...)
int __asmcall linux_ioctl(int fd, unsigned long request,...)
int __asmcall linux_close(int fd)
int __asmcall linux_fcntl(int fd, int cmd,...)
ssize_t __asmcall linux_read(int fd, void *buf, size_t count)
int __asmcall linux_poll(struct pollfd *fds, unsigned int nfds, int timeout)
const char *__asmcall linux_strerror(int linux_errno)
Dynamic memory allocation.
static const uint8_t r[3][4]
MD4 shift amounts.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
int register_netdev(struct net_device *netdev)
Register network device.
Network device management.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
unsigned int bus_type
Bus type.
struct device_description desc
Device description.
void * data
Start of data.
A device request setting.
int applied
Was the setting already applied?
Network device operations.
char * interface
Tap interface name.
int fd
File descriptor of the opened tap device.
static void tap_poll(struct net_device *netdev)
Poll for new packets.
static struct net_device_operations tap_operations
Tap operations.
static int tap_open(struct net_device *netdev)
Open the TAP device.
static void tap_close(struct net_device *netdev)
Close the TAP device.
static int tap_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit an ethernet packet.
static void tap_irq(struct net_device *netdev, int enable)
Set irq.
static const uint8_t tap_default_mac[ETH_ALEN]
Default MAC address.
static void tap_remove(struct linux_device *device)
Remove the device.
static int tap_probe(struct linux_device *device, struct linux_device_request *request)
Handle a device request for the tap driver.
int printf(const char *fmt,...)
Write a formatted string to the console.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.