VirtualBox

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

Last change on this file since 20383 was 20379, checked in by vboxsync, 16 years ago

NAT: introduce slirp's interface to configure socket's and sbuf defaults

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