VirtualBox

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

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

NAT: some cleanings

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette