libnd_filter

Name

libnd_filter -- 

Synopsis



enum        LND_FilterMode;
gboolean    (*LND_FilterInitFunc)           (LND_Filter *filter,
                                             LND_Trace *trace,
                                             void *filter_data);
gboolean    (*LND_FilterFunc)               (LND_Filter *filter,
                                             LND_Packet *packet,
                                             void *filter_data);
void        (*LND_FilterCleanupFunc)        (LND_Filter *filter,
                                             void *filter_data);
void        (*LND_FilterFreeFunc)           (void *filter_data);
LND_Filter* libnd_filter_new                (const char *name,
                                             LND_FilterInitFunc filter_init,
                                             LND_FilterFunc filter_func,
                                             LND_FilterCleanupFunc filter_cleanup,
                                             LND_FilterFreeFunc filter_data_free,
                                             void *filter_data);
void        libnd_filter_free               (LND_Filter *filter);
void        libnd_filter_set_factory        (LND_Filter *filter,
                                             LND_FilterFactory *factory);
gboolean    libnd_filter_apply              (LND_Filter *filter,
                                             LND_Packet *packet);
gboolean    libnd_filter_list_apply         (GList *filters,
                                             LND_Packet *packet,
                                             LND_FilterMode mode);
void        libnd_filter_list_init          (GList *filters,
                                             LND_Trace *trace);
void        libnd_filter_list_cleanup       (GList *filters);

Description

Details

enum LND_FilterMode

typedef enum {
  LND_FILTER_MODE_AND,
  LND_FILTER_MODE_OR
} LND_FilterMode;


LND_FilterInitFunc ()

gboolean    (*LND_FilterInitFunc)           (LND_Filter *filter,
                                             LND_Trace *trace,
                                             void *filter_data);

This is the signature for filter initializers.

filter :

filter to initialize.

trace :

trace to initialize the filter for.

filter_data :

filter-specific data.

Returns :

TRUE when initialization was successful, % FALSE otherwise.


LND_FilterFunc ()

gboolean    (*LND_FilterFunc)               (LND_Filter *filter,
                                             LND_Packet *packet,
                                             void *filter_data);

This is the signature for filter hooks.

filter :

filter to apply.

packet :

packet to filter.

filter_data :

filter-specific data.

Returns :

TRUE if the packet passes the filter, FALSE otherwise.


LND_FilterCleanupFunc ()

void        (*LND_FilterCleanupFunc)        (LND_Filter *filter,
                                             void *filter_data);

This is the signature for filter cleanup callbacks.

filter :

filter to clean up.

filter_data :

filter-specific data.


LND_FilterFreeFunc ()

void        (*LND_FilterFreeFunc)           (void *filter_data);

This is the signature for callbacks called when a filter is released, to clean up the filter data the filter was using.

filter_data :

filter-specific data.


libnd_filter_new ()

LND_Filter* libnd_filter_new                (const char *name,
                                             LND_FilterInitFunc filter_init,
                                             LND_FilterFunc filter_func,
                                             LND_FilterCleanupFunc filter_cleanup,
                                             LND_FilterFreeFunc filter_data_free,
                                             void *filter_data);

The function creates and returns a new filter with the given callbacks that implement the filter behaviour. If you don't require some of the functionality (e.g., when your filter is not stateful) then just pass NULL. filter_data can be any data structure that contains the state your filter requires for operation. It is cleaned up when the filter is destroyed, using a call to @filter_data_free().

name :

name of the filter.

filter_init :

initialization function to run before packets are iterated.

filter_func :

actual filter function, run on every packet.

filter_cleanup :

cleanup function, run after packets are iterated.

filter_data_free :

cleanup function for filter data.

filter_data :

arbitrary user data the filter might require.

Returns :

new filter, or NULL if an error occurred.


libnd_filter_free ()

void        libnd_filter_free               (LND_Filter *filter);

The function releases all memory that filter occupies.

filter :

filter to release.


libnd_filter_set_factory ()

void        libnd_filter_set_factory        (LND_Filter *filter,
                                             LND_FilterFactory *factory);

If your filter is created through a factory, the factory should call this function to make sure there is a connection from an instantiated filter to the factory that created it.

filter :

filter whose factory to set.

factory :

filter's new factory.


libnd_filter_apply ()

gboolean    libnd_filter_apply              (LND_Filter *filter,
                                             LND_Packet *packet);

The function applies filter to packet.

filter :

filter to apply.

packet :

packet to apply filter to.

Returns :

TRUE when the packet passed the filter, FALSE otherwise.


libnd_filter_list_apply ()

gboolean    libnd_filter_list_apply         (GList *filters,
                                             LND_Packet *packet,
                                             LND_FilterMode mode);

The function applies filters to packet. filters is assumed to be a list of LND_Filter*s. Depending on mode, the function returns TRUE only when packet passes all filters (LND_FILTER_MODE_AND), or when it passes at least one filter (LND_FILTER_MODE_OR).

filters :

list of filters to apply.

packet :

packet to apply filter to.

mode :

mode to use for filtering.

Returns :

TRUE when the packet passed the filter, FALSE otherwise.


libnd_filter_list_init ()

void        libnd_filter_list_init          (GList *filters,
                                             LND_Trace *trace);

The function initializes all filters for trace.

filters :

list of filters to initialize.

trace :

trace to initialize with.


libnd_filter_list_cleanup ()

void        libnd_filter_list_cleanup       (GList *filters);

The function cleans up the state of all filters int filters.

filters :

list of filters to clean up.