diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-02-20 22:51:14 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-02-20 22:51:14 +0000 |
commit | 6cf00455c4f553fde18bdfd09203263199cbf37c (patch) | |
tree | e81995e569199c08744dfb7f6234a0b83a2d260b /cpukit | |
parent | 2008-02-20 Alexandru Bugnar <a-bugnar@criticalsoftware.com> (diff) | |
download | rtems-6cf00455c4f553fde18bdfd09203263199cbf37c.tar.bz2 |
2008-02-20 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/shellconfig.h: Add netstats
command to access statistics reporting functions in TCP/IP stack.
* libmisc/shell/main_netstats.c: New file.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/libmisc/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/libmisc/shell/main_netstats.c | 98 | ||||
-rw-r--r-- | cpukit/libmisc/shell/shellconfig.h | 7 |
4 files changed, 112 insertions, 1 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 45fa765308..7db601b6ca 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +2008-02-20 Joel Sherrill <joel.sherrill@oarcorp.com> + + * libmisc/Makefile.am, libmisc/shell/shellconfig.h: Add netstats + command to access statistics reporting functions in TCP/IP stack. + * libmisc/shell/main_netstats.c: New file. + 2008-02-19 Joel Sherrill <joel.sherrill@oarcorp.com> * libmisc/Makefile.am, libmisc/shell/main_wkspaceinfo.c, diff --git a/cpukit/libmisc/Makefile.am b/cpukit/libmisc/Makefile.am index 57fdaddb71..af70d50eae 100644 --- a/cpukit/libmisc/Makefile.am +++ b/cpukit/libmisc/Makefile.am @@ -84,7 +84,7 @@ libshell_a_SOURCES = shell/cat_file.c shell/cmds.c shell/internal.h \ shell/fts.c shell/print_heapinfo.c shell/main_wkspaceinfo.c if LIBNETWORKING libshell_a_SOURCES += shell/main_mount_ftp.c shell/main_mount_tftp.c \ - shell/main_ifconfig.c shell/main_route.c + shell/main_ifconfig.c shell/main_route.c shell/main_netstats.c ##libshell_a_SOURCES += shell/main_mount_nfs.c endif endif diff --git a/cpukit/libmisc/shell/main_netstats.c b/cpukit/libmisc/shell/main_netstats.c new file mode 100644 index 0000000000..09dea65694 --- /dev/null +++ b/cpukit/libmisc/shell/main_netstats.c @@ -0,0 +1,98 @@ +/* + * Network Statistics Shell Command Implmentation + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <getopt.h> + +#include <rtems.h> +#include <rtems/rtems_bsdnet.h> +#include <rtems/shell.h> +#include "internal.h" + +static void netstats_usage() +{ + printf( + "netstats [-vAimfpcut] where:\n" + " -A print All statistics\n" + " -i print Inet Routes\n" + " -m print MBUF Statistics\n" + " -f print IF Statistics\n" + " -p print IP Statistics\n" + " -c print ICMP Statistics\n" + " -u print UDP Statistics\n" + " -t print TCP Statistics\n" + ); +} + +int rtems_shell_main_netstats( /* command */ + int argc, + char *argv[] +) +{ + int option; + int doAll = 0; + int doInetRoutes = 0; + int doMBUFStats = 0; + int doIFStats = 0; + int doIPStats = 0; + int doICMPStats = 0; + int doUDPStats = 0; + int doTCPStats = 0; + + while ( (option = getopt( argc, argv, "Aimfpcutv")) != -1 ) { + switch (option) { + case 'A': doAll = 1; break; + case 'i': doInetRoutes = 1; break; + case 'm': doMBUFStats = 1; break; + case 'f': doIFStats = 1; break; + case 'p': doIPStats = 1; break; + case 'c': doICMPStats = 1; break; + case 'u': doUDPStats = 1; break; + case 't': doTCPStats = 1; break; + case '?': + default: + netstats_usage(); + return -1; + } + } + + if ( doInetRoutes == 1 || doAll == 1 ) + rtems_bsdnet_show_inet_routes(); + if ( doMBUFStats == 1 || doAll == 1 ) + rtems_bsdnet_show_mbuf_stats(); + if ( doIFStats == 1 || doAll == 1 ) + rtems_bsdnet_show_if_stats(); + if ( doIPStats == 1 || doAll == 1 ) + rtems_bsdnet_show_ip_stats(); + if ( doICMPStats == 1 || doAll == 1 ) + rtems_bsdnet_show_icmp_stats(); + if ( doUDPStats == 1 || doAll == 1 ) + rtems_bsdnet_show_udp_stats(); + if ( doTCPStats == 1 || doAll == 1 ) + rtems_bsdnet_show_tcp_stats(); + + return 0; +} + +rtems_shell_cmd_t rtems_shell_NETSTATS_Command = { + "netstats", /* name */ + "netstats [-Aimfpcutv]", /* usage */ + "network", /* topic */ + rtems_shell_main_netstats, /* command */ + NULL, /* alias */ + NULL /* next */ +}; diff --git a/cpukit/libmisc/shell/shellconfig.h b/cpukit/libmisc/shell/shellconfig.h index 3865c398f5..33d60f7e28 100644 --- a/cpukit/libmisc/shell/shellconfig.h +++ b/cpukit/libmisc/shell/shellconfig.h @@ -59,6 +59,7 @@ extern rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command; #if defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command; extern rtems_shell_cmd_t rtems_shell_ROUTE_Command; + extern rtems_shell_cmd_t rtems_shell_NETSTATS_Command; #endif #endif @@ -325,6 +326,12 @@ extern rtems_shell_filesystems_t *rtems_shell_Mount_filesystems[]; defined(CONFIGURE_SHELL_COMMAND_ROUTE) &rtems_shell_ROUTE_Command, #endif + + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ + !defined(CONFIGURE_SHELL_COMMAND_NETSTATS)) || \ + defined(CONFIGURE_SHELL_COMMAND_NETSTATS) + &rtems_shell_NETSTATS_Command, + #endif #endif /* |