Annotation of qemu/roms/ipxe/src/hci/commands/lotest_cmd.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (C) 2010 Michael Brown <[email protected]>.
        !             3:  *
        !             4:  * This program is free software; you can redistribute it and/or
        !             5:  * modify it under the terms of the GNU General Public License as
        !             6:  * published by the Free Software Foundation; either version 2 of the
        !             7:  * License, or any later version.
        !             8:  *
        !             9:  * This program is distributed in the hope that it will be useful, but
        !            10:  * WITHOUT ANY WARRANTY; without even the implied warranty of
        !            11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            12:  * General Public License for more details.
        !            13:  *
        !            14:  * You should have received a copy of the GNU General Public License
        !            15:  * along with this program; if not, write to the Free Software
        !            16:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
        !            17:  */
        !            18: 
        !            19: FILE_LICENCE ( GPL2_OR_LATER );
        !            20: 
        !            21: #include <stdio.h>
        !            22: #include <stdlib.h>
        !            23: #include <string.h>
        !            24: #include <getopt.h>
        !            25: #include <ipxe/netdevice.h>
        !            26: #include <ipxe/command.h>
        !            27: #include <ipxe/parseopt.h>
        !            28: #include <ipxe/if_ether.h>
        !            29: #include <usr/lotest.h>
        !            30: 
        !            31: /** @file
        !            32:  *
        !            33:  * Loopback testing commands
        !            34:  *
        !            35:  */
        !            36: 
        !            37: /** "lotest" options */
        !            38: struct lotest_options {
        !            39:        /** MTU */
        !            40:        unsigned int mtu;
        !            41: };
        !            42: 
        !            43: /** "lotest" option list */
        !            44: static struct option_descriptor lotest_opts[] = {
        !            45:        OPTION_DESC ( "mtu", 'm', required_argument,
        !            46:                      struct lotest_options, mtu, parse_integer ),
        !            47: };
        !            48: 
        !            49: /** "lotest" command descriptor */
        !            50: static struct command_descriptor lotest_cmd =
        !            51:        COMMAND_DESC ( struct lotest_options, lotest_opts, 2, 2,
        !            52:                       "[--mtu <mtu>] <sending interface> "
        !            53:                       "<receiving interface>" );
        !            54: 
        !            55: /**
        !            56:  * "lotest" command
        !            57:  *
        !            58:  * @v argc             Argument count
        !            59:  * @v argv             Argument list
        !            60:  * @ret rc             Return status code
        !            61:  */
        !            62: static int lotest_exec ( int argc, char **argv ) {
        !            63:        struct lotest_options opts;
        !            64:        struct net_device *sender;
        !            65:        struct net_device *receiver;
        !            66:        int rc;
        !            67: 
        !            68:        /* Parse options */
        !            69:        if ( ( rc = parse_options ( argc, argv, &lotest_cmd, &opts ) ) != 0 )
        !            70:                return rc;
        !            71: 
        !            72:        /* Parse sending interface name */
        !            73:        if ( ( rc = parse_netdev ( argv[optind], &sender ) ) != 0 )
        !            74:                return rc;
        !            75: 
        !            76:        /* Parse receiving interface name */
        !            77:        if ( ( rc = parse_netdev ( argv[ optind + 1 ], &receiver ) ) != 0 )
        !            78:                return rc;
        !            79: 
        !            80:        /* Use default MTU if none specified */
        !            81:        if ( ! opts.mtu )
        !            82:                opts.mtu = ETH_MAX_MTU;
        !            83: 
        !            84:        /* Perform loopback test */
        !            85:        if ( ( rc = loopback_test ( sender, receiver, opts.mtu ) ) != 0 ) {
        !            86:                printf ( "Test failed: %s\n", strerror ( rc ) );
        !            87:                return rc;
        !            88:        }
        !            89: 
        !            90:        return 0;
        !            91: }
        !            92: 
        !            93: /** Loopback testing commands */
        !            94: struct command lotest_command __command = {
        !            95:        .name = "lotest",
        !            96:        .exec = lotest_exec,
        !            97: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.