summaryrefslogtreecommitdiffstats
path: root/apps/nshlib
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-24 08:26:12 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-24 08:26:12 -0600
commit5540c66c784c623e4c0525fc1c7ff2138bcf1fa7 (patch)
treeebbbadcfc96bb24f150c9e78d3f20015b85391d0 /apps/nshlib
parentf331654b9526da69868089165c4e3dabadfd72a1 (diff)
Networking: Clean up network status collection and presentation for IPv6
Diffstat (limited to 'apps/nshlib')
-rw-r--r--apps/nshlib/nsh_netcmds.c143
1 files changed, 110 insertions, 33 deletions
diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c
index f1ebe6625a..11286c3670 100644
--- a/apps/nshlib/nsh_netcmds.c
+++ b/apps/nshlib/nsh_netcmds.c
@@ -273,107 +273,184 @@ errout:
#if defined(CONFIG_NET_STATISTICS) && !defined(CONFIG_NSH_DISABLE_IFCONFIG)
static inline void net_statistics(FAR struct nsh_vtbl_s *vtbl)
{
- nsh_output(vtbl, " IP ");
+ /* Headings */
+
+ nsh_output(vtbl, " ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " IPv4");
+#endif
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " IPv6");
+#endif
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " TCP");
+ nsh_output(vtbl, " TCP");
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " UDP");
+ nsh_output(vtbl, " UDP");
#endif
#ifdef CONFIG_NET_ICMP
nsh_output(vtbl, " ICMP");
#endif
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " ICMP6");
+#endif
nsh_output(vtbl, "\n");
/* Received packets */
- nsh_output(vtbl, "Received %04x", g_netstats.ip.recv);
+ nsh_output(vtbl, "Received ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " %04x", g_netstats.ipv4.recv);
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " %04x", g_netstats.ipv6.recv);
+#endif
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " %04x", g_netstats.tcp.recv);
+ nsh_output(vtbl, " %04x", g_netstats.tcp.recv);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " %04x", g_netstats.udp.recv);
+ nsh_output(vtbl, " %04x", g_netstats.udp.recv);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(vtbl, " %04x", g_netstats.icmp.recv);
+ nsh_output(vtbl, " %04x", g_netstats.icmp.recv);
+#endif
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " %04x", g_netstats.icmpv6.recv);
#endif
nsh_output(vtbl, "\n");
/* Dropped packets */
- nsh_output(vtbl, "Dropped %04x", g_netstats.ip.drop);
+ nsh_output(vtbl, "Dropped ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " %04x", g_netstats.ipv4.drop);
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " %04x", g_netstats.ipv6.drop);
+#endif
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " %04x", g_netstats.tcp.drop);
+ nsh_output(vtbl, " %04x", g_netstats.tcp.drop);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " %04x", g_netstats.udp.drop);
+ nsh_output(vtbl, " %04x", g_netstats.udp.drop);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(vtbl, " %04x", g_netstats.icmp.drop);
+ nsh_output(vtbl, " %04x", g_netstats.icmp.drop);
+#endif
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " %04x", g_netstats.icmpv6.drop);
#endif
nsh_output(vtbl, "\n");
- nsh_output(vtbl, " IP VHL: %04x HBL: %04x\n",
- g_netstats.ip.vhlerr, g_netstats.ip.hblenerr);
- nsh_output(vtbl, " LBL: %04x Frg: %04x\n",
- g_netstats.ip.lblenerr, g_netstats.ip.fragerr);
+ /* Dropped IP packets */
+
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " IPv4 VHL: %04x Frg: %04x\n",
+ g_netstats.ipv4.vhlerr, g_netstats.ipv4.fragerr);
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " IPv6 VHL: %04x\n",
+ g_netstats.ipv6.vhlerr);
+#endif
+
+ /* Checksum errors */
- nsh_output(vtbl, " Checksum %04x",g_netstats.ip.chkerr);
+ nsh_output(vtbl, " Checksum ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " %04x", g_netstats.ipv4.chkerr);
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " ----");
+#endif
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " %04x", g_netstats.tcp.chkerr);
+ nsh_output(vtbl, " %04x", g_netstats.tcp.chkerr);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " %04x", g_netstats.udp.chkerr);
+ nsh_output(vtbl, " %04x", g_netstats.udp.chkerr);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(vtbl, " ----");
+ nsh_output(vtbl, " ----");
+#endif
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " ----");
#endif
nsh_output(vtbl, "\n");
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " TCP ACK: %04x SYN: %04x\n",
+ nsh_output(vtbl, " TCP ACK: %04x SYN: %04x\n",
g_netstats.tcp.ackerr, g_netstats.tcp.syndrop);
- nsh_output(vtbl, " RST: %04x %04x\n",
+ nsh_output(vtbl, " RST: %04x %04x\n",
g_netstats.tcp.rst, g_netstats.tcp.synrst);
#endif
- nsh_output(vtbl, " Type %04x", g_netstats.ip.protoerr);
+ /* Prototype errors */
+
+ nsh_output(vtbl, " Type ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " %04x", g_netstats.ipv4.protoerr);
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " %04x", g_netstats.ipv6.protoerr);
+#endif
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " ----");
+ nsh_output(vtbl, " ----");
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " ----");
+ nsh_output(vtbl, " ----");
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(vtbl, " %04x", g_netstats.icmp.typeerr);
+ nsh_output(vtbl, " %04x", g_netstats.icmp.typeerr);
+#endif
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " %04x", g_netstats.icmpv6.typeerr);
#endif
nsh_output(vtbl, "\n");
/* Sent packets */
- nsh_output(vtbl, "Sent ----", g_netstats.ip.sent);
+ nsh_output(vtbl, "Sent ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " %04x", g_netstats.ipv4.sent);
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " %04x", g_netstats.ipv6.sent);
+#endif
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " %04x", g_netstats.tcp.sent);
+ nsh_output(vtbl, " %04x", g_netstats.tcp.sent);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " %04x", g_netstats.udp.sent);
+ nsh_output(vtbl, " %04x", g_netstats.udp.sent);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(vtbl, " %04x", g_netstats.icmp.sent);
+ nsh_output(vtbl, " %04x", g_netstats.icmp.sent);
+#endif
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " %04x", g_netstats.icmpv6.sent);
#endif
nsh_output(vtbl, "\n");
+ /* TCP retransmissions */
+
#ifdef CONFIG_NET_TCP
- nsh_output(vtbl, " Rexmit ---- %04x", g_netstats.tcp.rexmit);
+ nsh_output(vtbl, " Rexmit ");
+#ifdef CONFIG_NET_IPv4
+ nsh_output(vtbl, " ----");
+#endif
+#ifdef CONFIG_NET_IPv6
+ nsh_output(vtbl, " ----");
+#endif
#ifdef CONFIG_NET_UDP
- nsh_output(vtbl, " ----");
+ nsh_output(vtbl, " ----");
#endif
+ nsh_output(vtbl, " %04x", g_netstats.tcp.rexmit);
#ifdef CONFIG_NET_ICMP
- nsh_output(vtbl, " ----");
+ nsh_output(vtbl, " ----");
#endif
- nsh_output(vtbl, "\n");
+#ifdef CONFIG_NET_ICMPv6
+ nsh_output(vtbl, " ----");
#endif
nsh_output(vtbl, "\n");
+#endif /* CONFIG_NET_TCP */
}
#else
# define net_statistics(vtbl)