source: rtems/cpukit/libmisc/shell/main_netstats.c @ 3421e520

4.115
Last change on this file since 3421e520 was 3421e520, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/04/11 at 10:22:51
  • libmisc/shell/main_help.c: Make rtems_shell_help_cmd, rtems_shell_help static.
  • libmisc/shell/main_hexdump.c: Make main_hexdump static.
  • libmisc/shell/main_id.c: Make rtems_shell_main_id static.
  • libmisc/shell/main_ifconfig.c: Make rtems_shell_main_ifconfig static.
  • libmisc/shell/main_ln.c: Make rtems_shell_main_ln static.
  • libmisc/shell/main_logoff.c: Make rtems_shell_main_logoff static.
  • libmisc/shell/main_ls.c: Make rtems_shell_main_ls static.
  • libmisc/shell/main_mallocinfo.c: Include <rtems/libcsupport.h>. Remove private decls of malloc_info, rtems_shell_print_unified_work_area_message. Make rtems_shell_main_malloc_info static.
  • libmisc/shell/main_medit.c: Remove private decl of rtems_shell_main_mdump. Make rtems_shell_main_medit static.
  • libmisc/shell/main_mfill.c: Make rtems_shell_main_mfill static.
  • libmisc/shell/main_mkdir.c: Make rtems_shell_main_mkdir static.
  • libmisc/shell/main_mknod.c: Make rtems_shell_main_mknod static.
  • libmisc/shell/main_mmove.c: Remove private decl of rtems_shell_main_mdump. Make rtems_shell_main_mmove static.
  • libmisc/shell/main_mount.c: Make rtems_shell_main_mount static.
  • libmisc/shell/main_msdosfmt.c: Make rtems_shell_main_msdos_format static.
  • libmisc/shell/main_mv.c: Include "internal.h". Make rtems_shell_mv_exit, rtems_shell_main_mv static. Remove private decls of strmode rtems_shell_main_cp, rtems_shell_main_rm.
  • libmisc/shell/main_mwdump.c: Make rtems_shell_main_mwdump static.
  • libmisc/shell/main_netstats.c: Make rtems_shell_main_netstats static.
  • libmisc/shell/main_perioduse.c: Make rtems_shell_main_perioduse static.
  • libmisc/shell/main_pwd.c: Make rtems_shell_main_pwd static.
  • libmisc/shell/main_rm.c: Include "internal.h". Make rtems_shell_rm_exit static. Remove private decl of strmode.
  • libmisc/shell/main_rmdir.c: Make rtems_shell_main_rmdir static. libmisc/shell/main_route.c: Make rtems_shell_main_route static.
  • libmisc/shell/main_setenv.c: Make rtems_shell_main_setenv static.
  • libmisc/shell/main_sleep.c: Make rtems_shell_main_sleep static.
  • libmisc/shell/main_stackuse.c: Make rtems_shell_main_stackuse static.
  • libmisc/shell/main_time.c: Make rtems_shell_main_time static.
  • libmisc/shell/main_tty.c: Make rtems_shell_main_tty static.
  • libmisc/shell/main_umask.c: Make rtems_shell_main_umask static.
  • libmisc/shell/main_unmount.c: Make rtems_shell_main_unmount static.
  • libmisc/shell/main_unsetenv.c: Make rtems_shell_main_unsetenv static.
  • libmisc/shell/main_whoami.c: Make rtems_shell_main_whoami static.
  • libmisc/shell/main_wkspaceinfo.c: Make rtems_shell_main_wkspace_info static.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  Network Statistics Shell Command Implmentation
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <stdio.h>
19#define __need_getopt_newlib
20#include <getopt.h>
21
22#include <rtems.h>
23#include <rtems/rtems_bsdnet.h>
24#include <rtems/shell.h>
25#include "internal.h"
26
27static void netstats_usage(void)
28{
29  printf(
30    "netstats [-vAimfpcut] where:\n"
31    "  -A    print All statistics\n"
32    "  -i    print Inet Routes\n"
33    "  -m    print MBUF Statistics\n"
34    "  -f    print IF Statistics\n"
35    "  -p    print IP Statistics\n"
36    "  -c    print ICMP Statistics\n"
37    "  -u    print UDP Statistics\n"
38    "  -t    print TCP Statistics\n"
39  );
40}
41
42static int rtems_shell_main_netstats(                       /* command */
43  int   argc,
44  char *argv[]
45)
46{
47  int   option;
48  int   doAll = 0;
49  int   doInetRoutes = 0;
50  int   doMBUFStats = 0;
51  int   doIFStats = 0;
52  int   doIPStats = 0;
53  int   doICMPStats = 0;
54  int   doUDPStats = 0;
55  int   doTCPStats = 0;
56  int   verbose = 0;
57  struct getopt_data getopt_reent;
58
59  memset(&getopt_reent, 0, sizeof(getopt_data));
60  while ( (option = getopt_r( argc, argv, "Aimfpcutv", &getopt_reent)) != -1 ) {
61
62    switch ((char)option) {
63      case 'A': doAll = 1;        break;
64      case 'i': doInetRoutes = 1; break;
65      case 'm': doMBUFStats = 1;  break;
66      case 'f': doIFStats = 1;    break;
67      case 'p': doIPStats = 1;    break;
68      case 'c': doICMPStats = 1;  break;
69      case 'u': doUDPStats = 1;   break;
70      case 't': doTCPStats = 1;   break;
71      case 'v': verbose = 1;      break;
72      case '?':
73      default:
74        netstats_usage();
75        return -1;
76    }
77  }
78
79  if ( verbose ) {
80    printf(
81      "doAll=%d\n"
82      "doInetRoutes=%d\n"
83      "doMBUFStats=%d\n"
84      "doIFStats=%d\n"
85      "doIPStats=%d\n"
86      "doICMPStats=%d\n"
87      "doUDPStats=%d\n"
88      "doTCPStats=%d\n",
89      doAll,
90      doInetRoutes,
91      doMBUFStats,
92      doIFStats,
93      doIPStats,
94      doICMPStats,
95      doUDPStats,
96      doTCPStats
97    );
98  }
99
100  if ( doInetRoutes == 1 || doAll == 1 ) {
101    rtems_bsdnet_show_inet_routes();
102  }
103
104  if ( doMBUFStats == 1 || doAll == 1 ) {
105    rtems_bsdnet_show_mbuf_stats();
106  }
107
108  if ( doIFStats == 1 || doAll == 1 ) {
109    rtems_bsdnet_show_if_stats();
110  }
111
112  if ( doIPStats == 1 || doAll == 1 ) {
113    rtems_bsdnet_show_ip_stats();
114  }
115
116  if ( doICMPStats == 1 || doAll == 1 ) {
117    rtems_bsdnet_show_icmp_stats();
118  }
119
120  if ( doUDPStats == 1 || doAll == 1 ) {
121    rtems_bsdnet_show_udp_stats();
122  }
123
124  if ( doTCPStats == 1 || doAll == 1 ) {
125    rtems_bsdnet_show_tcp_stats();
126  }
127
128  return 0;
129}
130
131rtems_shell_cmd_t rtems_shell_NETSTATS_Command = {
132  "netstats",                                      /* name */
133  "netstats [-Aimfpcutv]",                         /* usage */
134  "network",                                       /* topic */
135  rtems_shell_main_netstats,                       /* command */
136  NULL,                                            /* alias */
137  NULL                                             /* next */
138};
Note: See TracBrowser for help on using the repository browser.