VirtualBox

Ignore:
Timestamp:
Feb 2, 2012 12:19:41 PM (13 years ago)
Author:
vboxsync
Message:

Ancient Solaris crossbow/TAP no longer relevant.

File:
1 edited

Legend:

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

    r37596 r39955  
    3939# include <iprt/process.h>
    4040# include <iprt/env.h>
    41 # ifdef VBOX_WITH_CROSSBOW
    42 #  include <iprt/mem.h>
    43 # endif
    4441#endif
    4542
     
    6158# include <stdlib.h>
    6259# include <stdio.h>
    63 # ifdef VBOX_WITH_CROSSBOW
    64 #  include "solaris/vbox-libdlpi.h"
    65 # endif
    6660#else
    6761# include <sys/fcntl.h>
     
    9892    char                   *pszDeviceName;
    9993#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
    10694    /** IP device file handle (/dev/udp). */
    10795    int                     iIPFileDes;
    108 # endif
    10996    /** Whether device name is obtained from setup application. */
    11097    bool                    fStatic;
     
    157144*******************************************************************************/
    158145#ifdef RT_OS_SOLARIS
    159 # ifdef VBOX_WITH_CROSSBOW
    160 static int              SolarisOpenVNIC(PDRVTAP pThis);
    161 static int              SolarisDLPIErr2VBoxErr(int rc);
    162 # else
    163146static int              SolarisTAPAttach(PDRVTAP pThis);
    164 # endif
    165147#endif
    166148
     
    391373            char achBuf[16384];
    392374            size_t cbRead = 0;
    393 #ifdef VBOX_WITH_CROSSBOW
    394             cbRead = sizeof(achBuf);
    395             rc = g_pfnLibDlpiRecv(pThis->pDeviceHandle, NULL, NULL, achBuf, &cbRead, -1, NULL);
    396             rc = RT_LIKELY(rc == DLPI_SUCCESS) ? VINF_SUCCESS : SolarisDLPIErr2VBoxErr(rc);
    397 #else
    398375            /** @note At least on Linux we will never receive more than one network packet
    399376             *        after poll() returned successfully. I don't know why but a second
    400377             *        RTFileRead() operation will return with VERR_TRY_AGAIN in any case. */
    401378            rc = RTFileRead(pThis->hFileDevice, achBuf, sizeof(achBuf), &cbRead);
    402 #endif
    403379            if (RT_SUCCESS(rc))
    404380            {
     
    515491    char szCommand[4096];
    516492
    517 #ifdef VBOX_WITH_CROSSBOW
    518     /* Convert MAC address bytes to string (required by Solaris' dladm). */
    519     char *pszHex = "0123456789abcdef";
    520     uint8_t *pMacAddr8 = pThis->MacAddress.au8;
    521     char szMacAddress[3 * sizeof(RTMAC)];
    522     for (unsigned int i = 0; i < sizeof(RTMAC); i++)
    523     {
    524         szMacAddress[3 * i] = pszHex[((*pMacAddr8 >> 4) & 0x0f)];
    525         szMacAddress[3 * i + 1] = pszHex[(*pMacAddr8 & 0x0f)];
    526         szMacAddress[3 * i + 2] = ':';
    527         *pMacAddr8++;
    528     }
    529     szMacAddress[sizeof(szMacAddress) - 1] =  0;
    530 
    531     RTStrPrintf(szCommand, sizeof(szCommand), "%s %s %s", pThis->pszSetupApplication,
    532             szMacAddress, pThis->fStatic ? pThis->pszDeviceName : "");
    533 #else
    534493    RTStrPrintf(szCommand, sizeof(szCommand), "%s %s", pThis->pszSetupApplication,
    535494            pThis->fStatic ? pThis->pszDeviceName : "");
    536 #endif
    537495
    538496    /* Pipe open the setup application. */
     
    623581
    624582#ifdef RT_OS_SOLARIS
    625 # ifdef VBOX_WITH_CROSSBOW
    626 /**
    627  * Crossbow: Open & configure the virtual NIC.
    628  *
    629  * @returns VBox error code.
    630  * @param   pThis           The instance data.
    631  */
    632 static int SolarisOpenVNIC(PDRVTAP pThis)
    633 {
    634     /*
    635      * Open & bind the NIC using the datalink provider routine.
    636      */
    637     int rc = g_pfnLibDlpiOpen(pThis->pszDeviceName, &pThis->pDeviceHandle, DLPI_RAW);
    638     if (rc != DLPI_SUCCESS)
    639         return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    640                            N_("Failed to open VNIC \"%s\" in raw mode"), pThis->pszDeviceName);
    641 
    642     dlpi_info_t vnicInfo;
    643     rc = g_pfnLibDlpiInfo(pThis->pDeviceHandle, &vnicInfo, 0);
    644     if (rc == DLPI_SUCCESS)
    645     {
    646         if (vnicInfo.di_mactype == DL_ETHER)
    647         {
    648             rc = g_pfnLibDlpiBind(pThis->pDeviceHandle, DLPI_ANY_SAP, NULL);
    649             if (rc == DLPI_SUCCESS)
    650             {
    651                 rc = g_pfnLibDlpiSetPhysAddr(pThis->pDeviceHandle, DL_CURR_PHYS_ADDR, &pThis->MacAddress, ETHERADDRL);
    652                 if (rc == DLPI_SUCCESS)
    653                 {
    654                     rc = g_pfnLibDlpiPromiscon(pThis->pDeviceHandle, DL_PROMISC_SAP);
    655                     if (rc == DLPI_SUCCESS)
    656                     {
    657                         /* Need to use DL_PROMIS_PHYS (not multicast) as we cannot be sure what the guest needs. */
    658                         rc = g_pfnLibDlpiPromiscon(pThis->pDeviceHandle, DL_PROMISC_PHYS);
    659                         if (rc == DLPI_SUCCESS)
    660                         {
    661                             int fd = g_pfnLibDlpiFd(pThis->pDeviceHandle);
    662                             if (pThis->FileDevice >= 0)
    663                             {
    664                                 rc = RTFileFromNative(&pThis->hFileDevice, fd);
    665                                 if (RT_SUCCESS(rc))
    666                                 {
    667                                     Log(("SolarisOpenVNIC: %s -> %RTfile\n", pThis->pszDeviceName, pThis->hFileDevice));
    668                                     return VINF_SUCCESS;
    669                                 }
    670                             }
    671                             else
    672                                 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    673                                                          N_("Failed to obtain file descriptor for VNIC"));
    674                         }
    675                         else
    676                             rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    677                                                      N_("Failed to set appropriate promiscuous mode"));
    678                     }
    679                     else
    680                         rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    681                                                  N_("Failed to activate promiscuous mode for VNIC"));
    682                 }
    683                 else
    684                     rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    685                                              N_("Failed to set physical address for VNIC"));
    686             }
    687             else
    688                 rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    689                                          N_("Failed to bind VNIC"));
    690         }
    691         else
    692             rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    693                                          N_("VNIC type is not ethernet"));
    694     }
    695     else
    696         rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    697                                          N_("Failed to obtain VNIC info"));
    698     g_pfnLibDlpiClose(pThis->pDeviceHandle);
    699     return rc;
    700 }
    701 
    702 
    703 /**
    704  * Crossbow: Converts a Solaris DLPI error code to a VBox error code.
    705  *
    706  * @returns corresponding VBox error code.
    707  * @param   rc  DLPI error code (DLPI_* defines).
    708  */
    709 static int SolarisDLPIErr2VBoxErr(int rc)
    710 {
    711     switch (rc)
    712     {
    713         case DLPI_SUCCESS:          return VINF_SUCCESS;
    714         case DLPI_EINVAL:           return VERR_INVALID_PARAMETER;
    715         case DLPI_ELINKNAMEINVAL:   return VERR_INVALID_NAME;
    716         case DLPI_EINHANDLE:        return VERR_INVALID_HANDLE;
    717         case DLPI_ETIMEDOUT:        return VERR_TIMEOUT;
    718         case DLPI_FAILURE:          return VERR_GENERAL_FAILURE;
    719 
    720         case DLPI_EVERNOTSUP:
    721         case DLPI_EMODENOTSUP:
    722         case DLPI_ERAWNOTSUP:
    723         /* case DLPI_ENOTENOTSUP: */
    724         case DLPI_EUNAVAILSAP:      return VERR_NOT_SUPPORTED;
    725 
    726         /*  Define VBox error codes for these, if really needed. */
    727         case DLPI_ENOLINK:
    728         case DLPI_EBADLINK:
    729         /* case DLPI_ENOTEIDINVAL: */
    730         case DLPI_EBADMSG:
    731         case DLPI_ENOTSTYLE2:       return VERR_GENERAL_FAILURE;
    732     }
    733 
    734     AssertMsgFailed(("SolarisDLPIErr2VBoxErr: Unhandled error %d\n", rc));
    735     return VERR_UNRESOLVED_ERROR;
    736 }
    737 
    738 # else  /* VBOX_WITH_CROSSBOW */
    739 
    740583/** From net/if_tun.h, installed by Universal TUN/TAP driver */
    741584# define TUNNEWPPA                   (('T'<<16) | 0x0001)
     
    897740}
    898741
    899 # endif /* VBOX_WITH_CROSSBOW */
    900742#endif  /* RT_OS_SOLARIS */
    901743
     
    948790        pThis->hFileDevice = NIL_RTFILE;
    949791    }
    950 
    951 # ifndef VBOX_WITH_CROSSBOW
    952     if (pThis->iIPFileDes != -1)
    953     {
    954         close(pThis->iIPFileDes);
    955         pThis->iIPFileDes = -1;
    956     }
    957 # endif
    958792
    959793    /*
     
    1014848    pThis->pszDeviceName                = NULL;
    1015849#ifdef RT_OS_SOLARIS
    1016 # ifdef VBOX_WITH_CROSSBOW
    1017     pThis->pDeviceHandle                = NULL;
    1018 # else
    1019850    pThis->iIPFileDes                   = -1;
    1020 # endif
    1021851    pThis->fStatic                      = true;
    1022852#endif
     
    1093923        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: failed to query \"TAPTerminateApplication\""));
    1094924
    1095 # ifdef VBOX_WITH_CROSSBOW
    1096     rc = CFGMR3QueryBytes(pCfg, "MAC", &pThis->MacAddress, sizeof(pThis->MacAddress));
    1097     if (RT_FAILURE(rc))
    1098         return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Configuration error: Failed to query \"MAC\""));
    1099 # endif
    1100 
    1101925    rc = CFGMR3QueryStringAlloc(pCfg, "Device", &pThis->pszDeviceName);
    1102926    if (RT_FAILURE(rc))
     
    1115939     * Do the setup.
    1116940     */
    1117 # ifdef VBOX_WITH_CROSSBOW
    1118     if (!VBoxLibDlpiFound())
    1119     {
    1120         return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    1121                                        N_("Failed to load library %s required for host interface networking."), LIB_DLPI);
    1122     }
    1123     rc = SolarisOpenVNIC(pThis);
    1124 # else
    1125941    rc = SolarisTAPAttach(pThis);
    1126 # endif
    1127942    if (RT_FAILURE(rc))
    1128943        return rc;
Note: See TracChangeset for help on using the changeset viewer.

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