summaryrefslogtreecommitdiffstats
path: root/libiptc/libip4tc.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2004-12-16 14:22:23 +0000
committerRusty Russell <rusty@rustcorp.com.au>2004-12-16 14:22:23 +0000
commit733e54b8250576d6a1e0ab5621ef5b144abdf018 (patch)
treeae7f8ab8585713ff52be052e1a3b63aca185ec04 /libiptc/libip4tc.c
parente45c71321e77735a1d66b180f8a29bea33aeb1b0 (diff)
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.
Diffstat (limited to 'libiptc/libip4tc.c')
-rw-r--r--libiptc/libip4tc.c31
1 files changed, 9 insertions, 22 deletions
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