NetIfList-win.cpp revision 53636fa747df9082f1a251c3b1b5a804308a390d
/* $Id$ */
/** @file
* Main - NetIfList, Windows implementation.
*/
/*
* Copyright (C) 2008 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_MAIN
#include <list>
#define _WIN32_DCOM
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#ifdef VBOX_WITH_NETFLT
#include "VBox/WinNetConfig.h"
#include "devguid.h"
#endif
#include <iphlpapi.h>
#include "Logging.h"
#include "HostNetworkInterfaceImpl.h"
#include "ProgressImpl.h"
#include "VirtualBoxImpl.h"
#include "netif.h"
#ifdef VBOX_WITH_NETFLT
#include <Wbemidl.h>
#include <comdef.h>
#include "svchlp.h"
#include <shellapi.h>
#define INITGUID
#include <guiddef.h>
#include <devguid.h>
#include <objbase.h>
#include <setupapi.h>
#include <shlobj.h>
#include <cfgmgr32.h>
#define VBOX_APP_NAME L"VirtualBox"
{
// Step 3: ---------------------------------------------------
// Obtain the initial locator to WMI -------------------------
0,
{
// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method
// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
{
LogRel(("Connected to ROOT\\CIMV2 WMI namespace\n"));
// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
{
/* do not need it any more */
return hres;
}
else
{
}
}
else
{
}
}
else
{
// CoUninitialize();
}
return hres;
}
static HRESULT netIfWinFindAdapterClassById(IWbemServices * pSvc, const Guid &guid, IWbemClassObject **pAdapterConfig)
{
// char uuidStr[RTUUID_STR_LENGTH];
// int rc = RTUuidToStr(guid.toString().raw(), uuidStr, sizeof(uuidStr));
{
swprintf(aQueryString, L"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE SettingID = \"{%S}\"", guid.toString().raw());
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
bstr_t("WQL"),
NULL,
&pEnumerator);
{
// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------
while (pEnumerator)
{
{
if(uReturn)
{
pEnumerator->Release();
return hres;
}
else
{
}
}
}
pEnumerator->Release();
}
else
{
}
}
return hres;
}
{
// Get the value of the key property
{
}
else
{
Assert(0);
}
return hr;
}
)
{
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
{
{
{
// Store the value for the in parameters
pArgs[i], 0);
{
break;
}
}
{
{
}
}
}
}
return hres;
}
{
if(pIpArray)
{
{
long aIndex[1];
aIndex[0] = i;
{
break;
}
}
{
}
}
else
{
Assert(0);
}
return hr;
}
{
if(pIpArray)
{
long aIndex[1];
aIndex[0] = 0;
{
}
{
}
}
else
{
Assert(0);
}
return hr;
}
{
{
}
return hr;
}
{
{
}
return hr;
}
static HRESULT netIfWinEnableStatic(IWbemServices * pSvc, BSTR ObjPath, VARIANT * pIp, VARIANT * pMask)
{
if(ClassName)
{
{
{
&varReturnValue, NULL, 0);
{
switch(winEr)
{
case 0:
break;
default:
break;
}
}
}
}
}
else
{
Assert(0);
}
return hr;
}
static HRESULT netIfWinEnableStaticV4(IWbemServices * pSvc, BSTR ObjPath, in_addr* aIp, in_addr * aMask, UINT cIp)
{
{
{
}
}
return hr;
}
{
{
{
}
}
return hr;
}
/* win API allows to set gw metrics as well, we are not setting them */
{
if(ClassName)
{
{
{
}
}
}
else
{
Assert(0);
}
return hr;
}
/* win API allows to set gw metrics as well, we are not setting them */
{
{
}
return hr;
}
/* win API allows to set gw metrics as well, we are not setting them */
{
{
VariantClear(&vGw);
}
return hr;
}
{
if(ClassName)
{
{
{
}
}
}
else
{
Assert(0);
}
return hr;
}
{
/*
* Most of the hosts probably have less than 10 adapters,
* so we'll mostly succeed from the first attempt.
*/
if (!pAddresses)
return VERR_NO_MEMORY;
if (dwRc == ERROR_BUFFER_OVERFLOW)
{
/* Impressive! More than 10 adapters! Get more memory and try again. */
if (!pAddresses)
return VERR_NO_MEMORY;
}
{
{
{
{
bool fIPFound, fIPv6Found;
fIPFound = fIPv6Found = false;
{
{
case AF_INET:
if (!fIPFound)
{
fIPFound = true;
}
break;
case AF_INET6:
if (!fIPv6Found)
{
fIPv6Found = true;
sizeof(pInfo->IPv6Address));
}
break;
}
}
fIPFound = fIPv6Found = false;
{
{
case AF_INET:
if (!fIPFound)
{
fIPFound = true;
}
break;
case AF_INET6:
if (!fIPv6Found)
{
fIPv6Found = true;
}
break;
}
}
Log(("collectNetIfInfo: Unexpected physical address length: %u\n", pAdapter->PhysicalAddressLength));
else
break;
}
}
}
}
return VINF_SUCCESS;
}
//static HRESULT netIfWinUpdateConfig(HostNetworkInterface * pIf)
//{
// NETIFINFO Info;
// memset(&Info, 0, sizeof(Info));
// GUID guid;
// HRESULT hr = pIf->COMGETTER(Id) (&guid);
// if(SUCCEEDED(hr))
// {
// Info.Uuid = (RTUUID)*(RTUUID*)&guid;
// BSTR name;
// hr = pIf->COMGETTER(Name) (&name);
// Assert(hr == S_OK);
// if(hr == S_OK)
// {
// int rc = collectNetIfInfo(Bstr(name), &Info);
// if (RT_SUCCESS(rc))
// {
// hr = pIf->updateConfig(&Info);
// }
// else
// {
// Log(("netIfWinUpdateConfig: collectNetIfInfo() -> %Vrc\n", rc));
// hr = E_FAIL;
// }
// }
// }
//
// return hr;
//}
{
{
{
{
{
#if 0
#endif
{
// hr = netIfWinUpdateConfig(pIf);
}
}
}
}
}
}
static int netIfEnableStaticIpConfigV6(const Guid & guid, IN_BSTR aIPV6Address, IN_BSTR aIPV6Mask, IN_BSTR aIPV6DefaultGateway)
{
{
{
{
{
{
}
{
// hr = netIfWinUpdateConfig(pIf);
}
}
}
}
}
}
static int netIfEnableStaticIpConfigV6(const Guid &guid, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength)
{
if(RT_SUCCESS(rc))
{
}
return rc;
}
{
{
{
{
{
// hr = netIfWinUpdateConfig(pIf);
}
}
}
}
return hr;
}
/* svc helper func */
struct StaticIpConfig
{
};
struct StaticIpV6Config
{
};
{
/* for SVCHlpMsg::CreateHostOnlyNetworkInterface */
/* for SVCHlpMsg::RemoveHostOnlyNetworkInterface */
union
{
} u;
};
{
LogFlowFunc (("aClient={%p}, aProgress={%p}, aUser={%p}\n",
d (static_cast <NetworkInterfaceHelperClientData *> (aUser));
{
/* "cleanup only" mode, just return (it will free aUser) */
return S_OK;
}
int vrc = VINF_SUCCESS;
switch (d->msgCode)
{
{
LogFlowFunc (("CreateHostOnlyNetworkInterface:\n"));
/* write message and parameters */
if (RT_FAILURE (vrc)) break;
// vrc = aClient->write (Utf8Str (d->name));
// if (RT_FAILURE (vrc)) break;
/* wait for a reply */
bool endLoop = false;
while (!endLoop)
{
if (RT_FAILURE (vrc)) break;
switch (reply)
{
{
/* read the GUID */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
/* initialize the object returned to the caller by
* CreateHostOnlyNetworkInterface() */
endLoop = true;
break;
}
{
/* read the error message */
if (RT_FAILURE (vrc)) break;
endLoop = true;
break;
}
default:
{
endLoop = true;
//"Invalid message code %d (%08lX)\n",
//reply, reply),
//rc = E_FAIL);
}
}
}
break;
}
{
LogFlowFunc (("RemoveHostOnlyNetworkInterface:\n"));
/* write message and parameters */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
/* wait for a reply */
bool endLoop = false;
while (!endLoop)
{
if (RT_FAILURE (vrc)) break;
switch (reply)
{
{
/* no parameters */
endLoop = true;
break;
}
{
/* read the error message */
if (RT_FAILURE (vrc)) break;
endLoop = true;
break;
}
default:
{
endLoop = true;
//"Invalid message code %d (%08lX)\n",
//reply, reply),
//rc = E_FAIL);
}
}
}
break;
}
{
LogFlowFunc (("EnableDynamicIpConfig:\n"));
/* write message and parameters */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
/* wait for a reply */
bool endLoop = false;
while (!endLoop)
{
if (RT_FAILURE (vrc)) break;
switch (reply)
{
{
/* no parameters */
endLoop = true;
break;
}
{
/* read the error message */
if (RT_FAILURE (vrc)) break;
endLoop = true;
break;
}
default:
{
endLoop = true;
//"Invalid message code %d (%08lX)\n",
//reply, reply),
//rc = E_FAIL);
}
}
}
break;
}
{
LogFlowFunc (("EnableStaticIpConfig:\n"));
/* write message and parameters */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
/* wait for a reply */
bool endLoop = false;
while (!endLoop)
{
if (RT_FAILURE (vrc)) break;
switch (reply)
{
{
/* no parameters */
endLoop = true;
break;
}
{
/* read the error message */
if (RT_FAILURE (vrc)) break;
endLoop = true;
break;
}
default:
{
endLoop = true;
//"Invalid message code %d (%08lX)\n",
//reply, reply),
//rc = E_FAIL);
}
}
}
break;
}
{
LogFlowFunc (("EnableStaticIpConfigV6:\n"));
/* write message and parameters */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
/* wait for a reply */
bool endLoop = false;
while (!endLoop)
{
if (RT_FAILURE (vrc)) break;
switch (reply)
{
{
/* no parameters */
endLoop = true;
break;
}
{
/* read the error message */
if (RT_FAILURE (vrc)) break;
endLoop = true;
break;
}
default:
{
endLoop = true;
//"Invalid message code %d (%08lX)\n",
//reply, reply),
//rc = E_FAIL);
}
}
}
break;
}
default:
// "Invalid message code %d (%08lX)\n",
// d->msgCode, d->msgCode),
// rc = E_FAIL);
}
if (aVrc)
return rc;
}
/* The original source of the VBoxTAP adapter creation/destruction code has the following copyright */
/*
Copyright 2004 by the Massachusetts Institute of Technology
All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the Massachusetts
Institute of Technology (M.I.T.) not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.
M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
*/
/**
* Use the IShellFolder API to rename the connection.
*/
{
/* This is the GUID for the network connections folder. It is constant.
* {7007ACC7-3202-11D1-AAD2-00805FC1270E} */
const GUID CLSID_NetworkConnections = {
0x7007ACC7, 0x3202, 0x11D1, {
0xAA, 0xD2, 0x00, 0x80, 0x5F, 0xC1, 0x27, 0x0E
}
};
/* Build the display name in the form "::{GUID}". */
return E_INVALIDARG;
/* Create an instance of the network connections folder. */
reinterpret_cast <LPVOID *> (&pShellFolder));
/* Parse the display name. */
{
}
{
&pidl);
}
if (pShellFolder)
pShellFolder->Release();
return hr;
}
{
/* First try the IShellFolder interface, which was unimplemented
* for the network connections folder before XP. */
{
/** @todo that code doesn't seem to work! */
/* The IShellFolder interface is not implemented on this platform.
* Try the (undocumented) HrRenameConnection API in the netshell
* library. */
return E_FAIL;
return E_FAIL;
"HrRenameConnection");
if (RenameConnectionFunc == NULL)
{
return E_FAIL;
}
}
return status;
return S_OK;
}
#define SetErrBreak(strAndArgs) \
if (1) { \
} else do {} while (0)
/* static */
{
// LogFlowFunc (("Network connection name = '%s'\n", aName.raw()));
// AssertReturn (!aName.isNull(), VERR_INVALID_PARAMETER);
int vrc = VINF_SUCCESS;
do
{
/* for our purposes, 2k buffer is more
* than enough to obtain the hardware ID
* of the VBoxTAP driver. */
/* initialize the structure size */
/* copy the net class GUID */
/* create an empty device info set associated with the net class GUID */
if (hDeviceInfo == INVALID_HANDLE_VALUE)
SetErrBreak (("SetupDiCreateDeviceInfoList failed (0x%08X)",
GetLastError()));
/* get the class name from GUID */
if (!ok)
SetErrBreak (("SetupDiClassNameFromGuid failed (0x%08X)",
GetLastError()));
/* create a device info element and add the new device instance
* key to registry */
if (!ok)
SetErrBreak (("SetupDiCreateDeviceInfo failed (0x%08X)",
GetLastError()));
/* select the newly created device info to be the currently
selected member */
if (!ok)
SetErrBreak (("SetupDiSetSelectedDevice failed (0x%08X)",
GetLastError()));
/* build a list of class drivers */
if (!ok)
SetErrBreak (("SetupDiBuildDriverInfoList failed (0x%08X)",
GetLastError()));
destroyList = TRUE;
/* enumerate the driver info list */
while (TRUE)
{
/* if the function failed and GetLastError() returned
* ERROR_NO_MORE_ITEMS, then we have reached the end of the
* list. Othewise there was something wrong with this
* particular driver. */
if (!ret)
{
if(GetLastError() == ERROR_NO_MORE_ITEMS)
break;
else
{
index++;
continue;
}
}
/* if we successfully find the hardware ID and it turns out to
* be the one for the loopback driver, then we are done. */
sizeof (detailBuf),
NULL))
{
TCHAR * t;
/* pDriverInfoDetail->HardwareID is a MULTISZ string. Go through the
* whole list and see if there is a match somewhere. */
t = pDriverInfoDetail->HardwareID;
{
if (!_tcsicmp(t, DRIVERHWID))
break;
t += _tcslen(t) + 1;
}
{
break;
}
}
index ++;
}
if (!found)
SetErrBreak (("Could not find Host Interface Networking driver! "
"Please reinstall"));
/* set the loopback driver to be the currently selected */
if (!ok)
SetErrBreak (("SetupDiSetSelectedDriver failed (0x%08X)",
GetLastError()));
/* register the phantom device to prepare for install */
if (!ok)
SetErrBreak (("SetupDiCallClassInstaller failed (0x%08X)",
GetLastError()));
/* registered, but remove if errors occur in the following code */
registered = TRUE;
/* ask the installer if we can install the device */
if (!ok)
{
if (GetLastError() != ERROR_DI_DO_DEFAULT)
SetErrBreak (("SetupDiCallClassInstaller (DIF_ALLOW_INSTALL) failed (0x%08X)",
GetLastError()));
/* that's fine */
}
/* install the files first */
if (!ok)
SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLDEVICEFILES) failed (0x%08X)",
GetLastError()));
/* get the device install parameters and disable filecopy */
if (ok)
{
if (!ok)
SetErrBreak (("SetupDiSetDeviceInstallParams failed (0x%08X)",
GetLastError()));
}
/*
* Register any device-specific co-installers for this device,
*/
if (!ok)
SetErrBreak (("SetupDiCallClassInstaller (DIF_REGISTER_COINSTALLERS) failed (0x%08X)",
GetLastError()));
/*
* install any installer-specified interfaces.
* and then do the real install
*/
if (!ok)
SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLINTERFACES) failed (0x%08X)",
GetLastError()));
if (!ok)
SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLDEVICE) failed (0x%08X)",
GetLastError()));
/* Figure out NetCfgInstanceId */
0,
KEY_READ);
if (hkey == INVALID_HANDLE_VALUE)
SetErrBreak (("SetupDiOpenDevRegKey failed (0x%08X)",
GetLastError()));
cbSize = sizeof (pCfgGuidString);
RegCloseKey (hkey);
}
while (0);
/*
* cleanup
*/
if (hDeviceInfo != INVALID_HANDLE_VALUE)
{
/* an error has occured, but the device is registered, we must remove it */
if (ret != 0 && registered)
/* destroy the driver info list */
if (destroyList)
/* clean up the device info set */
}
/* return the network connection GUID on success */
if (RT_SUCCESS (vrc))
{
/* remove the curly bracket at the end */
&pNc,
&lpszApp );
{
aGUID.asOutParam(),
&pMpNcc);
{
{
}
}
}
{
}
}
return vrc;
}
/* static */
{
int vrc = VINF_SUCCESS;
do
{
/* We have to find the device instance ID through a registry search */
HKEY hkeyNetwork = 0;
HKEY hkeyConnection = 0;
do
{
char strRegLocation [256];
"SYSTEM\\CurrentControlSet\\Control\\Network\\"
"{4D36E972-E325-11CE-BFC1-08002BE10318}\\{%s}",
KEY_READ, &hkeyNetwork);
SetErrBreak ((
"Host interface network is not found in registry (%s) [1]",
SetErrBreak ((
"Host interface network is not found in registry (%s) [2]",
SetErrBreak ((
"Host interface network is not found in registry (%s) [3]",
}
while (0);
if (hkeyConnection)
if (hkeyNetwork)
if (RT_FAILURE (vrc))
break;
/*
* Now we are going to enumerate all network devices and
* wait until we encounter the right device instance ID
*/
do
{
/* initialize the structure size */
/* copy the net class GUID */
/* return a device info set contains all installed devices of the Net class */
if (hDeviceInfo == INVALID_HANDLE_VALUE)
/* enumerate the driver info list */
while (TRUE)
{
if (!ok)
{
if (GetLastError() == ERROR_NO_MORE_ITEMS)
break;
else
{
index++;
continue;
}
}
/* try to get the hardware ID registry property */
NULL,
NULL,
0,
&size);
if (!ok)
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
index++;
continue;
}
NULL,
size,
NULL);
if (!ok)
{
free (deviceHwid);
deviceHwid = NULL;
index++;
continue;
}
}
else
{
/* something is wrong. This shouldn't have worked with a NULL buffer */
index++;
continue;
}
for (TCHAR *t = deviceHwid;
t += _tcslen (t) + 1)
{
if (!_tcsicmp (DRIVERHWID, t))
{
/* get the device instance ID */
{
/* compare to what we determined before */
{
break;
}
}
}
}
if (deviceHwid)
{
free (deviceHwid);
deviceHwid = NULL;
}
if (found)
break;
index++;
}
SetErrBreak (("Host Interface Network driver not found (0x%08X)",
GetLastError()));
if (!ok)
SetErrBreak (("SetupDiSetSelectedDevice failed (0x%08X)",
GetLastError()));
if (!ok)
SetErrBreak (("SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)",
GetLastError()));
}
while (0);
/* clean up the device info set */
if (hDeviceInfo != INVALID_HANDLE_VALUE)
if (RT_FAILURE (vrc))
break;
}
while (0);
return vrc;
}
{
int vrc = VINF_SUCCESS;
switch (aMsgCode)
{
{
LogFlowFunc (("CreateHostOnlyNetworkInterface:\n"));
// Utf8Str name;
// vrc = aClient->read (name);
// if (RT_FAILURE (vrc)) break;
if (RT_SUCCESS (vrc))
{
/* write success followed by GUID */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
}
else
{
/* write failure followed by error message */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
}
break;
}
{
LogFlowFunc (("RemoveHostOnlyNetworkInterface:\n"));
if (RT_FAILURE (vrc)) break;
if (RT_SUCCESS (vrc))
{
/* write parameter-less success */
if (RT_FAILURE (vrc)) break;
}
else
{
/* write failure followed by error message */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
}
break;
}
case SVCHlpMsg::EnableStaticIpConfigV6:
{
LogFlowFunc (("EnableStaticIpConfigV6:\n"));
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_SUCCESS (vrc))
{
/* write success followed by GUID */
if (RT_FAILURE (vrc)) break;
}
else
{
/* write failure followed by error message */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
}
break;
}
case SVCHlpMsg::EnableStaticIpConfig:
{
LogFlowFunc (("EnableStaticIpConfig:\n"));
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
if (RT_SUCCESS (vrc))
{
/* write success followed by GUID */
if (RT_FAILURE (vrc)) break;
}
else
{
/* write failure followed by error message */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
}
break;
}
case SVCHlpMsg::EnableDynamicIpConfig:
{
LogFlowFunc (("EnableDynamicIpConfig:\n"));
if (RT_FAILURE (vrc)) break;
if (RT_SUCCESS (vrc))
{
/* write success followed by GUID */
if (RT_FAILURE (vrc)) break;
}
else
{
/* write failure followed by error message */
if (RT_FAILURE (vrc)) break;
if (RT_FAILURE (vrc)) break;
}
break;
}
default:
}
return vrc;
}
/** @todo REMOVE. OBSOLETE NOW. */
/**
* Returns TRUE if the Windows version is 6.0 or greater (i.e. it's Vista and
* later OSes) and it has the UAC (User Account Control) feature enabled.
*/
static BOOL IsUACEnabled()
{
LogFlowFunc (("dwMajorVersion=%d, dwMinorVersion=%d\n",
/* we are interested only in Vista (and newer versions...). In all
* earlier versions UAC is not present. */
return FALSE;
/* the default EnableLUA value is 1 (Enabled) */
"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
0, KEY_QUERY_VALUE, &hKey);
if (rc == ERROR_SUCCESS)
{
RegCloseKey (hKey);
}
return dwEnableLUA == 1;
}
/* end */
static int vboxNetWinAddComponent(std::list <ComObjPtr <HostNetworkInterface> > * pPist, INetCfgComponent * pncc, HostNetworkInterfaceType enmType)
{
int rc = VERR_GENERAL_FAILURE;
{
{
if (RT_FAILURE(rc))
{
}
/* create a new object and add it to the list */
/* remove the curly bracket at the end */
{
rc = VINF_SUCCESS;
}
else
{
Assert(0);
}
}
}
return rc;
}
#endif /* #ifndef VBOX_WITH_NETFLT */
{
#ifndef VBOX_WITH_NETFLT
/* VBoxNetAdp is available only when VBOX_WITH_NETFLT is enabled */
return VERR_NOT_IMPLEMENTED;
#else /* # if defined VBOX_WITH_NETFLT */
/* we are using the INetCfg API for getting the list of miniports */
&pNc,
&lpszApp );
{
{
{
//#ifndef DEBUG_bird
// Assert(hr == S_OK);
//#endif
{
if(uComponentStatus == 0)
{
{
{
}
}
}
}
}
}
else
{
}
}
else if(lpszApp)
{
}
#endif /* # if defined VBOX_WITH_NETFLT */
return VINF_SUCCESS;
}
{
#ifndef VBOX_WITH_NETFLT
return VERR_NOT_IMPLEMENTED;
#else
{
}
return VERR_GENERAL_FAILURE;
#endif
}
{
/* create a progress object */
{
FALSE /* aCancelable */);
{
/* create a new uninitialized host interface object */
/* create the networkInterfaceHelperClient() argument */
d (new NetworkInterfaceHelperClientData());
// d->name = aName;
static_cast <void *> (d.get()),
progress);
{
/* d is now owned by netIfNetworkInterfaceHelperClient(), so release it */
d.release();
}
}
}
}
{
/* create a progress object */
{
FALSE /* aCancelable */);
{
/* create the networkInterfaceHelperClient() argument */
d (new NetworkInterfaceHelperClientData());
static_cast <void *> (d.get()),
progress);
{
/* d is now owned by netIfNetworkInterfaceHelperClient(), so release it */
d.release();
}
}
}
}
{
{
{
/* create a progress object */
{
Bstr ("Enabling Dynamic Ip Configuration"),
FALSE /* aCancelable */);
{
// progress.queryInterfaceTo (aProgress);
/* create the networkInterfaceHelperClient() argument */
d (new NetworkInterfaceHelperClientData());
static_cast <void *> (d.get()),
progress);
{
/* d is now owned by netIfNetworkInterfaceHelperClient(), so release it */
d.release();
}
}
}
}
}
}
int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength)
{
{
{
/* create a progress object */
{
Bstr ("Enabling Dynamic Ip Configuration"),
FALSE /* aCancelable */);
{
// progress.queryInterfaceTo (aProgress);
/* create the networkInterfaceHelperClient() argument */
d (new NetworkInterfaceHelperClientData());
static_cast <void *> (d.get()),
progress);
{
/* d is now owned by netIfNetworkInterfaceHelperClient(), so release it */
d.release();
}
}
}
}
}
}
{
{
{
/* create a progress object */
{
Bstr ("Enabling Dynamic Ip Configuration"),
FALSE /* aCancelable */);
{
// progress.queryInterfaceTo (aProgress);
/* create the networkInterfaceHelperClient() argument */
d (new NetworkInterfaceHelperClientData());
static_cast <void *> (d.get()),
progress);
{
/* d is now owned by netIfNetworkInterfaceHelperClient(), so release it */
d.release();
}
}
}
}
}
}
{
#ifndef VBOX_WITH_NETFLT
return VERR_NOT_IMPLEMENTED;
#else /* # if defined VBOX_WITH_NETFLT */
/* we are using the INetCfg API for getting the list of miniports */
&pNc,
&lpszApp );
{
# ifdef VBOX_NETFLT_ONDEMAND_BIND
/* for the protocol-based approach for now we just get all miniports the MS_TCPIP protocol binds to */
# else
/* for the filter-based approach we get all miniports our filter (sun_VBoxNetFlt)is bound to */
# ifndef VBOX_WITH_HARDENING
{
/* TODO: try to install the netflt from here */
}
# endif
# endif
{
{
{
/* S_OK == enabled, S_FALSE == disabled */
{
{
{
{
//#ifndef DEBUG_bird
// Assert(hr == S_OK);
//#endif
{
if(uComponentStatus == 0)
{
}
}
}
}
}
}
}
}
}
else
{
}
}
return VINF_SUCCESS;
#endif /* # if defined VBOX_WITH_NETFLT */
}