VBoxManageHostonly.cpp revision 08a5b674adfbbe190929a378cab16381cef6f727
/* $Id$ */
/** @file
* VBoxManage - Implementation of hostonlyif command.
*/
/*
* Copyright (C) 2006-2009 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 *
*******************************************************************************/
#ifndef VBOX_ONLY_DOCS
#include <vector>
#include <list>
#endif /* !VBOX_ONLY_DOCS */
#include "VBoxManage.h"
#ifndef VBOX_ONLY_DOCS
using namespace com;
#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
{
index++;
{
if (info.isBasicAvailable())
RTPrintf("Error: failed to remove the host-only adapter. Error message: %lS\n", info.getText().raw());
else
RTPrintf("Error: failed to remove the host-only adapter. No error message available, HRESULT code: 0x%x\n", hr);
return 1;
}
return 0;
}
{
index++;
{
if (info.isBasicAvailable())
RTPrintf("Error: failed to remove the host-only adapter. Error message: %lS\n", info.getText().raw());
else
RTPrintf("Error: failed to remove the host-only adapter. No error message available, HRESULT code: 0x%x\n", hr);
return 1;
}
return 0;
}
#endif
enum enOptionCodes
{
DHCP = 1000,
IP,
IPV6,
};
static const RTGETOPTDEF g_aListOptions[]
= {
};
{
index++;
bool bDhcp = false;
bool bNetmasklengthv6 = false;
uint8_t uNetmasklengthv6 = 0;
bool bIp = false;
bool bNetmask = false;
int c;
a->argc,
a->argv,
0 /* fFlags */);
{
switch (c)
{
case DHCP: // -dhcp
if (bDhcp)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6.");
else
bDhcp = true;
break;
case IP:
if(bIp)
else if (bDhcp)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6.");
else if(bNetmasklengthv6 || pIpv6)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use ipv4 configuration (-ip and -netmask) with ipv6 (-ipv6 and -netmasklengthv6) simultaneously.");
else
{
bIp = true;
}
break;
case NETMASK:
if(bNetmask)
else if (bDhcp)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6.");
else if(bNetmasklengthv6 || pIpv6)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use ipv4 configuration (-ip and -netmask) with ipv6 (-ipv6 and -netmasklengthv6) simultaneously.");
else
{
bNetmask = true;
}
break;
case IPV6:
if(pIpv6)
else if (bDhcp)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6.");
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use ipv4 configuration (-ip and -netmask) with ipv6 (-ipv6 and -netmasklengthv6) simultaneously.");
else
break;
case NETMASKLENGTHV6:
if(bNetmasklengthv6)
else if (bDhcp)
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6.");
return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can not use ipv4 configuration (-ip and -netmask) with ipv6 (-ipv6 and -netmasklengthv6) simultaneously.");
else
{
bNetmasklengthv6 = true;
}
break;
default:
if (c > 0)
else if (ValueUnion.pDef)
else
}
}
if(bDhcp)
{
}
else if(bIp)
{
if(!bNetmask)
{
netmask.u = 0;
}
}
else if(pIpv6)
{
}
else
{
}
return 0;
}
int handleHostonlyIf(HandlerArg *a)
{
int result = 0;
if (a->argc < 1)
for (int i = 0; i < a->argc; i++)
{
{
int cProcessed;
break;
// if(!rc)
// i+= cProcessed;
// else
// break;
}
#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
{
int cProcessed;
if(!result)
i+= cProcessed;
else
break;
}
{
int cProcessed;
if(!result)
i+= cProcessed;
else
break;
}
#endif
else
{
break;
}
}
return result;
}
#endif /* !VBOX_ONLY_DOCS */