aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2003-07-25 03:44:05 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2003-07-25 03:44:05 +0000
commit086774b71f236b797a9e7a14e2bbb444b55e6d79 (patch)
treec295c5d9f4e05517f4d56f17032183c996ab27df /epan/ftypes
parentc2150d9d778613bb7eb8135ea1f155346f26e473 (diff)
Add to the fundamental types passed between the scanner and the parser.
Besides "STRING", there is now "UNPARSED_STRING", where the distinction is that "STRING" was a double-quoted string and "UNPARSED_STRING" is just a sequence of characters that the scanner didn't know how to scan/parse, so it's up to the Ftype to parse it. This gives us more flexibility and prepares the dfilter parsing engine for the upcoming addition of the "contains" operator. In the process of doing this, I also re-did the double-quoted string support in the scanner, so that instead of the naively-simple support we used to have, double-quoted strings now can have embedded dobule-quotes, embedded octal sequences, and embedded hexadecimal sequences: "\"" embedded double-quote "\110" embedded octal "\x48" embedded hex Enhance the dfilter unit test script to be able to run a single collection of tests instead of having to run all of them all the time. svn path=/trunk/; revision=8083
Diffstat (limited to 'epan/ftypes')
-rw-r--r--epan/ftypes/ftype-bytes.c32
-rw-r--r--epan/ftypes/ftype-double.c10
-rw-r--r--epan/ftypes/ftype-integer.c41
-rw-r--r--epan/ftypes/ftype-ipv4.c10
-rw-r--r--epan/ftypes/ftype-none.c3
-rw-r--r--epan/ftypes/ftype-string.c9
-rw-r--r--epan/ftypes/ftype-time.c10
-rw-r--r--epan/ftypes/ftype-tvbuff.c5
-rw-r--r--epan/ftypes/ftypes-int.h4
-rw-r--r--epan/ftypes/ftypes.c19
-rw-r--r--epan/ftypes/ftypes.h6
11 files changed, 100 insertions, 49 deletions
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c
index 28329f7295..25c2f445ec 100644
--- a/epan/ftypes/ftype-bytes.c
+++ b/epan/ftypes/ftype-bytes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-bytes.c,v 1.15 2003/06/11 21:24:53 gram Exp $
+ * $Id: ftype-bytes.c,v 1.16 2003/07/25 03:44:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -129,7 +129,7 @@ is_byte_sep(guint8 c)
}
static gboolean
-val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+val_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
GByteArray *bytes;
guint8 val;
@@ -226,7 +226,7 @@ val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
}
static gboolean
-ether_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+ether_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
guint8 *mac;
@@ -235,7 +235,7 @@ ether_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
* up as an Ethernet host name if it does, and if that fails,
* we'll log a message.
*/
- if (val_from_string(fv, s, NULL)) {
+ if (val_from_unparsed(fv, s, NULL)) {
return TRUE;
}
@@ -251,7 +251,7 @@ ether_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
}
static gboolean
-ipv6_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+ipv6_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
guint8 buffer[16];
@@ -265,7 +265,7 @@ ipv6_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
}
static gboolean
-u64_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+u64_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
guint8 buffer[8];
@@ -279,7 +279,7 @@ u64_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
}
static gboolean
-i64_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+i64_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
guint8 buffer[8];
@@ -587,7 +587,8 @@ ftype_register_bytes(void)
0, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
bytes_to_repr, /* val_to_string_repr */
bytes_repr_len, /* len_string_repr */
@@ -616,7 +617,8 @@ ftype_register_bytes(void)
0, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
bytes_to_repr, /* val_to_string_repr */
bytes_repr_len, /* len_string_repr */
@@ -645,7 +647,8 @@ ftype_register_bytes(void)
ETHER_LEN, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
- ether_from_string, /* val_from_string */
+ ether_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
bytes_to_repr, /* val_to_string_repr */
bytes_repr_len, /* len_string_repr */
@@ -674,7 +677,8 @@ ftype_register_bytes(void)
IPv6_LEN, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
- ipv6_from_string, /* val_from_string */
+ ipv6_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -703,7 +707,8 @@ ftype_register_bytes(void)
U64_LEN, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
- u64_from_string, /* val_from_string */
+ u64_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -732,7 +737,8 @@ ftype_register_bytes(void)
U64_LEN, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
- i64_from_string, /* val_from_string */
+ i64_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-double.c b/epan/ftypes/ftype-double.c
index 2091bda846..5ee3aee44d 100644
--- a/epan/ftypes/ftype-double.c
+++ b/epan/ftypes/ftype-double.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-double.c,v 1.8 2003/02/08 04:22:37 gram Exp $
+ * $Id: ftype-double.c,v 1.9 2003/07/25 03:44:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -48,7 +48,7 @@ value_get_floating(fvalue_t *fv)
}
static gboolean
-val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+val_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
char *endptr = NULL;
@@ -123,7 +123,8 @@ ftype_register_double(void)
0,
double_fvalue_new,
NULL,
- val_from_string,
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -152,7 +153,8 @@ ftype_register_double(void)
0,
double_fvalue_new,
NULL,
- val_from_string,
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-integer.c b/epan/ftypes/ftype-integer.c
index d170dec129..818b6cce7a 100644
--- a/epan/ftypes/ftype-integer.c
+++ b/epan/ftypes/ftype-integer.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-integer.c,v 1.13 2003/06/11 21:24:53 gram Exp $
+ * $Id: ftype-integer.c,v 1.14 2003/07/25 03:44:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -49,7 +49,7 @@ get_integer(fvalue_t *fv)
}
static gboolean
-val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+val_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
char *endptr;
@@ -78,7 +78,7 @@ val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
}
static gboolean
-ipxnet_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+ipxnet_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
guint32 val;
gboolean known;
@@ -88,7 +88,7 @@ ipxnet_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
* up as an IPX network name if it does, and if that fails,
* we'll log a message.
*/
- if (val_from_string(fv, s, NULL)) {
+ if (val_from_unparsed(fv, s, NULL)) {
return TRUE;
}
@@ -223,7 +223,8 @@ ftype_register_integers(void)
1, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -251,7 +252,8 @@ ftype_register_integers(void)
2, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -279,7 +281,8 @@ ftype_register_integers(void)
3, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -307,7 +310,8 @@ ftype_register_integers(void)
4, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -335,7 +339,8 @@ ftype_register_integers(void)
1, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -363,7 +368,8 @@ ftype_register_integers(void)
2, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -391,7 +397,8 @@ ftype_register_integers(void)
3, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -419,7 +426,8 @@ ftype_register_integers(void)
4, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -447,7 +455,8 @@ ftype_register_integers(void)
0, /* wire_size */
boolean_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
boolean_to_repr, /* val_to_string_repr */
boolean_repr_len, /* len_string_repr */
@@ -476,7 +485,8 @@ ftype_register_integers(void)
4, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- ipxnet_from_string, /* val_from_string */
+ ipxnet_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -505,7 +515,8 @@ ftype_register_integers(void)
4, /* wire_size */
int_fvalue_new, /* new_value */
NULL, /* free_value */
- val_from_string, /* val_from_string */
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index ad978a7915..e583f17aa0 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-ipv4.c,v 1.10 2003/02/08 04:22:37 gram Exp $
+ * $Id: ftype-ipv4.c,v 1.11 2003/07/25 03:44:02 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -45,7 +45,7 @@ value_get(fvalue_t *fv)
}
static gboolean
-val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+val_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
guint32 addr;
unsigned int nmask_bits;
@@ -98,7 +98,8 @@ val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
return FALSE;
}
- nmask_fvalue = fvalue_from_string(FT_UINT32, net_str, logfunc);
+ /* XXX - this is inefficient */
+ nmask_fvalue = fvalue_from_unparsed(FT_UINT32, net_str, logfunc);
g_free(s_copy);
if (!nmask_fvalue) {
return FALSE;
@@ -167,7 +168,8 @@ ftype_register_ipv4(void)
4,
NULL,
NULL,
- val_from_string,
+ val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-none.c b/epan/ftypes/ftype-none.c
index 864c8a6b9a..bf6cd400eb 100644
--- a/epan/ftypes/ftype-none.c
+++ b/epan/ftypes/ftype-none.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-none.c,v 1.5 2003/02/08 04:22:37 gram Exp $
+ * $Id: ftype-none.c,v 1.6 2003/07/25 03:44:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -39,6 +39,7 @@ ftype_register_none(void)
NULL,
NULL,
NULL,
+ NULL,
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index 312d1baa02..f1d529709a 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-string.c,v 1.9 2003/06/11 21:24:53 gram Exp $
+ * $Id: ftype-string.c,v 1.10 2003/07/25 03:44:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -154,6 +154,7 @@ ftype_register_string(void)
0, /* wire_size */
string_fvalue_new, /* new_value */
string_fvalue_free, /* free_value */
+ val_from_string, /* val_from_unparsed */
val_from_string, /* val_from_string */
string_to_repr, /* val_to_string_repr */
string_repr_len, /* len_string_repr */
@@ -182,7 +183,8 @@ ftype_register_string(void)
0,
string_fvalue_new,
string_fvalue_free,
- val_from_string,
+ val_from_string, /* val_from_unparsed */
+ val_from_string, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -210,7 +212,8 @@ ftype_register_string(void)
0,
string_fvalue_new,
string_fvalue_free,
- val_from_string,
+ val_from_string, /* val_from_unparsed */
+ val_from_string, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-time.c b/epan/ftypes/ftype-time.c
index f35483da7b..818467a380 100644
--- a/epan/ftypes/ftype-time.c
+++ b/epan/ftypes/ftype-time.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-time.c,v 1.18 2003/02/08 04:22:37 gram Exp $
+ * $Id: ftype-time.c,v 1.19 2003/07/25 03:44:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -167,7 +167,7 @@ get_nsecs(char *startp, int *nsecs)
}
static gboolean
-relative_val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
+relative_val_from_unparsed(fvalue_t *fv, char *s, LogFunc logfunc)
{
char *curptr, *endptr;
@@ -307,7 +307,8 @@ ftype_register_time(void)
0,
time_fvalue_new,
NULL,
- absolute_val_from_string,
+ absolute_val_from_string, /* val_from_unparsed */
+ absolute_val_from_string, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
@@ -334,7 +335,8 @@ ftype_register_time(void)
0,
time_fvalue_new,
NULL,
- relative_val_from_string,
+ relative_val_from_unparsed, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftype-tvbuff.c b/epan/ftypes/ftype-tvbuff.c
index f051fd3094..43050f9f9f 100644
--- a/epan/ftypes/ftype-tvbuff.c
+++ b/epan/ftypes/ftype-tvbuff.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-tvbuff.c,v 1.8 2003/02/08 04:22:37 gram Exp $
+ * $Id: ftype-tvbuff.c,v 1.9 2003/07/25 03:44:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -84,7 +84,8 @@ ftype_register_tvbuff(void)
0,
value_new,
NULL,
- NULL,
+ NULL, /* val_from_unparsed */
+ NULL, /* val_from_string */
NULL, /* val_to_string_repr */
NULL, /* len_string_repr */
diff --git a/epan/ftypes/ftypes-int.h b/epan/ftypes/ftypes-int.h
index cda64a1862..d6922ef7c9 100644
--- a/epan/ftypes/ftypes-int.h
+++ b/epan/ftypes/ftypes-int.h
@@ -1,5 +1,5 @@
/*
- * $Id: ftypes-int.h,v 1.8 2003/06/11 21:24:54 gram Exp $
+ * $Id: ftypes-int.h,v 1.9 2003/07/25 03:44:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -29,6 +29,7 @@
typedef void (*FvalueNewFunc)(fvalue_t*);
typedef void (*FvalueFreeFunc)(fvalue_t*);
+typedef gboolean (*FvalueFromUnparsed)(fvalue_t*, char*, LogFunc);
typedef gboolean (*FvalueFromString)(fvalue_t*, char*, LogFunc);
typedef void (*FvalueToStringRepr)(fvalue_t*, ftrepr_t, char*);
typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t);
@@ -52,6 +53,7 @@ struct _ftype_t {
int wire_size;
FvalueNewFunc new_value;
FvalueFreeFunc free_value;
+ FvalueFromUnparsed val_from_unparsed;
FvalueFromString val_from_string;
FvalueToStringRepr val_to_string_repr;
FvalueStringReprLen len_string_repr;
diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c
index fb07b1a738..aa2239397f 100644
--- a/epan/ftypes/ftypes.c
+++ b/epan/ftypes/ftypes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftypes.c,v 1.9 2003/06/11 21:24:54 gram Exp $
+ * $Id: ftypes.c,v 1.10 2003/07/25 03:44:03 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -235,7 +235,24 @@ fvalue_free(fvalue_t *fv)
g_mem_chunk_free(gmc_fvalue, fv);
}
+fvalue_t*
+fvalue_from_unparsed(ftenum_t ftype, char *s, LogFunc logfunc)
+{
+ fvalue_t *fv;
+ fv = fvalue_new(ftype);
+ if (fv->ftype->val_from_unparsed) {
+ if (fv->ftype->val_from_unparsed(fv, s, logfunc)) {
+ return fv;
+ }
+ }
+ else {
+ logfunc("\"%s\" cannot be converted to %s.",
+ s, ftype_pretty_name(ftype));
+ }
+ fvalue_free(fv);
+ return NULL;
+}
fvalue_t*
fvalue_from_string(ftenum_t ftype, char *s, LogFunc logfunc)
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 9ddac05bb6..1e224cbf53 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.17 2003/06/11 21:24:54 gram Exp $
+ * $Id: ftypes.h,v 1.18 2003/07/25 03:44:04 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -73,6 +73,7 @@ enum ftrepr {
typedef enum ftrepr ftrepr_t;
+
/* Initialize the ftypes subsytem. Called once. */
void
ftypes_initialize(void);
@@ -151,6 +152,9 @@ fvalue_free(fvalue_t *fv);
typedef void (*LogFunc)(char*,...);
fvalue_t*
+fvalue_from_unparsed(ftenum_t ftype, char *s, LogFunc log);
+
+fvalue_t*
fvalue_from_string(ftenum_t ftype, char *s, LogFunc log);
/* Returns the length of the string required to hold the