12 #define IPSTACK_ROOT "/Devices/ip"
15 void PrintUsage(char *ProgName);
16 void PrintHelp(char *ProgName);
19 int giNumberOfPings = 1;
23 * \fn int main(int argc, char *argv[])
26 int main(int argc, char *argv[])
36 for(i = 1; i < argc; i++)
52 char *arg = &argv[i][2];
53 if(strcmp(arg, "help") == 0) {
59 for( j = 1; argv[i][j]; j++ )
77 type = Net_ParseAddress(ipStr, addr);
79 fprintf(stderr, "Invalid IP Address\n");
85 char *_iface = malloc( sizeof("/Devices/ip/") + strlen(iface) + 1 );
86 strcpy(_iface, "/Devices/ip/");
87 strcat(_iface, iface);
88 free(iface); // TODO: Handle when this is not heap
90 printf("iface = '%s'\n", iface);
91 fd = open(iface, OPENFLAG_EXEC);
93 fprintf(stderr, "ERROR: Unable to open interface '%s'\n", iface);
100 fd = Net_OpenSocket(type, addr, NULL);
102 fprintf(stderr, "Unable to find a route to '%s'\n",
103 Net_PrintAddress(type, addr)
109 call = ioctl(fd, 3, "ping");
111 fprintf(stderr, "ERROR: '%s' does not have a 'ping' call\n", iface);
115 for( i = 0; i < giNumberOfPings; i ++ )
117 ping = ioctl(fd, call, addr);
118 printf("ping = %i\n", ping);
126 void PrintUsage(char *ProgName)
128 fprintf(stderr, "Usage: %s <address> [<interface>]\n", ProgName);
131 void PrintHelp(char *ProgName)
133 PrintUsage(ProgName);
134 fprintf(stderr, " -h\tPrint this message\n");