NetIf-darwin.cpp revision 7547322ca3d142bab6d209a69765257c1883da30
/* $Id$ */
/** @file
* Main - NetIfList, Darwin 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 *
*******************************************************************************/
/*
* Deal with conflicts first.
* PVM - BSD mess, that FreeBSD has correct a long time ago.
*/
#define LOG_GROUP LOG_GROUP_MAIN
#include <string.h>
#include <net/if_types.h>
#include <ifaddrs.h>
#include <errno.h>
#include <unistd.h>
#include <list>
#include "HostNetworkInterfaceImpl.h"
#include "netif.h"
#include "iokit.h"
#include "Logging.h"
#if 0
{
if (sock < 0)
{
return NULL;
}
if (rc)
{
return VERR_INTERNAL_ERROR;
}
while (pEtherNICs)
{
{
}
else
{
continue;
{
case AF_INET:
break;
break;
case AF_INET6:
break;
sizeof(pNew->IPv6Address));
sizeof(pNew->IPv6NetMask));
break;
}
}
/* next, free current */
void *pvFree = pEtherNICs;
}
return VINF_SUCCESS;
}
#else
#define ROUNDUP(a) \
{
if (iAddrMask & (1 << i))
{
pAddresses[i] = sa;
}
else
pAddresses[i] = NULL;
}
}
{
{
case AF_INET:
{
}
break;
case AF_INET6:
{
sizeof(pInfo->IPv6Address));
sizeof(pInfo->IPv6NetMask));
}
break;
default:
break;
}
}
static int getDefaultIfaceIndex(unsigned short *pu16Index)
{
int aiMib[6];
aiMib[2] = 0;
aiMib[5] = 0;
{
return RTErrConvertFromErrno(errno);
}
return VERR_NO_MEMORY;
{
return RTErrConvertFromErrno(errno);
}
{
{
Log(("getDefaultIfaceIndex: Got message %u while expecting %u.\n",
//rc = VERR_INTERNAL_ERROR;
continue;
}
{
/* Extract addresses from the message. */
{
continue;
mask &&
{
return VINF_SUCCESS;
}
}
}
}
return 0; /* Failed to find default interface, take the first one in the list. */
}
{
int rc = VINF_SUCCESS;
int aiMib[6];
unsigned short u16DefaultIface = 0; /* initialized to shut up gcc */
/* Get the index of the interface associated with default route. */
if (RT_FAILURE(rc))
return rc;
aiMib[2] = 0;
aiMib[5] = 0;
{
return RTErrConvertFromErrno(errno);
}
return VERR_NO_MEMORY;
{
return RTErrConvertFromErrno(errno);
}
if (sock < 0)
{
return RTErrConvertFromErrno(errno);
}
{
{
Log(("NetIfList: Got message %u while expecting %u.\n",
break;
}
{
break;
}
if (!pNew)
{
rc = VERR_NO_MEMORY;
break;
}
/*
* If we found the adapter in the list returned by
* DarwinGetEthernetControllers() copy the name and UUID from there.
*/
if (pNIC)
{
}
else
{
/* Generate UUID from name and MAC address. */
RTUuidClear(&uuid);
}
{
break;
(char *)(pIfAddrMsg + 1),
pNew);
}
{
{
}
else
else
{
/* Make sure the default interface gets to the beginning. */
else
}
}
}
{
}
return rc;
}
{
int rc = VINF_SUCCESS;
int aiMib[6];
aiMib[2] = 0;
aiMib[5] = 0;
{
return RTErrConvertFromErrno(errno);
}
return VERR_NO_MEMORY;
{
return RTErrConvertFromErrno(errno);
}
if (sock < 0)
{
return RTErrConvertFromErrno(errno);
}
{
{
Log(("NetIfList: Got message %u while expecting %u.\n",
break;
}
{
break;
if (!fSkip)
(char *)(pIfAddrMsg + 1),
pInfo);
}
{
/* Generate UUID from name and MAC address. */
RTUuidClear(&uuid);
{
}
else
return VINF_SUCCESS;
}
}
return rc;
}
/**
* Retrieve the physical link speed in megabits per second. If the interface is
* not up or otherwise unavailable the zero speed is returned.
*
* @returns VBox status code.
*
* @param pcszIfName Interface name.
* @param puMbits Where to store the link speed.
*/
{
return VERR_NOT_IMPLEMENTED;
}
#endif