diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index d8d5e37d27..a579f68436 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -570,9 +570,9 @@ capture_ip(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, } static void -add_geoip_info_entry(proto_tree *tree, tvbuff_t *tvb, gint offset, guint32 ip, int isdst) +add_geoip_info_entry(proto_tree *tree, tvbuff_t *tvb, gint offset, ws_in4_addr ip, int isdst) { - const mmdb_lookup_t *lookup = maxmind_db_lookup_ipv4(ip); + const mmdb_lookup_t *lookup = maxmind_db_lookup_ipv4(&ip); if (!lookup->found) return; wmem_strbuf_t *summary = wmem_strbuf_new(wmem_packet_scope(), ""); diff --git a/epan/maxmind_db.c b/epan/maxmind_db.c index 99705eef21..9acf8e047e 100644 --- a/epan/maxmind_db.c +++ b/epan/maxmind_db.c @@ -630,16 +630,16 @@ gboolean maxmind_db_lookup_process(void) } const mmdb_lookup_t * -maxmind_db_lookup_ipv4(guint32 addr) { - mmdb_lookup_t *result = (mmdb_lookup_t *) wmem_map_lookup(mmdb_ipv4_map, GUINT_TO_POINTER(addr)); +maxmind_db_lookup_ipv4(const ws_in4_addr *addr) { + mmdb_lookup_t *result = (mmdb_lookup_t *) wmem_map_lookup(mmdb_ipv4_map, GUINT_TO_POINTER(*addr)); if (!result) { result = &mmdb_not_found; - wmem_map_insert(mmdb_ipv4_map, GUINT_TO_POINTER(addr), result); + wmem_map_insert(mmdb_ipv4_map, GUINT_TO_POINTER(*addr), result); if (mmdbr_pipe_valid()) { char addr_str[WS_INET_ADDRSTRLEN]; - ws_inet_ntop4(&addr, addr_str, WS_INET_ADDRSTRLEN); + ws_inet_ntop4(addr, addr_str, WS_INET_ADDRSTRLEN); MMDB_DEBUG("looking up %s", addr_str); g_async_queue_push(mmdbr_request_q, g_strdup_printf("%s\n", addr_str)); } @@ -707,7 +707,7 @@ maxmind_db_lookup_process(void) } const mmdb_lookup_t * -maxmind_db_lookup_ipv4(guint32 addr _U_) { +maxmind_db_lookup_ipv4(const ws_in4_addr *addr _U_) { return &mmdb_not_found; } diff --git a/epan/maxmind_db.h b/epan/maxmind_db.h index 0bbf668a02..251bf558e8 100644 --- a/epan/maxmind_db.h +++ b/epan/maxmind_db.h @@ -17,8 +17,9 @@ extern "C" { #endif /* __cplusplus */ -#include #include +#include +#include #include "ws_symbol_export.h" typedef struct _mmdb_lookup_t { @@ -49,7 +50,7 @@ WS_DLL_LOCAL void maxmind_db_pref_cleanup(void); * * @return The database entry if found, else NULL. */ -WS_DLL_PUBLIC WS_RETNONNULL const mmdb_lookup_t *maxmind_db_lookup_ipv4(guint32 addr); +WS_DLL_PUBLIC WS_RETNONNULL const mmdb_lookup_t *maxmind_db_lookup_ipv4(const ws_in4_addr *addr); /** * Look up an IPv6 address in a database diff --git a/sharkd_session.c b/sharkd_session.c index 59e95cec62..b611df297a 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -1223,10 +1223,9 @@ sharkd_session_geoip_addr(address *addr, const char *suffix) if (addr->type == AT_IPv4) { - guint32 ip; + const ws_in4_addr *ip4 = (const ws_in4_addr *) addr->data; - memcpy(&ip, addr->data, 4); - lookup = maxmind_db_lookup_ipv4(ip); + lookup = maxmind_db_lookup_ipv4(ip4); } else if (addr->type == AT_IPv6) { diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp index 6cdf02ca1a..1fd38ef169 100644 --- a/ui/qt/endpoint_dialog.cpp +++ b/ui/qt/endpoint_dialog.cpp @@ -210,9 +210,7 @@ public: const mmdb_lookup_t *mmdb_lookup = NULL; if (endp_item->myaddress.type == AT_IPv4) { - guint32 ip; - memcpy(&ip, endp_item->myaddress.data, 4); - mmdb_lookup = maxmind_db_lookup_ipv4(ip); + mmdb_lookup = maxmind_db_lookup_ipv4((ws_in4_addr *) endp_item->myaddress.data); } else if (endp_item->myaddress.type == AT_IPv6) { mmdb_lookup = maxmind_db_lookup_ipv6((ws_in6_addr *) endp_item->myaddress.data); }