NetIf-solaris.cpp revision 061b6c37b680038a9f23ac4a9625e7032b638fec
/* $Id$ */
/** @file
* Main - NetIfList, Solaris implementation.
*/
/*
* Copyright (C) 2008-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_MAIN
#include <list>
#include "Logging.h"
#include "HostNetworkInterfaceImpl.h"
#include "netif.h"
#ifdef VBOX_WITH_HOSTNETIF_API
#include <map>
#include <string>
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#include <limits.h>
#include <stdio.h>
#include <libdevinfo.h>
#include "DynLoadLibSolaris.h"
{
char szBuf[RTPATH_MAX];
if (fp)
{
{
/* Skip the id string */
int i = 0;
pszDigit++;
pszDigit++;
}
else
LogFlowFunc(("fgets returned nothing\n"));
}
return uSpeed;
}
{
/*
* Get the instance number from the interface name, then clip it off.
*/
int cbInstance = 0;
for (int i = 0; i < cbIface - 1; i++)
{
if (!RT_C_IS_DIGIT(*pszEnd))
break;
cbInstance++;
pszEnd--;
}
return uInstance;
}
{
char szMask[RTPATH_MAX];
if (uSpeed == 0)
{
/* Lets try module:instance approach */
if (uSpeed == 0)
LogRel(("queryIfaceSpeed: failed to get speed for %s(instance=%u) via kstat\n", szDevName, uInstance));
}
}
{
std::list<ComObjPtr<HostNetworkInterface> > *pList = (std::list<ComObjPtr<HostNetworkInterface> > *)pvHostNetworkInterfaceList;
static NICMap SolarisNICMap;
if (SolarisNICMap.empty())
{
SolarisNICMap.insert(NICPair("vboxvnic_template", "VirtualBox Virtual Network Interface Template"));
}
/*
* Try picking up description from our NIC map.
*/
char szNICInstance[128];
char szNICDesc[256];
if (Description != "VirtualBox Host Ethernet")
{
if (Description != "")
else
}
else
/*
* Try to get IP V4 address and netmask as well as Ethernet address.
*/
if (Sock > 0)
{
{
/*
* We might fail if the interface has not been assigned an IP address.
* That doesn't matter; as long as it's plumbed we can pick it up.
* But, if it has not acquired an IP address we cannot obtain it's MAC
* address this way, so we just use all zeros there.
*/
{
}
}
{
}
{
}
}
/*
* Try to get IP V6 address and netmask.
*/
if (Sock > 0)
{
{
}
{
}
}
/*
* Construct UUID with interface name and the MAC address if available.
*/
RTUuidClear(&Uuid);
else
}
static boolean_t vboxSolarisAddLinkHostIface(const char *pszIface, void *pvHostNetworkInterfaceList)
{
/*
* Skip IPSEC interfaces. It's at IP level.
*/
return _B_FALSE;
/*
* Skip our own dynamic VNICs but don't skip VNIC templates.
* These names originate from VBoxNetFltBow-solaris.c, hardcoded here for now.
*/
return _B_FALSE;
/*
* Clip off the zone instance number from the interface name (if any).
*/
char szIfaceName[128];
if (pszColon)
*pszColon = '\0';
/*
* Get the instance number from the interface name, then clip it off.
*/
int cbInstance = 0;
for (int i = 0; i < cbIface - 1; i++)
{
if (!RT_C_IS_DIGIT(*pszEnd))
break;
cbInstance++;
pszEnd--;
}
/*
* Add the interface.
*/
/*
* Continue walking...
*/
return _B_FALSE;
}
static bool vboxSolarisSortNICList(const ComObjPtr<HostNetworkInterface> Iface1, const ComObjPtr<HostNetworkInterface> Iface2)
{
}
static bool vboxSolarisSameNIC(const ComObjPtr<HostNetworkInterface> Iface1, const ComObjPtr<HostNetworkInterface> Iface2)
{
}
static int vboxSolarisAddPhysHostIface(di_node_t Node, di_minor_t Minor, void *pvHostNetworkInterfaceList)
{
/*
* Skip aggregations.
*/
return DI_WALK_CONTINUE;
/*
* Skip softmacs.
*/
return DI_WALK_CONTINUE;
return DI_WALK_CONTINUE;
}
{
/*
* Use libdevinfo for determining all physical interfaces.
*/
if (Root != DI_NODE_NIL)
{
}
/*
* Use libdlpi for determining all DLPI interfaces.
*/
if (VBoxSolarisLibDlpiFound())
/*
* This gets only the list of all plumbed logical interfaces.
* This is needed for zones which cannot access the device tree
* and in this case we just let them use the list of plumbed interfaces
* on the zone.
*/
if (Sock > 0)
{
if (!rc)
{
if (!rc)
{
for (int i = 0; i < IfNum.lifn_count; i++)
{
/*
* Skip loopback interfaces.
*/
continue;
#if 0
if (rc >= 0)
{
// SIOCGLIFNETMASK
/*
* We might fail if the interface has not been assigned an IP address.
* That doesn't matter; as long as it's plumbed we can pick it up.
* But, if it has not acquired an IP address we cannot obtain it's MAC
* address this way, so we just use all zeros there.
*/
if (rc >= 0)
}
#endif
}
}
}
}
/*
* Weed out duplicates caused by dlpi_walk inconsistencies across Nevadas.
*/
return VINF_SUCCESS;
}
#else
{
return VERR_NOT_IMPLEMENTED;
}
#endif
{
return VERR_NOT_IMPLEMENTED;
}