iPXE
slirp.h
Go to the documentation of this file.
1 #ifndef _IPXE_SLIRP_H
2 #define _IPXE_SLIRP_H
3 
4 /** @file
5  *
6  * Linux Slirp network driver
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER );
11 
12 #include <stdint.h>
13 #include <stdbool.h>
14 
15 /** Ready to be read */
16 #define SLIRP_EVENT_IN 0x01
17 
18 /** Ready to be written */
19 #define SLIRP_EVENT_OUT 0x02
20 
21 /** Exceptional condition */
22 #define SLIRP_EVENT_PRI 0x04
23 
24 /** Error condition */
25 #define SLIRP_EVENT_ERR 0x08
26 
27 /** Hang up */
28 #define SLIRP_EVENT_HUP 0x10
29 
30 /** Slirp device configuration */
31 struct slirp_config {
32  /** Configuration version */
34  /** Restrict to host loopback connections only */
36  /** IPv4 is enabled */
37  bool in_enabled;
38  /** IPv4 network */
39  struct in_addr vnetwork;
40  /** IPv4 netmask */
41  struct in_addr vnetmask;
42  /** IPv4 host server address */
43  struct in_addr vhost;
44  /** IPv6 is enabled */
46  /** IPv6 prefix */
48  /** IPv6 prefix length */
50  /** IPv6 host server address */
51  struct in6_addr vhost6;
52  /** Client hostname */
53  const char *vhostname;
54  /** TFTP server name */
55  const char *tftp_server_name;
56  /** TFTP path prefix */
57  const char *tftp_path;
58  /** Boot filename */
59  const char *bootfile;
60  /** DHCPv4 start address */
62  /** DNS IPv4 address */
64  /** DNS IPv6 address */
66  /** DNS search list */
67  const char **vdnssearch;
68  /** Domain name */
69  const char *vdomainname;
70  /** Interface MTU */
71  size_t if_mtu;
72  /** Interface MRU */
73  size_t if_mru;
74  /** Disable host loopback connections */
76  /** Enable emulation (apparently unsafe) */
77  bool enable_emu;
78 };
79 
80 /** Slirp device callbacks */
82  /**
83  * Send packet
84  *
85  * @v buf Data buffer
86  * @v len Length of data
87  * @v device Device opaque pointer
88  * @ret len Consumed length (or negative on error)
89  */
90  ssize_t ( __asmcall * send_packet ) ( const void *buf, size_t len,
91  void *device );
92  /**
93  * Print an error message
94  *
95  * @v msg Error message
96  * @v device Device opaque pointer
97  */
98  void ( __asmcall * guest_error ) ( const char *msg, void *device );
99  /**
100  * Get virtual clock
101  *
102  * @v device Device opaque pointer
103  * @ret clock_ns Clock time in nanoseconds
104  */
105  int64_t ( __asmcall * clock_get_ns ) ( void *device );
106  /**
107  * Create a new timer
108  *
109  * @v callback Timer callback
110  * @v opaque Timer opaque pointer
111  * @v device Device opaque pointer
112  * @ret timer Timer
113  */
114  void * ( __asmcall * timer_new ) ( void ( __asmcall * callback )
115  ( void *opaque ),
116  void *opaque, void *device );
117  /**
118  * Delete a timer
119  *
120  * @v timer Timer
121  * @v device Device opaque pointer
122  */
123  void ( __asmcall * timer_free ) ( void *timer, void *device );
124  /**
125  * Set timer expiry time
126  *
127  * @v timer Timer
128  * @v expire Expiry time
129  * @v device Device opaque pointer
130  */
131  void ( __asmcall * timer_mod ) ( void *timer, int64_t expire,
132  void *device );
133  /**
134  * Register file descriptor for polling
135  *
136  * @v fd File descriptor
137  * @v device Device opaque pointer
138  */
139  void ( __asmcall * register_poll_fd ) ( int fd, void *device );
140  /**
141  * Unregister file descriptor
142  *
143  * @v fd File descriptor
144  * @v device Device opaque pointer
145  */
146  void ( __asmcall * unregister_poll_fd ) ( int fd, void *device );
147  /**
148  * Notify that new events are ready
149  *
150  * @v device Device opaque pointer
151  */
152  void ( __asmcall * notify ) ( void *device );
153 };
154 
155 #endif /* _IPXE_SLIRP_H */
Slirp device configuration.
Definition: slirp.h:31
struct in_addr vnameserver
DNS IPv4 address.
Definition: slirp.h:63
bool enable_emu
Enable emulation (apparently unsafe)
Definition: slirp.h:77
void(__asmcall *guest_error)(const char *msg
Print an error message.
const char * tftp_server_name
TFTP server name.
Definition: slirp.h:55
const char * vhostname
Client hostname.
Definition: slirp.h:53
const char * bootfile
Boot filename.
Definition: slirp.h:59
size_t if_mtu
Interface MTU.
Definition: slirp.h:71
int64_t(__asmcall *clock_get_ns)(void *device)
Get virtual clock.
const char ** vdnssearch
DNS search list.
Definition: slirp.h:67
struct in6_addr vhost6
IPv6 host server address.
Definition: slirp.h:51
A hardware device.
Definition: device.h:73
struct in6_addr vprefix_addr6
IPv6 prefix.
Definition: slirp.h:47
#define __asmcall
Declare a function with standard calling conventions.
Definition: compiler.h:15
signed long long int64_t
Definition: stdint.h:18
int64_t expire
Definition: slirp.h:131
bool in6_enabled
IPv6 is enabled.
Definition: slirp.h:45
size_t len
Definition: slirp.h:90
struct in_addr vnetwork
IPv4 network.
Definition: slirp.h:39
struct in_addr vhost
IPv4 host server address.
Definition: slirp.h:43
void * device
Definition: slirp.h:98
IP6 address structure.
Definition: in.h:48
void *__asmcall * timer_new(void(__asmcall *callback)(void *opaque), void *opaque, void *device)
Create a new timer.
int restricted
Restrict to host loopback connections only.
Definition: slirp.h:35
IP address structure.
Definition: in.h:39
struct in_addr vdhcp_start
DHCPv4 start address.
Definition: slirp.h:61
const char * vdomainname
Domain name.
Definition: slirp.h:69
unsigned char uint8_t
Definition: stdint.h:10
struct in_addr vnetmask
IPv4 netmask.
Definition: slirp.h:41
const char * tftp_path
TFTP path prefix.
Definition: slirp.h:57
uint32_t version
Configuration version.
Definition: slirp.h:33
unsigned int uint32_t
Definition: stdint.h:12
Slirp device callbacks.
Definition: slirp.h:81
struct in_addr vnameserver6
DNS IPv6 address.
Definition: slirp.h:65
size_t void * device
Definition: slirp.h:90
static struct timer * timer
Current timer.
Definition: timer.c:35
uint8_t vprefix_len
IPv6 prefix length.
Definition: slirp.h:49
FILE_LICENCE(GPL2_OR_LATER)
size_t if_mru
Interface MRU.
Definition: slirp.h:73
bool disable_host_loopback
Disable host loopback connections.
Definition: slirp.h:75
ssize_t(__asmcall *send_packet)(const void *buf
Send packet.
bool in_enabled
IPv4 is enabled.
Definition: slirp.h:37
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:288