Networking: Clean up network status collection and presentation for IPv6
This commit is contained in:
parent
96a53254dd
commit
f4bb7f14e1
@ -174,6 +174,38 @@ struct ipv6_hdr_s
|
||||
};
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct ipv4_stats_s
|
||||
{
|
||||
net_stats_t drop; /* Number of dropped packets at the IP layer */
|
||||
net_stats_t recv; /* Number of received packets at the IP layer */
|
||||
net_stats_t sent; /* Number of sent packets at the IP layer */
|
||||
net_stats_t vhlerr; /* Number of packets dropped due to wrong
|
||||
IP version or header length */
|
||||
net_stats_t fragerr; /* Number of packets dropped since they
|
||||
were IP fragments */
|
||||
net_stats_t chkerr; /* Number of packets dropped due to IP
|
||||
checksum errors */
|
||||
net_stats_t protoerr; /* Number of packets dropped since they
|
||||
were neither ICMP, UDP nor TCP */
|
||||
};
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct ipv6_stats_s
|
||||
{
|
||||
net_stats_t drop; /* Number of dropped packets at the IP layer */
|
||||
net_stats_t recv; /* Number of received packets at the IP layer */
|
||||
net_stats_t sent; /* Number of sent packets at the IP layer */
|
||||
net_stats_t vhlerr; /* Number of packets dropped due to wrong
|
||||
IP version or header length */
|
||||
net_stats_t protoerr; /* Number of packets dropped since they
|
||||
were neither ICMP, UDP nor TCP */
|
||||
};
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
#endif /* CONFIG_NET_STATISTICS */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
@ -50,6 +50,7 @@
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
|
||||
#include <nuttx/net/ip.h>
|
||||
#ifdef CONFIG_NET_TCP
|
||||
# include <nuttx/net/tcp.h>
|
||||
#endif
|
||||
@ -66,6 +67,8 @@
|
||||
# include <nuttx/net/igmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@ -74,33 +77,19 @@
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The structure holding the uIP statistics that are gathered if
|
||||
/* The structure holding the networking statistics that are gathered if
|
||||
* CONFIG_NET_STATISTICS is defined.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
struct ip_stats_s
|
||||
{
|
||||
net_stats_t drop; /* Number of dropped packets at the IP layer */
|
||||
net_stats_t recv; /* Number of received packets at the IP layer */
|
||||
net_stats_t sent; /* Number of sent packets at the IP layer */
|
||||
net_stats_t vhlerr; /* Number of packets dropped due to wrong
|
||||
IP version or header length */
|
||||
net_stats_t hblenerr; /* Number of packets dropped due to wrong
|
||||
IP length, high byte */
|
||||
net_stats_t lblenerr; /* Number of packets dropped due to wrong
|
||||
IP length, low byte */
|
||||
net_stats_t fragerr; /* Number of packets dropped since they
|
||||
were IP fragments */
|
||||
net_stats_t chkerr; /* Number of packets dropped due to IP
|
||||
checksum errors */
|
||||
net_stats_t protoerr; /* Number of packets dropped since they
|
||||
were neither ICMP, UDP nor TCP */
|
||||
};
|
||||
|
||||
struct net_stats_s
|
||||
{
|
||||
struct ip_stats_s ip; /* IP statistics */
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
struct ipv4_stats_s ipv4; /* IPv4 statistics */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct ipv6_stats_s ipv6; /* IPv6 statistics */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_ICMP
|
||||
struct icmp_stats_s icmp; /* ICMP statistics */
|
||||
@ -122,7 +111,6 @@ struct net_stats_s
|
||||
struct udp_stats_s udp; /* UDP statistics */
|
||||
#endif
|
||||
};
|
||||
#endif /* CONFIG_NET_STATISTICS */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -130,12 +118,11 @@ struct net_stats_s
|
||||
|
||||
/* This is the structure in which the statistics are gathered. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
extern struct net_stats_s g_netstats;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* CONFIG_NET_STATISTICS */
|
||||
#endif /* __INCLUDE_NUTTX_NET_NETSTATS_H */
|
||||
|
@ -321,7 +321,7 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
/* This is where the input processing starts. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.recv++;
|
||||
g_netstats.ipv4.recv++;
|
||||
#endif
|
||||
|
||||
/* Start of IP input header processing code. */
|
||||
@ -332,8 +332,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
/* IP version and header length. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ip.vhlerr++;
|
||||
g_netstats.ipv4.drop++;
|
||||
g_netstats.ipv4.vhlerr++;
|
||||
#endif
|
||||
nlldbg("Invalid IP version or header length: %02x\n", pbuf->vhl);
|
||||
goto drop;
|
||||
@ -369,8 +369,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
}
|
||||
#else /* CONFIG_NET_TCP_REASSEMBLY */
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ip.fragerr++;
|
||||
g_netstats.ipv4.drop++;
|
||||
g_netstats.ipv4.fragerr++;
|
||||
#endif
|
||||
nlldbg("IP fragment dropped\n");
|
||||
goto drop;
|
||||
@ -435,7 +435,7 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ipv4.drop++;
|
||||
#endif
|
||||
goto drop;
|
||||
}
|
||||
@ -447,8 +447,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
/* Compute and check the IP header checksum. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ip.chkerr++;
|
||||
g_netstats.ipv4.drop++;
|
||||
g_netstats.ipv4.chkerr++;
|
||||
#endif
|
||||
nlldbg("Bad IP checksum\n");
|
||||
goto drop;
|
||||
@ -494,8 +494,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
||||
|
||||
default: /* Unrecognized/unsupported protocol */
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ip.protoerr++;
|
||||
g_netstats.ipv4.drop++;
|
||||
g_netstats.ipv4.protoerr++;
|
||||
#endif
|
||||
|
||||
nlldbg("Unrecognized IP protocol\n");
|
||||
|
@ -147,7 +147,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
||||
/* This is where the input processing starts. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.recv++;
|
||||
g_netstats.ipv6.recv++;
|
||||
#endif
|
||||
|
||||
/* Start of IP input header processing code. */
|
||||
@ -158,8 +158,8 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
||||
/* IP version and header length. */
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ip.vhlerr++;
|
||||
g_netstats.ipv6.drop++;
|
||||
g_netstats.ipv6.vhlerr++;
|
||||
#endif
|
||||
|
||||
nlldbg("Invalid IPv6 version: %d\n", ipv6->vtc >> 4);
|
||||
@ -245,7 +245,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
||||
ipv6->destipaddr[0] != HTONS(0xff02))
|
||||
{
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ipv6.drop++;
|
||||
#endif
|
||||
goto drop;
|
||||
}
|
||||
@ -283,8 +283,8 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
||||
|
||||
default: /* Unrecognized/unsupported protocol */
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ip.drop++;
|
||||
g_netstats.ip.protoerr++;
|
||||
g_netstats.ipv6.drop++;
|
||||
g_netstats.ipv6.protoerr++;
|
||||
#endif
|
||||
|
||||
nlldbg("Unrecognized IP protocol: %04x\n", ipv6->proto);
|
||||
|
@ -173,7 +173,7 @@ void icmp_input(FAR struct net_driver_s *dev)
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmp.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
g_netstats.ipv4.sent++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ void icmp_send(FAR struct net_driver_s *dev, FAR in_addr_t *destaddr)
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmp.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
g_netstats.ipv4.sent++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ void icmpv6_input(FAR struct net_driver_s *dev)
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmpv6.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
g_netstats.ipv6.sent++;
|
||||
#endif
|
||||
return;
|
||||
|
||||
|
@ -229,7 +229,7 @@ static void icmpv6_echo_request(FAR struct net_driver_s *dev,
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmpv6.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
g_netstats.ipv6.sent++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void icmpv6_send(FAR struct net_driver_s *dev, FAR net_ipv6addr_t *destaddr)
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmpv6.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
g_netstats.ipv6.sent++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev,
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmpv6.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
g_netstats.ipv6.sent++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* net/igmp/igmp_send.c
|
||||
*
|
||||
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2010, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -175,7 +175,7 @@ void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
||||
IGMPBUF->chksum = ~igmp_chksum(&IGMPBUF->type, IPIGMP_HDRLEN);
|
||||
|
||||
IGMP_STATINCR(g_netstats.igmp.poll_send);
|
||||
IGMP_STATINCR(g_netstats.ip.sent);
|
||||
IGMP_STATINCR(g_netstats.ipv4.sent);
|
||||
|
||||
nllvdbg("Outgoing IGMP packet length: %d (%d)\n",
|
||||
dev->d_len, (IGMPBUF->len[0] << 8) | IGMPBUF->len[1]);
|
||||
|
@ -176,6 +176,10 @@ static inline void tcp_ipv4_sendcomplete(FAR struct net_driver_s *dev,
|
||||
ipv4->ipchksum = ~ipv4_chksum(dev);
|
||||
|
||||
nllvdbg("IPv4 length: %d\n", ((int)ipv4->len[0] << 8) + ipv4->len[1]);
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ipv4.sent++;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
@ -235,6 +239,10 @@ static inline void tcp_ipv6_sendcomplete(FAR struct net_driver_s *dev,
|
||||
ipv6->flow = 0x00;
|
||||
|
||||
nllvdbg("IPv6 length: %d\n", ((int)ipv6->len[0] << 8) + ipv6->len[1]);
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ipv6.sent++;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
@ -281,7 +289,6 @@ static void tcp_sendcomplete(FAR struct net_driver_s *dev,
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.tcp.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,10 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
|
||||
|
||||
ipv4->ipchksum = 0;
|
||||
ipv4->ipchksum = ~ipv4_chksum(dev);
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ipv4.sent++;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
@ -198,6 +202,10 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
|
||||
*/
|
||||
|
||||
dev->d_len += IPv6_HDRLEN;
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.ipv6.sent++;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
@ -239,7 +247,6 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.udp.sent++;
|
||||
g_netstats.ip.sent++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user