summaryrefslogtreecommitdiffstats
path: root/ulogd/libipulog
diff options
context:
space:
mode:
authorlaforge <laforge>2003-05-04 10:00:10 +0000
committerlaforge <laforge>2003-05-04 10:00:10 +0000
commita7d8cac343d6be4a2f8b1430af715c1afe9297d2 (patch)
tree4b2dffd172aa5203d0ce5e82888e8fa79530018a /ulogd/libipulog
parent1719083b0c9114495ff2a3be96df94eec4a525ac (diff)
add support for setting of SO_RCVBUF socket option to libipulog and ulogd (rmem config file entry)
Diffstat (limited to 'ulogd/libipulog')
-rw-r--r--ulogd/libipulog/include/libipulog/libipulog.h20
-rw-r--r--ulogd/libipulog/libipulog.c33
2 files changed, 32 insertions, 21 deletions
diff --git a/ulogd/libipulog/include/libipulog/libipulog.h b/ulogd/libipulog/include/libipulog/libipulog.h
index 8a023c1..307510c 100644
--- a/ulogd/libipulog/include/libipulog/libipulog.h
+++ b/ulogd/libipulog/include/libipulog/libipulog.h
@@ -1,7 +1,7 @@
#ifndef _LIBIPULOG_H
#define _LIBIPULOG_H
-/* $Id: libipulog.h,v 1.5 2002/07/30 07:04:12 laforge Exp $ */
+/* $Id: libipulog.h,v 1.6 2002/07/30 07:23:36 laforge Exp $ */
#include <errno.h>
#include <unistd.h>
@@ -24,7 +24,7 @@ extern int ipulog_errno;
u_int32_t ipulog_group2gmask(u_int32_t group);
-struct ipulog_handle *ipulog_create_handle(u_int32_t gmask);
+struct ipulog_handle *ipulog_create_handle(u_int32_t gmask, u_int32_t rmem);
void ipulog_destroy_handle(struct ipulog_handle *h);
@@ -39,4 +39,20 @@ char *ipulog_strerror(int errcode);
void ipulog_perror(const char *s);
+enum
+{
+ IPULOG_ERR_NONE = 0,
+ IPULOG_ERR_IMPL,
+ IPULOG_ERR_HANDLE,
+ IPULOG_ERR_SOCKET,
+ IPULOG_ERR_BIND,
+ IPULOG_ERR_RECVBUF,
+ IPULOG_ERR_RECV,
+ IPULOG_ERR_NLEOF,
+ IPULOG_ERR_TRUNC,
+ IPULOG_ERR_INVGR,
+ IPULOG_ERR_INVNL,
+};
+#define IPULOG_MAXERR IPULOG_ERR_INVNL
+
#endif /* _LIBULOG_H */
diff --git a/ulogd/libipulog/libipulog.c b/ulogd/libipulog/libipulog.c
index bee0038..0b82fee 100644
--- a/ulogd/libipulog/libipulog.c
+++ b/ulogd/libipulog/libipulog.c
@@ -1,5 +1,5 @@
/*
- * libipulog.c, $Revision: 1.9 $
+ * libipulog.c, $Revision: 1.10 $
*
* netfilter ULOG userspace library.
*
@@ -21,7 +21,7 @@
* This library is still under development, so be aware of sudden interface
* changes
*
- * $Id: libipulog.c,v 1.9 2001/09/01 11:53:41 laforge Exp $
+ * $Id: libipulog.c,v 1.10 2002/07/30 07:04:12 laforge Exp $
*/
#include <stdlib.h>
@@ -42,22 +42,6 @@ struct ipulog_handle
/* internal */
-enum
-{
- IPULOG_ERR_NONE = 0,
- IPULOG_ERR_IMPL,
- IPULOG_ERR_HANDLE,
- IPULOG_ERR_SOCKET,
- IPULOG_ERR_BIND,
- IPULOG_ERR_RECVBUF,
- IPULOG_ERR_RECV,
- IPULOG_ERR_NLEOF,
- IPULOG_ERR_TRUNC,
- IPULOG_ERR_INVGR,
- IPULOG_ERR_INVNL,
-};
-
-#define IPULOG_MAXERR IPULOG_ERR_INVNL
int ipulog_errno = IPULOG_ERR_NONE;
@@ -139,7 +123,8 @@ u_int32_t ipulog_group2gmask(u_int32_t group)
}
/* create a ipulog handle for the reception of packets sent to gmask */
-struct ipulog_handle *ipulog_create_handle(unsigned int gmask)
+struct ipulog_handle *ipulog_create_handle(u_int32_t gmask,
+ u_int32_t rcvbufsize)
{
struct ipulog_handle *h;
int status;
@@ -176,6 +161,16 @@ struct ipulog_handle *ipulog_create_handle(unsigned int gmask)
h->peer.nl_pid = 0;
h->peer.nl_groups = gmask;
+ status = setsockopt(h->fd, SOL_SOCKET, SO_RCVBUF, &rcvbufsize,
+ sizeof(rcvbufsize));
+ if (status == -1)
+ {
+ ipulog_errno = IPULOG_ERR_RECVBUF;
+ close(h->fd);
+ free(h);
+ return NULL;
+ }
+
return h;
}