mirror of
https://github.com/ipxe/ipxe
synced 2025-12-26 01:22:37 +03:00
[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:
@@ -31,18 +31,21 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** "startpxe" command descriptor */
|
/** "startpxe" options */
|
||||||
static struct command_descriptor startpxe_cmd =
|
struct startpxe_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>]" );
|
/** "startpxe" option list */
|
||||||
|
static struct option_descriptor startpxe_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "startpxe" payload
|
* "startpxe" payload
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int startpxe_payload ( struct net_device *netdev ) {
|
static int startpxe_payload ( struct net_device *netdev,
|
||||||
|
struct startpxe_options *opts __unused ) {
|
||||||
|
|
||||||
if ( netdev_is_open ( netdev ) )
|
if ( netdev_is_open ( netdev ) )
|
||||||
pxe_activate ( netdev );
|
pxe_activate ( netdev );
|
||||||
@@ -50,6 +53,12 @@ static int startpxe_payload ( struct net_device *netdev ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** "startpxe" command descriptor */
|
||||||
|
static struct ifcommon_command_descriptor startpxe_cmd =
|
||||||
|
IFCOMMON_COMMAND_DESC ( struct startpxe_options, startpxe_opts,
|
||||||
|
0, MAX_ARGUMENTS, "[<interface>]",
|
||||||
|
startpxe_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "startpxe" command
|
* The "startpxe" command
|
||||||
*
|
*
|
||||||
@@ -58,7 +67,7 @@ static int startpxe_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int startpxe_exec ( int argc, char **argv ) {
|
static int startpxe_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &startpxe_cmd, startpxe_payload, 0 );
|
return ifcommon_exec ( argc, argv, &startpxe_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "stoppxe" options */
|
/** "stoppxe" options */
|
||||||
|
|||||||
@@ -33,10 +33,29 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** "autoboot" options */
|
||||||
|
struct autoboot_options {};
|
||||||
|
|
||||||
|
/** "autoboot" option list */
|
||||||
|
static struct option_descriptor autoboot_opts[] = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "autoboot" payload
|
||||||
|
*
|
||||||
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
static int autoboot_payload ( struct net_device *netdev,
|
||||||
|
struct autoboot_options *opts __unused ) {
|
||||||
|
return netboot ( netdev );
|
||||||
|
}
|
||||||
|
|
||||||
/** "autoboot" command descriptor */
|
/** "autoboot" command descriptor */
|
||||||
static struct command_descriptor autoboot_cmd =
|
static struct ifcommon_command_descriptor autoboot_cmd =
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
IFCOMMON_COMMAND_DESC ( struct autoboot_options, autoboot_opts,
|
||||||
"[<interface>...]" );
|
0, MAX_ARGUMENTS, "[<interface>...]",
|
||||||
|
autoboot_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "autoboot" command
|
* "autoboot" command
|
||||||
@@ -46,7 +65,7 @@ static struct command_descriptor autoboot_cmd =
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int autoboot_exec ( int argc, char **argv ) {
|
static int autoboot_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &autoboot_cmd, netboot, 0 );
|
return ifcommon_exec ( argc, argv, &autoboot_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Booting commands */
|
/** Booting commands */
|
||||||
|
|||||||
@@ -41,18 +41,21 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** "dhcp" command descriptor */
|
/** "dhcp" options */
|
||||||
static struct command_descriptor dhcp_cmd =
|
struct dhcp_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>...]" );
|
/** "dhcp" option list */
|
||||||
|
static struct option_descriptor dhcp_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute "dhcp" command for a network device
|
* Execute "dhcp" command for a network device
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @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;
|
int rc;
|
||||||
|
|
||||||
if ( ( rc = dhcp ( netdev ) ) != 0 ) {
|
if ( ( rc = dhcp ( netdev ) ) != 0 ) {
|
||||||
@@ -68,6 +71,12 @@ static int dhcp_payload ( struct net_device *netdev ) {
|
|||||||
return 0;
|
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
|
* The "dhcp" command
|
||||||
*
|
*
|
||||||
@@ -76,7 +85,7 @@ static int dhcp_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int dhcp_exec ( int argc, char **argv ) {
|
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 */
|
/** "pxebs" options */
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** "if<xxx>" command options */
|
|
||||||
struct option_descriptor ifcommon_opts[0];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute if<xxx> command
|
* Execute if<xxx> command
|
||||||
*
|
*
|
||||||
@@ -48,16 +45,15 @@ struct option_descriptor ifcommon_opts[0];
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int ifcommon_exec ( int argc, char **argv,
|
int ifcommon_exec ( int argc, char **argv,
|
||||||
struct command_descriptor *cmd,
|
struct ifcommon_command_descriptor *ifcmd ) {
|
||||||
int ( * payload ) ( struct net_device * ),
|
struct command_descriptor *cmd = &ifcmd->cmd;
|
||||||
int stop_on_first_success ) {
|
uint8_t opts[cmd->len];
|
||||||
struct ifcommon_options opts;
|
|
||||||
struct net_device *netdev;
|
struct net_device *netdev;
|
||||||
int i;
|
int i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Parse options */
|
/* Parse options */
|
||||||
if ( ( rc = parse_options ( argc, argv, cmd, &opts ) ) != 0 )
|
if ( ( rc = parse_options ( argc, argv, cmd, opts ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if ( optind != argc ) {
|
if ( optind != argc ) {
|
||||||
@@ -65,8 +61,8 @@ int ifcommon_exec ( int argc, char **argv,
|
|||||||
for ( i = optind ; i < argc ; i++ ) {
|
for ( i = optind ; i < argc ; i++ ) {
|
||||||
if ( ( rc = parse_netdev ( argv[i], &netdev ) ) != 0 )
|
if ( ( rc = parse_netdev ( argv[i], &netdev ) ) != 0 )
|
||||||
continue;
|
continue;
|
||||||
if ( ( ( rc = payload ( netdev ) ) == 0 ) &&
|
if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
|
||||||
stop_on_first_success ) {
|
&& ifcmd->stop_on_first_success ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,8 +70,8 @@ int ifcommon_exec ( int argc, char **argv,
|
|||||||
/* Try all interfaces */
|
/* Try all interfaces */
|
||||||
rc = -ENODEV;
|
rc = -ENODEV;
|
||||||
for_each_netdev ( netdev ) {
|
for_each_netdev ( netdev ) {
|
||||||
if ( ( ( rc = payload ( netdev ) ) == 0 ) &&
|
if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
|
||||||
stop_on_first_success ) {
|
&& ifcmd->stop_on_first_success ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,21 +80,30 @@ int ifcommon_exec ( int argc, char **argv,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "ifopen" command descriptor */
|
/** "ifopen" options */
|
||||||
static struct command_descriptor ifopen_cmd =
|
struct ifopen_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>...]" );
|
/** "ifopen" option list */
|
||||||
|
static struct option_descriptor ifopen_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "ifopen" payload
|
* "ifopen" payload
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ifopen_payload ( struct net_device *netdev ) {
|
static int ifopen_payload ( struct net_device *netdev,
|
||||||
|
struct ifopen_options *opts __unused ) {
|
||||||
return ifopen ( netdev );
|
return ifopen ( netdev );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** "ifopen" command descriptor */
|
||||||
|
static struct ifcommon_command_descriptor ifopen_cmd =
|
||||||
|
IFCOMMON_COMMAND_DESC ( struct ifopen_options, ifopen_opts,
|
||||||
|
0, MAX_ARGUMENTS, "[<interface>...]",
|
||||||
|
ifopen_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "ifopen" command
|
* The "ifopen" command
|
||||||
*
|
*
|
||||||
@@ -107,25 +112,34 @@ static int ifopen_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ifopen_exec ( int argc, char **argv ) {
|
static int ifopen_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &ifopen_cmd, ifopen_payload, 0 );
|
return ifcommon_exec ( argc, argv, &ifopen_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "ifclose" command descriptor */
|
/** "ifclose" options */
|
||||||
static struct command_descriptor ifclose_cmd =
|
struct ifclose_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>...]" );
|
/** "ifclose" option list */
|
||||||
|
static struct option_descriptor ifclose_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "ifclose" payload
|
* "ifclose" payload
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ifclose_payload ( struct net_device *netdev ) {
|
static int ifclose_payload ( struct net_device *netdev,
|
||||||
|
struct ifclose_options *opts __unused ) {
|
||||||
ifclose ( netdev );
|
ifclose ( netdev );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** "ifclose" command descriptor */
|
||||||
|
static struct ifcommon_command_descriptor ifclose_cmd =
|
||||||
|
IFCOMMON_COMMAND_DESC ( struct ifclose_options, ifclose_opts,
|
||||||
|
0, MAX_ARGUMENTS, "[<interface>...]",
|
||||||
|
ifclose_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "ifclose" command
|
* The "ifclose" command
|
||||||
*
|
*
|
||||||
@@ -134,25 +148,34 @@ static int ifclose_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ifclose_exec ( int argc, char **argv ) {
|
static int ifclose_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &ifclose_cmd, ifclose_payload, 0 );
|
return ifcommon_exec ( argc, argv, &ifclose_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "ifstat" command descriptor */
|
/** "ifstat" options */
|
||||||
static struct command_descriptor ifstat_cmd =
|
struct ifstat_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>...]" );
|
/** "ifstat" option list */
|
||||||
|
static struct option_descriptor ifstat_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "ifstat" payload
|
* "ifstat" payload
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ifstat_payload ( struct net_device *netdev ) {
|
static int ifstat_payload ( struct net_device *netdev,
|
||||||
|
struct ifstat_options *opts __unused ) {
|
||||||
ifstat ( netdev );
|
ifstat ( netdev );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** "ifstat" command descriptor */
|
||||||
|
static struct ifcommon_command_descriptor ifstat_cmd =
|
||||||
|
IFCOMMON_COMMAND_DESC ( struct ifstat_options, ifstat_opts,
|
||||||
|
0, MAX_ARGUMENTS, "[<interface>...]",
|
||||||
|
ifstat_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "ifstat" command
|
* The "ifstat" command
|
||||||
*
|
*
|
||||||
@@ -161,7 +184,7 @@ static int ifstat_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int ifstat_exec ( int argc, char **argv ) {
|
static int ifstat_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &ifstat_cmd, ifstat_payload, 0 );
|
return ifcommon_exec ( argc, argv, &ifstat_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Interface management commands */
|
/** Interface management commands */
|
||||||
|
|||||||
@@ -32,18 +32,21 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** "iwstat" command descriptor */
|
/** "iwstat" options */
|
||||||
static struct command_descriptor iwstat_cmd =
|
struct iwstat_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>...]" );
|
/** "iwstat" option list */
|
||||||
|
static struct option_descriptor iwstat_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "iwstat" payload
|
* "iwstat" payload
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int iwstat_payload ( struct net_device *netdev ) {
|
static int iwstat_payload ( struct net_device *netdev,
|
||||||
|
struct iwstat_options *opts __unused ) {
|
||||||
struct net80211_device *dev = net80211_get ( netdev );
|
struct net80211_device *dev = net80211_get ( netdev );
|
||||||
|
|
||||||
if ( dev )
|
if ( dev )
|
||||||
@@ -52,6 +55,12 @@ static int iwstat_payload ( struct net_device *netdev ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** "iwstat" command descriptor */
|
||||||
|
static struct ifcommon_command_descriptor iwstat_cmd =
|
||||||
|
IFCOMMON_COMMAND_DESC ( struct iwstat_options, iwstat_opts,
|
||||||
|
0, MAX_ARGUMENTS, "[<interface>...]",
|
||||||
|
iwstat_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "iwstat" command
|
* The "iwstat" command
|
||||||
*
|
*
|
||||||
@@ -60,21 +69,24 @@ static int iwstat_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int iwstat_exec ( int argc, char **argv ) {
|
static int iwstat_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &iwstat_cmd, iwstat_payload, 0 );
|
return ifcommon_exec ( argc, argv, &iwstat_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "iwlist" command descriptor */
|
/** "iwlist" options */
|
||||||
static struct command_descriptor iwlist_cmd =
|
struct iwlist_options {};
|
||||||
COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
|
|
||||||
"[<interface>...]" );
|
/** "iwlist" option list */
|
||||||
|
static struct option_descriptor iwlist_opts[] = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "iwlist" payload
|
* "iwlist" payload
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int iwlist_payload ( struct net_device *netdev ) {
|
static int iwlist_payload ( struct net_device *netdev,
|
||||||
|
struct iwlist_options *opts __unused ) {
|
||||||
struct net80211_device *dev = net80211_get ( netdev );
|
struct net80211_device *dev = net80211_get ( netdev );
|
||||||
|
|
||||||
if ( dev )
|
if ( dev )
|
||||||
@@ -83,6 +95,12 @@ static int iwlist_payload ( struct net_device *netdev ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** "iwlist" command descriptor */
|
||||||
|
static struct ifcommon_command_descriptor iwlist_cmd =
|
||||||
|
IFCOMMON_COMMAND_DESC ( struct iwlist_options, iwlist_opts,
|
||||||
|
0, MAX_ARGUMENTS, "[<interface>...]",
|
||||||
|
iwlist_payload, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "iwlist" command
|
* The "iwlist" command
|
||||||
*
|
*
|
||||||
@@ -91,7 +109,7 @@ static int iwlist_payload ( struct net_device *netdev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int iwlist_exec ( int argc, char **argv ) {
|
static int iwlist_exec ( int argc, char **argv ) {
|
||||||
return ifcommon_exec ( argc, argv, &iwlist_cmd, iwlist_payload, 0 );
|
return ifcommon_exec ( argc, argv, &iwlist_cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wireless interface management commands */
|
/** Wireless interface management commands */
|
||||||
|
|||||||
@@ -26,13 +26,46 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
|
|
||||||
struct net_device;
|
struct net_device;
|
||||||
|
|
||||||
struct ifcommon_options {};
|
/** An "if<xxx>" command descriptor */
|
||||||
|
struct ifcommon_command_descriptor {
|
||||||
|
/** Command descriptor */
|
||||||
|
struct command_descriptor cmd;
|
||||||
|
/** Payload
|
||||||
|
*
|
||||||
|
* @v netdev Network device
|
||||||
|
* @v opts Command options
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
int ( * payload ) ( struct net_device *netdev, void *opts );
|
||||||
|
/** Stop on first success */
|
||||||
|
int stop_on_first_success;
|
||||||
|
};
|
||||||
|
|
||||||
extern struct option_descriptor ifcommon_opts[0];
|
/**
|
||||||
|
* Construct "if<xxx>" command descriptor
|
||||||
|
*
|
||||||
|
* @v _struct Options structure type
|
||||||
|
* @v _options Option descriptor array
|
||||||
|
* @v _check_args Remaining argument checker
|
||||||
|
* @v _usage Command usage
|
||||||
|
* @ret _command Command descriptor
|
||||||
|
*/
|
||||||
|
#define IFCOMMON_COMMAND_DESC( _struct, _options, _min_args, \
|
||||||
|
_max_args, _usage, _payload, \
|
||||||
|
_stop_on_first_success ) \
|
||||||
|
{ \
|
||||||
|
.cmd = COMMAND_DESC ( _struct, _options, _min_args, \
|
||||||
|
_max_args, _usage ), \
|
||||||
|
.payload = ( ( int ( * ) ( struct net_device *netdev, \
|
||||||
|
void *opts ) ) \
|
||||||
|
( ( ( ( int ( * ) ( struct net_device *, \
|
||||||
|
_struct * ) ) NULL ) \
|
||||||
|
== ( typeof ( _payload ) * ) NULL ) \
|
||||||
|
? _payload : _payload ) ), \
|
||||||
|
.stop_on_first_success = _stop_on_first_success, \
|
||||||
|
}
|
||||||
|
|
||||||
extern int ifcommon_exec ( int argc, char **argv,
|
extern int ifcommon_exec ( int argc, char **argv,
|
||||||
struct command_descriptor *cmd,
|
struct ifcommon_command_descriptor *cmd );
|
||||||
int ( * payload ) ( struct net_device * ),
|
|
||||||
int stop_on_first_success );
|
|
||||||
|
|
||||||
#endif /* _IFMGMT_CMD_H */
|
#endif /* _IFMGMT_CMD_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user