# 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>
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 \
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 \
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 \
"-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 \
$(ethereal_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
+ @PCRE_LIBS@ \
@PCAP_LIBS@ @GTK_LIBS@ @ADNS_LIBS@
TETHEREAL_TAP_SRC = \
$(tethereal_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
+ @PCRE_LIBS@ \
@GLIB_LIBS@ -lm \
@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ @ADNS_LIBS@
$(dftest_additional_libs) \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
+ @PCRE_LIBS@ \
@GLIB_LIBS@ -lm \
@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ @ADNS_LIBS@
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
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
+])
+
#
# AC_ETHEREAL_UCDSNMP_CHECK
#
-# $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
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)
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
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"
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
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
+])
-# $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
[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
/*
- * $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>
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;
/*
- * $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>
ANY_LT,
ANY_LE,
ANY_CONTAINS,
+ ANY_MATCHES,
MK_RANGE
} dfvm_opcode_t;
/*
- * $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>
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;
}
}
-/* $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
/* 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 */
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; }
%{
/*
- * $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>
"(" 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);
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:
/*
- * $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>
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();
/*
- * $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>
return 2;
case TEST_OP_CONTAINS:
return 2;
+ case TEST_OP_MATCHES:
+ return 2;
}
g_assert_not_reached();
return -1;
/*
- * $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>
TEST_OP_GE,
TEST_OP_LT,
TEST_OP_LE,
- TEST_OP_CONTAINS
+ TEST_OP_CONTAINS,
+ TEST_OP_MATCHES
} test_op_t;
void
/*
- * $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>
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
cmp_lt,
cmp_le,
cmp_contains,
+ NULL, /* cmp_matches */
len,
slice,
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
len,
slice,
cmp_lt_i64,
cmp_le_i64,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
len,
slice,
/*
- * $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>
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
/*
- * $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>
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
s_cmp_lt,
s_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
NULL, /* cmp_lt */
NULL, /* cmp_le */
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
u_cmp_lt,
u_cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL, /* len */
NULL, /* slice */
/*
- * $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>
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL,
/*
- * $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>
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,
/*
- * $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>
#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)
{
}
}
+#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)
{
cmp_ge,
cmp_lt,
cmp_le,
- cmp_contains, /* cmp_contains */
+ cmp_contains,
+ CMP_MATCHES,
len,
slice,
cmp_lt,
cmp_le,
cmp_contains, /* cmp_contains */
+ CMP_MATCHES,
len,
slice,
cmp_lt,
cmp_le,
cmp_contains, /* cmp_contains */
+ CMP_MATCHES,
len,
slice,
/*
- * $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>
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL
cmp_lt,
cmp_le,
NULL, /* cmp_contains */
+ NULL, /* cmp_matches */
NULL,
NULL
/*
- * $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>
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,
/*
- * $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>
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 */
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);
+}
/* 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>
gboolean
ftype_can_contains(enum ftenum ftype);
+gboolean
+ftype_can_matches(enum ftenum ftype);
+
/* ---------------- FVALUE ----------------- */
#include <epan/ipv4.h>
FvalueCmp cmp_lt;
FvalueCmp cmp_le;
FvalueCmp cmp_contains;
+ FvalueCmp cmp_matches;
FvalueLen len;
FvalueSlice slice;
gboolean
fvalue_contains(fvalue_t *a, fvalue_t *b);
+gboolean
+fvalue_matches(fvalue_t *a, fvalue_t *b);
+
guint
fvalue_length(fvalue_t *fv);
/* 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>
#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 */
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, " ");
#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 */
}
/*