Implement a filter compiler with new features.

Replaces the old filter compiler with a new version that:
- Is a cleaner, more extensible, implementation.
- Can report specific error messages (e.g. bad token vs parse error).
- Supports the new C-style if-then-else expression "(A? B: C)" syntax.

Two new WinDivert helper API functions have been implemented:
- WinDivertHelperCheckFilter() can be used to check a filter string for
  errors.
- WinDivertHelperEvalFilter() evaluates a filter on a given packet.  Will be
  useful for testing.
This commit is contained in:
basil00
2015-06-21 12:38:49 +08:00
parent 90da7a92c7
commit e1ea77f1d3
3 changed files with 2438 additions and 1337 deletions
+12 -1337
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+18
View File
@@ -352,6 +352,24 @@ extern WINDIVERTEXPORT UINT WinDivertHelperCalcChecksums(
__in UINT packetLen,
__in UINT64 flags);
/*
* Check the given filter string.
*/
extern WINDIVERTEXPORT BOOL WinDivertHelperCheckFilter(
__in const char *filter,
__in WINDIVERT_LAYER layer,
__out_opt const char **errorStr,
__out_opt UINT *errorPos);
/*
* Evaluate the given filter string.
*/
extern WINDIVERTEXPORT BOOL WinDivertHelperEvalFilter(
__in const char *filter,
__in WINDIVERT_LAYER layer,
__in PVOID pPacket,
__in UINT packetLen,
__in PWINDIVERT_ADDRESS pAddr);
/****************************************************************************/
/* WINDIVERT LEGACY API */