NetIf-linux.cpp revision c58c984e78e29e8e10765f6a105263c770ab4d23
/* $Id$ */
/** @file
* Main - NetIfList, Linux implementation.
*/
/*
* Copyright (C) 2008 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 <stdio.h>
#include <unistd.h>
#include "HostNetworkInterfaceImpl.h"
#include "netif.h"
#include "Logging.h"
static int getDefaultIfaceName(char *pszName)
{
char szBuf[1024];
char szIfName[17];
char szAddr[129];
char szGateway[129];
char szMask[129];
int iTmp;
unsigned uFlags;
if (fp)
{
{
continue;
{
pszName[16] = 0;
return VINF_SUCCESS;
}
}
}
return VERR_INTERNAL_ERROR;
}
{
// Zeroing out pInfo is a bad idea as it should contain both short and long names at
// this point. So make sure the structure is cleared by the caller if necessary!
// memset(pInfo, 0, sizeof(*pInfo));
{
{
case ARPHRD_ETHER:
break;
default:
break;
}
/* Generate UUID from name and MAC address. */
RTUuidClear(&uuid);
if (fp)
{
char szName[30];
for (;;)
{
"%08x%08x%08x%08x"
" %02x %02x %02x %02x %20s\n",
if (n == EOF)
break;
{
n, uLength));
break;
}
{
}
}
}
/*
* I wish I could do simple ioctl here, but older kernels require root
* privileges for any ethtool commands.
*/
char szBuf[256];
/* First, we try to retrieve the speed via sysfs. */
else
{
/* Failed to get speed via sysfs, go to plan B. */
if (RT_SUCCESS(rc))
{
}
else
return rc;
}
}
return VINF_SUCCESS;
}
{
char szDefaultIface[256];
if (RT_FAILURE(rc))
{
Log(("NetIfList: Failed to find default interface.\n"));
szDefaultIface[0] = 0;
}
if (sock >= 0)
{
if (fp)
{
char buf[256];
{
if (!pszEndOfName)
continue;
*pszEndOfName = 0;
if (RT_FAILURE(rc))
break;
{
else
{
else
}
}
}
}
}
else
return rc;
}
{
int rc = VINF_SUCCESS;
if (sock < 0)
return VERR_NOT_IMPLEMENTED;
return rc;
}