net: icmp: Update ICMP statistics for every ICMP packet

Update statistics for every sent, received and dropped
ICMPv{4|6} packet.

Change-Id: Ibe6f02e8222adb3db1f1dbd0cde1ed251710eb43
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-03-15 11:02:26 +02:00
parent d233f91388
commit 8ae7bb257f
2 changed files with 8 additions and 1 deletions

View file

@ -167,11 +167,15 @@ enum net_verdict net_icmpv4_input(struct net_buf *buf, uint16_t len,
ARG_UNUSED(code);
ARG_UNUSED(len);
net_stats_update_icmp_recv();
switch (type) {
case NET_ICMPV4_ECHO_REQUEST:
return handle_echo_request(buf);
}
net_stats_update_icmp_drop();
return NET_DROP;
}

View file

@ -388,13 +388,16 @@ enum net_verdict net_icmpv6_input(struct net_buf *buf,
{
struct net_icmpv6_handler *cb;
net_stats_update_icmp_recv();
SYS_SLIST_FOR_EACH_CONTAINER(&handlers, cb, node) {
if (cb->type == type && (cb->code == code || cb->code == 0)) {
net_stats_update_icmp_recv();
return cb->handler(buf);
}
}
net_stats_update_icmp_drop();
return NET_DROP;
}