[netfilter-cvslog] r4455 - in trunk/libnetfilter_log: . include/libnetfilter_log src utils

laforge at netfilter.org laforge at netfilter.org
Sat Nov 5 10:59:07 CET 2005


Author: laforge at netfilter.org
Date: 2005-11-05 10:59:06 +0100 (Sat, 05 Nov 2005)
New Revision: 4455

Modified:
   trunk/libnetfilter_log/autogen.sh
   trunk/libnetfilter_log/include/libnetfilter_log/libnetfilter_log.h
   trunk/libnetfilter_log/src/libipulog_compat.c
   trunk/libnetfilter_log/src/libnetfilter_log.c
   trunk/libnetfilter_log/utils/nfulnl_test.c
Log:
rename all functions to remove 'nl' (netlink) from prefix


Modified: trunk/libnetfilter_log/autogen.sh
===================================================================
--- trunk/libnetfilter_log/autogen.sh	2005-11-05 09:53:27 UTC (rev 4454)
+++ trunk/libnetfilter_log/autogen.sh	2005-11-05 09:59:06 UTC (rev 4455)
@@ -11,8 +11,8 @@
     fi
 }
 
-run aclocal-1.6
+run aclocal
 #run autoheader
 run libtoolize -f
-run automake-1.6 -a
+run automake -a
 run autoconf

Modified: trunk/libnetfilter_log/include/libnetfilter_log/libnetfilter_log.h
===================================================================
--- trunk/libnetfilter_log/include/libnetfilter_log/libnetfilter_log.h	2005-11-05 09:53:27 UTC (rev 4454)
+++ trunk/libnetfilter_log/include/libnetfilter_log/libnetfilter_log.h	2005-11-05 09:59:06 UTC (rev 4455)
@@ -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 */

Modified: trunk/libnetfilter_log/src/libipulog_compat.c
===================================================================
--- trunk/libnetfilter_log/src/libipulog_compat.c	2005-11-05 09:53:27 UTC (rev 4454)
+++ trunk/libnetfilter_log/src/libipulog_compat.c	2005-11-05 09:59:06 UTC (rev 4455)
@@ -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 @@
 		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 @@
 
 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 @@
 
 	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 @@
 {
 	/* '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 */

Modified: trunk/libnetfilter_log/src/libnetfilter_log.c
===================================================================
--- trunk/libnetfilter_log/src/libnetfilter_log.c	2005-11-05 09:53:27 UTC (rev 4454)
+++ trunk/libnetfilter_log/src/libnetfilter_log.c	2005-11-05 09:59:06 UTC (rev 4455)
@@ -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 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 @@
 	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 @@
 
 /* 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 @@
 	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 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 @@
 
 	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 @@
 	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 @@
 	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 @@
 }
 
 /* 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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;

Modified: trunk/libnetfilter_log/utils/nfulnl_test.c
===================================================================
--- trunk/libnetfilter_log/utils/nfulnl_test.c	2005-11-05 09:53:27 UTC (rev 4454)
+++ trunk/libnetfilter_log/utils/nfulnl_test.c	2005-11-05 09:59:06 UTC (rev 4455)
@@ -51,7 +51,7 @@
 	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 @@
 
 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 @@
 		}
 #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);
 }




More information about the netfilter-cvslog mailing list