VirtualBox

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

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

NAT: remove (and enable) VBOX_WITH_MULTI_DNS and VBOX_WITH_SLIRP_DNS_PROXY ifdefs as both were properly tested with VBox 2.2.x

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