diff options
author | João Valverde <j@v6e.pt> | 2023-04-17 16:39:00 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-04-19 16:16:28 +0100 |
commit | 1ff7b8303781819fdaeb01be4b40ca6aa77d9cc5 (patch) | |
tree | bc792a09c4407243be70b284cb09770e2d54a5bc /epan/ftypes/ftype-ipv4.c | |
parent | 7595af96a08744392b1ff2a866c1d86ef6b7099e (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.c | 9 |
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, |