X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Fping_src%2Fmain.c;h=7c10e57be93477f9cc034cd0bdf94d722d025000;hb=be5123fe1f4aa66b76ce8ef589362ad21b6bbf72;hp=4be3306c6149bf155a4fcab051fc486bcf1baad6;hpb=f4e3c3d24ca880fe72396b2b0fc1ca3ce506b6ff;p=tpg%2Facess2.git diff --git a/Usermode/Applications/ping_src/main.c b/Usermode/Applications/ping_src/main.c index 4be3306c..7c10e57b 100644 --- a/Usermode/Applications/ping_src/main.c +++ b/Usermode/Applications/ping_src/main.c @@ -1,5 +1,5 @@ /* - * Acess2 IFCONFIG command + * Acess2 ping command */ #include #include @@ -80,19 +80,7 @@ int main(int argc, char *argv[]) return 1; } - if( !iface ) - { - iface = Net_GetInterface(type, addr); - if( !iface ) { - fprintf(stderr, "Unable to find a route to '%s'\n", - Net_PrintAddress(type, addr) - ); - return -1; - } - - printf("iface = '%s'\n", iface); - } - + if( iface ) { char *_iface = malloc( sizeof("/Devices/ip/") + strlen(iface) + 1 ); strcpy(_iface, "/Devices/ip/"); @@ -100,15 +88,25 @@ int main(int argc, char *argv[]) free(iface); // TODO: Handle when this is not heap iface = _iface; printf("iface = '%s'\n", iface); + fd = _SysOpen(iface, OPENFLAG_EXEC); + if(fd == -1) { + fprintf(stderr, "ERROR: Unable to open interface '%s'\n", iface); + return 1; + } + } - - fd = open(iface, OPENFLAG_EXEC); - if(fd == -1) { - fprintf(stderr, "ERROR: Unable to open interface '%s'\n", iface); - return 1; + else + { + fd = Net_OpenSocket(type, addr, NULL); + if( fd == -1 ) { + fprintf(stderr, "Unable to find a route to '%s'\n", + Net_PrintAddress(type, addr) + ); + return -1; + } } - - call = ioctl(fd, 3, "ping"); + + call = _SysIOCtl(fd, 3, "ping"); if(call == 0) { fprintf(stderr, "ERROR: '%s' does not have a 'ping' call\n", iface); return 1; @@ -116,11 +114,11 @@ int main(int argc, char *argv[]) for( i = 0; i < giNumberOfPings; i ++ ) { - ping = ioctl(fd, call, addr); + ping = _SysIOCtl(fd, call, addr); printf("ping = %i\n", ping); } - close(fd); + _SysClose(fd); return 0; }