diff options
author | Gerald Combs <gerald@wireshark.org> | 2008-12-23 18:17:01 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2008-12-23 18:17:01 +0000 |
commit | 218ec164c67deb33d213f8003915b90192078641 (patch) | |
tree | 58e68425f8178ebf77163744d77e3c9a7a4bda91 | |
parent | 8f375871c1fc75685d776d360620f8793f5328fb (diff) |
GeoIP expects IPv4 addresses in host byte order.
svn path=/trunk/; revision=27097
-rw-r--r-- | epan/dissectors/packet-ip.c | 22 | ||||
-rw-r--r-- | gtk/hostlist_table.c | 3 |
2 files changed, 13 insertions, 12 deletions
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index 756d310e29..bd799f7efb 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -1214,7 +1214,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { proto_tree *ip_tree = NULL, *field_tree; proto_item *ti = NULL, *tf; - guint32 src_naddr, dst_naddr; + guint32 addr; int offset = 0; guint hlen, optlen; guint16 flags; @@ -1440,13 +1440,13 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (tree) { const char *src_host; - memcpy(&src_naddr, iph->ip_src.data, 4); - src_host = get_hostname(src_naddr); + memcpy(&addr, iph->ip_src.data, 4); + src_host = get_hostname(addr); if (ip_summary_in_tree) { proto_item_append_text(ti, ", Src: %s (%s)", src_host, ip_to_str(iph->ip_src.data)); } - proto_tree_add_ipv4(ip_tree, hf_ip_src, tvb, offset + 12, 4, src_naddr); - item = proto_tree_add_ipv4(ip_tree, hf_ip_addr, tvb, offset + 12, 4, src_naddr); + proto_tree_add_ipv4(ip_tree, hf_ip_src, tvb, offset + 12, 4, addr); + item = proto_tree_add_ipv4(ip_tree, hf_ip_addr, tvb, offset + 12, 4, addr); PROTO_ITEM_SET_HIDDEN(item); item = proto_tree_add_string(ip_tree, hf_ip_src_host, tvb, offset + 12, 4, src_host); PROTO_ITEM_SET_GENERATED(item); @@ -1483,13 +1483,13 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (tree) { const char *dst_host; - memcpy(&dst_naddr, iph->ip_dst.data, 4); - dst_host = get_hostname(dst_naddr); + memcpy(&addr, iph->ip_dst.data, 4); + dst_host = get_hostname(addr); if (ip_summary_in_tree) { proto_item_append_text(ti, ", Dst: %s (%s)", dst_host, ip_to_str(iph->ip_dst.data)); } - proto_tree_add_ipv4(ip_tree, hf_ip_dst, tvb, offset + 16, 4, dst_naddr); - item = proto_tree_add_ipv4(ip_tree, hf_ip_addr, tvb, offset + 16, 4, dst_naddr); + proto_tree_add_ipv4(ip_tree, hf_ip_dst, tvb, offset + 16, 4, addr); + item = proto_tree_add_ipv4(ip_tree, hf_ip_addr, tvb, offset + 16, 4, addr); PROTO_ITEM_SET_HIDDEN(item); item = proto_tree_add_string(ip_tree, hf_ip_dst_host, tvb, offset + 16, 4, dst_host); PROTO_ITEM_SET_GENERATED(item); @@ -1502,8 +1502,8 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) #ifdef HAVE_GEOIP if (tree && ip_use_geoip) { for (dbnum = 0; dbnum < geoip_num_dbs(); dbnum++) { - geoip_src_str = geoip_db_lookup_ipv4(dbnum, src_naddr, NULL); - geoip_dst_str = geoip_db_lookup_ipv4(dbnum, dst_naddr, NULL); + geoip_src_str = geoip_db_lookup_ipv4(dbnum, src32, NULL); + geoip_dst_str = geoip_db_lookup_ipv4(dbnum, dst32, NULL); switch (geoip_db_type(dbnum)) { case GEOIP_COUNTRY_EDITION: diff --git a/gtk/hostlist_table.c b/gtk/hostlist_table.c index e7f9c9863c..c28321e1be 100644 --- a/gtk/hostlist_table.c +++ b/gtk/hostlist_table.c @@ -41,6 +41,7 @@ #include <epan/strutil.h> #ifdef HAVE_GEOIP #include <epan/geoip_db.h> +#include <epan/pint.h> #endif #include "../simple_dialog.h" @@ -1108,7 +1109,7 @@ add_hostlist_table_data(hostlist_table *hl, const address *addr, guint32 port, g /* Filled in from the GeoIP config, if any */ for (i = 0; i < NUM_GEOIP_COLS; i++) { if (i < geoip_num_dbs() && talker->address.type == AT_IPv4) { - const guchar *name = geoip_db_lookup_ipv4(i, *(guint32*)talker->address.data, "-"); + const guchar *name = geoip_db_lookup_ipv4(i, pntohl(talker->address.data), "-"); g_snprintf(geoip[i], COL_STR_LEN, "%s", format_text (name, strlen(name))); entries[NUM_BUILTIN_COLS + i] = geoip[i]; gtk_clist_set_column_visibility(hl->table, NUM_BUILTIN_COLS + i, TRUE); |