NetIf-freebsd.cpp revision a3e5b1cf4ab5395f45b7ed855c72f70e4bcf4219
/* $Id$ */
/** @file
* Main - NetIfList, FreeBSD implementation.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*
* Original (C) 2009 Fredrik Lindberg <fli@shapeshifter.se>. Contributed
* to VirtualBox under the MIT license by the author.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_MAIN
#include <net/if_types.h>
/*
* around free. This collides with Free defined in xpcom/include/nsIMemory.h
* Undefine it and hope for the best
*/
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <list>
#include "HostNetworkInterfaceImpl.h"
#include "netif.h"
#include "Logging.h"
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
{
if (!(iAddrMask & (1 << i)))
continue;
pAddresses[i] = sa;
}
}
{
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 VERR_INTERNAL_ERROR;
}
{
{
case AF_INET:
{
}
break;
case AF_INET6:
{
sizeof(pInfo->IPv6Address));
sizeof(pInfo->IPv6NetMask));
}
break;
default:
break;
}
}
{
int rc = VINF_SUCCESS;
int aiMib[6];
unsigned short u16DefaultIface;
/* 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;
}
if (!pNew)
{
rc = VERR_NO_MEMORY;
break;
}
/* 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;
}