Changeset 5183 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 8, 2007 1:09:28 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 25104
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvTAP.cpp
r5182 r5183 1 /** $Id :*/1 /** $Id$ */ 2 2 /** @file 3 3 * Universial TAP network transport driver. … … 97 97 /** IP device file handle (/dev/udp). */ 98 98 RTFILE IPFileDevice; 99 #endif 99 #endif 100 100 /** TAP setup application. */ 101 101 char *pszSetupApplication; … … 491 491 return VERR_HOSTIF_INIT_FAILED; 492 492 } 493 493 494 494 return VINF_SUCCESS; 495 495 } … … 524 524 /* Child process. */ 525 525 execv(pszArgs[0], pszArgs); 526 _exit(1); 527 } 528 526 _exit(1); 527 } 528 529 529 /* Parent process. */ 530 530 int result; … … 536 536 return VERR_HOSTIF_TERM_FAILED; 537 537 } 538 538 539 539 return VINF_SUCCESS; 540 540 } … … 560 560 PDRVTAP pData = PDMINS2DATA(pDrvIns, PDRVTAP); 561 561 LogFlow(("SolarisTapAttach: pData=%p\n", pData)); 562 563 562 563 564 564 int IPFileDes = open("/dev/udp", O_RDWR, 0); 565 565 if (IPFileDes < 0) 566 566 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 567 567 N_("Failed to open /dev/udp. errno=%d"), errno); 568 568 569 569 int TapFileDes = open("/dev/tap", O_RDWR, 0); 570 570 if (TapFileDes < 0) 571 571 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 572 572 N_("Failed to open /dev/tap for TAP. errno=%d"), errno); 573 573 574 574 /* Use the PPA from the ifname if possible (e.g "tap2", then use 2 as PPA) */ 575 575 int iPPA = -1; … … 580 580 iPPA = pData->pszDeviceName[cch - 1] - '0'; 581 581 } 582 582 583 583 struct strioctl ioIF; 584 584 ioIF.ic_cmd = TUNNEWPPA; … … 593 593 N_("Failed to get new interface. errno=%d"), errno); 594 594 } 595 595 596 596 int InterfaceFD = open("/dev/tap", O_RDWR, 0); 597 597 if (!InterfaceFD) 598 598 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 599 599 N_("Failed to open interface /dev/tap. errno=%d"), errno); 600 600 601 601 if (ioctl(InterfaceFD, I_PUSH, "ip") == -1) 602 602 { … … 605 605 N_("Failed to push IP. errno=%d"), errno); 606 606 } 607 607 608 608 struct lifreq ifReq; 609 609 memset(&ifReq, 0, sizeof(ifReq)); … … 612 612 613 613 char szTmp[16]; 614 char *pszDevName = pData->pszDeviceName; 614 char *pszDevName = pData->pszDeviceName; 615 615 if (!pData->pszDeviceName || !*pData->pszDeviceName) 616 616 { … … 618 618 pszDevName = szTmp; 619 619 } 620 620 621 621 ifReq.lifr_ppa = iPPA; 622 622 RTStrPrintf (ifReq.lifr_name, sizeof(ifReq.lifr_name), pszDevName); 623 623 624 624 if (ioctl(InterfaceFD, SIOCSLIFNAME, &ifReq) == -1) 625 625 LogRel(("TAP#%d: Failed to set PPA. errno=%d\n", pDrvIns->iInstance, errno)); 626 626 627 627 if (ioctl(InterfaceFD, SIOCGLIFFLAGS, &ifReq) == -1) 628 628 LogRel(("TAP#%d: Failed to get interface flags after setting PPA. errno=%d\n", pDrvIns->iInstance, errno)); … … 639 639 if (ioctl(IPFileDes, I_PUSH, "arp") == -1) 640 640 LogRel(("TAP#%d: Failed to push ARP to IP FD. errno=%d\n", pDrvIns->iInstance, errno)); 641 641 642 642 /* ARP */ 643 643 int ARPFileDes = open("/dev/tap", O_RDWR, 0); 644 644 if (ARPFileDes < 0) 645 645 LogRel(("TAP#%d: Failed to open for /dev/tap for ARP. errno=%d", pDrvIns->iInstance, errno)); 646 646 647 647 if (ioctl(ARPFileDes, I_PUSH, "arp") == -1) 648 648 LogRel(("TAP#%d: Failed to push ARP to ARP FD. errno=%d\n", pDrvIns->iInstance, errno)); 649 649 650 650 ioIF.ic_cmd = SIOCSLIFNAME; 651 651 ioIF.ic_timout = 0; … … 671 671 N_("Failed to link TAP device to IP. Check TAP interface name. errno=%d"), errno); 672 672 } 673 673 674 674 #ifdef VBOX_SOLARIS_TAP_ARP 675 675 int ARPMuxID = ioctl(IPFileDes, I_LINK, ARPFileDes); 676 676 if (ARPMuxID == -1) 677 677 LogRel(("TAP#%d: Failed to link TAP device to ARP\n", pDrvIns->iInstance)); 678 678 679 679 close(ARPFileDes); 680 680 #endif … … 704 704 pData->IPFileDevice = (RTFILE)IPFileDes; 705 705 pData->pszDeviceNameActual = RTStrDup(pszDevName); 706 706 707 707 return VINF_SUCCESS; 708 708 } … … 826 826 pData->pszDeviceNameActual = NULL; 827 827 pData->IPFileDevice = NIL_RTFILE; 828 #endif 828 #endif 829 829 pData->pszSetupApplication = NULL; 830 830 pData->pszTerminateApplication = NULL; … … 887 887 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\"")); 888 888 889 889 890 890 rc = CFGMR3QueryStringAlloc(pCfgHandle, "Device", &pData->pszDeviceName); 891 891 if (VBOX_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.