VirtualBox

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

Last change on this file since 7795 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

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