if( strcmp(argv[1], "route") == 0 )
{
// Add new route
- if( strcmp(argv[2], "add") == 0 )
+ if( argc > 2 && strcmp(argv[2], "add") == 0 )
{
uint8_t dest[16] = {0};
uint8_t nextHop[16] = {0};
int addrType, subnetBits = -1;
int nextHopType, nextHopBits=-1;
- char *ifaceName;
+ char *ifaceName = NULL;
int metric = DEFAULT_METRIC;
// Usage:
// ifconfig route add <host>[/<prefix>] <interface> [<metric>]
return 0;
}
// Delete a route
- else if( strcmp(argv[2], "del") == 0 )
+ else if( argc > 2 && strcmp(argv[2], "del") == 0 )
{
// Usage:
// ifconfig route del <routenum>
dp = open(IPSTACK_ROOT"/routes", OPENFLAG_READ);
+ printf("ID\tType\tNetwork \tGateway \tMetric\tIFace\n");
+
while( readdir(dp, filename) )
{
if(filename[0] == '.') continue;
return ;
}
- printf("%s:\t", Name);
- {
- int call_num = ioctl(fd, 3, "get_interface");
- int len = ioctl(fd, call_num, NULL);
- char *buf = malloc(len+1);
- ioctl(fd, call_num, buf);
- printf("'%s'\t", buf);
- free(buf);
- }
+ // Number
+ printf("%s\t", Name);
// Get the address type
switch(type)
{
uint8_t net[4], addr[4];
int subnet, metric;
- printf("IPv4\n");
+ printf("IPv4\t");
ioctl(fd, ioctl(fd, 3, "get_network"), net); // Get Network
ioctl(fd, ioctl(fd, 3, "get_nexthop"), addr); // Get Gateway/NextHop
subnet = ioctl(fd, ioctl(fd, 3, "getset_subnetbits"), NULL); // Get Subnet Bits
metric = ioctl(fd, ioctl(fd, 3, "getset_metric"), NULL); // Get Subnet Bits
- printf("\tNetwork: %s/%i\n", Net_PrintAddress(4, net), subnet);
- printf("\tGateway: %s\n", Net_PrintAddress(4, addr));
- printf("\tMetric: %i\n", metric);
+ printf("%s/%i\t", Net_PrintAddress(4, net), subnet);
+ printf("%s \t", Net_PrintAddress(4, addr));
+ printf("%i\t", metric);
}
break;
case 6: // IPv6
{
uint16_t net[8], addr[8];
int subnet, metric;
- printf("IPv6\n");
+ printf("IPv6\t");
ioctl(fd, ioctl(fd, 3, "get_network"), net); // Get Network
ioctl(fd, ioctl(fd, 3, "get_nexthop"), addr); // Get Gateway/NextHop
subnet = ioctl(fd, ioctl(fd, 3, "getset_subnetbits"), NULL); // Get Subnet Bits
metric = ioctl(fd, ioctl(fd, 3, "getset_metric"), NULL); // Get Subnet Bits
- printf("\tNetwork: %s/%i\n", Net_PrintAddress(6, net), subnet);
- printf("\tGateway: %s\n", Net_PrintAddress(6, addr));
- printf("\tMetric: %i\n", metric);
+ printf("%s/%i\t", Net_PrintAddress(6, net), subnet);
+ printf("%s\t", Net_PrintAddress(6, addr));
+ printf("%i\t", metric);
}
break;
default: // Unknow
printf("UNKNOWN (%i)\n", type);
break;
}
+
+ // Interface
+ {
+ int call_num = ioctl(fd, 3, "get_interface");
+ int len = ioctl(fd, call_num, NULL);
+ char *buf = malloc(len+1);
+ ioctl(fd, call_num, buf);
+ printf("'%s'\t", buf);
+ free(buf);
+ }
+
printf("\n");
close(fd);
\r
memset(&srv, 0, sizeof(srv));\r
\r
+ // Parse Command line\r
+ // - Sets the server configuration globals\r
if( (tmp = ParseArguments(argc, argv)) ) {\r
return tmp;\r
}\r
\r
+ // Connect to the remove server\r
srv.FD = OpenTCP( gsRemoteAddress, giRemotePort );\r
if( srv.FD == -1 ) {\r
fprintf(stderr, "Unable to create socket\n");\r
}\r
\r
// Set remote port and address\r
- printf("Setting port and remote address");\r
+ printf("Setting port and remote address\n");\r
ioctl(fd, 5, &PortNumber);\r
ioctl(fd, 6, addrBuffer);\r
\r
// Connect\r
- printf("Initiating connection");\r
+ printf("Initiating connection\n");\r
if( ioctl(fd, 7, NULL) == 0 ) {\r
// Shouldn't happen :(\r
fprintf(stderr, "Unable to start connection\n");\r