Changeset 19323 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt
- Timestamp:
- May 4, 2009 12:34:14 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 46800
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/solaris/VBoxNetFlt-solaris.c
r18878 r19323 56 56 #include <sys/dlpi.h> 57 57 #include <sys/types.h> 58 #ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2 59 # include <sys/time.h> 60 #endif 58 61 #include <sys/param.h> 59 62 #include <sys/ethernet.h> … … 95 98 #define DEVICE_DESC_DRV "VirtualBox NetDrv" 96 99 #define DEVICE_DESC_MOD "VirtualBox NetMod" 100 101 #ifdef VBOX_WITH_NETFLT_SOLARIS_DLPISTYLE2 102 # define ISDIGIT(c) ((c) >= '0' && (c) <= '9') 103 #endif 97 104 98 105 /** @todo Remove the below hackery once done! */ … … 1282 1289 * @returns VBox status code. 1283 1290 * @param pQueue Pointer to the read queue. 1284 * @param pMsg Pointer to the request message.1285 1291 */ 1286 1292 static int vboxNetFltSolarisPhysAddrReq(queue_t *pQueue) … … 1422 1428 VN_RELE(pVNodeHeld); 1423 1429 } 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 */ 1439 static 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 1424 1466 1425 1467 … … 1639 1681 1640 1682 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 */ 1690 static 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 1641 1744 /** 1642 1745 * Opens up dedicated stream on top of the interface. … … 1652 1755 int ret; 1653 1756 1654 /** @todo support DLPI style 2.*/1757 /** @todo enable and test DLPI style 2.*/ 1655 1758 /* 1656 1759 * Try style-1 open first. … … 1668 1771 rc = ldi_open_by_name(szDev, FREAD | FWRITE, kcred, &pThis->u.s.hIface, DevId); 1669 1772 } 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 1670 1785 1671 1786 ldi_ident_release(DevId);
Note:
See TracChangeset
for help on using the changeset viewer.