VirtualBox

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

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

NAT: some counters

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