VirtualBox

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

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

NAT: dhcp rfc2131/rfc2132 step 1

  • 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#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#undef PROFILE_COUNTER
254#undef COUNTING_COUNTER
255
256} NATState;
257
258
259/** Default IP time to live. */
260#define ip_defttl IPDEFTTL
261
262/** Number of permanent buffers in mbuf. */
263#define mbuf_thresh 30
264
265/** Use a fixed time before sending keepalive. */
266#define tcp_keepidle TCPTV_KEEP_IDLE
267
268/** Use a fixed interval between keepalive. */
269#define tcp_keepintvl TCPTV_KEEPINTVL
270
271/** Maximum idle time before timing out a connection. */
272#define tcp_maxidle (TCPTV_KEEPCNT * tcp_keepintvl)
273
274/** Default TCP socket options. */
275#define so_options DO_KEEPALIVE
276
277/** Default TCP MSS value. */
278#define tcp_mssdflt TCP_MSS
279
280/** Default TCP round trip time. */
281#define tcp_rttdflt (TCPTV_SRTTDFLT / PR_SLOWHZ)
282
283/** Enable RFC1323 performance enhancements.
284 * @todo check if it really works, it was turned off before. */
285#define tcp_do_rfc1323 1
286
287/** TCP receive buffer size. */
288#define tcp_rcvspace pData->tcp_rcvspace
289
290/** TCP receive buffer size. */
291#define tcp_sndspace pData->tcp_sndspace
292
293/* TCP duplicate ACK retransmit threshold. */
294#define tcprexmtthresh 3
295
296
297#define bootp_filename pData->bootp_filename
298#define bootp_clients pData->bootp_clients
299
300#define if_mtu pData->if_mtu
301#define if_mru pData->if_mru
302#define if_comp pData->if_comp
303#define if_maxlinkhdr pData->if_maxlinkhdr
304#define if_queued pData->if_queued
305#define if_thresh pData->if_thresh
306#define if_fastq pData->if_fastq
307#define if_batchq pData->if_batchq
308#define next_m pData->next_m
309
310#define icmpstat pData->icmpstat
311
312#define ipstat pData->ipstat
313#define ipq pData->ipq
314#define ip_currid pData->ip_currid
315
316#define mbuf_alloced pData->mbuf_alloced
317#define mbuf_max pData->mbuf_max
318#define msize pData->msize
319#define m_freelist pData->m_freelist
320#define m_usedlist pData->m_usedlist
321
322#define curtime pData->curtime
323#define time_fasttimo pData->time_fasttimo
324#define last_slowtimo pData->last_slowtimo
325#define do_slowtimo pData->do_slowtimo
326#define link_up pData->link_up
327#define cUsers pData->cUsers
328#define tt pData->tt
329#define our_addr pData->our_addr
330#ifndef VBOX_SLIRP_ALIAS
331# define alias_addr pData->alias_addr
332#else
333# define handler_chain pData->handler_chain
334#endif
335#define special_addr pData->special_addr
336#define dns_addr pData->dns_addr
337#define loopback_addr pData->loopback_addr
338#define client_ethaddr pData->client_ethaddr
339#define exec_list pData->exec_list
340#define slirp_hostname pData->slirp_hostname
341
342#define tcb pData->tcb
343#define tcp_last_so pData->tcp_last_so
344#define tcp_iss pData->tcp_iss
345
346#define tcpstat pData->tcpstat
347#define tcp_now pData->tcp_now
348
349#define tftp_sessions pData->tftp_sessions
350#define tftp_prefix pData->tftp_prefix
351
352#define udpstat pData->udpstat
353#define udb pData->udb
354#define udp_last_so pData->udp_last_so
355
356#define maxfragsperpacket pData->maxfragsperpacket
357#define maxnipq pData->maxnipq
358#define nipq pData->nipq
359
360#define tcp_reass_qsize pData->tcp_reass_qsize
361#define tcp_reass_maxqlen pData->tcp_reass_maxqlen
362#define tcp_reass_maxseg pData->tcp_reass_maxseg
363#define tcp_reass_overflows pData->tcp_reass_overflows
364
365#define queue_tcp_label tcb
366#define queue_udp_label udb
367#define VBOX_X2(x) x
368#define VBOX_X(x) VBOX_X2(x)
369
370#ifdef VBOX_WITH_SLIRP_MT
371
372# define QSOCKET_LOCK(queue) \
373 do { \
374 int rc; \
375 /* Assert(strcmp(RTThreadSelfName(), "EMT") != 0); */ \
376 rc = RTCritSectEnter(&VBOX_X(queue) ## _mutex); \
377 AssertReleaseRC(rc); \
378 } while (0)
379# define QSOCKET_UNLOCK(queue) \
380 do { \
381 int rc; \
382 rc = RTCritSectLeave(&VBOX_X(queue) ## _mutex); \
383 AssertReleaseRC(rc); \
384 } while (0)
385# define QSOCKET_LOCK_CREATE(queue) \
386 do { \
387 int rc; \
388 rc = RTCritSectInit(&pData->queue ## _mutex); \
389 AssertReleaseRC(rc); \
390 } while (0)
391# define QSOCKET_LOCK_DESTROY(queue) \
392 do { \
393 int rc = RTCritSectDelete(&pData->queue ## _mutex); \
394 AssertReleaseRC(rc); \
395 } while (0)
396
397# define QSOCKET_FOREACH(so, sonext, label) \
398 QSOCKET_LOCK(VBOX_X2(queue_## label ## _label)); \
399 (so) = (VBOX_X(queue_ ## label ## _label)).so_next; \
400 QSOCKET_UNLOCK(VBOX_X2(queue_## label ##_label)); \
401 if ((so) != &(VBOX_X(queue_## label ## _label))) SOCKET_LOCK((so));\
402 for (;;) \
403 { \
404 if ((so) == &(VBOX_X(queue_## label ## _label))) \
405 { \
406 break; \
407 } \
408 Log2(("%s:%d Processing so:%R[natsock]\n", __FUNCTION__, __LINE__, (so)));
409
410# define CONTINUE_NO_UNLOCK(label) goto loop_end_ ## label ## _mt_nounlock
411# define CONTINUE(label) goto loop_end_ ## label ## _mt
412/* @todo replace queue parameter with macrodinition */
413/* _mt_nounlock - user should lock so_next before calling CONTINUE_NO_UNLOCK */
414# define LOOP_LABEL(label, so, sonext) loop_end_ ## label ## _mt: \
415 (sonext) = (so)->so_next; \
416 SOCKET_UNLOCK(so); \
417 QSOCKET_LOCK(VBOX_X(queue_ ## label ## _label)); \
418 if ((sonext) != &(VBOX_X(queue_## label ## _label))) \
419 { \
420 SOCKET_LOCK((sonext)); \
421 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
422 } \
423 else \
424 { \
425 so = &VBOX_X(queue_ ## label ## _label); \
426 QSOCKET_UNLOCK(VBOX_X(queue_ ## label ## _label)); \
427 break; \
428 } \
429 (so) = (sonext); \
430 continue; \
431 loop_end_ ## label ## _mt_nounlock: \
432 (so) = (sonext)
433
434# define DO_TCP_OUTPUT(data, sotcb) \
435 do { \
436 PRTREQ pReq = NULL; \
437 int rc; \
438 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
439 AssertReleaseRC(rc); \
440 pReq->u.Internal.pfn = (PFNRT)tcp_output; \
441 pReq->u.Internal.cArgs = 2; \
442 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
443 pReq->u.Internal.aArgs[1] = (uintptr_t)(sotcb); \
444 pReq->fFlags = RTREQFLAGS_VOID; \
445 rc = RTReqQueue(pReq, 0); \
446 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
447 { \
448 SOCKET_UNLOCK(so); \
449 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
450 AssertReleaseRC(rc); \
451 SOCKET_LOCK(so); \
452 RTReqFree(pReq); \
453 } \
454 else \
455 AssertReleaseRC(rc); \
456} while(0)
457
458# define DO_TCP_INPUT(data, mbuf, size, so) \
459 do { \
460 PRTREQ pReq = NULL; \
461 int rc; \
462 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
463 AssertReleaseRC(rc); \
464 pReq->u.Internal.pfn = (PFNRT)tcp_input; \
465 pReq->u.Internal.cArgs = 4; \
466 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
467 pReq->u.Internal.aArgs[1] = (uintptr_t)(mbuf); \
468 pReq->u.Internal.aArgs[2] = (uintptr_t)(size); \
469 pReq->u.Internal.aArgs[3] = (uintptr_t)(so); \
470 pReq->fFlags = RTREQFLAGS_VOID|RTREQFLAGS_NO_WAIT; \
471 rc = RTReqQueue(pReq, 0); \
472 AssertReleaseRC(rc); \
473 } while(0)
474
475# define DO_TCP_CONNECT(data, so) \
476 do { \
477 PRTREQ pReq = NULL; \
478 int rc; \
479 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
480 AssertReleaseRC(rc); \
481 pReq->u.Internal.pfn = (PFNRT)tcp_connect; \
482 pReq->u.Internal.cArgs = 2; \
483 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
484 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
485 pReq->fFlags = RTREQFLAGS_VOID; \
486 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
487 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
488 { \
489 SOCKET_UNLOCK(so); \
490 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
491 AssertReleaseRC(rc); \
492 SOCKET_LOCK(so); \
493 RTReqFree(pReq); \
494 } \
495 else \
496 AssertReleaseRC(rc); \
497 } while(0)
498
499# define DO_SOREAD(ret, data, so, ifclose) \
500 do { \
501 PRTREQ pReq = NULL; \
502 int rc; \
503 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
504 AssertReleaseRC(rc); \
505 pReq->u.Internal.pfn = (PFNRT)soread_queue; \
506 pReq->u.Internal.cArgs = 4; \
507 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
508 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
509 pReq->u.Internal.aArgs[2] = (uintptr_t)(ifclose); \
510 pReq->u.Internal.aArgs[3] = (uintptr_t)&(ret); \
511 pReq->fFlags = RTREQFLAGS_VOID; \
512 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
513 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
514 { \
515 SOCKET_UNLOCK(so); \
516 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
517 AssertReleaseRC(rc); \
518 SOCKET_LOCK(so); \
519 RTReqFree(pReq); \
520 } \
521 else \
522 AssertReleaseRC(rc); \
523 } while(0)
524
525# define DO_SOWRITE(ret, data, so) \
526 do { \
527 PRTREQ pReq = NULL; \
528 int rc; \
529 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
530 AssertReleaseRC(rc); \
531 pReq->u.Internal.pfn = (PFNRT)sowrite; \
532 pReq->u.Internal.cArgs = 2; \
533 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
534 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
535 pReq->fFlags = RTREQFLAGS_RETURN_MASK; \
536 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
537 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
538 { \
539 SOCKET_UNLOCK(so); \
540 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
541 SOCKET_LOCK(so); \
542 ret = pReq->iStatus; \
543 RTReqFree(pReq); \
544 } \
545 else \
546 AssertReleaseRC(rc); \
547 } while(0)
548
549# define DO_SORECFROM(data, so) \
550 do { \
551 PRTREQ pReq = NULL; \
552 int rc; \
553 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
554 AssertReleaseRC(rc); \
555 pReq->u.Internal.pfn = (PFNRT)sorecvfrom; \
556 pReq->u.Internal.cArgs = 2; \
557 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
558 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
559 pReq->fFlags = RTREQFLAGS_VOID; \
560 rc = RTReqQueue(pReq, 0); \
561 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
562 { \
563 SOCKET_UNLOCK(so); \
564 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
565 AssertReleaseRC(rc); \
566 SOCKET_LOCK(so); \
567 RTReqFree(pReq); \
568 } \
569 else \
570 AssertReleaseRC(rc); \
571 } while(0)
572
573# define DO_UDP_DETACH(data, so, so_next) \
574 do { \
575 PRTREQ pReq = NULL; \
576 int rc; \
577 rc = RTReqAlloc((data)->pReqQueue, &pReq, RTREQTYPE_INTERNAL); \
578 AssertReleaseRC(rc); \
579 pReq->u.Internal.pfn = (PFNRT)udp_detach; \
580 pReq->u.Internal.cArgs = 2; \
581 pReq->u.Internal.aArgs[0] = (uintptr_t)(data); \
582 pReq->u.Internal.aArgs[1] = (uintptr_t)(so); \
583 pReq->fFlags = RTREQFLAGS_VOID; \
584 rc = RTReqQueue(pReq, 0); /* don't wait, we have to release lock before*/ \
585 if (RT_LIKELY(rc) == VERR_TIMEOUT) \
586 { \
587 SOCKET_UNLOCK(so); \
588 rc = RTReqWait(pReq, RT_INDEFINITE_WAIT); \
589 AssertReleaseRC(rc); \
590 if ((so_next) != &udb) SOCKET_LOCK((so_next)); \
591 RTReqFree(pReq); \
592 } \
593 else \
594 AssertReleaseRC(rc); \
595 } while(0)
596
597# define SOLOOKUP(so, label, src, sport, dst, dport) \
598 do { \
599 struct socket *sonxt; \
600 (so) = NULL; \
601 QSOCKET_FOREACH(so, sonxt, label) \
602 /* { */ \
603 if ( so->so_lport == (sport) \
604 && so->so_laddr.s_addr == (src).s_addr \
605 && so->so_faddr.s_addr == (dst).s_addr \
606 && so->so_fport == (dport)) \
607 { \
608 if (sonxt != &VBOX_X2(queue_ ## label ## _label)) \
609 SOCKET_UNLOCK(sonxt); \
610 break; /*so is locked*/ \
611 } \
612 LOOP_LABEL(so, sonxt, label); \
613 } \
614 } \
615 } while (0)
616
617#else /* !VBOX_WITH_SLIRP_MT */
618
619# define QSOCKET_LOCK(queue) do {} while (0)
620# define QSOCKET_UNLOCK(queue) do {} while (0)
621# define QSOCKET_LOCK_CREATE(queue) do {} while (0)
622# define QSOCKET_LOCK_DESTROY(queue) do {} while (0)
623# define QSOCKET_FOREACH(so, sonext, label) \
624 for ((so) = VBOX_X2(queue_ ## label ## _label).so_next; \
625 (so) != &(VBOX_X2(queue_ ## label ## _label)); \
626 (so) = (sonext)) \
627 { \
628 (sonext) = (so)->so_next;
629# define CONTINUE(label) continue
630# define CONTINUE_NO_UNLOCK(label) continue
631# define LOOP_LABEL(label, so, sonext) /* empty*/
632# define DO_TCP_OUTPUT(data, sotcb) tcp_output((data), (sotcb))
633# define DO_TCP_INPUT(data, mbuf, size, so) tcp_input((data), (mbuf), (size), (so))
634# define DO_TCP_CONNECT(data, so) tcp_connect((data), (so))
635# define DO_SOREAD(ret, data, so, ifclose) \
636 do { \
637 (ret) = soread((data), (so), (ifclose)); \
638 } while(0)
639# define DO_SOWRITE(ret, data, so) \
640 do { \
641 (ret) = sowrite((data), (so)); \
642 } while(0)
643# define DO_SORECFROM(data, so) sorecvfrom((data), (so))
644# define SOLOOKUP(so, label, src, sport, dst, dport) \
645 do { \
646 (so) = solookup(&VBOX_X2(queue_ ## label ## _label), (src), (sport), (dst), (dport)); \
647 } while (0)
648# define DO_UDP_DETACH(data, so, ignored) udp_detach((data), (so))
649
650#endif /* !VBOX_WITH_SLIRP_MT */
651
652#define TCP_OUTPUT(data, sotcb) DO_TCP_OUTPUT((data), (sotcb))
653#define TCP_INPUT(data, mbuf, size, so) DO_TCP_INPUT((data), (mbuf), (size), (so))
654#define TCP_CONNECT(data, so) DO_TCP_CONNECT((data), (so))
655#define SOREAD(ret, data, so, ifclose) DO_SOREAD((ret), (data), (so), (ifclose))
656#define SOWRITE(ret, data, so) DO_SOWRITE((ret), (data), (so))
657#define SORECVFROM(data, so) DO_SORECFROM((data), (so))
658#define UDP_DETACH(data, so, so_next) DO_UDP_DETACH((data), (so), (so_next))
659
660/* dnsproxy/dnsproxy.c */
661#define authoritative_port pData->authoritative_port
662#define authoritative_timeout pData->authoritative_timeout
663#define recursive_port pData->recursive_port
664#define recursive_timeout pData->recursive_timeout
665#define stats_timeout pData->stats_timeout
666/* dnsproxy/hash.c */
667#define dns_port pData->port
668#define request_hash pData->request_hash
669#define hash_collisions pData->hash_collisions
670#define active_queries pData->active_queries
671#define all_queries pData->all_queries
672#define authoritative_queries pData->authoritative_queries
673#define recursive_queries pData->recursive_queries
674#define removed_queries pData->removed_queries
675#define dropped_queries pData->dropped_queries
676#define answered_queries pData->answered_queries
677#define dropped_answers pData->dropped_answers
678#define late_answers pData->late_answers
679
680/* dnsproxy/dnsproxy.c */
681#define queryid pData->queryid
682#define authoritative_addr pData->authoritative_addr
683#define recursive_addr pData->recursive_addr
684#define sock_query pData->sock_query
685#define sock_answer pData->sock_answer
686
687#define instancehead pData->instancehead
688
689#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