iPXE
lotest_cmd.c File Reference

Loopback testing commands. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <ipxe/netdevice.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/if_ether.h>
#include <usr/lotest.h>

Go to the source code of this file.

Data Structures

struct  lotest_options
 "lotest" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int lotest_exec (int argc, char **argv)
 "lotest" command
 COMMAND (lotest, lotest_exec)
 Loopback testing commands.

Variables

static struct option_descriptor lotest_opts []
 "lotest" option list
static struct command_descriptor lotest_cmd
 "lotest" command descriptor

Detailed Description

Loopback testing commands.

Definition in file lotest_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ lotest_exec()

int lotest_exec ( int argc,
char ** argv )
static

"lotest" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 70 of file lotest_cmd.c.

70 {
71 struct lotest_options opts;
72 struct net_device *sender;
73 struct net_device *receiver;
74 int rc;
75
76 /* Parse options */
77 if ( ( rc = parse_options ( argc, argv, &lotest_cmd, &opts ) ) != 0 )
78 return rc;
79
80 /* Parse sending interface name */
81 if ( ( rc = parse_netdev ( argv[optind], &sender ) ) != 0 )
82 return rc;
83
84 /* Parse receiving interface name */
85 if ( ( rc = parse_netdev ( argv[ optind + 1 ], &receiver ) ) != 0 )
86 return rc;
87
88 /* Use default MTU if none specified */
89 if ( ! opts.mtu )
90 opts.mtu = ETH_MAX_MTU;
91
92 /* Perform loopback test */
93 if ( ( rc = loopback_test ( sender, receiver, opts.mtu,
94 opts.broadcast ) ) != 0 ) {
95 printf ( "Test failed: %s\n", strerror ( rc ) );
96 return rc;
97 }
98
99 return 0;
100}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
int optind
Current option index.
Definition getopt.c:52
#define ETH_MAX_MTU
Definition if_ether.h:15
int loopback_test(struct net_device *sender, struct net_device *receiver, size_t mtu, int broadcast)
Perform loopback test between two network devices.
Definition lotest.c:194
static struct command_descriptor lotest_cmd
"lotest" command descriptor
Definition lotest_cmd.c:59
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
struct stp_switch sender
Sender switch.
Definition stp.h:19
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
"lotest" options
Definition lotest_cmd.c:43
A network device.
Definition netdevice.h:353
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References ETH_MAX_MTU, loopback_test(), lotest_cmd, optind, opts, parse_netdev(), parse_options(), printf(), rc, sender, and strerror().

Referenced by COMMAND().

◆ COMMAND()

COMMAND ( lotest ,
lotest_exec  )

Loopback testing commands.

References lotest_exec().

Variable Documentation

◆ lotest_opts

struct option_descriptor lotest_opts[]
static
Initial value:
= {
OPTION_DESC ( "broadcast", 'b', no_argument,
struct lotest_options, broadcast, parse_flag ),
}
uint32_t mtu
Maximum MTU.
Definition ena.h:17
@ required_argument
Option requires an argument.
Definition getopt.h:19
@ no_argument
Option does not take an argument.
Definition getopt.h:17
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition parseopt.c:227
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition parseopt.c:92
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition parseopt.h:68

"lotest" option list

Definition at line 51 of file lotest_cmd.c.

51 {
52 OPTION_DESC ( "mtu", 'm', required_argument,
54 OPTION_DESC ( "broadcast", 'b', no_argument,
55 struct lotest_options, broadcast, parse_flag ),
56};

◆ lotest_cmd

struct command_descriptor lotest_cmd
static
Initial value:
=
"<sending interface> <receiving interface>" )
static struct option_descriptor lotest_opts[]
"lotest" option list
Definition lotest_cmd.c:51
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109

"lotest" command descriptor

Definition at line 59 of file lotest_cmd.c.

Referenced by lotest_exec(), and PROVIDE_REQUIRING_SYMBOL().