diff options
author | Thomas Graf <tgraf@suug.ch> | 2011-06-09 12:28:04 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2011-06-09 12:28:04 +0200 |
commit | ed69b2a79b8e0b71c230b5e75626aa620a0d5ff9 (patch) | |
tree | 569eb67c3b3518108ffc393f8f7f416b8bf78bcb /lib/route/tc.c | |
parent | 4cb1666fe19f71c09628615a1c4b6f822b7cd8de (diff) | |
download | libnl-ed69b2a79b8e0b71c230b5e75626aa620a0d5ff9.tar.gz |
Add rtnl_tc_data_check()
Behaves like rtnl_tc_data() but verifies that the traffic control
object is of the expected type.
Diffstat (limited to 'lib/route/tc.c')
-rw-r--r-- | lib/route/tc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/route/tc.c b/lib/route/tc.c index da8c75f..983555a 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -1010,6 +1010,21 @@ void *rtnl_tc_data(struct rtnl_tc *tc) return nl_data_get(tc->tc_subdata); } +void *rtnl_tc_data_check(struct rtnl_tc *tc, struct rtnl_tc_ops *ops) +{ + if (tc->tc_ops != ops) { + char buf[64]; + + snprintf(buf, sizeof(buf), + "tc object %p used in %s context but is of type %s", + tc, ops->to_kind, tc->tc_ops->to_kind); + + return NULL; + } + + return rtnl_tc_data(tc); +} + void rtnl_tc_type_register(struct rtnl_tc_type_ops *ops) { if (ops->tt_type > RTNL_TC_TYPE_MAX) |