Add support for network procfs statistics when Nothing is enabled but PF_IEEE802154.

This commit is contained in:
Gregory Nutt 2017-08-21 09:31:12 -06:00
parent 77534e2b49
commit 55f27c40e8
2 changed files with 47 additions and 12 deletions

View File

@ -51,6 +51,10 @@
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
!defined(CONFIG_FS_PROCFS_EXCLUDE_NET) && defined(CONFIG_NET_STATISTICS)
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6) || \
defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP) || \
defined(CONFIG_NET_ICMP) || defined(CONFIG_NET_ICMPv6)
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@ -459,5 +463,15 @@ ssize_t netprocfs_read_netstats(FAR struct netprocfs_file_s *priv,
return netprocfs_read_linegen(priv, buffer, buflen, g_stat_linegen, NSTAT_LINES);
}
#else
ssize_t netprocfs_read_netstats(FAR struct netprocfs_file_s *priv,
FAR char *buffer, size_t buflen)
{
return OK;
}
#endif /* CONFIG_NET_IPv4 || CONFIG_NET_IPv6 || CONFIG_NET_TCP || \
* CONFIG_NET_UDP || CONFIG_NET_ICMP || CONFIG_NET_ICMPv6 */
#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
* !CONFIG_FS_PROCFS_EXCLUDE_NET */

View File

@ -68,6 +68,9 @@ static int netprocfs_inet4addresses(FAR struct netprocfs_file_s *netfile);
static int netprocfs_inet6address(FAR struct netprocfs_file_s *netfile);
static int netprocfs_inet6draddress(FAR struct netprocfs_file_s *netfile);
#endif
#if !defined(CONFIG_NET_IPv4) && !defined(CONFIG_NET_IPv6)
static int netprocfs_blank_line(FAR struct netprocfs_file_s *netfile);
#endif
#ifdef CONFIG_NETDEV_STATISTICS
static int netprocfs_rxstatistics_header(FAR struct netprocfs_file_s *netfile);
static int netprocfs_rxstatistics(FAR struct netprocfs_file_s *netfile);
@ -94,6 +97,10 @@ static const linegen_t g_netstat_linegen[] =
, netprocfs_inet6address
, netprocfs_inet6draddress
#endif
#if !defined(CONFIG_NET_IPv4) && !defined(CONFIG_NET_IPv6)
, netprocfs_blank_line
#endif
#ifdef CONFIG_NETDEV_STATISTICS
, netprocfs_rxstatistics_header,
netprocfs_rxstatistics,
@ -111,8 +118,8 @@ static const linegen_t g_netstat_linegen[] =
* Private Functions
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN
static int netprocfs_6lowpan_linklayer(FAR struct netprocfs_file_s *netfile,
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
static int netprocfs_radio_linklayer(FAR struct netprocfs_file_s *netfile,
int len)
{
FAR struct netdev_varaddr_s *addr;
@ -122,9 +129,15 @@ static int netprocfs_6lowpan_linklayer(FAR struct netprocfs_file_s *netfile,
dev = netfile->dev;
addr = &dev->d_mac.radio;
#ifdef CONFIG_NET_6LOWPAN
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:6LoWPAN HWaddr ",
dev->d_ifname);
#else
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%s\tLink encap:Raw HWaddr ",
dev->d_ifname);
#endif
switch (addr->nv_addrlen)
{
@ -142,17 +155,13 @@ static int netprocfs_6lowpan_linklayer(FAR struct netprocfs_file_s *netfile,
break;
#endif
#if defined(CONFIG_WIRELESS_PKTRADIO) || \
(defined(CONFIG_WIRELESS_IEEE802154) && !defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR))
case 2:
#if defined(CONFIG_WIRELESS_PKTRADIO) || defined(CONFIG_WIRELESS_IEEE802154)
case 2:
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%02x:%02x",
addr->nv_addr[0], addr->nv_addr[1]);
break;
#endif
#if defined(CONFIG_WIRELESS_PKTRADIO) || \
(defined(CONFIG_WIRELESS_IEEE802154) && defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR))
case 8:
len += snprintf(&netfile->line[len], NET_LINELEN - len,
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
@ -210,14 +219,14 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
break;
#endif
#ifdef CONFIG_NET_6LOWPAN
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
case NET_LL_IEEE802154:
case NET_LL_PKTRADIO:
{
len += netprocfs_6lowpan_linklayer(netfile, len);
len += netprocfs_radio_linklayer(netfile, len);
}
break;
#endif /* CONFIG_NET_6LOWPAN */
#endif /* CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154 */
#ifdef CONFIG_NET_LOOPBACK
case NET_LL_LOOPBACK:
@ -349,7 +358,6 @@ static int netprocfs_inet6draddress(FAR struct netprocfs_file_s *netfile)
preflen = net_ipv6_mask2pref(dev->d_ipv6netmask);
/* Show the IPv6 default router address */
if (inet_ntop(AF_INET6, dev->d_ipv6draddr, addrstr, INET6_ADDRSTRLEN))
@ -362,6 +370,19 @@ static int netprocfs_inet6draddress(FAR struct netprocfs_file_s *netfile)
}
#endif
/****************************************************************************
* Name: netprocfs_blank_line
****************************************************************************/
#if !defined(CONFIG_NET_IPv4) && !defined(CONFIG_NET_IPv6)
static int netprocfs_blank_line(FAR struct netprocfs_file_s *netfile)
{
netfile->line[0] = '\n';
netfile->line[1] = '\0';
return 1;
}
#endif
/****************************************************************************
* Name: netprocfs_rxstatistics_header
****************************************************************************/