apps/nshlib: The 'ifconfig' command now uses /proc/net/stat to show network statistics. A consequence of this is that you cannot view network statistics if the procfs is not enabled and mounted at /proc
This commit is contained in:
parent
0c03c1e840
commit
32b992971b
@ -1466,4 +1466,8 @@
|
|||||||
calls (2015-11-25).
|
calls (2015-11-25).
|
||||||
* apps/nshlib: If CONFIG_NETDEV_STATISTICS=y, then print the network
|
* apps/nshlib: If CONFIG_NETDEV_STATISTICS=y, then print the network
|
||||||
driver statistics in the ifconfig (15-11-26).
|
driver statistics in the ifconfig (15-11-26).
|
||||||
|
* apps/nshlib: The 'ifconfig' command now uses /proc/net/stat to
|
||||||
|
show network statistics. A consequence of this is that you cannot
|
||||||
|
view network statistics if the procfs is not enabled and mounted
|
||||||
|
at /proc (2015-11-27).
|
||||||
|
|
||||||
|
@ -50,6 +50,10 @@ else
|
|||||||
CSRCS += nsh_session.c
|
CSRCS += nsh_session.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||||
|
CSRCS += nsh_fsutils.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||||
CSRCS += nsh_builtin.c
|
CSRCS += nsh_builtin.c
|
||||||
endif
|
endif
|
||||||
|
21
nshlib/nsh.h
21
nshlib/nsh.h
@ -1110,4 +1110,25 @@ int nsh_extmatch_count(FAR char *name, FAR int *matches, int namelen);
|
|||||||
FAR const char *nsh_extmatch_getname(int index);
|
FAR const char *nsh_extmatch_getname(int index);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_catfile
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Dump the contents of a file to the current NSH terminal.
|
||||||
|
*
|
||||||
|
* Input Paratemets:
|
||||||
|
* vtbl - session vtbl
|
||||||
|
* cmd - NSH command name to use in error reporting
|
||||||
|
* filepath - The full path to the file to be dumped
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; -1 (ERROR) on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
|
int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
||||||
|
FAR const char *filepath);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __APPS_NSHLIB_NSH_H */
|
#endif /* __APPS_NSHLIB_NSH_H */
|
||||||
|
@ -420,127 +420,6 @@ static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath,
|
|||||||
|
|
||||||
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 && !CONFIG_NSH_DISABLE_LS */
|
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 && !CONFIG_NSH_DISABLE_LS */
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: cat_common
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
|
||||||
#ifndef CONFIG_NSH_DISABLE_CAT
|
|
||||||
static int cat_common(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|
||||||
FAR const char *filename)
|
|
||||||
{
|
|
||||||
FAR char *buffer;
|
|
||||||
int fd;
|
|
||||||
int ret = OK;
|
|
||||||
|
|
||||||
/* Open the file for reading */
|
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = (FAR char *)malloc(IOBUFFERSIZE);
|
|
||||||
if(buffer == NULL)
|
|
||||||
{
|
|
||||||
(void)close(fd);
|
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* And just dump it byte for byte into stdout */
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
int nbytesread = read(fd, buffer, IOBUFFERSIZE);
|
|
||||||
|
|
||||||
/* Check for read errors */
|
|
||||||
|
|
||||||
if (nbytesread < 0)
|
|
||||||
{
|
|
||||||
int errval = errno;
|
|
||||||
|
|
||||||
/* EINTR is not an error (but will stop stop the cat) */
|
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_SIGNALS
|
|
||||||
if (errval == EINTR)
|
|
||||||
{
|
|
||||||
nsh_output(vtbl, g_fmtsignalrecvd, cmd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, cmd, "read", NSH_ERRNO_OF(errval));
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for data successfully read */
|
|
||||||
|
|
||||||
else if (nbytesread > 0)
|
|
||||||
{
|
|
||||||
int nbyteswritten = 0;
|
|
||||||
|
|
||||||
while (nbyteswritten < nbytesread)
|
|
||||||
{
|
|
||||||
ssize_t n = nsh_write(vtbl, buffer, nbytesread);
|
|
||||||
if (n < 0)
|
|
||||||
{
|
|
||||||
int errval = errno;
|
|
||||||
|
|
||||||
/* EINTR is not an error (but will stop stop the cat) */
|
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_SIGNALS
|
|
||||||
if (errval == EINTR)
|
|
||||||
{
|
|
||||||
nsh_output(vtbl, g_fmtsignalrecvd, cmd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, cmd, "write", NSH_ERRNO);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nbyteswritten += n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, it is the end of file */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure that the following NSH prompt appears on a new line. If the
|
|
||||||
* file ends in a newline, then this will print an extra blank line
|
|
||||||
* before the prompt, but that is preferable to the case where there is
|
|
||||||
* no newline and the NSH prompt appears on the same line as the cat'ed
|
|
||||||
* file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
nsh_output(vtbl, "\n");
|
|
||||||
|
|
||||||
/* Close the input file and return the result */
|
|
||||||
|
|
||||||
(void)close(fd);
|
|
||||||
free(buffer);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -632,7 +511,7 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
{
|
{
|
||||||
/* Dump the file to the console */
|
/* Dump the file to the console */
|
||||||
|
|
||||||
ret = cat_common(vtbl, argv[0], fullpath);
|
ret = nsh_catfile(vtbl, argv[0], fullpath);
|
||||||
|
|
||||||
/* Free the allocated full path */
|
/* Free the allocated full path */
|
||||||
|
|
||||||
@ -653,7 +532,7 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
|
defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
|
||||||
int cmd_dmesg(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_dmesg(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
{
|
{
|
||||||
return cat_common(vtbl, argv[0], CONFIG_SYSLOG_DEVPATH);
|
return nsh_catfile(vtbl, argv[0], CONFIG_SYSLOG_DEVPATH);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -669,7 +548,7 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
char *srcpath = NULL;
|
char *srcpath = NULL;
|
||||||
char *destpath = NULL;
|
char *destpath = NULL;
|
||||||
char *allocpath = NULL;
|
char *allocpath = NULL;
|
||||||
int oflags = O_WRONLY|O_CREAT|O_TRUNC;
|
int oflags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||||
int rdfd;
|
int rdfd;
|
||||||
int wrfd;
|
int wrfd;
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
196
nshlib/nsh_fsutils.c
Normal file
196
nshlib/nsh_fsutils.c
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* apps/nshlib/nsh_fsutils.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "nsh.h"
|
||||||
|
#include "nsh_console.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_catfile
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Dump the contents of a file to the current NSH terminal.
|
||||||
|
*
|
||||||
|
* Input Paratemets:
|
||||||
|
* vtbl - session vtbl
|
||||||
|
* cmd - NSH command name to use in error reporting
|
||||||
|
* filepath - The full path to the file to be dumped
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; -1 (ERROR) on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
|
int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
||||||
|
FAR const char *filepath)
|
||||||
|
{
|
||||||
|
FAR char *buffer;
|
||||||
|
int fd;
|
||||||
|
int ret = OK;
|
||||||
|
|
||||||
|
/* Open the file for reading */
|
||||||
|
|
||||||
|
fd = open(filepath, O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = (FAR char *)malloc(IOBUFFERSIZE);
|
||||||
|
if(buffer == NULL)
|
||||||
|
{
|
||||||
|
(void)close(fd);
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And just dump it byte for byte into stdout */
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
int nbytesread = read(fd, buffer, IOBUFFERSIZE);
|
||||||
|
|
||||||
|
/* Check for read errors */
|
||||||
|
|
||||||
|
if (nbytesread < 0)
|
||||||
|
{
|
||||||
|
int errval = errno;
|
||||||
|
|
||||||
|
/* EINTR is not an error (but will stop stop the cat) */
|
||||||
|
|
||||||
|
#ifndef CONFIG_DISABLE_SIGNALS
|
||||||
|
if (errval == EINTR)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtsignalrecvd, cmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, cmd, "read", NSH_ERRNO_OF(errval));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for data successfully read */
|
||||||
|
|
||||||
|
else if (nbytesread > 0)
|
||||||
|
{
|
||||||
|
int nbyteswritten = 0;
|
||||||
|
|
||||||
|
while (nbyteswritten < nbytesread)
|
||||||
|
{
|
||||||
|
ssize_t n = nsh_write(vtbl, buffer, nbytesread);
|
||||||
|
if (n < 0)
|
||||||
|
{
|
||||||
|
int errval = errno;
|
||||||
|
|
||||||
|
/* EINTR is not an error (but will stop stop the cat) */
|
||||||
|
|
||||||
|
#ifndef CONFIG_DISABLE_SIGNALS
|
||||||
|
if (errval == EINTR)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtsignalrecvd, cmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, cmd, "write", NSH_ERRNO);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nbyteswritten += n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, it is the end of file */
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure that the following NSH prompt appears on a new line. If the
|
||||||
|
* file ends in a newline, then this will print an extra blank line
|
||||||
|
* before the prompt, but that is preferable to the case where there is
|
||||||
|
* no newline and the NSH prompt appears on the same line as the cat'ed
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
nsh_output(vtbl, "\n");
|
||||||
|
|
||||||
|
/* Close the input file and return the result */
|
||||||
|
|
||||||
|
(void)close(fd);
|
||||||
|
free(buffer);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -274,187 +274,12 @@ errout:
|
|||||||
* Name: net_statistics
|
* Name: net_statistics
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET_STATISTICS) && !defined(CONFIG_NSH_DISABLE_IFCONFIG)
|
#if defined(CONFIG_NET_STATISTICS) && defined(CONFIG_FS_PROCFS) && \
|
||||||
|
!defined(CONFIG_FS_PROCFS_EXCLUDE_NET) && \
|
||||||
|
!defined(CONFIG_NSH_DISABLE_IFCONFIG)
|
||||||
static inline void net_statistics(FAR struct nsh_vtbl_s *vtbl)
|
static inline void net_statistics(FAR struct nsh_vtbl_s *vtbl)
|
||||||
{
|
{
|
||||||
/* Headings */
|
(void)nsh_catfile(vtbl, "ifconfig", "/proc/net/stat");
|
||||||
|
|
||||||
nsh_output(vtbl, " ");
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
|
||||||
nsh_output(vtbl, " IPv4");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
nsh_output(vtbl, " IPv6");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_TCP
|
|
||||||
nsh_output(vtbl, " TCP");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " UDP");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
nsh_output(vtbl, " ICMP");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
|
||||||
nsh_output(vtbl, " ICMPv6");
|
|
||||||
#endif
|
|
||||||
nsh_output(vtbl, "\n");
|
|
||||||
|
|
||||||
/* Received packets */
|
|
||||||
|
|
||||||
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);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " %04x", g_netstats.udp.recv);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
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 ");
|
|
||||||
#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);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " %04x", g_netstats.udp.drop);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
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");
|
|
||||||
|
|
||||||
/* 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 ");
|
|
||||||
#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);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " %04x", g_netstats.udp.chkerr);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
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",
|
|
||||||
g_netstats.tcp.ackerr, g_netstats.tcp.syndrop);
|
|
||||||
nsh_output(vtbl, " RST: %04x %04x\n",
|
|
||||||
g_netstats.tcp.rst, g_netstats.tcp.synrst);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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, " ----");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " ----");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
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 ");
|
|
||||||
#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);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " %04x", g_netstats.udp.sent);
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
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 ");
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
|
||||||
nsh_output(vtbl, " ----");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
nsh_output(vtbl, " ----");
|
|
||||||
#endif
|
|
||||||
nsh_output(vtbl, " %04x", g_netstats.tcp.rexmit);
|
|
||||||
#ifdef CONFIG_NET_UDP
|
|
||||||
nsh_output(vtbl, " ----");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMP
|
|
||||||
nsh_output(vtbl, " ----");
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
|
||||||
nsh_output(vtbl, " ----");
|
|
||||||
#endif
|
|
||||||
nsh_output(vtbl, "\n");
|
|
||||||
#endif /* CONFIG_NET_TCP */
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define net_statistics(vtbl)
|
# define net_statistics(vtbl)
|
||||||
|
Loading…
Reference in New Issue
Block a user