VBoxManageDHCPServer.cpp revision c829b606c5535f37e00ffee381cca0815a57f319
/* $Id$ */
/** @file
* VBoxManage - Implementation of dhcpserver 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;
typedef enum enMainOpCodes
{
OP_ADD = 1000,
} OPCODE;
static const RTGETOPTDEF g_aDHCPIPOptions[]
= {
* 1. the misspelled "-enable" long option to be treated as 'e' (for -enable) + 'n' (for -netname) + "<the_rest_opt>" (for net name)
* 2. the misspelled "-netmask" to be treated as 'n' (for -netname) + "<the_rest_opt>" (for net name)
*/
* 1. the misspelled "-disable" long option to be treated as 'd' (for -disable) + 'i' (for -ifname) + "<the_rest_opt>" (for if name)
*/
};
{
int enable = -1;
int c;
a->argc,
a->argv,
enmCode != OP_REMOVE ? RT_ELEMENTS(g_aDHCPIPOptions) : 4, /* we use only --netname and --ifname for remove*/
{
switch (c)
{
case 't': // --netname
if(pNetName)
else if (pIfName)
return errorSyntax(USAGE_DHCPSERVER, "You can either use a --netname or --ifname for identifying the dhcp server.");
else
{
}
break;
case 'f': // --ifname
if(pIfName)
else if (pNetName)
return errorSyntax(USAGE_DHCPSERVER, "You can either use a --netname or --ipname for identifying the dhcp server.");
else
{
}
break;
case 'a': // -ip
if(pIp)
else
{
}
break;
case 'm': // --netmask
if(pNetmask)
else
{
}
break;
case 'l': // --lowerip
if(pLowerIp)
else
{
}
break;
case 'u': // --upperip
if(pUpperIp)
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;
default:
if (c > 0)
{
if (RT_C_IS_GRAPH(c))
else
}
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
else if (ValueUnion.pDef)
else
}
}
return errorSyntax(USAGE_DHCPSERVER, "You need to specify either --netname or --ifname to identify the dhcp server");
{
{
if(!pIp)
if(!pNetmask)
if(!pLowerIp)
if(!pUpperIp)
}
}
if(!pNetName)
{
}
else
{
}
{
return errorArgument("dhcp server already exists");
return errorArgument("failed to create server");
}
{
return errorArgument("dhcp server does not exist");
}
{
{
CHECK_ERROR(svr, SetConfiguration (Bstr(pIp).mutableRaw(), Bstr(pNetmask).mutableRaw(), Bstr(pLowerIp).mutableRaw(), Bstr(pUpperIp).mutableRaw()));
return errorArgument("failed to set configuration");
}
if(enable >= 0)
{
}
}
else
{
return errorArgument("failed to remove server");
}
return 0;
}
int handleDHCPServer(HandlerArg *a)
{
int result = 0;
if (a->argc < 1)
for (int i = 0; i < a->argc; i++)
{
{
int cProcessed;
break;
}
{
int cProcessed;
break;
}
{
int cProcessed;
break;
}
else
{
break;
}
}
return result;
}
#endif /* !VBOX_ONLY_DOCS */