summaryrefslogtreecommitdiff
path: root/nuttx/examples/nsh/nsh_netcmds.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-16 18:39:46 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-16 18:39:46 +0000
commit07656e5f84288c96e871a522bb48e050ceec8551 (patch)
tree9ee3ba0a23a3c660076204af8b2a7fbf399c5ff2 /nuttx/examples/nsh/nsh_netcmds.c
parent4764ba54f9306b0e39ccf5e3a0dd2f40604ea848 (diff)
downloadnuttx-07656e5f84288c96e871a522bb48e050ceec8551.tar.gz
nuttx-07656e5f84288c96e871a522bb48e050ceec8551.tar.bz2
nuttx-07656e5f84288c96e871a522bb48e050ceec8551.zip
NSH redirected output
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@823 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nsh/nsh_netcmds.c')
-rw-r--r--nuttx/examples/nsh/nsh_netcmds.c101
1 files changed, 51 insertions, 50 deletions
diff --git a/nuttx/examples/nsh/nsh_netcmds.c b/nuttx/examples/nsh/nsh_netcmds.c
index 6c26584df..ee21ae154 100644
--- a/nuttx/examples/nsh/nsh_netcmds.c
+++ b/nuttx/examples/nsh/nsh_netcmds.c
@@ -1,7 +1,7 @@
/****************************************************************************
* examples/nsh/nsh_netcmds.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -86,112 +86,112 @@
****************************************************************************/
#ifdef CONFIG_NET_STATISTICS
-static inline void uip_statistics(void *handle)
+static inline void uip_statistics(FAR struct nsh_vtbl_s *vtbl)
{
- nsh_output(handle, "uIP IP ");
+ nsh_output(vtbl, "uIP IP ");
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " TCP");
+ nsh_output(vtbl, " TCP");
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " UDP");
+ nsh_output(vtbl, " UDP");
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " ICMP");
+ nsh_output(vtbl, " ICMP");
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
/* Received packets */
- nsh_output(handle, "Received %04x",uip_stat.ip.recv);
+ nsh_output(vtbl, "Received %04x",uip_stat.ip.recv);
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " %04x",uip_stat.tcp.recv);
+ nsh_output(vtbl, " %04x",uip_stat.tcp.recv);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " %04x",uip_stat.udp.recv);
+ nsh_output(vtbl, " %04x",uip_stat.udp.recv);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " %04x",uip_stat.icmp.recv);
+ nsh_output(vtbl, " %04x",uip_stat.icmp.recv);
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
/* Dropped packets */
- nsh_output(handle, "Dropped %04x",uip_stat.ip.drop);
+ nsh_output(vtbl, "Dropped %04x",uip_stat.ip.drop);
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " %04x",uip_stat.tcp.drop);
+ nsh_output(vtbl, " %04x",uip_stat.tcp.drop);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " %04x",uip_stat.udp.drop);
+ nsh_output(vtbl, " %04x",uip_stat.udp.drop);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " %04x",uip_stat.icmp.drop);
+ nsh_output(vtbl, " %04x",uip_stat.icmp.drop);
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
- nsh_output(handle, " IP VHL: %04x HBL: %04x\n",
+ nsh_output(vtbl, " IP VHL: %04x HBL: %04x\n",
uip_stat.ip.vhlerr, uip_stat.ip.hblenerr);
- nsh_output(handle, " LBL: %04x Frg: %04x\n",
+ nsh_output(vtbl, " LBL: %04x Frg: %04x\n",
uip_stat.ip.lblenerr, uip_stat.ip.fragerr);
- nsh_output(handle, " Checksum %04x",uip_stat.ip.chkerr);
+ nsh_output(vtbl, " Checksum %04x",uip_stat.ip.chkerr);
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " %04x",uip_stat.tcp.chkerr);
+ nsh_output(vtbl, " %04x",uip_stat.tcp.chkerr);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " %04x",uip_stat.udp.chkerr);
+ nsh_output(vtbl, " %04x",uip_stat.udp.chkerr);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " ----");
+ nsh_output(vtbl, " ----");
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " TCP ACK: %04x SYN: %04x\n",
+ nsh_output(vtbl, " TCP ACK: %04x SYN: %04x\n",
uip_stat.tcp.ackerr, uip_stat.tcp.syndrop);
- nsh_output(handle, " RST: %04x %04x\n",
+ nsh_output(vtbl, " RST: %04x %04x\n",
uip_stat.tcp.rst, uip_stat.tcp.synrst);
#endif
- nsh_output(handle, " Type %04x",uip_stat.ip.protoerr);
+ nsh_output(vtbl, " Type %04x",uip_stat.ip.protoerr);
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " ----");
+ nsh_output(vtbl, " ----");
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " ----");
+ nsh_output(vtbl, " ----");
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " %04x",uip_stat.icmp.typeerr);
+ nsh_output(vtbl, " %04x",uip_stat.icmp.typeerr);
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
/* Sent packets */
- nsh_output(handle, "Sent ----",uip_stat.ip.sent);
+ nsh_output(vtbl, "Sent ----",uip_stat.ip.sent);
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " %04x",uip_stat.tcp.sent);
+ nsh_output(vtbl, " %04x",uip_stat.tcp.sent);
#endif
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " %04x",uip_stat.udp.sent);
+ nsh_output(vtbl, " %04x",uip_stat.udp.sent);
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " %04x",uip_stat.icmp.sent);
+ nsh_output(vtbl, " %04x",uip_stat.icmp.sent);
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
#ifdef CONFIG_NET_TCP
- nsh_output(handle, " Rexmit ---- %04x",uip_stat.tcp.rexmit);
+ nsh_output(vtbl, " Rexmit ---- %04x",uip_stat.tcp.rexmit);
#ifdef CONFIG_NET_UDP
- nsh_output(handle, " ----");
+ nsh_output(vtbl, " ----");
#endif
#ifdef CONFIG_NET_ICMP
- nsh_output(handle, " ----");
+ nsh_output(vtbl, " ----");
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
#endif
- nsh_output(handle, "\n");
+ nsh_output(vtbl, "\n");
}
#else
-# define uip_statistics(handle)
+# define uip_statistics(vtbl)
#endif
/****************************************************************************
@@ -200,15 +200,16 @@ static inline void uip_statistics(void *handle)
int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg)
{
+ struct nsh_vtbl_s *vtbl = (struct nsh_vtbl_s*)arg;
struct in_addr addr;
- nsh_output(arg, "%s\tHWaddr %s\n", dev->d_ifname, ether_ntoa(&dev->d_mac));
+ nsh_output(vtbl, "%s\tHWaddr %s\n", dev->d_ifname, ether_ntoa(&dev->d_mac));
addr.s_addr = dev->d_ipaddr;
- nsh_output(arg, "\tIPaddr:%s ", inet_ntoa(addr));
+ nsh_output(vtbl, "\tIPaddr:%s ", inet_ntoa(addr));
addr.s_addr = dev->d_draddr;
- nsh_output(arg, "DRaddr:%s ", inet_ntoa(addr));
+ nsh_output(vtbl, "DRaddr:%s ", inet_ntoa(addr));
addr.s_addr = dev->d_netmask;
- nsh_output(arg, "Mask:%s\n\n", inet_ntoa(addr));
+ nsh_output(vtbl, "Mask:%s\n\n", inet_ntoa(addr));
return OK;
}
@@ -220,10 +221,10 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg)
* Name: cmd_ifconfig
****************************************************************************/
-void cmd_ifconfig(FAR void *handle, int argc, char **argv)
+void cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
- netdev_foreach(ifconfig_callback, handle);
- uip_statistics(handle);
+ netdev_foreach(ifconfig_callback, vtbl);
+ uip_statistics(vtbl);
}
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */