]> granicus.if.org Git - libnl/commitdiff
route/tc: add rtnl_tc_stat2str() and rtnl_tc_str2stat()
authorCong Wang <xiyou.wangcong@gmail.com>
Thu, 29 Jan 2015 01:12:12 +0000 (17:12 -0800)
committerThomas Haller <thaller@redhat.com>
Mon, 2 Feb 2015 17:22:47 +0000 (18:22 +0100)
[thaller@redhat.com: add symbols to libnl-route-3.sym]

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
include/netlink/route/tc.h
lib/route/tc.c
libnl-route-3.sym

index 870c1f2638de59eb3c8dab137849fc9cc05248a9..f1f0f8d16b770484c3569119d8cb63a46f7cc127 100644 (file)
@@ -97,6 +97,8 @@ extern uint32_t               rtnl_tc_get_parent(struct rtnl_tc *);
 extern int             rtnl_tc_set_kind(struct rtnl_tc *, const char *);
 extern char *          rtnl_tc_get_kind(struct rtnl_tc *);
 extern uint64_t                rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat);
+extern char *          rtnl_tc_stat2str(enum rtnl_tc_stat, char *, size_t);
+extern int             rtnl_tc_str2stat(const char *);
 
 extern int             rtnl_tc_calc_txtime(int, int);
 extern int             rtnl_tc_calc_bufsize(int, int);
index 1dcb9865954e5b1e11c00ffe4a62eced51de8c3d..b24c06eeee9744745580283a0ab60630ca5c8da4 100644 (file)
@@ -564,6 +564,28 @@ uint64_t rtnl_tc_get_stat(struct rtnl_tc *tc, enum rtnl_tc_stat id)
  * @{
  */
 
+static const struct trans_tbl tc_stats[] = {
+       __ADD(RTNL_TC_PACKETS, packets),
+       __ADD(RTNL_TC_BYTES, bytes),
+       __ADD(RTNL_TC_RATE_BPS, rate_bps),
+       __ADD(RTNL_TC_RATE_PPS, rate_pps),
+       __ADD(RTNL_TC_QLEN, qlen),
+       __ADD(RTNL_TC_BACKLOG, backlog),
+       __ADD(RTNL_TC_DROPS, drops),
+       __ADD(RTNL_TC_REQUEUES, requeues),
+       __ADD(RTNL_TC_OVERLIMITS, overlimits),
+};
+
+char *rtnl_tc_stat2str(enum rtnl_tc_stat st, char *buf, size_t len)
+{
+       return __type2str(st, buf, len, tc_stats, ARRAY_SIZE(tc_stats));
+}
+
+int rtnl_tc_str2stat(const char *name)
+{
+       return __str2type(name, tc_stats, ARRAY_SIZE(tc_stats));
+}
+
 /**
  * Calculate time required to transmit buffer at a specific rate
  * @arg bufsize                Size of buffer to be transmited in bytes.
index a0ca051e0522fac4ab02c5e9760202221e3cc08a..2768f055d97391d1a45426903bd51e43d7ee3f08 100644 (file)
@@ -850,6 +850,8 @@ global:
        rtnl_skbedit_set_mark;
        rtnl_skbedit_set_priority;
        rtnl_skbedit_set_queue_mapping;
+       rtnl_tc_stat2str;
+       rtnl_tc_str2stat;
        rtnl_u32_add_mark;
        rtnl_u32_del_mark;
 } libnl_3;