summaryrefslogtreecommitdiffstats
path: root/lib/types.c
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2010-10-24 21:42:48 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2010-10-24 21:42:48 +0200
commit0d32c5c070f817229110f92d7b31df9a3e4eeec5 (patch)
tree5ee04a9e03de32d2029ad0d708811e382ca922d1 /lib/types.c
parent62a3d29539aa109fed1c8a20d63ef95948b13842 (diff)
Fixes, cleanups, commentsv5.0-pre8
- More comments added to the code - ICMP and ICMPv6 support added to the hash:ip,port, hash:ip,port,ip and hash:ip,port,net types - hash:net and hash:ip,port,net types are reworked - hash:net,port type added - Wrong direction parameters fixed in hash:ip,port - Helps and manpage are updated - More tests added - Ugly macros are rewritten to functions in parse.c (Holger Eitzenberger) - resize related bug in hash types fixed (Holger Eitzenberger) - autoreconf patches by Jan Engelhardt applied - netlink patch minimalized: dumping can be initialized by a second parsing of the message (thanks to David and Patrick for the suggestion) - IPv4/IPv6 address attributes are introduced in order to fix the context (suggested by David)
Diffstat (limited to 'lib/types.c')
-rw-r--r--lib/types.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/types.c b/lib/types.c
index e3cad35..3d9b034 100644
--- a/lib/types.c
+++ b/lib/types.c
@@ -11,6 +11,7 @@
#include <sys/socket.h> /* AF_ */
#include <stdlib.h> /* malloc, free */
#include <stdio.h> /* FIXME: debug */
+#include <libmnl/libmnl.h> /* MNL_ALIGN */
#include <libipset/debug.h> /* D() */
#include <libipset/data.h> /* ipset_data_* */
@@ -438,14 +439,25 @@ type_max_size(struct ipset_type *type, uint8_t family)
continue;
if (!(IPSET_FLAG(opt) & type->full[IPSET_ADD]))
continue;
- max += ipset_data_sizeof(opt, family);
+ max += MNL_ALIGN(ipset_data_sizeof(opt, family))
+ + MNL_ATTR_HDRLEN;
+ switch (opt) {
+ case IPSET_OPT_IP:
+ case IPSET_OPT_IP_TO:
+ case IPSET_OPT_IP2:
+ /* Nested attributes */
+ max += MNL_ATTR_HDRLEN;
+ break;
+ default:
+ break;
+ }
}
type->maxsize[sizeid] = max;
}
/**
* ipset_type_add - add (register) a userspace set type
- * @type: set type structure
+ * @type: pointer to the set type structure
*
* Add the given set type to the type list. The types
* are added sorted, in descending revision number.