summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2015-06-25 09:29:20 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2015-06-25 09:29:20 +0200
commit0c7e18edb07ed205e7087b73a85fa692f45003ab (patch)
tree4455fd109bcdd539e47234e74ce158b0269f213d /lib
parenteb9af8fe6d4776242fea84f5228b46d903539146 (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/errcode.c3
-rw-r--r--lib/session.c4
2 files changed, 5 insertions, 2 deletions
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, "</memsize>\n<references>");
safe_dprintf(session, ipset_print_number, IPSET_OPT_REFERENCES);
safe_snprintf(session, "</references>\n");
- if (MATCH_TYPENAME(type->name , "hash:")) {
+ if (ipset_data_test(data, IPSET_OPT_ELEMENTS)) {
safe_snprintf(session, "<numentries>");
safe_dprintf(session, ipset_print_number, IPSET_OPT_ELEMENTS);
safe_snprintf(session, "</numentries>\n");