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

Variables

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

Detailed Description

Loopback testing commands.

Definition in file lotest_cmd.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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.

References lotest_options::broadcast, loopback_test(), lotest_options::mtu, optind, parse_netdev(), parse_options(), printf(), rc, sender, and strerror().

                                                 {
        struct lotest_options opts;
        struct net_device *sender;
        struct net_device *receiver;
        int rc;

        /* Parse options */
        if ( ( rc = parse_options ( argc, argv, &lotest_cmd, &opts ) ) != 0 )
                return rc;

        /* Parse sending interface name */
        if ( ( rc = parse_netdev ( argv[optind], &sender ) ) != 0 )
                return rc;

        /* Parse receiving interface name */
        if ( ( rc = parse_netdev ( argv[ optind + 1 ], &receiver ) ) != 0 )
                return rc;

        /* Use default MTU if none specified */
        if ( ! opts.mtu )
                opts.mtu = ETH_MAX_MTU;

        /* Perform loopback test */
        if ( ( rc = loopback_test ( sender, receiver, opts.mtu,
                                    opts.broadcast ) ) != 0 ) {
                printf ( "Test failed: %s\n", strerror ( rc ) );
                return rc;
        }

        return 0;
}

Variable Documentation

struct option_descriptor lotest_opts[] [static]
Initial value:
 {
        OPTION_DESC ( "mtu", 'm', required_argument,
                      struct lotest_options, mtu, parse_integer ),
        OPTION_DESC ( "broadcast", 'b', no_argument,
                      struct lotest_options, broadcast, parse_flag ),
}

"lotest" option list

Definition at line 51 of file lotest_cmd.c.

struct command_descriptor lotest_cmd [static]
Initial value:
        COMMAND_DESC ( struct lotest_options, lotest_opts, 2, 2,
                       "<sending interface> <receiving interface>" )

"lotest" command descriptor

Definition at line 59 of file lotest_cmd.c.

struct command lotest_command __command
Initial value:
 {
        .name = "lotest",
        .exec = lotest_exec,
}

Loopback testing commands.

Definition at line 103 of file lotest_cmd.c.