VirtualBox

Changeset 54499 in vbox


Ignore:
Timestamp:
Feb 25, 2015 3:42:17 PM (10 years ago)
Author:
vboxsync
Message:

VBoxNetDHCP: keep a pointer to NetworkManager instead of using a
global. To minimize churn, convert that global into a singleton.
No functional change intended.

Location:
trunk/src/VBox/NetworkServices/DHCP
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/DHCP/Config.cpp

    r50587 r54499  
    7474static ConfigurationManager *g_ConfigurationManager = ConfigurationManager::getConfigurationManager();
    7575
    76 static NetworkManager *g_NetworkManager = NetworkManager::getNetworkManager();
     76NetworkManager *NetworkManager::g_NetworkManager;
    7777
    7878bool MACClientMatchCriteria::check(const Client& client) const
  • trunk/src/VBox/NetworkServices/DHCP/Config.h

    r50587 r54499  
    517517    int doReply(const Client& client, const std::vector<RawOption>& extra);
    518518    int processParameterReqList(const Client& client, const uint8_t *pu8ReqList, int cReqList, std::vector<RawOption>& extra);
     519
     520private:
     521    static NetworkManager *g_NetworkManager;
    519522
    520523private:
  • trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp

    r50587 r54499  
    130130    /** Listener for Host DNS changes */
    131131    ComPtr<NATNetworkListenerImpl> m_vboxListener;
     132
     133    NetworkManager *m_NetworkManager;
     134
    132135    /*
    133136     * We will ignore cmd line parameters IFF there will be some DHCP specific arguments
     
    192195 * Construct a DHCP server with a default configuration.
    193196 */
    194 VBoxNetDhcp::VBoxNetDhcp():VBoxNetBaseService("VBoxNetDhcp", "VBoxNetDhcp")
     197VBoxNetDhcp::VBoxNetDhcp()
     198  : VBoxNetBaseService("VBoxNetDhcp", "VBoxNetDhcp"),
     199    m_NetworkManager(NULL)
    195200{
    196201    /*   m_enmTrunkType          = kIntNetTrunkType_WhateverNone; */
     
    281286    AssertRCReturn(rc, rc);
    282287
    283     NetworkManager *netManager = NetworkManager::getNetworkManager();
    284 
    285     netManager->setOurAddress(getIpv4Address());
    286     netManager->setOurNetmask(getIpv4Netmask());
    287     netManager->setOurMac(getMacAddress());
    288     netManager->setService(this);
    289 
    290288    if (isMainNeeded())
    291289        rc = initWithMain();
    292290    else
    293291        rc = initNoMain();
    294 
    295292    AssertRCReturn(rc, rc);
     293
     294    m_NetworkManager = NetworkManager::getNetworkManager();
     295    AssertPtrReturn(m_NetworkManager, VERR_INTERNAL_ERROR);
     296
     297    m_NetworkManager->setOurAddress(getIpv4Address());
     298    m_NetworkManager->setOurNetmask(getIpv4Netmask());
     299    m_NetworkManager->setOurMac(getMacAddress());
     300    m_NetworkManager->setService(this);
    296301
    297302    return VINF_SUCCESS;
     
    338343    if (pDhcpMsg->bp_op == RTNETBOOTP_OP_REQUEST)
    339344    {
    340         NetworkManager *networkManager = NetworkManager::getNetworkManager();
     345        AssertPtrReturn(m_NetworkManager, false);
    341346
    342347        switch (uMsgType)
    343348        {
    344349            case RTNET_DHCP_MT_DISCOVER:
    345                 return networkManager->handleDhcpReqDiscover(pDhcpMsg, cb);
     350                return m_NetworkManager->handleDhcpReqDiscover(pDhcpMsg, cb);
    346351
    347352            case RTNET_DHCP_MT_REQUEST:
    348                 return networkManager->handleDhcpReqRequest(pDhcpMsg, cb);
     353                return m_NetworkManager->handleDhcpReqRequest(pDhcpMsg, cb);
    349354
    350355            case RTNET_DHCP_MT_DECLINE:
    351                 return networkManager->handleDhcpReqDecline(pDhcpMsg, cb);
     356                return m_NetworkManager->handleDhcpReqDecline(pDhcpMsg, cb);
    352357
    353358            case RTNET_DHCP_MT_RELEASE:
    354                 return networkManager->handleDhcpReqRelease(pDhcpMsg, cb);
     359                return m_NetworkManager->handleDhcpReqRelease(pDhcpMsg, cb);
    355360
    356361            case RTNET_DHCP_MT_INFORM:
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