iPXE
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.

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.
int ifconf_exec (int argc, char **argv)
 The "ifconf" command.

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

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

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 golan_eqe_cmd cmd
Definition CIB_PRM.h:1
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned char uint8_t
Definition stdint.h:10
int optind
Current option index.
Definition getopt.c:52
#define ENODEV
No such device.
Definition errno.h:510
#define for_each_netdev(netdev)
Iterate over all network devices.
Definition netdevice.h:547
int parse_netdev(char *text, struct net_device **netdev)
Parse network device name.
Definition parseopt.c:159
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
int(* payload)(struct net_device *netdev, void *opts)
Payload.
Definition ifmgmt_cmd.h:44
struct command_descriptor cmd
Command descriptor.
Definition ifmgmt_cmd.h:37
int stop_on_first_success
Stop on first success.
Definition ifmgmt_cmd.h:46

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

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}
int ifcommon_exec(int argc, char **argv, struct ifcommon_command_descriptor *ifcmd)
Execute if<xxx> command.
Definition ifmgmt_cmd.c:52
static struct ifcommon_command_descriptor ifconf_cmd
"ifconf" command descriptor
Definition ifmgmt_cmd.c:238

References ifcommon_exec(), and ifconf_cmd.

Referenced by COMMAND(), and COMMAND().