1 | #ifndef _LIBSLIRP_H
|
---|
2 | #define _LIBSLIRP_H
|
---|
3 |
|
---|
4 | #ifdef RT_OS_WINDOWS
|
---|
5 | # include <winsock2.h>
|
---|
6 | # ifdef __cplusplus
|
---|
7 | extern "C" {
|
---|
8 | # endif
|
---|
9 | int inet_aton(const char *cp, struct in_addr *ia);
|
---|
10 | # ifdef __cplusplus
|
---|
11 | }
|
---|
12 | # endif
|
---|
13 | #else
|
---|
14 | # ifdef RT_OS_OS2 /* temporary workaround, see ticket #127 */
|
---|
15 | # include <sys/time.h>
|
---|
16 | # endif
|
---|
17 | # include <sys/select.h>
|
---|
18 | # include <poll.h>
|
---|
19 | # include <arpa/inet.h>
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #include <VBox/types.h>
|
---|
23 |
|
---|
24 | typedef struct NATState *PNATState;
|
---|
25 |
|
---|
26 | #ifdef __cplusplus
|
---|
27 | extern "C" {
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #ifndef VBOX_WITH_NAT_SERVICE
|
---|
31 | int slirp_init(PNATState *, const char *, uint32_t, bool, void *);
|
---|
32 | #else
|
---|
33 | int slirp_init(PNATState *, uint32_t, uint32_t, bool, void *);
|
---|
34 | #endif
|
---|
35 | void slirp_register_timers(PNATState pData, PPDMDRVINS pDrvIns);
|
---|
36 | void slirp_term(PNATState);
|
---|
37 | void slirp_link_up(PNATState);
|
---|
38 | void slirp_link_down(PNATState);
|
---|
39 |
|
---|
40 | #if defined(RT_OS_WINDOWS)
|
---|
41 | void slirp_select_fill(PNATState pData, int *pndfs);
|
---|
42 |
|
---|
43 | void slirp_select_poll(PNATState pData, int fTimeout, int fIcmp);
|
---|
44 | #else /* RT_OS_WINDOWS */
|
---|
45 | void slirp_select_fill(PNATState pData, int *pnfds, struct pollfd *polls);
|
---|
46 | void slirp_select_poll(PNATState pData, struct pollfd *polls, int ndfs);
|
---|
47 | #endif /* !RT_OS_WINDOWS */
|
---|
48 |
|
---|
49 | void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);
|
---|
50 | void slirp_set_ethaddr(PNATState pData, const uint8_t *ethaddr);
|
---|
51 |
|
---|
52 | /* you must provide the following functions: */
|
---|
53 | int slirp_can_output(void * pvUser);
|
---|
54 | void slirp_output(void * pvUser, void *pvArg, const uint8_t *pkt, int pkt_len);
|
---|
55 | void slirp_post_sent(PNATState pData, void *pvArg);
|
---|
56 |
|
---|
57 | int slirp_redir(PNATState pData, int is_udp, int host_port,
|
---|
58 | struct in_addr guest_addr, int guest_port);
|
---|
59 | int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
|
---|
60 | int guest_port);
|
---|
61 |
|
---|
62 | void slirp_set_dhcp_TFTP_prefix(PNATState pData, const char *tftpPrefix);
|
---|
63 | void slirp_set_dhcp_TFTP_bootfile(PNATState pData, const char *bootFile);
|
---|
64 | void slirp_set_dhcp_next_server(PNATState pData, const char *nextServer);
|
---|
65 | #ifdef VBOX_WITH_SLIRP_DNS_PROXY
|
---|
66 | void slirp_set_dhcp_dns_proxy(PNATState pData, bool fDNSProxy);
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | #if defined(RT_OS_WINDOWS)
|
---|
70 |
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * ICMP handle state change
|
---|
74 | */
|
---|
75 | # define VBOX_ICMP_EVENT_INDEX 0
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * This event is for
|
---|
79 | * - slirp_input
|
---|
80 | * - slirp_link_up
|
---|
81 | * - slirp_link_down
|
---|
82 | * - wakeup
|
---|
83 | */
|
---|
84 | # define VBOX_WAKEUP_EVENT_INDEX 1
|
---|
85 |
|
---|
86 | /*
|
---|
87 | * UDP/TCP socket state change (socket ready to receive, to send, ...)
|
---|
88 | */
|
---|
89 | # define VBOX_SOCKET_EVENT_INDEX 2
|
---|
90 |
|
---|
91 | /*
|
---|
92 | * The number of events for WSAWaitForMultipleEvents().
|
---|
93 | */
|
---|
94 | # define VBOX_EVENT_COUNT 3
|
---|
95 |
|
---|
96 | HANDLE *slirp_get_events(PNATState pData);
|
---|
97 | void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index);
|
---|
98 | #endif /* RT_OS_WINDOWS */
|
---|
99 |
|
---|
100 | #ifdef VBOX_WITH_SLIRP_MT
|
---|
101 | void slirp_process_queue(PNATState pData);
|
---|
102 | void *slirp_get_queue(PNATState pData);
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | /*
|
---|
106 | * Returns the timeout.
|
---|
107 | */
|
---|
108 | unsigned int slirp_get_timeout_ms(PNATState pData);
|
---|
109 |
|
---|
110 | # ifndef RT_OS_WINDOWS
|
---|
111 | /*
|
---|
112 | * Returns the number of sockets.
|
---|
113 | */
|
---|
114 | int slirp_get_nsock(PNATState pData);
|
---|
115 | # endif
|
---|
116 |
|
---|
117 | #ifdef __cplusplus
|
---|
118 | }
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | #endif
|
---|