VirtualBox

Ignore:
Timestamp:
Apr 27, 2015 3:20:42 AM (10 years ago)
Author:
vboxsync
Message:

G/c VBOX_WITH_NEW_LWIP. This option only affects DevINIP/DrvVD (as
NAT Network always uses the new one) and it has been on since 4.3 was
released. Old lwip sources will be removed in a separate commit.

Same object code is produced modulo a few LINE changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevINIP.cpp

    r48947 r55432  
    3434#include "lwip/pbuf.h"
    3535#include "lwip/netif.h"
    36 #ifndef VBOX_WITH_NEW_LWIP
    37 # include "ipv4/lwip/ip.h"
    38 #else
    39 # include "lwip/api.h"
    40 # include "lwip/tcp_impl.h"
    41 # include "ipv6/lwip/ethip6.h"
    42 #endif
     36#include "lwip/api.h"
     37#include "lwip/tcp_impl.h"
     38# if LWIP_IPV6
     39#  include "ipv6/lwip/ethip6.h"
     40# endif
    4341#include "lwip/udp.h"
    4442#include "lwip/tcp.h"
     
    5553
    5654#include "VBoxDD.h"
    57 
    58 #ifdef VBOX_WITH_NEW_LWIP
    59 # include "VBoxLwipCore.h"
    60 #endif
     55#include "VBoxLwipCore.h"
    6156
    6257/*******************************************************************************
     
    115110    /** Flag whether the link is up. */
    116111    bool                    fLnkUp;
    117 #ifndef VBOX_WITH_NEW_LWIP
    118     /**
    119      * This hack-flag for spliting initialization logic in devINIPTcpipInitDone,
    120      * this is the only place when during initialization we can be called from TCPIP
    121      * thread.
    122      * This callback used for Initialization and Finalization with old lwip.
    123      */
    124     bool fTermination;
    125 #endif
    126112    /**
    127113     * In callback we're getting status of interface adding operation (TCPIP thread),
     
    159145*   Internal Functions                                                         *
    160146*******************************************************************************/
    161 #ifndef VBOX_WITH_NEW_LWIP
    162 static DECLCALLBACK(void) devINIPARPTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer);
    163 static DECLCALLBACK(void) devINIPTCPFastTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer);
    164 static DECLCALLBACK(void) devINIPTCPSlowTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer);
    165 #endif
    166147static DECLCALLBACK(err_t) devINIPOutput(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr);
    167148static DECLCALLBACK(err_t) devINIPOutputRaw(struct netif *netif, struct pbuf *p);
    168149static DECLCALLBACK(err_t) devINIPInterface(struct netif *netif);
    169150
    170 
    171 #ifndef VBOX_WITH_NEW_LWIP
    172 /**
    173  * ARP cache timeout handling for lwIP.
    174  *
    175  * @param   pDevIns     Device instance.
    176  * @param   pTimer      Pointer to timer.
    177  */
    178 static DECLCALLBACK(void) devINIPARPTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    179 {
    180     PDEVINTNETIP pThis = (PDEVINTNETIP)pvUser;
    181     LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer));
    182     lwip_etharp_tmr();
    183     TMTimerSetMillies(pThis->ARPTimer, ARP_TMR_INTERVAL);
    184     LogFlow(("%s: return\n", __FUNCTION__));
    185 }
    186 
    187 /**
    188  * TCP fast timer handling for lwIP.
    189  *
    190  * @param   pDevIns     Device instance.
    191  * @param   pTimer      Pointer to timer.
    192  */
    193 static DECLCALLBACK(void) devINIPTCPFastTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    194 {
    195     PDEVINTNETIP pThis = (PDEVINTNETIP)pvUser;
    196     LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer));
    197     lwip_tcp_fasttmr();
    198     TMTimerSetMillies(pThis->TCPFastTimer, TCP_FAST_INTERVAL);
    199     LogFlow(("%s: return\n", __FUNCTION__));
    200 }
    201 
    202 /**
    203  * TCP slow timer handling for lwIP.
    204  *
    205  * @param   pDevIns     Device instance.
    206  * @param   pTimer      Pointer to timer.
    207  */
    208 static DECLCALLBACK(void) devINIPTCPSlowTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    209 {
    210     PDEVINTNETIP pThis = (PDEVINTNETIP)pvUser;
    211     LogFlow(("%s: pDevIns=%p pTimer=%p\n", __FUNCTION__, pDevIns, pTimer));
    212     lwip_tcp_slowtmr();
    213     TMTimerSetMillies(pThis->TCPSlowTimer, TCP_SLOW_INTERVAL);
    214     LogFlow(("%s: return\n", __FUNCTION__));
    215 }
    216 #endif /* VBOX_WITH_NEW_LWIP */
    217151
    218152/**
     
    230164    LogFlow(("%s: netif=%p p=%p ipaddr=%#04x\n", __FUNCTION__, netif, p,
    231165             ipaddr->addr));
    232 #ifndef VBOX_WITH_NEW_LWIP
    233     lrc = lwip_etharp_output(netif, ipaddr, p);
    234 #else
     166
    235167    lrc = lwip_etharp_output(netif, p, ipaddr);
    236 #endif
     168
    237169    LogFlow(("%s: return %d\n", __FUNCTION__, lrc));
    238170    return lrc;
     
    327259    netif->mtu = DEVINIP_MAX_FRAME;
    328260    netif->flags = NETIF_FLAG_BROADCAST;
    329 #ifdef VBOX_WITH_NEW_LWIP
    330     /** @todo why explicit ARP routing required for 1.2.0 case? */
    331261    netif->flags |= NETIF_FLAG_ETHARP;
    332262    netif->flags |= NETIF_FLAG_ETHERNET;
    333     /* Note! We always assign link-local IPv6 address */
     263
     264#if LWIP_IPV6
    334265    netif_create_ip6_linklocal_address(netif, 0);
    335266    netif_ip6_addr_set_state(netif, 0, IP6_ADDR_VALID);
     
    337268    netif->ip6_autoconfig_enabled=1;
    338269    LogFunc(("netif: ipv6:%RTnaipv6\n", &netif->ip6_addr[0].addr[0]));
     270#endif
     271
    339272    netif->output = lwip_etharp_output;
    340 
    341     lwip_etharp_init();
    342 #else
    343     netif->output = devINIPOutput;
    344 
    345     lwip_etharp_init();
    346     TMTimerSetMillies(g_pDevINIPData->ARPTimer, ARP_TMR_INTERVAL);
    347  #endif
    348273    netif->linkoutput = devINIPOutputRaw;
    349274
     
    452377        ethhdr = (const struct eth_hdr *)p->payload;
    453378        struct netif *iface = &g_pDevINIPData->IntNetIF;
    454 #ifndef VBOX_WITH_NEW_LWIP
    455         err_t lrc;
    456         switch (htons(ethhdr->type))
    457         {
    458             case ETHTYPE_IP:    /* IP packet */
    459                 lwip_pbuf_header(p, -(ssize_t)sizeof(struct eth_hdr));
    460                 lrc = iface->input(p, iface);
    461                 if (lrc)
    462                     rc = VERR_NET_IO_ERROR;
    463                 break;
    464             case ETHTYPE_ARP:   /* ARP packet */
    465                 lwip_etharp_arp_input(iface, (struct eth_addr *)iface->hwaddr, p);
    466                 break;
    467             default:
    468                 lwip_pbuf_free(p);
    469         }
    470 #else
     379
    471380        /* We've setup flags NETIF_FLAG_ETHARP and NETIF_FLAG_ETHERNET
    472381          so this should be thread-safe. */
    473382        tcpip_input(p,iface);
    474 #endif
    475383    }
    476384
     
    500408
    501409    pThis->rcInitialization = VINF_SUCCESS;
    502 #ifndef VBOX_WITH_NEW_LWIP
    503     /* see PDEVINTNETIP::fTermination */
    504     if (!pThis->fTermination)
    505     {
    506 #endif
     410    {
    507411        struct netif *ret;
    508412        struct ip_addr ipaddr, netmask, gw;
     
    565469        lwip_netif_set_default(&pThis->IntNetIF);
    566470        lwip_netif_set_up(&pThis->IntNetIF);
    567 
    568 #ifndef VBOX_WITH_NEW_LWIP
    569     }
    570     done:
    571     lwip_sys_sem_signal(pThis->LWIPTcpInitSem);
    572 #else
     471    }
    573472    done:
    574473    return;
    575 #endif
    576 }
    577 
    578 #ifdef VBOX_WITH_NEW_LWIP
     474}
     475
     476
    579477/**
    580478 * This callback is for finitializing our activity on TCPIP thread.
     
    590488    netif_remove(&pThis->IntNetIF);
    591489}
    592 #endif
    593490
    594491
     
    688585
    689586    if (g_pDevINIPData != NULL)
    690     {
    691 #ifndef VBOX_WITH_NEW_LWIP
    692         netif_set_down(&pThis->IntNetIF);
    693         netif_remove(&pThis->IntNetIF);
    694         pThis->fTermination = true;
    695         tcpip_terminate();
    696         lwip_sys_sem_wait(pThis->LWIPTcpInitSem);
    697         lwip_sys_sem_free(pThis->LWIPTcpInitSem);
    698 #else
    699587        vboxLwipCoreFinalize(devINIPTcpipFiniDone, pThis);
    700 #endif
    701     }
    702588
    703589    MMR3HeapFree(pThis->pszIP);
     
    720606    PDEVINTNETIP pThis = PDMINS_2_DATA(pDevIns, PDEVINTNETIP);
    721607    int rc = VINF_SUCCESS;
    722 #ifdef VBOX_WITH_NEW_LWIP
    723608    err_t errRc = ERR_OK;
    724 #endif
     609
    725610    LogFlow(("%s: pDevIns=%p iInstance=%d pCfg=%p\n", __FUNCTION__,
    726611             pDevIns, iInstance, pCfg));
     
    733618     */
    734619    if (!CFGMR3AreValuesValid(pCfg, "MAC\0IP\0"
    735 #ifdef VBOX_WITH_NEW_LWIP
    736620                                    "IPv6\0"
    737 #endif
    738621                                    "Netmask\0Gateway\0"))
    739622        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
     
    822705     * Initialize lwIP.
    823706     */
    824 #ifndef VBOX_WITH_NEW_LWIP
    825     lwip_stats_init();
    826     lwip_sys_init();
    827 # if MEM_LIBC_MALLOC == 0
    828     lwip_mem_init();
    829 # endif
    830     lwip_memp_init();
    831     lwip_pbuf_init();
    832     lwip_netif_init();
    833     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPARPTimer, pThis,
    834                                 TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP ARP", &pThis->ARPTimer);
    835     AssertRCReturn(rc, rc);
    836     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPFastTimer, pThis,
    837                                 TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP fast TCP", &pThis->TCPFastTimer);
    838     AssertRCReturn(rc, rc);
    839     TMTimerSetMillies(pThis->TCPFastTimer, TCP_FAST_INTERVAL);
    840     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, devINIPTCPSlowTimer, pThis,
    841                                 TMTIMER_FLAGS_NO_CRIT_SECT, "lwIP slow TCP", &pThis->TCPSlowTimer);
    842     AssertRCReturn(rc, rc);
    843     TMTimerSetMillies(pThis->TCPFastTimer, TCP_SLOW_INTERVAL);
    844 
    845     pThis->LWIPTcpInitSem = lwip_sys_sem_new(0);
    846 
    847     lwip_tcpip_init(devINIPTcpipInitDone, pThis);
    848     lwip_sys_sem_wait(pThis->LWIPTcpInitSem);
    849 
    850 #else /* VBOX_WITH_NEW_LWIP */
    851707    vboxLwipCoreInitialize(devINIPTcpipInitDone, pThis);
    852 #endif
    853708
    854709    /* this rc could be updated in devINIPTcpInitDone thread */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette