VirtualBox

Changeset 48417 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 10, 2013 3:58:39 PM (11 years ago)
Author:
vboxsync
Message:

Main/NATNetworkImpl: accept hint for address selection returning default value or assigning available.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/NATNetworkImpl.h

    r48107 r48417  
    4040# define NATSR_EXECUTABLE_NAME "VBoxNetNAT"
    4141#endif
     42
     43enum ADDRESSLOOKUPTYPE
     44{
     45    ADDR_GATEWAY,
     46    ADDR_DHCP,
     47    ADDR_DHCPLOWERIP,
     48    ADDR_ANY
     49};
    4250
    4351class NATNetworkServiceRunner: public NetworkServiceRunner
     
    128136private:
    129137    int recalculateIpv4AddressAssignments();
    130     int findFirstAvailableOffset(uint32_t *);
     138    int findFirstAvailableOffset(ADDRESSLOOKUPTYPE, uint32_t *);
    131139
    132140    typedef std::map<Utf8Str, settings::NATRule> NATRuleMap;
  • trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp

    r48415 r48417  
    904904
    905905
    906 int NATNetwork::findFirstAvailableOffset(uint32_t *poff)
     906int NATNetwork::findFirstAvailableOffset(ADDRESSLOOKUPTYPE addrType, uint32_t *poff)
    907907{
    908908    RTNETADDRIPV4 network, netmask;
     
    918918    {
    919919
    920         if (off == m->offGateway)
    921             continue;
    922 
    923         if (off == m->offDhcp)
    924             continue;
    925        
    926920        bool skip = false;
    927921        for (it = m->llNATLoopbackOffsetList.begin();
     
    937931        }
    938932       
     933        if (skip)
     934            continue;
     935
     936        if (off == m->offGateway)
     937        {
     938            if (addrType == ADDR_GATEWAY)
     939                break;
     940            else
     941                continue;
     942        }
     943
     944        if (off == m->offDhcp)
     945        {
     946            if (addrType == ADDR_DHCP)
     947                break;
     948            else
     949                continue;
     950        }
     951
    939952        if (!skip)
    940953            break;
     
    955968    AssertRCReturn(rc, rc);
    956969
    957     findFirstAvailableOffset(&m->offGateway);
     970    findFirstAvailableOffset(ADDR_GATEWAY, &m->offGateway);
    958971    if (m->fNeedDhcpServer)
    959         findFirstAvailableOffset(&m->offDhcp);
     972        findFirstAvailableOffset(ADDR_DHCP, &m->offDhcp);
    960973
    961974    /* I don't remember the reason CIDR calculated on the host. */
     
    975988        RTNETADDRIPV4 dhcplowerip = network;
    976989        uint32_t offDhcpLowerIp;
    977         findFirstAvailableOffset(&offDhcpLowerIp);
     990        findFirstAvailableOffset(ADDR_DHCPLOWERIP, &offDhcpLowerIp);
    978991        dhcplowerip.u = RT_H2N_U32(dhcplowerip.u + offDhcpLowerIp);
    979992
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