VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/libslirp.h@ 17439

Last change on this file since 17439 was 17436, checked in by vboxsync, 16 years ago

NAT: added extradata options to control DHCP forcing use external TFTP server and DNS proxy

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
1#ifndef _LIBSLIRP_H
2#define _LIBSLIRP_H
3
4#ifdef RT_OS_WINDOWS
5# include <winsock2.h>
6# ifdef __cplusplus
7extern "C" {
8# endif
9int 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
24typedef struct NATState *PNATState;
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30int slirp_init(PNATState *, const char *, uint32_t, bool, void *);
31void slirp_register_timers(PNATState pData, PPDMDRVINS pDrvIns);
32void slirp_term(PNATState);
33void slirp_link_up(PNATState);
34void slirp_link_down(PNATState);
35
36#if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC)
37# if defined(RT_OS_WINDOWS)
38void slirp_select_fill(PNATState pData, int *pndfs);
39
40void slirp_select_poll(PNATState pData, int fTimeout, int fIcmp);
41# else /* RT_OS_WINDOWS */
42void slirp_select_fill(PNATState pData, int *pnfds, struct pollfd *polls);
43void slirp_select_poll(PNATState pData, struct pollfd *polls, int ndfs);
44# endif /* !RT_OS_WINDOWS */
45#else /* VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */
46void slirp_select_fill(PNATState pData, int *pnfds,
47 fd_set *readfds, fd_set *writefds, fd_set *xfds);
48
49void slirp_select_poll(PNATState pData, int *pnfds,
50 fd_set *readfds, fd_set *writefds, fd_set *xfds);
51#endif /* !VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */
52
53void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);
54void slirp_set_ethaddr(PNATState pData, const uint8_t *ethaddr);
55
56/* you must provide the following functions: */
57int slirp_can_output(void * pvUser);
58#ifdef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC
59void slirp_output(void * pvUser, void *pvArg, const uint8_t *pkt, int pkt_len);
60void slirp_post_sent(PNATState pData, void *pvArg);
61#else
62void slirp_output(void * pvUser, const uint8_t *pkt, int pkt_len);
63#endif
64
65int slirp_redir(PNATState pData, int is_udp, int host_port,
66 struct in_addr guest_addr, int guest_port);
67int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
68 int guest_port);
69
70void slirp_set_dhcp_TFTP_prefix(PNATState pData, const char *tftpPrefix);
71void slirp_set_dhcp_TFTP_bootfile(PNATState pData, const char *bootFile);
72void slirp_set_dhcp_next_server(PNATState pData, const char *nextServer);
73#ifdef VBOX_WITH_SLIRP_DNS_PROXY
74void slirp_set_dhcp_dns_proxy(PNATState pData, bool fDNSProxy);
75#endif
76#if defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
77
78
79/*
80 * ICMP handle state change
81 */
82# define VBOX_ICMP_EVENT_INDEX 0
83
84/**
85 * This event is for
86 * - slirp_input
87 * - slirp_link_up
88 * - slirp_link_down
89 * - wakeup
90 */
91# define VBOX_WAKEUP_EVENT_INDEX 1
92
93/*
94 * UDP/TCP socket state change (socket ready to receive, to send, ...)
95 */
96# define VBOX_SOCKET_EVENT_INDEX 2
97
98/*
99 * The number of events for WSAWaitForMultipleEvents().
100 */
101# define VBOX_EVENT_COUNT 3
102
103HANDLE *slirp_get_events(PNATState pData);
104void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index);
105#endif
106#ifdef VBOX_WITH_SLIRP_MT
107void slirp_process_queue(PNATState pData);
108void *slirp_get_queue(PNATState pData);
109#endif
110
111/*
112 * Returns the timeout.
113 */
114unsigned int slirp_get_timeout_ms(PNATState pData);
115
116# ifndef RT_OS_WINDOWS
117/*
118 * Returns the number of sockets.
119 */
120int slirp_get_nsock(PNATState pData);
121# endif
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette