slirp_state.h revision 54fe561ef34bc91e6d39efe592aa5fc2d31a0cbd
/** @file
* NAT state/configuration.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef _slirp_state_h_
#define _slirp_state_h_
#include "ip_icmp.h"
#ifdef VBOX_WITH_SLIRP_DNS_PROXY
# include "dnsproxy/dnsproxy.h"
#endif
/** Number of DHCP clients supported by NAT. */
#define NB_ADDR 16
/** Where to start DHCP IP number allocation. */
#define START_ADDR 15
/** DHCP Lease time. */
/** Entry in the table of known DHCP clients. */
typedef struct
{
bool allocated;
#endif
} BOOTPClient;
/** TFTP session entry. */
struct tftp_session
{
int in_use;
unsigned char filename[TFTP_FILENAME_MAX];
int timestamp;
};
#ifdef VBOX_WITH_MULTI_DNS
struct dns_domain_entry
{
char *dd_pszDomain;
};
struct dns_entry
{
};
#endif
/** Main state/configuration structure for slirp NAT. */
typedef struct NATState
{
/* Stuff from boot.c */
const char *bootp_filename;
/* Stuff from if.c */
int if_comp;
int if_maxlinkhdr;
int if_queued;
int if_thresh;
/* Stuff from icmp.c */
struct icmpstat_t icmpstat;
/* Stuff from ip_input.c */
int maxnipq; /* Administrative limit on # of reass queues*/
int maxfragsperpacket; /* Maximum number of IPv4 fragments allowed per packet */
int nipq; /* total number of reass queues */
/* Stuff from mbuf.c */
int mbuf_alloced, mbuf_max;
int msize;
/* Stuff from slirp.c */
void *pvUser;
bool do_slowtimo;
bool link_up;
struct in_addr alias_addr;
struct in_addr special_addr;
#ifdef VBOX_WITH_SLIRP_MT
#endif
#ifndef VBOX_WITH_MULTI_DNS
#else
# ifdef RT_OS_WINDOWS
# endif
struct dns_list_head dns_list_head;
#endif
struct in_addr tftp_server;
struct in_addr loopback_addr;
#ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
#else
#endif
char slirp_hostname[33];
bool fPassDomain;
#ifndef VBOX_WITH_MULTI_DNS
const char *pszDomain;
#endif
/* Stuff from tcp_input.c */
#ifdef VBOX_WITH_SLIRP_MT
#endif
struct socket *tcp_last_so;
/* Stuff from tcp_timer.c */
int tcp_reass_qsize;
int tcp_reass_maxqlen;
int tcp_reass_maxseg;
int tcp_reass_overflows;
/* Stuff from tftp.c */
const char *tftp_prefix;
/* Stuff from udp.c */
#ifdef VBOX_WITH_SLIRP_MT
#endif
struct socket *udp_last_so;
struct socket icmp_socket;
struct icmp_storage icmp_msg_head;
# ifndef RT_OS_WINDOWS
/* counter of sockets needed for allocation enough room to
*
* operation on socket queue (tcb, udb)
*/
int nsock;
# else
# define NSOCK_INC() do {} while (0)
# define NSOCK_DEC() do {} while (0)
# endif
# ifdef RT_OS_WINDOWS
void *pvIcmpBuffer;
/* Accordin MSDN specification IcmpParseReplies
* function should be detected in runtime
*/
long (WINAPI * pfIcmpParseReplies)(void *, long);
# endif
#if defined(RT_OS_WINDOWS)
#endif
#ifdef VBOX_WITH_SLIRP_DNS_PROXY
/* from dnsproxy/dnsproxy.h*/
unsigned int authoritative_port;
unsigned int authoritative_timeout;
unsigned int recursive_port;
unsigned int recursive_timeout;
unsigned int stats_timeout;
unsigned int port;
unsigned long active_queries;
unsigned long all_queries;
unsigned long authoritative_queries;
unsigned long recursive_queries;
unsigned long removed_queries;
unsigned long dropped_queries;
unsigned long answered_queries;
unsigned long dropped_answers;
unsigned long late_answers;
unsigned long hash_collisions;
/*dnsproxy/dnsproxy.c*/
unsigned short queryid;
struct sockaddr_in authoritative_addr;
struct sockaddr_in recursive_addr;
int sock_query;
int sock_answer;
#define HASHSIZE 10
/* this field control behaviour of DHCP server */
bool use_dns_proxy;
#endif
#ifdef VBOX_WITH_SLIRP_ALIAS
#endif
} NATState;
/** Default IP time to live. */
/** Number of permanent buffers in mbuf. */
#define mbuf_thresh 30
/** Use a fixed time before sending keepalive. */
#define tcp_keepidle TCPTV_KEEP_IDLE
/** Use a fixed interval between keepalive. */
#define tcp_keepintvl TCPTV_KEEPINTVL
/** Maximum idle time before timing out a connection. */
/** Default TCP socket options. */
#define so_options DO_KEEPALIVE
/** Default TCP MSS value. */
#define tcp_mssdflt TCP_MSS
/** Default TCP round trip time. */
/** Enable RFC1323 performance enhancements.
* @todo check if it really works, it was turned off before. */
#define tcp_do_rfc1323 1
/** TCP receive buffer size. */
#define tcp_rcvspace TCP_RCVSPACE
/** TCP receive buffer size. */
#define tcp_sndspace TCP_SNDSPACE
/* TCP duplicate ACK retransmit threshold. */
#define tcprexmtthresh 3
#ifndef VBOX_SLIRP_ALIAS
#endif
#define queue_tcp_label tcb
#define queue_udp_label udb
#define __X(x) x
#define _str(x) #x
#ifdef VBOX_WITH_SLIRP_MT
# define QSOCKET_LOCK(queue) \
do { \
int rc; \
/* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \
AssertReleaseRC(rc); \
} while (0)
# define QSOCKET_UNLOCK(queue) \
do { \
int rc; \
AssertReleaseRC(rc); \
} while (0)
# define QSOCKET_LOCK_CREATE(queue) \
do { \
int rc; \
AssertReleaseRC(rc); \
} while (0)
# define QSOCKET_LOCK_DESTROY(queue) \
do { \
AssertReleaseRC(rc); \
} while (0)
for(;;) \
{ \
{ \
break; \
} \
/* @todo replace queue parameter with macrodinition */
/* _mt_nounlock - user should lock so_next before calling CONTINUE_NO_UNLOCK */
SOCKET_UNLOCK(so); \
{ \
SOCKET_LOCK((sonext)); \
} \
else \
{ \
break; \
} \
continue; \
do { \
int rc; \
AssertReleaseRC(rc); \
{ \
SOCKET_UNLOCK(so); \
AssertReleaseRC(rc); \
SOCKET_LOCK(so); \
} \
else \
AssertReleaseRC(rc); \
} while(0)
do { \
int rc; \
AssertReleaseRC(rc); \
AssertReleaseRC(rc); \
} while(0)
do { \
int rc; \
AssertReleaseRC(rc); \
{ \
SOCKET_UNLOCK(so); \
AssertReleaseRC(rc); \
SOCKET_LOCK(so); \
} \
else \
AssertReleaseRC(rc); \
} while(0)
do { \
int rc; \
AssertReleaseRC(rc); \
{ \
SOCKET_UNLOCK(so); \
AssertReleaseRC(rc); \
SOCKET_LOCK(so); \
} \
else \
AssertReleaseRC(rc); \
} while(0)
do { \
int rc; \
AssertReleaseRC(rc); \
{ \
SOCKET_UNLOCK(so); \
SOCKET_LOCK(so); \
} \
else \
AssertReleaseRC(rc); \
} while(0)
do { \
int rc; \
AssertReleaseRC(rc); \
{ \
SOCKET_UNLOCK(so); \
AssertReleaseRC(rc); \
SOCKET_LOCK(so); \
} \
else \
AssertReleaseRC(rc); \
} while(0)
do { \
int rc; \
AssertReleaseRC(rc); \
{ \
SOCKET_UNLOCK(so); \
AssertReleaseRC(rc); \
} \
else \
AssertReleaseRC(rc); \
} while(0)
do { \
/* { */ \
{ \
SOCKET_UNLOCK(sonxt); \
break; /*so is locked*/ \
} \
} \
} \
} while (0)
#else /* !VBOX_WITH_SLIRP_MT */
# define QSOCKET_LOCK(queue) do {} while (0)
# define QSOCKET_UNLOCK(queue) do {} while (0)
# define QSOCKET_LOCK_CREATE(queue) do {} while (0)
# define QSOCKET_LOCK_DESTROY(queue) do {} while (0)
{ \
# define CONTINUE_NO_UNLOCK(label) continue
do { \
} while(0)
do { \
} while(0)
do { \
} while (0)
#endif /* !VBOX_WITH_SLIRP_MT */
#ifdef VBOX_WITH_SLIRP_DNS_PROXY
/* dnsproxy/dnsproxy.c */
/* dnsproxy/dnsproxy.c */
#endif
#ifdef VBOX_WITH_SLIRP_ALIAS
#endif
#endif /* !_slirp_state_h_ */