Print some details of the interface statistics
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 30 Nov 2009 00:17:42 +0000 (01:17 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 30 Nov 2009 00:17:42 +0000 (01:17 +0100)
src/rtnl.c

index 6d2efa2..455a259 100644 (file)
@@ -242,6 +242,7 @@ static const char *operstate2str(unsigned char operstate)
 static void extract_link(struct ifinfomsg *msg, int bytes,
                                const char **ifname, unsigned char *operstate)
 {
+       struct rtnl_link_stats stats;
        struct rtattr *attr;
 
        for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
@@ -257,6 +258,14 @@ static void extract_link(struct ifinfomsg *msg, int bytes,
                        break;
                case IFLA_LINKMODE:
                        break;
+               case IFLA_STATS:
+                       memcpy(&stats, RTA_DATA(attr),
+                                       sizeof(struct rtnl_link_stats));
+                       connman_info("%s {RX} %d packets %d bytes", *ifname,
+                                       stats.rx_packets, stats.rx_bytes);
+                       connman_info("%s {TX} %d packets %d bytes", *ifname,
+                                       stats.tx_packets, stats.tx_bytes);
+                       break;
                }
        }
 }