diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2015-01-29 01:12:12 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-02-02 17:22:47 (GMT) |
commit | e75a1c373ad447ddf376b77f36c8e4ef039de3b5 (patch) | |
tree | 2510a25f4cba7a7ca4ce014b11c45a17694cc6bc /lib/route/tc.c | |
parent | c2151e8b7d66924aab0a5e71e958b280e1b4e216 (diff) | |
download | libnl-e75a1c373ad447ddf376b77f36c8e4ef039de3b5.zip libnl-e75a1c373ad447ddf376b77f36c8e4ef039de3b5.tar.gz libnl-e75a1c373ad447ddf376b77f36c8e4ef039de3b5.tar.bz2 |
route/tc: add rtnl_tc_stat2str() and rtnl_tc_str2stat()
[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>
Diffstat (limited to 'lib/route/tc.c')
-rw-r--r-- | lib/route/tc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/route/tc.c b/lib/route/tc.c index 1dcb986..b24c06e 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -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. |