From 57ffa414b54cb6b90a1154c30e8f2328fed8e670 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 25 Jan 2011 22:25:50 +0800 Subject: [PATCH] Slight bugfixes and output cleanups --- Usermode/Applications/Makefile.cfg | 2 +- Usermode/Applications/ifconfig_src/main.c | 46 +++++++++++++---------- Usermode/Applications/irc_src/main.c | 7 +++- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Usermode/Applications/Makefile.cfg b/Usermode/Applications/Makefile.cfg index 2e64b9d6..920526d2 100644 --- a/Usermode/Applications/Makefile.cfg +++ b/Usermode/Applications/Makefile.cfg @@ -13,6 +13,6 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.cfg ASFLAGS = -felf CPPFLAGS = -I$(ACESSUSERDIR)/include/ -CFLAGS = -fno-stack-protector $(CPPFLAGS) +CFLAGS = -fno-stack-protector $(CPPFLAGS) -Wall LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc DIR = Bin diff --git a/Usermode/Applications/ifconfig_src/main.c b/Usermode/Applications/ifconfig_src/main.c index 9aa9d722..bd21e2b1 100644 --- a/Usermode/Applications/ifconfig_src/main.c +++ b/Usermode/Applications/ifconfig_src/main.c @@ -46,13 +46,13 @@ int main(int argc, char *argv[]) if( strcmp(argv[1], "route") == 0 ) { // Add new route - if( strcmp(argv[2], "add") == 0 ) + if( argc > 2 && strcmp(argv[2], "add") == 0 ) { uint8_t dest[16] = {0}; uint8_t nextHop[16] = {0}; int addrType, subnetBits = -1; int nextHopType, nextHopBits=-1; - char *ifaceName; + char *ifaceName = NULL; int metric = DEFAULT_METRIC; // Usage: // ifconfig route add [/] [] @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) return 0; } // Delete a route - else if( strcmp(argv[2], "del") == 0 ) + else if( argc > 2 && strcmp(argv[2], "del") == 0 ) { // Usage: // ifconfig route del @@ -227,6 +227,8 @@ void DumpRoutes(void) dp = open(IPSTACK_ROOT"/routes", OPENFLAG_READ); + printf("ID\tType\tNetwork \tGateway \tMetric\tIFace\n"); + while( readdir(dp, filename) ) { if(filename[0] == '.') continue; @@ -332,15 +334,8 @@ void DumpRoute(const char *Name) return ; } - printf("%s:\t", Name); - { - 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); - } + // Number + printf("%s\t", Name); // Get the address type switch(type) @@ -352,34 +347,45 @@ void DumpRoute(const char *Name) { uint8_t net[4], addr[4]; int subnet, metric; - printf("IPv4\n"); + 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("\tNetwork: %s/%i\n", Net_PrintAddress(4, net), subnet); - printf("\tGateway: %s\n", Net_PrintAddress(4, addr)); - printf("\tMetric: %i\n", metric); + 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\n"); + 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("\tNetwork: %s/%i\n", Net_PrintAddress(6, net), subnet); - printf("\tGateway: %s\n", Net_PrintAddress(6, addr)); - printf("\tMetric: %i\n", metric); + 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); + } + printf("\n"); close(fd); diff --git a/Usermode/Applications/irc_src/main.c b/Usermode/Applications/irc_src/main.c index 30c579c0..4fce928b 100644 --- a/Usermode/Applications/irc_src/main.c +++ b/Usermode/Applications/irc_src/main.c @@ -38,10 +38,13 @@ int main(int argc, const char *argv[], const char *envp[]) memset(&srv, 0, sizeof(srv)); + // Parse Command line + // - Sets the server configuration globals if( (tmp = ParseArguments(argc, argv)) ) { return tmp; } + // Connect to the remove server srv.FD = OpenTCP( gsRemoteAddress, giRemotePort ); if( srv.FD == -1 ) { fprintf(stderr, "Unable to create socket\n"); @@ -232,12 +235,12 @@ int OpenTCP(const char *AddressString, short PortNumber) } // Set remote port and address - printf("Setting port and remote address"); + printf("Setting port and remote address\n"); ioctl(fd, 5, &PortNumber); ioctl(fd, 6, addrBuffer); // Connect - printf("Initiating connection"); + printf("Initiating connection\n"); if( ioctl(fd, 7, NULL) == 0 ) { // Shouldn't happen :( fprintf(stderr, "Unable to start connection\n"); -- 2.20.1