From 0c7e18edb07ed205e7087b73a85fa692f45003ab Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 25 Jun 2015 09:29:20 +0200 Subject: Add element count to all set types header It is better to list the set elements for all set types, thus the header information is uniform. Element counts are therefore added to the bitmap and list types. --- lib/errcode.c | 3 +++ lib/session.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/errcode.c b/lib/errcode.c index 3881121..60220c7 100644 --- a/lib/errcode.c +++ b/lib/errcode.c @@ -148,6 +148,9 @@ static const struct ipset_errcode_table list_errcode_table[] = { { }, }; +/* Match set type names */ +#define MATCH_TYPENAME(a, b) STRNEQ(a, b, strlen(b)) + /** * ipset_errcode - interpret a kernel error code * @session: session structure diff --git a/lib/session.c b/lib/session.c index 2650755..95c253e 100644 --- a/lib/session.c +++ b/lib/session.c @@ -931,7 +931,7 @@ list_create(struct ipset_session *session, struct nlattr *nla[]) safe_dprintf(session, ipset_print_number, IPSET_OPT_MEMSIZE); safe_snprintf(session, "\nReferences: "); safe_dprintf(session, ipset_print_number, IPSET_OPT_REFERENCES); - if (MATCH_TYPENAME(type->name , "hash:")) { + if (ipset_data_test(data, IPSET_OPT_ELEMENTS)) { safe_snprintf(session, "\nNumber of entries: "); safe_dprintf(session, ipset_print_number, IPSET_OPT_ELEMENTS); } @@ -945,7 +945,7 @@ list_create(struct ipset_session *session, struct nlattr *nla[]) safe_snprintf(session, "\n"); safe_dprintf(session, ipset_print_number, IPSET_OPT_REFERENCES); safe_snprintf(session, "\n"); - if (MATCH_TYPENAME(type->name , "hash:")) { + if (ipset_data_test(data, IPSET_OPT_ELEMENTS)) { safe_snprintf(session, ""); safe_dprintf(session, ipset_print_number, IPSET_OPT_ELEMENTS); safe_snprintf(session, "\n"); -- cgit v1.2.3