VirtualBox

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

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

NAT: burn fix

  • 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# define PROFILE_COUNTER(name, dsc) STAMPROFILE Stat ## name
234# define COUNTING_COUTER(name, dsc) STAMCOUNTER Stat ## name
235
236#include "counters.h"
237
238#undef PROFILE_COUNTER
239#undef COUNTING_COUTER
240
241} NATState;
242
243
244/** Default IP time to live. */
245#define ip_defttl IPDEFTTL
246
247/** Number of permanent buffers in mbuf. */
248#define mbuf_thresh 30
249
250/** Use a fixed time before sending keepalive. */
251#define tcp_keepidle TCPTV_KEEP_IDLE
252
253/** Use a fixed interval between keepalive. */
254#define tcp_keepintvl TCPTV_KEEPINTVL
255
256/** Maximum idle time before timing out a connection. */
257#define tcp_maxidle (TCPTV_KEEPCNT * tcp_keepintvl)
258
259/** Default TCP socket options. */
260#define so_options DO_KEEPALIVE
261
262/** Default TCP MSS value. */
263#define tcp_mssdflt TCP_MSS
264
265/** Default TCP round trip time. */
266#define tcp_rttdflt (TCPTV_SRTTDFLT / PR_SLOWHZ)
267
268/** Enable RFC1323 performance enhancements.
269 * @todo check if it really works, it was turned off before. */
270#define tcp_do_rfc1323 1
271
272/** TCP receive buffer size. */
273#define tcp_rcvspace TCP_RCVSPACE
274
275/** TCP receive buffer size. */
276#define tcp_sndspace TCP_SNDSPACE
277
278/* TCP duplicate ACK retransmit threshold. */
279#define tcprexmtthresh 3
280
281
282#define bootp_filename pData->bootp_filename
283#define bootp_clients pData->bootp_clients
284
285#define if_mtu pData->if_mtu
286#define if_mru pData->if_mru
287#define if_comp pData->if_comp
288#define if_maxlinkhdr pData->if_maxlinkhdr
289#define if_queued pData->if_queued
290#define if_thresh pData->if_thresh
291#define if_fastq pData->if_fastq
292#define if_batchq pData->if_batchq
293#define next_m pData->next_m
294
295#define icmpstat pData->icmpstat
296
297#define ipstat pData->ipstat
298#define ipq pData->ipq
299#define ip_currid pData->ip_currid
300
301#define mbuf_alloced pData->mbuf_alloced
302#define mbuf_max pData->mbuf_max
303#define msize pData->msize
304#define m_freelist pData->m_freelist
305#define m_usedlist pData->m_usedlist
306
307#define curtime pData->curtime
308#define time_fasttimo pData->time_fasttimo
309#define last_slowtimo pData->last_slowtimo
310#define do_slowtimo pData->do_slowtimo
311#define link_up pData->link_up
312#define cUsers pData->cUsers
313#define tt pData->tt
314#define our_addr pData->our_addr
315#ifndef VBOX_SLIRP_ALIAS
316# define alias_addr pData->alias_addr
317#endif
318#define special_addr pData->special_addr
319#define dns_addr pData->dns_addr
320#define loopback_addr pData->loopback_addr
321#define client_ethaddr pData->client_ethaddr
322#define exec_list pData->exec_list
323#define slirp_hostname pData->slirp_hostname
324
325#define tcb pData->tcb
326#define tcp_last_so pData->tcp_last_so
327#define tcp_iss pData->tcp_iss
328
329#define tcpstat pData->tcpstat
330#define tcp_now pData->tcp_now
331
332#define tftp_sessions pData->tftp_sessions
333#define tftp_prefix pData->tftp_prefix
334
335#define udpstat pData->udpstat
336#define udb pData->udb
337#define udp_last_so pData->udp_last_so
338
339#define maxfragsperpacket pData->maxfragsperpacket
340#define maxnipq pData->maxnipq
341#define nipq pData->nipq
342
343#define tcp_reass_qsize pData->tcp_reass_qsize
344#define tcp_reass_maxqlen pData->tcp_reass_maxqlen
345#define tcp_reass_maxseg pData->tcp_reass_maxseg
346#define tcp_reass_overflows pData->tcp_reass_overflows
347
348#define queue_tcp_label tcb
349#define queue_udp_label udb
350#define VBOX_X2(x) x
351#define VBOX_X(x) VBOX_X2(x)
352#define VBOX_STR2(x) #x
353#define VBOX_STR(x) VBOX_STR2(x)
354
355#ifdef VBOX_WITH_SLIRP_MT
356
357# define QSOCKET_LOCK(queue) \
358 do { \
359 int rc; \
360 /* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \
361 rc = RTCritSectEnter(&VBOX_X(queue) ## _mutex); \
362 AssertReleaseRC(rc); \
363 } while (0)
364# define QSOCKET_UNLOCK(queue) \
365 do { \
366 int rc; \
367 rc = RTCritSectLeave(&VBOX_X(queue) ## _mutex); \
368 AssertReleaseRC(rc); \
369 } while (0)
370# define QSOCKET_LOCK_CREATE(queue) \
371 do { \
372 int rc; \
373 rc = RTCritSectInit(&pData->queue ## _mutex); \
374 AssertReleaseRC(rc); \
375 } while (0)
376# define QSOCKET_LOCK_DESTROY(queue) \
377 do { \
378 int rc = RTCritSectDelete(&pData->queue ## _mutex); \
379 AssertReleaseRC(rc); \
380 } while (0)
381
382# define QSOCKET_FOREACH(so, sonext, label) \
383 QSOCKET_LOCK(VBOX_X2(queue_## label ## _label)); \
384 (so) = (VBOX_X(queue_ ## label ## _label)).so_next; \
385 QSOCKET_UNLOCK(VBOX_X2(queue_## label ##_label)); \
386 if ((so) != &(VBOX_X(queue_## label ## _label))) SOCKET_LOCK((so));\
387 for (;;) \
388 { \
389 if ((so) == &(VBOX_X(queue_## label ## _label))) \
390 { \
391 break; \
392 } \
393 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so)));
394
395# define CONTINUE_NO_UNLOCK(label) goto loop_end_ ## label ## _mt_nounlock
396# define CONTINUE(label) goto loop_end_ ## label ## _mt
397/* @todo replace queue parameter with macrodinition */
398/* _mt_nounlock - user should lock so_next before calling CONTINUE_NO_UNLOCK */
399# define LOOP_LABEL(label, so, sonext) loop_end_ ## label ## _mt: \
400 (sonext) = (so)->so_next; \
401 SOCKET_UNLOCK(so); \
402 QSOCKET_LOCK(VBOX_X(queue_ ## label ## _label)); \
403 if ((sonext) != &(VBOX_X(queue_## label ## _label))) \
404 { \
405 SOCKET_LOCK((sonext)); \
406 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
407 } \
408 else \
409 { \
410 so = &VBOX_X(queue_ ## label ## _label); \
411 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
412 break; \
413 } \
414 (so) = (sonext); \
415 continue; \
416 loop_end_ ## label ## _mt_nounlock: \
417 (so) = (sonext)
418
419# define DO_TCP_OUTPUT(data, sotcb) \
420 do { \
421 PRTREQ pReq = NULL; \
422 int rc; \
423 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
424 AssertReleaseRC(rc); \
425 pReq->u.Internal.pfn = (PFNRT)tcp_output; \
426 pReq->u.Internal.cArgs = 2; \
427 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
428 pReq->u.Internal.aArgs[1] = (uintptr_t)(sotcb); \
429 pReq->fFlags = RTREQFLAGS_VOID; \
430 rc = RTReqQueue(pReq, 0); \
431 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
432 { \
433 SOCKET_UNLOCK(so); \
434 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
435 AssertReleaseRC(rc); \
436 SOCKET_LOCK(so); \
437 RTReqFree(pReq); \
438 } \
439 else \
440 AssertReleaseRC(rc); \
441} while(0)
442
443# define DO_TCP_INPUT(data, mbuf, size, so) \
444 do { \
445 PRTREQ pReq = NULL; \
446 int rc; \
447 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
448 AssertReleaseRC(rc); \
449 pReq->u.Internal.pfn = (PFNRT)tcp_input; \
450 pReq->u.Internal.cArgs = 4; \
451 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
452 pReq->u.Internal.aArgs[1] = (uintptr_t)(mbuf); \
453 pReq->u.Internal.aArgs[2] = (uintptr_t)(size); \
454 pReq->u.Internal.aArgs[3] = (uintptr_t)(so); \
455 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; \
456 rc = RTReqQueue(pReq, 0); \
457 AssertReleaseRC(rc); \
458 } while(0)
459
460# define DO_TCP_CONNECT(data, so) \
461 do { \
462 PRTREQ pReq = NULL; \
463 int rc; \
464 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
465 AssertReleaseRC(rc); \
466 pReq->u.Internal.pfn = (PFNRT)tcp_connect; \
467 pReq->u.Internal.cArgs = 2; \
468 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
469 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
470 pReq->fFlags = RTREQFLAGS_VOID; \
471 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
472 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
473 { \
474 SOCKET_UNLOCK(so); \
475 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
476 AssertReleaseRC(rc); \
477 SOCKET_LOCK(so); \
478 RTReqFree(pReq); \
479 } \
480 else \
481 AssertReleaseRC(rc); \
482 } while(0)
483
484# define DO_SOREAD(ret, data, so, ifclose) \
485 do { \
486 PRTREQ pReq = NULL; \
487 int rc; \
488 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
489 AssertReleaseRC(rc); \
490 pReq->u.Internal.pfn = (PFNRT)soread_queue; \
491 pReq->u.Internal.cArgs = 4; \
492 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
493 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
494 pReq->u.Internal.aArgs[2] = (uintptr_t)(ifclose); \
495 pReq->u.Internal.aArgs[3] = (uintptr_t)&(ret); \
496 pReq->fFlags = RTREQFLAGS_VOID; \
497 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
498 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
499 { \
500 SOCKET_UNLOCK(so); \
501 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
502 AssertReleaseRC(rc); \
503 SOCKET_LOCK(so); \
504 RTReqFree(pReq); \
505 } \
506 else \
507 AssertReleaseRC(rc); \
508 } while(0)
509
510# define DO_SOWRITE(ret, data, so) \
511 do { \
512 PRTREQ pReq = NULL; \
513 int rc; \
514 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
515 AssertReleaseRC(rc); \
516 pReq->u.Internal.pfn = (PFNRT)sowrite; \
517 pReq->u.Internal.cArgs = 2; \
518 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
519 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
520 pReq->fFlags = RTREQFLAGS_RETURN_MASK; \
521 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
522 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
523 { \
524 SOCKET_UNLOCK(so); \
525 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
526 SOCKET_LOCK(so); \
527 ret = pReq->iStatus; \
528 RTReqFree(pReq); \
529 } \
530 else \
531 AssertReleaseRC(rc); \
532 } while(0)
533
534# define DO_SORECFROM(data, so) \
535 do { \
536 PRTREQ pReq = NULL; \
537 int rc; \
538 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
539 AssertReleaseRC(rc); \
540 pReq->u.Internal.pfn = (PFNRT)sorecvfrom; \
541 pReq->u.Internal.cArgs = 2; \
542 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
543 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
544 pReq->fFlags = RTREQFLAGS_VOID; \
545 rc = RTReqQueue(pReq, 0); \
546 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
547 { \
548 SOCKET_UNLOCK(so); \
549 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
550 AssertReleaseRC(rc); \
551 SOCKET_LOCK(so); \
552 RTReqFree(pReq); \
553 } \
554 else \
555 AssertReleaseRC(rc); \
556 } while(0)
557
558# define DO_UDP_DETACH(data, so, so_next) \
559 do { \
560 PRTREQ pReq = NULL; \
561 int rc; \
562 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
563 AssertReleaseRC(rc); \
564 pReq->u.Internal.pfn = (PFNRT)udp_detach; \
565 pReq->u.Internal.cArgs = 2; \
566 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
567 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
568 pReq->fFlags = RTREQFLAGS_VOID; \
569 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
570 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
571 { \
572 SOCKET_UNLOCK(so); \
573 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
574 AssertReleaseRC(rc); \
575 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \
576 RTReqFree(pReq); \
577 } \
578 else \
579 AssertReleaseRC(rc); \
580 } while(0)
581
582# define SOLOOKUP(so, label, src, sport, dst, dport) \
583 do { \
584 struct socket *sonxt; \
585 (so) = NULL; \
586 QSOCKET_FOREACH(so, sonxt, label) \
587 /* { */ \
588 if ( so->so_lport == (sport) \
589 && so->so_laddr.s_addr == (src).s_addr \
590 && so->so_faddr.s_addr == (dst).s_addr \
591 && so->so_fport == (dport)) \
592 { \
593 if (sonxt != &VBOX_X2(queue_ ## label ## _label)) \
594 SOCKET_UNLOCK(sonxt); \
595 break; /*so is locked*/ \
596 } \
597 LOOP_LABEL(so, sonxt, label); \
598 } \
599 } \
600 } while (0)
601
602#else /* !VBOX_WITH_SLIRP_MT */
603
604# define QSOCKET_LOCK(queue) do {} while (0)
605# define QSOCKET_UNLOCK(queue) do {} while (0)
606# define QSOCKET_LOCK_CREATE(queue) do {} while (0)
607# define QSOCKET_LOCK_DESTROY(queue) do {} while (0)
608# define QSOCKET_FOREACH(so, sonext, label) \
609 for ((so) = VBOX_X2(queue_ ## label ## _label).so_next; \
610 (so) != &(VBOX_X2(queue_ ## label ## _label)); \
611 (so) = (sonext)) \
612 { \
613 (sonext) = (so)->so_next;
614# define CONTINUE(label) continue
615# define CONTINUE_NO_UNLOCK(label) continue
616# define LOOP_LABEL(label, so, sonext) /* empty*/
617# define DO_TCP_OUTPUT(data, sotcb) tcp_output((data), (sotcb))
618# define DO_TCP_INPUT(data, mbuf, size, so) tcp_input((data), (mbuf), (size), (so))
619# define DO_TCP_CONNECT(data, so) tcp_connect((data), (so))
620# define DO_SOREAD(ret, data, so, ifclose) \
621 do { \
622 (ret) = soread((data), (so), (ifclose)); \
623 } while(0)
624# define DO_SOWRITE(ret, data, so) \
625 do { \
626 (ret) = sowrite((data), (so)); \
627 } while(0)
628# define DO_SORECFROM(data, so) sorecvfrom((data), (so))
629# define SOLOOKUP(so, label, src, sport, dst, dport) \
630 do { \
631 (so) = solookup(&VBOX_X2(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \
632 } while (0)
633# define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so))
634
635#endif /* !VBOX_WITH_SLIRP_MT */
636
637#define TCP_OUTPUT(data, sotcb) DO_TCP_OUTPUT((data), (sotcb))
638#define TCP_INPUT(data, mbuf, size, so) DO_TCP_INPUT((data), (mbuf), (size), (so))
639#define TCP_CONNECT(data, so) DO_TCP_CONNECT((data), (so))
640#define SOREAD(ret, data, so, ifclose) DO_SOREAD((ret), (data), (so), (ifclose))
641#define SOWRITE(ret, data, so) DO_SOWRITE((ret), (data), (so))
642#define SORECVFROM(data, so) DO_SORECFROM((data), (so))
643#define UDP_DETACH(data, so, so_next) DO_UDP_DETACH((data), (so), (so_next))
644
645#ifdef VBOX_WITH_SLIRP_DNS_PROXY
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#endif
673
674#ifdef VBOX_WITH_SLIRP_ALIAS
675# define instancehead pData->instancehead
676#endif
677
678#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