Commit Graph

49 Commits

Author SHA1 Message Date
Guy Harris f51bad11d7 Use noyywrap rather than defining our own yywrap functions.
Tweak lemonflex-tail.inc to fix an issue this reveals.

It appears that, at least on the buildbots, the Visual Studio compiler
no longer issues warnings for the code generated with %option noyywrap.

Change-Id: Id64d56f1ae8a79d0336488a4a50518da1f511497
Reviewed-on: https://code.wireshark.org/review/12433
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-05 08:06:50 +00:00
Guy Harris ce22578996 Don't include io.h in Flex scanners - they're not interactive.
We don't have any Flex scanners that support an interactive command-line
interface, so none of our scanners are, or need to be, interactive.
Mark text2pcap's scanner as not interactive.

That means none of our scanners should call isatty(), so they don't have
any need to include <io.h> on Windows; remove that include from the
Lucent/Ascent text capture scanner.

Update a comment to reflect that what matters isn't whether we can read
from a terminal or whether we actually do so, what matters is whether
they read *interactively* from a terminal (if you want to run text2pcap
reading from the standard input and type at it, be my guest).

Change-Id: I59979d1fdb37e1913125a400963ff7a3fa6b9bbd
Reviewed-on: https://code.wireshark.org/review/11587
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-06 01:14:31 +00:00
Jeffrey Smith 57d954e168 Treat IPv4 subnet masks as distinct from addresses
While IPv4 subnet masks are obviously related and similar to IPv4
addresses, they are distinct enough that they need to be treated
seperately in some aspects.  For instance, there is no value in
attempting to resolve a subnet mask.

This change creates a new display type: BASE_NETMASK, which allows distinction from FT_IPv4
(and possible name resolution) where appropriate.

Change-Id: I99e19c9a58eb613f8e58d481af84c30e2e5e14d7
Reviewed-on: https://code.wireshark.org/review/10438
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-01 20:49:42 +00:00
Jeffrey Smith 80322d88da dfilter: Add membership operator
Added a new relational test: 'x in {a b c}'.  The only LHS entity
supported at this time is a field.  The generated DFVM operations are
equivalent to an OR'ed series of =='s, but with the redundant existence
tests removed.

Change-Id: Iddc89b81cf7ad6319aef1a2a94f93314cb721a8a
Reviewed-on: https://code.wireshark.org/review/10246
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-09-11 06:31:33 +00:00
Guy Harris cfcbb28671 Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string.  That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.

Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.

Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.

Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 10:22:59 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Guy Harris ebacca89a7 Add %option noinput to a bunch of Flex files, as we aren't using the
input() routine and thus don't need to have it generated - and as it
produces warnings of a routine defined but not used, we don't want to
have it generated.

Squelch a casting-const-away warning.

svn path=/trunk/; revision=47613
2013-02-10 19:13:07 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Anders Broman d785c79f88 From Jakub Zawadzki :
Add support for prefix in IPv6 address filter.
 
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5538

svn path=/trunk/; revision=38916
2011-09-07 11:03:47 +00:00
Guy Harris 4a7f7dc6d0 Squelch a narrowing warning.
svn path=/trunk/; revision=37227
2011-05-17 23:37:27 +00:00
Guy Harris 02d50e354b Use strtoul() rather than sscanf to parse octal and hex numbers in
escape sequences; sscanf is a bit heavyweight, and using strtoul() also
squelches some "return value ignored" warnings.

svn path=/trunk/; revision=37007
2011-05-06 03:59:44 +00:00
Guy Harris f27e55c241 Back out previous change - I guess the Solaris buildbot has a pre-2.5.30
flex.

svn path=/trunk/; revision=36833
2011-04-23 19:03:05 +00:00
Guy Harris 210cc311fb Try putting the include of config.h at the top of the generated scanner,
so that the config.h definitions are available before we include
anything else; that way, for example, anything defined to enable
large-file support will be defined before we include any system header
files that might depend on it.

svn path=/trunk/; revision=36832
2011-04-23 17:56:43 +00:00
Jeff Morriss 4a8c8e4d7f Fix up indentation a bit
svn path=/trunk/; revision=32617
2010-04-30 21:40:57 +00:00
Guy Harris f0c55f2856 Get rid of unused routine (which gets errors when compiled on Win64).
svn path=/trunk/; revision=27740
2009-03-16 16:49:47 +00:00
Guy Harris caa183b45b We require GLib 2.4 or later, and they define G_MININT32, G_MAXIN32,
G_MAXUINT32, and G_MAXUINT64; don't check whether we need to define them
ourselves.

svn path=/trunk/; revision=25420
2008-06-03 23:57:47 +00:00
Bill Meier 2bce8b248c Bug 2493: Fix (Part 3 of 3):
To prevent Windows compiler errors when using flex 2.5.35.
  Ignore 'signed /unsigned mismatch' warnings


svn path=/trunk/; revision=25174
2008-04-25 18:26:54 +00:00
Bill Meier 0d4b874b44 Bug 2493: Fix (Part 2):
To prevent Windows compiler errors when using flex 2.5.35.
 Fixes "missing unistd.h" and yywrap "mismatched parameter" warnings
 [Upcoming Part 3: ignore 'signed /unsigned mismatch' errors]

svn path=/trunk/; revision=25173
2008-04-25 17:40:29 +00:00
Gerald Combs 9703c2bb75 If "!=" or "ne" are used in a display filter, warn the user that the results
may be unexpected.

svn path=/trunk/; revision=24232
2008-01-31 19:50:38 +00:00
Luis Ontanon 0b43610ea8 Use '~' as a synonim for "matches" replace rogue "s with \042 to avoid some text editors going wild
svn path=/trunk/; revision=22486
2007-08-11 22:05:44 +00:00
Guy Harris 5be4499ad1 Add a script as a front-end for Flex, to work around various problems,
such as the fact that Flex strips all but the last component of the "-o"
argument, and that it doesn't generate a header file to declare routines
the generated lexical analyzer defines.  Use that script when building
lexical analyzers, and, for each lexical analyzer, include the generated
header file in the generated analyzer.

svn path=/trunk/; revision=22446
2007-08-04 02:13:52 +00:00
Guy Harris 968d363f11 Add comments to various %option items to explain what they're doing.
Move the %options to the beginning if they weren't already there, and
put them in the same order in all files.

Add "prefix=" options to .l files that don't already have them, so we
don't have to pass a "-P" option.

Add "never-interactive" and "noyywrap" options to our lexical analyzers,
to remove extra isatty() checks and to eliminate the need for yywrap()
from the Flex library.

Get rid of %option nostdinit - that's the default.

Add .l.c: rules to Makefile.am files, replacing the rules for specific
.l files.  Have those rules all check that $(LEX) is set.

Update the address for the FSF.

svn path=/trunk/; revision=22424
2007-07-30 20:22:37 +00:00
Richard van der Hoff 8177d0f4a9 disable generation of unput to avoid a compiler warning.
svn path=/trunk/; revision=21320
2007-04-03 18:41:24 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Gilbert Ramirez e3899ed4a4 Add infrastructure for display filter functions.
Add upper() and lower() display filter functions for string fields.

svn path=/trunk/; revision=18071
2006-05-02 14:26:17 +00:00
Guy Harris e361585aef The "new" routine for STTYPE_STRING and STTYPE_UNPARSED does a
"strdup()" on the argument, so we don't need to do that ourselves (and,
in fact, as we're doing it ourselves but not freeing the result, we leak
memory).

svn path=/trunk/; revision=13892
2005-03-24 05:27:03 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Guy Harris 12fddb1280 G_MAXINT32, G_MININT32, and G_MAXUINT32 aren't defined by GLib 1.2[.x],
so we have to define them ourselves if they're not defined.

svn path=/trunk/; revision=11384
2004-07-17 08:45:10 +00:00
Guy Harris c27d80c9ad I'm not sure "strtol()" and "strtoul()" are guaranteed to clear "errno"
on success, so we clear it before calling them.

Assign the value of "strtol()" to a "long" and assign the value of
"strtoul()" to an "unsigned long", as those are the return types for
those functions - "gint32" and "guint32" might not be large enough for
the return value on an LP64 platform.

Check for errno being EINVAL, as that can happen if the number isn't
valid.

Before assigning the value returned by "strtol()" or "strtoul()" to the
final destination, check whether it's in the right range for that
destination.

svn path=/trunk/; revision=11382
2004-07-16 23:35:46 +00:00
Guy Harris e1e690ff3a From Graeme Hewson:
Use gint32 instead of guint32 for node data.

Fix up some other signed-vs-unsigned issues in the display filter
parser and lexical analyzer.

svn path=/trunk/; revision=11085
2004-06-03 07:36:25 +00:00
Guy Harris c02072be2c From Graeme Hewson:
Use gint32 instead of guint32 and strtol() instead of strtoul()
     for signed integers.

     Pathological slice specifications could cause Flex default rule
     to be invoked, echoing characters to stdout.
     Example: frame[0foo]==1

svn path=/trunk/; revision=11082
2004-06-03 07:17:24 +00:00
Guy Harris 4befb390d1 From Graeme Hewson: get rid of unnecessary check (it's necessary for
octal, as the maximum of 3 octal digits can be more than 0377, but not
necessary for hex, as the maximum of 2 hex digits can't be more than
0xff).

svn path=/trunk/; revision=10827
2004-05-08 22:03:43 +00:00
Gilbert Ramirez f31ddecf91 Add support for flex 2.5.31.
svn path=/trunk/; revision=10684
2004-04-25 04:53:42 +00:00
Olivier Biot 1791f84919 First attempt at "bitwise AND" display filter operator.
Document how a display operator can be added.

svn path=/trunk/; revision=10250
2004-02-27 12:00:32 +00:00
Guy Harris 60096bfad9 Use -1 rather than 0 as the SCAN_FAILED return value from the lexical
analyzer on errors, and check for SCAN_FAILED from the lexical analyzer
and abort the parse if we see it; 0 means "end of input", and we want to
distinguish errors from end-of-input, so that we can report errors as
such.

If we see end-of-input while parsing a double-quoted string, report the
error (missing closing quote).

Fix the URL for the "Start conditions" section of the Flex manual.

svn path=/trunk/; revision=10044
2004-02-11 22:52:54 +00:00
Gilbert Ramirez 4f1c2830f1 Don't assert that quoted_string be NULL; it can be non-NULL if
the previous dfilter failed to compile because a closing double-quote
was not provided. Handle that case.

svn path=/trunk/; revision=9585
2004-01-07 05:24:04 +00:00
Guy Harris 331b8b5a8b Add, for \xXX, the same sanity check (that 0xXX fits in a single byte)
that we have for \0OOO.

svn path=/trunk/; revision=9396
2003-12-21 21:04:56 +00:00
Ulf Lamping dea93d2bee removed some MSVC warnings (added type casts)
svn path=/trunk/; revision=9370
2003-12-20 23:50:50 +00:00
Gilbert Ramirez 55a6251e7c From Olivier Biot
New "matches" operater in display filter language. Uses PCRE.

If a "matches" operator is found in a dfilter
while libpcre has not been used to build the binary, then an
exception is thrown after using dfilter_fail() to set an apporporiate
error message.

svn path=/trunk/; revision=9182
2003-12-06 16:35:20 +00:00
Guy Harris 4b1fda78b9 Allow + and , in unparsed strings, so that you can use + as a sign in a
number or exponent and so that floating-point numbers can use , as well
as . as a decimal point.

svn path=/trunk/; revision=8791
2003-10-27 22:45:47 +00:00
Gilbert Ramirez 52338a3baf Add a "contains" operator for byte-strings, strings, and tvbuffs (protocols).
The search uses a naive approach; more work is required to add a
Boyer-Moore Search algorithm.

svn path=/trunk/; revision=8280
2003-08-27 15:23:11 +00:00
Gilbert Ramirez 086774b71f 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
2003-07-25 03:44:05 +00:00
Guy Harris 30f02bc99c Move the code to build the balanced tree of fields into "proto_init()",
move the code from "dfilter_lookup_token()" into
"proto_registrar_get_byname()", and get rid of "dfilter_lookup_token()"
and have its callers call "proto_registrar_get_byname()" instead.

svn path=/trunk/; revision=5287
2002-04-29 07:55:32 +00:00
Gilbert Ramirez 5c75eb2df7 Add "-" (hyphen) to the pattern for field-name/non-quoted string.
svn path=/trunk/; revision=5139
2002-04-11 03:26:26 +00:00
Gilbert Ramirez 39b0e82f63 Support CIDR notation in IPv4 address filtering.
svn path=/trunk/; revision=3601
2001-06-22 16:29:15 +00:00
Gilbert Ramirez b24dff17bd Enable slices of [i-j], where i is start offset and j is end offset,
inclusive. That is, [0-1] is a slice of 2 bytes.

svn path=/trunk/; revision=3092
2001-03-02 17:04:25 +00:00
Gilbert Ramirez 2a50f8af4f Add Ed Warnicke's drange code to the new dfilter system.
Not supported yet: [i-j] (offset-offset)
Supported:
	[i]	index
	[i:j]	offset:length
	[:j]	0:offset
	[i:]	offset:end
	[x,y]	concatenation of slices

svn path=/trunk/; revision=3080
2001-02-27 19:23:30 +00:00
Gilbert Ramirez 96e0398fc6 Grumble, grumble. I forgot to add the license comment at the top
of these files.

svn path=/trunk/; revision=2968
2001-02-01 20:31:21 +00:00
Gilbert Ramirez 8f1fff2e6a Create a more modular type system for the FT_* types. Put them
into epan/ftypes.

Re-write display filter routines using Lemon parser instead of yacc.
Besides using a different tool, the new grammar is much simpler, while
the display filter engine itself is more powerful and more easily extended.

Add dftest executable, to test display filter "bytecode" generation.
Add option to "configure" to build dftest or randpkt, both of which are not
built by default.

Implement Ed Warnicke's ideas about dranges in the new display filter and
ftype code.

Remove type FT_TEXT_ONLY in favor of FT_NONE, and have protocols registered
as FT_PROTOCOL. Thus, FT_NONE is used only for simple labels in the proto tree,
while FT_PROTOCOL is used for protocols. This was necessary for being
able to make byte slices (ranges) out of protocols, like "frame[0:3]"

Win32 Makefile.nmake's will be added tonight.

svn path=/trunk/; revision=2967
2001-02-01 20:21:25 +00:00