VirtualBox

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

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

NAT: Slirp don't use ether address of guest anymore
instead it calculates ethernet address of destination
with lookup operation. Currently it's very simple looks
over send addresses via dhcp or assume destination in outer
network and gets Slirp's ethernet address.

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