2 * Acess2 Networking Test Suite (NetTest)
3 * - By John Hodge (thePowersGang)
9 #include <acess_logging.h>
15 extern int VFS_Init(void);
16 extern int IPStack_Install(char **Args);
19 void PrintUsage(const char *ProgramName)
21 fprintf(stderr, "Usage: %s <commands...>\n", ProgramName);
22 fprintf(stderr, "\n");
25 "-dev <mac>:<type>:<arg>\n"
26 "-ip <dev>,<addr>/<mask>\n"
27 "-route <net>/<mask>,<nexthop>\n"
30 "netcat <addr> <port>\n"
33 "tun - Linux TUN/TAP device (takes an optional name)\n"
34 "unix - Unix named pipe (datagram)\n"
38 int main(int argc, char *argv[])
52 char *ipstack_args[] = {NULL};
53 IPStack_Install( ipstack_args );
56 for( int i = 1; i < argc; i ++ )
61 if( strcmp(arg, "netcat") == 0 )
64 Log_Error("NetTest", "'netcat' <addr> <port>");
69 NetTest_Suite_Netcat(argv[i+1], strtol(argv[i+2], NULL, 0));
72 else if( strcmp(arg, "cmdline") == 0 )
74 NetTest_Suite_Cmdline();
78 Log_Error("NetTest", "Unknown suite name '%s'", arg);
84 if( strcmp(arg, "--help") == 0 )
89 else if( strcmp(arg, "-dev") == 0 )
91 if( i+1 == argc ) { PrintUsage(argv[0]); return 1; }
92 rv = NativeNic_AddDev(argv[i+1]);
94 Log_Error("NetTest", "Failed to add device %s", argv[i+1]);
99 else if( strcmp(arg, "-ip") == 0 )
101 if( i+1 == argc ) { PrintUsage(argv[0]); return 1; }
102 // Parse argument and poke ipstack
103 if( NetTest_AddAddress(argv[i+1]) ) {
110 Log_Error("NetTest", "Unknown argument '%s'", arg);
118 Log_Log("NetTest", "Shutting down");
123 size_t NetTest_WriteStdout(const void *Data, size_t Size)
125 return fwrite(Data, 1, Size, stdout);