- Timestamp:
- Jul 4, 2013 5:21:06 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86967
- Location:
- trunk
- Files:
-
- 2 deleted
- 13 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r46720 r46959 286 286 typedef std::list<MachineRegistryEntry> MachinesRegistry; 287 287 288 typedef std::map<DhcpOpt_T, com::Utf8Str> DhcpOptionMap; 289 typedef DhcpOptionMap::value_type DhcpOptValuePair; 290 typedef DhcpOptionMap::iterator DhcpOptIterator; 291 typedef DhcpOptionMap::const_iterator DhcpOptConstIterator; 292 293 typedef struct VmNameSlotKey 294 { 295 VmNameSlotKey(const com::Utf8Str& aVmName, LONG aSlot): VmName(aVmName), 296 Slot(aSlot){} 297 const com::Utf8Str VmName; 298 LONG Slot; 299 bool operator< (const VmNameSlotKey& that) const 300 { 301 if (VmName == that.VmName) 302 return Slot < that.Slot; 303 else return VmName < that.VmName; 304 } 305 } VmNameSlotKey; 306 typedef std::map<VmNameSlotKey, DhcpOptionMap> VmSlot2OptionsMap; 307 typedef VmSlot2OptionsMap::value_type VmSlot2OptionsPair; 308 typedef VmSlot2OptionsMap::iterator VmSlot2OptionsIterator; 309 typedef VmSlot2OptionsMap::const_iterator VmSlot2OptionsConstIterator; 310 288 311 struct DHCPServer 289 312 { … … 294 317 com::Utf8Str strNetworkName, 295 318 strIPAddress, 296 strIPNetworkMask,297 319 strIPLower, 298 320 strIPUpper; 299 321 bool fEnabled; 322 std::map<DhcpOpt_T, com::Utf8Str> GlobalDhcpOptions; 323 VmSlot2OptionsMap VmSlot2OptionsM; 300 324 }; 301 325 typedef std::list<DHCPServer> DHCPServersList; … … 337 361 void readMachineRegistry(const xml::ElementNode &elmMachineRegistry); 338 362 void readDHCPServers(const xml::ElementNode &elmDHCPServers); 363 void readDhcpOptions(DhcpOptionMap& map, const xml::ElementNode& options); 339 364 void readNATNetworks(const xml::ElementNode &elmNATNetworks); 340 365 -
trunk/src/VBox/Main/Makefile.kmk
r46649 r46959 335 335 src-server/BIOSSettingsImpl.cpp \ 336 336 src-server/DHCPServerImpl.cpp \ 337 src-server/ DHCPServerRunner.cpp \337 src-server/NetworkServiceRunner.cpp \ 338 338 src-server/NATNetworkImpl.cpp \ 339 $(if $(VBOX_WITH_NAT_SERVICE),src-server/NATNetworkServiceRunner.cpp,) \340 339 src-server/GuestOSTypeImpl.cpp \ 341 340 src-server/HostImpl.cpp \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r46778 r46959 1466 1466 </interface> 1467 1467 1468 <enum 1469 name="DhcpOpt" 1470 uuid="40d99bd3-3ece-44d2-a07e-1085fe9c4f0b"> 1471 <const name="SubnetMask" value="1"/> 1472 <const name="TimeOffset" value="2"/> 1473 <const name="Router" value="3"/> 1474 <const name="TimeServer" value="4"/> 1475 <const name="NameServer" value="5"/> 1476 <const name="DomainNameServer" value="6"/> 1477 <const name="LogServer" value="7"/> 1478 <const name="Cookie" value="8"/> 1479 <const name="LPRServer" value="9"/> 1480 <const name="ImpressServer" value="10"/> 1481 <const name="ResourseLocationServer" value="11"/> 1482 <const name="HostName" value="12"/> 1483 <const name="BootFileSize" value="13"/> 1484 <const name="MeritDumpFile" value="14"/> 1485 <const name="DomainName" value="15"/> 1486 <const name="SwapServer" value="16"/> 1487 <const name="RootPath" value="17"/> 1488 <const name="ExtensionPath" value="18"/> 1489 <const name="IPForwardingEnableDisable" value="19"/> 1490 <const name="NonLocalSourceRoutingEnableDisable" value="20"/> 1491 <const name="PolicyFilter" value="21"/> 1492 <const name="MaximumDatagramReassemblySize" value="22"/> 1493 <const name="DefaultIPTime2Live" value="23"/> 1494 <const name="PathMTUAgingTimeout" value="24"/> 1495 <const name="IPLayerParametersPerInterface" value="25"/> 1496 <const name="InterfaceMTU" value="26"/> 1497 <const name="AllSubnetsAreLocal" value="27"/> 1498 <const name="BroadcastAddress" value="28"/> 1499 <const name="PerformMaskDiscovery" value="29"/> 1500 <const name="MaskSupplier" value="30"/> 1501 <const name="PerformRouteDiscovery" value="31"/> 1502 <const name="RouterSolicitationAddress" value="32"/> 1503 <const name="StaticRoute" value="33"/> 1504 <const name="TrailerEncapsulation" value="34"/> 1505 <const name="ARPCacheTimeout" value="35"/> 1506 <const name="EthernetEncapsulation" value="36"/> 1507 <const name="TCPDefaultTTL" value="37"/> 1508 <const name="TCPKeepAliveInterval" value="38"/> 1509 <const name="TCPKeepAliveGarbage" value="39"/> 1510 <const name="NetworkInformationServiceDomain" value="40"/> 1511 <const name="NetworkInformationServiceServers" value="41"/> 1512 <const name="NetworkTimeProtocolServers" value="42"/> 1513 <const name="VendorSpecificInformation" value="43"/> 1514 <const name="Option_44" value="44"/> 1515 <const name="Option_45" value="45"/> 1516 <const name="Option_46" value="46"/> 1517 <const name="Option_47" value="47"/> 1518 <const name="Option_48" value="48"/> 1519 <const name="Option_49" value="49"/> 1520 <const name="IPAddressLeaseTime" value="51"/> 1521 <const name="Option_64" value="64"/> 1522 <const name="Option_65" value="65"/> 1523 <const name="TFTPServerName" value="66"/> 1524 <const name="BootfileName" value="67"/> 1525 <const name="Option_68" value="68"/> 1526 <const name="Option_69" value="69"/> 1527 <const name="Option_70" value="70"/> 1528 <const name="Option_71" value="71"/> 1529 <const name="Option_72" value="72"/> 1530 <const name="Option_73" value="73"/> 1531 <const name="Option_74" value="74"/> 1532 <const name="Option_75" value="75"/> 1533 <const name="Option_119" value="119"/> 1534 </enum> 1535 1468 1536 <interface 1469 1537 name="IDHCPServer" extends="$unknown" 1470 uuid=" 6cfe387c-74fb-4ca7-bff6-973bec8af7a3"1538 uuid="ff0774c5-1f62-4bc3-919c-7fc942bf1d25" 1471 1539 wsmap="managed" 1472 1540 > … … 1477 1545 <link to="IVirtualBox::DHCPServers"/> attribute. 1478 1546 </desc> 1479 1547 <!-- We want to keep our "real" servers updated about configuration changes --> 1548 <attribute name="eventSource" type="IEventSource" readonly="yes"/> 1480 1549 <attribute name="enabled" type="boolean"> 1481 1550 <desc> … … 1513 1582 </desc> 1514 1583 </attribute> 1584 1585 <method name="addGlobalOption"> 1586 <param name="option" type="DhcpOpt" dir="in"/> 1587 <param name="value" type="wstring" dir="in" /> 1588 </method> 1589 1590 <!-- string in format: "option_id:value" --> 1591 <attribute name="globalOptions" type="wstring" safearray="yes" readonly="yes"/> 1592 1593 <!-- string in format: "[vm name]:slot" --> 1594 <attribute name="vmConfigs" type="wstring" safearray="yes" readonly="yes"/> 1595 1596 <!-- VM-slot settings 1597 It's corresponds to dhcpd.conf entries, like: 1598 1599 host ncd1 { hardware ethernet 0:c0:c3:11:90:23; } 1600 1601 - in Main we can match (vm name, slot) to ethernet address 1602 that why it's easy to configure dhcp server in such way, 1603 then ask user to to enter valid name, 1604 1605 - mac address might change because of adapter type (e1k <-> pcnet) or because 1606 of import/export 1607 1608 - it's easy to provide vm-name.rom in boot filename VM with network boot. 1609 1610 XXX: do we need classic getOptionValueByMAC? 1611 1612 XML: O-o-oh, this settings are per VM, so perhaps they should be stored in 1613 VM configuration files. And we haven't got the attachment type for 1614 NATNetwork. 1615 --> 1616 <method name="addVmSlotOption"> 1617 <param name="vmname" type="wstring" dir="in"/> 1618 <param name="slot" type="long" dir="in"/> 1619 <param name="option" type="DhcpOpt" dir="in"/> 1620 <param name="value" type="wstring" dir="in" /> 1621 </method> 1622 1623 <method name="removeVmSlotOptions"> 1624 <param name="vmname" type="wstring" dir="in"/> 1625 <param name="slot" type="long" dir="in"/> 1626 </method> 1627 1628 <!-- returns array of strings in format: "option_id:value" for a given pair (vm, slot) --> 1629 <method name="getVmSlotOptions"> 1630 <param name="vmname" type="wstring" dir="in"/> 1631 <param name="slot" type="long" dir="in"/> 1632 <param name="option" type="wstring" safearray="yes" dir="return"/> 1633 </method> 1634 1635 <!-- Returns options by MAC address --> 1636 <method name="getMacOptions"> 1637 <param name="mac" type="wstring" dir="in"/> 1638 <param name="option" type="wstring" safearray="yes" dir="return"/> 1639 </method> 1515 1640 1516 1641 <method name="setConfiguration"> … … 8038 8163 <interface 8039 8164 name="IHost" extends="$unknown" 8040 uuid=" 30678943-32df-4830-b413-931b25ac86a0"8165 uuid="a6107246-f939-42c4-82b6-8aca40327b6d" 8041 8166 wsmap="managed" 8042 8167 > … … 8099 8224 <attribute name="networkInterfaces" type="IHostNetworkInterface" safearray="yes" readonly="yes"> 8100 8225 <desc>List of host network interfaces currently defined on the host.</desc> 8226 </attribute> 8227 8228 <attribute name="nameServers" type="wstring" safearray="yes" readonly="yes"> 8229 <desc> The list of nameservers registered in host's name resolving system.</desc> 8230 </attribute> 8231 8232 <attribute name="domainName" type="wstring" readonly="yes"> 8233 <desc>Domain name used for name resoving.</desc> 8234 </attribute> 8235 8236 <attribute name="searchStrings" type="wstring" safearray="yes" readonly="yes"> 8237 <desc>Search string registered for name resoving.</desc> 8101 8238 </attribute> 8102 8239 -
trunk/src/VBox/Main/include/DHCPServerImpl.h
r44528 r46959 30 30 { 31 31 struct DHCPServer; 32 struct VmNameSlotKey; 32 33 } 34 #ifdef RT_OS_WINDOWS 35 # define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe" 36 #else 37 # define DHCP_EXECUTABLE_NAME "VBoxNetDHCP" 38 #endif 39 40 class DHCPServerRunner: public NetworkServiceRunner 41 { 42 public: 43 DHCPServerRunner():NetworkServiceRunner(DHCP_EXECUTABLE_NAME){} 44 virtual ~DHCPServerRunner(){}; 45 }; 46 47 /** 48 * for server configuration needs, it's perhaps better to use (VM,slot) pair 49 * (vm-name, slot) <----> (MAC) 50 * 51 * but for client configuration, when server will have MACs at hand, it'd be 52 * easier to requiest options by MAC. 53 * (MAC) <----> (option-list) 54 * 55 * Doubts: What should be done if MAC changed for (vm-name, slot), when syncing should? 56 * XML: serialization of dependecy (DHCP options) - (VM,slot) shouldn't be done via MAC in 57 * the middle. 58 */ 59 60 typedef std::map<DhcpOpt_T, com::Utf8Str> DhcpOptionMap; 61 typedef DhcpOptionMap::value_type DhcpOptValuePair; 62 typedef DhcpOptionMap::const_iterator DhcpOptConstIterator; 63 typedef DhcpOptionMap::iterator DhcpOptIterator; 64 65 typedef std::map<settings::VmNameSlotKey, DhcpOptionMap> VmSlot2OptionsMap; 66 typedef VmSlot2OptionsMap::value_type VmSlot2OptionsPair; 67 typedef VmSlot2OptionsMap::iterator VmSlot2OptionsIterator; 68 33 69 34 70 class ATL_NO_VTABLE DHCPServer : … … 70 106 STDMETHOD(COMGETTER(UpperIP))(BSTR *aIPAddress); 71 107 108 STDMETHOD(AddGlobalOption)(DhcpOpt_T aOption, IN_BSTR aValue); 109 STDMETHOD(COMGETTER(GlobalOptions))(ComSafeArrayOut(BSTR, aValue)); 110 STDMETHOD(COMGETTER(VmConfigs))(ComSafeArrayOut(BSTR, aValue)); 111 STDMETHOD(AddVmSlotOption)(IN_BSTR aVmName, LONG aSlot, DhcpOpt_T aOption, IN_BSTR aValue); 112 STDMETHOD(RemoveVmSlotOptions)(IN_BSTR aVmName, LONG aSlot); 113 STDMETHOD(GetVmSlotOptions)(IN_BSTR aVmName, LONG aSlot, ComSafeArrayOut(BSTR, aValues)); 114 STDMETHOD(GetMacOptions)(IN_BSTR aMAC, ComSafeArrayOut(BSTR, aValues)); 115 STDMETHOD(COMGETTER(EventSource))(IEventSource **aEventSource); 116 117 72 118 STDMETHOD(SetConfiguration)(IN_BSTR aIPAddress, IN_BSTR aNetworkMask, IN_BSTR aFromIPAddress, IN_BSTR aToIPAddress); 73 119 … … 86 132 87 133 Bstr IPAddress; 88 Bstr networkMask;89 134 Bstr lowerIP; 90 135 Bstr upperIP; 136 91 137 BOOL enabled; 92 93 138 DHCPServerRunner dhcp; 139 140 DhcpOptionMap GlobalDhcpOptions; 141 VmSlot2OptionsMap VmSlot2Options; 94 142 } m; 95 143 144 DhcpOptionMap& findOptMapByVmNameSlot(const com::Utf8Str& aVmName, 145 LONG Slot); 96 146 }; 97 147 -
trunk/src/VBox/Main/include/HostImpl.h
r44528 r46959 62 62 STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut(IHostUSBDeviceFilter *, aUSBDeviceFilters)); 63 63 STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces)); 64 STDMETHOD(COMGETTER(NameServers))(ComSafeArrayOut(BSTR, aNameServers)); 65 STDMETHOD(COMGETTER(DomainName))(BSTR *aDomainName); 66 STDMETHOD(COMGETTER(SearchStrings))(ComSafeArrayOut(BSTR, aSearchStrings)); 67 64 68 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count); 65 69 STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count); … … 147 151 HRESULT updateNetIfList(); 148 152 153 #ifndef RT_OS_WINDOWS 154 HRESULT parseResolvConf(); 155 #else 156 HRESULT fetchNameResolvingInformation(); 157 #endif 158 149 159 #ifdef VBOX_WITH_RESOURCE_USAGE_API 150 160 void registerMetrics(PerformanceCollector *aCollector); -
trunk/src/VBox/Main/include/NATNetworkImpl.h
r45559 r46959 37 37 } 38 38 39 #ifdef RT_OS_WINDOWS 40 # define NATSR_EXECUTABLE_NAME "VBoxNetLwipNAT.exe" 41 #else 42 # define NATSR_EXECUTABLE_NAME "VBoxNetLwipNAT" 43 #endif 44 45 class NATNetworkServiceRunner: public NetworkServiceRunner 46 { 47 public: 48 NATNetworkServiceRunner(): NetworkServiceRunner(NATSR_EXECUTABLE_NAME){} 49 virtual ~NATNetworkServiceRunner(){} 50 }; 39 51 40 52 class ATL_NO_VTABLE NATNetwork : -
trunk/src/VBox/Main/include/NetworkServiceRunner.h
r46958 r46959 23 23 typedef enum 24 24 { 25 DHCPCFG_NAME = 1, 26 DHCPCFG_NETNAME, 27 DHCPCFG_TRUNKTYPE, 28 DHCPCFG_TRUNKNAME, 29 DHCPCFG_MACADDRESS, 30 DHCPCFG_IPADDRESS, 31 DHCPCFG_LEASEDB, 32 DHCPCFG_VERBOSE, 33 DHCPCFG_GATEWAY, 34 DHCPCFG_LOWERIP, 35 DHCPCFG_UPPERIP, 36 DHCPCFG_NETMASK, 37 DHCPCFG_HELP, 38 DHCPCFG_VERSION, 39 DHCPCFG_BEGINCONFIG, 40 DHCPCFG_NOTOPT_MAXVAL 41 }DHCPCFG; 25 NETCFG_NAME = 1, 26 NETCFG_NETNAME, 27 NETCFG_TRUNKTYPE, 28 NETCFG_TRUNKNAME, 29 NETCFG_MACADDRESS, 30 NETCFG_IPADDRESS, 31 NETCFG_NETMASK, 32 NETCFG_VERBOSE, 33 NETCFG_NOTOPT_MAXVAL 34 }NETCFG; 42 35 43 36 #define TRUNKTYPE_WHATEVER "whatever" … … 46 39 #define TRUNKTYPE_SRVNAT "srvnat" 47 40 48 class DHCPServerRunner41 class NetworkServiceRunner 49 42 { 50 43 public: 51 DHCPServerRunner(); 52 ~DHCPServerRunner() { stop(); /* don't leave abandoned servers */} 44 NetworkServiceRunner(const char *aProcName): 45 mProcName(aProcName), 46 mProcess(NIL_RTPROCESS) 47 { 48 memset(mOptionEnabled, 0, sizeof(mOptionEnabled)); 49 }; 50 ~NetworkServiceRunner() { stop(); /* don't leave abandoned servers */} 53 51 54 int setOption( DHCPCFG opt, const char *val, bool enabled)52 int setOption(NETCFG opt, const char *val, bool enabled) 55 53 { 56 if (opt == 0 || opt >= DHCPCFG_NOTOPT_MAXVAL)54 if (opt == 0 || opt >= NETCFG_NOTOPT_MAXVAL) 57 55 return VERR_INVALID_PARAMETER; 58 56 if (isRunning()) … … 64 62 } 65 63 66 int setOption( DHCPCFG opt, const com::Utf8Str &val, bool enabled)64 int setOption(NETCFG opt, const com::Utf8Str &val, bool enabled) 67 65 { 68 66 return setOption(opt, val.c_str(), enabled); … … 75 73 void detachFromServer(); 76 74 private: 77 com::Utf8Str mOptions[DHCPCFG_NOTOPT_MAXVAL]; 78 bool mOptionEnabled[DHCPCFG_NOTOPT_MAXVAL]; 75 com::Utf8Str mOptions[NETCFG_NOTOPT_MAXVAL]; 76 bool mOptionEnabled[NETCFG_NOTOPT_MAXVAL]; 77 const char *mProcName; 79 78 RTPROCESS mProcess; 80 79 }; -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r46880 r46959 115 115 #endif /* VBOX_WITH_NETFLT */ 116 116 117 #include " DHCPServerRunner.h"117 #include "NetworkServiceRunner.h" 118 118 #include "BusAssignmentManager.h" 119 119 #ifdef VBOX_WITH_EXTPACK -
trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp
r44528 r46959 18 18 */ 19 19 20 #include " DHCPServerRunner.h"20 #include "NetworkServiceRunner.h" 21 21 #include "DHCPServerImpl.h" 22 22 #include "AutoCaller.h" … … 25 25 #include <iprt/cpp/utils.h> 26 26 27 #include <VBox/com/array.h> 27 28 #include <VBox/settings.h> 28 29 … … 37 38 } 38 39 40 39 41 DHCPServer::~DHCPServer() 40 42 { 41 43 } 42 44 45 43 46 HRESULT DHCPServer::FinalConstruct() 44 47 { … … 46 49 } 47 50 51 48 52 void DHCPServer::FinalRelease() 49 53 { … … 52 56 BaseFinalRelease(); 53 57 } 58 54 59 55 60 void DHCPServer::uninit() … … 63 68 } 64 69 70 65 71 HRESULT DHCPServer::init(VirtualBox *aVirtualBox, IN_BSTR aName) 66 72 { … … 75 81 unconst(mName) = aName; 76 82 m.IPAddress = "0.0.0.0"; 77 m. networkMask = "0.0.0.0";83 m.GlobalDhcpOptions.insert(DhcpOptValuePair(DhcpOpt_SubnetMask, Bstr("0.0.0.0"))); 78 84 m.enabled = FALSE; 85 79 86 m.lowerIP = "0.0.0.0"; 80 87 m.upperIP = "0.0.0.0"; … … 85 92 return S_OK; 86 93 } 94 87 95 88 96 HRESULT DHCPServer::init(VirtualBox *aVirtualBox, … … 98 106 unconst(mName) = data.strNetworkName; 99 107 m.IPAddress = data.strIPAddress; 100 m.networkMask = data.strIPNetworkMask;101 108 m.enabled = data.fEnabled; 102 109 m.lowerIP = data.strIPLower; 103 110 m.upperIP = data.strIPUpper; 104 111 112 113 m.GlobalDhcpOptions.clear(); 114 m.GlobalDhcpOptions.insert(data.GlobalDhcpOptions.begin(), 115 data.GlobalDhcpOptions.end()); 116 117 m.VmSlot2Options.clear(); 118 m.VmSlot2Options.insert(data.VmSlot2OptionsM.begin(), 119 data.VmSlot2OptionsM.end()); 120 105 121 autoInitSpan.setSucceeded(); 106 122 107 123 return S_OK; 108 124 } 125 109 126 110 127 HRESULT DHCPServer::saveSettings(settings::DHCPServer &data) … … 117 134 data.strNetworkName = mName; 118 135 data.strIPAddress = m.IPAddress; 119 data.strIPNetworkMask = m.networkMask; 136 120 137 data.fEnabled = !!m.enabled; 121 138 data.strIPLower = m.lowerIP; 122 139 data.strIPUpper = m.upperIP; 123 140 124 return S_OK; 125 } 141 data.GlobalDhcpOptions.clear(); 142 data.GlobalDhcpOptions.insert(m.GlobalDhcpOptions.begin(), 143 m.GlobalDhcpOptions.end()); 144 145 data.VmSlot2OptionsM.clear(); 146 data.VmSlot2OptionsM.insert(m.VmSlot2Options.begin(), 147 m.VmSlot2Options.end()); 148 149 return S_OK; 150 } 151 126 152 127 153 STDMETHODIMP DHCPServer::COMGETTER(NetworkName) (BSTR *aName) … … 137 163 } 138 164 165 139 166 STDMETHODIMP DHCPServer::COMGETTER(Enabled) (BOOL *aEnabled) 140 167 { … … 148 175 return S_OK; 149 176 } 177 150 178 151 179 STDMETHODIMP DHCPServer::COMSETTER(Enabled) (BOOL aEnabled) … … 165 193 } 166 194 195 167 196 STDMETHODIMP DHCPServer::COMGETTER(IPAddress) (BSTR *aIPAddress) 168 197 { … … 177 206 } 178 207 208 179 209 STDMETHODIMP DHCPServer::COMGETTER(NetworkMask) (BSTR *aNetworkMask) 180 210 { … … 184 214 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 185 215 186 m.networkMask.cloneTo(aNetworkMask); 187 188 return S_OK; 189 } 216 m.GlobalDhcpOptions[DhcpOpt_SubnetMask].cloneTo(aNetworkMask); 217 218 return S_OK; 219 } 220 190 221 191 222 STDMETHODIMP DHCPServer::COMGETTER(LowerIP) (BSTR *aIPAddress) … … 195 226 AutoCaller autoCaller(this); 196 227 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 197 228 198 229 m.lowerIP.cloneTo(aIPAddress); 199 230 … … 201 232 } 202 233 234 203 235 STDMETHODIMP DHCPServer::COMGETTER(UpperIP) (BSTR *aIPAddress) 204 236 { … … 212 244 return S_OK; 213 245 } 246 214 247 215 248 STDMETHODIMP DHCPServer::SetConfiguration (IN_BSTR aIPAddress, IN_BSTR aNetworkMask, IN_BSTR aLowerIP, IN_BSTR aUpperIP) … … 225 258 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 226 259 m.IPAddress = aIPAddress; 227 m.networkMask = aNetworkMask; 260 m.GlobalDhcpOptions[DhcpOpt_SubnetMask] = aNetworkMask; 261 228 262 m.lowerIP = aLowerIP; 229 263 m.upperIP = aUpperIP; … … 235 269 } 236 270 271 272 STDMETHODIMP DHCPServer::AddGlobalOption(DhcpOpt_T aOption, IN_BSTR aValue) 273 { 274 CheckComArgStr(aValue); 275 /* store global option */ 276 AutoCaller autoCaller(this); 277 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 278 279 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 280 281 m.GlobalDhcpOptions.insert( 282 DhcpOptValuePair(aOption, Utf8Str(aValue))); 283 284 alock.release(); 285 286 AutoWriteLock vboxLock(mVirtualBox COMMA_LOCKVAL_SRC_POS); 287 return mVirtualBox->saveSettings(); 288 } 289 290 291 STDMETHODIMP DHCPServer::COMGETTER(GlobalOptions)(ComSafeArrayOut(BSTR, aValue)) 292 { 293 CheckComArgOutSafeArrayPointerValid(aValue); 294 295 AutoCaller autoCaller(this); 296 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 297 298 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 299 300 SafeArray<BSTR> sf(m.GlobalDhcpOptions.size()); 301 int i = 0; 302 303 for (DhcpOptIterator it = m.GlobalDhcpOptions.begin(); 304 it != m.GlobalDhcpOptions.end(); ++it) 305 { 306 Bstr(Utf8StrFmt("%d:%s", (*it).first, (*it).second.c_str())).detachTo(&sf[i]); 307 i++; 308 } 309 310 sf.detachTo(ComSafeArrayOutArg(aValue)); 311 312 return S_OK; 313 } 314 315 316 STDMETHODIMP DHCPServer::COMGETTER(VmConfigs)(ComSafeArrayOut(BSTR, aValue)) 317 { 318 CheckComArgOutSafeArrayPointerValid(aValue); 319 320 AutoCaller autoCaller(this); 321 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 322 323 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 324 325 SafeArray<BSTR> sf(m.VmSlot2Options.size()); 326 VmSlot2OptionsIterator it = m.VmSlot2Options.begin(); 327 int i = 0; 328 for (;it != m.VmSlot2Options.end(); ++it) 329 { 330 Bstr(Utf8StrFmt("[%s]:%d", 331 it->first.VmName.c_str(), 332 it->first.Slot)).detachTo(&sf[i]); 333 i++; 334 } 335 336 sf.detachTo(ComSafeArrayOutArg(aValue)); 337 338 return S_OK; 339 } 340 341 342 STDMETHODIMP DHCPServer::AddVmSlotOption(IN_BSTR aVmName, LONG aSlot, DhcpOpt_T aOption, IN_BSTR aValue) 343 { 344 AutoCaller autoCaller(this); 345 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 346 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 347 348 m.VmSlot2Options[settings::VmNameSlotKey( 349 com::Utf8Str(aVmName), 350 aSlot)][aOption] = com::Utf8Str(aValue); 351 352 353 alock.release(); 354 355 AutoWriteLock vboxLock(mVirtualBox COMMA_LOCKVAL_SRC_POS); 356 return mVirtualBox->saveSettings(); 357 } 358 359 360 STDMETHODIMP DHCPServer::RemoveVmSlotOptions(IN_BSTR aVmName, LONG aSlot) 361 { 362 AutoCaller autoCaller(this); 363 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 364 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 365 366 DhcpOptionMap& map = findOptMapByVmNameSlot(com::Utf8Str(aVmName), aSlot); 367 368 map.clear(); 369 370 alock.release(); 371 372 AutoWriteLock vboxLock(mVirtualBox COMMA_LOCKVAL_SRC_POS); 373 return mVirtualBox->saveSettings(); 374 } 375 376 377 /** 378 * this is mapping (vm, slot) 379 */ 380 STDMETHODIMP DHCPServer::GetVmSlotOptions(IN_BSTR aVmName, LONG aSlot, ComSafeArrayOut(BSTR, aValues)) 381 { 382 CheckComArgOutSafeArrayPointerValid(aValues); 383 AutoCaller autoCaller(this); 384 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 385 386 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 387 388 DhcpOptionMap& map = findOptMapByVmNameSlot(com::Utf8Str(aVmName), aSlot); 389 390 SafeArray<BSTR> sf(map.size()); 391 int i = 0; 392 393 for (DhcpOptIterator it = map.begin(); 394 it != map.end(); ++it) 395 { 396 Bstr(Utf8StrFmt("%d:%s", (*it).first, (*it).second.c_str())).detachTo(&sf[i]); 397 i++; 398 } 399 400 sf.detachTo(ComSafeArrayOutArg(aValues)); 401 402 return S_OK; 403 } 404 405 406 STDMETHODIMP DHCPServer::GetMacOptions(IN_BSTR aMAC, ComSafeArrayOut(BSTR, aValues)) 407 { 408 CheckComArgOutSafeArrayPointerValid(aValues); 409 410 AutoCaller autoCaller(this); 411 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 412 413 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 414 HRESULT hrc; 415 416 ComPtr<IMachine> machine; 417 ComPtr<INetworkAdapter> nic; 418 419 VmSlot2OptionsIterator it; 420 for(it = m.VmSlot2Options.begin(); 421 it != m.VmSlot2Options.end(); 422 ++it) 423 { 424 425 alock.release(); 426 hrc = mVirtualBox->FindMachine(Bstr(it->first.VmName).raw(), machine.asOutParam()); 427 alock.acquire(); 428 429 if (FAILED(hrc)) 430 continue; 431 432 alock.release(); 433 hrc = machine->GetNetworkAdapter(it->first.Slot, nic.asOutParam()); 434 alock.acquire(); 435 436 if (FAILED(hrc)) 437 continue; 438 439 com::Bstr mac; 440 441 alock.release(); 442 hrc = nic->GetMACAddress(mac.asOutParam()); 443 alock.acquire(); 444 445 if (FAILED(hrc)) /* no MAC address ??? */ 446 break; 447 448 if (!RTStrICmp(com::Utf8Str(mac).c_str(), com::Utf8Str(aMAC).c_str())) 449 return GetVmSlotOptions(Bstr(it->first.VmName).raw(), 450 it->first.Slot, 451 ComSafeArrayOutArg(aValues)); 452 } /* end of for */ 453 454 return hrc; 455 } 456 457 458 STDMETHODIMP DHCPServer::COMGETTER(EventSource)(IEventSource **aEventSource) 459 { 460 ReturnComNotImplemented(); 461 } 462 463 237 464 STDMETHODIMP DHCPServer::Start(IN_BSTR aNetworkName, IN_BSTR aTrunkName, IN_BSTR aTrunkType) 238 465 { … … 240 467 if (!m.enabled) 241 468 return S_OK; 242 243 m.dhcp.setOption(DHCPCFG_NETNAME, Utf8Str(aNetworkName), true); 469 470 /* Commmon Network Settings */ 471 m.dhcp.setOption(NETCFG_NETNAME, Utf8Str(aNetworkName), true); 472 244 473 Bstr tmp(aTrunkName); 474 245 475 if (!tmp.isEmpty()) 246 m.dhcp.setOption( DHCPCFG_TRUNKNAME, Utf8Str(tmp), true);247 m.dhcp.setOption( DHCPCFG_TRUNKTYPE, Utf8Str(aTrunkType), true);248 //temporary hack for testing 249 / / DHCPCFG_NAME476 m.dhcp.setOption(NETCFG_TRUNKNAME, Utf8Str(tmp), true); 477 m.dhcp.setOption(NETCFG_TRUNKTYPE, Utf8Str(aTrunkType), true); 478 479 /* XXX: should this MAC default initialization moved to NetworkServiceRunner? */ 250 480 char strMAC[32]; 251 481 Guid guid; 252 482 guid.create(); 253 483 RTStrPrintf (strMAC, sizeof(strMAC), "08:00:27:%02X:%02X:%02X", 254 guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]); 255 m.dhcp.setOption(DHCPCFG_MACADDRESS, strMAC, true); 256 m.dhcp.setOption(DHCPCFG_IPADDRESS, Utf8Str(m.IPAddress), true); 257 // DHCPCFG_LEASEDB, 258 // DHCPCFG_VERBOSE, 259 // DHCPCFG_GATEWAY, 260 m.dhcp.setOption(DHCPCFG_LOWERIP, Utf8Str(m.lowerIP), true); 261 m.dhcp.setOption(DHCPCFG_UPPERIP, Utf8Str(m.upperIP), true); 262 m.dhcp.setOption(DHCPCFG_NETMASK, Utf8Str(m.networkMask), true); 263 264 // DHCPCFG_HELP, 265 // DHCPCFG_VERSION, 266 // DHCPCFG_NOTOPT_MAXVAL 267 m.dhcp.setOption(DHCPCFG_BEGINCONFIG, "", true); 268 484 guid.raw()->au8[0], 485 guid.raw()->au8[1], 486 guid.raw()->au8[2]); 487 m.dhcp.setOption(NETCFG_MACADDRESS, strMAC, true); 488 m.dhcp.setOption(NETCFG_IPADDRESS, Utf8Str(m.IPAddress), true); 489 m.dhcp.setOption(NETCFG_NETMASK, Utf8Str(m.GlobalDhcpOptions[DhcpOpt_SubnetMask]), true); 490 491 /* XXX: This parameters Dhcp Server will fetch via API */ 269 492 return RT_FAILURE(m.dhcp.start()) ? E_FAIL : S_OK; 270 493 //m.dhcp.detachFromServer(); /* need to do this to avoid server shutdown on runner destruction */ 271 494 } 272 495 496 273 497 STDMETHODIMP DHCPServer::Stop (void) 274 498 { 275 499 return RT_FAILURE(m.dhcp.stop()) ? E_FAIL : S_OK; 276 500 } 501 502 DhcpOptionMap& DHCPServer::findOptMapByVmNameSlot(const com::Utf8Str& aVmName, 503 LONG aSlot) 504 { 505 return m.VmSlot2Options[settings::VmNameSlotKey( 506 com::Utf8Str(aVmName), 507 aSlot)]; 508 } -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r46820 r46959 134 134 #include <iprt/mem.h> 135 135 #include <iprt/system.h> 136 #ifndef RT_OS_WINDOWS 137 # include <iprt/path.h> 138 #endif 136 139 #ifdef RT_OS_SOLARIS 137 # include <iprt/path.h>138 140 # include <iprt/ctype.h> 139 141 #endif … … 215 217 216 218 HostPowerService *pHostPowerService; 219 220 /* Name resolving */ 221 std::list<com::Bstr> llNameServers; 222 std::list<com::Bstr> llSearchStrings; 223 Bstr DomainName; 224 /* XXX: we need timestamp when these values were set, on repeate in some 225 * (~1h?, 5 min?) period, this values should be refetched from host syetem. 226 */ 217 227 }; 218 228 229 #ifndef RT_OS_WINDOWS 230 static char g_aszResolvConf[RTPATH_MAX]; 231 232 static inline char *getResolvConfPath() 233 { 234 int rc = VINF_SUCCESS; 235 if (!g_aszResolvConf[0]) return g_aszResolvConf; 236 # ifdef RT_OS_OS2 237 /* 238 * This was in an old Slirp code: 239 * IBM's "Technical Document # - 16070238", clearly says \MPTN\ETC\RESOLV2 240 * no redolv.conf (remark to code in old Slirp code) 241 */ 242 if (RTEnvExists("ETC")) 243 { 244 RTStrmPrintf(g_aszResolvConf, MAX_PATH, "%/RESOLV2", RTEnvGet("ETC")); 245 rc = RTFileExists(g_aszResolvConf); 246 if (RT_SUCCESS(rc)) 247 return g_aszResolvConf; 248 } 249 250 RT_ZERO(g_aszResolvConf); 251 RTStrmPrintf(g_aszResolvConf, MAX_PATH, "%/RESOLV2", _PATH_ETC); 252 # else 253 strcmp(g_aszResolvConf, "/etc/resolv.conf"); 254 # endif 255 return g_aszResolvConf; 256 } 257 #endif 219 258 220 259 //////////////////////////////////////////////////////////////////////////////// … … 797 836 #endif 798 837 } 838 839 840 /** 841 * This method return the list of registered name servers 842 */ 843 STDMETHODIMP Host::COMGETTER(NameServers)(ComSafeArrayOut(BSTR, aNameServers)) 844 { 845 return E_NOTIMPL; 846 } 847 848 849 /** 850 * This method returns the domain name of the host 851 */ 852 STDMETHODIMP Host::COMGETTER(DomainName)(BSTR *aDomainName) 853 { 854 return E_NOTIMPL; 855 } 856 857 858 /** 859 * This method returns the search string. 860 */ 861 STDMETHODIMP Host::COMGETTER(SearchStrings)(ComSafeArrayOut(BSTR, aSearchStrings)) 862 { 863 return E_NOTIMPL; 864 } 865 799 866 800 867 STDMETHODIMP Host::COMGETTER(USBDeviceFilters)(ComSafeArrayOut(IHostUSBDeviceFilter*, aUSBDeviceFilters)) -
trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp
r45559 r46959 18 18 */ 19 19 20 #include " DHCPServerRunner.h"20 #include "NetworkServiceRunner.h" 21 21 #include "DHCPServerImpl.h" 22 22 #include "NATNetworkImpl.h" … … 35 35 #include "VBoxEvents.h" 36 36 37 #include "NATNetworkServiceRunner.h"38 37 #include "VirtualBoxImpl.h" 39 38 … … 632 631 633 632 if (!m->fEnabled) return S_OK; 634 m->NATRunner.setOption(NATSCCFG_NAME, mName, true); 635 m->NATRunner.setOption(NATSCCFG_TRUNKTYPE, Utf8Str(aTrunkType), true); 636 m->NATRunner.setOption(NATSCCFG_IPADDRESS, m->IPv4Gateway, true); 637 m->NATRunner.setOption(NATSCCFG_NETMASK, m->IPv4NetworkMask, true); 638 639 /* port-forwarding */ 640 641 for (constNATRuleMapIterator it = m->mapName2PortForwardRule4.begin(); 642 it != m->mapName2PortForwardRule4.end(); ++it) 643 { 644 settings::NATRule r = it->second; 645 m->NATRunner.setOption(NATSCCFG_PORTFORWARD4, 646 Bstr(Utf8StrFmt("%s:%d:[%s]:%d:[%s]:%d", 647 r.strName.c_str(), 648 r.proto, 649 r.strHostIP.isEmpty() ? 650 "0.0.0.0" : 651 r.strHostIP.c_str(), 652 r.u16HostPort, 653 r.strGuestIP.c_str(), 654 r.u16GuestPort)), true); 655 } 633 634 m->NATRunner.setOption(NETCFG_NETNAME, mName, true); 635 m->NATRunner.setOption(NETCFG_TRUNKTYPE, Utf8Str(aTrunkType), true); 636 m->NATRunner.setOption(NETCFG_IPADDRESS, m->IPv4Gateway, true); 637 m->NATRunner.setOption(NETCFG_NETMASK, m->IPv4NetworkMask, true); 638 639 /* No portforwarding rules from command-line, all will be fetched via API */ 656 640 657 641 if (m->fNeedDhcpServer) … … 682 666 return E_FAIL; 683 667 /* breakthrough */ 684 case S_OK: 668 685 669 { 686 670 LogFunc(("gateway: %s, dhcpserver:%s, dhcplowerip:%s, dhcpupperip:%s\n", … … 689 673 Utf8Str(m->IPv4DhcpServerLowerIp.raw()).c_str(), 690 674 Utf8Str(m->IPv4DhcpServerUpperIp.raw()).c_str())); 691 675 676 m->dhcpServer->AddGlobalOption(DhcpOpt_Router, m->IPv4Gateway.raw()); 692 677 693 678 rc = m->dhcpServer->SetEnabled(true); 679 694 680 BSTR dhcpip = NULL; 695 681 BSTR netmask = NULL; 696 682 BSTR lowerip = NULL; 697 683 BSTR upperip = NULL; 684 698 685 m->IPv4DhcpServer.cloneTo(&dhcpip); 699 686 m->IPv4NetworkMask.cloneTo(&netmask); 700 701 687 m->IPv4DhcpServerLowerIp.cloneTo(&lowerip); 702 688 m->IPv4DhcpServerUpperIp.cloneTo(&upperip); … … 705 691 lowerip, 706 692 upperip); 707 break;708 693 } 709 710 default: 711 return E_FAIL; 694 case S_OK: 695 break; 696 697 default: 698 return E_FAIL; 712 699 } 713 700 … … 728 715 #else 729 716 NOREF(aTrunkType); 730 return E_NOTIMPL;717 ReturnComNotImplemented(); 731 718 #endif 732 719 } … … 741 728 } 742 729 else return E_FAIL; 743 744 730 #else 745 return E_NOTIMPL;731 ReturnComNotImplemented(); 746 732 #endif 747 733 } … … 818 804 m->IPv4DhcpServerLowerIp = aszDhcpLowerIp; 819 805 m->IPv4DhcpServerUpperIp = aszDhcpUpperIp; 820 LogFunc(("network: %RTnaipv4, dhcpserver:%RTnaipv4, dhcplowerip:%RTnaipv4, dhcpupperip:%RTnaipv4\n", network, dhcpserver, dhcplowerip, dhcpupperip)); 806 807 LogFunc(("network: %RTnaipv4, dhcpserver:%RTnaipv4, dhcplowerip:%RTnaipv4, dhcpupperip:%RTnaipv4\n", 808 network, 809 dhcpserver, 810 dhcplowerip, 811 dhcpupperip)); 821 812 } 822 813 /* we need IPv4NetworkMask for NAT's gw service start */ -
trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp
r46958 r46959 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 #include " DHCPServerRunner.h"17 #include "NetworkServiceRunner.h" 18 18 #include <iprt/process.h> 19 19 #include <iprt/param.h> … … 22 22 struct ARGDEF 23 23 { 24 DHCPCFG Type;24 NETCFG Type; 25 25 const char * Name; 26 26 }; 27 27 28 #ifdef RT_OS_WINDOWS29 # define DHCP_EXECUTABLE_NAME "VBoxNetDHCP.exe"30 #else31 # define DHCP_EXECUTABLE_NAME "VBoxNetDHCP"32 #endif33 34 28 static const ARGDEF g_aArgDefs[] = 35 29 { 36 {DHCPCFG_NAME, "--name"}, 37 {DHCPCFG_NETNAME, "--network"}, 38 {DHCPCFG_TRUNKTYPE, "--trunk-type"}, 39 {DHCPCFG_TRUNKNAME, "--trunk-name"}, 40 {DHCPCFG_MACADDRESS, "--mac-address"}, 41 {DHCPCFG_IPADDRESS, "--ip-address"}, 42 {DHCPCFG_LEASEDB, "--lease-db"}, 43 {DHCPCFG_VERBOSE, "--verbose"}, 44 {DHCPCFG_BEGINCONFIG, "--begin-config"}, 45 {DHCPCFG_GATEWAY, "--gateway"}, 46 {DHCPCFG_LOWERIP, "--lower-ip"}, 47 {DHCPCFG_UPPERIP, "--upper-ip"}, 48 {DHCPCFG_NETMASK, "--netmask"}, 49 {DHCPCFG_HELP, "--help"}, 50 {DHCPCFG_VERSION, "--version"} 30 {NETCFG_NAME, "--name"}, 31 {NETCFG_NETNAME, "--network"}, 32 {NETCFG_TRUNKTYPE, "--trunk-type"}, 33 {NETCFG_TRUNKNAME, "--trunk-name"}, 34 {NETCFG_MACADDRESS, "--mac-address"}, 35 {NETCFG_IPADDRESS, "--ip-address"}, 36 {NETCFG_VERBOSE, "--verbose"}, 37 {NETCFG_NETMASK, "--netmask"}, 51 38 }; 52 39 53 static const ARGDEF * getArgDef( DHCPCFG type)40 static const ARGDEF * getArgDef(NETCFG type) 54 41 { 55 42 for (unsigned i = 0; i < RT_ELEMENTS(g_aArgDefs); i++) … … 60 47 } 61 48 62 DHCPServerRunner::DHCPServerRunner() 63 { 64 mProcess = NIL_RTPROCESS; 65 for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++) 66 { 67 mOptionEnabled[i] = false; 68 } 69 } 70 71 void DHCPServerRunner::detachFromServer() 49 void NetworkServiceRunner::detachFromServer() 72 50 { 73 51 mProcess = NIL_RTPROCESS; 74 52 } 75 53 76 int DHCPServerRunner::start()54 int NetworkServiceRunner::start() 77 55 { 78 56 if (isRunning()) 79 57 return VINF_ALREADY_INITIALIZED; 80 58 81 const char * args[ DHCPCFG_NOTOPT_MAXVAL * 2];59 const char * args[NETCFG_NOTOPT_MAXVAL * 2]; 82 60 83 61 /* get the path to the executable */ … … 91 69 { 92 70 suffix++; 93 strcpy(suffix, DHCP_EXECUTABLE_NAME);71 strcpy(suffix, mProcName); 94 72 } 95 else96 exePath = DHCP_EXECUTABLE_NAME;97 73 98 74 int index = 0; … … 100 76 args[index++] = exePath; 101 77 102 for (unsigned i = 0; i < DHCPCFG_NOTOPT_MAXVAL; i++)78 for (unsigned i = 0; i < NETCFG_NOTOPT_MAXVAL; i++) 103 79 { 104 80 if (mOptionEnabled[i]) 105 81 { 106 const ARGDEF *pArgDef = getArgDef(( DHCPCFG)i);82 const ARGDEF *pArgDef = getArgDef((NETCFG)i); 107 83 if (!pArgDef) 108 84 continue; 109 args[index++] = pArgDef->Name; // e.g. "--network"85 args[index++] = pArgDef->Name; 110 86 111 /* value can be null for e.g. --begin-config has no value112 * and thus check the mOptions string length here113 */114 87 if (mOptions[i].length()) 115 88 args[index++] = mOptions[i].c_str(); // value … … 119 92 args[index++] = NULL; 120 93 121 int rc = RTProcCreate( exePath, args, RTENV_DEFAULT, 0, &mProcess);94 int rc = RTProcCreate(suffix ? exePath : mProcName, args, RTENV_DEFAULT, 0, &mProcess); 122 95 if (RT_FAILURE(rc)) 123 96 mProcess = NIL_RTPROCESS; … … 126 99 } 127 100 128 int DHCPServerRunner::stop()101 int NetworkServiceRunner::stop() 129 102 { 130 103 if (!isRunning()) … … 136 109 } 137 110 138 bool DHCPServerRunner::isRunning()111 bool NetworkServiceRunner::isRunning() 139 112 { 140 113 if (mProcess == NIL_RTPROCESS) -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r46651 r46959 61 61 #include "SystemPropertiesImpl.h" 62 62 #include "GuestOSTypeImpl.h" 63 #include " DHCPServerRunner.h"63 #include "NetworkServiceRunner.h" 64 64 #include "DHCPServerImpl.h" 65 65 #include "NATNetworkImpl.h" -
trunk/src/VBox/Main/src-server/xpcom/server.cpp
r46909 r46959 67 67 #include "BandwidthControlImpl.h" 68 68 #include "BandwidthGroupImpl.h" 69 #include " DHCPServerRunner.h"69 #include "NetworkServiceRunner.h" 70 70 #include "DHCPServerImpl.h" 71 71 #include "GuestOSTypeImpl.h" -
trunk/src/VBox/Main/xml/Settings.cpp
r46720 r46959 1302 1302 if ( (pelmServer->getAttributeValue("networkName", srv.strNetworkName)) 1303 1303 && (pelmServer->getAttributeValue("IPAddress", srv.strIPAddress)) 1304 && (pelmServer->getAttributeValue("networkMask", srv.strIPNetworkMask))1304 && (pelmServer->getAttributeValue("networkMask", srv.GlobalDhcpOptions[DhcpOpt_SubnetMask])) 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 } 1309 1329 llDhcpServers.push_back(srv); 1330 } 1310 1331 else 1311 1332 throw ConfigFileError(this, pelmServer, N_("Required DHCPServer/@networkName, @IPAddress, @networkMask, @lowerIP, @upperIP or @enabled attribute is missing")); 1312 1333 } 1313 1334 } 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 1314 1357 } 1315 1358 … … 1446 1489 #endif 1447 1490 srv.strIPAddress = "192.168.56.100"; 1448 srv. strIPNetworkMask= "255.255.255.0";1491 srv.GlobalDhcpOptions[DhcpOpt_SubnetMask] = "255.255.255.0"; 1449 1492 srv.strIPLower = "192.168.56.101"; 1450 1493 srv.strIPUpper = "192.168.56.254"; … … 1489 1532 const DHCPServer &d = *it; 1490 1533 xml::ElementNode *pelmThis = pelmDHCPServers->createChild("DHCPServer"); 1534 DhcpOptConstIterator itOpt; 1535 itOpt = d.GlobalDhcpOptions.find(DhcpOpt_SubnetMask); 1536 1491 1537 pelmThis->setAttribute("networkName", d.strNetworkName); 1492 1538 pelmThis->setAttribute("IPAddress", d.strIPAddress); 1493 pelmThis->setAttribute("networkMask", d.strIPNetworkMask); 1539 if (itOpt != d.GlobalDhcpOptions.end()) 1540 pelmThis->setAttribute("networkMask", itOpt->second); 1494 1541 pelmThis->setAttribute("lowerIP", d.strIPLower); 1495 1542 pelmThis->setAttribute("upperIP", d.strIPUpper); 1496 1543 pelmThis->setAttribute("enabled", (d.fEnabled) ? 1 : 0); // too bad we chose 1 vs. 0 here 1497 } 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 } 1498 1593 1499 1594 /* TODO: bump main version ? */
Note:
See TracChangeset
for help on using the changeset viewer.