aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-10-29 18:39:41 -0700
committerGuy Harris <guy@alum.mit.edu>2017-10-30 01:40:13 +0000
commitdd1c18dd031038cbee7e219e322cbea1eafc87ca (patch)
treecd9e471c265d8d2ceab059f6677626e67e920d96
parent734c5b35a5491794dc9cb31ed07a8d0d5576d4f5 (diff)
Make FT_IPv4 a bit more like FT_IPv6.
FT_IPv6 doesn't expose the prefix, which is used only for values in filter expressions, not values in protocol fields; do the same for FT_IPv4, hiding the netmask, and using fvalue_get_integer() to get the value, having it return a network-byte-order value for the address. (This also makes it opaque whether the address and netmask are stored in host or network byte order.) Change-Id: I4285a87f6ccef2c0ccec040490ddcd15d787326e Reviewed-on: https://code.wireshark.org/review/24177 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/ftypes/ftype-ipv4.c6
-rw-r--r--epan/proto.c18
-rw-r--r--ui/gtk/packet_win.c5
3 files changed, 12 insertions, 17 deletions
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index 6d45e2e..27276d2 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -34,10 +34,10 @@ set_uinteger(fvalue_t *fv, guint32 value)
fv->value.ipv4.nmask = ip_get_subnet_mask(32);
}
-static gpointer
+static guint32
value_get(fvalue_t *fv)
{
- return &(fv->value.ipv4);
+ return g_htonl(fv->value.ipv4.addr);
}
static gboolean
@@ -234,7 +234,7 @@ ftype_register_ipv4(void)
val_repr_len, /* len_string_repr */
{ .set_value_uinteger = set_uinteger }, /* union set_value */
- { .get_value_ptr = value_get }, /* union get_value */
+ { .get_value_uinteger = value_get }, /* union get_value */
cmp_eq,
cmp_ne,
diff --git a/epan/proto.c b/epan/proto.c
index 68e81af..57dcdaf 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -5622,10 +5622,9 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
guint32 number;
guint64 number64;
guint8 *bytes;
- ipv4_addr_and_mask *ipv4;
- ws_in6_addr *ipv6;
+ guint32 ipv4;
+ ws_in6_addr *ipv6;
address addr;
- guint32 n_addr; /* network-order IPv4 address */
const true_false_string *tfstring;
@@ -5944,9 +5943,8 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
break;
case FT_IPv4:
- ipv4 = (ipv4_addr_and_mask *)fvalue_get(&finfo->value);
- n_addr = g_ntohl(ipv4->addr);
- set_address (&addr, AT_IPv4, 4, &n_addr);
+ ipv4 = fvalue_get_uinteger(&finfo->value);
+ set_address (&addr, AT_IPv4, 4, &ipv4);
address_to_str_buf(&addr, result+offset_r, size-offset_r);
offset_r = (int)strlen(result);
break;
@@ -8130,9 +8128,8 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
guint8 *bytes;
guint32 integer;
guint64 integer64;
- ipv4_addr_and_mask *ipv4;
+ guint32 ipv4;
e_guid_t *guid;
- guint32 n_addr; /* network-order IPv4 address */
gchar *name;
address addr;
char *addr_str;
@@ -8365,12 +8362,11 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_IPv4:
- ipv4 = (ipv4_addr_and_mask *)fvalue_get(&fi->value);
- n_addr = g_htonl(ipv4->addr);
+ ipv4 = fvalue_get_uinteger(&fi->value);
addr.type = AT_IPv4;
addr.len = 4;
- addr.data = &n_addr;
+ addr.data = &ipv4;
if (hfinfo->display == BASE_NETMASK)
{
diff --git a/ui/gtk/packet_win.c b/ui/gtk/packet_win.c
index 529e04f..50cae43 100644
--- a/ui/gtk/packet_win.c
+++ b/ui/gtk/packet_win.c
@@ -615,14 +615,13 @@ new_finfo_window(GtkWidget *w, struct FieldinfoWinData *DataPtr)
g_signal_connect(fvalue_edit, "toggled", G_CALLBACK(finfo_boolean_changed), DataPtr);
} else if (finfo_type == FT_IPv4) {
- ipv4_addr_and_mask *ipv4 = (ipv4_addr_and_mask *)fvalue_get(&finfo->value);
- guint32 net_addr = g_htonl(ipv4->addr);
+ guint32 ipv4 = fvalue_get_uinteger(&finfo->value);
#if GTK_CHECK_VERSION(3,0,0)
GtkAdjustment *adj;
#else
GtkObject *adj;
#endif
- adj = gtk_adjustment_new((double) (GUINT32_FROM_BE(net_addr)), 0.0, 4294967295.0 /* (2^32)-1 */, 1.0, 256.0, 0);
+ adj = gtk_adjustment_new((double) (GUINT32_FROM_BE(ipv4)), 0.0, 4294967295.0 /* (2^32)-1 */, 1.0, 256.0, 0);
/* XXX, create four gtk_spin_button_new which takes 0..255 */
fvalue_edit = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1.0, 0);