From eb6854e080f99d34f372c0fbe11efda3eba3d9c0 Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=rusty/emailAddress=rusty@netfilter.org" Date: Thu, 16 Dec 2004 14:22:23 +0000 Subject: Make "is_same" test basics and entries only: targets are generic. Make target testing aware of different kinds of rules. Change reverse logic: target_different now target_same. Set type to MODULE in iptcc_map_target. Add testcase for this. --- libiptc/libip6tc.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'libiptc/libip6tc.c') diff --git a/libiptc/libip6tc.c b/libiptc/libip6tc.c index c915ccb..06b15fb 100644 --- a/libiptc/libip6tc.c +++ b/libiptc/libip6tc.c @@ -214,12 +214,11 @@ dump_entry(struct ip6t_entry *e, const ip6tc_handle_t handle) return 0; } -static int +static unsigned char * is_same(const STRUCT_ENTRY *a, const STRUCT_ENTRY *b, unsigned char *matchmask) { unsigned int i; - STRUCT_ENTRY_TARGET *ta, *tb; unsigned char *mptr; /* Always compare head structures: ignore mask here. */ @@ -231,43 +230,31 @@ is_same(const STRUCT_ENTRY *a, const STRUCT_ENTRY *b, || a->ipv6.tos != b->ipv6.tos || a->ipv6.flags != b->ipv6.flags || a->ipv6.invflags != b->ipv6.invflags) - return 0; + return NULL; for (i = 0; i < IFNAMSIZ; i++) { if (a->ipv6.iniface_mask[i] != b->ipv6.iniface_mask[i]) - return 0; + return NULL; if ((a->ipv6.iniface[i] & a->ipv6.iniface_mask[i]) != (b->ipv6.iniface[i] & b->ipv6.iniface_mask[i])) - return 0; + return NULL; if (a->ipv6.outiface_mask[i] != b->ipv6.outiface_mask[i]) - return 0; + return NULL; if ((a->ipv6.outiface[i] & a->ipv6.outiface_mask[i]) != (b->ipv6.outiface[i] & b->ipv6.outiface_mask[i])) - return 0; + return NULL; } if (a->nfcache != b->nfcache || a->target_offset != b->target_offset || a->next_offset != b->next_offset) - return 0; + return NULL; mptr = matchmask + sizeof(STRUCT_ENTRY); if (IP6T_MATCH_ITERATE(a, match_different, a->elems, b->elems, &mptr)) - return 0; - - ta = GET_TARGET((STRUCT_ENTRY *)a); - tb = GET_TARGET((STRUCT_ENTRY *)b); - if (ta->u.target_size != tb->u.target_size) - return 0; - if (strcmp(ta->u.user.name, tb->u.user.name) != 0) - return 0; - mptr += sizeof(*ta); - - if (target_different(ta->data, tb->data, - ta->u.target_size - sizeof(*ta), mptr)) - return 0; + return NULL; - return 1; + return mptr; } /* All zeroes == unconditional rule. */ -- cgit v1.2.3