iPXE
Data Structures | Functions | Variables
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 More...
 

Variables

static struct option_descriptor lotest_opts []
 "lotest" option list More...
 
static struct command_descriptor lotest_cmd
 "lotest" command descriptor More...
 
struct command lotest_command __command
 Loopback testing commands. More...
 

Detailed Description

Loopback testing commands.

Definition in file lotest_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ lotest_exec()

static 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:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
int optind
Current option index.
Definition: getopt.c:51
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
#define ETH_MAX_MTU
Definition: if_ether.h:14
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
"lotest" options
Definition: lotest_cmd.c:43
static union @423 opts
"cert<xxx>" option list
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:348
struct stp_switch sender
Sender switch.
Definition: stp.h:30
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:132

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

Variable Documentation

◆ lotest_opts

struct option_descriptor lotest_opts[]
static
Initial value:
= {
OPTION_DESC ( "broadcast", 'b', no_argument,
struct lotest_options, broadcast, parse_flag ),
}
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:88
"lotest" options
Definition: lotest_cmd.c:43
int parse_flag(char *text __unused, int *flag)
Parse flag.
Definition: parseopt.c:200
Option does not take an argument.
Definition: getopt.h:16
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition: parseopt.h:66
Option requires an argument.
Definition: getopt.h:18

"lotest" option list

Definition at line 51 of file lotest_cmd.c.

◆ lotest_cmd

struct command_descriptor lotest_cmd
static
Initial value:
=
"<sending interface> <receiving interface>" )
"lotest" options
Definition: lotest_cmd.c:43
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:107

"lotest" command descriptor

Definition at line 59 of file lotest_cmd.c.

Referenced by lotest_exec().

◆ __command

struct command lotest_command __command
Initial value:
= {
.name = "lotest",
.exec = lotest_exec,
}
static int lotest_exec(int argc, char **argv)
"lotest" command
Definition: lotest_cmd.c:70

Loopback testing commands.

Definition at line 103 of file lotest_cmd.c.