aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes
diff options
context:
space:
mode:
authorTomas Kukosa <tomas.kukosa@siemens.com>2005-07-04 13:04:53 +0000
committerTomas Kukosa <tomas.kukosa@siemens.com>2005-07-04 13:04:53 +0000
commitbab34b522b46bd46d47dc4cb448aed9ce4423d9f (patch)
treeaf5815fc3606f36fa87c2bcaed9c471aef9e5c57 /epan/ftypes
parent5f2fd433abc60c0e5f97613fbb18a00090dddc26 (diff)
new field type FT_GUID
svn path=/trunk/; revision=14845
Diffstat (limited to 'epan/ftypes')
-rw-r--r--epan/ftypes/ftype-bytes.c69
-rw-r--r--epan/ftypes/ftypes.h1
2 files changed, 70 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c
index 0284fa41d7..867c1008b1 100644
--- a/epan/ftypes/ftype-bytes.c
+++ b/epan/ftypes/ftype-bytes.c
@@ -39,6 +39,7 @@
#define ETHER_LEN 6
#define IPv6_LEN 16
+#define GUID_LEN 16
static void
bytes_fvalue_new(fvalue_t *fv)
@@ -121,6 +122,13 @@ ipv6_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
common_fvalue_set(fv, value, IPv6_LEN);
}
+static void
+guid_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
+{
+ g_assert(!already_copied);
+ common_fvalue_set(fv, value, GUID_LEN);
+}
+
static gpointer
value_get(fvalue_t *fv)
{
@@ -218,6 +226,31 @@ ipv6_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogF
return TRUE;
}
+static gboolean
+guid_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value, LogFunc logfunc)
+{
+ /*
+ * Don't log a message if this fails; we'll try looking it
+ * up as an GUID if it does, and if that fails,
+ * we'll log a message.
+ */
+ if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
+ if (fv->value.bytes->len > GUID_LEN) {
+ logfunc("\"%s\" contains too many bytes to be a valid Globally Unique Identifier.",
+ s);
+ return FALSE;
+ }
+ else if (fv->value.bytes->len < GUID_LEN && !allow_partial_value) {
+ logfunc("\"%s\" contains too few bytes to be a valid Globally Unique Identifier.",
+ s);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
static guint
len(fvalue_t *fv)
{
@@ -547,8 +580,44 @@ ftype_register_bytes(void)
slice,
};
+ static ftype_t guid_type = {
+ "GUID", /* name */
+ "Globally Unique Identifier", /* pretty_name */
+ GUID_LEN, /* wire_size */
+ bytes_fvalue_new, /* new_value */
+ bytes_fvalue_free, /* free_value */
+ guid_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
+ bytes_to_repr, /* val_to_string_repr */
+ bytes_repr_len, /* len_string_repr */
+
+ guid_fvalue_set, /* set_value */
+ NULL, /* set_value_integer */
+ NULL, /* set_value_integer64 */
+ NULL, /* set_value_floating */
+
+ value_get, /* get_value */
+ NULL, /* get_value_integer */
+ NULL, /* get_value_integer64 */
+ NULL, /* get_value_floating */
+
+ cmp_eq,
+ cmp_ne,
+ cmp_gt,
+ cmp_ge,
+ cmp_lt,
+ cmp_le,
+ cmp_bytes_bitwise_and,
+ cmp_contains,
+ NULL, /* cmp_matches */
+
+ len,
+ slice,
+ };
+
ftype_register(FT_BYTES, &bytes_type);
ftype_register(FT_UINT_BYTES, &uint_bytes_type);
ftype_register(FT_ETHER, &ether_type);
ftype_register(FT_IPv6, &ipv6_type);
+ ftype_register(FT_GUID, &guid_type);
}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index e328af5aac..ddb7515537 100644
--- a/epan/ftypes/ftypes.h
+++ b/epan/ftypes/ftypes.h
@@ -60,6 +60,7 @@ enum ftenum {
FT_IPXNET,
FT_FRAMENUM, /* a UINT32, but if selected lets you go to frame with that numbe */
FT_PCRE, /* a compiled Perl-Compatible Regular Expression object */
+ FT_GUID, /* GUID, UUID */
FT_NUM_TYPES /* last item number plus one */
};