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, bool, void *);
|
---|
32 | #else
|
---|
33 | int slirp_init(PNATState *, uint32_t, uint32_t, bool, void *);
|
---|
34 | #endif
|
---|
35 | void slirp_register_statistics(PNATState pData, PPDMDRVINS pDrvIns);
|
---|
36 | void slirp_deregister_statistics(PNATState pData, PPDMDRVINS pDrvIns);
|
---|
37 | void slirp_term(PNATState);
|
---|
38 | void slirp_link_up(PNATState);
|
---|
39 | void slirp_link_down(PNATState);
|
---|
40 |
|
---|
41 | #if defined(RT_OS_WINDOWS)
|
---|
42 | void slirp_select_fill(PNATState pData, int *pndfs);
|
---|
43 |
|
---|
44 | void slirp_select_poll(PNATState pData, int fTimeout, int fIcmp);
|
---|
45 | #else /* RT_OS_WINDOWS */
|
---|
46 | void slirp_select_fill(PNATState pData, int *pnfds, struct pollfd *polls);
|
---|
47 | void slirp_select_poll(PNATState pData, struct pollfd *polls, int ndfs);
|
---|
48 | #endif /* !RT_OS_WINDOWS */
|
---|
49 |
|
---|
50 | #ifdef VBOX_WITH_SLIRP_BSD_MBUF
|
---|
51 | void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);
|
---|
52 | #else
|
---|
53 | void slirp_input(PNATState pData, void *pvData);
|
---|
54 | #endif
|
---|
55 | void slirp_set_ethaddr_and_activate_port_forwarding(PNATState pData, const uint8_t *ethaddr, uint32_t GuestIP);
|
---|
56 |
|
---|
57 | /* you must provide the following functions: */
|
---|
58 | void slirp_arm_fast_timer(void *pvUser);
|
---|
59 | void slirp_arm_slow_timer(void *pvUser);
|
---|
60 | int slirp_can_output(void * pvUser);
|
---|
61 | void slirp_output(void * pvUser, void *pvArg, const uint8_t *pkt, int pkt_len);
|
---|
62 | void slirp_urg_output(void *pvUser, void *pvArg, const uint8_t *pu8Buf, int cb);
|
---|
63 | void slirp_post_sent(PNATState pData, void *pvArg);
|
---|
64 |
|
---|
65 | int slirp_redir(PNATState pData, int is_udp, struct in_addr host_addr,
|
---|
66 | int host_port, struct in_addr guest_addr,
|
---|
67 | int guest_port, const uint8_t *);
|
---|
68 | int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
|
---|
69 | int guest_port);
|
---|
70 |
|
---|
71 | void slirp_set_dhcp_TFTP_prefix(PNATState pData, const char *tftpPrefix);
|
---|
72 | void slirp_set_dhcp_TFTP_bootfile(PNATState pData, const char *bootFile);
|
---|
73 | void slirp_set_dhcp_next_server(PNATState pData, const char *nextServer);
|
---|
74 | void slirp_set_dhcp_dns_proxy(PNATState pData, bool fDNSProxy);
|
---|
75 | void slirp_set_rcvbuf(PNATState pData, int kilobytes);
|
---|
76 | void slirp_set_sndbuf(PNATState pData, int kilobytes);
|
---|
77 | void slirp_set_tcp_rcvspace(PNATState pData, int kilobytes);
|
---|
78 | void slirp_set_tcp_sndspace(PNATState pData, int kilobytes);
|
---|
79 |
|
---|
80 | int slirp_set_binding_address(PNATState, char *addr);
|
---|
81 | #ifdef VBOX_WITH_SLIRP_BSD_MBUF
|
---|
82 | void slirp_set_mtu(PNATState, int);
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | #if defined(RT_OS_WINDOWS)
|
---|
86 |
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * ICMP handle state change
|
---|
90 | */
|
---|
91 | # define VBOX_ICMP_EVENT_INDEX 0
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * This event is for
|
---|
95 | * - slirp_input
|
---|
96 | * - slirp_link_up
|
---|
97 | * - slirp_link_down
|
---|
98 | * - wakeup
|
---|
99 | */
|
---|
100 | # define VBOX_WAKEUP_EVENT_INDEX 1
|
---|
101 |
|
---|
102 | /*
|
---|
103 | * UDP/TCP socket state change (socket ready to receive, to send, ...)
|
---|
104 | */
|
---|
105 | # define VBOX_SOCKET_EVENT_INDEX 2
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * The number of events for WSAWaitForMultipleEvents().
|
---|
109 | */
|
---|
110 | # define VBOX_EVENT_COUNT 3
|
---|
111 |
|
---|
112 | HANDLE *slirp_get_events(PNATState pData);
|
---|
113 | void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index);
|
---|
114 | #endif /* RT_OS_WINDOWS */
|
---|
115 |
|
---|
116 | #ifdef VBOX_WITH_SLIRP_MT
|
---|
117 | void slirp_process_queue(PNATState pData);
|
---|
118 | void *slirp_get_queue(PNATState pData);
|
---|
119 | #endif
|
---|
120 | #ifndef VBOX_WITH_SLIRP_BSD_MBUF
|
---|
121 | void *slirp_ext_m_get(PNATState pData);
|
---|
122 | void slirp_ext_m_free(PNATState pData, void *);
|
---|
123 | void slirp_ext_m_append(PNATState pData, void *, uint8_t *, size_t);
|
---|
124 | void slirp_push_recv_thread(void *pvUser);
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * Returns the timeout.
|
---|
129 | */
|
---|
130 | unsigned int slirp_get_timeout_ms(PNATState pData);
|
---|
131 |
|
---|
132 | # ifndef RT_OS_WINDOWS
|
---|
133 | /*
|
---|
134 | * Returns the number of sockets.
|
---|
135 | */
|
---|
136 | int slirp_get_nsock(PNATState pData);
|
---|
137 | # endif
|
---|
138 |
|
---|
139 | #ifdef __cplusplus
|
---|
140 | }
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | #endif
|
---|