VBoxNetAdpInstall.cpp revision 7c63dd76442a4896af6ce9c65d87461d3e7fe82b
/* $Id$ */
/** @file
* NetAdpInstall - VBoxNetAdp installer command line tool
*/
/*
* Copyright (C) 2009 Oracle Corporation
*
* 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.
*/
#include <VBox/VBoxNetCfg-win.h>
#include <VBox/VBoxDrvCfg-win.h>
#include <stdio.h>
#include <devguid.h>
#define VBOX_NETADP_INF L".\\VBoxNetAdp.inf"
{
}
static int VBoxNetAdpInstall()
{
int r = 1;
{
#if 0 //ndef DEBUG_misha
printf("not implemented yet, please use device manager for Host-Only net interface installation.. sorry :( \n");
#else
printf("adding host-only interface..\n");
WinEr = GetLastError();
if(WinEr == ERROR_SUCCESS)
{
{
{
/* ip returned by VBoxNetCfgWinGenHostOnlyNetworkNetworkIp is a network ip,
* i.e. 192.168.xxx.0, assign 192.168.xxx.1 for the hostonly adapter */
{
}
else
{
r = 0;
}
}
else
{
}
}
else
{
}
}
else
{
}
#endif
}
else
{
}
return r;
}
static int VBoxNetAdpUninstall()
{
int r = 1;
printf("uninstalling all Host-Only interfaces..\n");
{
{
hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", L"sun_VBoxNetAdp", 0/* could be SUOI_FORCEDELETE */);
{
printf("uninstalled successfully\n");
}
else
{
printf("uninstalled successfully, but failed to remove infs\n");
}
r = 0;
}
else
{
}
}
else
{
}
return r;
}
static int VBoxNetAdpUpdate()
{
int r = 1;
printf("uninstalling all Host-Only interfaces..\n");
{
{
if (fRebootRequired)
printf("!!REBOOT REQUIRED!!\n");
printf("updated successfully\n");
r = 0;
}
else
{
}
}
else
{
}
return r;
}
static int VBoxNetAdpDisable()
{
int r = 1;
printf("disabling all Host-Only interfaces..\n");
{
hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(L"sun_VBoxNetAdp", VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE);
{
printf("disable succeeded!\n");
r = 0;
}
else
{
}
}
else
{
}
return r;
}
static int VBoxNetAdpEnable()
{
int r = 1;
printf("enabling all Host-Only interfaces..\n");
{
hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(L"sun_VBoxNetAdp", VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE);
{
printf("disable succeeded!\n");
r = 0;
}
else
{
}
}
else
{
}
return r;
}
static void printUsage()
{
printf("Host-Only network adapter configuration tool\n"
" Usage: VBoxNetAdpInstall [cmd]\n"
" cmd can be one of the following values:\n"
" i - install a new host-only interface\n"
" u - uninstall all host-only interfaces\n"
" a - update the host-only driver\n"
" d - disable all host-only interfaces\n"
" e - enable all host-only interfaces\n"
" h - print this message\n");
}
{
if (argc < 2)
return VBoxNetAdpInstall();
if (argc > 2)
{
printUsage();
return 1;
}
__debugbreak();
return VBoxNetAdpInstall();
return VBoxNetAdpUninstall();
return VBoxNetAdpUpdate();
return VBoxNetAdpDisable();
return VBoxNetAdpEnable();
printUsage();
}