summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2013-12-13 15:24:50 -0800
committerThomas Haller <thaller@redhat.com>2013-12-17 18:14:10 +0200
commitd7aca17701519240bd69c0c6f7d55d0a09ce9346 (patch)
treef8efcb317947f6d9b8477e9f36e53a87526581b1 /lib
parentbc717a9bfcac70eead2d04e6978d136166294d34 (diff)
downloadlibnl-d7aca17701519240bd69c0c6f7d55d0a09ce9346.tar.gz
u32: add rtnl_u32_get_key()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Cc: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/route/cls/u32.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c
index e79ec9be..567fab99 100644
--- a/lib/route/cls/u32.c
+++ b/lib/route/cls/u32.c
@@ -570,6 +570,42 @@ int rtnl_u32_add_key(struct rtnl_cls *cls, uint32_t val, uint32_t mask,
return 0;
}
+/**
+ * Get the 32-bit key from the selector
+ *
+ * @arg cls classifier to be retrieve
+ * @arg index the index of the array of keys, start with 0
+ * @arg val pointer to store value after masked (network byte-order)
+ * @arg mask pointer to store the mask (network byte-order)
+ * @arg off pointer to store the offset
+ * @arg offmask pointer to store offset mask
+ *
+*/
+int rtnl_u32_get_key(struct rtnl_cls *cls, uint8_t index,
+ uint32_t *val, uint32_t *mask, int *off, int *offmask)
+{
+ struct tc_u32_sel *sel;
+ struct rtnl_u32 *u;
+
+ if (!(u = rtnl_tc_data(TC_CAST(cls))))
+ return -NLE_NOMEM;
+
+ if (!(u->cu_mask & U32_ATTR_SELECTOR))
+ return -NLE_INVAL;
+
+ /* the selector might have been moved by realloc */
+ sel = u32_selector(u);
+ if (index >= sel->nkeys)
+ return -NLE_RANGE;
+
+ *mask = sel->keys[index].mask;
+ *val = sel->keys[index].val;
+ *off = sel->keys[index].off;
+ *offmask = sel->keys[index].offmask;
+ return 0;
+}
+
+
int rtnl_u32_add_key_uint8(struct rtnl_cls *cls, uint8_t val, uint8_t mask,
int off, int offmask)
{