From 0d46d9a60a89b8d2fd37c91515f3c8153b5e6b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Thu, 26 Oct 2023 12:16:54 +0100 Subject: ftypes: Add IPv4 setter/getter Do not allow "fvalue_set_uinteger" and "fvalue_get_uinteger" with FT_IPv4. Use "fvalue_set_ipv4" and "fvalue_get_ipv4" intead. Fix incorrect usage of fvalue_*_uinteger with FT_IPv4, hopefully I caught all of them. --- epan/ftypes/ftype-ipv4.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'epan/ftypes/ftype-ipv4.c') diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c index ef4b684f25..9965cf861d 100644 --- a/epan/ftypes/ftype-ipv4.c +++ b/epan/ftypes/ftype-ipv4.c @@ -18,16 +18,15 @@ #include static void -set_uinteger(fvalue_t *fv, uint32_t value) +value_set_ipv4(fvalue_t *fv, const ipv4_addr_and_mask *ipv4) { - fv->value.ipv4.addr = g_ntohl(value); - fv->value.ipv4.nmask = ip_get_subnet_mask(32); + fv->value.ipv4 = *ipv4; } -static uint32_t -value_get(fvalue_t *fv) +static const ipv4_addr_and_mask * +value_get_ipv4(fvalue_t *fv) { - return g_htonl(fv->value.ipv4.addr); + return &fv->value.ipv4; } static bool @@ -193,8 +192,8 @@ ftype_register_ipv4(void) NULL, /* val_to_sinteger64 */ NULL, /* val_to_double */ - { .set_value_uinteger = set_uinteger }, /* union set_value */ - { .get_value_uinteger = value_get }, /* union get_value */ + { .set_value_ipv4 = value_set_ipv4 }, /* union set_value */ + { .get_value_ipv4 = value_get_ipv4 }, /* union get_value */ cmp_order, NULL, /* cmp_contains */ -- cgit v1.2.3