VirtualBox

Ignore:
Timestamp:
May 4, 2009 12:34:14 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46800
Message:

Solaris/VBoxNetFlt: #3183 DLPI style 2 support (disabled, untested).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c

    r18878 r19323  
    5656#include <sys/dlpi.h>
    5757#include <sys/types.h>
     58#ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2
     59# include <sys/time.h>
     60#endif
    5861#include <sys/param.h>
    5962#include <sys/ethernet.h>
     
    9598#define DEVICE_DESC_DRV          "VirtualBox NetDrv"
    9699#define DEVICE_DESC_MOD          "VirtualBox NetMod"
     100
     101#ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2
     102# define ISDIGIT(c)              ((c) >= '0' && (c) <= '9')
     103#endif
    97104
    98105/** @todo Remove the below hackery once done! */
     
    12821289 * @returns VBox status code.
    12831290 * @param   pQueue      Pointer to the read queue.
    1284  * @param   pMsg        Pointer to the request message.
    12851291 */
    12861292static int vboxNetFltSolarisPhysAddrReq(queue_t *pQueue)
     
    14221428    VN_RELE(pVNodeHeld);
    14231429}
     1430
     1431#ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2
     1432/**
     1433 * Set the DLPI style-2 PPA via an attach request.
     1434 *
     1435 * @returns VBox status code.
     1436 * @param   hDevice        Layered device handle.
     1437 * @param   PPA            Physical Point of Attachment (PPA) number.
     1438 */
     1439static int vboxNetFltSolarisAttachReq(ldi_handle_t hDevice, int PPA)
     1440{
     1441    int rc;
     1442    t_uscalar_t Cmd = DL_ATTACH_REQ;
     1443    size_t cbReq = DL_ATTACH_REQ_SIZE;
     1444    mblk_t *pAttachMsg = mexchange(NULL, NULL, cbReq, M_PROTO, Cmd);
     1445    if (RT_UNLIKELY(!pAttachMsg))
     1446        return VERR_NO_MEMORY;
     1447
     1448    dl_attach_req_t *pAttachReq = (dl_attach_req_t *)pAttachMsg->b_rptr;
     1449    pAttachReq->dl_ppa = PPA;
     1450
     1451    rc = ldi_putmsg(hDevice, pAttachMsg);
     1452    if (!rc)
     1453    {
     1454        rc = ldi_getmsg(hDevice, &pAttachMsg, NULL);
     1455        if (!rc)
     1456            return VINF_SUCCESS;
     1457        else
     1458            LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachReq ldi_getmsg failed. rc=%d\n", rc));
     1459    }
     1460    else
     1461        LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachReq ldi_putmsg failed. rc=%d\n", rc));
     1462
     1463    return VERR_GENERAL_FAILURE;
     1464}
     1465#endif
    14241466
    14251467
     
    16391681
    16401682
     1683#ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2
     1684/**
     1685 * Opens up the DLPI style 2 link that requires explicit PPA attach
     1686 * phase.
     1687 *
     1688 * @param   pThis       The instance.
     1689 */
     1690static int vboxNetFltSolarisOpenStyle2(PVBOXNETFLTINS pThis, ldi_ident_t *pDevId)
     1691{
     1692    /*
     1693     * Strip out PPA from the device name, eg: "ce3".
     1694     */
     1695    char *pszDev = RTStrDup(pThis->szName);
     1696    char *pszEnd = strchr(pszDev, '\0');
     1697    int PPALen = 0;
     1698    while (--pszEnd > pszDev)
     1699    {
     1700        if (!ISDIGIT(*pszEnd))
     1701            break;
     1702        PPALen++;
     1703    }
     1704    pszEnd++;
     1705
     1706    char szDev[128];
     1707    RTStrPrintf(szDev, sizeof(szDev), "/dev/%s", pszDev);
     1708    RTStrFree(pszDev);
     1709
     1710    int rc;
     1711    long PPA;
     1712    if (   pszEnd
     1713        && ddi_strtol(pszEnd, NULL, 10, &PPA) == 0)
     1714    {
     1715        pszEnd -= PPALen;
     1716        *pszEnd = '\0';
     1717        /*
     1718         * Try open the device as DPLI style 2.
     1719         */
     1720        rc = ldi_open_by_name(szDev, FREAD | FWRITE, kcred, &pThis->u.s.hIface, *pDevId);
     1721        if (!rc)
     1722        {
     1723            /*
     1724             * Attach the PPA explictly.
     1725             */
     1726            rc = dl_attach(pThis->u.s.hIface, (int)PPA, NULL);
     1727            if (!rc)
     1728                return VINF_SUCCESS;
     1729
     1730            ldi_close(pThis->u.s.hIface, FREAD | FWRITE, kcred);
     1731            LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStyle2 dl_attach failed. rc=%d\n", rc));
     1732        }
     1733        else
     1734            LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStyle2 Failed to open szDev=%s\n", szDev));
     1735    }
     1736    else
     1737        LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStyle2 Failed to construct PPA.\n"));
     1738
     1739    return VERR_INTNET_FLT_IF_FAILED;
     1740}
     1741#endif
     1742
     1743
    16411744/**
    16421745 * Opens up dedicated stream on top of the interface.
     
    16521755    int ret;
    16531756
    1654     /** @todo support DLPI style 2.*/
     1757    /** @todo enable and test DLPI style 2.*/
    16551758    /*
    16561759     * Try style-1 open first.
     
    16681771        rc = ldi_open_by_name(szDev, FREAD | FWRITE, kcred, &pThis->u.s.hIface, DevId);
    16691772    }
     1773
     1774#ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2
     1775    if (rc)
     1776    {
     1777        /*
     1778         * Try DLPI style 2.
     1779         */       
     1780        rc = vboxNetFltSolarisOpenStyle2(pThis, &DevId);
     1781        if (RT_FAILURE(rc))
     1782            LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream vboxNetFltSolarisOpenStyle2 failed. rc=%d\n", rc));
     1783    }
     1784#endif
    16701785
    16711786    ldi_ident_release(DevId);
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