VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/DrvNAT.cpp@ 9391

Last change on this file since 9391 was 9336, checked in by vboxsync, 17 years ago

oops, left at stdint.h include in there.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.4 KB
Line 
1/** @file
2 *
3 * VBox network devices:
4 * NAT network transport driver
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27#define LOG_GROUP LOG_GROUP_DRV_NAT
28#define __STDC_LIMIT_MACROS
29#define __STDC_CONSTANT_MACROS
30#include "Network/slirp/libslirp.h"
31#include <VBox/pdmdrv.h>
32#include <iprt/assert.h>
33#include <iprt/file.h>
34#include <iprt/string.h>
35#include <iprt/critsect.h>
36#include <iprt/cidr.h>
37
38#include "Builtins.h"
39
40
41/*******************************************************************************
42* Structures and Typedefs *
43*******************************************************************************/
44/**
45 * NAT network transport driver instance data.
46 */
47typedef struct DRVNAT
48{
49 /** The network interface. */
50 PDMINETWORKCONNECTOR INetworkConnector;
51 /** The port we're attached to. */
52 PPDMINETWORKPORT pPort;
53 /** The network config of the port we're attached to. */
54 PPDMINETWORKCONFIG pConfig;
55 /** Pointer to the driver instance. */
56 PPDMDRVINS pDrvIns;
57 /** Slirp critical section. */
58 RTCRITSECT CritSect;
59 /** Link state */
60 PDMNETWORKLINKSTATE enmLinkState;
61 /** NAT state for this instance. */
62 PNATState pNATState;
63 /** TFTP directory prefix. */
64 char *pszTFTPPrefix;
65 /** Boot file name to provide in the DHCP server response. */
66 char *pszBootFile;
67} DRVNAT, *PDRVNAT;
68
69/** Converts a pointer to NAT::INetworkConnector to a PRDVNAT. */
70#define PDMINETWORKCONNECTOR_2_DRVNAT(pInterface) ( (PDRVNAT)((uintptr_t)pInterface - RT_OFFSETOF(DRVNAT, INetworkConnector)) )
71
72
73/*******************************************************************************
74* Global Variables *
75*******************************************************************************/
76#if 0
77/** If set the thread should terminate. */
78static bool g_fThreadTerm = false;
79/** The thread id of the select thread (drvNATSelectThread()). */
80static RTTHREAD g_ThreadSelect;
81#endif
82
83
84/**
85 * Send data to the network.
86 *
87 * @returns VBox status code.
88 * @param pInterface Pointer to the interface structure containing the called function pointer.
89 * @param pvBuf Data to send.
90 * @param cb Number of bytes to send.
91 * @thread EMT
92 */
93static DECLCALLBACK(int) drvNATSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
94{
95 PDRVNAT pData = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
96
97 LogFlow(("drvNATSend: pvBuf=%p cb=%#x\n", pvBuf, cb));
98 Log2(("drvNATSend: pvBuf=%p cb=%#x\n"
99 "%.*Vhxd\n",
100 pvBuf, cb, cb, pvBuf));
101
102 int rc = RTCritSectEnter(&pData->CritSect);
103 AssertReleaseRC(rc);
104
105 Assert(pData->enmLinkState == PDMNETWORKLINKSTATE_UP);
106 if (pData->enmLinkState == PDMNETWORKLINKSTATE_UP)
107 slirp_input(pData->pNATState, (uint8_t *)pvBuf, cb);
108 RTCritSectLeave(&pData->CritSect);
109 LogFlow(("drvNATSend: end\n"));
110 return VINF_SUCCESS;
111}
112
113
114/**
115 * Set promiscuous mode.
116 *
117 * This is called when the promiscuous mode is set. This means that there doesn't have
118 * to be a mode change when it's called.
119 *
120 * @param pInterface Pointer to the interface structure containing the called function pointer.
121 * @param fPromiscuous Set if the adaptor is now in promiscuous mode. Clear if it is not.
122 * @thread EMT
123 */
124static DECLCALLBACK(void) drvNATSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
125{
126 LogFlow(("drvNATSetPromiscuousMode: fPromiscuous=%d\n", fPromiscuous));
127 /* nothing to do */
128}
129
130
131/**
132 * Notification on link status changes.
133 *
134 * @param pInterface Pointer to the interface structure containing the called function pointer.
135 * @param enmLinkState The new link state.
136 * @thread EMT
137 */
138static DECLCALLBACK(void) drvNATNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
139{
140 PDRVNAT pData = PDMINETWORKCONNECTOR_2_DRVNAT(pInterface);
141
142 LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
143
144 int rc = RTCritSectEnter(&pData->CritSect);
145 AssertReleaseRC(rc);
146 pData->enmLinkState = enmLinkState;
147
148 switch (enmLinkState)
149 {
150 case PDMNETWORKLINKSTATE_UP:
151 LogRel(("NAT: link up\n"));
152 slirp_link_up(pData->pNATState);
153 break;
154
155 case PDMNETWORKLINKSTATE_DOWN:
156 case PDMNETWORKLINKSTATE_DOWN_RESUME:
157 LogRel(("NAT: link down\n"));
158 slirp_link_down(pData->pNATState);
159 break;
160
161 default:
162 AssertMsgFailed(("drvNATNotifyLinkChanged: unexpected link state %d\n", enmLinkState));
163 }
164 RTCritSectLeave(&pData->CritSect);
165}
166
167
168/**
169 * Poller callback.
170 */
171static DECLCALLBACK(void) drvNATPoller(PPDMDRVINS pDrvIns)
172{
173 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
174 fd_set ReadFDs;
175 fd_set WriteFDs;
176 fd_set XcptFDs;
177 int cFDs = -1;
178 FD_ZERO(&ReadFDs);
179 FD_ZERO(&WriteFDs);
180 FD_ZERO(&XcptFDs);
181
182 int rc = RTCritSectEnter(&pData->CritSect);
183 AssertReleaseRC(rc);
184
185 slirp_select_fill(pData->pNATState, &cFDs, &ReadFDs, &WriteFDs, &XcptFDs);
186
187 struct timeval tv = {0, 0}; /* no wait */
188 int cReadFDs = select(cFDs + 1, &ReadFDs, &WriteFDs, &XcptFDs, &tv);
189 if (cReadFDs >= 0)
190 slirp_select_poll(pData->pNATState, &ReadFDs, &WriteFDs, &XcptFDs);
191
192 RTCritSectLeave(&pData->CritSect);
193}
194
195
196/**
197 * Function called by slirp to check if it's possible to feed incoming data to the network port.
198 * @returns 1 if possible.
199 * @returns 0 if not possible.
200 */
201int slirp_can_output(void *pvUser)
202{
203 PDRVNAT pData = (PDRVNAT)pvUser;
204
205 Assert(pData);
206
207 /** Happens during termination */
208 if (!RTCritSectIsOwner(&pData->CritSect))
209 return 0;
210
211 int rc = pData->pPort->pfnWaitReceiveAvail(pData->pPort, 0);
212 return RT_SUCCESS(rc);
213}
214
215
216/**
217 * Function called by slirp to feed incoming data to the network port.
218 */
219void slirp_output(void *pvUser, const uint8_t *pu8Buf, int cb)
220{
221 PDRVNAT pData = (PDRVNAT)pvUser;
222
223 LogFlow(("slirp_output BEGIN %x %d\n", pu8Buf, cb));
224 Log2(("slirp_output: pu8Buf=%p cb=%#x (pData=%p)\n"
225 "%.*Vhxd\n",
226 pu8Buf, cb, pData,
227 cb, pu8Buf));
228
229 Assert(pData);
230
231 /** Happens during termination */
232 if (!RTCritSectIsOwner(&pData->CritSect))
233 return;
234
235 int rc = pData->pPort->pfnReceive(pData->pPort, pu8Buf, cb);
236 AssertRC(rc);
237 LogFlow(("slirp_output END %x %d\n", pu8Buf, cb));
238}
239
240/**
241 * Queries an interface to the driver.
242 *
243 * @returns Pointer to interface.
244 * @returns NULL if the interface was not supported by the driver.
245 * @param pInterface Pointer to this interface structure.
246 * @param enmInterface The requested interface identification.
247 * @thread Any thread.
248 */
249static DECLCALLBACK(void *) drvNATQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
250{
251 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
252 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
253 switch (enmInterface)
254 {
255 case PDMINTERFACE_BASE:
256 return &pDrvIns->IBase;
257 case PDMINTERFACE_NETWORK_CONNECTOR:
258 return &pData->INetworkConnector;
259 default:
260 return NULL;
261 }
262}
263
264
265/**
266 * Destruct a driver instance.
267 *
268 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
269 * resources can be freed correctly.
270 *
271 * @param pDrvIns The driver instance data.
272 */
273static DECLCALLBACK(void) drvNATDestruct(PPDMDRVINS pDrvIns)
274{
275 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
276
277 LogFlow(("drvNATDestruct:\n"));
278
279 int rc = RTCritSectEnter(&pData->CritSect);
280 AssertReleaseRC(rc);
281 slirp_term(pData->pNATState);
282 pData->pNATState = NULL;
283 RTCritSectLeave(&pData->CritSect);
284
285 RTCritSectDelete(&pData->CritSect);
286}
287
288
289/**
290 * Sets up the redirectors.
291 *
292 * @returns VBox status code.
293 * @param pCfgHandle The drivers configuration handle.
294 */
295static int drvNATConstructRedir(unsigned iInstance, PDRVNAT pData, PCFGMNODE pCfgHandle)
296{
297 /*
298 * Enumerate redirections.
299 */
300 for (PCFGMNODE pNode = CFGMR3GetFirstChild(pCfgHandle); pNode; pNode = CFGMR3GetNextChild(pNode))
301 {
302 /*
303 * Validate the port forwarding config.
304 */
305 if (!CFGMR3AreValuesValid(pNode, "Protocol\0UDP\0HostPort\0GuestPort\0GuestIP\0"))
306 return PDMDRV_SET_ERROR(pData->pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, N_("Unknown configuration in port forwarding"));
307
308 /* protocol type */
309 bool fUDP;
310 char szProtocol[32];
311 int rc = CFGMR3QueryString(pNode, "Protocol", &szProtocol[0], sizeof(szProtocol));
312 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
313 {
314 rc = CFGMR3QueryBool(pNode, "UDP", &fUDP);
315 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
316 fUDP = false;
317 else if (VBOX_FAILURE(rc))
318 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"UDP\" boolean failed"), iInstance);
319 }
320 else if (VBOX_SUCCESS(rc))
321 {
322 if (!RTStrICmp(szProtocol, "TCP"))
323 fUDP = false;
324 else if (!RTStrICmp(szProtocol, "UDP"))
325 fUDP = true;
326 else
327 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("NAT#%d: Invalid configuration value for \"Protocol\": \"%s\""), iInstance, szProtocol);
328 }
329 else
330 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"Protocol\" string failed"), iInstance);
331
332 /* host port */
333 int32_t iHostPort;
334 rc = CFGMR3QueryS32(pNode, "HostPort", &iHostPort);
335 if (VBOX_FAILURE(rc))
336 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"HostPort\" integer failed"), iInstance);
337
338 /* guest port */
339 int32_t iGuestPort;
340 rc = CFGMR3QueryS32(pNode, "GuestPort", &iGuestPort);
341 if (VBOX_FAILURE(rc))
342 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestPort\" integer failed"), iInstance);
343
344 /* guest address */
345 char szGuestIP[32];
346 rc = CFGMR3QueryString(pNode, "GuestIP", &szGuestIP[0], sizeof(szGuestIP));
347 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
348 strcpy(szGuestIP, "10.0.2.15");
349 else if (VBOX_FAILURE(rc))
350 return PDMDrvHlpVMSetError(pData->pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"GuestIP\" string failed"), iInstance);
351 struct in_addr GuestIP;
352 if (!inet_aton(szGuestIP, &GuestIP))
353 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_NAT_REDIR_GUEST_IP, RT_SRC_POS, N_("NAT#%d: configuration error: invalid \"GuestIP\"=\"%s\", inet_aton failed"), iInstance, szGuestIP);
354
355 /*
356 * Call slirp about it.
357 */
358 Log(("drvNATConstruct: Redir %d -> %s:%d\n", iHostPort, szGuestIP, iGuestPort));
359 if (slirp_redir(pData->pNATState, fUDP, iHostPort, GuestIP, iGuestPort) < 0)
360 return PDMDrvHlpVMSetError(pData->pDrvIns, VERR_NAT_REDIR_SETUP, RT_SRC_POS, N_("NAT#%d: configuration error: failed to set up redirection of %d to %s:%d. Probably a conflict with existing services or other rules"), iInstance, iHostPort, szGuestIP, iGuestPort);
361 } /* for each redir rule */
362
363 return VINF_SUCCESS;
364}
365
366/**
367 * Get the MAC address into the slirp stack.
368 */
369static void drvNATSetMac(PDRVNAT pData)
370{
371 if (pData->pConfig)
372 {
373 PDMMAC Mac;
374 pData->pConfig->pfnGetMac(pData->pConfig, &Mac);
375 slirp_set_ethaddr(pData->pNATState, Mac.au8);
376 }
377}
378
379
380/**
381 * After loading we have to pass the MAC address of the ethernet device to the slirp stack.
382 * Otherwise the guest is not reachable until it performs a DHCP request or an ARP request
383 * (usually done during guest boot).
384 */
385static DECLCALLBACK(int) drvNATLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSMHandle)
386{
387 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
388 drvNATSetMac(pData);
389 return VINF_SUCCESS;
390}
391
392
393/**
394 * Some guests might not use DHCP to retrieve an IP but use a static IP.
395 */
396static DECLCALLBACK(void) drvNATPowerOn(PPDMDRVINS pDrvIns)
397{
398 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
399 drvNATSetMac(pData);
400}
401
402
403/**
404 * Construct a NAT network transport driver instance.
405 *
406 * @returns VBox status.
407 * @param pDrvIns The driver instance data.
408 * If the registration structure is needed, pDrvIns->pDrvReg points to it.
409 * @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
410 * of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
411 * iInstance it's expected to be used a bit in this function.
412 */
413static DECLCALLBACK(int) drvNATConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
414{
415 PDRVNAT pData = PDMINS2DATA(pDrvIns, PDRVNAT);
416 char szNetAddr[16];
417 char szNetwork[32]; /* xxx.xxx.xxx.xxx/yy */
418 LogFlow(("drvNATConstruct:\n"));
419
420 /*
421 * Validate the config.
422 */
423 if (!CFGMR3AreValuesValid(pCfgHandle, "PassDomain\0TFTPPrefix\0BootFile\0Network\0"))
424 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, N_("Unknown NAT configuration option, only supports PassDomain, TFTPPrefix, BootFile and Network"));
425
426 /*
427 * Init the static parts.
428 */
429 pData->pDrvIns = pDrvIns;
430 pData->pNATState = NULL;
431 pData->pszTFTPPrefix = NULL;
432 pData->pszBootFile = NULL;
433 /* IBase */
434 pDrvIns->IBase.pfnQueryInterface = drvNATQueryInterface;
435 /* INetwork */
436 pData->INetworkConnector.pfnSend = drvNATSend;
437 pData->INetworkConnector.pfnSetPromiscuousMode = drvNATSetPromiscuousMode;
438 pData->INetworkConnector.pfnNotifyLinkChanged = drvNATNotifyLinkChanged;
439
440 /*
441 * Get the configuration settings.
442 */
443 bool fPassDomain = true;
444 int rc = CFGMR3QueryBool(pCfgHandle, "PassDomain", &fPassDomain);
445 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
446 fPassDomain = true;
447 else if (VBOX_FAILURE(rc))
448 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"PassDomain\" boolean failed"), pDrvIns->iInstance);
449
450 rc = CFGMR3QueryStringAlloc(pCfgHandle, "TFTPPrefix", &pData->pszTFTPPrefix);
451 if (VBOX_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND)
452 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"TFTPPrefix\" string failed"), pDrvIns->iInstance);
453 rc = CFGMR3QueryStringAlloc(pCfgHandle, "BootFile", &pData->pszBootFile);
454 if (VBOX_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND)
455 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"BootFile\" string failed"), pDrvIns->iInstance);
456
457 /*
458 * Query the network port interface.
459 */
460 pData->pPort = (PPDMINETWORKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_PORT);
461 if (!pData->pPort)
462 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
463 N_("Configuration error: the above device/driver didn't export the network port interface"));
464 pData->pConfig = (PPDMINETWORKCONFIG)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_NETWORK_CONFIG);
465 if (!pData->pConfig)
466 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
467 N_("Configuration error: the above device/driver didn't export the network config interface"));
468
469 /* Generate a network address for this network card. */
470 rc = CFGMR3QueryString(pCfgHandle, "Network", szNetwork, sizeof(szNetwork));
471 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
472 RTStrPrintf(szNetwork, sizeof(szNetwork), "10.0.%d.0/24", pDrvIns->iInstance + 2);
473 else if (VBOX_FAILURE(rc))
474 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: configuration query for \"Network\" string failed"), pDrvIns->iInstance);
475
476 RTIPV4ADDR Network;
477 RTIPV4ADDR Netmask;
478 rc = RTCidrStrToIPv4(szNetwork, &Network, &Netmask);
479 if (RT_FAILURE(rc))
480 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("NAT#%d: Configuration error: network '%s' describes not a valid IPv4 network"), pDrvIns->iInstance, szNetwork);
481
482 RTStrPrintf(szNetAddr, sizeof(szNetAddr), "%d.%d.%d.%d",
483 (Network & 0xFF000000) >> 24, (Network & 0xFF0000) >> 16, (Network & 0xFF00) >> 8, Network & 0xFF);
484
485 /*
486 * The slirp lock..
487 */
488 rc = RTCritSectInit(&pData->CritSect);
489 if (VBOX_FAILURE(rc))
490 return rc;
491#if 0
492 rc = RTSemEventCreate(&g_EventSem);
493 if (VBOX_SUCCESS(rc))
494 {
495 /*
496 * Start the select thread. (it'll block on the sem)
497 */
498 g_fThreadTerm = false;
499 rc = RTThreadCreate(&g_ThreadSelect, drvNATSelectThread, 0, NULL, "NATSEL");
500 if (VBOX_SUCCESS(rc))
501 {
502#endif
503 /*
504 * Initialize slirp.
505 */
506 rc = slirp_init(&pData->pNATState, &szNetAddr[0], Netmask, fPassDomain, pData->pszTFTPPrefix, pData->pszBootFile, pData);
507 if (VBOX_SUCCESS(rc))
508 {
509 int rc2 = drvNATConstructRedir(pDrvIns->iInstance, pData, pCfgHandle);
510 if (VBOX_SUCCESS(rc2))
511 {
512 /*
513 * Register a load done notification to get the MAC address into the slirp
514 * engine after we loaded a guest state.
515 */
516 rc2 = PDMDrvHlpSSMRegister(pDrvIns, pDrvIns->pDrvReg->szDriverName,
517 pDrvIns->iInstance, 0, 0,
518 NULL, NULL, NULL, NULL, NULL, drvNATLoadDone);
519 AssertRC(rc2);
520 pDrvIns->pDrvHlp->pfnPDMPollerRegister(pDrvIns, drvNATPoller);
521
522 pData->enmLinkState = PDMNETWORKLINKSTATE_UP;
523#if 0
524 RTSemEventSignal(g_EventSem);
525 RTThreadSleep(0);
526#endif
527 /* might return VINF_NAT_DNS */
528 return rc;
529 }
530 /* failure path */
531 rc = rc2;
532 slirp_term(pData->pNATState);
533 pData->pNATState = NULL;
534 }
535 else
536 {
537 PDMDRV_SET_ERROR(pDrvIns, rc, N_("Unknown error during NAT networking setup: "));
538 AssertMsgFailed(("Add error message for rc=%d (%Vrc)\n", rc, rc));
539 }
540#if 0
541 g_fThreadTerm = true;
542 RTSemEventSignal(g_EventSem);
543 RTThreadSleep(0);
544 }
545 RTSemEventDestroy(g_EventSem);
546 g_EventSem = NULL;
547 }
548#endif
549 RTCritSectDelete(&pData->CritSect);
550 return rc;
551}
552
553
554
555/**
556 * NAT network transport driver registration record.
557 */
558const PDMDRVREG g_DrvNAT =
559{
560 /* u32Version */
561 PDM_DRVREG_VERSION,
562 /* szDriverName */
563 "NAT",
564 /* pszDescription */
565 "NAT Network Transport Driver",
566 /* fFlags */
567 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
568 /* fClass. */
569 PDM_DRVREG_CLASS_NETWORK,
570 /* cMaxInstances */
571 16,
572 /* cbInstance */
573 sizeof(DRVNAT),
574 /* pfnConstruct */
575 drvNATConstruct,
576 /* pfnDestruct */
577 drvNATDestruct,
578 /* pfnIOCtl */
579 NULL,
580 /* pfnPowerOn */
581 drvNATPowerOn,
582 /* pfnReset */
583 NULL,
584 /* pfnSuspend */
585 NULL,
586 /* pfnResume */
587 NULL,
588 /* pfnDetach */
589 NULL,
590 /* pfnPowerOff */
591 NULL
592};
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