aboutsummaryrefslogtreecommitdiffstats
path: root/proto.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-11-15 06:32:38 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-11-15 06:32:38 +0000
commit6a20c7bbc5e98c72bda45f7b7e17336694ec5580 (patch)
treea387ae6866e8e50e796c83937e84df6ee7838647 /proto.c
parent1fca132c59ad267b19719cd1b061255ef5751e17 (diff)
Add "class" that understands IPv4 addresses and subnet masks.
We now store IPv4 addresses in host order, allowing non-equivalence comparisons. That is, display filters with lt, le, gt, and ge will work on big-endian and little-endian machines. CIDR notation is now supported for IPv4 addresses in display filters. You can test to see if an IPv4 address is on a certain subnet by using this notation. For example, to test for IPv4 packets on a Class-C network: ip.addr == 192.168.1.0/24 svn path=/trunk/; revision=1032
Diffstat (limited to 'proto.c')
-rw-r--r--proto.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/proto.c b/proto.c
index 1848a5648c..9e80203578 100644
--- a/proto.c
+++ b/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.47 1999/11/11 16:20:25 nneul Exp $
+ * $Id: proto.c,v 1.48 1999/11/15 06:32:14 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -340,6 +340,10 @@ NOTES
break;
case FT_IPv4:
+ ipv4_addr_set_net_order_addr(&(fi->value.ipv4), va_arg(ap, unsigned int));
+ ipv4_addr_set_netmask_bits(&(fi->value.ipv4), 32);
+ break;
+
case FT_IPXNET:
fi->value.numeric = va_arg(ap, unsigned int);
break;
@@ -480,6 +484,7 @@ void
proto_item_fill_label(field_info *fi, gchar *label_str)
{
struct header_field_info *hfinfo = fi->hfinfo;
+ guint32 n_addr; /* network-order IPv4 address */
switch(hfinfo->type) {
case FT_NONE:
@@ -569,10 +574,11 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_IPv4:
+ n_addr = ipv4_get_net_order_addr(&fi->value.ipv4);
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (%s)", fi->hfinfo->name,
- get_hostname(fi->value.numeric),
- ip_to_str((guint8*)&fi->value.numeric));
+ get_hostname(n_addr),
+ ip_to_str((guint8*)&n_addr));
break;
case FT_IPv6:
@@ -1009,7 +1015,8 @@ proto_registrar_is_protocol(int n)
return FALSE;
}
-/* Returns length of field.
+/* Returns length of field in packet (not necessarily the length
+ * in our internal representation, as in the case of IPv4).
* 0 means undeterminable at time of registration
* -1 means the field is not registered. */
gint