Changeset 49516 in vbox for trunk/src/VBox/NetworkServices
- Timestamp:
- Nov 16, 2013 6:42:31 AM (11 years ago)
- Location:
- trunk/src/VBox/NetworkServices
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/DHCP/VBoxNetDHCP.cpp
r49490 r49516 357 357 int VBoxNetDhcp::init() 358 358 { 359 HRESULT hrc = S_OK; 360 /* ok, here we should initiate instance of dhcp server 361 * and listener for Dhcp configuration events 362 */ 363 AssertRCReturn(virtualbox.isNull(), VERR_INTERNAL_ERROR); 364 365 hrc = virtualbox->FindDHCPServerByNetworkName(com::Bstr(m_Network.c_str()).raw(), 366 m_DhcpServer.asOutParam()); 367 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 368 369 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(), 370 m_NATNetwork.asOutParam()); 371 372 373 bool fNoMain = m_NATNetwork.isNull(); 374 int rc; 359 int rc = this->VBoxNetBaseService::init(); 360 AssertRCReturn(rc, rc); 361 375 362 NetworkManager *netManager = NetworkManager::getNetworkManager(); 376 363 … … 378 365 netManager->setOurNetmask(m_Ipv4Netmask); 379 366 netManager->setOurMac(m_MacAddress); 380 381 if (fNoMain) 367 368 if (m_fNeedMain) 369 rc = initWithMain(); 370 else 382 371 rc = initNoMain(); 383 else384 rc = initWithMain();385 372 386 373 AssertRCReturn(rc, rc); … … 733 720 int VBoxNetDhcp::initNoMain() 734 721 { 735 /* In Host-Only mode we don't need Main. */736 com::Shutdown();737 738 722 CmdParameterIterator it; 739 723 … … 777 761 int VBoxNetDhcp::initWithMain() 778 762 { 763 /* ok, here we should initiate instance of dhcp server 764 * and listener for Dhcp configuration events 765 */ 766 AssertRCReturn(virtualbox.isNull(), VERR_INTERNAL_ERROR); 767 768 HRESULT hrc = virtualbox->FindDHCPServerByNetworkName(com::Bstr(m_Network.c_str()).raw(), 769 m_DhcpServer.asOutParam()); 770 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 771 772 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(), 773 m_NATNetwork.asOutParam()); 774 779 775 BOOL fNeedDhcpServer = false; 780 776 if (FAILED(m_NATNetwork->COMGETTER(NeedDhcpServer)(&fNeedDhcpServer))) … … 787 783 com::Bstr strGateway; 788 784 789 HRESULThrc = m_NATNetwork->COMGETTER(Gateway)(strGateway.asOutParam());785 hrc = m_NATNetwork->COMGETTER(Gateway)(strGateway.asOutParam()); 790 786 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 791 787 RTNetStrToIPv4Addr(com::Utf8Str(strGateway).c_str(), &gateway); … … 918 914 * Instantiate the DHCP server and hand it the options. 919 915 */ 920 HRESULT hrc = com::Initialize();921 Assert(!FAILED(hrc));922 916 923 917 VBoxNetDhcp *pDhcp = new VBoxNetDhcp(); -
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r49413 r49516 890 890 int VBoxNetLwipNAT::init() 891 891 { 892 int rc = VINF_SUCCESS;893 892 HRESULT hrc; 894 893 LogFlowFuncEnter(); … … 896 895 897 896 /* virtualbox initialized in super class */ 897 898 int rc = ::VBoxNetBaseService::init(); 899 AssertRCReturn(rc, rc); 898 900 899 901 hrc = virtualbox->FindNATNetworkByName(com::Bstr(m_Network.c_str()).raw(), -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r49492 r49516 86 86 { "--netmask", 'm', RTGETOPT_REQ_IPV4ADDR }, 87 87 { "--verbose", 'v', RTGETOPT_REQ_NOTHING }, 88 { "--need-main", 'M', RTGETOPT_REQ_BOOL }, 88 89 }; 89 90 … … 102 103 m_Name = "VBoxNetNAT"; 103 104 m_Network = "intnet"; 105 m_fNeedMain = false; 104 106 105 107 for(unsigned int i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i) 106 108 m_vecOptionDefs.push_back(&g_aGetOptDef[i]); 107 108 HRESULT hrc = virtualbox.createLocalObject(CLSID_VirtualBox);109 if (FAILED(hrc))110 RTMsgError("Failed to create the VirtualBox object!");111 109 } 112 110 … … 140 138 int VBoxNetBaseService::init() 141 139 { 140 if (m_fNeedMain) 141 { 142 HRESULT hrc = com::Initialize(); 143 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 144 145 hrc = virtualbox.createLocalObject(CLSID_VirtualBox); 146 AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); 147 } 148 142 149 return VINF_SUCCESS; 143 150 } … … 223 230 return 1; 224 231 232 case 'M': // --need-main 233 m_fNeedMain = true; 234 break; 235 225 236 case 'h': // --help (missed) 226 237 RTPrintf("%s Version %sr%u\n" -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.h
r47019 r49516 83 83 PINTNETBUF m_pIfBuf; /**< Interface buffer. */ 84 84 std::vector<PRTGETOPTDEF> m_vecOptionDefs; 85 bool m_fNeedMain; 85 86 /** @} */ 86 87 /** @name Debug stuff
Note:
See TracChangeset
for help on using the changeset viewer.