From 5a6021823aa0da24b83f8d03f46ad4202f149fa3 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Tue, 9 Apr 2013 17:17:00 +0200 Subject: Support counters in the ipset library Signed-off-by: Jozsef Kadlecsik --- lib/parse.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/parse.c') diff --git a/lib/parse.c b/lib/parse.c index 679aefc..0058369 100644 --- a/lib/parse.c +++ b/lib/parse.c @@ -1478,6 +1478,34 @@ ipset_parse_after(struct ipset_session *session, return ipset_data_set(data, opt, str); } +/** + * ipset_parse_uint64 - parse string as an unsigned long integer + * @session: session structure + * @opt: option kind of the data + * @str: string to parse + * + * Parse string as an unsigned long integer number. + * The value is stored in the data blob of the session. + * + * Returns 0 on success or a negative error code. + */ +int +ipset_parse_uint64(struct ipset_session *session, + enum ipset_opt opt, const char *str) +{ + unsigned long long value = 0; + int err; + + assert(session); + assert(str); + + err = string_to_number_ll(session, str, 0, ULLONG_MAX - 1, &value); + if (err) + return err; + + return ipset_session_data_set(session, opt, &value); +} + /** * ipset_parse_uint32 - parse string as an unsigned integer * @session: session structure -- cgit v1.2.3