VirtualBox

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

Last change on this file since 27848 was 27848, checked in by vboxsync, 15 years ago

NAT service: sync with changes in DrvNAT. NAT service is compilable and usable now.

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