VirtualBox

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

Last change on this file since 29603 was 29506, checked in by vboxsync, 15 years ago

NAT: backed r61642, pospone till 3.2.2.

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