path: root/include/libipset/utils.h
diff options
authorEric B Munson <>2015-05-29 11:36:25 -0400
committerJozsef Kadlecsik <>2015-06-19 23:30:06 +0200
commiteb9af8fe6d4776242fea84f5228b46d903539146 (patch)
treed7578d91c40b1c228ddf7e354683362e7042e7c3 /include/libipset/utils.h
parent01a13aa4fe0cb668fc535d38d6f9383433923874 (diff)
Add element count to hash headers
It would be useful for userspace to query the size of an ipset hash, however, this data is not exposed to userspace outside of counting the number of member entries. This patch uses the attribute IPSET_ATTR_ELEMENTS to indicate the size in the the header that is exported to userspace. This field is then printed by the userspace tool for hashes. Because it is only meaningful for hashes to report their size, the output is conditional on the set type. To do this checking the MATCH_TYPENAME macro was moved to utils.h. The bulk of this patch changes the expected test suite to account for the change in output. Signed-off-by: Eric B Munson <> Cc: Pablo Neira Ayuso <> Cc: Josh Hunt <> Cc: Signed-off-by: Jozsef Kadlecsik <>
Diffstat (limited to 'include/libipset/utils.h')
1 files changed, 3 insertions, 0 deletions
diff --git a/include/libipset/utils.h b/include/libipset/utils.h
index 3cd29da..ceedd45 100644
--- a/include/libipset/utils.h
+++ b/include/libipset/utils.h
@@ -19,6 +19,9 @@
#define STRCASEQ(a, b) (strcasecmp(a, b) == 0)
#define STRNCASEQ(a, b, n) (strncasecmp(a, b, n) == 0)
+/* Match set type names */
+#define MATCH_TYPENAME(a, b) STRNEQ(a, b, strlen(b))
/* Stringify tokens */
#define _STR(c) #c
#define STR(c) _STR(c)