VBoxManageNATNetwork.cpp revision a0a3a26a4065b9401681a8c99a11bd83e08f94cc
/* $Id$ */
/** @file
* VBoxManage - Implementation of NAT Network command command.
*/
/*
* Copyright (C) 2006-2013 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifndef VBOX_ONLY_DOCS
#endif /* !VBOX_ONLY_DOCS */
#include "VBoxManage.h"
#ifndef VBOX_ONLY_DOCS
using namespace com;
typedef enum enMainOpCodes
{
OP_ADD = 1000,
} OPCODE;
static const RTGETOPTDEF g_aNATNetworkIPOptions[]
= {
};
{
const char *pNetworkCidr = NULL;
int enable = -1;
int dhcp = -1;
int ipv6 = -1;
int c;
a->argc,
a->argv,
enmCode != OP_REMOVE ? RT_ELEMENTS(g_aNATNetworkIPOptions) : 4, /* we use only --netname and --ifname for remove*/
{
switch (c)
{
case 't': // --netname
if(pNetName)
else
{
}
break;
case 'n': // --network
if(pNetworkCidr)
else
{
}
break;
case 'e': // --enable
if(enable >= 0)
else
{
enable = 1;
}
break;
case 'd': // --disable
if(enable >= 0)
else
{
enable = 0;
}
break;
case VINF_GETOPT_NOT_OPTION:
break;
case 'h':
if (dhcp != -1)
dhcp = ValueUnion.f;
break;
case '6':
if (ipv6 != -1)
ipv6 = ValueUnion.f;
break;
default:
if (c > 0)
{
if (RT_C_IS_GRAPH(c))
else
}
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
else if (ValueUnion.pDef)
else
}
}
if (!pNetName)
return errorSyntax(USAGE_NATNETWORK,
"You need to specify --netname option");
/* verification */
switch (enmCode)
{
case OP_ADD:
if (!pNetworkCidr)
return errorSyntax(USAGE_NATNETWORK,
"You need to specify --network option");
break;
case OP_MODIFY:
case OP_REMOVE:
case OP_START:
case OP_STOP:
break;
default:
}
{
return errorArgument("NATNetwork server already exists");
return errorArgument("Failed to create the NAT network service");
}
{
return errorArgument("NATNetwork server does not exist");
}
switch (enmCode)
{
case OP_ADD:
case OP_MODIFY:
{
if (pNetworkCidr)
{
return errorArgument("Failed to set configuration");
}
if (dhcp >= 0)
{
return errorArgument("Failed to set configuration");
}
if (ipv6 >= 0)
{
return errorArgument("Failed to set configuration");
}
if(enable >= 0)
{
return errorArgument("Failed to set configuration");
}
break;
}
case OP_REMOVE:
{
return errorArgument("Failed to remove nat network");
break;
}
case OP_START:
{
return errorArgument("Failed to start network");
break;
}
case OP_STOP:
{
return errorArgument("Failed to start network");
break;
}
default:;
}
return 0;
}
int handleNATNetwork(HandlerArg *a)
{
if (a->argc < 1)
int result;
int cProcessed;
else
return result;
}
#endif /* !VBOX_ONLY_DOCS */