From 733e54b8250576d6a1e0ab5621ef5b144abdf018 Mon Sep 17 00:00:00 2001 From: Rusty Russell 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/libip4tc.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'libiptc/libip4tc.c') diff --git a/libiptc/libip4tc.c b/libiptc/libip4tc.c index 399d5910..f623c78c 100644 --- a/libiptc/libip4tc.c +++ b/libiptc/libip4tc.c @@ -184,11 +184,10 @@ dump_entry(STRUCT_ENTRY *e, const TC_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. */ @@ -199,43 +198,31 @@ is_same(const STRUCT_ENTRY *a, const STRUCT_ENTRY *b, unsigned char *matchmask) || a->ip.proto != b->ip.proto || a->ip.flags != b->ip.flags || a->ip.invflags != b->ip.invflags) - return 0; + return NULL; for (i = 0; i < IFNAMSIZ; i++) { if (a->ip.iniface_mask[i] != b->ip.iniface_mask[i]) - return 0; + return NULL; if ((a->ip.iniface[i] & a->ip.iniface_mask[i]) != (b->ip.iniface[i] & b->ip.iniface_mask[i])) - return 0; + return NULL; if (a->ip.outiface_mask[i] != b->ip.outiface_mask[i]) - return 0; + return NULL; if ((a->ip.outiface[i] & a->ip.outiface_mask[i]) != (b->ip.outiface[i] & b->ip.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 (IPT_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; } #if 0 -- cgit v1.2.3