VirtualBox

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

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

DrvNat,slirp: simplify statistics and deregister them.

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