filter.h File Reference
NAF Core Library Flow Filter API. More...
#include <naf/autoinc.h>
#include <naf/nafcore.h>
#include <naf/lexcore.h>
Go to the source code of this file.
Data Structures | |
| struct | _NAFilter |
| A rangelist-based filter for NAF raw and aggregate flows. More... | |
Defines | |
| #define | naf_filter_active(_filter_) |
| Convenience macro to determine if a filter has any rangelists. | |
Typedefs | |
| typedef _NAFilter | NAFilter |
| A rangelist-based filter for NAF raw and aggregate flows. | |
Functions | |
| void | naf_filter_rl_add (GArray **rl, uint32_t a, uint32_t b) |
| Add a range to a rangelist. | |
| gboolean | naf_filter_rl_contains (GArray *rl, uint32_t v) |
| Determine if a rangelist contains a given value. | |
| gboolean | naf_filter_key (NAFilter *filter, NAFlowKey *key) |
| Determine if a filter matches a given flow key. | |
| gboolean | naf_filter_val (NAFilter *filter, NAFlowVal *val) |
| Determine if a filter matches a given flow value. | |
| void | naf_filter_init (NAFilter *filter) |
| Initialize a filter by setting all its rangelists to empty. | |
| void | naf_filter_reinit (NAFilter *filter) |
| Reinitialize a filter by freeing all its rangelists. | |
| void | naf_filter_rl_print (GArray *rl, GString *str) |
| Append a textual description of an unsigned rangelist to a GString. | |
| void | naf_filter_rl_print_ipaddr (GArray *rl, GString *str) |
| Append a textual description of an IPv4 address rangelist to a GString. | |
| void | naf_filter_print (NAFilter *filter, GString *str) |
| Append a textual description of a filter to a GString. | |
| gboolean | naf_filter_rl_parse_ipaddr (GScanner *scanner, GArray **rl) |
| Parse an IPv4 address rangelist. | |
| gboolean | naf_filter_rl_parse_uint (GScanner *scanner, GArray **rl, uint32_t max) |
| Parse an unsigned rangelist. | |
| gboolean | naf_filter_parse (GScanner *scanner, NAFilter *filter) |
| Parse a filter expression. | |
Detailed Description
NAF Core Library Flow Filter API.Used by nafalize and nafilter. Defines an API for handling rangelist-based filters for flows. The flow filter API also provides a facility for parsing filter expressions from user input.
Define Documentation
| #define naf_filter_active | ( | _filter_ | ) |
Value:
(((_filter_).binrl) || \
((_filter_).siprl) || \
((_filter_).diprl) || \
((_filter_).sprl) || \
((_filter_).dprl) || \
((_filter_).protorl) || \
((_filter_).florl) || \
((_filter_).rflorl) || \
((_filter_).pktrl) || \
((_filter_).rpktrl) || \
((_filter_).octrl) || \
((_filter_).roctrl))
Function Documentation
| void naf_filter_init | ( | NAFilter * | filter | ) |
Initialize a filter by setting all its rangelists to empty.
Call this to prepare a new filter for parsing or other construction.
- Parameters:
-
filter filter to initialize
Determine if a filter matches a given flow key.
Filters are evaluated as AND-of-OR; that is, for each rangelist present in a filter, a flow must match one of the ranges in the list to match the filter as a whole.
- Parameters:
-
filter filter to check flow against key flow key to check
- Returns:
- TRUE if the filter matches the flow, FALSE otherwise.
| gboolean naf_filter_parse | ( | GScanner * | scanner, | |
| NAFilter * | filter | |||
| ) |
Parse a filter expression.
Requires a scanner initialized with naf_lex_init() or naf_lex_init_argv(). The scanner should be positioned such that the next token is NAF_SYM_FILTER.
- Parameters:
-
scanner scanner to take filter tokens from filter structure to store parsed filter in.
- Returns:
- TRUE on success, FALSE on error. Will use glib logging facility to note parse errors; ensure that log routing is configured before calling this routine.
| void naf_filter_print | ( | NAFilter * | filter, | |
| GString * | str | |||
| ) |
Append a textual description of a filter to a GString.
- Parameters:
-
filter filter to print str string to append to
| void naf_filter_reinit | ( | NAFilter * | filter | ) |
Reinitialize a filter by freeing all its rangelists.
Call this to prepare a previously constructed filter for parsing or other construction.
- Parameters:
-
filter filter to reinitialize
| void naf_filter_rl_add | ( | GArray ** | rl, | |
| uint32_t | a, | |||
| uint32_t | b | |||
| ) |
Add a range to a rangelist.
All rangelist ranges are treated as inclusive.
- Parameters:
-
rl pointer to rangelist to add to. naf_filter_rl_add will allocate a new GArray if *rl is NULL. a start of range to add b end of range to add
| gboolean naf_filter_rl_contains | ( | GArray * | rl, | |
| uint32_t | v | |||
| ) |
Determine if a rangelist contains a given value.
- Parameters:
-
rl rangelist to check v value to check for
- Returns:
- TRUE if the rangelist contains the value, FALSE otherwise.
| gboolean naf_filter_rl_parse_ipaddr | ( | GScanner * | scanner, | |
| GArray ** | rl | |||
| ) |
Parse an IPv4 address rangelist.
Requires a scanner initialized with naf_lex_init() or naf_lex_init_argv().
- Parameters:
-
scanner scanner to take rangelist tokens from rl pointer to GArray to store new rangelist in.
- Returns:
- TRUE on success, FALSE on error. Will use glib logging facility to note parse errors; ensure that log routing is configured before calling this routine.
| gboolean naf_filter_rl_parse_uint | ( | GScanner * | scanner, | |
| GArray ** | rl, | |||
| uint32_t | max | |||
| ) |
Parse an unsigned rangelist.
Requires a scanner initialized with naf_lex_init() or naf_lex_init_argv().
- Parameters:
-
scanner scanner to take rangelist tokens from rl pointer to GArray to store new rangelist in. max Maximum value to accept. Pass 255 for uint8 rangelists, 65535 for uint16 rangelists.
- Returns:
- TRUE on success, FALSE on error. Will use glib logging facility to note parse errors; ensure that log routing is configured before calling this routine.
| void naf_filter_rl_print | ( | GArray * | rl, | |
| GString * | str | |||
| ) |
Append a textual description of an unsigned rangelist to a GString.
- Parameters:
-
rl rangelist to print str string to append to
| void naf_filter_rl_print_ipaddr | ( | GArray * | rl, | |
| GString * | str | |||
| ) |
Append a textual description of an IPv4 address rangelist to a GString.
- Parameters:
-
rl rangelist to print str string to append to
Determine if a filter matches a given flow value.
Filters are evaluated as AND-of-OR; that is, for each rangelist present in a filter, a flow must match one of the ranges in the list to match the filter as a whole.
- Parameters:
-
filter filter to check flow against val flow value to check
- Returns:
- TRUE if the filter matches the flow, FALSE otherwise.