VirtualBox

Changeset 5183 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Oct 8, 2007 1:09:28 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25104
Message:

hdr.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r5182 r5183  
    1 /** $Id: */
     1/** $Id$ */
    22/** @file
    33 * Universial TAP network transport driver.
     
    9797    /** IP device file handle (/dev/udp). */
    9898    RTFILE                  IPFileDevice;
    99 #endif 
     99#endif
    100100    /** TAP setup application. */
    101101    char                   *pszSetupApplication;
     
    491491        return VERR_HOSTIF_INIT_FAILED;
    492492    }
    493    
     493
    494494    return VINF_SUCCESS;
    495495}
     
    524524        /* Child process. */
    525525        execv(pszArgs[0], pszArgs);
    526         _exit(1); 
    527     }
    528        
     526        _exit(1);
     527    }
     528
    529529    /* Parent process. */
    530530    int result;
     
    536536        return VERR_HOSTIF_TERM_FAILED;
    537537    }
    538    
     538
    539539    return VINF_SUCCESS;
    540540}
     
    560560    PDRVTAP pData = PDMINS2DATA(pDrvIns, PDRVTAP);
    561561    LogFlow(("SolarisTapAttach: pData=%p\n", pData));
    562    
    563    
     562
     563
    564564    int IPFileDes = open("/dev/udp", O_RDWR, 0);
    565565    if (IPFileDes < 0)
    566566        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
    567567                                   N_("Failed to open /dev/udp. errno=%d"), errno);
    568    
     568
    569569    int TapFileDes = open("/dev/tap", O_RDWR, 0);
    570570    if (TapFileDes < 0)
    571571        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
    572572                                   N_("Failed to open /dev/tap for TAP. errno=%d"), errno);
    573    
     573
    574574    /* Use the PPA from the ifname if possible (e.g "tap2", then use 2 as PPA) */
    575575    int iPPA = -1;
     
    580580            iPPA = pData->pszDeviceName[cch - 1] - '0';
    581581    }
    582    
     582
    583583    struct strioctl ioIF;
    584584    ioIF.ic_cmd = TUNNEWPPA;
     
    593593                                   N_("Failed to get new interface. errno=%d"), errno);
    594594    }
    595    
     595
    596596    int InterfaceFD = open("/dev/tap", O_RDWR, 0);
    597597    if (!InterfaceFD)
    598598        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
    599599                                   N_("Failed to open interface /dev/tap. errno=%d"), errno);
    600    
     600
    601601    if (ioctl(InterfaceFD, I_PUSH, "ip") == -1)
    602602    {
     
    605605                                   N_("Failed to push IP. errno=%d"), errno);
    606606    }
    607    
     607
    608608    struct lifreq ifReq;
    609609    memset(&ifReq, 0, sizeof(ifReq));
     
    612612
    613613    char szTmp[16];
    614     char *pszDevName = pData->pszDeviceName;   
     614    char *pszDevName = pData->pszDeviceName;
    615615    if (!pData->pszDeviceName || !*pData->pszDeviceName)
    616616    {
     
    618618        pszDevName = szTmp;
    619619    }
    620    
     620
    621621    ifReq.lifr_ppa = iPPA;
    622622    RTStrPrintf (ifReq.lifr_name, sizeof(ifReq.lifr_name), pszDevName);
    623    
     623
    624624    if (ioctl(InterfaceFD, SIOCSLIFNAME, &ifReq) == -1)
    625625        LogRel(("TAP#%d: Failed to set PPA. errno=%d\n", pDrvIns->iInstance, errno));
    626    
     626
    627627    if (ioctl(InterfaceFD, SIOCGLIFFLAGS, &ifReq) == -1)
    628628        LogRel(("TAP#%d: Failed to get interface flags after setting PPA. errno=%d\n", pDrvIns->iInstance, errno));
     
    639639    if (ioctl(IPFileDes, I_PUSH, "arp") == -1)
    640640        LogRel(("TAP#%d: Failed to push ARP to IP FD. errno=%d\n", pDrvIns->iInstance, errno));
    641    
     641
    642642    /* ARP */
    643643    int ARPFileDes = open("/dev/tap", O_RDWR, 0);
    644644    if (ARPFileDes < 0)
    645645        LogRel(("TAP#%d: Failed to open for /dev/tap for ARP. errno=%d", pDrvIns->iInstance, errno));
    646    
     646
    647647    if (ioctl(ARPFileDes, I_PUSH, "arp") == -1)
    648648        LogRel(("TAP#%d: Failed to push ARP to ARP FD. errno=%d\n", pDrvIns->iInstance, errno));
    649    
     649
    650650    ioIF.ic_cmd = SIOCSLIFNAME;
    651651    ioIF.ic_timout = 0;
     
    671671                    N_("Failed to link TAP device to IP. Check TAP interface name. errno=%d"), errno);
    672672    }
    673    
     673
    674674#ifdef VBOX_SOLARIS_TAP_ARP
    675675    int ARPMuxID = ioctl(IPFileDes, I_LINK, ARPFileDes);
    676676    if (ARPMuxID == -1)
    677677        LogRel(("TAP#%d: Failed to link TAP device to ARP\n", pDrvIns->iInstance));
    678    
     678
    679679    close(ARPFileDes);
    680680#endif
     
    704704    pData->IPFileDevice = (RTFILE)IPFileDes;
    705705    pData->pszDeviceNameActual = RTStrDup(pszDevName);
    706    
     706
    707707    return VINF_SUCCESS;
    708708}
     
    826826    pData->pszDeviceNameActual          = NULL;
    827827    pData->IPFileDevice                 = NIL_RTFILE;
    828 #endif 
     828#endif
    829829    pData->pszSetupApplication          = NULL;
    830830    pData->pszTerminateApplication      = NULL;
     
    887887        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\""));
    888888
    889    
     889
    890890    rc = CFGMR3QueryStringAlloc(pCfgHandle, "Device", &pData->pszDeviceName);
    891891    if (VBOX_FAILURE(rc))
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette