diff options
-rwxr-xr-x | autogen.sh | 4 | ||||
-rw-r--r-- | include/libnetfilter_log/libnetfilter_log.h | 38 | ||||
-rw-r--r-- | src/libipulog_compat.c | 20 | ||||
-rw-r--r-- | src/libnetfilter_log.c | 82 | ||||
-rw-r--r-- | utils/nfulnl_test.c | 40 |
5 files changed, 92 insertions, 92 deletions
@@ -11,8 +11,8 @@ run () fi } -run aclocal-1.6 +run aclocal #run autoheader run libtoolize -f -run automake-1.6 -a +run automake -a run autoconf diff --git a/include/libnetfilter_log/libnetfilter_log.h b/include/libnetfilter_log/libnetfilter_log.h index ff546d1..7866288 100644 --- a/include/libnetfilter_log/libnetfilter_log.h +++ b/include/libnetfilter_log/libnetfilter_log.h @@ -12,36 +12,36 @@ #include <libnfnetlink/libnfnetlink.h> #include <linux/netfilter/nfnetlink_log.h> -struct nfulnl_handle; -struct nfulnl_g_handle; +struct nflog_handle; +struct nflog_g_handle; -extern int nfulnl_errno; +extern int nflog_errno; -extern struct nfnl_handle *nfulnl_nfnlh(struct nfulnl_handle *h); -extern int nfulnl_fd(struct nfulnl_handle *h); +extern struct nfnl_handle *nflog_nfnlh(struct nflog_handle *h); +extern int nflog_fd(struct nflog_handle *h); -typedef int nfulnl_callback(struct nfulnl_g_handle *gh, struct nfgenmsg *nfmsg, +typedef int nflog_callback(struct nflog_g_handle *gh, struct nfgenmsg *nfmsg, struct nfattr *nfa[], void *data); -extern struct nfulnl_handle *nfulnl_open(void); -extern int nfulnl_close(struct nfulnl_handle *h); +extern struct nflog_handle *nflog_open(void); +extern int nflog_close(struct nflog_handle *h); -extern int nfulnl_bind_pf(struct nfulnl_handle *h, u_int16_t pf); -extern int nfulnl_unbind_pf(struct nfulnl_handle *h, u_int16_t pf); +extern int nflog_bind_pf(struct nflog_handle *h, u_int16_t pf); +extern int nflog_unbind_pf(struct nflog_handle *h, u_int16_t pf); -extern struct nfulnl_g_handle *nfulnl_bind_group(struct nfulnl_handle *h, +extern struct nflog_g_handle *nflog_bind_group(struct nflog_handle *h, u_int16_t num); -extern int nfulnl_unbind_group(struct nfulnl_g_handle *gh); +extern int nflog_unbind_group(struct nflog_g_handle *gh); -extern int nfulnl_set_mode(struct nfulnl_g_handle *gh, +extern int nflog_set_mode(struct nflog_g_handle *gh, u_int8_t mode, unsigned int len); -extern int nfulnl_set_timeout(struct nfulnl_g_handle *gh, u_int32_t timeout); -extern int nfulnl_set_qthresh(struct nfulnl_g_handle *gh, u_int32_t qthresh); -extern int nfulnl_set_nlbufsiz(struct nfulnl_g_handle *gh, u_int32_t nlbufsiz); +extern int nflog_set_timeout(struct nflog_g_handle *gh, u_int32_t timeout); +extern int nflog_set_qthresh(struct nflog_g_handle *gh, u_int32_t qthresh); +extern int nflog_set_nlbufsiz(struct nflog_g_handle *gh, u_int32_t nlbufsiz); -extern int nfulnl_callback_register(struct nfulnl_g_handle *gh, - nfulnl_callback *cb, void *data); -extern int nfulnl_handle_packet(struct nfulnl_handle *h, char *buf, int len); +extern int nflog_callback_register(struct nflog_g_handle *gh, + nflog_callback *cb, void *data); +extern int nflog_handle_packet(struct nflog_handle *h, char *buf, int len); #endif /* __LIBNETFILTER_LOG_H */ diff --git a/src/libipulog_compat.c b/src/libipulog_compat.c index ca535fc..9d93bcd 100644 --- a/src/libipulog_compat.c +++ b/src/libipulog_compat.c @@ -15,8 +15,8 @@ struct ipulog_handle { - struct nfulnl_handle *nfulh; - struct nfulnl_g_handle *nful_gh; + struct nflog_handle *nfulh; + struct nflog_g_handle *nful_gh; struct nlmsghdr *last_nlh; #if 0 int fd; @@ -96,16 +96,16 @@ struct ipulog_handle *ipulog_create_handle(u_int32_t gmask, return NULL; } memset(h, 0, sizeof(*h)); - h->nfulh = nfulnl_open(); + h->nfulh = nflog_open(); if (!h->nfulh) goto out_free; /* bind_pf returns EEXIST if we are already registered */ - rv = nfulnl_bind_pf(h->nfulh, AF_INET); + rv = nflog_bind_pf(h->nfulh, AF_INET); if (rv < 0 && rv != -EEXIST) goto out_free; - h->nful_gh = nfulnl_bind_group(h->nfulh, group); + h->nful_gh = nflog_bind_group(h->nfulh, group); if (!h->nful_gh) goto out_free; @@ -119,8 +119,8 @@ out_free: void ipulog_destroy_handle(struct ipulog_handle *h) { - nfulnl_unbind_group(h->nful_gh); - nfulnl_close(h->nfulh); + nflog_unbind_group(h->nful_gh); + nflog_close(h->nfulh); free(h); } @@ -134,10 +134,10 @@ ulog_packet_msg_t *ipulog_get_packet(struct ipulog_handle *h, if (!h->last_nlh) { printf("first\n"); - nlh = nfnl_get_msg_first(nfulnl_nfnlh(h->nfulh), buf, len); + nlh = nfnl_get_msg_first(nflog_nfnlh(h->nfulh), buf, len); }else { next_msg: printf("next\n"); - nlh = nfnl_get_msg_next(nfulnl_nfnlh(h->nfulh), buf, len); + nlh = nfnl_get_msg_next(nflog_nfnlh(h->nfulh), buf, len); } h->last_nlh = nlh; @@ -207,7 +207,7 @@ ssize_t ipulog_read(struct ipulog_handle *h, unsigned char *buf, { /* 'timeout' was never implemented in the original libipulog, * so we don't bother emulating it */ - return nfnl_recv(nfulnl_nfnlh(h->nfulh), buf, len); + return nfnl_recv(nflog_nfnlh(h->nfulh), buf, len); } /* print a human readable description of the last error to stderr */ diff --git a/src/libnetfilter_log.c b/src/libnetfilter_log.c index 8dc5598..cb3ed4b 100644 --- a/src/libnetfilter_log.c +++ b/src/libnetfilter_log.c @@ -28,31 +28,31 @@ #include <libnfnetlink/libnfnetlink.h> #include <libnetfilter_log/libnetfilter_log.h> -struct nfulnl_handle +struct nflog_handle { struct nfnl_handle nfnlh; - struct nfulnl_g_handle *gh_list; + struct nflog_g_handle *gh_list; }; -struct nfulnl_g_handle +struct nflog_g_handle { - struct nfulnl_g_handle *next; - struct nfulnl_handle *h; + struct nflog_g_handle *next; + struct nflog_handle *h; u_int16_t id; - nfulnl_callback *cb; + nflog_callback *cb; void *data; }; -int nfulnl_errno; +int nflog_errno; /*********************************************************************** * low level stuff ***********************************************************************/ -static void del_gh(struct nfulnl_g_handle *gh) +static void del_gh(struct nflog_g_handle *gh) { - struct nfulnl_g_handle *cur_gh, *prev_gh = NULL; + struct nflog_g_handle *cur_gh, *prev_gh = NULL; for (cur_gh = gh->h->gh_list; cur_gh; cur_gh = cur_gh->next) { if (cur_gh == gh) { @@ -66,15 +66,15 @@ static void del_gh(struct nfulnl_g_handle *gh) } } -static void add_gh(struct nfulnl_g_handle *gh) +static void add_gh(struct nflog_g_handle *gh) { gh->next = gh->h->gh_list; gh->h->gh_list = gh; } -static struct nfulnl_g_handle *find_gh(struct nfulnl_handle *h, u_int16_t group) +static struct nflog_g_handle *find_gh(struct nflog_handle *h, u_int16_t group) { - struct nfulnl_g_handle *gh; + struct nflog_g_handle *gh; for (gh = h->gh_list; gh; gh = gh->next) { if (gh->id == group) @@ -83,10 +83,10 @@ static struct nfulnl_g_handle *find_gh(struct nfulnl_handle *h, u_int16_t group) return NULL; } -static int __nfulnl_rcv_cmd(struct nlmsghdr *nlh, struct nfattr *nfa[], +static int __nflog_rcv_cmd(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data) { - struct nfulnl_handle *h = data; + struct nflog_handle *h = data; /* FIXME: implement this */ return 0; @@ -94,7 +94,7 @@ static int __nfulnl_rcv_cmd(struct nlmsghdr *nlh, struct nfattr *nfa[], /* build a NFULNL_MSG_CONFIG message */ static int -__build_send_cfg_msg(struct nfulnl_handle *h, u_int8_t command, +__build_send_cfg_msg(struct nflog_handle *h, u_int8_t command, u_int16_t queuenum, u_int8_t pf) { char buf[NFNL_HEADER_LEN @@ -111,13 +111,13 @@ __build_send_cfg_msg(struct nfulnl_handle *h, u_int8_t command, return nfnl_talk(&h->nfnlh, nmh, 0, 0, NULL, NULL, NULL); } -static int __nfulnl_rcv_pkt(struct nlmsghdr *nlh, struct nfattr *nfa[], +static int __nflog_rcv_pkt(struct nlmsghdr *nlh, struct nfattr *nfa[], void *data) { struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); - struct nfulnl_handle *h = data; + struct nflog_handle *h = data; u_int16_t group = ntohs(nfmsg->res_id); - struct nfulnl_g_handle *gh = find_gh(h, group); + struct nflog_g_handle *gh = find_gh(h, group); if (!gh) return -ENODEV; @@ -129,30 +129,30 @@ static int __nfulnl_rcv_pkt(struct nlmsghdr *nlh, struct nfattr *nfa[], } static struct nfnl_callback cmd_cb = { - .call = &__nfulnl_rcv_cmd, + .call = &__nflog_rcv_cmd, .attr_count = NFULA_CFG_MAX, }; static struct nfnl_callback pkt_cb = { - .call = &__nfulnl_rcv_pkt, + .call = &__nflog_rcv_pkt, .attr_count = NFULA_MAX, }; /* public interface */ -struct nfnl_handle *nfulnl_nfnlh(struct nfulnl_handle *h) +struct nfnl_handle *nflog_nfnlh(struct nflog_handle *h) { return &h->nfnlh; } -int nfulnl_fd(struct nfulnl_handle *h) +int nflog_fd(struct nflog_handle *h) { - return nfnl_fd(nfulnl_nfnlh(h)); + return nfnl_fd(nflog_nfnlh(h)); } -struct nfulnl_handle *nfulnl_open(void) +struct nflog_handle *nflog_open(void) { - struct nfulnl_handle *h; + struct nflog_handle *h; int err; h = malloc(sizeof(*h)); @@ -163,20 +163,20 @@ struct nfulnl_handle *nfulnl_open(void) err = nfnl_open(&h->nfnlh, NFNL_SUBSYS_ULOG, NFULNL_MSG_MAX, 0); if (err < 0) { - nfulnl_errno = err; + nflog_errno = err; goto out_free; } cmd_cb.data = h; err = nfnl_callback_register(&h->nfnlh, NFULNL_MSG_CONFIG, &cmd_cb); if (err < 0) { - nfulnl_errno = err; + nflog_errno = err; goto out_close; } pkt_cb.data = h; err = nfnl_callback_register(&h->nfnlh, NFULNL_MSG_PACKET, &pkt_cb); if (err < 0) { - nfulnl_errno = err; + nflog_errno = err; goto out_close; } @@ -188,7 +188,7 @@ out_free: return NULL; } -int nfulnl_callback_register(struct nfulnl_g_handle *gh, nfulnl_callback *cb, +int nflog_callback_register(struct nflog_g_handle *gh, nflog_callback *cb, void *data) { gh->data = data; @@ -197,33 +197,33 @@ int nfulnl_callback_register(struct nfulnl_g_handle *gh, nfulnl_callback *cb, return 0; } -int nfulnl_handle_packet(struct nfulnl_handle *h, char *buf, int len) +int nflog_handle_packet(struct nflog_handle *h, char *buf, int len) { return nfnl_handle_packet(&h->nfnlh, buf, len); } -int nfulnl_close(struct nfulnl_handle *h) +int nflog_close(struct nflog_handle *h) { return nfnl_close(&h->nfnlh); } /* bind nf_queue from a specific protocol family */ -int nfulnl_bind_pf(struct nfulnl_handle *h, u_int16_t pf) +int nflog_bind_pf(struct nflog_handle *h, u_int16_t pf) { return __build_send_cfg_msg(h, NFULNL_CFG_CMD_PF_BIND, 0, pf); } /* unbind nf_queue from a specific protocol family */ -int nfulnl_unbind_pf(struct nfulnl_handle *h, u_int16_t pf) +int nflog_unbind_pf(struct nflog_handle *h, u_int16_t pf) { return __build_send_cfg_msg(h, NFULNL_CFG_CMD_PF_UNBIND, 0, pf); } /* bind this socket to a specific queue number */ -struct nfulnl_g_handle * -nfulnl_bind_group(struct nfulnl_handle *h, u_int16_t num) +struct nflog_g_handle * +nflog_bind_group(struct nflog_handle *h, u_int16_t num) { - struct nfulnl_g_handle *gh; + struct nflog_g_handle *gh; if (find_gh(h, num)) return NULL; @@ -246,7 +246,7 @@ nfulnl_bind_group(struct nfulnl_handle *h, u_int16_t num) } /* unbind this socket from a specific queue number */ -int nfulnl_unbind_group(struct nfulnl_g_handle *gh) +int nflog_unbind_group(struct nflog_g_handle *gh) { int ret = __build_send_cfg_msg(gh->h, NFULNL_CFG_CMD_UNBIND, gh->id, 0); if (ret == 0) { @@ -257,7 +257,7 @@ int nfulnl_unbind_group(struct nfulnl_g_handle *gh) return ret; } -int nfulnl_set_mode(struct nfulnl_g_handle *gh, +int nflog_set_mode(struct nflog_g_handle *gh, u_int8_t mode, u_int32_t range) { char buf[NFNL_HEADER_LEN @@ -276,7 +276,7 @@ int nfulnl_set_mode(struct nfulnl_g_handle *gh, return nfnl_talk(&gh->h->nfnlh, nmh, 0, 0, NULL, NULL, NULL); } -int nfulnl_set_timeout(struct nfulnl_g_handle *gh, u_int32_t timeout) +int nflog_set_timeout(struct nflog_g_handle *gh, u_int32_t timeout) { char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; struct nlmsghdr *nmh = (struct nlmsghdr *) buf; @@ -289,7 +289,7 @@ int nfulnl_set_timeout(struct nfulnl_g_handle *gh, u_int32_t timeout) return nfnl_talk(&gh->h->nfnlh, nmh, 0, 0, NULL, NULL, NULL); } -int nfulnl_set_qthresh(struct nfulnl_g_handle *gh, u_int32_t qthresh) +int nflog_set_qthresh(struct nflog_g_handle *gh, u_int32_t qthresh) { char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; struct nlmsghdr *nmh = (struct nlmsghdr *) buf; @@ -302,7 +302,7 @@ int nfulnl_set_qthresh(struct nfulnl_g_handle *gh, u_int32_t qthresh) return nfnl_talk(&gh->h->nfnlh, nmh, 0, 0, NULL, NULL, NULL); } -int nfulnl_set_nlbufsiz(struct nfulnl_g_handle *gh, u_int32_t nlbufsiz) +int nflog_set_nlbufsiz(struct nflog_g_handle *gh, u_int32_t nlbufsiz) { char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; struct nlmsghdr *nmh = (struct nlmsghdr *) buf; diff --git a/utils/nfulnl_test.c b/utils/nfulnl_test.c index d0d4414..a41d7a6 100644 --- a/utils/nfulnl_test.c +++ b/utils/nfulnl_test.c @@ -51,7 +51,7 @@ static int print_pkt(struct nfattr *tb[]) return 0; } -static int cb(struct nfulnl_g_handle *gh, struct nfgenmsg *nfmsg, +static int cb(struct nflog_g_handle *gh, struct nfgenmsg *nfmsg, struct nfattr *nfa[], void *data) { print_pkt(nfa); @@ -60,55 +60,55 @@ static int cb(struct nfulnl_g_handle *gh, struct nfgenmsg *nfmsg, int main(int argc, char **argv) { - struct nfulnl_handle *h; - struct nfulnl_g_handle *qh; - struct nfulnl_g_handle *qh100; + struct nflog_handle *h; + struct nflog_g_handle *qh; + struct nflog_g_handle *qh100; struct nfnl_handle *nh; int rv, fd; char buf[4096]; - h = nfulnl_open(); + h = nflog_open(); if (!h) { - fprintf(stderr, "error during nfulnl_open()\n"); + fprintf(stderr, "error during nflog_open()\n"); exit(1); } printf("unbinding existing nf_log handler for AF_INET (if any)\n"); - if (nfulnl_unbind_pf(h, AF_INET) < 0) { - fprintf(stderr, "error nfulnl_unbind_pf()\n"); + if (nflog_unbind_pf(h, AF_INET) < 0) { + fprintf(stderr, "error nflog_unbind_pf()\n"); exit(1); } printf("binding nfnetlink_log to AF_INET\n"); - if (nfulnl_bind_pf(h, AF_INET) < 0) { - fprintf(stderr, "error during nfulnl_bind_pf()\n"); + if (nflog_bind_pf(h, AF_INET) < 0) { + fprintf(stderr, "error during nflog_bind_pf()\n"); exit(1); } printf("binding this socket to group 0\n"); - qh = nfulnl_bind_group(h, 0); + qh = nflog_bind_group(h, 0); if (!qh) { fprintf(stderr, "no handle for grup 0\n"); exit(1); } printf("binding this socket to group 100\n"); - qh100 = nfulnl_bind_group(h, 100); + qh100 = nflog_bind_group(h, 100); if (!qh100) { fprintf(stderr, "no handle for group 100\n"); exit(1); } printf("setting copy_packet mode\n"); - if (nfulnl_set_mode(qh, NFULNL_COPY_PACKET, 0xffff) < 0) { + if (nflog_set_mode(qh, NFULNL_COPY_PACKET, 0xffff) < 0) { fprintf(stderr, "can't set packet copy mode\n"); exit(1); } - nh = nfulnl_nfnlh(h); + nh = nflog_nfnlh(h); fd = nfnl_fd(nh); printf("registering callback for group 0\n"); - nfulnl_callback_register(qh, &cb, NULL); + nflog_callback_register(qh, &cb, NULL); printf("going into main loop\n"); while ((rv = recv(fd, buf, sizeof(buf), 0)) && rv >= 0) { @@ -132,24 +132,24 @@ int main(int argc, char **argv) } #else /* handle messages in just-received packet */ - nfulnl_handle_packet(h, buf, rv); + nflog_handle_packet(h, buf, rv); #endif } printf("unbinding from group 100\n"); - nfulnl_unbind_group(qh100); + nflog_unbind_group(qh100); printf("unbinding from group 0\n"); - nfulnl_unbind_group(qh); + nflog_unbind_group(qh); #ifdef INSANE /* norally, applications SHOULD NOT issue this command, * since it detaches other programs/sockets from AF_INET, too ! */ printf("unbinding from AF_INET\n"); - nfulnl_unbind_pf(h, AF_INET); + nflog_unbind_pf(h, AF_INET); #endif printf("closing handle\n"); - nfulnl_close(h); + nflog_close(h); exit(0); } |