X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Fifconfig_src%2Fmain.c;h=ba788383db2076a3d89ccd5a6f4cf47ce7f31cbd;hb=775bf8013abe9fe4ef3d4883ea2e43bba2a84da1;hp=47798a83b89f44cef5318595952676d7b998debc;hpb=f035491c949cb86d92a93fc3d9d033538704256b;p=tpg%2Facess2.git diff --git a/Usermode/Applications/ifconfig_src/main.c b/Usermode/Applications/ifconfig_src/main.c index 47798a83..ba788383 100644 --- a/Usermode/Applications/ifconfig_src/main.c +++ b/Usermode/Applications/ifconfig_src/main.c @@ -61,7 +61,6 @@ void DumpInterfaces(int DumpAll) while( readdir(dp, filename) ) { if(filename[0] == '.') continue; - if(filename[0] != 'i' || filename[1] != 'p') continue; fd = open(path, OPENFLAG_READ); if(fd == -1) { @@ -71,6 +70,13 @@ void DumpInterfaces(int DumpAll) type = ioctl(fd, 4, NULL); printf("%s:\t", filename); + { + int len = ioctl(fd, ioctl(fd, 3, "get_device"), NULL); + char *buf = malloc(len+1); + ioctl(fd, ioctl(fd, 3, "get_device"), buf); + printf("'%s'\t", buf); + free(buf); + } switch(type) { case 0: @@ -126,7 +132,7 @@ int AddInterface( char *Device ) return -1; } - printf("-- Added '"IPSTACK_ROOT"/ip%i' using device %s\n", ret, Device); + printf("-- Added '"IPSTACK_ROOT"/%i' using device %s\n", ret, Device); return ret; } @@ -135,13 +141,14 @@ int DoAutoConfig( char *Device ) { int tmp, fd; char path[sizeof(IPSTACK_ROOT)+5+1]; // ip000 - uint8_t addr[4] = {192,168,1,39}; - uint8_t gw[4] = {192,168,1,1}; + uint8_t addr[4] = {10,0,2,55}; + uint8_t gw[4] = {10,0,2,1}; + int subnet = 8; tmp = AddInterface(Device); if( tmp < 0 ) return tmp; - sprintf(path, IPSTACK_ROOT"/ip%i", tmp); + sprintf(path, IPSTACK_ROOT"/%i", tmp); fd = open(path, OPENFLAG_READ); if( fd == -1 ) { @@ -158,14 +165,16 @@ int DoAutoConfig( char *Device ) // Set Address ioctl(fd, ioctl(fd, 3, "set_address"), addr); // Set Subnet - tmp = 24; - ioctl(fd, ioctl(fd, 3, "getset_subnet"), &tmp); + ioctl(fd, ioctl(fd, 3, "getset_subnet"), &subnet); // Set Gateway ioctl(fd, ioctl(fd, 3, "set_gateway"), gw); close(fd); - printf("Set address to 192.168.1.39/24 (GW: 192.168.1.1)\n"); + printf("Set address to %i.%i.%i.%i/%i (GW: %i.%i.%i.%i)\n", + addr[0], addr[1], addr[2], addr[3], + subnet, + gw[0], gw[1], gw[2], gw[3]); return 0; }