VBoxNetAdpInstall.cpp revision 0169e67dce462cc3f7c8859b1bb3d7bcbca34775
/* $Id$ */
/** @file
* NetAdpInstall - VBoxNetAdp installer command line tool.
*/
/*
* Copyright (C) 2009-2012 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>
#ifdef NDIS60
#define VBOX_NETADP_INF L"VBoxNetAdp6.inf"
#else /* !NDIS60 */
#define VBOX_NETADP_INF L"VBoxNetAdp.inf"
#endif /* !NDIS60 */
{
}
static int VBoxNetAdpInstall(void)
{
{
printf("adding host-only interface..\n");
dwErr = GetLastError();
if (dwErr == 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 */
{
printf("installation successful\n");
}
else
}
else
}
else
}
else
{
}
}
else
}
static int VBoxNetAdpUninstall(void)
{
printf("uninstalling all host-only interfaces..\n");
{
{
hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", L"sun_VBoxNetAdp", 0/* could be SUOI_FORCEDELETE */);
{
printf("uninstallation successful\n");
}
else
printf("uninstalled successfully, but failed to remove infs\n");
}
else
}
else
}
static int VBoxNetAdpUpdate(void)
{
printf("uninstalling all host-only interfaces..\n");
{
{
if (fRebootRequired)
printf("!!REBOOT REQUIRED!!\n");
printf("updated successfully\n");
}
else
}
else
}
static int VBoxNetAdpDisable(void)
{
printf("disabling all host-only interfaces..\n");
{
hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(L"sun_VBoxNetAdp", VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE);
{
printf("disabling successful\n");
}
else
}
else
}
static int VBoxNetAdpEnable(void)
{
printf("enabling all host-only interfaces..\n");
{
hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(L"sun_VBoxNetAdp", VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE);
{
printf("enabling successful\n");
}
else
}
else
}
static void printUsage(void)
{
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 (default command)\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;
}
return VBoxNetAdpInstall();
return VBoxNetAdpUninstall();
return VBoxNetAdpUpdate();
return VBoxNetAdpDisable();
return VBoxNetAdpEnable();
printUsage();
}