VirtualBox

Changeset 48093 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 27, 2013 4:39:15 PM (11 years ago)
Author:
vboxsync
Message:

NAT/xml: loopback mappings introduces NATNetwork entities:

<Mappings>

<Loopback4 address="127.0.1.1" offset="6"/>
<Loopback4 address="127.0.1.2" offset="7"/>

</Mappings>

to describe mapppings any hostid in 127/8 network to our NAT network, e.g. in this case 127.0.1.1 corresponds to network id + 6 (network id here from CIDR defined on creation), for IPv6 (as soon localhost6 could be only one) attribute "loopback6" is reserved in NATNetwork tag.

operators: NATHostLoopbackOffset::operator == (const Utf8Str&) and NATHostLoopbackOffset::operator==(uint32_t) are introduced got using std::find on adding and modification operations in NATNetworkImpl.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r47991 r48093  
    837837}
    838838
     839void ConfigFileBase::readNATLoopbacks(const xml::ElementNode &elmParent, NATLoopbackOffsetList &llLoopbacks)
     840{
     841    xml::ElementNodesList plstLoopbacks;
     842    elmParent.getChildElements(plstLoopbacks, "Loopback4");
     843    for (xml::ElementNodesList::iterator lo = plstLoopbacks.begin();
     844         lo != plstLoopbacks.end(); ++lo)
     845    {
     846        NATHostLoopbackOffset loopback;
     847        (*lo)->getAttributeValue("address", loopback.strLoopbackHostAddress);
     848        (*lo)->getAttributeValue("offset", (uint32_t&)loopback.u32Offset);
     849        llLoopbacks.push_back(loopback);
     850    }
     851}
     852
     853
    839854/**
    840855 * Adds a "version" attribute to the given XML element with the
     
    11921207}
    11931208
     1209
     1210void ConfigFileBase::buildNATLoopbacks(xml::ElementNode &elmParent, const NATLoopbackOffsetList &natLoopbackOffsetList)
     1211{
     1212    for (NATLoopbackOffsetList::const_iterator lo = natLoopbackOffsetList.begin();
     1213         lo != natLoopbackOffsetList.end(); ++lo)
     1214    {
     1215        xml::ElementNode *pelmLo;
     1216        pelmLo = elmParent.createChild("Loopback4");
     1217        pelmLo->setAttribute("address", (*lo).strLoopbackHostAddress);
     1218        pelmLo->setAttribute("offset", (*lo).u32Offset);
     1219    }
     1220}
     1221
    11941222/**
    11951223 * Cleans up memory allocated by the internal XML parser. To be called by
     
    13791407               )
    13801408            {
     1409                pelmNet->getAttributeValue("loopback6", net.u32HostLoopback6Offset);
     1410                const xml::ElementNode *pelmMappings;
     1411                if ((pelmMappings = pelmNet->findChildElement("Mappings")))
     1412                    readNATLoopbacks(*pelmMappings, net.llHostLoopbackOffsetList);
     1413
    13811414                const xml::ElementNode *pelmPortForwardRules4;
    13821415                if ((pelmPortForwardRules4 = pelmNet->findChildElement("PortForwarding4")))
     
    16331666                xml::ElementNode *pelmPf6 = pelmThis->createChild("PortForwarding6");
    16341667                buildNATForwardRuleList(*pelmPf6, n.llPortForwardRules6);
     1668            }
     1669
     1670            if (n.llHostLoopbackOffsetList.size())
     1671            {
     1672                xml::ElementNode *pelmMappings = pelmThis->createChild("Mappings");
     1673                buildNATLoopbacks(*pelmMappings, n.llHostLoopbackOffsetList);
     1674
    16351675            }
    16361676        }
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