slirp_state.h revision b08ef9b004264c5334b65bfe8e1af14da731db92
/** @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_
#ifdef VBOX_WITH_SYNC_SLIRP
#include <iprt/semaphore.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;
} BOOTPClient;
/** TFTP session entry. */
struct tftp_session {
int in_use;
unsigned char filename[TFTP_FILENAME_MAX];
int timestamp;
};
/** 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;
#ifdef VBOX_WITH_SYNC_SLIRP
/* mutex for accessing if_queued flag which used in if_start function and
* and understanding that we need call if_start to send anything we have to
* send.
*/
#endif
int if_thresh;
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* fast queue (mbufs) from this queue are processed in first order
*/
#endif
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* batch queue mbufs from this queue used if no mbufs on fast queue
* and next_m doesn't point on mbuf scheduled to be processesed
*/
#endif
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* from pointer next_m, used for pointing next mbuf to be processed
* it readed if no messages are not in fast queue, usually it assigned with
* mbuf from batch queue
*/
#endif
/* Stuff from icmp.c */
struct icmpstat_t icmpstat;
/* Stuff from ip_input.c */
/* Stuff from mbuf.c */
int mbuf_alloced, mbuf_max;
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* mbuf_alloced_mutex used to prevent concurent access to mbuf_alloced counter
* which ticks on every allocation and readed to check it against limits
*/
#endif
int msize;
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* m_freelist_mutex and m_usedlist_mutex are used to prevent concurrent access and modifications
* of corresponded queues controlling allocation/utilization of mbufs
*/
#endif
/* Stuff from slirp.c */
void *pvUser;
bool do_slowtimo;
bool link_up;
struct in_addr alias_addr;
struct in_addr special_addr;
struct in_addr loopback_addr;
char slirp_hostname[33];
bool fPassDomain;
const char *pszDomain;
/* Stuff from tcp_input.c */
struct socket *tcp_last_so;
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* tcp_last_so_mutex used for control access to tcp_last_so pointer
*/
/*
* tcb_mutex used for control access to tcb queue of sockets
* servising TCP connections
*/
#endif
#if ARCH_BITS == 64
/* Stuff from tcp_subr.c */
void *apvHash[16384];
#endif
/* Stuff from tcp_timer.c */
/* Stuff from tftp.c */
const char *tftp_prefix;
/* Stuff from udp.c */
struct socket *udp_last_so;
#ifdef VBOX_WITH_SYNC_SLIRP
/*
* udb_mutex used in similar to tcb_mutex way, but for handling udp connections
*/
/*
* used for access udp_last_so global pointer avoiding overusing of udb_mutex.
*/
#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
#if SIZEOF_CHAR_P != 4
/** Hash the pointer, inserting it if need be. */
{
return i;
}
/** Lookup the hash value. */
{
void *pv;
return pv;
}
#endif
#endif /* !_slirp_state_h_ */