diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-07-31 04:18:01 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-07-31 04:18:01 +0000 |
commit | 5b04b9a4ff42eb6e59c4102cfe7d9a3e121fb3c9 (patch) | |
tree | a3e8da74b17554447e946574b19d51a1c067e631 | |
parent | adf711d5fb40af4af8b6914704c984709f551e81 (diff) | |
download | wireshark-5b04b9a4ff42eb6e59c4102cfe7d9a3e121fb3c9.tar.gz |
Give FT_IPv4 val_repr_len and val_to_repr methods, and use them for
generating display filters from FT_IPv4 fields.
svn path=/trunk/; revision=8110
-rw-r--r-- | epan/ftypes/ftype-ipv4.c | 21 | ||||
-rw-r--r-- | epan/ipv4.c | 11 | ||||
-rw-r--r-- | epan/ipv4.h | 13 | ||||
-rw-r--r-- | epan/proto.c | 15 |
4 files changed, 31 insertions, 29 deletions
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c index e583f17aa0..cad03ef251 100644 --- a/epan/ftypes/ftype-ipv4.c +++ b/epan/ftypes/ftype-ipv4.c @@ -1,5 +1,5 @@ /* - * $Id: ftype-ipv4.c,v 1.11 2003/07/25 03:44:02 gram Exp $ + * $Id: ftype-ipv4.c,v 1.12 2003/07/31 04:18:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -122,6 +122,21 @@ val_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc) return TRUE; } +static int +val_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_) +{ + /* + * 14 characters for "XXX.XXX.XXX.XXX". + */ + return 14; +} + +static void +val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) +{ + ipv4_addr_str_buf(&fv->value.ipv4, buf); +} + static gboolean cmp_eq(fvalue_t *a, fvalue_t *b) { @@ -170,8 +185,8 @@ ftype_register_ipv4(void) NULL, val_from_unparsed, /* val_from_unparsed */ NULL, /* val_from_string */ - NULL, /* val_to_string_repr */ - NULL, /* len_string_repr */ + val_to_repr, /* val_to_string_repr */ + val_repr_len, /* len_string_repr */ NULL, set_integer, diff --git a/epan/ipv4.c b/epan/ipv4.c index f37caef07d..21903a6713 100644 --- a/epan/ipv4.c +++ b/epan/ipv4.c @@ -5,13 +5,12 @@ * * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: ipv4.c,v 1.4 2002/08/28 20:40:44 jmayer Exp $ + * $Id: ipv4.c,v 1.5 2003/07/31 04:18:00 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -86,11 +85,11 @@ ipv4_get_host_order_addr(ipv4_addr *ipv4) return ipv4->addr; } -gchar* -ipv4_addr_str(ipv4_addr *ipv4) +void +ipv4_addr_str_buf(const ipv4_addr *ipv4, gchar *buf) { guint32 ipv4_host_order = g_htonl(ipv4->addr); - return ip_to_str((gchar*)&ipv4_host_order); + return ip_to_str_buf((gchar*)&ipv4_host_order, buf); } static guint32 diff --git a/epan/ipv4.h b/epan/ipv4.h index 40648c3207..6b7e135998 100644 --- a/epan/ipv4.h +++ b/epan/ipv4.h @@ -1,17 +1,16 @@ -/* ip4.h +/* ipv4.h * * IPv4 address class. They understand how to take netmasks into consideration * during equivalence testing. * * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: ipv4.h,v 1.4 2002/08/28 20:40:44 jmayer Exp $ + * $Id: ipv4.h,v 1.5 2003/07/31 04:18:00 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -50,9 +49,9 @@ void ipv4_addr_set_netmask_bits(ipv4_addr *ipv4, guint new_nmask_bits); guint32 ipv4_get_net_order_addr(ipv4_addr *ipv4); guint32 ipv4_get_host_order_addr(ipv4_addr *ipv4); -/* Returns a string pointer to a dotted-decimal notation representation of an IPv4 - * address. The pointer points to a internal buffer, so don't try to g_free() it */ -gchar* ipv4_addr_str(ipv4_addr *ipv4); +/* Fills in a buffer with a dotted-decimal notation representation of an IPv4 + * address. */ +void ipv4_addr_str_buf(const ipv4_addr *ipv4, gchar *buf); /* Compares two ipv4_addrs, taking into account the less restrictive of the * two netmasks, applying that netmask to both addrs. diff --git a/epan/proto.c b/epan/proto.c index c521872e9e..74fe13b094 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.97 2003/07/31 03:52:40 guy Exp $ + * $Id: proto.c,v 1.98 2003/07/31 04:18:00 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -3572,18 +3572,6 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) stringified); break; - case FT_IPv4: - /* - * 4 bytes for " == ". - * 14 bytes for "XXX.XXX.XXX.XXX". - * 1 byte for the trailing '\0'. - */ - dfilter_len = abbrev_len + 4 + 15 + 1; - buf = g_malloc0(dfilter_len); - snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev, - ipv4_addr_str(fvalue_get(finfo->value))); - break; - case FT_IPXNET: /* * 4 bytes for " == ". @@ -3620,6 +3608,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) case FT_DOUBLE: case FT_ABSOLUTE_TIME: case FT_RELATIVE_TIME: + case FT_IPv4: /* Figure out the string length needed. * The ft_repr length. * 4 bytes for " == ". |