From 55f27c40e892a625253aa4a6ca589b55aeb7c41e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 21 Aug 2017 09:31:12 -0600 Subject: [PATCH] Add support for network procfs statistics when Nothing is enabled but PF_IEEE802154. --- net/procfs/net_statistics.c | 14 +++++++++++ net/procfs/netdev_statistics.c | 45 +++++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/net/procfs/net_statistics.c b/net/procfs/net_statistics.c index 0ceac8ecfb..288ec35c03 100644 --- a/net/procfs/net_statistics.c +++ b/net/procfs/net_statistics.c @@ -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 */ diff --git a/net/procfs/netdev_statistics.c b/net/procfs/netdev_statistics.c index 0ec04f0947..7bec6340cb 100644 --- a/net/procfs/netdev_statistics.c +++ b/net/procfs/netdev_statistics.c @@ -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 ****************************************************************************/