summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ifpps.c1
-rw-r--r--ifpps/Makefile1
-rw-r--r--netsniff-ng.c1
-rw-r--r--netsniff-ng/Makefile1
-rw-r--r--promisc.c25
-rw-r--r--promisc.h7
-rw-r--r--xutils.c21
-rw-r--r--xutils.h2
8 files changed, 36 insertions, 23 deletions
diff --git a/ifpps.c b/ifpps.c
index e835660..340b1a3 100644
--- a/ifpps.c
+++ b/ifpps.c
@@ -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 */
diff --git a/xutils.c b/xutils.c
index e3e7f6f..991ff5b 100644
--- a/xutils.c
+++ b/xutils.c
@@ -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)
diff --git a/xutils.h b/xutils.h
index eda512d..8cf1af2 100644
--- a/xutils.h
+++ b/xutils.h
@@ -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);