VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/slirp_state.h@ 14119

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

per polling allocation of event array was replaced by on init allocation
sending event registration moved in initialization part

  • Property svn:eol-style set to native
File size: 6.5 KB
Line 
1/** @file
2 * NAT state/configuration.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
17 * Clara, CA 95054 USA or visit http://www.sun.com if you need
18 * additional information or have any questions.
19 */
20
21#ifndef _slirp_state_h_
22#define _slirp_state_h_
23
24/** Number of DHCP clients supported by NAT. */
25#define NB_ADDR 16
26
27/** Where to start DHCP IP number allocation. */
28#define START_ADDR 15
29
30/** DHCP Lease time. */
31#define LEASE_TIME (24 * 3600)
32
33/** Entry in the table of known DHCP clients. */
34typedef struct {
35 bool allocated;
36 uint8_t macaddr[6];
37} BOOTPClient;
38
39
40/** TFTP session entry. */
41struct tftp_session {
42 int in_use;
43 unsigned char filename[TFTP_FILENAME_MAX];
44
45 struct in_addr client_ip;
46 u_int16_t client_port;
47
48 int timestamp;
49};
50
51
52/** Main state/configuration structure for slirp NAT. */
53typedef struct NATState
54{
55 /* Stuff from boot.c */
56 BOOTPClient bootp_clients[NB_ADDR];
57 const char *bootp_filename;
58 /* Stuff from if.c */
59 int if_mtu, if_mru;
60 int if_comp;
61 int if_maxlinkhdr;
62 int if_queued;
63 int if_thresh;
64 struct mbuf if_fastq;
65 struct mbuf if_batchq;
66 struct mbuf *next_m;
67 /* Stuff from icmp.c */
68 struct icmpstat_t icmpstat;
69 /* Stuff from ip_input.c */
70 struct ipstat_t ipstat;
71 struct ipq_t ipq;
72 uint16_t ip_currid;
73 /* Stuff from mbuf.c */
74 int mbuf_alloced, mbuf_max;
75 int msize;
76 struct mbuf m_freelist, m_usedlist;
77 /* Stuff from slirp.c */
78 void *pvUser;
79 uint32_t curtime;
80 uint32_t time_fasttimo;
81 uint32_t last_slowtimo;
82 bool do_slowtimo;
83 bool link_up;
84 struct timeval tt;
85 struct in_addr our_addr;
86 struct in_addr alias_addr;
87 struct in_addr special_addr;
88 struct in_addr dns_addr;
89 struct in_addr loopback_addr;
90 uint32_t netmask;
91 uint8_t client_ethaddr[6];
92 struct ex_list *exec_list;
93 char slirp_hostname[33];
94 bool fPassDomain;
95 const char *pszDomain;
96 /* Stuff from tcp_input.c */
97 struct socket tcb;
98 struct socket *tcp_last_so;
99 tcp_seq tcp_iss;
100#if ARCH_BITS == 64
101 /* Stuff from tcp_subr.c */
102 void *apvHash[16384];
103 uint32_t cpvHashUsed;
104 uint32_t cpvHashCollisions;
105 uint64_t cpvHashInserts;
106 uint64_t cpvHashDone;
107#endif
108 /* Stuff from tcp_timer.c */
109 struct tcpstat_t tcpstat;
110 uint32_t tcp_now;
111 /* Stuff from tftp.c */
112 struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
113 const char *tftp_prefix;
114 /* Stuff from udp.c */
115 struct udpstat_t udpstat;
116 struct socket udb;
117 struct socket *udp_last_so;
118#if defined(VBOX_WITH_SIMPLEFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS)
119 int cMaxEvent;
120 HANDLE *phEvents;
121#endif
122} NATState;
123
124
125/** Default IP time to live. */
126#define ip_defttl IPDEFTTL
127
128/** Number of permanent buffers in mbuf. */
129#define mbuf_thresh 30
130
131/** Use a fixed time before sending keepalive. */
132#define tcp_keepidle TCPTV_KEEP_IDLE
133
134/** Use a fixed interval between keepalive. */
135#define tcp_keepintvl TCPTV_KEEPINTVL
136
137/** Maximum idle time before timing out a connection. */
138#define tcp_maxidle (TCPTV_KEEPCNT * tcp_keepintvl)
139
140/** Default TCP socket options. */
141#define so_options DO_KEEPALIVE
142
143/** Default TCP MSS value. */
144#define tcp_mssdflt TCP_MSS
145
146/** Default TCP round trip time. */
147#define tcp_rttdflt (TCPTV_SRTTDFLT / PR_SLOWHZ)
148
149/** Enable RFC1323 performance enhancements.
150 * @todo check if it really works, it was turned off before. */
151#define tcp_do_rfc1323 1
152
153/** TCP receive buffer size. */
154#define tcp_rcvspace TCP_RCVSPACE
155
156/** TCP receive buffer size. */
157#define tcp_sndspace TCP_SNDSPACE
158
159/* TCP duplicate ACK retransmit threshold. */
160#define tcprexmtthresh 3
161
162
163#define bootp_filename pData->bootp_filename
164#define bootp_clients pData->bootp_clients
165
166#define if_mtu pData->if_mtu
167#define if_mru pData->if_mru
168#define if_comp pData->if_comp
169#define if_maxlinkhdr pData->if_maxlinkhdr
170#define if_queued pData->if_queued
171#define if_thresh pData->if_thresh
172#define if_fastq pData->if_fastq
173#define if_batchq pData->if_batchq
174#define next_m pData->next_m
175
176#define icmpstat pData->icmpstat
177
178#define ipstat pData->ipstat
179#define ipq pData->ipq
180#define ip_currid pData->ip_currid
181
182#define mbuf_alloced pData->mbuf_alloced
183#define mbuf_max pData->mbuf_max
184#define msize pData->msize
185#define m_freelist pData->m_freelist
186#define m_usedlist pData->m_usedlist
187
188#define curtime pData->curtime
189#define time_fasttimo pData->time_fasttimo
190#define last_slowtimo pData->last_slowtimo
191#define do_slowtimo pData->do_slowtimo
192#define link_up pData->link_up
193#define cUsers pData->cUsers
194#define tt pData->tt
195#define our_addr pData->our_addr
196#define alias_addr pData->alias_addr
197#define special_addr pData->special_addr
198#define dns_addr pData->dns_addr
199#define loopback_addr pData->loopback_addr
200#define client_ethaddr pData->client_ethaddr
201#define exec_list pData->exec_list
202#define slirp_hostname pData->slirp_hostname
203
204#define tcb pData->tcb
205#define tcp_last_so pData->tcp_last_so
206#define tcp_iss pData->tcp_iss
207
208#define tcpstat pData->tcpstat
209#define tcp_now pData->tcp_now
210
211#define tftp_sessions pData->tftp_sessions
212#define tftp_prefix pData->tftp_prefix
213
214#define udpstat pData->udpstat
215#define udb pData->udb
216#define udp_last_so pData->udp_last_so
217
218
219#if SIZEOF_CHAR_P != 4
220 extern void VBoxU32PtrDone(PNATState pData, void *pv, uint32_t iHint);
221 extern uint32_t VBoxU32PtrHashSlow(PNATState pData, void *pv);
222
223 /** Hash the pointer, inserting it if need be. */
224 DECLINLINE(uint32_t) VBoxU32PtrHash(PNATState pData, void *pv)
225 {
226 uint32_t i = ((uintptr_t)pv >> 3) % RT_ELEMENTS(pData->apvHash);
227 if (RT_LIKELY(pData->apvHash[i] == pv && pv))
228 return i;
229 return VBoxU32PtrHashSlow(pData, pv);
230 }
231 /** Lookup the hash value. */
232 DECLINLINE(void *) VBoxU32PtrLookup(PNATState pData, uint32_t i)
233 {
234 void *pv;
235 Assert(i < RT_ELEMENTS(pData->apvHash));
236 pv = pData->apvHash[i];
237 Assert(pv || !i);
238 return pv;
239 }
240#endif
241
242
243#endif /* !_slirp_state_h_ */
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