+
+ close(fd);
+}
+
+
+/**
+ * \brief Dump a route
+ */
+void DumpRoute(const char *Name)
+{
+ int fd;
+ int type;
+ char path[sizeof(IPSTACK_ROOT)+8+FILENAME_MAX+1] = IPSTACK_ROOT"/routes/";
+
+ strcat(path, Name);
+
+ fd = open(path, OPENFLAG_READ);
+ if(fd == -1) {
+ printf("%s:\tUnable to open ('%s')\n", Name, path);
+ return ;
+ }
+
+ type = ioctl(fd, 4, NULL);
+
+ // Ignore -1 values
+ if( type == -1 ) {
+ return ;
+ }
+
+ // Number
+ printf("%s\t", Name);
+
+ // Get the address type
+ switch(type)
+ {
+ case 0: // Disabled/Unset
+ printf("DISABLED\n");
+ break;
+ case 4: // IPv4
+ {
+ uint8_t net[4], addr[4];
+ int subnet, metric;
+ 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("%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\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("%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);
+ }
+