summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2007-11-06 09:19:59 +0000
committerGuy Harris <guy@alum.mit.edu>2007-11-06 09:19:59 +0000
commitd913f45ef132ff0823900e9202ec5831348c0148 (patch)
tree2cd5deef26461c1385c10af7837f9a7866762ef9
parent69ba6c776216548752169437b4751bd70c6a9b8a (diff)
downloadwireshark-d913f45ef132ff0823900e9202ec5831348c0148.tar.gz
Fix bug 1956 - make the bitwise-AND routine treat its arguments as being
IPv4 addresses. Also, rename that routine to cmp_bitwise_and(), as it's not working on bit strings. svn path=/trunk/; revision=23375
-rw-r--r--epan/ftypes/ftype-ipv4.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index 789f80676f..ff3aec15c9 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -168,25 +168,15 @@ cmp_le(fvalue_t *a, fvalue_t *b)
return ipv4_addr_le(&a->value.ipv4, &b->value.ipv4);
}
-static gboolean cmp_bytes_bitwise_and(fvalue_t *fv_a, fvalue_t *fv_b)
+static gboolean
+cmp_bitwise_and(fvalue_t *fv_a, fvalue_t *fv_b)
{
- GByteArray *a = fv_a->value.bytes;
- GByteArray *b = fv_b->value.bytes;
- guint i = 0;
- unsigned char *p_a, *p_b;
+ guint32 addr_a;
+ guint32 addr_b;
- if (b->len != a->len) {
- return FALSE;
- }
- p_a = a->data;
- p_b = b->data;
- while (i < b->len) {
- if (p_a[i] & p_b[i])
- i++;
- else
- return FALSE;
- }
- return TRUE;
+ addr_a = fv_a->value.ipv4.addr & fv_a->value.ipv4.nmask;
+ addr_b = fv_b->value.ipv4.addr & fv_b->value.ipv4.nmask;
+ return ((addr_a & addr_b) != 0);
}
void
@@ -223,7 +213,7 @@ ftype_register_ipv4(void)
cmp_ge,
cmp_lt,
cmp_le,
- cmp_bytes_bitwise_and,
+ cmp_bitwise_and,
NULL, /* cmp_contains */
NULL, /* cmp_matches */