VirtualBox

Changeset 87375 in vbox


Ignore:
Timestamp:
Jan 22, 2021 6:26:45 PM (4 years ago)
Author:
vboxsync
Message:

NAT/Net: In various callback functions consistently use the callback
cookie to access the VBoxNetLwipNAT object - not the wild and
confusing mixture of both the cookie and the global singleton
variable. Consistently call it "self". No functional change
intended.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r85121 r87375  
    425425{
    426426    AssertPtrReturnVoid(arg);
    427     VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(arg);
     427    VBoxNetLwipNAT *self = static_cast<VBoxNetLwipNAT *>(arg);
    428428
    429429    HRESULT hrc = com::Initialize();
     
    438438    /* lwip thread */
    439439    RTNETADDRIPV4 network;
    440     RTNETADDRIPV4 address = g_pLwipNat->getIpv4Address();
    441     RTNETADDRIPV4 netmask = g_pLwipNat->getIpv4Netmask();
     440    RTNETADDRIPV4 address = self->getIpv4Address();
     441    RTNETADDRIPV4 netmask = self->getIpv4Netmask();
    442442    network.u = address.u & netmask.u;
    443443
     
    448448    memcpy(&LwipIpNetwork, &network, sizeof(ip_addr));
    449449
    450     netif *pNetif = netif_add(&g_pLwipNat->m_LwipNetIf /* Lwip Interface */,
     450    netif *pNetif = netif_add(&self->m_LwipNetIf /* Lwip Interface */,
    451451                              &LwipIpAddr /* IP address*/,
    452452                              &LwipIpNetMask /* Network mask */,
    453453                              &LwipIpAddr /* gateway address, @todo: is self IP acceptable? */,
    454                               g_pLwipNat /* state */,
     454                              self /* state */,
    455455                              VBoxNetLwipNAT::netifInit /* netif_init_fn */,
    456456                              tcpip_input /* netif_input_fn */);
     
    475475    netif_set_link_up(pNetif);
    476476
    477     if (pNat->m_ProxyOptions.ipv6_enabled) {
     477    if (self->m_ProxyOptions.ipv6_enabled) {
    478478        /*
    479479         * XXX: lwIP currently only ever calls mld6_joingroup() in
     
    508508    }
    509509
    510     proxy_init(&g_pLwipNat->m_LwipNetIf, &g_pLwipNat->m_ProxyOptions);
    511 
    512     natServiceProcessRegisteredPf(g_pLwipNat->m_vecPortForwardRule4);
    513     natServiceProcessRegisteredPf(g_pLwipNat->m_vecPortForwardRule6);
     510    proxy_init(&self->m_LwipNetIf, &self->m_ProxyOptions);
     511
     512    natServiceProcessRegisteredPf(self->m_vecPortForwardRule4);
     513    natServiceProcessRegisteredPf(self->m_vecPortForwardRule6);
    514514}
    515515
     
    518518{
    519519    AssertPtrReturnVoid(arg);
     520    VBoxNetLwipNAT *self = static_cast<VBoxNetLwipNAT *>(arg);
    520521
    521522    /* XXX: proxy finalization */
    522     netif_set_link_down(&g_pLwipNat->m_LwipNetIf);
    523     netif_set_down(&g_pLwipNat->m_LwipNetIf);
    524     netif_remove(&g_pLwipNat->m_LwipNetIf);
     523    netif_set_link_down(&self->m_LwipNetIf);
     524    netif_set_down(&self->m_LwipNetIf);
     525    netif_remove(&self->m_LwipNetIf);
    525526
    526527}
     
    535536    AssertPtrReturn(pNetif, ERR_ARG);
    536537
    537     VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(pNetif->state);
    538     AssertPtrReturn(pNat, ERR_ARG);
     538    VBoxNetLwipNAT *self = static_cast<VBoxNetLwipNAT *>(pNetif->state);
     539    AssertPtrReturn(self, ERR_ARG);
    539540
    540541    LogFlowFunc(("ENTER: pNetif[%c%c%d]\n", pNetif->name[0], pNetif->name[1], pNetif->num));
     
    545546
    546547    pNetif->hwaddr_len = sizeof(RTMAC);
    547     RTMAC mac = g_pLwipNat->getMacAddress();
     548    RTMAC mac = self->getMacAddress();
    548549    memcpy(pNetif->hwaddr, &mac, sizeof(RTMAC));
    549550
    550     pNat->m_u16Mtu = 1500; // XXX: FIXME
    551     pNetif->mtu = pNat->m_u16Mtu;
     551    self->m_u16Mtu = 1500; // XXX: FIXME
     552    pNetif->mtu = self->m_u16Mtu;
    552553
    553554    pNetif->flags = NETIF_FLAG_BROADCAST
     
    558559    pNetif->output = etharp_output;       /* ip-pipe */
    559560
    560     if (pNat->m_ProxyOptions.ipv6_enabled) {
     561    if (self->m_ProxyOptions.ipv6_enabled) {
    561562        pNetif->output_ip6 = ethip6_output;
    562563
     
    945946    /* end of COM initialization */
    946947
    947     rc = g_pLwipNat->tryGoOnline();
     948    rc = tryGoOnline();
    948949    if (RT_FAILURE(rc))
    949950        return rc;
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