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 (u_int8_t subsys_id, unsigned subscriptions)
int nfct_close (struct nfct_handle *cth)
int nfct_fd (struct nfct_handle *cth)
struct nfnl_handle * nfct_nfnlh (struct nfct_handle *cth)

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:
h library handler
type message type (see enum nf_conntrack_msg_type definition)
cb callback used to process conntrack received
data data 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 210 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:
h library handler
cb callback used to process conntrack received
data data 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 284 of file conntrack/api.c.

void nfct_callback_unregister ( struct nfct_handle *  h  ) 

nfct_callback_unregister - unregister a callback

Parameters:
h library handler

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

void nfct_callback_unregister2 ( struct nfct_handle *  h  ) 

nfct_callback_unregister2 - unregister a callback

Parameters:
h library handler

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

int nfct_close ( struct nfct_handle *  cth  ) 

nfct_close - close a ctnetlink handler

Parameters:
cth handler 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:
cth handler obtained via nfct_open()

Definition at line 144 of file main.c.

struct nfct_handle* nfct_open ( u_int8_t  subsys_id,
unsigned  subscriptions 
) [read]

nfct_open - open a ctnetlink handler

Parameters:
subsys_id can be NFNL_SUBSYS_CTNETLINK or NFNL_SUBSYS_CTNETLINK_EXP
subscriptions ctnetlink 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:
h library handler
cb callback used to process expect received
data data 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 121 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:
h library handler
cb callback used to process expect received
data data 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 195 of file expect/api.c.

void nfexp_callback_unregister ( struct nfct_handle *  h  ) 

nfexp_callback_unregister - unregister a callback

Parameters:
h library handler

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

void nfexp_callback_unregister2 ( struct nfct_handle *  h  ) 

nfexp_callback_unregister2 - unregister a callback

Parameters:
h library handler

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