[cmdline] Allow "if<xxx>" commands to take options

Allow commands implemented using ifcommon_exec() to accept
command-specific options.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2013-11-05 17:15:24 +00:00
parent 16d37102ca
commit 55e85ad1ee
6 changed files with 174 additions and 63 deletions
+15 -6
View File
@@ -41,18 +41,21 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
*/
/** "dhcp" command descriptor */
static struct command_descriptor dhcp_cmd =
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
"[<interface>...]" );
/** "dhcp" options */
struct dhcp_options {};
/** "dhcp" option list */
static struct option_descriptor dhcp_opts[] = {};
/**
* Execute "dhcp" command for a network device
*
* @v netdev Network device
* @v opts Command options
* @ret rc Return status code
*/
static int dhcp_payload ( struct net_device *netdev ) {
static int dhcp_payload ( struct net_device *netdev,
struct dhcp_options *opts __unused ) {
int rc;
if ( ( rc = dhcp ( netdev ) ) != 0 ) {
@@ -68,6 +71,12 @@ static int dhcp_payload ( struct net_device *netdev ) {
return 0;
}
/** "dhcp" command descriptor */
static struct ifcommon_command_descriptor dhcp_cmd =
IFCOMMON_COMMAND_DESC ( struct dhcp_options, dhcp_opts,
0, MAX_ARGUMENTS, "[<interface>...]",
dhcp_payload, 1 );
/**
* The "dhcp" command
*
@@ -76,7 +85,7 @@ static int dhcp_payload ( struct net_device *netdev ) {
* @ret rc Return status code
*/
static int dhcp_exec ( int argc, char **argv ) {
return ifcommon_exec ( argc, argv, &dhcp_cmd, dhcp_payload, 1 );
return ifcommon_exec ( argc, argv, &dhcp_cmd );
}
/** "pxebs" options */