VirtualBox

Changeset 54314 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
Feb 19, 2015 9:32:18 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98389
Message:

Main/DHCPServerImpl: for DHCP options keep not just the text
representation, but also encoding of that text representation.

When XML settings are read, interpret old format, without explicit
"encoding" attribute, as legacy encoding where we are expected to know
the actual format of the option from the option code itself. When
writing legacy options, write them in old format.

This is in preparation for using "de:ad:be:ef" hex-encoded option
values for non-standard options which format we can't know a priory.

File:
1 edited

Legend:

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

    r52959 r54314  
    13461346            if (   pelmServer->getAttributeValue("networkName", srv.strNetworkName)
    13471347                && pelmServer->getAttributeValue("IPAddress", srv.strIPAddress)
    1348                 && pelmServer->getAttributeValue("networkMask", srv.GlobalDhcpOptions[DhcpOpt_SubnetMask])
     1348                && pelmServer->getAttributeValue("networkMask", srv.GlobalDhcpOptions[DhcpOpt_SubnetMask].text)
    13491349                && pelmServer->getAttributeValue("lowerIP", srv.strIPLower)
    13501350                && pelmServer->getAttributeValue("upperIP", srv.strIPUpper)
     
    13851385    {
    13861386        DhcpOpt_T OptName;
    1387         com::Utf8Str OptValue;
     1387        com::Utf8Str OptText;
     1388        int32_t OptEnc = DhcpOptValue::LEGACY;
     1389
    13881390        opt->getAttributeValue("name", (uint32_t&)OptName);
    13891391
     
    13911393            continue;
    13921394
    1393         opt->getAttributeValue("value", OptValue);
    1394 
    1395         map.insert(std::map<DhcpOpt_T, Utf8Str>::value_type(OptName, OptValue));
     1395        opt->getAttributeValue("value", OptText);
     1396        opt->getAttributeValue("encoding", OptEnc);
     1397
     1398        map[OptName] = DhcpOptValue(OptText, (DhcpOptValue::Encoding)OptEnc);
    13961399    } /* end of forall("Option") */
    13971400
     
    15351538#endif
    15361539        srv.strIPAddress = "192.168.56.100";
    1537         srv.GlobalDhcpOptions[DhcpOpt_SubnetMask] = "255.255.255.0";
     1540        srv.GlobalDhcpOptions[DhcpOpt_SubnetMask] = DhcpOptValue("255.255.255.0");
    15381541        srv.strIPLower = "192.168.56.101";
    15391542        srv.strIPUpper = "192.168.56.254";
     
    15971600        pelmThis->setAttribute("IPAddress", d.strIPAddress);
    15981601        if (itOpt != d.GlobalDhcpOptions.end())
    1599             pelmThis->setAttribute("networkMask", itOpt->second);
     1602            pelmThis->setAttribute("networkMask", itOpt->second.text);
    16001603        pelmThis->setAttribute("lowerIP", d.strIPLower);
    16011604        pelmThis->setAttribute("upperIP", d.strIPUpper);
     
    16221625
    16231626                pelmOpt->setAttribute("name", itOpt->first);
    1624                 pelmOpt->setAttribute("value", itOpt->second);
     1627                pelmOpt->setAttribute("value", itOpt->second.text);
     1628                if (itOpt->second.encoding != DhcpOptValue::LEGACY)
     1629                    pelmOpt->setAttribute("encoding", (int)itOpt->second.encoding);
    16251630            }
    16261631        } /* end of if */
     
    16441649                    xml::ElementNode *pelmOpt = pelmCfg->createChild("Option");
    16451650                    pelmOpt->setAttribute("name", itOpt1->first);
    1646                     pelmOpt->setAttribute("value", itOpt1->second);
     1651                    pelmOpt->setAttribute("value", itOpt1->second.text);
     1652                    if (itOpt1->second.encoding != DhcpOptValue::LEGACY)
     1653                        pelmOpt->setAttribute("encoding", (int)itOpt1->second.encoding);
    16471654                }
    16481655            }
Note: See TracChangeset for help on using the changeset viewer.

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