VirtualBox

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

Last change on this file since 22844 was 22843, checked in by vboxsync, 15 years ago

NAT: using host resolver instead of dnsproxy.

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