X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Fifconfig_src%2Fmain.c;h=3a45530497d58820574408f09b695d3f3cdbcc4c;hb=92517b68b7582251f69db7e062d5e5a4c773791f;hp=7a7fd07a8d89a26f292440c91c69625cf7e159da;hpb=2bdb445efbe8a5440c5ed27acfccd32626bd67e7;p=tpg%2Facess2.git diff --git a/Usermode/Applications/ifconfig_src/main.c b/Usermode/Applications/ifconfig_src/main.c index 7a7fd07a..3a455304 100644 --- a/Usermode/Applications/ifconfig_src/main.c +++ b/Usermode/Applications/ifconfig_src/main.c @@ -174,9 +174,10 @@ void DumpInterface(const char *Name) int len = ioctl(fd, call_num, NULL); char *buf = malloc(len+1); ioctl(fd, call_num, buf); - printf("'%s'\t", buf); + printf("'%s'\n", buf); free(buf); } + printf("\t"); // Get the address type switch(type) { @@ -187,20 +188,20 @@ void DumpInterface(const char *Name) { uint8_t ip[4]; int subnet; - printf("IPv4\n"); + printf("IPv4\t"); ioctl(fd, 5, ip); // Get IP Address subnet = ioctl(fd, 7, NULL); // Get Subnet Bits - printf("\tAddress: %i.%i.%i.%i/%i\n", ip[0], ip[1], ip[2], ip[3], subnet); + printf("%i.%i.%i.%i/%i\n", ip[0], ip[1], ip[2], ip[3], subnet); } break; case 6: // IPv6 { uint16_t ip[8]; int subnet; - printf("IPv6\n"); + printf("IPv6\t"); ioctl(fd, 5, ip); // Get IP Address subnet = ioctl(fd, 7, NULL); // Get Subnet Bits - printf("\t%x:%x:%x:%x:%x:%x:%x:%x/%i\n", + printf("%x:%x:%x:%x:%x:%x:%x:%x/%i\n", ntohs(ip[0]), ntohs(ip[1]), ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]), ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7]), subnet); @@ -210,7 +211,6 @@ void DumpInterface(const char *Name) printf("UNKNOWN (%i)\n", type); break; } - printf("\n"); close(fd); } @@ -223,7 +223,7 @@ void DumpRoute(const char *Name) { int fd; int type; - char path[sizeof(IPSTACK_ROOT)+7+FILENAME_MAX+1] = IPSTACK_ROOT"/route/"; + char path[sizeof(IPSTACK_ROOT)+8+FILENAME_MAX+1] = IPSTACK_ROOT"/routes/"; strcat(path, Name); @@ -346,10 +346,10 @@ void AddRoute(const char *Interface, void *Dest, int MaskBits, void *NextHop) int DoAutoConfig(const char *Device) { int tmp, fd; - char path[sizeof(IPSTACK_ROOT)+5+1]; // ip000 + char path[sizeof(IPSTACK_ROOT)+1+4+1]; // /0000 uint8_t addr[4] = {10,0,2,55}; - uint8_t gw[4] = {10,0,2,1}; - int subnet = 8; + uint8_t gw[4] = {10,0,2,2}; + int subnet = 24; tmp = AddInterface(Device); if( tmp < 0 ) return tmp; @@ -373,10 +373,11 @@ int DoAutoConfig(const char *Device) // Set Subnet ioctl(fd, ioctl(fd, 3, "getset_subnet"), &subnet); - // Set Gateway + // Set routes { uint8_t net[4] = {0,0,0,0}; - AddRoute(path + sizeof(IPSTACK_ROOT) + 1, net, 0, gw); + AddRoute(path + sizeof(IPSTACK_ROOT), addr, subnet, net); // This interface + AddRoute(path + sizeof(IPSTACK_ROOT), net, 0, gw); // Gateway } close(fd);