Changeset 46969 in vbox for trunk/src/VBox/Main/xml
- Timestamp:
- Jul 4, 2013 6:35:01 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86977
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r46959 r46969 1302 1302 if ( (pelmServer->getAttributeValue("networkName", srv.strNetworkName)) 1303 1303 && (pelmServer->getAttributeValue("IPAddress", srv.strIPAddress)) 1304 && (pelmServer->getAttributeValue("networkMask", srv.GlobalDhcpOptions[DhcpOpt_SubnetMask]))1304 && (pelmServer->getAttributeValue("networkMask", srv.strIPNetworkMask)) 1305 1305 && (pelmServer->getAttributeValue("lowerIP", srv.strIPLower)) 1306 1306 && (pelmServer->getAttributeValue("upperIP", srv.strIPUpper)) 1307 1307 && (pelmServer->getAttributeValue("enabled", srv.fEnabled)) 1308 1308 ) 1309 {1310 xml::NodesLoop nlOptions(*pelmServer, "Options");1311 const xml::ElementNode *options;1312 /* XXX: Options are in 1:1 relation to DHCPServer */1313 1314 while ((options = nlOptions.forAllNodes()))1315 {1316 readDhcpOptions(srv.GlobalDhcpOptions, *options);1317 } /* end of forall("Options") */1318 xml::NodesLoop nlConfig(*pelmServer, "Config");1319 const xml::ElementNode *cfg;1320 while ((cfg = nlConfig.forAllNodes()))1321 {1322 com::Utf8Str strVmName;1323 uint32_t u32Slot;1324 cfg->getAttributeValue("vm-name", strVmName);1325 cfg->getAttributeValue("slot", (uint32_t&)u32Slot);1326 readDhcpOptions(srv.VmSlot2OptionsM[VmNameSlotKey(strVmName, u32Slot)],1327 *cfg);1328 }1329 1309 llDhcpServers.push_back(srv); 1330 }1331 1310 else 1332 1311 throw ConfigFileError(this, pelmServer, N_("Required DHCPServer/@networkName, @IPAddress, @networkMask, @lowerIP, @upperIP or @enabled attribute is missing")); 1333 1312 } 1334 1313 } 1335 }1336 1337 void MainConfigFile::readDhcpOptions(DhcpOptionMap& map,1338 const xml::ElementNode& options)1339 {1340 xml::NodesLoop nl2(options, "Option");1341 const xml::ElementNode *opt;1342 while((opt = nl2.forAllNodes()))1343 {1344 DhcpOpt_T OptName;1345 com::Utf8Str OptValue;1346 opt->getAttributeValue("name", (uint32_t&)OptName);1347 1348 if (OptName == DhcpOpt_SubnetMask)1349 continue;1350 1351 opt->getAttributeValue("value", OptValue);1352 1353 map.insert(1354 std::map<DhcpOpt_T, Utf8Str>::value_type(OptName, OptValue));1355 } /* end of forall("Option") */1356 1357 1314 } 1358 1315 … … 1489 1446 #endif 1490 1447 srv.strIPAddress = "192.168.56.100"; 1491 srv. GlobalDhcpOptions[DhcpOpt_SubnetMask]= "255.255.255.0";1448 srv.strIPNetworkMask = "255.255.255.0"; 1492 1449 srv.strIPLower = "192.168.56.101"; 1493 1450 srv.strIPUpper = "192.168.56.254"; … … 1532 1489 const DHCPServer &d = *it; 1533 1490 xml::ElementNode *pelmThis = pelmDHCPServers->createChild("DHCPServer"); 1534 DhcpOptConstIterator itOpt;1535 itOpt = d.GlobalDhcpOptions.find(DhcpOpt_SubnetMask);1536 1537 1491 pelmThis->setAttribute("networkName", d.strNetworkName); 1538 1492 pelmThis->setAttribute("IPAddress", d.strIPAddress); 1539 if (itOpt != d.GlobalDhcpOptions.end()) 1540 pelmThis->setAttribute("networkMask", itOpt->second); 1493 pelmThis->setAttribute("networkMask", d.strIPNetworkMask); 1541 1494 pelmThis->setAttribute("lowerIP", d.strIPLower); 1542 1495 pelmThis->setAttribute("upperIP", d.strIPUpper); 1543 1496 pelmThis->setAttribute("enabled", (d.fEnabled) ? 1 : 0); // too bad we chose 1 vs. 0 here 1544 /* We assume that if there're only 1 element it means that */ 1545 int cOpt = d.GlobalDhcpOptions.size(); 1546 /* We don't want duplicate validation check of networkMask here*/ 1547 if ( ( itOpt == d.GlobalDhcpOptions.end() 1548 && cOpt > 0) 1549 || cOpt > 1) 1550 { 1551 xml::ElementNode *pelmOptions = pelmThis->createChild("Options"); 1552 for (itOpt = d.GlobalDhcpOptions.begin(); 1553 itOpt != d.GlobalDhcpOptions.end(); 1554 ++itOpt) 1555 { 1556 if (itOpt->first == DhcpOpt_SubnetMask) 1557 continue; 1558 1559 xml::ElementNode *pelmOpt = pelmOptions->createChild("Option"); 1560 1561 if (!pelmOpt) 1562 break; 1563 1564 pelmOpt->setAttribute("name", itOpt->first); 1565 pelmOpt->setAttribute("value", itOpt->second); 1566 } 1567 } /* end of if */ 1568 1569 if (d.VmSlot2OptionsM.size() > 0) 1570 { 1571 VmSlot2OptionsConstIterator itVmSlot; 1572 DhcpOptConstIterator itOpt1; 1573 for(itVmSlot = d.VmSlot2OptionsM.begin(); 1574 itVmSlot != d.VmSlot2OptionsM.end(); 1575 ++itVmSlot) 1576 { 1577 xml::ElementNode *pelmCfg = pelmThis->createChild("Config"); 1578 pelmCfg->setAttribute("vm-name", itVmSlot->first.VmName); 1579 pelmCfg->setAttribute("slot", itVmSlot->first.Slot); 1580 1581 for (itOpt1 = itVmSlot->second.begin(); 1582 itOpt1 != itVmSlot->second.end(); 1583 ++itOpt1) 1584 { 1585 xml::ElementNode *pelmOpt = pelmCfg->createChild("Option"); 1586 pelmOpt->setAttribute("name", itOpt1->first); 1587 pelmOpt->setAttribute("value", itOpt1->second); 1588 } 1589 } 1590 } /* and of if */ 1591 1592 } 1497 } 1593 1498 1594 1499 /* TODO: bump main version ? */
Note:
See TracChangeset
for help on using the changeset viewer.