VirtualBox

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

Last change on this file since 39766 was 39766, checked in by vboxsync, 13 years ago

NAT: host resolver can use user-defined mapping instead of host provided mappings.
o need to test alias resolving.
o code is disabled (VBOX_WITH_DNSMAPPING_IN_HOSTRESOLVER) need more testing.
o CFGM configuration:

# VBoxManage setextradata deb6-i386 "VBoxInternal/Devices/e1000/0/LUN#0/AttachedDriver/Config/HostResolverMappings/1/HostIP" 127.0.0.1
# VBoxManage setextradata deb6-i386 "VBoxInternal/Devices/e1000/0/LUN#0/AttachedDriver/Config/HostResolverMappings/1/HostName" update.microsoft.com

Host resolver should be on

# VBoxManage modifyvm deb6-i386 --natdnshostresolver1 on

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.8 KB
Line 
1/** @file
2 * NAT - slirp state/configuration.
3 */
4
5/*
6 * Copyright (C) 2006-2010 Oracle Corporation
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#include <iprt/req.h>
21#include <iprt/critsect.h>
22
23#define COUNTERS_INIT
24#include "counters.h"
25
26#include "ip_icmp.h"
27#include "dnsproxy/dnsproxy.h"
28
29
30/** Where to start DHCP IP number allocation. */
31#define START_ADDR 15
32
33/** DHCP Lease time. */
34#define LEASE_TIME (24 * 3600)
35
36/*
37 * ARP cache this is naive implementaion of ARP
38 * cache of mapping 4 byte IPv4 address to 6 byte
39 * ethernet one.
40 */
41struct arp_cache_entry
42{
43 uint32_t ip;
44 uint8_t ether[6];
45 LIST_ENTRY(arp_cache_entry) list;
46};
47LIST_HEAD(arp_cache_head, arp_cache_entry);
48
49/** TFTP session entry. */
50struct tftp_session
51{
52 int in_use;
53 unsigned char filename[TFTP_FILENAME_MAX];
54
55 struct in_addr client_ip;
56 u_int16_t client_port;
57
58 int timestamp;
59};
60
61struct dns_domain_entry
62{
63 char *dd_pszDomain;
64 LIST_ENTRY(dns_domain_entry) dd_list;
65};
66LIST_HEAD(dns_domain_list_head, dns_domain_entry);
67
68#ifdef VBOX_WITH_DNSMAPPING_IN_HOSTRESOLVER
69typedef struct DNSMAPPINGENTRY
70{
71 char *pszCName;
72 uint32_t u32IpAddress;
73 LIST_ENTRY(DNSMAPPINGENTRY) MapList;
74} DNSMAPPINGENTRY, *PDNSMAPPINGENTRY;
75typedef LIST_HEAD(DNSMAPPINGLISTHEAD, DNSMAPPINGENTRY) DNSMAPPINGLISTHEAD;
76#endif
77
78struct dns_entry
79{
80 struct in_addr de_addr;
81 TAILQ_ENTRY(dns_entry) de_list;
82};
83TAILQ_HEAD(dns_list_head, dns_entry);
84TAILQ_HEAD(if_queue, mbuf);
85
86struct port_forward_rule
87{
88 uint16_t proto;
89 uint16_t host_port;
90 uint16_t guest_port;
91 struct in_addr guest_addr;
92 struct in_addr bind_ip;
93 uint8_t mac_address[6]; /*need ETH_ALEN here */
94 int activated;
95 struct socket *so;
96 LIST_ENTRY(port_forward_rule) list;
97};
98LIST_HEAD(port_forward_rule_list, port_forward_rule);
99
100
101
102/* forward declaration */
103struct proto_handler;
104
105/** Main state/configuration structure for slirp NAT. */
106typedef struct NATState
107{
108#define PROFILE_COUNTER(name, dsc) STAMPROFILE Stat ## name
109#define COUNTING_COUNTER(name, dsc) STAMCOUNTER Stat ## name
110#include "counters.h"
111 /* Stuff from boot.c */
112 void *pbootp_clients;
113 const char *bootp_filename;
114 /* Stuff from if.c */
115 int if_mtu, if_mru;
116 int if_comp;
117 int if_maxlinkhdr;
118 int if_queued;
119 int if_thresh;
120 /* Stuff from icmp.c */
121 struct icmpstat_t icmpstat;
122 /* Stuff from ip_input.c */
123 struct ipstat_t ipstat;
124 struct ipqhead ipq[IPREASS_NHASH];
125 int maxnipq; /* Administrative limit on # of reass queues*/
126 int maxfragsperpacket; /* Maximum number of IPv4 fragments allowed per packet */
127 int nipq; /* total number of reass queues */
128 uint16_t ip_currid;
129 /* Stuff from mbuf.c */
130 /* Stuff from slirp.c */
131 void *pvUser;
132 uint32_t curtime;
133 uint32_t time_fasttimo;
134 uint32_t last_slowtimo;
135 bool do_slowtimo;
136 bool link_up;
137 struct timeval tt;
138 struct in_addr our_addr;
139 struct in_addr alias_addr;
140 struct in_addr special_addr;
141
142 int tcp_rcvspace;
143 int tcp_sndspace;
144 int socket_rcv;
145 int socket_snd;
146 int soMaxConn;
147#ifdef VBOX_WITH_SLIRP_MT
148 RTREQQUEUE hReqQueue;
149#endif
150#ifdef RT_OS_WINDOWS
151 ULONG (WINAPI * pfGetAdaptersAddresses)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG);
152#endif
153 struct dns_list_head pDnsList;
154 struct dns_domain_list_head pDomainList;
155 struct in_addr tftp_server;
156 struct in_addr loopback_addr;
157 uint32_t dnsLastUpdate;
158 uint32_t netmask;
159#ifndef VBOX_WITH_NAT_SERVICE
160 uint8_t client_ethaddr[6];
161#endif
162 const uint8_t *slirp_ethaddr;
163 char slirp_hostname[33];
164 bool fPassDomain;
165 struct in_addr bindIP;
166 /* Stuff from tcp_input.c */
167 struct socket tcb;
168#ifdef VBOX_WITH_SLIRP_MT
169 RTCRITSECT tcb_mutex;
170#endif
171 struct socket *tcp_last_so;
172 tcp_seq tcp_iss;
173 /* Stuff from tcp_timer.c */
174 struct tcpstat_t tcpstat;
175 uint32_t tcp_now;
176 int tcp_reass_qsize;
177 int tcp_reass_maxqlen;
178 int tcp_reass_maxseg;
179 int tcp_reass_overflows;
180 /* Stuff from tftp.c */
181 struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
182 const char *tftp_prefix;
183 /* Stuff from udp.c */
184 struct udpstat_t udpstat;
185 struct socket udb;
186#ifdef VBOX_WITH_SLIRP_MT
187 RTCRITSECT udb_mutex;
188#endif
189 struct socket *udp_last_so;
190 struct socket icmp_socket;
191 struct icmp_storage icmp_msg_head;
192# ifndef RT_OS_WINDOWS
193 /* counter of sockets needed for allocation enough room to
194 * process sockets with poll/epoll
195 *
196 * NSOCK_INC/DEC should be injected before every
197 * operation on socket queue (tcb, udb)
198 */
199 int nsock;
200# define NSOCK_INC() do {pData->nsock++;} while (0)
201# define NSOCK_DEC() do {pData->nsock--;} while (0)
202# define NSOCK_INC_EX(ex) do {ex->pData->nsock++;} while (0)
203# define NSOCK_DEC_EX(ex) do {ex->pData->nsock--;} while (0)
204# else
205# define NSOCK_INC() do {} while (0)
206# define NSOCK_DEC() do {} while (0)
207# define NSOCK_INC_EX(ex) do {} while (0)
208# define NSOCK_DEC_EX(ex) do {} while (0)
209# endif
210 int cIcmpCacheSize;
211 int iIcmpCacheLimit;
212# ifdef RT_OS_WINDOWS
213 void *pvIcmpBuffer;
214 size_t szIcmpBuffer;
215 /* Accordin MSDN specification IcmpParseReplies
216 * function should be detected in runtime
217 */
218 long (WINAPI * pfIcmpParseReplies)(void *, long);
219 BOOL (WINAPI * pfIcmpCloseHandle)(HANDLE);
220 HMODULE hmIcmpLibrary;
221# endif
222#if defined(RT_OS_WINDOWS)
223# define VBOX_SOCKET_EVENT (pData->phEvents[VBOX_SOCKET_EVENT_INDEX])
224 HANDLE phEvents[VBOX_EVENT_COUNT];
225#endif
226#ifdef zone_mbuf
227# undef zone_mbuf
228#endif
229 uma_zone_t zone_mbuf;
230#ifdef zone_clust
231# undef zone_clust
232#endif
233 uma_zone_t zone_clust;
234#ifdef zone_pack
235# undef zone_pack
236#endif
237 uma_zone_t zone_pack;
238#ifdef zone_jumbop
239# undef zone_jumbop
240#endif
241 uma_zone_t zone_jumbop;
242#ifdef zone_jumbo9
243# undef zone_jumbo9
244#endif
245 uma_zone_t zone_jumbo9;
246#ifdef zone_jumbo16
247# undef zone_jumbo16
248#endif
249 uma_zone_t zone_jumbo16;
250#ifdef zone_ext_refcnt
251# undef zone_ext_refcnt
252 int nmbclusters; /* limits number of mbuf clusters */
253 int nmbjumbop; /* limits number of page size jumbo clusters */
254 int nmbjumbo9; /* limits number of 9k jumbo clusters */
255 int nmbjumbo16; /* limits number of 16k jumbo clusters */
256 struct mbstat mbstat;
257#endif
258 uma_zone_t zone_ext_refcnt;
259 bool fUseHostResolver;
260 /* from dnsproxy/dnsproxy.h*/
261 unsigned int authoritative_port;
262 unsigned int authoritative_timeout;
263 unsigned int recursive_port;
264 unsigned int recursive_timeout;
265 unsigned int stats_timeout;
266 unsigned int port;
267
268 unsigned long active_queries;
269 unsigned long all_queries;
270 unsigned long authoritative_queries;
271 unsigned long recursive_queries;
272 unsigned long removed_queries;
273 unsigned long dropped_queries;
274 unsigned long answered_queries;
275 unsigned long dropped_answers;
276 unsigned long late_answers;
277 unsigned long hash_collisions;
278 /*dnsproxy/dnsproxy.c*/
279 unsigned short queryid;
280 struct sockaddr_in authoritative_addr;
281 struct sockaddr_in recursive_addr;
282 int sock_query;
283 int sock_answer;
284 /* dnsproxy/hash.c */
285#define HASHSIZE 10
286#define HASH(id) (id & ((1 << HASHSIZE) - 1))
287 struct request *request_hash[1 << HASHSIZE];
288 /* this field control behaviour of DHCP server */
289 bool fUseDnsProxy;
290
291 LIST_HEAD(RT_NOTHING, libalias) instancehead;
292 int i32AliasMode;
293 struct libalias *proxy_alias;
294 struct libalias *dns_alias;
295 LIST_HEAD(handler_chain, proto_handler) handler_chain;
296 struct port_forward_rule_list port_forward_rule_head;
297 int cRedirectionsActive;
298 int cRedirectionsStored;
299 struct arp_cache_head arp_cache;
300 /* libalis modules' handlers*/
301 struct proto_handler *ftp_module;
302 struct proto_handler *nbt_module;
303 struct proto_handler *dns_module;
304#ifdef VBOX_WITH_NAT_SEND2HOME
305 /* array of home addresses */
306 struct sockaddr_in *pInSockAddrHomeAddress;
307 /* size of pInSockAddrHomeAddress in elements */
308 int cInHomeAddressSize;
309#endif
310#ifdef VBOX_WITH_DNSMAPPING_IN_HOSTRESOLVER
311 DNSMAPPINGLISTHEAD DNSMapHead;
312#endif
313} NATState;
314
315
316/** Default IP time to live. */
317#define ip_defttl IPDEFTTL
318
319/** Number of permanent buffers in mbuf. */
320#define mbuf_thresh 30
321
322/** Use a fixed time before sending keepalive. */
323#define tcp_keepidle TCPTV_KEEP_IDLE
324
325/** Use a fixed interval between keepalive. */
326#define tcp_keepintvl TCPTV_KEEPINTVL
327
328/** Maximum idle time before timing out a connection. */
329#define tcp_maxidle (TCPTV_KEEPCNT * tcp_keepintvl)
330
331/** Default TCP socket options. */
332#define so_options DO_KEEPALIVE
333
334/** Default TCP MSS value. */
335#define tcp_mssdflt TCP_MSS
336
337/** Default TCP round trip time. */
338#define tcp_rttdflt (TCPTV_SRTTDFLT / PR_SLOWHZ)
339
340/** Enable RFC1323 performance enhancements.
341 * @todo check if it really works, it was turned off before. */
342#define tcp_do_rfc1323 1
343
344/** TCP receive buffer size. */
345#define tcp_rcvspace pData->tcp_rcvspace
346
347/** TCP receive buffer size. */
348#define tcp_sndspace pData->tcp_sndspace
349
350/* TCP duplicate ACK retransmit threshold. */
351#define tcprexmtthresh 3
352
353
354#define bootp_filename pData->bootp_filename
355
356#define if_mtu pData->if_mtu
357#define if_mru pData->if_mru
358#define if_comp pData->if_comp
359#define if_maxlinkhdr pData->if_maxlinkhdr
360#define if_queued pData->if_queued
361#define if_thresh pData->if_thresh
362
363#define icmpstat pData->icmpstat
364
365#define ipstat pData->ipstat
366#define ipq pData->ipq
367#define ip_currid pData->ip_currid
368
369#define mbuf_alloced pData->mbuf_alloced
370#define mbuf_max pData->mbuf_max
371#define msize pData->msize
372#define m_freelist pData->m_freelist
373#define m_usedlist pData->m_usedlist
374
375#define curtime pData->curtime
376#define time_fasttimo pData->time_fasttimo
377#define last_slowtimo pData->last_slowtimo
378#define do_slowtimo pData->do_slowtimo
379#define link_up pData->link_up
380#define cUsers pData->cUsers
381#define tt pData->tt
382#define our_addr pData->our_addr
383#ifndef VBOX_SLIRP_ALIAS
384# define alias_addr pData->alias_addr
385#else
386# define handler_chain pData->handler_chain
387#endif
388#define dns_addr pData->dns_addr
389#define loopback_addr pData->loopback_addr
390#define client_ethaddr pData->client_ethaddr
391#define slirp_hostname pData->slirp_hostname
392
393#define tcb pData->tcb
394#define tcp_last_so pData->tcp_last_so
395#define tcp_iss pData->tcp_iss
396
397#define tcpstat pData->tcpstat
398#define tcp_now pData->tcp_now
399
400#define tftp_sessions pData->tftp_sessions
401#define tftp_prefix pData->tftp_prefix
402
403#define udpstat pData->udpstat
404#define udb pData->udb
405#define udp_last_so pData->udp_last_so
406
407#define maxfragsperpacket pData->maxfragsperpacket
408#define maxnipq pData->maxnipq
409#define nipq pData->nipq
410
411#define tcp_reass_qsize pData->tcp_reass_qsize
412#define tcp_reass_maxqlen pData->tcp_reass_maxqlen
413#define tcp_reass_maxseg pData->tcp_reass_maxseg
414#define tcp_reass_overflows pData->tcp_reass_overflows
415
416#define queue_tcp_label tcb
417#define queue_udp_label udb
418#define VBOX_X2(x) x
419#define VBOX_X(x) VBOX_X2(x)
420
421#ifdef VBOX_WITH_SLIRP_MT
422
423# define QSOCKET_LOCK(queue) \
424 do { \
425 int rc; \
426 /* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \
427 rc = RTCritSectEnter(&VBOX_X(queue) ## _mutex); \
428 AssertRC(rc); \
429 } while (0)
430# define QSOCKET_UNLOCK(queue) \
431 do { \
432 int rc; \
433 rc = RTCritSectLeave(&VBOX_X(queue) ## _mutex); \
434 AssertRC(rc); \
435 } while (0)
436# define QSOCKET_LOCK_CREATE(queue) \
437 do { \
438 int rc; \
439 rc = RTCritSectInit(&pData->queue ## _mutex); \
440 AssertRC(rc); \
441 } while (0)
442# define QSOCKET_LOCK_DESTROY(queue) \
443 do { \
444 int rc = RTCritSectDelete(&pData->queue ## _mutex); \
445 AssertRC(rc); \
446 } while (0)
447
448# define QSOCKET_FOREACH(so, sonext, label) \
449 QSOCKET_LOCK(VBOX_X2(queue_## label ## _label)); \
450 (so) = (VBOX_X(queue_ ## label ## _label)).so_next; \
451 QSOCKET_UNLOCK(VBOX_X2(queue_## label ##_label)); \
452 if ((so) != &(VBOX_X(queue_## label ## _label))) SOCKET_LOCK((so));\
453 for (;;) \
454 { \
455 if ((so) == &(VBOX_X(queue_## label ## _label))) \
456 { \
457 break; \
458 } \
459 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so)));
460
461# define CONTINUE_NO_UNLOCK(label) goto loop_end_ ## label ## _mt_nounlock
462# define CONTINUE(label) goto loop_end_ ## label ## _mt
463/* @todo replace queue parameter with macrodinition */
464/* _mt_nounlock - user should lock so_next before calling CONTINUE_NO_UNLOCK */
465# define LOOP_LABEL(label, so, sonext) loop_end_ ## label ## _mt: \
466 (sonext) = (so)->so_next; \
467 SOCKET_UNLOCK(so); \
468 QSOCKET_LOCK(VBOX_X(queue_ ## label ## _label)); \
469 if ((sonext) != &(VBOX_X(queue_## label ## _label))) \
470 { \
471 SOCKET_LOCK((sonext)); \
472 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
473 } \
474 else \
475 { \
476 so = &VBOX_X(queue_ ## label ## _label); \
477 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
478 break; \
479 } \
480 (so) = (sonext); \
481 continue; \
482 loop_end_ ## label ## _mt_nounlock: \
483 (so) = (sonext)
484
485# define DO_TCP_OUTPUT(data, sotcb) \
486 do { \
487 PRTREQ pReq; \
488 int rc; \
489 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies*/, \
490 (PFNRT)tcp_output 2, data, sotcb); \
491 if (RT_LIKELY(rc == VERR_TIMEOUT)) \
492 { \
493 SOCKET_UNLOCK(so); \
494 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
495 AssertReleaseRC(rc); \
496 SOCKET_LOCK(so); \
497 RTReqRelease(pReq); \
498 } \
499 else \
500 AssertReleaseRC(rc); \
501} while(0)
502
503# define DO_TCP_INPUT(data, mbuf, size, so) \
504 do { \
505 int rc; \
506 rc = RTReqQueueCallEx((data)->hReqQueue, NULL, 0 /*cMillies*/, \
507 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, \
508 (PFNRT)tcp_input, 4, data, mbuf, size, so); \
509 AssertReleaseRC(rc); \
510 } while(0)
511
512# define DO_TCP_CONNECT(data, so) \
513 do { \
514 PRTREQ pReq; \
515 int rc; \
516 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies*/, \
517 (PFNRT)tcp_connect, 2, data, so); \
518 if (RT_LIKELY(rc == VERR_TIMEOUT)) \
519 { \
520 SOCKET_UNLOCK(so); \
521 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
522 AssertReleaseRC(rc); \
523 SOCKET_LOCK(so); \
524 RTReqRelease(pReq); \
525 } \
526 else \
527 AssertReleaseRC(rc); \
528 } while(0)
529
530# define DO_SOREAD(ret, data, so, ifclose) \
531 do { \
532 PRTREQ pReq; \
533 int rc; \
534 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies*/, \
535 (PFNRT)soread_queue, 4, \
536 data, so, ifclose, &(ret)); \
537 if (RT_LIKELY(rc == VERR_TIMEOUT)) \
538 { \
539 SOCKET_UNLOCK(so); \
540 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
541 AssertReleaseRC(rc); \
542 SOCKET_LOCK(so); \
543 RTReqRelease(pReq); \
544 } \
545 else \
546 AssertReleaseRC(rc); \
547 } while(0)
548
549# define DO_SOWRITE(ret, data, so) \
550 do { \
551 PRTREQ pReq; \
552 int rc; \
553 rc = RTReqQueueCall((data)->hReqQueue, &pReq, 0 /*cMillies*/, \
554 (PFNRT)sowrite, 2, data, so); \
555 if (RT_LIKELY(rc == VERR_TIMEOUT)) \
556 { \
557 SOCKET_UNLOCK(so); \
558 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
559 SOCKET_LOCK(so); \
560 ret = pReq->iStatus; \
561 RTReqRelease(pReq); \
562 } \
563 else \
564 AssertReleaseRC(rc); \
565 } while(0)
566
567# define DO_SORECFROM(data, so) \
568 do { \
569 PRTREQ pReq; \
570 int rc; \
571 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /*cMillies */, \
572 (PFNRT)sorecvfrom, 2, data, so); \
573 if (RT_LIKELY(rc == VERR_TIMEOUT)) \
574 { \
575 SOCKET_UNLOCK(so); \
576 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
577 AssertReleaseRC(rc); \
578 SOCKET_LOCK(so); \
579 RTReqRelease(pReq); \
580 } \
581 else \
582 AssertReleaseRC(rc); \
583 } while(0)
584
585# define DO_UDP_DETACH(data, so, so_next) \
586 do { \
587 PRTREQ pReq; \
588 int rc; \
589 rc = RTReqQueueCallVoid((data)->hReqQueue, &pReq, 0 /* cMillies*/, \
590 (PFNRT)udp_detach, 2, data, so); \
591 if (RT_LIKELY(rc == VERR_TIMEOUT)) \
592 { \
593 SOCKET_UNLOCK(so); \
594 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
595 AssertReleaseRC(rc); \
596 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \
597 RTReqRelease(pReq); \
598 } \
599 else \
600 AssertReleaseRC(rc); \
601 } while(0)
602
603# define SOLOOKUP(so, label, src, sport, dst, dport) \
604 do { \
605 struct socket *sonxt; \
606 (so) = NULL; \
607 QSOCKET_FOREACH(so, sonxt, label) \
608 /* { */ \
609 if ( so->so_lport == (sport) \
610 && so->so_laddr.s_addr == (src).s_addr \
611 && so->so_faddr.s_addr == (dst).s_addr \
612 && so->so_fport == (dport)) \
613 { \
614 if (sonxt != &VBOX_X2(queue_ ## label ## _label)) \
615 SOCKET_UNLOCK(sonxt); \
616 break; /*so is locked*/ \
617 } \
618 LOOP_LABEL(so, sonxt, label); \
619 } \
620 } \
621 } while (0)
622
623#else /* !VBOX_WITH_SLIRP_MT */
624
625# define QSOCKET_LOCK(queue) do {} while (0)
626# define QSOCKET_UNLOCK(queue) do {} while (0)
627# define QSOCKET_LOCK_CREATE(queue) do {} while (0)
628# define QSOCKET_LOCK_DESTROY(queue) do {} while (0)
629# define QSOCKET_FOREACH(so, sonext, label) \
630 for ((so) = VBOX_X2(queue_ ## label ## _label).so_next; \
631 (so) != &(VBOX_X2(queue_ ## label ## _label)); \
632 (so) = (sonext)) \
633 { \
634 (sonext) = (so)->so_next; \
635 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so)));
636# define CONTINUE(label) continue
637# define CONTINUE_NO_UNLOCK(label) continue
638# define LOOP_LABEL(label, so, sonext) /* empty*/
639# define DO_TCP_OUTPUT(data, sotcb) tcp_output((data), (sotcb))
640# define DO_TCP_INPUT(data, mbuf, size, so) tcp_input((data), (mbuf), (size), (so))
641# define DO_TCP_CONNECT(data, so) tcp_connect((data), (so))
642# define DO_SOREAD(ret, data, so, ifclose) \
643 do { \
644 (ret) = soread((data), (so), (ifclose)); \
645 } while(0)
646# define DO_SOWRITE(ret, data, so) \
647 do { \
648 (ret) = sowrite((data), (so)); \
649 } while(0)
650# define DO_SORECFROM(data, so) sorecvfrom((data), (so))
651# define SOLOOKUP(so, label, src, sport, dst, dport) \
652 do { \
653 (so) = solookup(&VBOX_X2(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \
654 } while (0)
655# define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so))
656
657#endif /* !VBOX_WITH_SLIRP_MT */
658
659#define TCP_OUTPUT(data, sotcb) DO_TCP_OUTPUT((data), (sotcb))
660#define TCP_INPUT(data, mbuf, size, so) DO_TCP_INPUT((data), (mbuf), (size), (so))
661#define TCP_CONNECT(data, so) DO_TCP_CONNECT((data), (so))
662#define SOREAD(ret, data, so, ifclose) DO_SOREAD((ret), (data), (so), (ifclose))
663#define SOWRITE(ret, data, so) DO_SOWRITE((ret), (data), (so))
664#define SORECVFROM(data, so) DO_SORECFROM((data), (so))
665#define UDP_DETACH(data, so, so_next) DO_UDP_DETACH((data), (so), (so_next))
666
667/* dnsproxy/dnsproxy.c */
668#define authoritative_port pData->authoritative_port
669#define authoritative_timeout pData->authoritative_timeout
670#define recursive_port pData->recursive_port
671#define recursive_timeout pData->recursive_timeout
672#define stats_timeout pData->stats_timeout
673/* dnsproxy/hash.c */
674#define dns_port pData->port
675#define request_hash pData->request_hash
676#define hash_collisions pData->hash_collisions
677#define active_queries pData->active_queries
678#define all_queries pData->all_queries
679#define authoritative_queries pData->authoritative_queries
680#define recursive_queries pData->recursive_queries
681#define removed_queries pData->removed_queries
682#define dropped_queries pData->dropped_queries
683#define answered_queries pData->answered_queries
684#define dropped_answers pData->dropped_answers
685#define late_answers pData->late_answers
686
687/* dnsproxy/dnsproxy.c */
688#define queryid pData->queryid
689#define authoritative_addr pData->authoritative_addr
690#define recursive_addr pData->recursive_addr
691#define sock_query pData->sock_query
692#define sock_answer pData->sock_answer
693
694#define instancehead pData->instancehead
695
696#define nmbclusters pData->nmbclusters
697#define nmbjumbop pData->nmbjumbop
698#define nmbjumbo9 pData->nmbjumbo9
699#define nmbjumbo16 pData->nmbjumbo16
700#define mbstat pData->mbstat
701#include "ext.h"
702#undef zone_mbuf
703#undef zone_clust
704#undef zone_pack
705#undef zone_jumbop
706#undef zone_jumbo9
707#undef zone_jumbo16
708#undef zone_ext_refcnt
709static inline uma_zone_t slirp_zone_pack(PNATState pData)
710{
711 return pData->zone_pack;
712}
713static inline uma_zone_t slirp_zone_jumbop(PNATState pData)
714{
715 return pData->zone_jumbop;
716}
717static inline uma_zone_t slirp_zone_jumbo9(PNATState pData)
718{
719 return pData->zone_jumbo9;
720}
721static inline uma_zone_t slirp_zone_jumbo16(PNATState pData)
722{
723 return pData->zone_jumbo16;
724}
725static inline uma_zone_t slirp_zone_ext_refcnt(PNATState pData)
726{
727 return pData->zone_ext_refcnt;
728}
729static inline uma_zone_t slirp_zone_mbuf(PNATState pData)
730{
731 return pData->zone_mbuf;
732}
733static inline uma_zone_t slirp_zone_clust(PNATState pData)
734{
735 return pData->zone_clust;
736}
737#ifndef VBOX_SLIRP_BSD
738# define m_adj(m, len) m_adj(pData, (m), (len))
739#endif
740
741#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