summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2005-08-08 17:08:03 +0000
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>2005-08-08 17:08:03 +0000
commit9b5887192ed5c9bad4f2d2d270e88c49ef606b92 (patch)
tree9d3c50facb662472636411b140fdf5a407f9ec95 /src
parent4dde299734b69459debfa21323baabaffa863d72 (diff)
- some more work on libipulog compat API [almost finished]
- improt ulog_test.c from libipulog in order to test libipulog compat API
Diffstat (limited to 'src')
-rw-r--r--src/libipulog_compat.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/libipulog_compat.c b/src/libipulog_compat.c
index d981e94..a0675ec 100644
--- a/src/libipulog_compat.c
+++ b/src/libipulog_compat.c
@@ -5,6 +5,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <libnfnetlink/libnfnetlink.h>
#include <libnfnetlink_log/libnfnetlink_log.h>
#include <libnfnetlink_log/libipulog.h>
@@ -85,6 +86,7 @@ u_int32_t ipulog_group2gmask(u_int32_t group)
struct ipulog_handle *ipulog_create_handle(u_int32_t gmask,
u_int32_t rcvbufsize)
{
+ int rv;
struct ipulog_handle *h;
unsigned int group = gmask2group(gmask);
@@ -98,7 +100,9 @@ struct ipulog_handle *ipulog_create_handle(u_int32_t gmask,
if (!h->nfulh)
goto out_free;
- if (nfulnl_bind_pf(h->nfulh, AF_INET) < 0)
+ /* bind_pf returns EEXIST if we are already registered */
+ rv = nfulnl_bind_pf(h->nfulh, AF_INET);
+ if (rv < 0 && rv != -EEXIST)
goto out_free;
h->nful_gh = nfulnl_bind_group(h->nfulh, group);
@@ -128,10 +132,11 @@ ulog_packet_msg_t *ipulog_get_packet(struct ipulog_handle *h,
struct nfattr *tb[NFULA_MAX];
struct nfulnl_msg_packet_hdr *hdr;
- if (!h->last_nlh)
+ if (!h->last_nlh) {
+ printf("first\n");
nlh = nfnl_get_msg_first(nfulnl_nfnlh(h->nfulh), buf, len);
- else {
-next_msg:
+ }else {
+next_msg: printf("next\n");
nlh = nfnl_get_msg_next(nfulnl_nfnlh(h->nfulh), buf, len);
}
h->last_nlh = nlh;
@@ -139,7 +144,8 @@ next_msg:
if (!nlh)
return NULL;
- nfnl_parse_attr(tb, NFULA_MAX, NFM_NFA(nlh), NFM_PAYLOAD(nlh));
+ nfnl_parse_attr(tb, NFULA_MAX, NFM_NFA(NLMSG_DATA(nlh)),
+ NFM_PAYLOAD(nlh));
if (!tb[NFULA_PACKET_HDR-1])
goto next_msg;
@@ -199,7 +205,9 @@ next_msg:
ssize_t ipulog_read(struct ipulog_handle *h, unsigned char *buf,
size_t len, int timeout)
{
- //return nfnl_listen();
+ /* 'timeout' was never implemented in the original libipulog,
+ * so we don't bother emulating it */
+ return nfnl_recv(nfulnl_nfnlh(h->nfulh), buf, len);
}
/* print a human readable description of the last error to stderr */