aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes/ftype-ipv4.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-04-17 16:39:00 +0100
committerJoão Valverde <j@v6e.pt>2023-04-19 16:16:28 +0100
commit1ff7b8303781819fdaeb01be4b40ca6aa77d9cc5 (patch)
treebc792a09c4407243be70b284cb09770e2d54a5bc /epan/ftypes/ftype-ipv4.c
parent7595af96a08744392b1ff2a866c1d86ef6b7099e (diff)
ftypes: Add a hash/equal method
Add methods to make fvalues hashable with GHashTable.
Diffstat (limited to 'epan/ftypes/ftype-ipv4.c')
-rw-r--r--epan/ftypes/ftype-ipv4.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index 73161a3b6e..9b02821d68 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -152,6 +152,14 @@ slice(fvalue_t *fv, GByteArray *bytes, guint offset, guint length)
g_byte_array_append(bytes, data, length);
}
+static guint
+ipv4_hash(const fvalue_t *fv)
+{
+ gint64 val1 = fv->value.ipv4.addr;
+ gint64 val2 = fv->value.ipv4.nmask;
+ return g_int64_hash(&val1) ^ g_int64_hash(&val2);
+}
+
static gboolean
is_zero(const fvalue_t *fv_a)
{
@@ -185,6 +193,7 @@ ftype_register_ipv4(void)
NULL, /* cmp_contains */
NULL, /* cmp_matches */
+ ipv4_hash,
is_zero,
NULL,
NULL,