iPXE
Data Structures | Macros | 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...
 

Macros

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

Functions

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

Macro Definition Documentation

◆ IFCOMMON_COMMAND_DESC

#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, \
}
static union @424 opts
"cert<xxx>" option list
static struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:352
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ifcommon_exec()

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.

52  {
53  struct command_descriptor *cmd = &ifcmd->cmd;
54  uint8_t opts[cmd->len];
55  struct net_device *netdev;
56  int i;
57  int rc;
58 
59  /* Parse options */
60  if ( ( rc = parse_options ( argc, argv, cmd, opts ) ) != 0 )
61  return rc;
62 
63  if ( optind != argc ) {
64  /* Treat arguments as a list of interfaces to try */
65  for ( i = optind ; i < argc ; i++ ) {
66  if ( ( rc = parse_netdev ( argv[i], &netdev ) ) != 0 )
67  continue;
68  if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
69  && ifcmd->stop_on_first_success ) {
70  return 0;
71  }
72  }
73  } else {
74  /* Try all interfaces */
75  rc = -ENODEV;
77  if ( ( ( rc = ifcmd->payload ( netdev, opts ) ) == 0 )
78  && ifcmd->stop_on_first_success ) {
79  return 0;
80  }
81  }
82  }
83 
84  return rc;
85 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int optind
Current option index.
Definition: getopt.c:51
static union @424 opts
"cert<xxx>" option list
int(* payload)(struct net_device *netdev, void *opts)
Payload.
Definition: ifmgmt_cmd.h:43
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
A command descriptor.
Definition: parseopt.h:76
static struct net_device * netdev
Definition: gdbudp.c:52
#define for_each_netdev(netdev)
Iterate over all network devices.
Definition: netdevice.h:532
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
unsigned char uint8_t
Definition: stdint.h:10
int stop_on_first_success
Stop on first success.
Definition: ifmgmt_cmd.h:45
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct command_descriptor cmd
Command descriptor.
Definition: ifmgmt_cmd.h:36
int parse_netdev(char *text, struct net_device **netdev)
Parse network device name.
Definition: parseopt.c:132

References cmd, ifcommon_command_descriptor::cmd, ENODEV, for_each_netdev, 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().

◆ ifconf_exec()

int ifconf_exec ( int  argc,
char **  argv 
)

The "ifconf" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 249 of file ifmgmt_cmd.c.

249  {
250  return ifcommon_exec ( argc, argv, &ifconf_cmd );
251 }
static struct ifcommon_command_descriptor ifconf_cmd
"ifconf" command descriptor
Definition: ifmgmt_cmd.c:237
int ifcommon_exec(int argc, char **argv, struct ifcommon_command_descriptor *ifcmd)
Execute if<xxx> command.
Definition: ifmgmt_cmd.c:51

References ifcommon_exec(), and ifconf_cmd.