DevINIP.cpp revision 1e9e76e4273dcc2e3d560a0f3605c46f0013eb7b
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * DevINIP - Internal Network IP stack device/service.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * Copyright (C) 2007-2013 Oracle Corporation
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * available from http://www.virtualbox.org. This file is free software;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * you can redistribute it and/or modify it under the terms of the GNU
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * General Public License (GPL) as published by the Free Software
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/*******************************************************************************
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Header Files *
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync*******************************************************************************/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#include <iprt/cdefs.h> /* include early to allow RT_C_DECLS_BEGIN hack */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#include <iprt/mem.h> /* include anything of ours that the lwip headers use. */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* All lwip header files are not C++ safe. So hack around this. */
#include "VBoxDD.h"
#ifdef VBOX_WITH_NEW_LWIP
# include "VBoxLwipCore.h"
typedef struct DEVINTNETIP
char *pszIP;
char *pszNetmask;
char *pszGateway;
const void *pLinkHack;
bool fLnkUp;
#ifndef VBOX_WITH_NEW_LWIP
bool fTermination;
int rcInitialization;
#ifndef VBOX_WITH_NEW_LWIP
static DECLCALLBACK(err_t) devINIPOutput(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr);
#ifndef VBOX_WITH_NEW_LWIP
static DECLCALLBACK(err_t) devINIPOutput(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
#ifndef VBOX_WITH_NEW_LWIP
return lrc;
if (g_pDevINIPData)
return ERR_IF;
rc = g_pDevINIPData->pDrv->pfnAllocBuf(g_pDevINIPData->pDrv, DEVINIP_MAX_FRAME, NULL /*pGso*/, &pSgBuf);
#if ETH_PAD_SIZE
if (cbBuf)
#if ETH_PAD_SIZE
return lrc;
#ifdef VBOX_WITH_NEW_LWIP
return ERR_OK;
static DECLCALLBACK(int) devINIPNetworkConfiguration(PPDMDEVINS pDevIns, PDEVINTNETIP pThis, PCFGMNODE pCfg)
return rc;
return rc;
return rc;
return VINF_SUCCESS;
static DECLCALLBACK(int) devINIPNetworkDown_WaitInputAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
return VINF_SUCCESS;
static DECLCALLBACK(int) devINIPNetworkDown_Input(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
struct pbuf *p, *q;
if (!g_pDevINIPData)
return VINF_SUCCESS;
#if ETH_PAD_SIZE
if (p != NULL)
#if ETH_PAD_SIZE
#ifndef VBOX_WITH_NEW_LWIP
if (lrc)
lwip_pbuf_free(p);
return rc;
#ifndef VBOX_WITH_NEW_LWIP
goto done;
goto done;
goto done;
if (!ret)
goto done;
#ifndef VBOX_WITH_NEW_LWIP
done:
done:
#ifdef VBOX_WITH_NEW_LWIP
return VINF_SUCCESS;
return PDMNETWORKLINKSTATE_UP;
return PDMNETWORKLINKSTATE_DOWN;
static DECLCALLBACK(int) devINIPSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
if (fNewUp)
return VINF_SUCCESS;
const char *pszIID)
return NULL;
#ifndef VBOX_WITH_NEW_LWIP
return VINF_SUCCESS;
#ifdef VBOX_WITH_NEW_LWIP
#ifdef VBOX_WITH_NEW_LWIP
macStr++;
AssertMsgReturn(pThis->pDrv, ("Failed to obtain the PDMINETWORKUP interface!\n"), VERR_PDM_MISSING_INTERFACE_BELOW);
#ifndef VBOX_WITH_NEW_LWIP
# if MEM_LIBC_MALLOC == 0
return rc;
bool DevINIPConfigured(void)
sizeof(DEVINTNETIP),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,