#include <cat.h>
int cat_pushfilter(cat_session *session, const cat_filter *filter);
struct cat_filter { char name[CAT_MAX_FILTERNAME]; int fd_ids; int (*init)(cat_session *session, cat_filter *filter); int (*rw)(cat_session *session, cat_filter *filter, int fd); void (*free)(cat_session *session, cat_filter *filter); void *filterdata; };
This function pushes filter onto the filter stack, affecting reads and/or writes when communicating
with the client or server. The fields from the supplied cat_filter
struct will be copied into internal data structures. When the filter is
installed, its init
function is called.
The rw
function is called for every data packet that passes through the session on
the fd_ids for which the filter is registered. The function can insert,
delete, or modify any data, as it considers necessary. The data is
extracted from the stack using catbuf_get(), and is re-inserted using catbuf_put().
The rw
function should return 0 during normal operation. The following return
codes from a filter rw function are handled in a special way:
init
function. The return value should be CAT_OK
if successful; otherwise, a negative error code is returned.