From c1dd8442aac6cadb29110f763f23cafc63135a79 Mon Sep 17 00:00:00 2001 From: Anton Danilov Date: Thu, 28 Aug 2014 10:11:31 +0400 Subject: libipset: Add userspace code for the skbinfo extension support. Add userspace code to support of the skbinfo extension independly of set types. Defines constants, flag and function for print/parse/send/recieve of skbinfo parameters. Signed-off-by: Anton Danilov Signed-off-by: Jozsef Kadlecsik --- lib/print.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'lib/print.c') diff --git a/lib/print.c b/lib/print.c index a7abdcf..7f42434 100644 --- a/lib/print.c +++ b/lib/print.c @@ -596,6 +596,55 @@ int ipset_print_comment(char *buf, unsigned int len, return offset; } +int +ipset_print_skbmark(char *buf, unsigned int len, + const struct ipset_data *data, enum ipset_opt opt, + uint8_t env UNUSED) +{ + int size, offset = 0; + const uint64_t *skbmark; + uint32_t mark, mask; + + assert(buf); + assert(len > 0); + assert(data); + assert(opt == IPSET_OPT_SKBMARK); + + skbmark = ipset_data_get(data, IPSET_OPT_SKBMARK); + assert(skbmark); + mark = *skbmark >> 32; + mask = *skbmark & 0xffffffff; + if (mask == 0xffffffff) + size = snprintf(buf + offset, len, "0x%"PRIx32, mark); + else + size = snprintf(buf + offset, len, + "0x%"PRIx32"/0x%"PRIx32, mark, mask); + SNPRINTF_FAILURE(size, len, offset); + return offset; +} + +int +ipset_print_skbprio(char *buf, unsigned int len, + const struct ipset_data *data, enum ipset_opt opt, + uint8_t env UNUSED) +{ + int size, offset = 0; + const uint32_t *skbprio; + + assert(buf); + assert(len > 0); + assert(data); + assert(opt == IPSET_OPT_SKBPRIO); + + skbprio = ipset_data_get(data, opt); + assert(skbprio); + size = snprintf(buf + offset, len, "%x:%x", + *skbprio >> 16, *skbprio & 0xffff); + SNPRINTF_FAILURE(size, len, offset); + return offset; +} + + /** * ipset_print_proto - print protocol name * @buf: printing buffer -- cgit v1.2.3