summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-04 11:38:17 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-06-04 11:38:17 +0200
commit57968a8ab19b45b5d128656f6bed2581aee2ef22 (patch)
tree48e9c560f6f9ffab29debf2cffaaad1acd331c55
parentab9d73629872a474d9194177fa4c9c8cdabe9a44 (diff)
sig: add signal handling functions
Add an extra file for signal handling functions. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r--astraceroute.c1
-rw-r--r--astraceroute/Makefile1
-rw-r--r--curvetun.c1
-rw-r--r--curvetun/Makefile1
-rw-r--r--flowtop.c1
-rw-r--r--flowtop/Makefile1
-rw-r--r--ifpps.c1
-rw-r--r--ifpps/Makefile2
-rw-r--r--netsniff-ng.c1
-rw-r--r--netsniff-ng/Makefile1
-rw-r--r--sig.c32
-rw-r--r--sig.h7
-rw-r--r--trafgen.c1
-rw-r--r--trafgen/Makefile1
-rw-r--r--xutils.c28
-rw-r--r--xutils.h2
16 files changed, 52 insertions, 30 deletions
diff --git a/astraceroute.c b/astraceroute.c
index 1469f8f..a7f04c6 100644
--- a/astraceroute.c
+++ b/astraceroute.c
@@ -34,6 +34,7 @@
#include "bpf.h"
#include "die.h"
#include "dev.h"
+#include "sig.h"
#include "tprintf.h"
#include "pkt_buff.h"
#include "proto.h"
diff --git a/astraceroute/Makefile b/astraceroute/Makefile
index ba45395..b99e310 100644
--- a/astraceroute/Makefile
+++ b/astraceroute/Makefile
@@ -9,6 +9,7 @@ astraceroute-objs = xmalloc.o \
tprintf.o \
bpf.o \
str.o \
+ sig.o \
sock.o \
link.o \
dev.o \
diff --git a/curvetun.c b/curvetun.c
index 0e7bb83..38e3f83 100644
--- a/curvetun.c
+++ b/curvetun.c
@@ -28,6 +28,7 @@
#include "xutils.h"
#include "die.h"
#include "str.h"
+#include "sig.h"
#include "cookie.h"
#include "ioexact.h"
#include "xmalloc.h"
diff --git a/curvetun/Makefile b/curvetun/Makefile
index 111664c..f66fd4d 100644
--- a/curvetun/Makefile
+++ b/curvetun/Makefile
@@ -7,6 +7,7 @@ curvetun-objs = xmalloc.o \
dev.o \
stun.o \
sock.o \
+ sig.o \
link.o \
patricia.o \
corking.o \
diff --git a/flowtop.c b/flowtop.c
index 2319a68..0de3cb6 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -31,6 +31,7 @@
#include "xmalloc.h"
#include "ioops.h"
#include "str.h"
+#include "sig.h"
#include "geoip.h"
#include "xutils.h"
#include "built_in.h"
diff --git a/flowtop/Makefile b/flowtop/Makefile
index ba22803..43f221f 100644
--- a/flowtop/Makefile
+++ b/flowtop/Makefile
@@ -10,6 +10,7 @@ flowtop-objs = xmalloc.o \
xutils.o \
oui.o \
str.o \
+ sig.o \
sock.o \
dev.o \
link.o \
diff --git a/ifpps.c b/ifpps.c
index bdda39d..40a3f63 100644
--- a/ifpps.c
+++ b/ifpps.c
@@ -19,6 +19,7 @@
#include "die.h"
#include "dev.h"
+#include "sig.h"
#include "link.h"
#include "xmalloc.h"
#include "xutils.h"
diff --git a/ifpps/Makefile b/ifpps/Makefile
index 6088ec6..6f2666f 100644
--- a/ifpps/Makefile
+++ b/ifpps/Makefile
@@ -5,5 +5,7 @@ ifpps-objs = xmalloc.o \
promisc.o \
str.o \
link.o \
+ sock.o \
dev.o \
+ sig.o \
ifpps.o
diff --git a/netsniff-ng.c b/netsniff-ng.c
index 9eb482d..65875d8 100644
--- a/netsniff-ng.c
+++ b/netsniff-ng.c
@@ -37,6 +37,7 @@
#include "die.h"
#include "irq.h"
#include "str.h"
+#include "sig.h"
#include "sock.h"
#include "geoip.h"
#include "lockme.h"
diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile
index 02c6120..cbe8f64 100644
--- a/netsniff-ng/Makefile
+++ b/netsniff-ng/Makefile
@@ -37,6 +37,7 @@ netsniff-ng-objs = dissector.o \
proc.o \
dev.o \
str.o \
+ sig.o \
sock.o \
irq.o \
iosched.o \
diff --git a/sig.c b/sig.c
new file mode 100644
index 0000000..2b5ab5e
--- /dev/null
+++ b/sig.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <signal.h>
+
+#include "sig.h"
+
+void register_signal(int signal, void (*handler)(int))
+{
+ sigset_t block_mask;
+ struct sigaction saction;
+
+ sigfillset(&block_mask);
+
+ saction.sa_handler = handler;
+ saction.sa_mask = block_mask;
+ saction.sa_flags = SA_RESTART;
+
+ sigaction(signal, &saction, NULL);
+}
+
+void register_signal_f(int signal, void (*handler)(int), int flags)
+{
+ sigset_t block_mask;
+ struct sigaction saction;
+
+ sigfillset(&block_mask);
+
+ saction.sa_handler = handler;
+ saction.sa_mask = block_mask;
+ saction.sa_flags = flags;
+
+ sigaction(signal, &saction, NULL);
+}
diff --git a/sig.h b/sig.h
new file mode 100644
index 0000000..10627b8
--- /dev/null
+++ b/sig.h
@@ -0,0 +1,7 @@
+#ifndef SIG_H
+#define SIG_H
+
+extern void register_signal(int signal, void (*handler)(int));
+extern void register_signal_f(int signal, void (*handler)(int), int flags);
+
+#endif /* SIG_H */
diff --git a/trafgen.c b/trafgen.c
index c36a2d1..41d04bd 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -35,6 +35,7 @@
#include "xmalloc.h"
#include "die.h"
#include "str.h"
+#include "sig.h"
#include "sock.h"
#include "cpus.h"
#include "lockme.h"
diff --git a/trafgen/Makefile b/trafgen/Makefile
index 69db433..5aeb424 100644
--- a/trafgen/Makefile
+++ b/trafgen/Makefile
@@ -11,6 +11,7 @@ trafgen-objs = xmalloc.o \
irq.o \
link.o \
str.o \
+ sig.o \
sock.o \
mac80211.o \
ring_tx.o \
diff --git a/xutils.c b/xutils.c
index d53a3e7..35f9092 100644
--- a/xutils.c
+++ b/xutils.c
@@ -72,34 +72,6 @@ int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events)
return epoll_ctl(fd_epoll, action, fd_toadd, &ev);
}
-void register_signal(int signal, void (*handler)(int))
-{
- sigset_t block_mask;
- struct sigaction saction;
-
- sigfillset(&block_mask);
-
- saction.sa_handler = handler;
- saction.sa_mask = block_mask;
- saction.sa_flags = SA_RESTART;
-
- sigaction(signal, &saction, NULL);
-}
-
-void register_signal_f(int signal, void (*handler)(int), int flags)
-{
- sigset_t block_mask;
- struct sigaction saction;
-
- sigfillset(&block_mask);
-
- saction.sa_handler = handler;
- saction.sa_mask = block_mask;
- saction.sa_flags = flags;
-
- sigaction(signal, &saction, NULL);
-}
-
void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec,
unsigned long usec)
{
diff --git a/xutils.h b/xutils.h
index b2287bb..dd30fad 100644
--- a/xutils.h
+++ b/xutils.h
@@ -25,8 +25,6 @@
#include "built_in.h"
-extern void register_signal(int signal, void (*handler)(int));
-extern void register_signal_f(int signal, void (*handler)(int), int flags);
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);
extern void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec,