diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-04 10:32:48 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-04 10:32:48 +0200 |
commit | ac5fd9168efaa4e149340340805b1be7425d8834 (patch) | |
tree | 6f87f03c79d0168c44f472c03f9f800c9883d266 | |
parent | 92206a78c27de6442f1428ccf8cd622fa3364a5a (diff) |
xutils: break out promisc mode functions
Put them separately for the sake of maintanence.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | ifpps.c | 1 | ||||
-rw-r--r-- | ifpps/Makefile | 1 | ||||
-rw-r--r-- | netsniff-ng.c | 1 | ||||
-rw-r--r-- | netsniff-ng/Makefile | 1 | ||||
-rw-r--r-- | promisc.c | 25 | ||||
-rw-r--r-- | promisc.h | 7 | ||||
-rw-r--r-- | xutils.c | 21 | ||||
-rw-r--r-- | xutils.h | 2 |
8 files changed, 36 insertions, 23 deletions
@@ -21,6 +21,7 @@ #include "xmalloc.h" #include "xutils.h" #include "ioops.h" +#include "promisc.h" #include "cpus.h" #include "built_in.h" diff --git a/ifpps/Makefile b/ifpps/Makefile index 8b055b4..57816ac 100644 --- a/ifpps/Makefile +++ b/ifpps/Makefile @@ -3,5 +3,6 @@ ifpps-libs = $(shell pkg-config --libs ncurses) ifpps-objs = xmalloc.o \ ioops.o \ xutils.o \ + promisc.o \ str.o \ ifpps.o diff --git a/netsniff-ng.c b/netsniff-ng.c index 2005f9b..b0b6f51 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -27,6 +27,7 @@ #include "ring_tx.h" #include "mac80211.h" #include "xutils.h" +#include "promisc.h" #include "built_in.h" #include "pcap_io.h" #include "bpf.h" diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile index 7f5a490..39412a6 100644 --- a/netsniff-ng/Makefile +++ b/netsniff-ng/Makefile @@ -32,6 +32,7 @@ netsniff-ng-objs = dissector.o \ proto_vlan_q_in_q.o \ proto_mpls_unicast.o \ proto_80211_mac_hdr.o \ + promisc.o \ str.o \ irq.o \ iosched.o \ diff --git a/promisc.c b/promisc.c new file mode 100644 index 0000000..721da18 --- /dev/null +++ b/promisc.c @@ -0,0 +1,25 @@ +#include <string.h> + +#include "promisc.h" +#include "xutils.h" + +short enter_promiscuous_mode(char *ifname) +{ + short ifflags; + + if (!strncmp("any", ifname, strlen("any"))) + return 0; + + ifflags = device_get_flags(ifname); + device_set_flags(ifname, ifflags | IFF_PROMISC); + + return ifflags; +} + +void leave_promiscuous_mode(char *ifname, short oldflags) +{ + if (!strncmp("any", ifname, strlen("any"))) + return; + + device_set_flags(ifname, oldflags); +} diff --git a/promisc.h b/promisc.h new file mode 100644 index 0000000..b290b92 --- /dev/null +++ b/promisc.h @@ -0,0 +1,7 @@ +#ifndef PROMISC_H +#define PROMISC_H + +extern short enter_promiscuous_mode(char *ifname); +extern void leave_promiscuous_mode(char *ifname, short oldflags); + +#endif /* PROMISC_H */ @@ -569,27 +569,6 @@ void register_signal_f(int signal, void (*handler)(int), int flags) sigaction(signal, &saction, NULL); } -short enter_promiscuous_mode(char *ifname) -{ - short ifflags; - - if (!strncmp("any", ifname, strlen("any"))) - return 0; - - ifflags = device_get_flags(ifname); - device_set_flags(ifname, ifflags | IFF_PROMISC); - - return ifflags; -} - -void leave_promiscuous_mode(char *ifname, short oldflags) -{ - if (!strncmp("any", ifname, strlen("any"))) - return; - - device_set_flags(ifname, oldflags); -} - int device_up_and_running(char *ifname) { if (!ifname) @@ -52,8 +52,6 @@ extern int get_system_socket_mem(int which); extern void set_system_socket_mem(int which, int val); extern void register_signal(int signal, void (*handler)(int)); extern void register_signal_f(int signal, void (*handler)(int), int flags); -extern short enter_promiscuous_mode(char *ifname); -extern void leave_promiscuous_mode(char *ifname, short oldflags); extern int device_up_and_running(char *ifname); extern void set_epoll_descriptor(int fd_epoll, int action, int fd_toadd, int events); extern int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events); |