diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-12 14:41:36 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-12 14:41:36 +0000 |
commit | 1dbeb7137b593584b54bb6acbe9da4f3e5d5bf71 (patch) | |
tree | 30f6350d32b4fdb7ce8cc14954f1a0a8e1f309c1 /nuttx/examples/nsh | |
parent | 5fe3de54cf5d76704b60d598169031aad2b7130f (diff) | |
download | px4-nuttx-1dbeb7137b593584b54bb6acbe9da4f3e5d5bf71.tar.gz px4-nuttx-1dbeb7137b593584b54bb6acbe9da4f3e5d5bf71.tar.bz2 px4-nuttx-1dbeb7137b593584b54bb6acbe9da4f3e5d5bf71.zip |
ifconfig shows uIP stats
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@450 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nsh')
-rw-r--r-- | nuttx/examples/nsh/nsh_netcmds.c | 120 |
1 files changed, 119 insertions, 1 deletions
diff --git a/nuttx/examples/nsh/nsh_netcmds.c b/nuttx/examples/nsh/nsh_netcmds.c index c58a23f07..3874d3a53 100644 --- a/nuttx/examples/nsh/nsh_netcmds.c +++ b/nuttx/examples/nsh/nsh_netcmds.c @@ -51,6 +51,10 @@ #include <net/uip/uip-arch.h> #include <netinet/ether.h> +#ifdef CONFIG_NET_STATISTICS +#include <net/uip/uip.h> +#endif + #include "nsh.h" /**************************************************************************** @@ -78,6 +82,119 @@ ****************************************************************************/ /**************************************************************************** + * Name: uip_statistics + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static inline void uip_statistics(void *handle) +{ + nsh_output(handle, "uIP IP "); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " TCP"); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " UDP"); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " ICMP"); +#endif + nsh_output(handle, "\n"); + + /* Received packets */ + + nsh_output(handle, "Received %04x",uip_stat.ip.recv); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.recv); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.recv); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.recv); +#endif + nsh_output(handle, "\n"); + + /* Dropped packets */ + + nsh_output(handle, "Dropped %04x",uip_stat.ip.drop); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.drop); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.drop); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.drop); +#endif + nsh_output(handle, "\n"); + + nsh_output(handle, " IP VHL: %04x HBL: %04x\n", + uip_stat.ip.vhlerr, uip_stat.ip.hblenerr); + nsh_output(handle, " LBL: %04x Frg: %04x\n", + uip_stat.ip.lblenerr, uip_stat.ip.fragerr); + + nsh_output(handle, " Checksum %04x",uip_stat.ip.chkerr); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.chkerr); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.chkerr); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " ----"); +#endif + nsh_output(handle, "\n"); + +#ifdef CONFIG_NET_TCP + nsh_output(handle, " TCP ACK: %04x SYN: %04x\n", + uip_stat.tcp.ackerr, uip_stat.tcp.syndrop); + nsh_output(handle, " RST: %04x %04x\n", + uip_stat.tcp.rst, uip_stat.tcp.synrst); +#endif + + nsh_output(handle, " Type %04x",uip_stat.ip.protoerr); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " ----"); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " ----"); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.typeerr); +#endif + nsh_output(handle, "\n"); + + /* Sent packets */ + + nsh_output(handle, "Sent ----",uip_stat.ip.sent); +#ifdef CONFIG_NET_TCP + nsh_output(handle, " %04x",uip_stat.tcp.sent); +#endif +#ifdef CONFIG_NET_UDP + nsh_output(handle, " %04x",uip_stat.udp.sent); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " %04x",uip_stat.icmp.sent); +#endif + nsh_output(handle, "\n"); + +#ifdef CONFIG_NET_TCP + nsh_output(handle, " Rexmit ---- %04x",uip_stat.tcp.rexmit); +#ifdef CONFIG_NET_UDP + nsh_output(handle, " ----"); +#endif +#ifdef CONFIG_NET_ICMP + nsh_output(handle, " ----"); +#endif + nsh_output(handle, "\n"); +#endif + nsh_output(handle, "\n"); +} +#else +# define uip_statistics(handle) +#endif + +/**************************************************************************** * Name: ifconfig_callback ****************************************************************************/ @@ -91,7 +208,7 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg) addr.s_addr = dev->d_draddr; nsh_output(arg, "DRaddr:%s ", inet_ntoa(addr)); addr.s_addr = dev->d_netmask; - nsh_output(arg, "Mask:%s\n", inet_ntoa(addr)); + nsh_output(arg, "Mask:%s\n\n", inet_ntoa(addr)); } /**************************************************************************** @@ -105,6 +222,7 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg) void cmd_ifconfig(FAR void *handle, int argc, char **argv) { netdev_foreach(ifconfig_callback, handle); + uip_statistics(handle); } #endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ |