VirtualBox

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

Last change on this file since 30421 was 30421, checked in by vboxsync, 14 years ago

NAT: small performance enhancement (allocate intermediate buffer only if it's required).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: libslirp.h 30421 2010-06-24 11:59:49Z vboxsync $ */
2/** @file
3 * NAT - slirp interface.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef _LIBSLIRP_H
19#define _LIBSLIRP_H
20
21#ifdef RT_OS_WINDOWS
22# include <winsock2.h>
23# ifdef __cplusplus
24extern "C" {
25# endif
26int inet_aton(const char *cp, struct in_addr *ia);
27# ifdef __cplusplus
28}
29# endif
30#else
31# ifdef RT_OS_OS2 /* temporary workaround, see ticket #127 */
32# include <sys/time.h>
33# endif
34# include <sys/select.h>
35# include <poll.h>
36# include <arpa/inet.h>
37#endif
38
39#include <VBox/types.h>
40
41typedef struct NATState *PNATState;
42struct mbuf;
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48int slirp_init(PNATState *, uint32_t, uint32_t, bool, bool, int, void *);
49void slirp_register_statistics(PNATState pData, PPDMDRVINS pDrvIns);
50void slirp_deregister_statistics(PNATState pData, PPDMDRVINS pDrvIns);
51void slirp_term(PNATState);
52void slirp_link_up(PNATState);
53void slirp_link_down(PNATState);
54
55#if defined(RT_OS_WINDOWS)
56void slirp_select_fill(PNATState pData, int *pndfs);
57
58void slirp_select_poll(PNATState pData, int fTimeout, int fIcmp);
59#else /* RT_OS_WINDOWS */
60void slirp_select_fill(PNATState pData, int *pnfds, struct pollfd *polls);
61void slirp_select_poll(PNATState pData, struct pollfd *polls, int ndfs);
62#endif /* !RT_OS_WINDOWS */
63
64void slirp_input(PNATState pData, struct mbuf *m, size_t cbBuf);
65void slirp_set_ethaddr_and_activate_port_forwarding(PNATState pData, const uint8_t *ethaddr, uint32_t GuestIP);
66
67/* you must provide the following functions: */
68void slirp_arm_fast_timer(void *pvUser);
69int slirp_can_output(void * pvUser);
70void slirp_output(void * pvUser, struct mbuf *m, const uint8_t *pkt, int pkt_len);
71void slirp_urg_output(void *pvUser, struct mbuf *, const uint8_t *pu8Buf, int cb);
72void slirp_post_sent(PNATState pData, void *pvArg);
73
74int slirp_redir(PNATState pData, int is_udp, struct in_addr host_addr,
75 int host_port, struct in_addr guest_addr,
76 int guest_port, const uint8_t *);
77int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
78 int guest_port);
79
80void slirp_set_dhcp_TFTP_prefix(PNATState pData, const char *tftpPrefix);
81void slirp_set_dhcp_TFTP_bootfile(PNATState pData, const char *bootFile);
82void slirp_set_dhcp_next_server(PNATState pData, const char *nextServer);
83void slirp_set_dhcp_dns_proxy(PNATState pData, bool fDNSProxy);
84void slirp_set_rcvbuf(PNATState pData, int kilobytes);
85void slirp_set_sndbuf(PNATState pData, int kilobytes);
86void slirp_set_tcp_rcvspace(PNATState pData, int kilobytes);
87void slirp_set_tcp_sndspace(PNATState pData, int kilobytes);
88
89int slirp_set_binding_address(PNATState, char *addr);
90void slirp_set_mtu(PNATState, int);
91
92#if defined(RT_OS_WINDOWS)
93
94
95/*
96 * ICMP handle state change
97 */
98# define VBOX_ICMP_EVENT_INDEX 0
99
100/**
101 * This event is for
102 * - slirp_input
103 * - slirp_link_up
104 * - slirp_link_down
105 * - wakeup
106 */
107# define VBOX_WAKEUP_EVENT_INDEX 1
108
109/*
110 * UDP/TCP socket state change (socket ready to receive, to send, ...)
111 */
112# define VBOX_SOCKET_EVENT_INDEX 2
113
114/*
115 * The number of events for WSAWaitForMultipleEvents().
116 */
117# define VBOX_EVENT_COUNT 3
118
119HANDLE *slirp_get_events(PNATState pData);
120void slirp_register_external_event(PNATState pData, HANDLE hEvent, int index);
121#endif /* RT_OS_WINDOWS */
122
123#ifdef VBOX_WITH_SLIRP_MT
124void slirp_process_queue(PNATState pData);
125void *slirp_get_queue(PNATState pData);
126#endif
127
128struct mbuf *slirp_ext_m_get(PNATState pData, size_t cbMin, void **ppvBuf, size_t *pcbBuf);
129void slirp_ext_m_free(PNATState pData, struct mbuf *, uint8_t *pu8Buf);
130
131/*
132 * Returns the timeout.
133 */
134unsigned int slirp_get_timeout_ms(PNATState pData);
135
136# ifndef RT_OS_WINDOWS
137/*
138 * Returns the number of sockets.
139 */
140int slirp_get_nsock(PNATState pData);
141# endif
142
143#ifdef __cplusplus
144}
145#endif
146
147#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