#include <getopt.h>
#include <assert.h>
+#include <gpxe/ip.h>
#include <gpxe/tcp.h>
#include <gpxe/hello.h>
struct tester_options {
char interface[IF_NAMESIZE];
+ struct in_addr in_addr;
};
static void usage ( char **argv ) {
"Global options:\n"
" -h|--help Print this help message\n"
" -i|--interface intf Use specified network interface\n"
+ " -f|--from ip-address Use specified local IP address\n"
" -l|--list List available tests\n"
"\n"
"Use \"%s <test> -h\" to view test-specific options\n",
struct tester_options *options ) {
static struct option long_options[] = {
{ "interface", 1, NULL, 'i' },
+ { "from", 1, NULL, 'f' },
{ "list", 0, NULL, 'l' },
{ "help", 0, NULL, 'h' },
{ },
/* Set default options */
memset ( options, 0, sizeof ( *options ) );
strncpy ( options->interface, "eth0", sizeof ( options->interface ) );
+ inet_aton ( "192.168.0.2", &options->in_addr );
/* Parse command-line options */
while ( 1 ) {
int option_index = 0;
- c = getopt_long ( argc, argv, "+i:hl", long_options,
+ c = getopt_long ( argc, argv, "+i:f:hl", long_options,
&option_index );
if ( c < 0 )
break;
strncpy ( options->interface, optarg,
sizeof ( options->interface ) );
break;
+ case 'f':
+ if ( inet_aton ( optarg, &options->in_addr ) == 0 ) {
+ fprintf ( stderr, "Invalid IP address %s\n",
+ optarg );
+ return -1;
+ }
+ break;
case 'l':
list_tests ();
return -1;
/* Initialise the protocol stack */
init_tcpip();
+ set_ipaddr ( options.in_addr );
/* Open the hijack device */
hijack_dev.name = options.interface;