DevINIP.cpp revision 25747178cb66800d8386c20b8ffd87f78f24f4e5
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * DevINIP - Internal Network IP stack device/service.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Copyright (C) 2007-2009 Sun Microsystems, Inc.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * available from http://www.virtualbox.org. This file is free software;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * you can redistribute it and/or modify it under the terms of the GNU
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * General Public License (GPL) as published by the Free Software
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * additional information or have any questions.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/*******************************************************************************
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync* Header Files *
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync*******************************************************************************/
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#include <iprt/cdefs.h> /* include early to allow __BEGIN_DECLS hack */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#include <iprt/mem.h> /* include anything of ours that the lwip headers use. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/* All lwip header files are not C++ safe. So hack around this. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/*******************************************************************************
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync* Macros and Defines *
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync*******************************************************************************/
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Maximum frame size this device can handle. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/*******************************************************************************
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync* Structures and Typedefs *
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync*******************************************************************************/
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Internal Network IP stack device instance data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsynctypedef struct DEVINTNETIP
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The base interface. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The network port this device provides. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The base interface of the network driver below us. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The connector of the network driver below us. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the device instance. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** MAC adress. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Static IP address of the interface. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Netmask of the interface. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Gateway for the interface. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** lwIP network interface description. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** lwIP ARP timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** lwIP TCP fast timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** lwIP TCP slow timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** lwIP semaphore to coordinate TCPIP init/terminate. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** hack: get linking right. remove this eventually, once the device
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * provides a proper interface to all IP stack functions. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/*******************************************************************************
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync* Global Variables *
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync*******************************************************************************/
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Pointer to the (only) instance data in this device.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * really ugly hack to avoid linking problems on unix style platforms
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * using .a libraries for now.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/*******************************************************************************
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync* Internal Functions *
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync*******************************************************************************/
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(void) devINIPARPTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(void) devINIPTCPFastTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(void) devINIPTCPSlowTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(err_t) devINIPOutput(struct netif *netif, struct pbuf *p,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(err_t) devINIPOutputRaw(struct netif *netif,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync struct pbuf *p);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(err_t) devINIPInterface(struct netif *netif);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * ARP cache timeout handling for lwIP.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pDevIns Device instance.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pTimer Pointer to timer.
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsyncstatic DECLCALLBACK(void) devINIPARPTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync TMTimerSetMillies(pThis->ARPTimer, ARP_TMR_INTERVAL);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * TCP fast timer handling for lwIP.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pDevIns Device instance.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pTimer Pointer to timer.
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsyncstatic DECLCALLBACK(void) devINIPTCPFastTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync TMTimerSetMillies(pThis->TCPFastTimer, TCP_FAST_INTERVAL);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * TCP slow timer handling for lwIP.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pDevIns Device instance.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pTimer Pointer to timer.
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsyncstatic DECLCALLBACK(void) devINIPTCPSlowTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync TMTimerSetMillies(pThis->TCPSlowTimer, TCP_SLOW_INTERVAL);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Output a TCP/IP packet on the interface. Uses the generic lwIP ARP
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * code to resolve the address and call the link-level packet function.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns lwIP error code
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param netif Interface on which to send IP packet.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param p Packet data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param ipaddr Destination IP address.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(err_t) devINIPOutput(struct netif *netif, struct pbuf *p,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: netif=%p p=%p ipaddr=%#04x\n", __FUNCTION__, netif, p,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Output a raw packet on the interface.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns lwIP error code
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param netif Interface on which to send frame.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param p Frame data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(err_t) devINIPOutputRaw(struct netif *netif,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: netif=%p p=%p\n", __FUNCTION__, netif, p));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* Silently ignore packets being sent while lwIP isn't set up. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync lwip_pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = g_pDevINIPData->pDrv->pfnSend(g_pDevINIPData->pDrv,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync lwip_pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: return %d (vbox: %Rrc)\n", __FUNCTION__, rc, lrc));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Implements the ethernet interface backend initialization for lwIP.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns lwIP error code
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param netif Interface to configure.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(err_t) devINIPInterface(struct netif *netif)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync memcpy(netif->hwaddr, &g_pDevINIPData->MAC, sizeof(g_pDevINIPData->MAC));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync TMTimerSetMillies(g_pDevINIPData->ARPTimer, ARP_TMR_INTERVAL);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Wait until data can be received.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns VBox status code. VINF_SUCCESS means there is at least one receive descriptor available.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pInterface PDM network port interface pointer.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param cMillies Number of milliseconds to wait. 0 means return immediately.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(int) devINIPWaitInputAvail(PPDMINETWORKPORT pInterface, unsigned cMillies)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pInterface=%p\n", __FUNCTION__, pInterface));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: return VINF_SUCCESS\n", __FUNCTION__));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Receive data and pass it to lwIP for processing.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns VBox status code
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pInterface PDM network port interface pointer.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pvBuf Pointer to frame data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param cb Frame size.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(int) devINIPInput(PPDMINETWORKPORT pInterface,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync struct pbuf *p, *q;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pInterface=%p pvBuf=%p cb=%lu\n", __FUNCTION__, pInterface,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* Silently ignore packets being received while lwIP isn't set up. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* We allocate a pbuf chain of pbufs from the pool. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync lwip_pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* Fill the buffers, and clean out unused buffer space. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync memset(((uint8_t *)q->payload) + cb, '\0', q->len - cb);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync lwip_pbuf_header(p, -(ssize_t)sizeof(struct eth_hdr));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync lwip_etharp_arp_input(iface, (struct eth_addr *)iface->hwaddr, p);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Signals the end of lwIP TCPIP initialization.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param arg opaque argument, here the pointer to the semaphore.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(void) devINIPTcpipInitDone(void *arg)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Queries an interface to the device.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns Pointer to interface.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns NULL if the interface was not supported by the device.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pInterface Pointer to this interface structure.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param enmInterface The requested interface identification.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @thread Any thread.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(void *) devINIPQueryInterface(PPDMIBASE pInterface,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync PDEVINTNETIP pThis = (PDEVINTNETIP)((uintptr_t)pInterface - RT_OFFSETOF(DEVINTNETIP, IBase));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Construct an internal networking IP stack device instance.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns VBox status.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pDevIns The device instance data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * If the registration structure is needed, pDevIns->pDevReg points to it.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param iInstance Instance number. Use this to figure out which registers
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * and such to use.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * he device number is also found in pDevIns->iInstance, but since it's
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * likely to be freqently used PDM passes it as parameter.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pCfgHandle Configuration node handle for the device. Use this to obtain the configuration
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * of the device instance. It's also found in pDevIns->pCfgHandle, but like
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * iInstance it's expected to be used a bit in this function.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(int) devINIPConstruct(PPDMDEVINS pDevIns, int iInstance,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync PDEVINTNETIP pThis = PDMINS_2_DATA(pDevIns, PDEVINTNETIP);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pDevIns=%p iInstance=%d pCfgHandle=%p\n", __FUNCTION__,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Validate the config.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync if (!CFGMR3AreValuesValid(pCfgHandle, "MAC\0IP\0Netmask\0Gateway\0"))
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Unknown Internal Networking IP configuration option"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Init the static parts.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* Pointer to device instance */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* IBase */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync pThis->IBase.pfnQueryInterface = devINIPQueryInterface;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* INetworkPort */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync pThis->INetworkPort.pfnWaitReceiveAvail = devINIPWaitInputAvail;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Get the configuration settings.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = CFGMR3QueryBytes(pCfgHandle, "MAC", &pThis->MAC, sizeof(pThis->MAC));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = CFGMR3QueryString(pCfgHandle, "MAC", &szMAC[0], sizeof(szMAC));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Configuration error: Failed to get the \"MAC\" value"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = CFGMR3QueryStringAlloc(pCfgHandle, "IP", &pThis->pszIP);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Configuration error: Failed to get the \"IP\" value"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = CFGMR3QueryStringAlloc(pCfgHandle, "Netmask", &pThis->pszNetmask);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Configuration error: Failed to get the \"Netmask\" value"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = CFGMR3QueryStringAlloc(pCfgHandle, "Gateway", &pThis->pszGateway);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Configuration error: Failed to get the \"Gateway\" value"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Attach driver and query the network connector interface.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync "Network Port");
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync pThis->pDrv = (PPDMINETWORKCONNECTOR)pThis->pDrvBase->pfnQueryInterface(pThis->pDrvBase, PDMINTERFACE_NETWORK_CONNECTOR);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync AssertMsgFailed(("Failed to obtain the PDMINTERFACE_NETWORK_CONNECTOR interface!\n"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync rc = PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Configuration error: Invalid \"Netmask\" value"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync N_("Configuration error: Invalid \"Gateway\" value"));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Initialize lwIP.
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPARPTimer, pThis,
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP ARP", &pThis->ARPTimer);
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPFastTimer, pThis,
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP fast TCP", &pThis->TCPFastTimer);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync TMTimerSetMillies(pThis->TCPFastTimer, TCP_FAST_INTERVAL);
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPSlowTimer, pThis,
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP slow TCP", &pThis->TCPSlowTimer);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync TMTimerSetMillies(pThis->TCPFastTimer, TCP_SLOW_INTERVAL);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync lwip_tcpip_init(devINIPTcpipInitDone, &pThis->LWIPTcpInitSem);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Set up global pointer to interface data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync ret = netif_add(&pThis->IntNetIF, &ipaddr, &netmask, &gw, NULL,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* link hack */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Destruct a device instance.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Most VM resources are freed by the VM. This callback is provided so that any non-VM
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * resources can be freed correctly.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns VBox status.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pDevIns The device instance data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncstatic DECLCALLBACK(int) devINIPDestruct(PPDMDEVINS pDevIns)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync PDEVINTNETIP pThis = PDMINS_2_DATA(pDevIns, PDEVINTNETIP);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync LogFlow(("%s: pDevIns=%p\n", __FUNCTION__, pDevIns));
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Query whether lwIP is initialized or not. Since there is only a single
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * instance of this device ever for a VM, it can be a global function.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns True if lwIP is initialized.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Internal network IP stack device registration record.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* u32Version */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* szDeviceName */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync "IntNetIP",
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pszDescription */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync "Internal Network IP stack device",
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* fFlags */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* fClass. As this is used by the storage devices, it must come earlier. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* cMaxInstances */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* cbInstance */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnConstruct */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnDestruct */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnRelocate */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnIOCtl */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnPowerOn */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnReset */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnSuspend */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnResume */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnAttach */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnDetach */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnQueryInterface */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnInitComplete */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnPowerOff */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* pfnSoftReset */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /* u32VersionEnd */