40#define SLIRP_MAX_FDS 128
66 { 0x52, 0x54, 0x00, 0x12, 0x34, 0x56 };
141 alarm->callback ( alarm->
opaque );
154 void *opaque,
void *
device ) {
160 alarm =
malloc (
sizeof ( *alarm ) );
167 memset ( alarm, 0,
sizeof ( *alarm ) );
170 alarm->callback = callback;
172 DBGC (
slirp,
"SLIRP %p timer %p has callback %p (%p)\n",
222 if ( timeout_ms < 0 )
226 DBGC (
slirp,
"SLIRP %p timer %p set for %ld ticks\n",
344 struct pollfd *pollfd;
349 DBGC ( slirp,
"SLIRP %p too many file descriptors\n", slirp );
359 pollfd->events |= POLLIN;
361 pollfd->events |= POLLOUT;
363 pollfd->events |= POLLPRI;
365 pollfd->events |= POLLERR;
367 pollfd->events |= ( POLLHUP | POLLRDHUP );
368 DBGCP ( slirp,
"SLIRP %p polling FD %d event mask %#04x(%#04x)\n",
369 slirp, fd, events, pollfd->events );
394 if ( revents & POLLIN )
396 if ( revents & POLLOUT )
398 if ( revents & POLLPRI )
400 if ( revents & POLLERR )
402 if ( revents & ( POLLHUP | POLLRDHUP ) )
405 DBGC2 (
slirp,
"SLIRP %p polled FD %d events %#04x(%#04x)\n",
430 error = ( ready == -1 );
436 DBGC (
slirp,
"SLIRP %p poll failed: %s\n",
483 memset ( slirp, 0,
sizeof ( *slirp ) );
490 memset ( &config, 0,
sizeof ( config ) );
502 if ( ! slirp->
slirp ) {
503 DBGC ( slirp,
"SLIRP could not instantiate\n" );
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
struct arbelprm_completion_with_error error
#define __asmcall
Declare a function with standard calling conventions.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
static struct net_device * netdev
#define __unused
Declare a variable or data structure as unused.
#define ENOMEM
Not enough space.
#define ENODEV
No such device.
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.
#define ELINUX(errno)
Convert a Linux error number to an iPXE status code.
#define TICKS_PER_MS
Number of ticks per millisecond.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define iob_put(iobuf, len)
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
void __asmcall linux_slirp_pollfds_fill(struct Slirp *slirp, uint32_t *timeout, int(__asmcall *add_poll)(int fd, int events, void *opaque), void *opaque)
void __asmcall linux_slirp_input(struct Slirp *slirp, const uint8_t *pkt, int pkt_len)
void __asmcall linux_slirp_pollfds_poll(struct Slirp *slirp, int select_error, int(__asmcall *get_revents)(int idx, void *opaque), void *opaque)
struct Slirp *__asmcall linux_slirp_new(const struct slirp_config *config, const struct slirp_callbacks *callbacks, void *opaque)
void __asmcall linux_slirp_cleanup(struct Slirp *slirp)
int __asmcall linux_poll(struct pollfd *fds, unsigned int nfds, int timeout)
const char *__asmcall linux_strerror(int linux_errno)
void * malloc(size_t size)
Allocate memory.
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
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.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
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.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
static void(* free)(struct refcnt *refcnt))
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
void stop_timer(struct retry_timer *timer)
Stop timer.
static void __asmcall slirp_notify(void *device)
Notify that new events are ready.
static void slirp_expired(struct retry_timer *timer, int over __unused)
Handle timer expiry.
static void __asmcall slirp_unregister_poll_fd(int fd, void *device)
Unregister file descriptor.
static ssize_t __asmcall slirp_send_packet(const void *buf, size_t len, void *device)
Send packet.
static int slirp_open(struct net_device *netdev)
Open network device.
static struct net_device_operations slirp_operations
Network device operations.
static void slirp_close(struct net_device *netdev)
Close network device.
#define SLIRP_MAX_FDS
Maximum number of open file descriptors.
static void slirp_poll(struct net_device *netdev)
Poll for completed and received packets.
static int __asmcall slirp_add_poll(int fd, int events, void *device)
Add polling file descriptor.
static void __asmcall slirp_guest_error(const char *msg, void *device)
Print an error message.
static void __asmcall slirp_timer_mod(void *timer, int64_t expire, void *device)
Set timer expiry time.
static int slirp_probe(struct linux_device *linux, struct linux_device_request *request)
Probe device.
static const uint8_t slirp_default_mac[ETH_ALEN]
Default MAC address.
static int __asmcall slirp_get_revents(int index, void *device)
Get returned events for a file descriptor.
static int slirp_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
static void __asmcall slirp_timer_free(void *timer, void *device)
Delete a timer.
static void slirp_remove(struct linux_device *linux)
Remove device.
static void __asmcall slirp_register_poll_fd(int fd, void *device)
Register file descriptor for polling.
static void *__asmcall slirp_timer_new(void(__asmcall *callback)(void *opaque), void *opaque, void *device)
Create a new timer.
static int64_t __asmcall slirp_clock_get_ns(void *device __unused)
Get virtual clock.
Linux Slirp network driver.
#define SLIRP_EVENT_ERR
Error condition.
#define SLIRP_EVENT_IN
Ready to be read.
#define SLIRP_EVENT_PRI
Exceptional condition.
#define SLIRP_EVENT_HUP
Hang up.
#define SLIRP_EVENT_OUT
Ready to be written.
#define container_of(ptr, type, field)
Get containing structure.
void * data
Start of data.
struct device dev
Generic device.
Network device operations.
struct retry_timer timer
Retry timer.
void(__asmcall *callback)(void *opaque)
Callback function.
void * opaque
Opaque value for callback function.
struct slirp_nic * slirp
Slirp network interface.
Slirp device configuration.
bool in6_enabled
IPv6 is enabled.
struct in_addr vhost
IPv4 host server address.
bool in_enabled
IPv4 is enabled.
uint32_t version
Configuration version.
struct in_addr vnetmask
IPv4 netmask.
struct in_addr vnameserver
DNS IPv4 address.
struct in_addr vdhcp_start
DHCPv4 start address.
struct in_addr vnetwork
IPv4 network.
A Slirp network interface.
unsigned int numfds
Number of file descriptors.
struct pollfd pollfds[SLIRP_MAX_FDS]
Polling file descriptor list.
struct Slirp * slirp
The libslirp device object.
unsigned long currticks(void)
Get current system time in ticks.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.