summaryrefslogtreecommitdiffstats
path: root/src/libipq_compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libipq_compat.c')
-rw-r--r--src/libipq_compat.c105
1 files changed, 0 insertions, 105 deletions
diff --git a/src/libipq_compat.c b/src/libipq_compat.c
index 86481ac..099609b 100644
--- a/src/libipq_compat.c
+++ b/src/libipq_compat.c
@@ -82,111 +82,6 @@ struct ipq_errmap_t {
static int ipq_errno = IPQ_ERR_NONE;
-#if 0
-static ssize_t ipq_netlink_sendto(const struct ipq_handle *h,
- const void *msg, size_t len);
-
-static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h,
- unsigned char *buf, size_t len,
- int timeout);
-
-static ssize_t ipq_netlink_sendmsg(const struct ipq_handle *h,
- const struct msghdr *msg,
- unsigned int flags);
-
-static char *ipq_strerror(int errcode);
-
-static ssize_t ipq_netlink_sendto(const struct ipq_handle *h,
- const void *msg, size_t len)
-{
- int status = sendto(h->fd, msg, len, 0,
- (struct sockaddr *)&h->peer, sizeof(h->peer));
- if (status < 0)
- ipq_errno = IPQ_ERR_SEND;
- return status;
-}
-
-static ssize_t ipq_netlink_sendmsg(const struct ipq_handle *h,
- const struct msghdr *msg,
- unsigned int flags)
-{
- int status = sendmsg(h->fd, msg, flags);
- if (status < 0)
- ipq_errno = IPQ_ERR_SEND;
- return status;
-}
-
-static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h,
- unsigned char *buf, size_t len,
- int timeout)
-{
- unsigned int addrlen;
- int status;
- struct nlmsghdr *nlh;
-
- if (len < sizeof(struct nlmsgerr)) {
- ipq_errno = IPQ_ERR_RECVBUF;
- return -1;
- }
- addrlen = sizeof(h->peer);
-
- if (timeout != 0) {
- int ret;
- struct timeval tv;
- fd_set read_fds;
-
- if (timeout < 0) {
- /* non-block non-timeout */
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- } else {
- tv.tv_sec = timeout / 1000000;
- tv.tv_usec = timeout % 1000000;
- }
-
- FD_ZERO(&read_fds);
- FD_SET(h->fd, &read_fds);
- ret = select(h->fd+1, &read_fds, NULL, NULL, &tv);
- if (ret < 0) {
- if (errno == EINTR) {
- return 0;
- } else {
- ipq_errno = IPQ_ERR_RECV;
- return -1;
- }
- }
- if (!FD_ISSET(h->fd, &read_fds)) {
- ipq_errno = IPQ_ERR_TIMEOUT;
- return 0;
- }
- }
- status = recvfrom(h->fd, buf, len, 0,
- (struct sockaddr *)&h->peer, &addrlen);
- if (status < 0) {
- ipq_errno = IPQ_ERR_RECV;
- return status;
- }
- if (addrlen != sizeof(h->peer)) {
- 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;
- }
- nlh = (struct nlmsghdr *)buf;
- if (nlh->nlmsg_flags & MSG_TRUNC || nlh->nlmsg_len > status) {
- ipq_errno = IPQ_ERR_RTRUNC;
- return -1;
- }
- return status;
-}
-#endif
-
static char *ipq_strerror(int errcode)
{
if (errcode < 0 || errcode > IPQ_MAXERR)