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)
 
 FILE_SECBOOT (PERMITTED)
 
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 struct net_device * netdev
Definition: gdbudp.c:52
A network device.
Definition: netdevice.h:353
static union @447 opts
"cert<xxx>" option list
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:48
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

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 58 of file ifmgmt_cmd.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 52 of file ifmgmt_cmd.c.

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

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(), iflinkwait_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 250 of file ifmgmt_cmd.c.

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

References ifcommon_exec(), and ifconf_cmd.