VirtualBox

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

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

NAT: make counters registration easier

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