summaryrefslogtreecommitdiff
path: root/netfilter/nl.c
diff options
context:
space:
mode:
Diffstat (limited to 'netfilter/nl.c')
-rw-r--r--netfilter/nl.c59
1 files changed, 21 insertions, 38 deletions
diff --git a/netfilter/nl.c b/netfilter/nl.c
index ca71ca0..68c8b7c 100644
--- a/netfilter/nl.c
+++ b/netfilter/nl.c
@@ -1,8 +1,13 @@
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <sys/time.h>
-#include <linux/netlink.h>
+/*******************************************************************************
+ * Copyright (c) 2013 Linaro
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Linaro <linaro-dev@lists.linaro.org>
+ *******************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -11,39 +16,18 @@
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <linux/netlink.h>
enum type_t {
TYPE_SYSFS,
TYPE_NETLINK,
};
-int dump(void *_a, size_t s)
-{
- size_t i, j;
- unsigned char *p = _a;
-
- for (i = 0; i < s; i += 16) {
- for (j = 0; j < 16; j ++ ) {
- if (j == 8)
- printf(" - ");
- if (i + j > s) {
- printf(" ");
- } else {
- printf("%c", (isprint(p[i+j])) ? p[i+j] : '.');
- }
- }
- printf(" ");
- for (j = 0; j < 16; j ++ ) {
- if (j == 8)
- printf(" - ");
- printf("%02X ", p[i+j]);
- }
- printf("\n");
- }
- return 0;
-}
-
-int sysfs_handle_open(char *name)
+static int sysfs_handle_open(char *name)
{
char sysfs[256] = "/sys/devices/virtual/xt_idletimer/timers/";
char buffer[256];
@@ -57,18 +41,14 @@ int sysfs_handle_open(char *name)
return r;
}
-#define sysfs_handle_close(h) close(h)
-
-int netlink_socket_open(struct sockaddr_nl *s_nladdr)
+static int netlink_socket_open(struct sockaddr_nl *s_nladdr)
{
int fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
bind(fd, (struct sockaddr*)s_nladdr, sizeof(*s_nladdr));
return fd;
}
-#define netlink_socket_close(h) close(h)
-
-int do_wait(char *nick, enum type_t type, int seconds)
+static int do_wait(char *nick, enum type_t type, int seconds)
{
struct pollfd pfd;
int r;
@@ -131,6 +111,9 @@ int do_wait(char *nick, enum type_t type, int seconds)
continue;
printf("%s\n", ptr);
}
+
+ close(pfd.fd);
+
return 1;
}