libnetfilter_conntrack  1.0.6
Functions
Library setup

Functions

int nfct_callback_register (struct nfct_handle *h, enum nf_conntrack_msg_type type, int(*cb)(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data), void *data)
 
void nfct_callback_unregister (struct nfct_handle *h)
 
int nfct_callback_register2 (struct nfct_handle *h, enum nf_conntrack_msg_type type, int(*cb)(const struct nlmsghdr *nlh, enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data), void *data)
 
void nfct_callback_unregister2 (struct nfct_handle *h)
 
int nfexp_callback_register (struct nfct_handle *h, enum nf_conntrack_msg_type type, int(*cb)(enum nf_conntrack_msg_type type, struct nf_expect *exp, void *data), void *data)
 
void nfexp_callback_unregister (struct nfct_handle *h)
 
int nfexp_callback_register2 (struct nfct_handle *h, enum nf_conntrack_msg_type type, int(*cb)(const struct nlmsghdr *nlh, enum nf_conntrack_msg_type type, struct nf_expect *exp, void *data), void *data)
 
void nfexp_callback_unregister2 (struct nfct_handle *h)
 
struct nfct_handle * nfct_open (uint8_t subsys_id, unsigned subscriptions)
 
int nfct_close (struct nfct_handle *cth)
 
int nfct_fd (struct nfct_handle *cth)
 
const struct nfnl_handle * nfct_nfnlh (struct nfct_handle *cth)
 

Detailed Description

Function Documentation

int nfct_callback_register ( struct nfct_handle *  h,
enum nf_conntrack_msg_type  type,
int(*)(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data)  cb,
void *  data 
)

nf_callback_register - register a callback

Parameters
hlibrary handler
typemessage type (see enum nf_conntrack_msg_type definition)
cbcallback used to process conntrack received
datadata used by the callback, if any.

This function register a callback to handle the conntrack received, in case of error -1 is returned and errno is set appropiately, otherwise 0 is returned.

Note that the data parameter is optional, if you do not want to pass any data to your callback, then use NULL.

Definition at line 223 of file conntrack/api.c.

int nfct_callback_register2 ( struct nfct_handle *  h,
enum nf_conntrack_msg_type  type,
int(*)(const struct nlmsghdr *nlh, enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data)  cb,
void *  data 
)

nf_callback_register2 - register a callback

Parameters
hlibrary handler
cbcallback used to process conntrack received
datadata used by the callback, if any.

This function register a callback to handle the conntrack received, in case of error -1 is returned and errno is set appropiately, otherwise 0 is returned.

Note that the data parameter is optional, if you do not want to pass any data to your callback, then use NULL.

NOTICE: The difference with nf_callback_register() is that this function uses the new callback interface that includes the Netlink header.

WARNING: Don't mix nf_callback_register() and nf_callback_register2() calls, use only once at a time.

Definition at line 297 of file conntrack/api.c.

void nfct_callback_unregister ( struct nfct_handle *  h)

nfct_callback_unregister - unregister a callback

Parameters
hlibrary handler

Definition at line 263 of file conntrack/api.c.

void nfct_callback_unregister2 ( struct nfct_handle *  h)

nfct_callback_unregister2 - unregister a callback

Parameters
hlibrary handler

Definition at line 337 of file conntrack/api.c.

int nfct_close ( struct nfct_handle *  cth)

nfct_close - close a ctnetlink handler

Parameters
cthhandler obtained via nfct_open()

This function returns -1 on error and errno is explicitly set.

Definition at line 105 of file main.c.

int nfct_fd ( struct nfct_handle *  cth)

nfct_fd - get the Netlink file descriptor of one existing ctnetlink handler

Parameters
cthhandler obtained via nfct_open()

Definition at line 144 of file main.c.

struct nfct_handle* nfct_open ( uint8_t  subsys_id,
unsigned  subscriptions 
)

nfct_open - open a ctnetlink handler

Parameters
subsys_idcan be NFNL_SUBSYS_CTNETLINK or NFNL_SUBSYS_CTNETLINK_EXP
subscriptionsctnetlink groups to subscribe to events

This function returns a handler to send commands to and receive replies from kernel-space. You can pass the following subsystem IDs:

  • NFNL_SUBSYS_CTNETLINK: if you are only interested in conntrack operations (excluding expectations).
  • NFNL_SUBSYS_CTNETLINK_EXP: if you are only interested in expectation operations (exclude conntracks).
  • NFNL_SUBSYS_NONE: if you are interested in both conntrack and expectation operations.

On error, NULL is returned and errno is explicitly set.

Definition at line 84 of file main.c.

int nfexp_callback_register ( struct nfct_handle *  h,
enum nf_conntrack_msg_type  type,
int(*)(enum nf_conntrack_msg_type type, struct nf_expect *exp, void *data)  cb,
void *  data 
)

nfexp_callback_register - register a callback

Parameters
hlibrary handler
cbcallback used to process expect received
datadata used by the callback, if any.

This function register a callback to handle the expect received, in case of error -1 is returned and errno is set appropiately, otherwise 0 is returned.

Note that the data parameter is optional, if you do not want to pass any data to your callback, then use NULL.

Definition at line 157 of file expect/api.c.

int nfexp_callback_register2 ( struct nfct_handle *  h,
enum nf_conntrack_msg_type  type,
int(*)(const struct nlmsghdr *nlh, enum nf_conntrack_msg_type type, struct nf_expect *exp, void *data)  cb,
void *  data 
)

nfexp_callback_register2 - register a callback

Parameters
hlibrary handler
cbcallback used to process expect received
datadata used by the callback, if any.

This function register a callback to handle the expect received, in case of error -1 is returned and errno is set appropiately, otherwise 0 is returned.

Note that the data parameter is optional, if you do not want to pass any data to your callback, then use NULL.

NOTICE: The difference with nfexp_callback_register() is that this function uses the new callback interface that includes the Netlink header.

WARNING: Don't mix nfexp_callback_register() and nfexp_callback_register2() calls, use only once at a time.

Definition at line 231 of file expect/api.c.

void nfexp_callback_unregister ( struct nfct_handle *  h)

nfexp_callback_unregister - unregister a callback

Parameters
hlibrary handler

Definition at line 197 of file expect/api.c.

void nfexp_callback_unregister2 ( struct nfct_handle *  h)

nfexp_callback_unregister2 - unregister a callback

Parameters
hlibrary handler

Definition at line 272 of file expect/api.c.