2 * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA
20 FILE_LICENCE ( GPL2_OR_LATER );
26 #include <ipxe/netdevice.h>
27 #include <ipxe/command.h>
28 #include <ipxe/parseopt.h>
29 #include <ipxe/if_ether.h>
30 #include <usr/lotest.h>
34 * Loopback testing commands
38 /** "lotest" options */
39 struct lotest_options {
44 /** "lotest" option list */
45 static struct option_descriptor lotest_opts[] = {
46 OPTION_DESC ( "mtu", 'm', required_argument,
47 struct lotest_options, mtu, parse_integer ),
50 /** "lotest" command descriptor */
51 static struct command_descriptor lotest_cmd =
52 COMMAND_DESC ( struct lotest_options, lotest_opts, 2, 2,
53 "<sending interface> <receiving interface>" );
58 * @v argc Argument count
59 * @v argv Argument list
60 * @ret rc Return status code
62 static int lotest_exec ( int argc, char **argv ) {
63 struct lotest_options opts;
64 struct net_device *sender;
65 struct net_device *receiver;
69 if ( ( rc = parse_options ( argc, argv, &lotest_cmd, &opts ) ) != 0 )
72 /* Parse sending interface name */
73 if ( ( rc = parse_netdev ( argv[optind], &sender ) ) != 0 )
76 /* Parse receiving interface name */
77 if ( ( rc = parse_netdev ( argv[ optind + 1 ], &receiver ) ) != 0 )
80 /* Use default MTU if none specified */
82 opts.mtu = ETH_MAX_MTU;
84 /* Perform loopback test */
85 if ( ( rc = loopback_test ( sender, receiver, opts.mtu ) ) != 0 ) {
86 printf ( "Test failed: %s\n", strerror ( rc ) );
93 /** Loopback testing commands */
94 struct command lotest_command __command = {