summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am13
-rw-r--r--acinclude.m4104
-rw-r--r--configure.in45
-rw-r--r--epan/acinclude.m4104
-rw-r--r--epan/configure.in36
-rw-r--r--epan/dfilter/dfvm.c7
-rw-r--r--epan/dfilter/dfvm.h3
-rw-r--r--epan/dfilter/gencode.c6
-rw-r--r--epan/dfilter/grammar.lemon5
-rw-r--r--epan/dfilter/scanner.l37
-rw-r--r--epan/dfilter/semcheck.c10
-rw-r--r--epan/dfilter/sttype-test.c4
-rw-r--r--epan/dfilter/sttype-test.h5
-rw-r--r--epan/ftypes/ftype-bytes.c8
-rw-r--r--epan/ftypes/ftype-double.c4
-rw-r--r--epan/ftypes/ftype-integer.c13
-rw-r--r--epan/ftypes/ftype-ipv4.c3
-rw-r--r--epan/ftypes/ftype-none.c15
-rw-r--r--epan/ftypes/ftype-string.c62
-rw-r--r--epan/ftypes/ftype-time.c4
-rw-r--r--epan/ftypes/ftype-tvbuff.c17
-rw-r--r--epan/ftypes/ftypes.c19
-rw-r--r--epan/ftypes/ftypes.h9
-rw-r--r--util.c36
24 files changed, 508 insertions, 61 deletions
diff --git a/Makefile.am b/Makefile.am
index 775871088c..cb18f1ce0b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.663 2003/12/06 06:09:10 gram Exp $
+# $Id: Makefile.am,v 1.664 2003/12/06 16:35:17 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -481,7 +481,7 @@ if HAVE_PLUGINS
plugin_libs = \
plugins/acn/acn.la \
plugins/artnet/artnet.la \
- plugins/asn1/asn1.la \
+ plugins/asn1/asn1.la \
plugins/docsis/docsis.la \
plugins/enttec/enttec.la \
plugins/giop/cosnaming.la \
@@ -498,7 +498,7 @@ if ENABLE_STATIC
plugin_ldadd = \
plugins/acn/packet-acn.o \
plugins/artnet/packet-artnet.o \
- plugins/asn1/packet-asn1.o \
+ plugins/asn1/packet-asn1.o \
plugins/docsis/packet-bpkmattr.o \
plugins/docsis/packet-bpkmreq.o \
plugins/docsis/packet-bpkmrsp.o \
@@ -536,7 +536,7 @@ plugin_ldadd = \
plugin_src = \
plugins/acn/packet-acn.c \
plugins/artnet/packet-artnet.c \
- plugins/asn1/packet-asn1.c \
+ plugins/asn1/packet-asn1.c \
plugins/docsis/packet-bpkmattr.c \
plugins/docsis/packet-bpkmreq.c \
plugins/docsis/packet-bpkmrsp.c \
@@ -576,7 +576,7 @@ plugin_ldadd = \
"-dlopen" self \
"-dlopen" plugins/acn/acn.la \
"-dlopen" plugins/artnet/artnet.la \
- "-dlopen" plugins/asn1/asn1.la \
+ "-dlopen" plugins/asn1/asn1.la \
"-dlopen" plugins/docsis/docsis.la \
"-dlopen" plugins/enttec/enttec.la \
"-dlopen" plugins/giop/cosnaming.la \
@@ -930,6 +930,7 @@ ethereal_LDADD = \
$(ethereal_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
+ @PCRE_LIBS@ \
@PCAP_LIBS@ @GTK_LIBS@ @ADNS_LIBS@
TETHEREAL_TAP_SRC = \
@@ -978,6 +979,7 @@ tethereal_LDADD = \
$(tethereal_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
+ @PCRE_LIBS@ \
@GLIB_LIBS@ -lm \
@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ @ADNS_LIBS@
@@ -1119,6 +1121,7 @@ dftest_LDADD = \
$(dftest_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
+ @PCRE_LIBS@ \
@GLIB_LIBS@ -lm \
@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ @ADNS_LIBS@
diff --git a/acinclude.m4 b/acinclude.m4
index 76109ff08f..36f4eecc85 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2,7 +2,7 @@ dnl Macros that test for specific features.
dnl This file is part of the Autoconf packaging for Ethereal.
dnl Copyright (C) 1998-2000 by Gerald Combs.
dnl
-dnl $Id: acinclude.m4,v 1.62 2003/11/01 02:30:14 guy Exp $
+dnl $Id: acinclude.m4,v 1.63 2003/12/06 16:35:18 gram Exp $
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@@ -513,6 +513,108 @@ AC_DEFUN(AC_ETHEREAL_ZLIB_CHECK,
])
#
+# AC_ETHEREAL_LIBPCRE_CHECK
+#
+AC_DEFUN(AC_ETHEREAL_LIBPCRE_CHECK,
+[
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # The user specified a directory in which libpcre resides,
+ # so add the "include" subdirectory of that directory to
+ # the include file search path and the "lib" subdirectory
+ # of that directory to the library search path.
+ #
+ # XXX - if there's also a libpcre in a directory that's
+ # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
+ # make us find the version in the specified directory,
+ # as the compiler and/or linker will search that other
+ # directory before it searches the specified directory.
+ #
+ ethereal_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -I$pcre_dir/include"
+ ethereal_save_CPPLAGS="$CPPLAGS"
+ CPPFLAGS="$CPPFLAGS -I$pcre_dir/include"
+ ethereal_save_LIBS="$LIBS"
+ PCRE_LIBS="-L$pcre_dir/lib -lpcre"
+ fi
+
+ #
+ # Make sure we have "pcre.h". If we don't, it means we probably
+ # don't have libpcre, so don't use it.
+ #
+ AC_CHECK_HEADER(pcre.h,,
+ [
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # The user used "--with-pcre=" to specify a directory
+ # containing libpcre, but we didn't find the header file
+ # there; that either means they didn't specify the
+ # right directory or are confused about whether libpcre
+ # is, in fact, installed. Report the error and give up.
+ #
+ AC_MSG_ERROR([libpcre header not found in directory specified in --with-pcre])
+ else
+ if test "x$want_pcre" = "xyes"
+ then
+ #
+ # The user tried to force us to use the library, but we
+ # couldn't find the header file; report an error.
+ #
+ AC_MSG_ERROR(Header file pcre.h not found.)
+ else
+ #
+ # We couldn't find the header file; don't use the
+ # library, as it's probably not present.
+ #
+ want_pcre=no
+ fi
+ fi
+ ])
+
+ if test "x$want_pcre" != "xno"
+ then
+ #
+ # Well, we at least have the pcre header file.
+ #
+ # We're only using standard functions from libpcre,
+ # so we don't need to perform extra checks.
+ #
+ AC_CHECK_LIB(pcre, pcre_compile,
+ [
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # Put the "-I" and "-L" flags for pcre at
+ # the beginning of CFLAGS, CPPFLAGS, and
+ # LIBS.
+ #
+ PCRE_LIBS="-L$pcre_dir/lib -lpcre $ethereal_save_LIBS"
+ else
+ PCRE_LIBS="-lpcre"
+ fi
+ AC_DEFINE(HAVE_LIBPCRE, 1, [Define to use libpcre library])
+ ],[
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # Restore the versions of CFLAGS, CPPFLAGS,
+ # and LIBS before we added the "-with-pcre="
+ # directory, as we didn't actually find
+ # pcre there.
+ #
+ CFLAGS="$ethereal_save_CFLAGS"
+ CPPFLAGS="$ethereal_save_CPPLAGS"
+ PCRE_LIBS=""
+ fi
+ want_pcre=no
+ ])
+ AC_SUBST(PCRE_LIBS)
+ fi
+])
+
+#
# AC_ETHEREAL_UCDSNMP_CHECK
#
AC_DEFUN(AC_ETHEREAL_UCDSNMP_CHECK,
diff --git a/configure.in b/configure.in
index 31e7b15f5a..aa3633dd6b 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.233 2003/11/18 08:13:05 guy Exp $
+# $Id: configure.in,v 1.234 2003/12/06 16:35:18 gram Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@@ -520,6 +520,42 @@ else
fi
+dnl pcre check
+AC_MSG_CHECKING(whether to use libpcre for regular expressions in dfilters)
+
+AC_ARG_WITH(pcre,
+changequote(<<, >>)dnl
+<< --with-pcre[=DIR] use libpcre (located in directory DIR, if supplied) to use in dfilter regular expressions. [default=yes, if present]>>,
+changequote([, ])dnl
+[
+ if test $withval = no
+ then
+ want_pcre=no
+ elif test $withval = yes
+ then
+ want_pcre=yes
+ else
+ want_pcre=yes
+ pcre_dir=$withval
+ fi
+],[
+ #
+ # Use libpcre if it's present, otherwise don't.
+ #
+ want_pcre=ifpresent
+ pcre_dir=
+])
+if test "x$want_pcre" = "xno" ; then
+ AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(yes)
+ AC_ETHEREAL_LIBPCRE_CHECK
+ if test "x$want_pcre" = "xno" ; then
+ AC_MSG_RESULT(libpcre not found - disabling support for perl compatible regular expressions in dfilters)
+ fi
+fi
+
+
dnl ipv6 check
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 use ipv6 name resolution, if available. [default=yes]],enable_ipv6=$enableval,enable_ipv6=yes)
@@ -860,6 +896,12 @@ else
zlib_message="yes"
fi
+if test "x$want_pcre" = "xno" ; then
+ pcre_message="no"
+else
+ pcre_message="yes"
+fi
+
if test "x$have_good_adns" = "xyes" ; then
adns_message="yes"
else
@@ -894,6 +936,7 @@ echo " Build profile binaries : $enable_profile_build"
fi
echo " Use pcap library : $want_pcap"
echo " Use zlib library : $zlib_message"
+echo " Use pcre library : $pcre_message"
echo " Use GNU ADNS library : $adns_message"
echo " Use IPv6 name resolution : $enable_ipv6"
echo " Use UCD SNMP/NET-SNMP library : $snmp_libs_message"
diff --git a/epan/acinclude.m4 b/epan/acinclude.m4
index 77b339e106..a747c8b362 100644
--- a/epan/acinclude.m4
+++ b/epan/acinclude.m4
@@ -2,7 +2,7 @@ dnl Macros that test for specific features.
dnl This file is part of the Autoconf packaging for Ethereal.
dnl Copyright (C) 1998-2000 by Gerald Combs.
dnl
-dnl $Id: acinclude.m4,v 1.3 2003/08/21 07:17:09 guy Exp $
+dnl $Id: acinclude.m4,v 1.4 2003/12/06 16:35:18 gram Exp $
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@@ -182,3 +182,105 @@ changequote([, ])dnl
AC_MSG_RESULT(not required)
fi
])
+
+#
+# AC_ETHEREAL_LIBPCRE_CHECK
+#
+AC_DEFUN(AC_ETHEREAL_LIBPCRE_CHECK,
+[
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # The user specified a directory in which libpcre resides,
+ # so add the "include" subdirectory of that directory to
+ # the include file search path and the "lib" subdirectory
+ # of that directory to the library search path.
+ #
+ # XXX - if there's also a libpcre in a directory that's
+ # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
+ # make us find the version in the specified directory,
+ # as the compiler and/or linker will search that other
+ # directory before it searches the specified directory.
+ #
+ ethereal_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -I$pcre_dir/include"
+ ethereal_save_CPPLAGS="$CPPLAGS"
+ CPPFLAGS="$CPPFLAGS -I$pcre_dir/include"
+ ethereal_save_LIBS="$LIBS"
+ PCRE_LIBS="-L$pcre_dir/lib -lpcre"
+ fi
+
+ #
+ # Make sure we have "pcre.h". If we don't, it means we probably
+ # don't have libpcre, so don't use it.
+ #
+ AC_CHECK_HEADER(pcre.h,,
+ [
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # The user used "--with-pcre=" to specify a directory
+ # containing libpcre, but we didn't find the header file
+ # there; that either means they didn't specify the
+ # right directory or are confused about whether libpcre
+ # is, in fact, installed. Report the error and give up.
+ #
+ AC_MSG_ERROR([libpcre header not found in directory specified in --with-pcre])
+ else
+ if test "x$want_pcre" = "xyes"
+ then
+ #
+ # The user tried to force us to use the library, but we
+ # couldn't find the header file; report an error.
+ #
+ AC_MSG_ERROR(Header file pcre.h not found.)
+ else
+ #
+ # We couldn't find the header file; don't use the
+ # library, as it's probably not present.
+ #
+ want_pcre=no
+ fi
+ fi
+ ])
+
+ if test "x$want_pcre" != "xno"
+ then
+ #
+ # Well, we at least have the pcre header file.
+ #
+ # We're only using standard functions from libpcre,
+ # so we don't need to perform extra checks.
+ #
+ AC_CHECK_LIB(pcre, pcre_compile,
+ [
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # Put the "-I" and "-L" flags for pcre at
+ # the beginning of CFLAGS, CPPFLAGS, and
+ # LIBS.
+ #
+ PCRE_LIBS="-L$pcre_dir/lib -lpcre $ethereal_save_LIBS"
+ else
+ PCRE_LIBS="-lpcre"
+ fi
+ AC_DEFINE(HAVE_LIBPCRE, 1, [Define to use libpcre library])
+ ],[
+ if test "x$pcre_dir" != "x"
+ then
+ #
+ # Restore the versions of CFLAGS, CPPFLAGS,
+ # and LIBS before we added the "-with-pcre="
+ # directory, as we didn't actually find
+ # pcre there.
+ #
+ CFLAGS="$ethereal_save_CFLAGS"
+ CPPFLAGS="$ethereal_save_CPPLAGS"
+ PCRE_LIBS=""
+ fi
+ want_pcre=no
+ ])
+ AC_SUBST(PCRE_LIBS)
+ fi
+])
diff --git a/epan/configure.in b/epan/configure.in
index f540653059..a6501d3c51 100644
--- a/epan/configure.in
+++ b/epan/configure.in
@@ -1,4 +1,4 @@
-# $Id: configure.in,v 1.49 2003/11/18 08:13:09 guy Exp $
+# $Id: configure.in,v 1.50 2003/12/06 16:35:18 gram Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@@ -235,6 +235,40 @@ AC_CHECK_FUNC(strptime, ,
[AC_DEFINE(NEED_STRPTIME_H, 1, [Define if strptime.h needs to be included])
])
+dnl pcre check
+AC_MSG_CHECKING(whether to use libpcre for regular expressions in dfilters)
+AC_ARG_WITH(pcre,
+changequote(<<, >>)dnl
+<< --with-pcre[=DIR] use libpcre (located in directory DIR, if supplied) to use in dfilter regular expressions. [default=yes, if present]>>,
+changequote([, ])dnl
+[
+ if test $withval = no
+ then
+ want_pcre=no
+ elif test $withval = yes
+ then
+ want_pcre=yes
+ else
+ want_pcre=yes
+ pcre_dir=$withval
+ fi
+],[
+ #
+ # Use libpcre if it's present, otherwise don't.
+ #
+ want_pcre=ifpresent
+ pcre_dir=
+])
+if test "x$want_pcre" = "xno" ; then
+ AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(yes)
+ AC_ETHEREAL_LIBPCRE_CHECK
+ if test "x$want_pcre" = "xno" ; then
+ AC_MSG_RESULT(libpcre not found - disabling support for perl compatible regular expressions in dfilters)
+ fi
+fi
+
dnl ADNS Check
AC_MSG_CHECKING(whether to use the GNU ADNS library if available)
if test "x$enable_adns" = "xno" ; then
diff --git a/epan/dfilter/dfvm.c b/epan/dfilter/dfvm.c
index be409ed35b..3843d4609b 100644
--- a/epan/dfilter/dfvm.c
+++ b/epan/dfilter/dfvm.c
@@ -1,5 +1,5 @@
/*
- * $Id: dfvm.c,v 1.12 2003/12/02 21:15:48 guy Exp $
+ * $Id: dfvm.c,v 1.13 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -408,6 +408,11 @@ dfvm_apply(dfilter_t *df, proto_tree *tree)
arg1->value.numeric, arg2->value.numeric);
break;
+ case ANY_MATCHES:
+ accum = any_test(df, fvalue_matches,
+ arg1->value.numeric, arg2->value.numeric);
+ break;
+
case NOT:
accum = !accum;
break;
diff --git a/epan/dfilter/dfvm.h b/epan/dfilter/dfvm.h
index efeb478962..2f45043699 100644
--- a/epan/dfilter/dfvm.h
+++ b/epan/dfilter/dfvm.h
@@ -1,5 +1,5 @@
/*
- * $Id: dfvm.h,v 1.9 2003/08/27 15:23:04 gram Exp $
+ * $Id: dfvm.h,v 1.10 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -68,6 +68,7 @@ typedef enum {
ANY_LT,
ANY_LE,
ANY_CONTAINS,
+ ANY_MATCHES,
MK_RANGE
} dfvm_opcode_t;
diff --git a/epan/dfilter/gencode.c b/epan/dfilter/gencode.c
index 333fdacf38..992e3afe5b 100644
--- a/epan/dfilter/gencode.c
+++ b/epan/dfilter/gencode.c
@@ -1,5 +1,5 @@
/*
- * $Id: gencode.c,v 1.11 2003/08/27 15:23:04 gram Exp $
+ * $Id: gencode.c,v 1.12 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -323,6 +323,10 @@ gen_test(dfwork_t *dfw, stnode_t *st_node)
case TEST_OP_CONTAINS:
gen_relation(dfw, ANY_CONTAINS, st_arg1, st_arg2);
break;
+
+ case TEST_OP_MATCHES:
+ gen_relation(dfw, ANY_MATCHES, st_arg1, st_arg2);
+ break;
}
}
diff --git a/epan/dfilter/grammar.lemon b/epan/dfilter/grammar.lemon
index c114892034..8a7e280796 100644
--- a/epan/dfilter/grammar.lemon
+++ b/epan/dfilter/grammar.lemon
@@ -1,4 +1,4 @@
-/* $Id: grammar.lemon,v 1.6 2003/08/27 15:23:04 gram Exp $ */
+/* $Id: grammar.lemon,v 1.7 2003/12/06 16:35:19 gram Exp $ */
%include {
#ifdef HAVE_CONFIG_H
@@ -108,7 +108,7 @@ shifting 3 more symbols. */
/* Associativity */
%left TEST_AND.
%left TEST_OR.
-%nonassoc TEST_EQ TEST_NE TEST_LT TEST_LE TEST_GT TEST_GE TEST_CONTAINS.
+%nonassoc TEST_EQ TEST_NE TEST_LT TEST_LE TEST_GT TEST_GE TEST_CONTAINS TEST_MATCHES.
%right TEST_NOT.
/* Top-level targets */
@@ -248,6 +248,7 @@ rel_op2(O) ::= TEST_GE. { O = TEST_OP_GE; }
rel_op2(O) ::= TEST_LT. { O = TEST_OP_LT; }
rel_op2(O) ::= TEST_LE. { O = TEST_OP_LE; }
rel_op2(O) ::= TEST_CONTAINS. { O = TEST_OP_CONTAINS; }
+rel_op2(O) ::= TEST_MATCHES. { O = TEST_OP_MATCHES; }
diff --git a/epan/dfilter/scanner.l b/epan/dfilter/scanner.l
index 7d0aa95126..e37df4063d 100644
--- a/epan/dfilter/scanner.l
+++ b/epan/dfilter/scanner.l
@@ -1,6 +1,6 @@
%{
/*
- * $Id: scanner.l,v 1.10 2003/10/27 22:45:47 guy Exp $
+ * $Id: scanner.l,v 1.11 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -65,26 +65,26 @@ GString* quoted_string = NULL;
"(" return simple(TOKEN_LPAREN);
")" return simple(TOKEN_RPAREN);
-"==" return simple(TOKEN_TEST_EQ);
-"eq" return simple(TOKEN_TEST_EQ);
-"!=" return simple(TOKEN_TEST_NE);
-"ne" return simple(TOKEN_TEST_NE);
+"==" return simple(TOKEN_TEST_EQ);
+"eq" return simple(TOKEN_TEST_EQ);
+"!=" return simple(TOKEN_TEST_NE);
+"ne" return simple(TOKEN_TEST_NE);
">" return simple(TOKEN_TEST_GT);
-"gt" return simple(TOKEN_TEST_GT);
-">=" return simple(TOKEN_TEST_GE);
-"ge" return simple(TOKEN_TEST_GE);
+"gt" return simple(TOKEN_TEST_GT);
+">=" return simple(TOKEN_TEST_GE);
+"ge" return simple(TOKEN_TEST_GE);
"<" return simple(TOKEN_TEST_LT);
-"lt" return simple(TOKEN_TEST_LT);
-"<=" return simple(TOKEN_TEST_LE);
-"le" return simple(TOKEN_TEST_LE);
-"contains" return simple(TOKEN_TEST_CONTAINS);
-
+"lt" return simple(TOKEN_TEST_LT);
+"<=" return simple(TOKEN_TEST_LE);
+"le" return simple(TOKEN_TEST_LE);
+"contains" return simple(TOKEN_TEST_CONTAINS);
+"matches" return simple(TOKEN_TEST_MATCHES);
"!" return simple(TOKEN_TEST_NOT);
-"not" return simple(TOKEN_TEST_NOT);
-"&&" return simple(TOKEN_TEST_AND);
-"and" return simple(TOKEN_TEST_AND);
-"||" return simple(TOKEN_TEST_OR);
-"or" return simple(TOKEN_TEST_OR);
+"not" return simple(TOKEN_TEST_NOT);
+"&&" return simple(TOKEN_TEST_AND);
+"and" return simple(TOKEN_TEST_AND);
+"||" return simple(TOKEN_TEST_OR);
+"or" return simple(TOKEN_TEST_OR);
@@ -223,6 +223,7 @@ simple(int token)
case TOKEN_TEST_LT:
case TOKEN_TEST_LE:
case TOKEN_TEST_CONTAINS:
+ case TOKEN_TEST_MATCHES:
case TOKEN_TEST_NOT:
case TOKEN_TEST_AND:
case TOKEN_TEST_OR:
diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c
index 8bcf967d59..865d74deb2 100644
--- a/epan/dfilter/semcheck.c
+++ b/epan/dfilter/semcheck.c
@@ -1,5 +1,5 @@
/*
- * $Id: semcheck.c,v 1.19 2003/08/27 15:23:04 gram Exp $
+ * $Id: semcheck.c,v 1.20 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -694,6 +694,14 @@ check_test(stnode_t *st_node)
case TEST_OP_CONTAINS:
check_relation("contains", TRUE, ftype_can_contains, st_node, st_arg1, st_arg2);
break;
+ case TEST_OP_MATCHES:
+#ifdef HAVE_LIBPCRE
+ check_relation("matches", TRUE, ftype_can_matches, st_node, st_arg1, st_arg2);
+#else
+ dfilter_fail("This Ethereal version does not support the \"matches\" operation.");
+ THROW(TypeError);
+#endif
+ break;
default:
g_assert_not_reached();
diff --git a/epan/dfilter/sttype-test.c b/epan/dfilter/sttype-test.c
index f6f917f1fc..d01bf1472b 100644
--- a/epan/dfilter/sttype-test.c
+++ b/epan/dfilter/sttype-test.c
@@ -1,5 +1,5 @@
/*
- * $Id: sttype-test.c,v 1.4 2003/08/27 15:23:05 gram Exp $
+ * $Id: sttype-test.c,v 1.5 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -92,6 +92,8 @@ num_operands(test_op_t op)
return 2;
case TEST_OP_CONTAINS:
return 2;
+ case TEST_OP_MATCHES:
+ return 2;
}
g_assert_not_reached();
return -1;
diff --git a/epan/dfilter/sttype-test.h b/epan/dfilter/sttype-test.h
index f662a5b097..cdbf48b0ba 100644
--- a/epan/dfilter/sttype-test.h
+++ b/epan/dfilter/sttype-test.h
@@ -1,5 +1,5 @@
/*
- * $Id: sttype-test.h,v 1.4 2003/08/27 15:23:05 gram Exp $
+ * $Id: sttype-test.h,v 1.5 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -36,7 +36,8 @@ typedef enum {
TEST_OP_GE,
TEST_OP_LT,
TEST_OP_LE,
- TEST_OP_CONTAINS
+ TEST_OP_CONTAINS,
+ TEST_OP_MATCHES
} test_op_t;
void
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c
index 84c9f58a64..ddb3138769 100644
--- a/epan/ftypes/ftype-bytes.c
+++ b/epan/ftypes/ftype-bytes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-bytes.c,v 1.18 2003/10/29 23:48:14 guy Exp $
+ * $Id: ftype-bytes.c,v 1.19 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -642,6 +642,7 @@ ftype_register_bytes(void)
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
@@ -673,6 +674,7 @@ ftype_register_bytes(void)
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
@@ -704,6 +706,7 @@ ftype_register_bytes(void)
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
@@ -735,6 +738,7 @@ ftype_register_bytes(void)
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
@@ -766,6 +770,7 @@ ftype_register_bytes(void)
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
len,
slice,
@@ -797,6 +802,7 @@ ftype_register_bytes(void)
cmp_lt_i64,
cmp_le_i64,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
len,
slice,
diff --git a/epan/ftypes/ftype-double.c b/epan/ftypes/ftype-double.c
index 27fba9aaf4..0038591d11 100644
--- a/epan/ftypes/ftype-double.c
+++ b/epan/ftypes/ftype-double.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-double.c,v 1.11 2003/08/27 15:23:06 gram Exp $
+ * $Id: ftype-double.c,v 1.12 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -182,6 +182,7 @@ ftype_register_double(void)
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
@@ -213,6 +214,7 @@ ftype_register_double(void)
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
diff --git a/epan/ftypes/ftype-integer.c b/epan/ftypes/ftype-integer.c
index 0bba4d218b..b6e32f83df 100644
--- a/epan/ftypes/ftype-integer.c
+++ b/epan/ftypes/ftype-integer.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-integer.c,v 1.15 2003/08/27 15:23:06 gram Exp $
+ * $Id: ftype-integer.c,v 1.16 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -243,6 +243,7 @@ ftype_register_integers(void)
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -273,6 +274,7 @@ ftype_register_integers(void)
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -303,6 +305,7 @@ ftype_register_integers(void)
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -333,6 +336,7 @@ ftype_register_integers(void)
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -363,6 +367,7 @@ ftype_register_integers(void)
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -393,6 +398,7 @@ ftype_register_integers(void)
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -423,6 +429,7 @@ ftype_register_integers(void)
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -453,6 +460,7 @@ ftype_register_integers(void)
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -483,6 +491,7 @@ ftype_register_integers(void)
NULL, /* cmp_lt */
NULL, /* cmp_le */
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -514,6 +523,7 @@ ftype_register_integers(void)
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
@@ -545,6 +555,7 @@ ftype_register_integers(void)
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index 107b5c2525..abdbd7bad5 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-ipv4.c,v 1.14 2003/11/25 13:20:35 sahlberg Exp $
+ * $Id: ftype-ipv4.c,v 1.15 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -203,6 +203,7 @@ ftype_register_ipv4(void)
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
diff --git a/epan/ftypes/ftype-none.c b/epan/ftypes/ftype-none.c
index 46c1822a80..0dcb2f6e83 100644
--- a/epan/ftypes/ftype-none.c
+++ b/epan/ftypes/ftype-none.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-none.c,v 1.7 2003/08/27 15:23:07 gram Exp $
+ * $Id: ftype-none.c,v 1.8 2003/12/06 16:35:19 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -51,13 +51,14 @@ ftype_register_none(void)
NULL,
NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
+ NULL, /* cmp_eq */
+ NULL, /* cmp_ne */
+ NULL, /* cmp_gt */
+ NULL, /* cmp_ge */
+ NULL, /* cmp_lt */
+ NULL, /* cmp_le */
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index 4abdeca986..a70425a733 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-string.c,v 1.15 2003/11/25 13:20:36 sahlberg Exp $
+ * $Id: ftype-string.c,v 1.16 2003/12/06 16:35:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -27,6 +27,13 @@
#include <ftypes-int.h>
#include <string.h>
+#ifdef HAVE_LIBPCRE
+#include <pcre.h>
+#define CMP_MATCHES cmp_matches
+#else
+#define CMP_MATCHES NULL
+#endif
+
static void
string_fvalue_new(fvalue_t *fv)
{
@@ -226,6 +233,54 @@ cmp_contains(fvalue_t *fv_a, fvalue_t *fv_b)
}
}
+#ifdef HAVE_LIBPCRE
+static gboolean
+cmp_matches(fvalue_t *fv_a, fvalue_t *fv_b)
+{
+ pcre *re;
+ const char *pcre_error_text;
+ int pcre_error_offset;
+ int options = 0;
+ int rc;
+ pcre_extra *pe = NULL; /* TODO - pcre_study() */
+
+ re = pcre_compile(
+ fv_b->value.string, /* pattern */
+ options, /* PCRE options */
+ &pcre_error_text, /* PCRE constant error string */
+ &pcre_error_offset, /* Start offset of error in pattern */
+ NULL /* Default char tables (C locale) */
+ );
+ if (re == NULL) {
+ /* TODO - Do something with pcre_error and pcre_error_offset */
+ return FALSE;
+ }
+ /* TODO - Study the RE *if* the compile & study only happens once * /
+ pe = pcre_study(re, 0, &pcre_error_text);
+ if (pcre_error != NULL) {
+ / * TODO - Do something with pcre_error and pcre_error_offset * /
+ return FALSE;
+ }
+ */
+ rc = pcre_exec(
+ re, /* Compiled PCRE */
+ pe, /* PCRE extra from pcre_study() */
+ fv_a->value.string, /* The data to check for the pattern */
+ (int)strlen(fv_a->value.string), /* and its length */
+ 0, /* Start offset within data */
+ options, /* PCRE options */
+ NULL, /* We are not interested in the matched string */
+ 0 /* of the pattern; only in success or failure. */
+ );
+ /* if (pe != NULL)
+ g_free(pe); */
+ g_free(re);
+ if (rc == 0)
+ return TRUE;
+ return FALSE;
+}
+#endif
+
void
ftype_register_string(void)
{
@@ -255,7 +310,8 @@ ftype_register_string(void)
cmp_ge,
cmp_lt,
cmp_le,
- cmp_contains, /* cmp_contains */
+ cmp_contains,
+ CMP_MATCHES,
len,
slice,
@@ -286,6 +342,7 @@ ftype_register_string(void)
cmp_lt,
cmp_le,
cmp_contains, /* cmp_contains */
+ CMP_MATCHES,
len,
slice,
@@ -316,6 +373,7 @@ ftype_register_string(void)
cmp_lt,
cmp_le,
cmp_contains, /* cmp_contains */
+ CMP_MATCHES,
len,
slice,
diff --git a/epan/ftypes/ftype-time.c b/epan/ftypes/ftype-time.c
index d926d30365..8456bf6a31 100644
--- a/epan/ftypes/ftype-time.c
+++ b/epan/ftypes/ftype-time.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-time.c,v 1.21 2003/08/27 15:23:07 gram Exp $
+ * $Id: ftype-time.c,v 1.22 2003/12/06 16:35:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -363,6 +363,7 @@ ftype_register_time(void)
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL
@@ -393,6 +394,7 @@ ftype_register_time(void)
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL
diff --git a/epan/ftypes/ftype-tvbuff.c b/epan/ftypes/ftype-tvbuff.c
index ee0ef58ead..fc4cae972e 100644
--- a/epan/ftypes/ftype-tvbuff.c
+++ b/epan/ftypes/ftype-tvbuff.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftype-tvbuff.c,v 1.12 2003/10/29 23:48:14 guy Exp $
+ * $Id: ftype-tvbuff.c,v 1.13 2003/12/06 16:35:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -190,13 +190,14 @@ ftype_register_tvbuff(void)
NULL,
NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- cmp_contains, /* cmp_contains */
+ NULL, /* cmp_eq */
+ NULL, /* cmp_ne */
+ NULL, /* cmp_gt */
+ NULL, /* cmp_ge */
+ NULL, /* cmp_lt */
+ NULL, /* cmp_le */
+ cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c
index 43b437a49d..c294ed75bb 100644
--- a/epan/ftypes/ftypes.c
+++ b/epan/ftypes/ftypes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftypes.c,v 1.18 2003/12/03 09:28:23 guy Exp $
+ * $Id: ftypes.c,v 1.19 2003/12/06 16:35:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -183,6 +183,15 @@ ftype_can_contains(enum ftenum ftype)
return ft->cmp_contains ? TRUE : FALSE;
}
+gboolean
+ftype_can_matches(enum ftenum ftype)
+{
+ ftype_t *ft;
+
+ FTYPE_LOOKUP(ftype, ft);
+ return ft->cmp_matches ? TRUE : FALSE;
+}
+
/* ---------------------------------------------------------- */
/* Allocate and initialize an fvalue_t, given an ftype */
@@ -501,3 +510,11 @@ fvalue_contains(fvalue_t *a, fvalue_t *b)
g_assert(a->ftype->cmp_contains);
return a->ftype->cmp_contains(a, b);
}
+
+gboolean
+fvalue_matches(fvalue_t *a, fvalue_t *b)
+{
+ /* XXX - check compatibility of a and b */
+ g_assert(a->ftype->cmp_matches);
+ return a->ftype->cmp_matches(a, b);
+}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 00b10c8c04..1ffbef7bff 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.25 2003/12/03 09:28:23 guy Exp $
+ * $Id: ftypes.h,v 1.26 2003/12/06 16:35:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -118,6 +118,9 @@ ftype_can_le(enum ftenum ftype);
gboolean
ftype_can_contains(enum ftenum ftype);
+gboolean
+ftype_can_matches(enum ftenum ftype);
+
/* ---------------- FVALUE ----------------- */
#include <epan/ipv4.h>
@@ -196,6 +199,7 @@ struct _ftype_t {
FvalueCmp cmp_lt;
FvalueCmp cmp_le;
FvalueCmp cmp_contains;
+ FvalueCmp cmp_matches;
FvalueLen len;
FvalueSlice slice;
@@ -292,6 +296,9 @@ fvalue_le(fvalue_t *a, fvalue_t *b);
gboolean
fvalue_contains(fvalue_t *a, fvalue_t *b);
+gboolean
+fvalue_matches(fvalue_t *a, fvalue_t *b);
+
guint
fvalue_length(fvalue_t *fv);
diff --git a/util.c b/util.c
index 1b245c3e3c..26ee78395f 100644
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
/* util.c
* Utility routines
*
- * $Id: util.c,v 1.73 2003/12/01 20:27:09 gerald Exp $
+ * $Id: util.c,v 1.74 2003/12/06 16:35:18 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -60,6 +60,10 @@ typedef int mode_t; /* for win32 */
#include <zlib.h> /* to get the libz version number */
#endif
+#ifdef HAVE_LIBPCRE
+#include <pcre.h> /* to get the libpcre version number */
+#endif /* HAVE_LIBPCRE */
+
#ifdef HAVE_LIBPCAP
#include <pcap.h>
#endif /* HAVE_LIBPCAP */
@@ -152,6 +156,26 @@ get_compiled_version_info(GString *str)
g_string_append(str, ",");
do_word_wrap(str, break_point);
+ g_string_append(str, " ");
+ break_point = str->len - 1;
+#ifdef HAVE_LIBPCRE
+ g_string_append(str, "with libpcre ");
+#ifdef PCRE_MAJOR
+#ifdef PCRE_MINOR
+ g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
+#else /* PCRE_MINOR */
+ g_string_sprintfa(str, "%u", PCRE_MAJOR);
+#endif /* PCRE_MINOR */
+#else /* PCRE_MAJOR */
+ g_string_append(str, "(version unknown)");
+#endif /* PCRE_MAJOR */
+#else /* HAVE_LIBPCRE */
+ g_string_append(str, "without libpcre");
+#endif /* HAVE_LIBPCRE */
+
+ g_string_append(str, ",");
+ do_word_wrap(str, break_point);
+
/* Oh, this is pretty. */
/* Oh, ha. you think that was pretty. Try this:! --Wes */
g_string_append(str, " ");
@@ -181,7 +205,17 @@ get_compiled_version_info(GString *str)
#else
g_string_append(str, "without ADNS");
#endif /* HAVE_GNU_ADNS */
+
+ g_string_append(str, ".");
+ do_word_wrap(str, break_point);
+
+#ifndef HAVE_LIBPCRE
+ break_point = str->len - 1;
+ g_string_append(str,
+ "\nNOTE: this build does not support the \"matches\" operator"
+ "\nfor Ethereal filter syntax.\n");
do_word_wrap(str, break_point);
+#endif /* HAVE_LIBPCRE */
}
/*