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 <arpa/inet.h>
|
---|
19 | #endif
|
---|
20 |
|
---|
21 | #include <VBox/types.h>
|
---|
22 |
|
---|
23 | typedef struct NATState *PNATState;
|
---|
24 |
|
---|
25 | #ifdef __cplusplus
|
---|
26 | extern "C" {
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | int slirp_init(PNATState *, const char *, uint32_t, bool, const char *, const char *, void *);
|
---|
30 | void slirp_register_timers(PNATState pData, PPDMDRVINS pDrvIns);
|
---|
31 | void slirp_term(PNATState);
|
---|
32 | void slirp_link_up(PNATState);
|
---|
33 | void slirp_link_down(PNATState);
|
---|
34 |
|
---|
35 | void slirp_select_fill(PNATState pData, int *pnfds,
|
---|
36 | fd_set *readfds, fd_set *writefds, fd_set *xfds);
|
---|
37 |
|
---|
38 | #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC)
|
---|
39 | void slirp_select_poll(PNATState pData, int fTimeout, int fIcmp);
|
---|
40 | #else
|
---|
41 | void slirp_select_poll(PNATState pData, fd_set *readfds, fd_set *writefds, fd_set *xfds);
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);
|
---|
45 | void slirp_set_ethaddr(PNATState pData, const uint8_t *ethaddr);
|
---|
46 |
|
---|
47 | /* you must provide the following functions: */
|
---|
48 | int slirp_can_output(void * pvUser);
|
---|
49 | void slirp_output(void * pvUser, const uint8_t *pkt, int pkt_len);
|
---|
50 |
|
---|
51 | int slirp_redir(PNATState pData, int is_udp, int host_port,
|
---|
52 | struct in_addr guest_addr, int guest_port);
|
---|
53 | int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
|
---|
54 | int guest_port);
|
---|
55 |
|
---|
56 | #if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
|
---|
57 |
|
---|
58 | # ifdef VBOX_WITH_SLIRP_ICMP
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * ICMP handle state change
|
---|
62 | */
|
---|
63 | #define VBOX_ICMP_EVENT_INDEX 0
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * This event is for
|
---|
67 | * - slirp_input
|
---|
68 | * - slirp_link_up
|
---|
69 | * - slirp_link_down
|
---|
70 | * - wakeup
|
---|
71 | */
|
---|
72 | # define VBOX_WAKEUP_EVENT_INDEX 1
|
---|
73 |
|
---|
74 | /*
|
---|
75 | * UDP/TCP socket state change (socket ready to receive, to send, ...)
|
---|
76 | */
|
---|
77 | # define VBOX_SOCKET_EVENT_INDEX 2
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * The number of events for WSAWaitForMultipleEvents().
|
---|
81 | */
|
---|
82 | # define VBOX_EVENT_COUNT 3
|
---|
83 |
|
---|
84 | # else
|
---|
85 |
|
---|
86 | # define VBOX_WAKEUP_EVENT_INDEX 0
|
---|
87 | # define VBOX_SOCKET_EVENT_INDEX 1
|
---|
88 | # define VBOX_EVENT_COUNT 2
|
---|
89 |
|
---|
90 | # endif
|
---|
91 |
|
---|
92 | HANDLE *slirp_get_events(PNATState pData);
|
---|
93 | void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index);
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * Return the timeout.
|
---|
98 | */
|
---|
99 | unsigned int slirp_get_timeout_ms(PNATState pData);
|
---|
100 |
|
---|
101 | #ifdef __cplusplus
|
---|
102 | }
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | #endif
|
---|