/* $Id$ */
/** @file
* VBoxManage - Implementation of dhcpserver command.
*/
/*
* Copyright (C) 2006-2010 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"
#include <string>
#include <vector>
#include <map>
#ifndef VBOX_ONLY_DOCS
using namespace com;
typedef enum enMainOpCodes
{
} OPCODE;
struct VmNameSlotKey
{
bool operator< (const VmNameSlotKey& that) const
{
else
}
};
= {
* 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)
*/
};
{
bool fOptionsRead = false;
bool fVmOptionRead = false;
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;
case 'o': // --options
{
// {"--vm", 'n', RTGETOPT_REQ_STRING}, /* only with -o */
// {"--slot", 's', RTGETOPT_REQ_UINT8}, /* only with -o and -n*/
// {"--id", 'i', RTGETOPT_REQ_UINT8}, /* only with -o */
// {"--value", 'p', RTGETOPT_REQ_STRING} /* only with -i */
if (fOptionsRead)
return errorSyntax(USAGE_DHCPSERVER,
"previos option edition wasn't finished");
fOptionsRead = true;
fVmOptionRead = false; /* we want specify new global or vm option*/
} /* end of --options */
break;
case 'n': // --vm-name
{
if (fVmOptionRead)
return errorSyntax(USAGE_DHCPSERVER,
"previous vm option edition wasn't finished");
else
fVmOptionRead = true;
}
break; /* end of --vm-name */
case 's': // --slot
{
if (!fVmOptionRead)
return errorSyntax(USAGE_DHCPSERVER,
"vm name wasn't specified");
}
break; /* end of --slot */
case 'i': // --id
{
if (!fOptionsRead)
return errorSyntax(USAGE_DHCPSERVER,
"-o wasn't found");
}
break; /* end of --id */
case 'p': // --value
{
if (!fOptionsRead)
return errorSyntax(USAGE_DHCPSERVER,
"-o wasn't found");
return errorSyntax(USAGE_DHCPSERVER,
"--id wasn't found");
if ( fVmOptionRead
return errorSyntax(USAGE_DHCPSERVER,
"--slot wasn't found");
}
break; // --end of value
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");
&& GlobalDhcpOptions.size() == 0
&& VmSlot2Options.size() == 0)
{
{
if(!pIp)
if(!pNetmask)
if(!pLowerIp)
if(!pUpperIp)
}
}
if(!pNetName)
{
}
else
{
}
{
return errorArgument("DHCP server already exists");
return errorArgument("Failed to create the DHCP server");
}
{
return errorArgument("DHCP server does not exist");
}
{
{
return errorArgument("Failed to set configuration");
}
if(enable >= 0)
{
}
/* option processing */
/* Global Options */
++itOpt)
{
}
/* heh, vm slot options. */
++it)
{
++itOpt)
{
}
}
}
else
{
return errorArgument("Failed to remove server");
}
return 0;
}
{
if (a->argc < 1)
int result;
int cProcessed;
else
return result;
}
#endif /* !VBOX_ONLY_DOCS */