[bwm-tools-devel] COMMIT - r87 - in trunk: bwmd include
Brought to you by:
nkukard
From: <sv...@li...> - 2006-03-06 09:57:01
|
Author: nkukard Date: 2006-03-06 09:56:29 +0000 (Mon, 06 Mar 2006) New Revision: 87 Modified: trunk/bwmd/ipq.c trunk/bwmd/libipq.c trunk/include/libipq.h Log: * Updated ipq interface Modified: trunk/bwmd/ipq.c =================================================================== --- trunk/bwmd/ipq.c 2006-03-06 09:37:53 UTC (rev 86) +++ trunk/bwmd/ipq.c 2006-03-06 09:56:29 UTC (rev 87) @@ -48,7 +48,7 @@ int result; // Create our ipq socket - h = ipq_create_handle(0, PF_INET, 1048576); + h = ipq_create_handle(0, PF_INET); if (!h) { fprintf(stderr,"Failed to create IPQ handle\n"); Modified: trunk/bwmd/libipq.c =================================================================== --- trunk/bwmd/libipq.c 2006-03-06 09:37:53 UTC (rev 86) +++ trunk/bwmd/libipq.c 2006-03-06 09:56:29 UTC (rev 87) @@ -57,8 +57,7 @@ IPQ_ERR_SUPP, IPQ_ERR_RECVBUF, IPQ_ERR_TIMEOUT, - IPQ_ERR_PROTOCOL, - IPQ_ERR_SETSOCKET + IPQ_ERR_PROTOCOL }; #define IPQ_MAXERR IPQ_ERR_PROTOCOL @@ -82,8 +81,7 @@ { IPQ_ERR_SUPP, "Operation not supported" }, { IPQ_ERR_RECVBUF, "Receive buffer size invalid" }, { IPQ_ERR_TIMEOUT, "Timeout"}, - { IPQ_ERR_PROTOCOL, "Invalid protocol specified" }, - { IPQ_ERR_SETSOCKET, "Failed to set socket options" } + { IPQ_ERR_PROTOCOL, "Invalid protocol specified" } }; static int ipq_errno = IPQ_ERR_NONE; @@ -125,7 +123,8 @@ unsigned char *buf, size_t len, int timeout) { - int addrlen, status; + unsigned int addrlen; + int status; struct nlmsghdr *nlh; if (len < sizeof(struct nlmsgerr)) { @@ -174,6 +173,10 @@ ipq_errno = IPQ_ERR_RECV; return -1; } + if (h->peer.nl_pid != 0) { + ipq_errno = IPQ_ERR_RECV; + return -1; + } if (status == 0) { ipq_errno = IPQ_ERR_NLEOF; return -1; @@ -202,7 +205,7 @@ /* * Create and initialise an ipq handle. */ -struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol, int recv_buf_size) +struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol) { int status; struct ipq_handle *h; @@ -224,22 +227,13 @@ free(h); return NULL; } - + if (h->fd == -1) { ipq_errno = IPQ_ERR_SOCKET; close(h->fd); free(h); return NULL; } - - status = setsockopt(h->fd,SOL_SOCKET,SO_RCVBUF,&recv_buf_size,sizeof(int)); - if (status == -1) { - ipq_errno = IPQ_ERR_SETSOCKET; - close(h->fd); - free(h); - return NULL; - } - memset(&h->local, 0, sizeof(struct sockaddr_nl)); h->local.nl_family = AF_NETLINK; h->local.nl_pid = getpid(); Modified: trunk/include/libipq.h =================================================================== --- trunk/include/libipq.h 2006-03-06 09:37:53 UTC (rev 86) +++ trunk/include/libipq.h 2006-03-06 09:56:29 UTC (rev 87) @@ -35,7 +35,7 @@ typedef u_int64_t ipq_id_t; #else #include <linux/netfilter_ipv4/ip_queue.h> -typedef u_int32_t ipq_id_t; +typedef unsigned long ipq_id_t; #endif #ifdef DEBUG_LIBIPQ @@ -58,7 +58,7 @@ struct sockaddr_nl peer; }; -struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol, int recv_buf_size); +struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol); int ipq_destroy_handle(struct ipq_handle *h); |