VirtualBox

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

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

More PCI config register setters.

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