VirtualBox

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

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

NAT: globals

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