diff options
author | dmitry pervushin <dmitry.pervushin@linaro.org> | 2013-04-24 21:22:58 +0200 |
---|---|---|
committer | dmitry pervushin <dmitry.pervushin@linaro.org> | 2013-04-24 21:25:43 +0200 |
commit | 96b0404ad3e2f0910929fb89927dd94502a944cd (patch) | |
tree | 3ec18cdba71c6dc3056f914789eb381dac102c7b /netfilter | |
parent | f9c1d809cd9b78e6edeb4b2832deeb09b0f101ce (diff) | |
download | linaro-android-kernel-test-96b0404ad3e2f0910929fb89927dd94502a944cd.tar.gz |
Added license header
Diffstat (limited to 'netfilter')
-rw-r--r-- | netfilter/Makefile | 25 | ||||
-rw-r--r-- | netfilter/nl.c | 59 |
2 files changed, 46 insertions, 38 deletions
diff --git a/netfilter/Makefile b/netfilter/Makefile new file mode 100644 index 0000000..02d4e87 --- /dev/null +++ b/netfilter/Makefile @@ -0,0 +1,25 @@ +############################################################################# +# 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> +############################################################################# + +CC = $(CROSS_COMPILE)gcc +CFLAGS = -O2 -g +NLEXE = nl-listener +Q = @ + +$(NLEXE): nl.c + @echo -ne "\tCC\t" + @echo $< + $(Q)$(CC) $(CFLAGS) -I. -o $@ $< + +clean: + @echo -ne "\tRM\t" + @echo $(NLEXE) + $(Q)$(RM) $(NLEXE) 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; } |