11 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
13 static int event_cb(
enum nf_conntrack_msg_type type,
14 struct nf_conntrack *ct,
20 nfct_snprintf(buf,
sizeof(buf), ct, type, NFCT_O_PLAIN, NFCT_OF_TIME);
26 return NFCT_CB_CONTINUE;
32 struct nfct_handle *h;
33 struct nfct_filter *filter;
35 h =
nfct_open(CONNTRACK, NF_NETLINK_CONNTRACK_NEW |
36 NF_NETLINK_CONNTRACK_UPDATE);
44 perror(
"nfct_create_filter");
49 perror(
"nfct_filter_attach");
54 for (i=0; i<IPPROTO_MAX; i++)
58 for (i=0; i<128; i++) {
61 .addr = ntohl(inet_addr(
"127.0.0.1")) + i,
68 perror(
"nfct_filter_attach");
77 printf(
"test ret=%d (%s)\n", ret, strerror(errno));
void nfct_filter_destroy(struct nfct_filter *filter)
void nfct_filter_add_attr_u32(struct nfct_filter *filter, const enum nfct_filter_attr attr, const uint32_t value)
int nfct_fd(struct nfct_handle *cth)
int nfct_snprintf(char *buf, unsigned int size, const struct nf_conntrack *ct, const unsigned int msg_type, const unsigned int out_type, const unsigned int out_flags)
void nfct_filter_add_attr(struct nfct_filter *filter, const enum nfct_filter_attr attr, const void *value)
struct nfct_filter * nfct_filter_create(void)
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)
int nfct_filter_attach(int fd, struct nfct_filter *filter)
int nfct_catch(struct nfct_handle *h)
struct nfct_handle * nfct_open(uint8_t, unsigned)