tcpdump mailing list archives

Re: Filter not working?


From: Guy Harris <guy () netapp com>
Date: Fri, 7 Feb 2003 18:06:01 -0800

On Sat, Feb 08, 2003 at 02:06:12AM +0100, Gisle Vanem wrote:
Exactly. scanner.l doesn't understand '\'r' in line-endings.
I tried to modify scanner.l to say "[ \r\n\t] ;" instead of "[ \n\t] ;",
but that didn't work. So I modified read_infile() to strip all CR and LF
from buffer and now it works.

That's probably the right thing to do.

PS. There should IMHO be a more detailed error when parser fails. A line +
column position perhaps? I'm no flex expert, but might contribute a patch.

The problem is that lex/flex is reading from a string, not a file -
"pcap_compile()" only supports a string as an argument - so it has no
idea what line caused the problem.

Getting back from "pcap_compile()" a pointer into the string where the
error occurred would be nice - and we could keep a table of lines and
map that pointer into a line number; however, that'd require an API
change in libpcap.

.\windump: short read e:\filterpoop.txt (156 != 162)

Something to do with _fmode or fstat() returning wrong size for DOS/Win
files perhaps.

I think the problem is that it's not opening with O_BINARY, so CR/LF
gets turned into LF when a read is done:

        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt__read.asp

("read()" calls probably turn into "_read()" calls when compiled on
Windows), and that "fstat()" is returning the size of the file, in
bytes, but the read discards some of those bytes (6 of them, in fact, as
the filter file had 6 lines).

IMHO, would be better to use filelength() under Win32.

Unless "filelength()" opens the file and counts the characters in it
*after* turning CR/LF into LF, it wouldn't help.
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: