diff options
author | Guy Harris <guy@alum.mit.edu> | 1999-10-11 03:03:12 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 1999-10-11 03:03:12 +0000 |
commit | 29b9c8a2850ae3be73d1fce38a1e96591ba165fb (patch) | |
tree | 2f4a35a2ca11bf7a6c31bd3079ab48e12ed9b957 /dfilter-scanner.l | |
parent | 5779d0b754957b7b0b2921a0beef14eba7ac3250 (diff) |
Have "get_host_ipaddr()" return a Boolean indicating whether it
succeeded or failed, and, if it succeeded, have it fill in the IP
address if found through a pointer passed as the second argument.
Have it first try interpreting its first argument as a dotted-quad IP
address, with "inet_aton()", and, if that fails, have it try to
interpret it as a host name with "gethostbyname()"; don't bother with
"gethostbyaddr()", as we should be allowed to filter on IP addresses
even if there's no host name associated with them (there's no guarantee
that "gethostbyaddr()" will succeed if handed an IP address with no
corresponding name - and it looks as if FreeBSD 3.2, at least, may not
succeed in that case).
Add a "dfilter_fail()" routine that takes "printf()"-like arguments and
uses them to set an error message for the parse; doing so means that
even if the filter expression is syntactically valid, we treat it as
being invalid. (Is there a better way to force a parse to fail from
arbitrary places in routines called by the parser?)
Use that routine in the lexical analyzer.
If that error message was set, use it as is as the failure message,
rather than adding "Unable to parse filter string XXX" to it.
Have the code to handle IP addresses and host names in display filters
check whether "get_host_ipaddr()" succeeded or failed and, if it failed,
arrange that the parse fail with an error message indicating the source
of the problem.
svn path=/trunk/; revision=802
Diffstat (limited to 'dfilter-scanner.l')
-rw-r--r-- | dfilter-scanner.l | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/dfilter-scanner.l b/dfilter-scanner.l index 1db3ae63b1..80e030501c 100644 --- a/dfilter-scanner.l +++ b/dfilter-scanner.l @@ -3,7 +3,7 @@ /* dfilter-scanner.l * Scanner for display filters * - * $Id: dfilter-scanner.l,v 1.16 1999/10/09 14:14:53 deniel Exp $ + * $Id: dfilter-scanner.l,v 1.17 1999/10/11 03:03:10 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -171,19 +171,23 @@ le|\<\= { dfilter_lval.operand = TOK_LE; return TOK_LE; } retval = T_FT_UINT32; break; case FT_DOUBLE: - dfilter_error("sorry, we don't yet support filtering on floating-point values"); + dfilter_fail("Sorry, you can't filter on field \"%s\", as we don't yet support filtering on floating-point values.", + yytext); retval = 0; break; case FT_ABSOLUTE_TIME: - dfilter_error("sorry, we don't yet support filtering on time-of-day values"); + dfilter_fail("Sorry, you can't filter on field \"%s\", as we don't yet support filtering on time-of-day values.", + yytext); retval = 0; break; case FT_RELATIVE_TIME: - dfilter_error("sorry, we don't yet support filtering on time-delta values"); + dfilter_fail("Sorry, you can't filter on field \"%s\", as we don't yet support filtering on time-delta values.", + yytext); retval = 0; break; case FT_STRING: - dfilter_error("sorry, we don't yet support filtering on string values"); + dfilter_fail("Sorry, you can't filter on field \"%s\", as we don't yet support filtering on string values.", + yytext); retval = 0; break; case FT_ETHER: @@ -196,7 +200,8 @@ le|\<\= { dfilter_lval.operand = TOK_LE; return TOK_LE; } retval = T_FT_IPv4; break; case FT_IPv6: - dfilter_error("sorry, we don't yet support filtering on IPv6 addresses"); + dfilter_fail("Sorry, you can't filter on field \"%s\", as we don't yet support filtering on IPv6 addresses.", + yytext); retval = 0; break; case FT_IPXNET: |