VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/DrvTAP.cpp@ 25981

Last change on this file since 25981 was 25981, checked in by vboxsync, 15 years ago

pdmifs.h: yet another batch of refactored interface ID code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.9 KB
Line 
1/* $Id: DrvTAP.cpp 25981 2010-01-22 18:42:01Z vboxsync $ */
2/** @file
3 * DrvTAP - Universial TAP network transport driver.
4 */
5
6/*
7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#define LOG_GROUP LOG_GROUP_DRV_TUN
26#include <VBox/log.h>
27#include <VBox/pdmdrv.h>
28
29#include <iprt/asm.h>
30#include <iprt/assert.h>
31#include <iprt/ctype.h>
32#include <iprt/file.h>
33#include <iprt/path.h>
34#include <iprt/semaphore.h>
35#include <iprt/string.h>
36#include <iprt/thread.h>
37#include <iprt/uuid.h>
38#ifdef RT_OS_SOLARIS
39# include <iprt/process.h>
40# include <iprt/env.h>
41# ifdef VBOX_WITH_CROSSBOW
42# include <iprt/mem.h>
43# endif
44#endif
45
46#include <sys/ioctl.h>
47#include <sys/poll.h>
48#ifdef RT_OS_SOLARIS
49# include <sys/stat.h>
50# include <sys/ethernet.h>
51# include <sys/sockio.h>
52# include <netinet/in.h>
53# include <netinet/in_systm.h>
54# include <netinet/ip.h>
55# include <netinet/ip_icmp.h>
56# include <netinet/udp.h>
57# include <netinet/tcp.h>
58# include <net/if.h>
59# include <stropts.h>
60# include <fcntl.h>
61# include <stdlib.h>
62# include <stdio.h>
63# ifdef VBOX_WITH_CROSSBOW
64# include "solaris/vbox-libdlpi.h"
65# endif
66#else
67# include <sys/fcntl.h>
68#endif
69#include <errno.h>
70#include <unistd.h>
71
72#ifdef RT_OS_L4
73# include <l4/vboxserver/file.h>
74#endif
75
76#include "Builtins.h"
77
78
79/*******************************************************************************
80* Structures and Typedefs *
81*******************************************************************************/
82/**
83 * TAP driver instance data.
84 *
85 * @implements PDMINETWORKCONNECTOR
86 */
87typedef struct DRVTAP
88{
89 /** The network interface. */
90 PDMINETWORKCONNECTOR INetworkConnector;
91 /** The network interface. */
92 PPDMINETWORKPORT pPort;
93 /** Pointer to the driver instance. */
94 PPDMDRVINS pDrvIns;
95 /** TAP device file handle. */
96 RTFILE FileDevice;
97 /** The configured TAP device name. */
98 char *pszDeviceName;
99#ifdef RT_OS_SOLARIS
100# ifdef VBOX_WITH_CROSSBOW
101 /** Crossbow: MAC address of the device. */
102 RTMAC MacAddress;
103 /** Crossbow: Handle of the NIC. */
104 dlpi_handle_t pDeviceHandle;
105# else
106 /** IP device file handle (/dev/udp). */
107 RTFILE IPFileDevice;
108# endif
109 /** Whether device name is obtained from setup application. */
110 bool fStatic;
111#endif
112 /** TAP setup application. */
113 char *pszSetupApplication;
114 /** TAP terminate application. */
115 char *pszTerminateApplication;
116 /** The write end of the control pipe. */
117 RTFILE PipeWrite;
118 /** The read end of the control pipe. */
119 RTFILE PipeRead;
120 /** Reader thread. */
121 PPDMTHREAD pThread;
122
123#ifdef VBOX_WITH_STATISTICS
124 /** Number of sent packets. */
125 STAMCOUNTER StatPktSent;
126 /** Number of sent bytes. */
127 STAMCOUNTER StatPktSentBytes;
128 /** Number of received packets. */
129 STAMCOUNTER StatPktRecv;
130 /** Number of received bytes. */
131 STAMCOUNTER StatPktRecvBytes;
132 /** Profiling packet transmit runs. */
133 STAMPROFILE StatTransmit;
134 /** Profiling packet receive runs. */
135 STAMPROFILEADV StatReceive;
136#endif /* VBOX_WITH_STATISTICS */
137
138#ifdef LOG_ENABLED
139 /** The nano ts of the last transfer. */
140 uint64_t u64LastTransferTS;
141 /** The nano ts of the last receive. */
142 uint64_t u64LastReceiveTS;
143#endif
144} DRVTAP, *PDRVTAP;
145
146
147/** Converts a pointer to TAP::INetworkConnector to a PRDVTAP. */
148#define PDMINETWORKCONNECTOR_2_DRVTAP(pInterface) ( (PDRVTAP)((uintptr_t)pInterface - RT_OFFSETOF(DRVTAP, INetworkConnector)) )
149
150
151/*******************************************************************************
152* Internal Functions *
153*******************************************************************************/
154#ifdef RT_OS_SOLARIS
155# ifdef VBOX_WITH_CROSSBOW
156static int SolarisOpenVNIC(PDRVTAP pThis);
157static int SolarisDLPIErr2VBoxErr(int rc);
158# else
159static int SolarisTAPAttach(PDRVTAP pThis);
160# endif
161#endif
162
163
164/**
165 * Send data to the network.
166 *
167 * @returns VBox status code.
168 * @param pInterface Pointer to the interface structure containing the called function pointer.
169 * @param pvBuf Data to send.
170 * @param cb Number of bytes to send.
171 * @thread EMT
172 */
173static DECLCALLBACK(int) drvTAPSend(PPDMINETWORKCONNECTOR pInterface, const void *pvBuf, size_t cb)
174{
175 PDRVTAP pThis = PDMINETWORKCONNECTOR_2_DRVTAP(pInterface);
176 STAM_COUNTER_INC(&pThis->StatPktSent);
177 STAM_COUNTER_ADD(&pThis->StatPktSentBytes, cb);
178 STAM_PROFILE_START(&pThis->StatTransmit, a);
179
180#ifdef LOG_ENABLED
181 uint64_t u64Now = RTTimeProgramNanoTS();
182 LogFlow(("drvTAPSend: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n",
183 cb, u64Now, u64Now - pThis->u64LastReceiveTS, u64Now - pThis->u64LastTransferTS));
184 pThis->u64LastTransferTS = u64Now;
185#endif
186 Log2(("drvTAPSend: pvBuf=%p cb=%#x\n"
187 "%.*Rhxd\n",
188 pvBuf, cb, cb, pvBuf));
189
190 int rc = RTFileWrite(pThis->FileDevice, pvBuf, cb, NULL);
191
192 STAM_PROFILE_STOP(&pThis->StatTransmit, a);
193 AssertRC(rc);
194 return rc;
195}
196
197
198/**
199 * Set promiscuous mode.
200 *
201 * This is called when the promiscuous mode is set. This means that there doesn't have
202 * to be a mode change when it's called.
203 *
204 * @param pInterface Pointer to the interface structure containing the called function pointer.
205 * @param fPromiscuous Set if the adaptor is now in promiscuous mode. Clear if it is not.
206 * @thread EMT
207 */
208static DECLCALLBACK(void) drvTAPSetPromiscuousMode(PPDMINETWORKCONNECTOR pInterface, bool fPromiscuous)
209{
210 LogFlow(("drvTAPSetPromiscuousMode: fPromiscuous=%d\n", fPromiscuous));
211 /* nothing to do */
212}
213
214
215/**
216 * Notification on link status changes.
217 *
218 * @param pInterface Pointer to the interface structure containing the called function pointer.
219 * @param enmLinkState The new link state.
220 * @thread EMT
221 */
222static DECLCALLBACK(void) drvTAPNotifyLinkChanged(PPDMINETWORKCONNECTOR pInterface, PDMNETWORKLINKSTATE enmLinkState)
223{
224 LogFlow(("drvNATNotifyLinkChanged: enmLinkState=%d\n", enmLinkState));
225 /** @todo take action on link down and up. Stop the polling and such like. */
226}
227
228
229/**
230 * Asynchronous I/O thread for handling receive.
231 *
232 * @returns VINF_SUCCESS (ignored).
233 * @param Thread Thread handle.
234 * @param pvUser Pointer to a DRVTAP structure.
235 */
236static DECLCALLBACK(int) drvTAPAsyncIoThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
237{
238 PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP);
239 LogFlow(("drvTAPAsyncIoThread: pThis=%p\n", pThis));
240
241 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
242 return VINF_SUCCESS;
243
244 STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
245
246 /*
247 * Polling loop.
248 */
249 while (pThread->enmState == PDMTHREADSTATE_RUNNING)
250 {
251 /*
252 * Wait for something to become available.
253 */
254 struct pollfd aFDs[2];
255 aFDs[0].fd = pThis->FileDevice;
256 aFDs[0].events = POLLIN | POLLPRI;
257 aFDs[0].revents = 0;
258 aFDs[1].fd = pThis->PipeRead;
259 aFDs[1].events = POLLIN | POLLPRI | POLLERR | POLLHUP;
260 aFDs[1].revents = 0;
261 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
262 errno=0;
263 int rc = poll(&aFDs[0], RT_ELEMENTS(aFDs), -1 /* infinite */);
264
265 /* this might have changed in the meantime */
266 if (pThread->enmState != PDMTHREADSTATE_RUNNING)
267 break;
268
269 STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
270 if ( rc > 0
271 && (aFDs[0].revents & (POLLIN | POLLPRI))
272 && !aFDs[1].revents)
273 {
274 /*
275 * Read the frame.
276 */
277 char achBuf[16384];
278 size_t cbRead = 0;
279#ifdef VBOX_WITH_CROSSBOW
280 cbRead = sizeof(achBuf);
281 rc = g_pfnLibDlpiRecv(pThis->pDeviceHandle, NULL, NULL, achBuf, &cbRead, -1, NULL);
282 rc = RT_LIKELY(rc == DLPI_SUCCESS) ? VINF_SUCCESS : SolarisDLPIErr2VBoxErr(rc);
283#else
284 /** @note At least on Linux we will never receive more than one network packet
285 * after poll() returned successfully. I don't know why but a second
286 * RTFileRead() operation will return with VERR_TRY_AGAIN in any case. */
287 rc = RTFileRead(pThis->FileDevice, achBuf, sizeof(achBuf), &cbRead);
288#endif
289 if (RT_SUCCESS(rc))
290 {
291 /*
292 * Wait for the device to have space for this frame.
293 * Most guests use frame-sized receive buffers, hence non-zero cbMax
294 * automatically means there is enough room for entire frame. Some
295 * guests (eg. Solaris) use large chains of small receive buffers
296 * (each 128 or so bytes large). We will still start receiving as soon
297 * as cbMax is non-zero because:
298 * - it would be quite expensive for pfnCanReceive to accurately
299 * determine free receive buffer space
300 * - if we were waiting for enough free buffers, there is a risk
301 * of deadlocking because the guest could be waiting for a receive
302 * overflow error to allocate more receive buffers
303 */
304 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
305 int rc1 = pThis->pPort->pfnWaitReceiveAvail(pThis->pPort, RT_INDEFINITE_WAIT);
306 STAM_PROFILE_ADV_START(&pThis->StatReceive, a);
307
308 /*
309 * A return code != VINF_SUCCESS means that we were woken up during a VM
310 * state transistion. Drop the packet and wait for the next one.
311 */
312 if (RT_FAILURE(rc1))
313 continue;
314
315 /*
316 * Pass the data up.
317 */
318#ifdef LOG_ENABLED
319 uint64_t u64Now = RTTimeProgramNanoTS();
320 LogFlow(("drvTAPAsyncIoThread: %-4d bytes at %llu ns deltas: r=%llu t=%llu\n",
321 cbRead, u64Now, u64Now - pThis->u64LastReceiveTS, u64Now - pThis->u64LastTransferTS));
322 pThis->u64LastReceiveTS = u64Now;
323#endif
324 Log2(("drvTAPAsyncIoThread: cbRead=%#x\n" "%.*Rhxd\n", cbRead, cbRead, achBuf));
325 STAM_COUNTER_INC(&pThis->StatPktRecv);
326 STAM_COUNTER_ADD(&pThis->StatPktRecvBytes, cbRead);
327 rc1 = pThis->pPort->pfnReceive(pThis->pPort, achBuf, cbRead);
328 AssertRC(rc1);
329 }
330 else
331 {
332 LogFlow(("drvTAPAsyncIoThread: RTFileRead -> %Rrc\n", rc));
333 if (rc == VERR_INVALID_HANDLE)
334 break;
335 RTThreadYield();
336 }
337 }
338 else if ( rc > 0
339 && aFDs[1].revents)
340 {
341 LogFlow(("drvTAPAsyncIoThread: Control message: enmState=%d revents=%#x\n", pThread->enmState, aFDs[1].revents));
342 if (aFDs[1].revents & (POLLHUP | POLLERR | POLLNVAL))
343 break;
344
345 /* drain the pipe */
346 char ch;
347 size_t cbRead;
348 RTFileRead(pThis->PipeRead, &ch, 1, &cbRead);
349 }
350 else
351 {
352 /*
353 * poll() failed for some reason. Yield to avoid eating too much CPU.
354 *
355 * EINTR errors have been seen frequently. They should be harmless, even
356 * if they are not supposed to occur in our setup.
357 */
358 if (errno == EINTR)
359 Log(("rc=%d revents=%#x,%#x errno=%p %s\n", rc, aFDs[0].revents, aFDs[1].revents, errno, strerror(errno)));
360 else
361 AssertMsgFailed(("rc=%d revents=%#x,%#x errno=%p %s\n", rc, aFDs[0].revents, aFDs[1].revents, errno, strerror(errno)));
362 RTThreadYield();
363 }
364 }
365
366
367 LogFlow(("drvTAPAsyncIoThread: returns %Rrc\n", VINF_SUCCESS));
368 STAM_PROFILE_ADV_STOP(&pThis->StatReceive, a);
369 return VINF_SUCCESS;
370}
371
372
373/**
374 * Unblock the send thread so it can respond to a state change.
375 *
376 * @returns VBox status code.
377 * @param pDevIns The pcnet device instance.
378 * @param pThread The send thread.
379 */
380static DECLCALLBACK(int) drvTapAsyncIoWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
381{
382 PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP);
383
384 int rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL);
385 AssertRC(rc);
386
387 return VINF_SUCCESS;
388}
389
390
391#if defined(RT_OS_SOLARIS)
392/**
393 * Calls OS-specific TAP setup application/script.
394 *
395 * @returns VBox error code.
396 * @param pThis The instance data.
397 */
398static int drvTAPSetupApplication(PDRVTAP pThis)
399{
400 char szCommand[4096];
401
402#ifdef VBOX_WITH_CROSSBOW
403 /* Convert MAC address bytes to string (required by Solaris' dladm). */
404 char *pszHex = "0123456789abcdef";
405 uint8_t *pMacAddr8 = pThis->MacAddress.au8;
406 char szMacAddress[3 * sizeof(RTMAC)];
407 for (unsigned int i = 0; i < sizeof(RTMAC); i++)
408 {
409 szMacAddress[3 * i] = pszHex[((*pMacAddr8 >> 4) & 0x0f)];
410 szMacAddress[3 * i + 1] = pszHex[(*pMacAddr8 & 0x0f)];
411 szMacAddress[3 * i + 2] = ':';
412 *pMacAddr8++;
413 }
414 szMacAddress[sizeof(szMacAddress) - 1] = 0;
415
416 RTStrPrintf(szCommand, sizeof(szCommand), "%s %s %s", pThis->pszSetupApplication,
417 szMacAddress, pThis->fStatic ? pThis->pszDeviceName : "");
418#else
419 RTStrPrintf(szCommand, sizeof(szCommand), "%s %s", pThis->pszSetupApplication,
420 pThis->fStatic ? pThis->pszDeviceName : "");
421#endif
422
423 /* Pipe open the setup application. */
424 Log2(("Starting TAP setup application: %s\n", szCommand));
425 FILE* pfSetupHandle = popen(szCommand, "r");
426 if (pfSetupHandle == 0)
427 {
428 LogRel(("TAP#%d: Failed to run TAP setup application: %s\n", pThis->pDrvIns->iInstance,
429 pThis->pszSetupApplication, strerror(errno)));
430 return VERR_HOSTIF_INIT_FAILED;
431 }
432 if (!pThis->fStatic)
433 {
434 /* Obtain device name from setup application. */
435 char acBuffer[64];
436 size_t cBufSize;
437 fgets(acBuffer, sizeof(acBuffer), pfSetupHandle);
438 cBufSize = strlen(acBuffer);
439 /* The script must return the name of the interface followed by a carriage return as the
440 first line of its output. We need a null-terminated string. */
441 if ((cBufSize < 2) || (acBuffer[cBufSize - 1] != '\n'))
442 {
443 pclose(pfSetupHandle);
444 LogRel(("The TAP interface setup script did not return the name of a TAP device.\n"));
445 return VERR_HOSTIF_INIT_FAILED;
446 }
447 /* Overwrite the terminating newline character. */
448 acBuffer[cBufSize - 1] = 0;
449 RTStrAPrintf(&pThis->pszDeviceName, "%s", acBuffer);
450 }
451 int rc = pclose(pfSetupHandle);
452 if (!WIFEXITED(rc))
453 {
454 LogRel(("The TAP interface setup script terminated abnormally.\n"));
455 return VERR_HOSTIF_INIT_FAILED;
456 }
457 if (WEXITSTATUS(rc) != 0)
458 {
459 LogRel(("The TAP interface setup script returned a non-zero exit code.\n"));
460 return VERR_HOSTIF_INIT_FAILED;
461 }
462 return VINF_SUCCESS;
463}
464
465
466/**
467 * Calls OS-specific TAP terminate application/script.
468 *
469 * @returns VBox error code.
470 * @param pThis The instance data.
471 */
472static int drvTAPTerminateApplication(PDRVTAP pThis)
473{
474 char *pszArgs[3];
475 pszArgs[0] = pThis->pszTerminateApplication;
476 pszArgs[1] = pThis->pszDeviceName;
477 pszArgs[2] = NULL;
478
479 Log2(("Starting TAP terminate application: %s %s\n", pThis->pszTerminateApplication, pThis->pszDeviceName));
480 RTPROCESS pid = NIL_RTPROCESS;
481 int rc = RTProcCreate(pszArgs[0], pszArgs, RTENV_DEFAULT, 0, &pid);
482 if (RT_SUCCESS(rc))
483 {
484 RTPROCSTATUS Status;
485 rc = RTProcWait(pid, 0, &Status);
486 if (RT_SUCCESS(rc))
487 {
488 if ( Status.iStatus == 0
489 && Status.enmReason == RTPROCEXITREASON_NORMAL)
490 return VINF_SUCCESS;
491
492 LogRel(("TAP#%d: Error running TAP terminate application: %s\n", pThis->pDrvIns->iInstance, pThis->pszTerminateApplication));
493 }
494 else
495 LogRel(("TAP#%d: RTProcWait failed for: %s\n", pThis->pDrvIns->iInstance, pThis->pszTerminateApplication));
496 }
497 else
498 {
499 /* Bad. RTProcCreate() failed! */
500 LogRel(("TAP#%d: Failed to fork() process for running TAP terminate application: %s\n", pThis->pDrvIns->iInstance,
501 pThis->pszTerminateApplication, strerror(errno)));
502 }
503 return VERR_HOSTIF_TERM_FAILED;
504}
505
506#endif /* RT_OS_SOLARIS */
507
508
509#ifdef RT_OS_SOLARIS
510# ifdef VBOX_WITH_CROSSBOW
511/**
512 * Crossbow: Open & configure the virtual NIC.
513 *
514 * @returns VBox error code.
515 * @param pThis The instance data.
516 */
517static int SolarisOpenVNIC(PDRVTAP pThis)
518{
519 /*
520 * Open & bind the NIC using the datalink provider routine.
521 */
522 int rc = g_pfnLibDlpiOpen(pThis->pszDeviceName, &pThis->pDeviceHandle, DLPI_RAW);
523 if (rc != DLPI_SUCCESS)
524 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
525 N_("Failed to open VNIC \"%s\" in raw mode"), pThis->pszDeviceName);
526
527 dlpi_info_t vnicInfo;
528 rc = g_pfnLibDlpiInfo(pThis->pDeviceHandle, &vnicInfo, 0);
529 if (rc == DLPI_SUCCESS)
530 {
531 if (vnicInfo.di_mactype == DL_ETHER)
532 {
533 rc = g_pfnLibDlpiBind(pThis->pDeviceHandle, DLPI_ANY_SAP, NULL);
534 if (rc == DLPI_SUCCESS)
535 {
536 rc = g_pfnLibDlpiSetPhysAddr(pThis->pDeviceHandle, DL_CURR_PHYS_ADDR, &pThis->MacAddress, ETHERADDRL);
537 if (rc == DLPI_SUCCESS)
538 {
539 rc = g_pfnLibDlpiPromiscon(pThis->pDeviceHandle, DL_PROMISC_SAP);
540 if (rc == DLPI_SUCCESS)
541 {
542 /* Need to use DL_PROMIS_PHYS (not multicast) as we cannot be sure what the guest needs. */
543 rc = g_pfnLibDlpiPromiscon(pThis->pDeviceHandle, DL_PROMISC_PHYS);
544 if (rc == DLPI_SUCCESS)
545 {
546 pThis->FileDevice = g_pfnLibDlpiFd(pThis->pDeviceHandle);
547 if (pThis->FileDevice >= 0)
548 {
549 Log(("SolarisOpenVNIC: %s -> %d\n", pThis->pszDeviceName, pThis->FileDevice));
550 return VINF_SUCCESS;
551 }
552
553 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
554 N_("Failed to obtain file descriptor for VNIC"));
555 }
556 else
557 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
558 N_("Failed to set appropriate promiscous mode"));
559 }
560 else
561 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
562 N_("Failed to activate promiscous mode for VNIC"));
563 }
564 else
565 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
566 N_("Failed to set physical address for VNIC"));
567 }
568 else
569 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
570 N_("Failed to bind VNIC"));
571 }
572 else
573 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
574 N_("VNIC type is not ethernet"));
575 }
576 else
577 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
578 N_("Failed to obtain VNIC info"));
579 g_pfnLibDlpiClose(pThis->pDeviceHandle);
580 return rc;
581}
582
583
584/**
585 * Crossbow: Converts a Solaris DLPI error code to a VBox error code.
586 *
587 * @returns corresponding VBox error code.
588 * @param rc DLPI error code (DLPI_* defines).
589 */
590static int SolarisDLPIErr2VBoxErr(int rc)
591{
592 switch (rc)
593 {
594 case DLPI_SUCCESS: return VINF_SUCCESS;
595 case DLPI_EINVAL: return VERR_INVALID_PARAMETER;
596 case DLPI_ELINKNAMEINVAL: return VERR_INVALID_NAME;
597 case DLPI_EINHANDLE: return VERR_INVALID_HANDLE;
598 case DLPI_ETIMEDOUT: return VERR_TIMEOUT;
599 case DLPI_FAILURE: return VERR_GENERAL_FAILURE;
600
601 case DLPI_EVERNOTSUP:
602 case DLPI_EMODENOTSUP:
603 case DLPI_ERAWNOTSUP:
604 /* case DLPI_ENOTENOTSUP: */
605 case DLPI_EUNAVAILSAP: return VERR_NOT_SUPPORTED;
606
607 /* Define VBox error codes for these, if really needed. */
608 case DLPI_ENOLINK:
609 case DLPI_EBADLINK:
610 /* case DLPI_ENOTEIDINVAL: */
611 case DLPI_EBADMSG:
612 case DLPI_ENOTSTYLE2: return VERR_GENERAL_FAILURE;
613 }
614
615 AssertMsgFailed(("SolarisDLPIErr2VBoxErr: Unhandled error %d\n", rc));
616 return VERR_UNRESOLVED_ERROR;
617}
618
619# else /* VBOX_WITH_CROSSBOW */
620
621/** From net/if_tun.h, installed by Universal TUN/TAP driver */
622# define TUNNEWPPA (('T'<<16) | 0x0001)
623/** Whether to enable ARP for TAP. */
624# define VBOX_SOLARIS_TAP_ARP 1
625
626/**
627 * Creates/Attaches TAP device to IP.
628 *
629 * @returns VBox error code.
630 * @param pThis The instance data.
631 */
632static DECLCALLBACK(int) SolarisTAPAttach(PDRVTAP pThis)
633{
634 LogFlow(("SolarisTapAttach: pThis=%p\n", pThis));
635
636
637 int IPFileDes = open("/dev/udp", O_RDWR, 0);
638 if (IPFileDes < 0)
639 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
640 N_("Failed to open /dev/udp. errno=%d"), errno);
641
642 int TapFileDes = open("/dev/tap", O_RDWR, 0);
643 if (TapFileDes < 0)
644 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
645 N_("Failed to open /dev/tap for TAP. errno=%d"), errno);
646
647 /* Use the PPA from the ifname if possible (e.g "tap2", then use 2 as PPA) */
648 int iPPA = -1;
649 if (pThis->pszDeviceName)
650 {
651 size_t cch = strlen(pThis->pszDeviceName);
652 if (cch > 1 && RT_C_IS_DIGIT(pThis->pszDeviceName[cch - 1]) != 0)
653 iPPA = pThis->pszDeviceName[cch - 1] - '0';
654 }
655
656 struct strioctl ioIF;
657 ioIF.ic_cmd = TUNNEWPPA;
658 ioIF.ic_len = sizeof(iPPA);
659 ioIF.ic_dp = (char *)(&iPPA);
660 ioIF.ic_timout = 0;
661 iPPA = ioctl(TapFileDes, I_STR, &ioIF);
662 if (iPPA < 0)
663 {
664 close(TapFileDes);
665 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS,
666 N_("Failed to get new interface. errno=%d"), errno);
667 }
668
669 int InterfaceFD = open("/dev/tap", O_RDWR, 0);
670 if (!InterfaceFD)
671 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
672 N_("Failed to open interface /dev/tap. errno=%d"), errno);
673
674 if (ioctl(InterfaceFD, I_PUSH, "ip") == -1)
675 {
676 close(InterfaceFD);
677 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS,
678 N_("Failed to push IP. errno=%d"), errno);
679 }
680
681 struct lifreq ifReq;
682 memset(&ifReq, 0, sizeof(ifReq));
683 if (ioctl(InterfaceFD, SIOCGLIFFLAGS, &ifReq) == -1)
684 LogRel(("TAP#%d: Failed to get interface flags.\n", pThis->pDrvIns->iInstance));
685
686 ifReq.lifr_ppa = iPPA;
687 RTStrPrintf (ifReq.lifr_name, sizeof(ifReq.lifr_name), pThis->pszDeviceName);
688
689 if (ioctl(InterfaceFD, SIOCSLIFNAME, &ifReq) == -1)
690 LogRel(("TAP#%d: Failed to set PPA. errno=%d\n", pThis->pDrvIns->iInstance, errno));
691
692 if (ioctl(InterfaceFD, SIOCGLIFFLAGS, &ifReq) == -1)
693 LogRel(("TAP#%d: Failed to get interface flags after setting PPA. errno=%d\n", pThis->pDrvIns->iInstance, errno));
694
695#ifdef VBOX_SOLARIS_TAP_ARP
696 /* Interface */
697 if (ioctl(InterfaceFD, I_PUSH, "arp") == -1)
698 LogRel(("TAP#%d: Failed to push ARP to Interface FD. errno=%d\n", pThis->pDrvIns->iInstance, errno));
699
700 /* IP */
701 if (ioctl(IPFileDes, I_POP, NULL) == -1)
702 LogRel(("TAP#%d: Failed I_POP from IP FD. errno=%d\n", pThis->pDrvIns->iInstance, errno));
703
704 if (ioctl(IPFileDes, I_PUSH, "arp") == -1)
705 LogRel(("TAP#%d: Failed to push ARP to IP FD. errno=%d\n", pThis->pDrvIns->iInstance, errno));
706
707 /* ARP */
708 int ARPFileDes = open("/dev/tap", O_RDWR, 0);
709 if (ARPFileDes < 0)
710 LogRel(("TAP#%d: Failed to open for /dev/tap for ARP. errno=%d", pThis->pDrvIns->iInstance, errno));
711
712 if (ioctl(ARPFileDes, I_PUSH, "arp") == -1)
713 LogRel(("TAP#%d: Failed to push ARP to ARP FD. errno=%d\n", pThis->pDrvIns->iInstance, errno));
714
715 ioIF.ic_cmd = SIOCSLIFNAME;
716 ioIF.ic_timout = 0;
717 ioIF.ic_len = sizeof(ifReq);
718 ioIF.ic_dp = (char *)&ifReq;
719 if (ioctl(ARPFileDes, I_STR, &ioIF) == -1)
720 LogRel(("TAP#%d: Failed to set interface name to ARP.\n", pThis->pDrvIns->iInstance));
721#endif
722
723 /* We must use I_LINK and not I_PLINK as I_PLINK makes the link persistent.
724 * Then we would not be able unlink the interface if we reuse it.
725 * Even 'unplumb' won't work after that.
726 */
727 int IPMuxID = ioctl(IPFileDes, I_LINK, InterfaceFD);
728 if (IPMuxID == -1)
729 {
730 close(InterfaceFD);
731#ifdef VBOX_SOLARIS_TAP_ARP
732 close(ARPFileDes);
733#endif
734 LogRel(("TAP#%d: Cannot link TAP device to IP.\n", pThis->pDrvIns->iInstance));
735 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS,
736 N_("Failed to link TAP device to IP. Check TAP interface name. errno=%d"), errno);
737 }
738
739#ifdef VBOX_SOLARIS_TAP_ARP
740 int ARPMuxID = ioctl(IPFileDes, I_LINK, ARPFileDes);
741 if (ARPMuxID == -1)
742 LogRel(("TAP#%d: Failed to link TAP device to ARP\n", pThis->pDrvIns->iInstance));
743
744 close(ARPFileDes);
745#endif
746 close(InterfaceFD);
747
748 /* Reuse ifReq */
749 memset(&ifReq, 0, sizeof(ifReq));
750 RTStrPrintf (ifReq.lifr_name, sizeof(ifReq.lifr_name), pThis->pszDeviceName);
751 ifReq.lifr_ip_muxid = IPMuxID;
752#ifdef VBOX_SOLARIS_TAP_ARP
753 ifReq.lifr_arp_muxid = ARPMuxID;
754#endif
755
756 if (ioctl(IPFileDes, SIOCSLIFMUXID, &ifReq) == -1)
757 {
758#ifdef VBOX_SOLARIS_TAP_ARP
759 ioctl(IPFileDes, I_PUNLINK, ARPMuxID);
760#endif
761 ioctl(IPFileDes, I_PUNLINK, IPMuxID);
762 close(IPFileDes);
763 LogRel(("TAP#%d: Failed to set Mux ID.\n", pThis->pDrvIns->iInstance));
764 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS,
765 N_("Failed to set Mux ID. Check TAP interface name. errno=%d"), errno);
766 }
767
768 pThis->FileDevice = (RTFILE)TapFileDes;
769 pThis->IPFileDevice = (RTFILE)IPFileDes;
770
771 return VINF_SUCCESS;
772}
773
774# endif /* VBOX_WITH_CROSSBOW */
775#endif /* RT_OS_SOLARIS */
776
777
778/**
779 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
780 */
781static DECLCALLBACK(void *) drvTAPQueryInterface(PPDMIBASE pInterface, const char *pszIID)
782{
783 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
784 PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP);
785
786 if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
787 return &pDrvIns->IBase;
788 PDMIBASE_RETURN_INTERFACE(pszIID, PDMINETWORKCONNECTOR, &pThis->INetworkConnector);
789 return NULL;
790}
791
792
793/**
794 * Destruct a driver instance.
795 *
796 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
797 * resources can be freed correctly.
798 *
799 * @param pDrvIns The driver instance data.
800 */
801static DECLCALLBACK(void) drvTAPDestruct(PPDMDRVINS pDrvIns)
802{
803 LogFlow(("drvTAPDestruct\n"));
804 PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP);
805
806 /*
807 * Terminate the control pipe.
808 */
809 if (pThis->PipeWrite != NIL_RTFILE)
810 {
811 int rc = RTFileClose(pThis->PipeWrite);
812 AssertRC(rc);
813 pThis->PipeWrite = NIL_RTFILE;
814 }
815 if (pThis->PipeRead != NIL_RTFILE)
816 {
817 int rc = RTFileClose(pThis->PipeRead);
818 AssertRC(rc);
819 pThis->PipeRead = NIL_RTFILE;
820 }
821
822#ifdef RT_OS_SOLARIS
823 /** @todo r=bird: This *does* need checking against ConsoleImpl2.cpp if used on non-solaris systems. */
824 if (pThis->FileDevice != NIL_RTFILE)
825 {
826 int rc = RTFileClose(pThis->FileDevice);
827 AssertRC(rc);
828 pThis->FileDevice = NIL_RTFILE;
829 }
830
831# ifndef VBOX_WITH_CROSSBOW
832 if (pThis->IPFileDevice != NIL_RTFILE)
833 {
834 int rc = RTFileClose(pThis->IPFileDevice);
835 AssertRC(rc);
836 pThis->IPFileDevice = NIL_RTFILE;
837 }
838# endif
839
840 /*
841 * Call TerminateApplication after closing the device otherwise
842 * TerminateApplication would not be able to unplumb it.
843 */
844 if (pThis->pszTerminateApplication)
845 drvTAPTerminateApplication(pThis);
846
847#endif /* RT_OS_SOLARIS */
848
849#ifdef RT_OS_SOLARIS
850 if (!pThis->fStatic)
851 RTStrFree(pThis->pszDeviceName); /* allocated by drvTAPSetupApplication */
852 else
853 MMR3HeapFree(pThis->pszDeviceName);
854#else
855 MMR3HeapFree(pThis->pszDeviceName);
856#endif
857 MMR3HeapFree(pThis->pszSetupApplication);
858 MMR3HeapFree(pThis->pszTerminateApplication);
859
860#ifdef VBOX_WITH_STATISTICS
861 /*
862 * Deregister statistics.
863 */
864 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatPktSent);
865 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatPktSentBytes);
866 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatPktRecv);
867 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatPktRecvBytes);
868 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatTransmit);
869 PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->StatReceive);
870#endif /* VBOX_WITH_STATISTICS */
871}
872
873
874/**
875 * Construct a TAP network transport driver instance.
876 *
877 * @copydoc FNPDMDRVCONSTRUCT
878 */
879static DECLCALLBACK(int) drvTAPConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
880{
881 PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP);
882
883 /*
884 * Init the static parts.
885 */
886 pThis->pDrvIns = pDrvIns;
887 pThis->FileDevice = NIL_RTFILE;
888 pThis->pszDeviceName = NULL;
889#ifdef RT_OS_SOLARIS
890# ifdef VBOX_WITH_CROSSBOW
891 pThis->pDeviceHandle = NULL;
892# else
893 pThis->IPFileDevice = NIL_RTFILE;
894# endif
895 pThis->fStatic = true;
896#endif
897 pThis->pszSetupApplication = NULL;
898 pThis->pszTerminateApplication = NULL;
899
900 /* IBase */
901 pDrvIns->IBase.pfnQueryInterface = drvTAPQueryInterface;
902 /* INetwork */
903 pThis->INetworkConnector.pfnSend = drvTAPSend;
904 pThis->INetworkConnector.pfnSetPromiscuousMode = drvTAPSetPromiscuousMode;
905 pThis->INetworkConnector.pfnNotifyLinkChanged = drvTAPNotifyLinkChanged;
906
907 /*
908 * Validate the config.
909 */
910 if (!CFGMR3AreValuesValid(pCfgHandle, "Device\0InitProg\0TermProg\0FileHandle\0TAPSetupApplication\0TAPTerminateApplication\0MAC"))
911 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES, "");
912
913 /*
914 * Check that no-one is attached to us.
915 */
916 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
917 ("Configuration error: Not possible to attach anything to this driver!\n"),
918 VERR_PDM_DRVINS_NO_ATTACH);
919
920 /*
921 * Query the network port interface.
922 */
923 pThis->pPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMINETWORKPORT);
924 if (!pThis->pPort)
925 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
926 N_("Configuration error: The above device/driver didn't export the network port interface"));
927
928 /*
929 * Read the configuration.
930 */
931 int rc;
932#if defined(RT_OS_SOLARIS) /** @todo Other platforms' TAP code should be moved here from ConsoleImpl & VBoxBFE. */
933 rc = CFGMR3QueryStringAlloc(pCfgHandle, "TAPSetupApplication", &pThis->pszSetupApplication);
934 if (RT_SUCCESS(rc))
935 {
936 if (!RTPathExists(pThis->pszSetupApplication))
937 return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
938 N_("Invalid TAP setup program path: %s"), pThis->pszSetupApplication);
939 }
940 else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
941 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\""));
942
943 rc = CFGMR3QueryStringAlloc(pCfgHandle, "TAPTerminateApplication", &pThis->pszTerminateApplication);
944 if (RT_SUCCESS(rc))
945 {
946 if (!RTPathExists(pThis->pszTerminateApplication))
947 return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
948 N_("Invalid TAP terminate program path: %s"), pThis->pszTerminateApplication);
949 }
950 else if (rc != VERR_CFGM_VALUE_NOT_FOUND)
951 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\""));
952
953# ifdef VBOX_WITH_CROSSBOW
954 rc = CFGMR3QueryBytes(pCfgHandle, "MAC", &pThis->MacAddress, sizeof(pThis->MacAddress));
955 if (RT_FAILURE(rc))
956 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: Failed to query \"MAC\""));
957# endif
958
959 rc = CFGMR3QueryStringAlloc(pCfgHandle, "Device", &pThis->pszDeviceName);
960 if (RT_FAILURE(rc))
961 pThis->fStatic = false;
962
963 /* Obtain the device name from the setup application (if none was specified). */
964 if (pThis->pszSetupApplication)
965 {
966 rc = drvTAPSetupApplication(pThis);
967 if (RT_FAILURE(rc))
968 return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
969 N_("Error running TAP setup application. rc=%d"), rc);
970 }
971
972 /*
973 * Do the setup.
974 */
975# ifdef VBOX_WITH_CROSSBOW
976 if (!VBoxLibDlpiFound())
977 {
978 return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
979 N_("Failed to load library %s required for host interface networking."), LIB_DLPI);
980 }
981 rc = SolarisOpenVNIC(pThis);
982# else
983 rc = SolarisTAPAttach(pThis);
984# endif
985 if (RT_FAILURE(rc))
986 return rc;
987
988#else /* !RT_OS_SOLARIS */
989
990 int32_t iFile;
991 rc = CFGMR3QueryS32(pCfgHandle, "FileHandle", &iFile);
992 if (RT_FAILURE(rc))
993 return PDMDRV_SET_ERROR(pDrvIns, rc,
994 N_("Configuration error: Query for \"FileHandle\" 32-bit signed integer failed"));
995 pThis->FileDevice = (RTFILE)iFile;
996 if (!RTFileIsValid(pThis->FileDevice))
997 return PDMDrvHlpVMSetError(pDrvIns, VERR_INVALID_HANDLE, RT_SRC_POS,
998 N_("The TAP file handle %RTfile is not valid"), pThis->FileDevice);
999#endif /* !RT_OS_SOLARIS */
1000
1001 /*
1002 * Make sure the descriptor is non-blocking and valid.
1003 *
1004 * We should actually query if it's a TAP device, but I haven't
1005 * found any way to do that.
1006 */
1007 if (fcntl(pThis->FileDevice, F_SETFL, O_NONBLOCK) == -1)
1008 return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS,
1009 N_("Configuration error: Failed to configure /dev/net/tun. errno=%d"), errno);
1010 /** @todo determine device name. This can be done by reading the link /proc/<pid>/fd/<fd> */
1011 Log(("drvTAPContruct: %d (from fd)\n", pThis->FileDevice));
1012 rc = VINF_SUCCESS;
1013
1014 /*
1015 * Create the control pipe.
1016 */
1017 int fds[2];
1018#ifdef RT_OS_L4
1019 /* XXX We need to tell the library which interface we are using */
1020 fds[0] = vboxrtLinuxFd2VBoxFd(VBOXRT_FT_TAP, 0);
1021#endif
1022 if (pipe(&fds[0]) != 0) /** @todo RTPipeCreate() or something... */
1023 {
1024 rc = RTErrConvertFromErrno(errno);
1025 AssertRC(rc);
1026 return rc;
1027 }
1028 pThis->PipeRead = fds[0];
1029 pThis->PipeWrite = fds[1];
1030
1031 /*
1032 * Create the async I/O thread.
1033 */
1034 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pThread, pThis, drvTAPAsyncIoThread, drvTapAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "TAP");
1035 AssertRCReturn(rc, rc);
1036
1037#ifdef VBOX_WITH_STATISTICS
1038 /*
1039 * Statistics.
1040 */
1041 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatPktSent, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of sent packets.", "/Drivers/TAP%d/Packets/Sent", pDrvIns->iInstance);
1042 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatPktSentBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of sent bytes.", "/Drivers/TAP%d/Bytes/Sent", pDrvIns->iInstance);
1043 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatPktRecv, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of received packets.", "/Drivers/TAP%d/Packets/Received", pDrvIns->iInstance);
1044 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatPktRecvBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of received bytes.", "/Drivers/TAP%d/Bytes/Received", pDrvIns->iInstance);
1045 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatTransmit, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling packet transmit runs.", "/Drivers/TAP%d/Transmit", pDrvIns->iInstance);
1046 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReceive, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling packet receive runs.", "/Drivers/TAP%d/Receive", pDrvIns->iInstance);
1047#endif /* VBOX_WITH_STATISTICS */
1048
1049 return rc;
1050}
1051
1052
1053/**
1054 * TAP network transport driver registration record.
1055 */
1056const PDMDRVREG g_DrvHostInterface =
1057{
1058 /* u32Version */
1059 PDM_DRVREG_VERSION,
1060 /* szDriverName */
1061 "HostInterface",
1062 /* szRCMod */
1063 "",
1064 /* szR0Mod */
1065 "",
1066 /* pszDescription */
1067 "TAP Network Transport Driver",
1068 /* fFlags */
1069 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
1070 /* fClass. */
1071 PDM_DRVREG_CLASS_NETWORK,
1072 /* cMaxInstances */
1073 ~0,
1074 /* cbInstance */
1075 sizeof(DRVTAP),
1076 /* pfnConstruct */
1077 drvTAPConstruct,
1078 /* pfnDestruct */
1079 drvTAPDestruct,
1080 /* pfnRelocate */
1081 NULL,
1082 /* pfnIOCtl */
1083 NULL,
1084 /* pfnPowerOn */
1085 NULL,
1086 /* pfnReset */
1087 NULL,
1088 /* pfnSuspend */
1089 NULL, /** @todo Do power on, suspend and resume handlers! */
1090 /* pfnResume */
1091 NULL,
1092 /* pfnAttach */
1093 NULL,
1094 /* pfnDetach */
1095 NULL,
1096 /* pfnPowerOff */
1097 NULL,
1098 /* pfnSoftReset */
1099 NULL,
1100 /* u32EndVersion */
1101 PDM_DRVREG_VERSION
1102};
1103
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