VirtualBox

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

最後變更 在這個檔案從22494是 22494,由 vboxsync 提交於 16 年 前

NAT: some pollish of r51498

  • 屬性 svn:eol-style 設為 native
檔案大小: 29.6 KB
 
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.alldomusa.eu.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/** Number of DHCP clients supported by NAT. */
33#define NB_ADDR 16
34
35/** Where to start DHCP IP number allocation. */
36#define START_ADDR 15
37
38/** DHCP Lease time. */
39#define LEASE_TIME (24 * 3600)
40
41/** TFTP session entry. */
42struct tftp_session
43{
44 int in_use;
45 unsigned char filename[TFTP_FILENAME_MAX];
46
47 struct in_addr client_ip;
48 u_int16_t client_port;
49
50 int timestamp;
51};
52
53struct dns_domain_entry
54{
55 char *dd_pszDomain;
56 LIST_ENTRY(dns_domain_entry) dd_list;
57};
58LIST_HEAD(dns_domain_list_head, dns_domain_entry);
59
60struct dns_entry
61{
62 struct in_addr de_addr;
63 TAILQ_ENTRY(dns_entry) de_list;
64};
65TAILQ_HEAD(dns_list_head, dns_entry);
66
67struct port_forward_rule
68{
69 uint16_t proto;
70 uint16_t host_port;
71 uint16_t guest_port;
72#ifndef VBOX_WITH_NAT_SERVICE
73 struct in_addr guest_addr;
74#endif
75 struct in_addr bind_ip;
76 uint8_t mac_address[6]; /*need ETH_ALEN here */
77 int activated;
78 LIST_ENTRY(port_forward_rule) list;
79};
80LIST_HEAD(port_forward_rule_list, port_forward_rule);
81
82/* forward declaration */
83struct proto_handler;
84
85/** Main state/configuration structure for slirp NAT. */
86typedef struct NATState
87{
88 /* Stuff from boot.c */
89 BOOTPClient bootp_clients[NB_ADDR];
90 const char *bootp_filename;
91 /* Stuff from if.c */
92 int if_mtu, if_mru;
93 int if_comp;
94 int if_maxlinkhdr;
95 int if_queued;
96 int if_thresh;
97 struct mbuf if_fastq;
98 struct mbuf if_batchq;
99 struct mbuf *next_m;
100 /* Stuff from icmp.c */
101 struct icmpstat_t icmpstat;
102 /* Stuff from ip_input.c */
103 struct ipstat_t ipstat;
104 struct ipqhead ipq[IPREASS_NHASH];
105 int maxnipq; /* Administrative limit on # of reass queues*/
106 int maxfragsperpacket; /* Maximum number of IPv4 fragments allowed per packet */
107 int nipq; /* total number of reass queues */
108 uint16_t ip_currid;
109 /* Stuff from mbuf.c */
110 int mbuf_alloced, mbuf_max;
111 int msize;
112 struct mbuf m_freelist, m_usedlist;
113 /* Stuff from slirp.c */
114 void *pvUser;
115 uint32_t curtime;
116 uint32_t time_fasttimo;
117 uint32_t last_slowtimo;
118 bool do_slowtimo;
119 bool link_up;
120 struct timeval tt;
121 struct in_addr our_addr;
122 struct in_addr alias_addr;
123 struct in_addr special_addr;
124
125 int tcp_rcvspace;
126 int tcp_sndspace;
127 int socket_rcv;
128 int socket_snd;
129#ifdef VBOX_WITH_SLIRP_MT
130 PRTREQQUEUE pReqQueue;
131#endif
132#ifdef RT_OS_WINDOWS
133 ULONG (WINAPI * pfGetAdaptersAddresses)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG);
134#endif
135 struct dns_list_head dns_list_head;
136 struct dns_domain_list_head dns_domain_list_head;
137 struct in_addr tftp_server;
138 struct in_addr loopback_addr;
139 uint32_t netmask;
140#ifndef VBOX_WITH_NAT_SERVICE
141 uint8_t client_ethaddr[6];
142#endif
143 const uint8_t *slirp_ethaddr;
144 struct ex_list *exec_list;
145 char slirp_hostname[33];
146 bool fPassDomain;
147 struct in_addr bindIP;
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
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
238 LIST_HEAD(RT_NOTHING, libalias) instancehead;
239 struct libalias *proxy_alias;
240 LIST_HEAD(handler_chain, proto_handler) handler_chain;
241 struct port_forward_rule_list port_forward_rule_head;
242 int port_forwarding_activated;
243 /*libalis modules' handlers*/
244 struct proto_handler *ftp_module;
245 struct proto_handler *nbt_module;
246
247#define PROFILE_COUNTER(name, dsc) STAMPROFILE Stat ## name
248#define COUNTING_COUNTER(name, dsc) STAMCOUNTER Stat ## name
249
250#include "counters.h"
251
252} NATState;
253
254
255/** Default IP time to live. */
256#define ip_defttl IPDEFTTL
257
258/** Number of permanent buffers in mbuf. */
259#define mbuf_thresh 30
260
261/** Use a fixed time before sending keepalive. */
262#define tcp_keepidle TCPTV_KEEP_IDLE
263
264/** Use a fixed interval between keepalive. */
265#define tcp_keepintvl TCPTV_KEEPINTVL
266
267/** Maximum idle time before timing out a connection. */
268#define tcp_maxidle (TCPTV_KEEPCNT * tcp_keepintvl)
269
270/** Default TCP socket options. */
271#define so_options DO_KEEPALIVE
272
273/** Default TCP MSS value. */
274#define tcp_mssdflt TCP_MSS
275
276/** Default TCP round trip time. */
277#define tcp_rttdflt (TCPTV_SRTTDFLT / PR_SLOWHZ)
278
279/** Enable RFC1323 performance enhancements.
280 * @todo check if it really works, it was turned off before. */
281#define tcp_do_rfc1323 1
282
283/** TCP receive buffer size. */
284#define tcp_rcvspace pData->tcp_rcvspace
285
286/** TCP receive buffer size. */
287#define tcp_sndspace pData->tcp_sndspace
288
289/* TCP duplicate ACK retransmit threshold. */
290#define tcprexmtthresh 3
291
292
293#define bootp_filename pData->bootp_filename
294#define bootp_clients pData->bootp_clients
295
296#define if_mtu pData->if_mtu
297#define if_mru pData->if_mru
298#define if_comp pData->if_comp
299#define if_maxlinkhdr pData->if_maxlinkhdr
300#define if_queued pData->if_queued
301#define if_thresh pData->if_thresh
302#define if_fastq pData->if_fastq
303#define if_batchq pData->if_batchq
304#define next_m pData->next_m
305
306#define icmpstat pData->icmpstat
307
308#define ipstat pData->ipstat
309#define ipq pData->ipq
310#define ip_currid pData->ip_currid
311
312#define mbuf_alloced pData->mbuf_alloced
313#define mbuf_max pData->mbuf_max
314#define msize pData->msize
315#define m_freelist pData->m_freelist
316#define m_usedlist pData->m_usedlist
317
318#define curtime pData->curtime
319#define time_fasttimo pData->time_fasttimo
320#define last_slowtimo pData->last_slowtimo
321#define do_slowtimo pData->do_slowtimo
322#define link_up pData->link_up
323#define cUsers pData->cUsers
324#define tt pData->tt
325#define our_addr pData->our_addr
326#ifndef VBOX_SLIRP_ALIAS
327# define alias_addr pData->alias_addr
328#else
329# define handler_chain pData->handler_chain
330#endif
331#define special_addr pData->special_addr
332#define dns_addr pData->dns_addr
333#define loopback_addr pData->loopback_addr
334#define client_ethaddr pData->client_ethaddr
335#define exec_list pData->exec_list
336#define slirp_hostname pData->slirp_hostname
337
338#define tcb pData->tcb
339#define tcp_last_so pData->tcp_last_so
340#define tcp_iss pData->tcp_iss
341
342#define tcpstat pData->tcpstat
343#define tcp_now pData->tcp_now
344
345#define tftp_sessions pData->tftp_sessions
346#define tftp_prefix pData->tftp_prefix
347
348#define udpstat pData->udpstat
349#define udb pData->udb
350#define udp_last_so pData->udp_last_so
351
352#define maxfragsperpacket pData->maxfragsperpacket
353#define maxnipq pData->maxnipq
354#define nipq pData->nipq
355
356#define tcp_reass_qsize pData->tcp_reass_qsize
357#define tcp_reass_maxqlen pData->tcp_reass_maxqlen
358#define tcp_reass_maxseg pData->tcp_reass_maxseg
359#define tcp_reass_overflows pData->tcp_reass_overflows
360
361#define queue_tcp_label tcb
362#define queue_udp_label udb
363#define VBOX_X2(x) x
364#define VBOX_X(x) VBOX_X2(x)
365
366#ifdef VBOX_WITH_SLIRP_MT
367
368# define QSOCKET_LOCK(queue) \
369 do { \
370 int rc; \
371 /* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \
372 rc = RTCritSectEnter(&VBOX_X(queue) ## _mutex); \
373 AssertReleaseRC(rc); \
374 } while (0)
375# define QSOCKET_UNLOCK(queue) \
376 do { \
377 int rc; \
378 rc = RTCritSectLeave(&VBOX_X(queue) ## _mutex); \
379 AssertReleaseRC(rc); \
380 } while (0)
381# define QSOCKET_LOCK_CREATE(queue) \
382 do { \
383 int rc; \
384 rc = RTCritSectInit(&pData->queue ## _mutex); \
385 AssertReleaseRC(rc); \
386 } while (0)
387# define QSOCKET_LOCK_DESTROY(queue) \
388 do { \
389 int rc = RTCritSectDelete(&pData->queue ## _mutex); \
390 AssertReleaseRC(rc); \
391 } while (0)
392
393# define QSOCKET_FOREACH(so, sonext, label) \
394 QSOCKET_LOCK(VBOX_X2(queue_## label ## _label)); \
395 (so) = (VBOX_X(queue_ ## label ## _label)).so_next; \
396 QSOCKET_UNLOCK(VBOX_X2(queue_## label ##_label)); \
397 if ((so) != &(VBOX_X(queue_## label ## _label))) SOCKET_LOCK((so));\
398 for (;;) \
399 { \
400 if ((so) == &(VBOX_X(queue_## label ## _label))) \
401 { \
402 break; \
403 } \
404 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so)));
405
406# define CONTINUE_NO_UNLOCK(label) goto loop_end_ ## label ## _mt_nounlock
407# define CONTINUE(label) goto loop_end_ ## label ## _mt
408/* @todo replace queue parameter with macrodinition */
409/* _mt_nounlock - user should lock so_next before calling CONTINUE_NO_UNLOCK */
410# define LOOP_LABEL(label, so, sonext) loop_end_ ## label ## _mt: \
411 (sonext) = (so)->so_next; \
412 SOCKET_UNLOCK(so); \
413 QSOCKET_LOCK(VBOX_X(queue_ ## label ## _label)); \
414 if ((sonext) != &(VBOX_X(queue_## label ## _label))) \
415 { \
416 SOCKET_LOCK((sonext)); \
417 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
418 } \
419 else \
420 { \
421 so = &VBOX_X(queue_ ## label ## _label); \
422 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
423 break; \
424 } \
425 (so) = (sonext); \
426 continue; \
427 loop_end_ ## label ## _mt_nounlock: \
428 (so) = (sonext)
429
430# define DO_TCP_OUTPUT(data, sotcb) \
431 do { \
432 PRTREQ pReq = NULL; \
433 int rc; \
434 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
435 AssertReleaseRC(rc); \
436 pReq->u.Internal.pfn = (PFNRT)tcp_output; \
437 pReq->u.Internal.cArgs = 2; \
438 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
439 pReq->u.Internal.aArgs[1] = (uintptr_t)(sotcb); \
440 pReq->fFlags = RTREQFLAGS_VOID; \
441 rc = RTReqQueue(pReq, 0); \
442 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
443 { \
444 SOCKET_UNLOCK(so); \
445 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
446 AssertReleaseRC(rc); \
447 SOCKET_LOCK(so); \
448 RTReqFree(pReq); \
449 } \
450 else \
451 AssertReleaseRC(rc); \
452} while(0)
453
454# define DO_TCP_INPUT(data, mbuf, size, so) \
455 do { \
456 PRTREQ pReq = NULL; \
457 int rc; \
458 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
459 AssertReleaseRC(rc); \
460 pReq->u.Internal.pfn = (PFNRT)tcp_input; \
461 pReq->u.Internal.cArgs = 4; \
462 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
463 pReq->u.Internal.aArgs[1] = (uintptr_t)(mbuf); \
464 pReq->u.Internal.aArgs[2] = (uintptr_t)(size); \
465 pReq->u.Internal.aArgs[3] = (uintptr_t)(so); \
466 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; \
467 rc = RTReqQueue(pReq, 0); \
468 AssertReleaseRC(rc); \
469 } while(0)
470
471# define DO_TCP_CONNECT(data, so) \
472 do { \
473 PRTREQ pReq = NULL; \
474 int rc; \
475 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
476 AssertReleaseRC(rc); \
477 pReq->u.Internal.pfn = (PFNRT)tcp_connect; \
478 pReq->u.Internal.cArgs = 2; \
479 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
480 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
481 pReq->fFlags = RTREQFLAGS_VOID; \
482 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
483 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
484 { \
485 SOCKET_UNLOCK(so); \
486 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
487 AssertReleaseRC(rc); \
488 SOCKET_LOCK(so); \
489 RTReqFree(pReq); \
490 } \
491 else \
492 AssertReleaseRC(rc); \
493 } while(0)
494
495# define DO_SOREAD(ret, data, so, ifclose) \
496 do { \
497 PRTREQ pReq = NULL; \
498 int rc; \
499 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
500 AssertReleaseRC(rc); \
501 pReq->u.Internal.pfn = (PFNRT)soread_queue; \
502 pReq->u.Internal.cArgs = 4; \
503 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
504 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
505 pReq->u.Internal.aArgs[2] = (uintptr_t)(ifclose); \
506 pReq->u.Internal.aArgs[3] = (uintptr_t)&(ret); \
507 pReq->fFlags = RTREQFLAGS_VOID; \
508 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
509 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
510 { \
511 SOCKET_UNLOCK(so); \
512 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
513 AssertReleaseRC(rc); \
514 SOCKET_LOCK(so); \
515 RTReqFree(pReq); \
516 } \
517 else \
518 AssertReleaseRC(rc); \
519 } while(0)
520
521# define DO_SOWRITE(ret, data, so) \
522 do { \
523 PRTREQ pReq = NULL; \
524 int rc; \
525 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
526 AssertReleaseRC(rc); \
527 pReq->u.Internal.pfn = (PFNRT)sowrite; \
528 pReq->u.Internal.cArgs = 2; \
529 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
530 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
531 pReq->fFlags = RTREQFLAGS_RETURN_MASK; \
532 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
533 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
534 { \
535 SOCKET_UNLOCK(so); \
536 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
537 SOCKET_LOCK(so); \
538 ret = pReq->iStatus; \
539 RTReqFree(pReq); \
540 } \
541 else \
542 AssertReleaseRC(rc); \
543 } while(0)
544
545# define DO_SORECFROM(data, so) \
546 do { \
547 PRTREQ pReq = NULL; \
548 int rc; \
549 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
550 AssertReleaseRC(rc); \
551 pReq->u.Internal.pfn = (PFNRT)sorecvfrom; \
552 pReq->u.Internal.cArgs = 2; \
553 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
554 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
555 pReq->fFlags = RTREQFLAGS_VOID; \
556 rc = RTReqQueue(pReq, 0); \
557 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
558 { \
559 SOCKET_UNLOCK(so); \
560 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
561 AssertReleaseRC(rc); \
562 SOCKET_LOCK(so); \
563 RTReqFree(pReq); \
564 } \
565 else \
566 AssertReleaseRC(rc); \
567 } while(0)
568
569# define DO_UDP_DETACH(data, so, so_next) \
570 do { \
571 PRTREQ pReq = NULL; \
572 int rc; \
573 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
574 AssertReleaseRC(rc); \
575 pReq->u.Internal.pfn = (PFNRT)udp_detach; \
576 pReq->u.Internal.cArgs = 2; \
577 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
578 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
579 pReq->fFlags = RTREQFLAGS_VOID; \
580 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
581 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
582 { \
583 SOCKET_UNLOCK(so); \
584 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
585 AssertReleaseRC(rc); \
586 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \
587 RTReqFree(pReq); \
588 } \
589 else \
590 AssertReleaseRC(rc); \
591 } while(0)
592
593# define SOLOOKUP(so, label, src, sport, dst, dport) \
594 do { \
595 struct socket *sonxt; \
596 (so) = NULL; \
597 QSOCKET_FOREACH(so, sonxt, label) \
598 /* { */ \
599 if ( so->so_lport == (sport) \
600 && so->so_laddr.s_addr == (src).s_addr \
601 && so->so_faddr.s_addr == (dst).s_addr \
602 && so->so_fport == (dport)) \
603 { \
604 if (sonxt != &VBOX_X2(queue_ ## label ## _label)) \
605 SOCKET_UNLOCK(sonxt); \
606 break; /*so is locked*/ \
607 } \
608 LOOP_LABEL(so, sonxt, label); \
609 } \
610 } \
611 } while (0)
612
613#else /* !VBOX_WITH_SLIRP_MT */
614
615# define QSOCKET_LOCK(queue) do {} while (0)
616# define QSOCKET_UNLOCK(queue) do {} while (0)
617# define QSOCKET_LOCK_CREATE(queue) do {} while (0)
618# define QSOCKET_LOCK_DESTROY(queue) do {} while (0)
619# define QSOCKET_FOREACH(so, sonext, label) \
620 for ((so) = VBOX_X2(queue_ ## label ## _label).so_next; \
621 (so) != &(VBOX_X2(queue_ ## label ## _label)); \
622 (so) = (sonext)) \
623 { \
624 (sonext) = (so)->so_next;
625# define CONTINUE(label) continue
626# define CONTINUE_NO_UNLOCK(label) continue
627# define LOOP_LABEL(label, so, sonext) /* empty*/
628# define DO_TCP_OUTPUT(data, sotcb) tcp_output((data), (sotcb))
629# define DO_TCP_INPUT(data, mbuf, size, so) tcp_input((data), (mbuf), (size), (so))
630# define DO_TCP_CONNECT(data, so) tcp_connect((data), (so))
631# define DO_SOREAD(ret, data, so, ifclose) \
632 do { \
633 (ret) = soread((data), (so), (ifclose)); \
634 } while(0)
635# define DO_SOWRITE(ret, data, so) \
636 do { \
637 (ret) = sowrite((data), (so)); \
638 } while(0)
639# define DO_SORECFROM(data, so) sorecvfrom((data), (so))
640# define SOLOOKUP(so, label, src, sport, dst, dport) \
641 do { \
642 (so) = solookup(&VBOX_X2(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \
643 } while (0)
644# define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so))
645
646#endif /* !VBOX_WITH_SLIRP_MT */
647
648#define TCP_OUTPUT(data, sotcb) DO_TCP_OUTPUT((data), (sotcb))
649#define TCP_INPUT(data, mbuf, size, so) DO_TCP_INPUT((data), (mbuf), (size), (so))
650#define TCP_CONNECT(data, so) DO_TCP_CONNECT((data), (so))
651#define SOREAD(ret, data, so, ifclose) DO_SOREAD((ret), (data), (so), (ifclose))
652#define SOWRITE(ret, data, so) DO_SOWRITE((ret), (data), (so))
653#define SORECVFROM(data, so) DO_SORECFROM((data), (so))
654#define UDP_DETACH(data, so, so_next) DO_UDP_DETACH((data), (so), (so_next))
655
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
683#define instancehead pData->instancehead
684
685#endif /* !___slirp_state_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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