- Timestamp:
- Mar 13, 2009 3:18:59 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
r17763 r17835 447 447 if (RT_FAILURE(rc)) 448 448 { 449 LogRel(("Failed to Enable StaticIpConfigV6with rc=%Vrc\n", rc));449 LogRel(("Failed to EnableDynamicIpConfig with rc=%Vrc\n", rc)); 450 450 return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; 451 451 } … … 454 454 } 455 455 456 STDMETHODIMP HostNetworkInterface::DhcpRediscover () 457 { 458 #ifndef VBOX_WITH_HOSTNETIF_API 459 return E_NOTIMPL; 460 #else 461 AutoCaller autoCaller (this); 462 CheckComRCReturnRC (autoCaller.rc()); 463 464 int rc = NetIfDhcpRediscover(mVBox, this); 465 if (RT_FAILURE(rc)) 466 { 467 LogRel(("Failed to DhcpRediscover with rc=%Vrc\n", rc)); 468 return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; 469 } 470 return S_OK; 471 #endif 472 } 473 456 474 HRESULT HostNetworkInterface::setVirtualBox(VirtualBox *pVBox) 457 475 { -
trunk/src/VBox/Main/generic/NetIf-generic.cpp
r17764 r17835 118 118 return VERR_NOT_IMPLEMENTED; 119 119 } 120 121 int NetIfDhcpRediscover(VirtualBox *pVbox, HostNetworkInterface * pIf) 122 { 123 return VERR_NOT_IMPLEMENTED; 124 } 125 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r17827 r17835 6537 6537 <interface 6538 6538 name="IHostNetworkInterface" extends="$unknown" 6539 uuid=" 09de36e8-2588-4050-a791-655240b556e0"6539 uuid="bcc99385-71ad-4887-90fc-15a3f2cad0a5" 6540 6540 wsmap="managed" 6541 6541 > … … 6624 6624 <method name="enableDynamicIpConfig"> 6625 6625 <desc>enables the dynamic IP configuration.</desc> 6626 </method> 6627 6628 <method name="dhcpRediscover"> 6629 <desc>refreshes the IP configuration for dhcp-enabled interface.</desc> 6626 6630 </method> 6627 6631 -
trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
r17759 r17835 84 84 STDMETHOD(EnableStaticIpConfigV6) (IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength); 85 85 STDMETHOD(EnableDynamicIpConfig) (); 86 STDMETHOD(DhcpRediscover) (); 86 87 87 88 // for VirtualBoxSupportErrorInfoImpl -
trunk/src/VBox/Main/include/netif.h
r17713 r17835 84 84 int NetIfRemoveHostOnlyNetworkInterface (VirtualBox *pVbox, IN_GUID aId, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress); 85 85 int NetIfGetConfig(HostNetworkInterface * pIf, NETIFINFO *); 86 int NetIfDhcpRediscover(VirtualBox *pVbox, HostNetworkInterface * pIf); 86 87 87 88 DECLINLINE(Bstr) composeIPv6Address(PRTNETADDRIPV6 aAddrPtr) -
trunk/src/VBox/Main/os2/NetIfList-os2.cpp
r17710 r17835 53 53 } 54 54 55 56 int NetIfDhcpRediscover(VirtualBox *pVbox, HostNetworkInterface * pIf) 57 { 58 return VERR_NOT_IMPLEMENTED; 59 } -
trunk/src/VBox/Main/win/NetIfList-win.cpp
r17811 r17835 567 567 hr = HRESULT_FROM_WIN32( winEr ); 568 568 break; 569 } 570 } 571 } 572 } 573 SysFreeString(ClassName); 574 } 575 else 576 { 577 DWORD dwError = GetLastError(); 578 Assert(0); 579 hr = HRESULT_FROM_WIN32( dwError ); 580 } 581 582 return hr; 583 } 584 585 static HRESULT netIfWinDhcpRediscover(IWbemServices * pSvc, BSTR ObjPath) 586 { 587 ComPtr<IWbemClassObject> pClass; 588 BSTR ClassName = SysAllocString(L"Win32_NetworkAdapterConfiguration"); 589 HRESULT hr; 590 if(ClassName) 591 { 592 hr = pSvc->GetObject(ClassName, 0, NULL, pClass.asOutParam(), NULL); 593 if(SUCCEEDED(hr)) 594 { 595 ComPtr<IWbemClassObject> pOutParams; 596 597 hr = netIfExecMethod(pSvc, pClass, ObjPath, 598 bstr_t(L"ReleaseDHCPLease"), NULL, NULL, 0, pOutParams.asOutParam()); 599 if(SUCCEEDED(hr)) 600 { 601 VARIANT varReturnValue; 602 hr = pOutParams->Get(bstr_t(L"ReturnValue"), 0, 603 &varReturnValue, NULL, 0); 604 Assert(SUCCEEDED(hr)); 605 if(SUCCEEDED(hr)) 606 { 607 // Assert(varReturnValue.vt == VT_UINT); 608 int winEr = varReturnValue.uintVal; 609 if(winEr == 0) 610 { 611 hr = netIfExecMethod(pSvc, pClass, ObjPath, 612 bstr_t(L"RenewDHCPLease"), NULL, NULL, 0, pOutParams.asOutParam()); 613 if(SUCCEEDED(hr)) 614 { 615 VARIANT varReturnValue; 616 hr = pOutParams->Get(bstr_t(L"ReturnValue"), 0, 617 &varReturnValue, NULL, 0); 618 Assert(SUCCEEDED(hr)); 619 if(SUCCEEDED(hr)) 620 { 621 // Assert(varReturnValue.vt == VT_UINT); 622 int winEr = varReturnValue.uintVal; 623 if(winEr == 0) 624 { 625 hr = S_OK; 626 } 627 else 628 { 629 hr = HRESULT_FROM_WIN32( winEr ); 630 } 631 } 632 } 633 } 634 else 635 { 636 hr = HRESULT_FROM_WIN32( winEr ); 569 637 } 570 638 } … … 832 900 } 833 901 902 static HRESULT netIfDhcpRediscover(const Guid &guid) 903 { 904 HRESULT hr; 905 ComPtr <IWbemServices> pSvc; 906 hr = netIfWinCreateIWbemServices(pSvc.asOutParam()); 907 if(SUCCEEDED(hr)) 908 { 909 ComPtr <IWbemClassObject> pAdapterConfig; 910 hr = netIfWinFindAdapterClassById(pSvc, guid, pAdapterConfig.asOutParam()); 911 if(SUCCEEDED(hr)) 912 { 913 BSTR ObjPath; 914 hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath); 915 if(SUCCEEDED(hr)) 916 { 917 hr = netIfWinEnableDHCP(pSvc, ObjPath); 918 if(SUCCEEDED(hr)) 919 { 920 // hr = netIfWinUpdateConfig(pIf); 921 } 922 SysFreeString(ObjPath); 923 } 924 } 925 } 926 927 928 return hr; 929 } 930 834 931 /* svc helper func */ 835 932 … … 1131 1228 if (RT_FAILURE (vrc)) break; 1132 1229 vrc = aClient->write (d->u.StaticIPV6.IPV6NetMaskLength); 1230 if (RT_FAILURE (vrc)) break; 1231 1232 /* wait for a reply */ 1233 bool endLoop = false; 1234 while (!endLoop) 1235 { 1236 SVCHlpMsg::Code reply = SVCHlpMsg::Null; 1237 1238 vrc = aClient->read (reply); 1239 if (RT_FAILURE (vrc)) break; 1240 1241 switch (reply) 1242 { 1243 case SVCHlpMsg::OK: 1244 { 1245 /* no parameters */ 1246 rc = d->iface->updateConfig(); 1247 endLoop = true; 1248 break; 1249 } 1250 case SVCHlpMsg::Error: 1251 { 1252 /* read the error message */ 1253 Utf8Str errMsg; 1254 vrc = aClient->read (errMsg); 1255 if (RT_FAILURE (vrc)) break; 1256 1257 rc = E_FAIL; // TODO: setError (E_FAIL, errMsg); 1258 endLoop = true; 1259 break; 1260 } 1261 default: 1262 { 1263 endLoop = true; 1264 rc = E_FAIL; // TODO: ComAssertMsgFailedBreak (( 1265 //"Invalid message code %d (%08lX)\n", 1266 //reply, reply), 1267 //rc = E_FAIL); 1268 } 1269 } 1270 } 1271 1272 break; 1273 } 1274 case SVCHlpMsg::DhcpRediscover: /* see usage in code */ 1275 { 1276 LogFlowFunc (("DhcpRediscover:\n")); 1277 LogFlowFunc (("Network connection name = '%ls'\n", d->name.raw())); 1278 1279 /* write message and parameters */ 1280 vrc = aClient->write (d->msgCode); 1281 if (RT_FAILURE (vrc)) break; 1282 vrc = aClient->write (d->guid); 1133 1283 if (RT_FAILURE (vrc)) break; 1134 1284 … … 1939 2089 break; 1940 2090 } 2091 case SVCHlpMsg::DhcpRediscover: 2092 { 2093 LogFlowFunc (("DhcpRediscover:\n")); 2094 2095 Guid guid; 2096 vrc = aClient->read (guid); 2097 if (RT_FAILURE (vrc)) break; 2098 2099 Utf8Str errMsg; 2100 vrc = netIfDhcpRediscover (guid); 2101 2102 if (RT_SUCCESS (vrc)) 2103 { 2104 /* write success followed by GUID */ 2105 vrc = aClient->write (SVCHlpMsg::OK); 2106 if (RT_FAILURE (vrc)) break; 2107 } 2108 else 2109 { 2110 /* write failure followed by error message */ 2111 if (errMsg.isEmpty()) 2112 errMsg = Utf8StrFmt ("Unspecified error (%Rrc)", vrc); 2113 vrc = aClient->write (SVCHlpMsg::Error); 2114 if (RT_FAILURE (vrc)) break; 2115 vrc = aClient->write (errMsg); 2116 if (RT_FAILURE (vrc)) break; 2117 } 2118 2119 break; 2120 } 1941 2121 default: 1942 2122 AssertMsgFailedBreakStmt ( … … 2353 2533 2354 2534 int NetIfEnableDynamicIpConfig(VirtualBox *vBox, HostNetworkInterface * pIf) 2535 { 2536 HRESULT rc; 2537 GUID guid; 2538 rc = pIf->COMGETTER(Id) (&guid); 2539 if(SUCCEEDED(rc)) 2540 { 2541 // ComPtr<VirtualBox> vBox; 2542 // rc = pIf->getVirtualBox (vBox.asOutParam()); 2543 // if(SUCCEEDED(rc)) 2544 { 2545 /* create a progress object */ 2546 ComObjPtr <Progress> progress; 2547 progress.createObject(); 2548 // ComPtr<IHost> host; 2549 // HRESULT rc = vBox->COMGETTER(Host)(host.asOutParam()); 2550 // if(SUCCEEDED(rc)) 2551 { 2552 rc = progress->init (vBox, (IHostNetworkInterface*)pIf, 2553 Bstr ("Enabling Dynamic Ip Configuration"), 2554 FALSE /* aCancelable */); 2555 if(SUCCEEDED(rc)) 2556 { 2557 CheckComRCReturnRC (rc); 2558 // progress.queryInterfaceTo (aProgress); 2559 2560 /* create the networkInterfaceHelperClient() argument */ 2561 std::auto_ptr <NetworkInterfaceHelperClientData> 2562 d (new NetworkInterfaceHelperClientData()); 2563 AssertReturn (d.get(), E_OUTOFMEMORY); 2564 2565 d->msgCode = SVCHlpMsg::EnableDynamicIpConfig; 2566 d->guid = guid; 2567 d->iface = pIf; 2568 2569 rc = vBox->startSVCHelperClient ( 2570 IsUACEnabled() == TRUE /* aPrivileged */, 2571 netIfNetworkInterfaceHelperClient, 2572 static_cast <void *> (d.get()), 2573 progress); 2574 2575 if (SUCCEEDED (rc)) 2576 { 2577 /* d is now owned by netIfNetworkInterfaceHelperClient(), so release it */ 2578 d.release(); 2579 2580 progress->WaitForCompletion(-1); 2581 } 2582 } 2583 } 2584 } 2585 } 2586 2587 return SUCCEEDED(rc) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; 2588 } 2589 2590 int NetIfDhcpRediscover(VirtualBox *vBox, HostNetworkInterface * pIf) 2355 2591 { 2356 2592 HRESULT rc; -
trunk/src/VBox/Main/win/svchlp.cpp
r17494 r17835 280 280 case SVCHlpMsg::EnableStaticIpConfig: 281 281 case SVCHlpMsg::EnableStaticIpConfigV6: 282 case SVCHlpMsg::DhcpRediscover: 282 283 { 283 284 vrc = netIfNetworkInterfaceHelperServer (this, msgCode); -
trunk/src/VBox/Main/win/svchlp.h
r17494 r17835 44 44 EnableStaticIpConfig, /* see usage in code */ 45 45 EnableStaticIpConfigV6, /* see usage in code */ 46 DhcpRediscover, /* see usage in code */ 46 47 }; 47 48 };
Note:
See TracChangeset
for help on using the changeset viewer.