VirtualBox

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

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

NAT: replacing dhcp_cache update with arp_cache,
leasing dhcp updates arp_cache.

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

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