From e1cc3d782f3bca89c8d8f2ca6b0fd7885fc91cf8 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 22 Sep 2013 20:56:35 +0200 Subject: ipset: Support comments in the userspace library. This adds support to the userspace portion of ipset for handling ipsets with the comment extension enabled. The library revision has been raised accordingly. Signed-off-by: Oliver Smith Signed-off-by: Jozsef Kadlecsik --- lib/print.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib/print.c') diff --git a/lib/print.c b/lib/print.c index 86a7674..abdfd34 100644 --- a/lib/print.c +++ b/lib/print.c @@ -529,6 +529,37 @@ ipset_print_iface(char *buf, unsigned int len, return offset; } +/** + * ipset_print_comment - print arbitrary parameter string + * @buf: printing buffer + * @len: length of available buffer space + * @data: data blob + * @opt: the option kind + * @env: environment flags + * + * Print arbitrary string to output buffer. + * + * Return length of printed string or error size. + */ +int ipset_print_comment(char *buf, unsigned int len, + const struct ipset_data *data, enum ipset_opt opt, + uint8_t env UNUSED) +{ + const char *comment; + int size, offset = 0; + + assert(buf); + assert(len > 0); + assert(data); + assert(opt == IPSET_OPT_ADT_COMMENT); + + comment = ipset_data_get(data, opt); + assert(comment); + size = snprintf(buf + offset, len, "\"%s\"", comment); + SNPRINTF_FAILURE(size, len, offset); + return offset; +} + /** * ipset_print_proto - print protocol name * @buf: printing buffer -- cgit v1.2.3