From 7bd73747fff54cf51642dbbf042c621e59a2c005 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 4 Jun 2013 11:42:01 +0200 Subject: timer: add time management functions Signed-off-by: Daniel Borkmann --- netsniff-ng.c | 1 + netsniff-ng/Makefile | 1 + timer.c | 13 +++++++++++++ timer.h | 9 +++++++++ trafgen.c | 1 + trafgen/Makefile | 1 + xutils.c | 10 ---------- xutils.h | 2 -- 8 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 timer.c create mode 100644 timer.h diff --git a/netsniff-ng.c b/netsniff-ng.c index 65875d8..ed488aa 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -42,6 +42,7 @@ #include "geoip.h" #include "lockme.h" #include "tprintf.h" +#include "timer.h" #include "dissector.h" #include "xmalloc.h" diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile index cbe8f64..4621179 100644 --- a/netsniff-ng/Makefile +++ b/netsniff-ng/Makefile @@ -57,6 +57,7 @@ netsniff-ng-objs = dissector.o \ ring.o \ tprintf.o \ tstamping.o \ + timer.o \ geoip.o \ mac80211.o \ netsniff-ng.o diff --git a/timer.c b/timer.c new file mode 100644 index 0000000..8941ab7 --- /dev/null +++ b/timer.c @@ -0,0 +1,13 @@ +#include + +#include "timer.h" + +void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec, + unsigned long usec) +{ + itimer->it_interval.tv_sec = sec; + itimer->it_interval.tv_usec = usec; + + itimer->it_value.tv_sec = sec; + itimer->it_value.tv_usec = usec; +} diff --git a/timer.h b/timer.h new file mode 100644 index 0000000..8e869c8 --- /dev/null +++ b/timer.h @@ -0,0 +1,9 @@ +#ifndef TIMER_H +#define TIMER_H + +#include + +extern void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec, + unsigned long usec); + +#endif /* TIMER_H */ diff --git a/trafgen.c b/trafgen.c index 41d04bd..fc15e20 100644 --- a/trafgen.c +++ b/trafgen.c @@ -48,6 +48,7 @@ #include "built_in.h" #include "trafgen_conf.h" #include "tprintf.h" +#include "timer.h" #include "ring_tx.h" #include "csum.h" diff --git a/trafgen/Makefile b/trafgen/Makefile index 5aeb424..9555ca0 100644 --- a/trafgen/Makefile +++ b/trafgen/Makefile @@ -16,6 +16,7 @@ trafgen-objs = xmalloc.o \ mac80211.o \ ring_tx.o \ ring.o \ + timer.o \ trafgen_lexer.yy.o \ trafgen_parser.tab.o \ trafgen.o diff --git a/xutils.c b/xutils.c index 35f9092..56b4c59 100644 --- a/xutils.c +++ b/xutils.c @@ -71,13 +71,3 @@ int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events) return epoll_ctl(fd_epoll, action, fd_toadd, &ev); } - -void set_itimer_interval_value(struct itimerval *itimer, unsigned long sec, - unsigned long usec) -{ - itimer->it_interval.tv_sec = sec; - itimer->it_interval.tv_usec = usec; - - itimer->it_value.tv_sec = sec; - itimer->it_value.tv_usec = usec; -} diff --git a/xutils.h b/xutils.h index dd30fad..2e0e251 100644 --- a/xutils.h +++ b/xutils.h @@ -27,7 +27,5 @@ 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, - unsigned long usec); #endif /* XSYS_H */ -- cgit v1.2.3-54-g00ecf