summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-10-29 21:13:13 +0000
committerGuy Harris <guy@alum.mit.edu>2001-10-29 21:13:13 +0000
commitd82c74d757383e94f745fef6b409b3da44ffb08d (patch)
tree0d1078ed4e15ca77422d9b578febfd8c678cd503 /epan
parente5eee0bd76c0c55559facafb6d4223914cfb5b1d (diff)
downloadwireshark-d82c74d757383e94f745fef6b409b3da44ffb08d.tar.gz
From Ronnie Sahlberg: FT_UINT64 support, code to handle 64-bit integers
without requiring compiler support for them, and updates to the Diameter, L2TP, NFS, and NLM dissectors to use it and to the ONC RPC dissector to allow ONC RPC subdissectors to use it. svn path=/trunk/; revision=4099
Diffstat (limited to 'epan')
-rw-r--r--epan/dfilter/semcheck.c3
-rw-r--r--epan/ftypes/ftype-bytes.c55
-rw-r--r--epan/ftypes/ftypes.h4
-rw-r--r--epan/proto.c74
4 files changed, 130 insertions, 6 deletions
diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c
index 03866ab00c..d63911f0dc 100644
--- a/epan/dfilter/semcheck.c
+++ b/epan/dfilter/semcheck.c
@@ -1,5 +1,5 @@
/*
- * $Id: semcheck.c,v 1.4 2001/03/02 17:04:23 gram Exp $
+ * $Id: semcheck.c,v 1.5 2001/10/29 21:13:12 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -53,6 +53,7 @@ compatible_ftypes(ftenum_t a, ftenum_t b)
case FT_IPv4:
case FT_IPv6:
case FT_IPXNET:
+ case FT_UINT64:
return a == b;
case FT_ETHER:
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c
index 92e80b6430..66073e636b 100644
--- a/epan/ftypes/ftype-bytes.c
+++ b/epan/ftypes/ftype-bytes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-bytes.c,v 1.5 2001/03/03 00:33:24 guy Exp $
+ * $Id: ftype-bytes.c,v 1.6 2001/10/29 21:13:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -29,10 +29,11 @@
#include <string.h>
#include <ctype.h>
#include "resolv.h"
+#include "../../int-64bit.h"
#define ETHER_LEN 6
#define IPv6_LEN 16
-
+#define U64_LEN 8
static void
bytes_fvalue_new(fvalue_t *fv)
@@ -45,6 +46,7 @@ bytes_fvalue_free(fvalue_t *fv)
{
if (fv->value.bytes) {
g_byte_array_free(fv->value.bytes, TRUE);
+ fv->value.bytes=NULL;
}
}
@@ -77,6 +79,13 @@ ipv6_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
common_fvalue_set(fv, value, IPv6_LEN);
}
+static void
+u64_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
+{
+ g_assert(!already_copied);
+ common_fvalue_set(fv, value, U64_LEN);
+}
+
static gpointer
value_get(fvalue_t *fv)
{
@@ -224,6 +233,20 @@ ipv6_from_string(fvalue_t *fv, char *s, LogFunc log)
return TRUE;
}
+static gboolean
+u64_from_string(fvalue_t *fv, char *s, LogFunc log)
+{
+ guint8 buffer[8];
+
+ if (atou64(s, buffer) == NULL) {
+ log("\"%s\" is not a valid integer", s);
+ return FALSE;
+ }
+
+ u64_fvalue_set(fv, buffer, FALSE);
+ return TRUE;
+}
+
static guint
len(fvalue_t *fv)
{
@@ -422,7 +445,35 @@ ftype_register_bytes(void)
slice,
};
+ static ftype_t u64_type = {
+ "FT_UINT64",
+ "Unsigned 64-bit integer",
+ U64_LEN,
+ bytes_fvalue_new,
+ bytes_fvalue_free,
+ u64_from_string,
+
+ u64_fvalue_set,
+ NULL,
+ NULL,
+
+ value_get,
+ NULL,
+ NULL,
+
+ cmp_eq,
+ cmp_ne,
+ cmp_gt,
+ cmp_ge,
+ cmp_lt,
+ cmp_le,
+
+ len,
+ slice,
+ };
+
ftype_register(FT_BYTES, &bytes_type);
ftype_register(FT_ETHER, &ether_type);
ftype_register(FT_IPv6, &ipv6_type);
+ ftype_register(FT_UINT64, &u64_type);
}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 6a66fdcca2..78f30ce7d8 100644
--- a/epan/ftypes/ftypes.h
+++ b/epan/ftypes/ftypes.h
@@ -1,7 +1,7 @@
/* ftypes.h
* Definitions for field types
*
- * $Id: ftypes.h,v 1.5 2001/09/14 07:23:34 guy Exp $
+ * $Id: ftypes.h,v 1.6 2001/10/29 21:13:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -39,6 +39,7 @@ enum ftenum {
FT_UINT16,
FT_UINT24, /* really a UINT32, but displayed as 3 hex-digits if FD_HEX*/
FT_UINT32,
+ FT_UINT64,
FT_INT8,
FT_INT16,
FT_INT24,
@@ -131,7 +132,6 @@ typedef struct {
gchar *string;
GByteArray *bytes;
ipv4_addr ipv4;
- guint8 ipv6[16];
nstime_t time;
tvbuff_t *tvb;
} value;
diff --git a/epan/proto.c b/epan/proto.c
index ffb84a50b6..3811826ddb 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.37 2001/10/26 17:29:09 gram Exp $
+ * $Id: proto.c,v 1.38 2001/10/29 21:13:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -44,6 +44,7 @@
#include "plugins.h"
#include "ipv6-utils.h"
#include "proto.h"
+#include "../int-64bit.h"
#define cVALS(x) (const value_string*)(x)
@@ -52,6 +53,7 @@ proto_tree_free_node(GNode *node, gpointer data);
static void fill_label_boolean(field_info *fi, gchar *label_str);
static void fill_label_uint(field_info *fi, gchar *label_str);
+static void fill_label_uint64(field_info *fi, gchar *label_str);
static void fill_label_enumerated_uint(field_info *fi, gchar *label_str);
static void fill_label_enumerated_bitfield(field_info *fi, gchar *label_str);
static void fill_label_numeric_bitfield(field_info *fi, gchar *label_str);
@@ -81,6 +83,10 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap);
static void
proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb);
static void
+proto_tree_set_uint64b(field_info *fi, const guint8 *value_ptr, gboolean little_endian);
+static void
+proto_tree_set_uint64_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian);
+static void
proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length);
static void
proto_tree_set_bytes_tvb(field_info *fi, tvbuff_t *tvb, gint offset, gint length);
@@ -485,6 +491,11 @@ proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
get_uint_value(tvb, start, length, little_endian));
break;
+ case FT_UINT64:
+ g_assert(length == 8);
+ proto_tree_set_uint64_tvb(new_fi, tvb, start, little_endian);
+ break;
+
/* XXX - make these just FT_INT? */
case FT_INT8:
case FT_INT16:
@@ -981,6 +992,30 @@ proto_tree_set_ipv6_tvb(field_info *fi, tvbuff_t *tvb, gint start)
proto_tree_set_ipv6(fi, tvb_get_ptr(tvb, start, 16));
}
+static void
+proto_tree_set_uint64(field_info *fi, const guint8 *value_ptr, gboolean little_endian)
+{
+ if(little_endian){
+ unsigned char buffer[8];
+ int i;
+
+ for(i=0;i<8;i++){
+ buffer[i]=value_ptr[7-i];
+ }
+ fvalue_set(fi->value, (gpointer)buffer, FALSE);
+ } else {
+ fvalue_set(fi->value, (gpointer)value_ptr, FALSE);
+ }
+}
+
+static void
+proto_tree_set_uint64_tvb(field_info *fi, tvbuff_t *tvb, gint start, gboolean little_endian)
+{
+ /* XXX remove all this when last non-tvbuff dissector is removed*/
+ NullTVB;
+ proto_tree_set_uint64(fi, tvb_get_ptr(tvb, start, 8), little_endian);
+}
+
/* Add a FT_STRING to a proto_tree */
proto_item *
proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
@@ -1954,6 +1989,10 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
}
break;
+ case FT_UINT64:
+ fill_label_uint64(fi, label_str);
+ break;
+
case FT_INT8:
case FT_INT16:
case FT_INT24:
@@ -2033,6 +2072,30 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
}
static void
+fill_label_uint64(field_info *fi, gchar *label_str)
+{
+ unsigned char *bytes;
+ header_field_info *hfinfo = fi->hfinfo;
+
+ bytes=fvalue_get(fi->value);
+ switch(hfinfo->display){
+ case BASE_DEC:
+ snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s", hfinfo->name,
+ u64toa(bytes));
+ break;
+ case BASE_HEX:
+ snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s", hfinfo->name,
+ u64toh(bytes));
+ break;
+ default:
+ g_assert_not_reached();
+ ;
+ }
+}
+
+static void
fill_label_boolean(field_info *fi, gchar *label_str)
{
char *p = label_str;
@@ -2875,6 +2938,7 @@ proto_can_match_selected(field_info *finfo)
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
+ case FT_UINT64:
case FT_INT8:
case FT_INT16:
case FT_INT24:
@@ -2941,6 +3005,14 @@ proto_alloc_dfilter_string(field_info *finfo, guint8 *pd)
snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer(finfo->value));
break;
+ case FT_UINT64:
+ stringified = u64toa(fvalue_get(finfo->value));
+ dfilter_len = abbrev_len + 4 + strlen(stringified) +1;
+ buf = g_malloc0(dfilter_len);
+ snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev,
+ stringified);
+ break;
+
case FT_IPv4:
dfilter_len = abbrev_len + 4 + 15 + 1;
buf = g_malloc0(dfilter_len);