iPXE
Data Structures | Defines | Functions
ifmgmt_cmd.h File Reference
#include <ipxe/parseopt.h>

Go to the source code of this file.

Data Structures

struct  ifcommon_command_descriptor
 An "if<xxx>" command descriptor. More...

Defines

#define IFCOMMON_COMMAND_DESC(_struct, _options, _min_args,_max_args, _usage, _payload,_stop_on_first_success)
 Construct "if<xxx>" command descriptor.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int ifcommon_exec (int argc, char **argv, struct ifcommon_command_descriptor *cmd)
 Execute if<xxx> command.
int ifconf_exec (int argc, char **argv)
 The "ifconf" command.

Define Documentation

#define IFCOMMON_COMMAND_DESC (   _struct,
  _options,
  _min_args,
  _max_args,
  _usage,
  _payload,
  _stop_on_first_success 
)
Value:
{                                                               \
                .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,        \
        }

Construct "if<xxx>" command descriptor.

Parameters:
_structOptions structure type
_optionsOption descriptor array
_check_argsRemaining argument checker
_usageCommand usage
Return values:
_commandCommand descriptor

Definition at line 57 of file ifmgmt_cmd.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
int ifcommon_exec ( int  argc,
char **  argv,
struct ifcommon_command_descriptor ifcmd 
)

Execute if<xxx> command.

Parameters:
argcArgument count
argvArgument list
cmdCommand descriptor
payloadCommand to execute
verbVerb describing the action of the command
Return values:
rcReturn status code

Definition at line 51 of file ifmgmt_cmd.c.

References ifcommon_command_descriptor::cmd, cmd, ENODEV, for_each_netdev, command_descriptor::len, netdev, optind, opts, parse_netdev(), parse_options(), ifcommon_command_descriptor::payload, rc, and ifcommon_command_descriptor::stop_on_first_success.

Referenced by autoboot_exec(), ifclose_exec(), ifconf_exec(), ifopen_exec(), ifstat_exec(), iwlist_exec(), iwstat_exec(), and startpxe_exec().

                                                                {
        struct command_descriptor *cmd = &ifcmd->cmd;
        uint8_t opts[cmd->len];
        struct net_device *netdev;
        int i;
        int rc;

        /* Parse options */
        if ( ( rc = parse_options ( argc, argv, cmd, opts ) ) != 0 )
                return rc;

        if ( optind != argc ) {
                /* Treat arguments as a list of interfaces to try */
                for ( i = optind ; i < argc ; i++ ) {
                        if ( ( rc = parse_netdev ( argv[i], &netdev ) ) != 0 )
                                continue;
                        if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
                             && ifcmd->stop_on_first_success ) {
                                return 0;
                        }
                }
        } else {
                /* Try all interfaces */
                rc = -ENODEV;
                for_each_netdev ( netdev ) {
                        if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
                             && ifcmd->stop_on_first_success ) {
                                return 0;
                        }
                }
        }

        return rc;
}
int ifconf_exec ( int  argc,
char **  argv 
)

The "ifconf" command.

Parameters:
argcArgument count
argvArgument list
Return values:
rcReturn status code

Definition at line 243 of file ifmgmt_cmd.c.

References ifcommon_exec().

                                          {
        return ifcommon_exec ( argc, argv, &ifconf_cmd );
}