From 83ef345503943cc6f7c2f02381f71113601e8261 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 4 Jun 2013 11:55:28 +0200 Subject: xutils: eliminate xutils, move rest to epoll2 Finally eliminate xutils.{c,h} and move the rest to epoll2. Signed-off-by: Daniel Borkmann --- astraceroute.c | 1 - astraceroute/Makefile | 1 - bpf.c | 1 - bpf_parser.y | 1 - bpfc.c | 2 +- bpfc/Makefile | 2 -- ct_client.c | 1 - ct_server.c | 2 +- ct_servmgmt.c | 1 - ct_usermgmt.c | 1 - curve.c | 1 - curvetun.c | 1 - curvetun/Makefile | 2 +- dev.c | 1 - dissector.h | 2 ++ dissector_80211.h | 1 - dissector_eth.h | 1 - epoll2.c | 30 +++++++++++++++++++++ epoll2.h | 7 +++++ flowtop.c | 1 - flowtop/Makefile | 1 - geoip.c | 1 - ifpps.c | 1 - ioops.c | 1 - irq.c | 9 +------ mac80211.c | 3 ++- mausezahn/Makefile | 4 +-- netsniff-ng.c | 1 - netsniff-ng/Makefile | 1 - oui.c | 1 - pcap_mm.c | 3 +-- pcap_rw.c | 1 - pcap_sg.c | 1 - proto_lldp.c | 1 - ring.h | 1 - ring_rx.h | 2 ++ ring_tx.h | 2 ++ stun.c | 1 - tprintf.c | 1 - trafgen.c | 3 ++- trafgen/Makefile | 1 - trafgen_parser.y | 1 - tstamping.c | 1 - xmalloc.c | 1 - xutils.c | 73 --------------------------------------------------- xutils.h | 31 ---------------------- 46 files changed, 53 insertions(+), 154 deletions(-) create mode 100644 epoll2.c create mode 100644 epoll2.h delete mode 100644 xutils.c delete mode 100644 xutils.h diff --git a/astraceroute.c b/astraceroute.c index a7f04c6..1bcb9a4 100644 --- a/astraceroute.c +++ b/astraceroute.c @@ -43,7 +43,6 @@ #include "csum.h" #include "sock.h" #include "geoip.h" -#include "xutils.h" #include "ring_rx.h" #include "built_in.h" diff --git a/astraceroute/Makefile b/astraceroute/Makefile index b99e310..8f9f518 100644 --- a/astraceroute/Makefile +++ b/astraceroute/Makefile @@ -4,7 +4,6 @@ astraceroute-libs = -lGeoIP \ astraceroute-objs = xmalloc.o \ ioops.o \ - xutils.o \ proto_none.o \ tprintf.o \ bpf.o \ diff --git a/bpf.c b/bpf.c index b64b909..d18eac2 100644 --- a/bpf.c +++ b/bpf.c @@ -16,7 +16,6 @@ #include "bpf.h" #include "xmalloc.h" -#include "xutils.h" #include "die.h" #include "str.h" diff --git a/bpf_parser.y b/bpf_parser.y index 307066e..0bbc17d 100644 --- a/bpf_parser.y +++ b/bpf_parser.y @@ -24,7 +24,6 @@ #include "bpf_parser.tab.h" #include "built_in.h" #include "die.h" -#include "xutils.h" #define MAX_INSTRUCTIONS 4096 diff --git a/bpfc.c b/bpfc.c index f326025..d83bfd7 100644 --- a/bpfc.c +++ b/bpfc.c @@ -7,13 +7,13 @@ #include #include +#include #include #include #include #include #include "xmalloc.h" -#include "xutils.h" #include "die.h" #include "bpf.h" diff --git a/bpfc/Makefile b/bpfc/Makefile index 61107bf..fa19d55 100644 --- a/bpfc/Makefile +++ b/bpfc/Makefile @@ -1,9 +1,7 @@ bpfc-libs = bpfc-objs = xmalloc.o \ - xutils.o \ str.o \ - sock.o \ bpf.o \ bpf_lexer.yy.o \ bpf_parser.tab.o \ diff --git a/ct_client.c b/ct_client.c index 50f5df4..1f4d10e 100644 --- a/ct_client.c +++ b/ct_client.c @@ -30,7 +30,6 @@ #include "str.h" #include "sock.h" #include "ioops.h" -#include "xutils.h" #include "curve.h" #include "xmalloc.h" #include "corking.h" diff --git a/ct_server.c b/ct_server.c index 89ed815..eb53bd3 100644 --- a/ct_server.c +++ b/ct_server.c @@ -29,7 +29,7 @@ #include #include "die.h" -#include "xutils.h" +#include "epoll2.h" #include "ioops.h" #include "xmalloc.h" #include "curvetun.h" diff --git a/ct_servmgmt.c b/ct_servmgmt.c index 0d7da78..143b03a 100644 --- a/ct_servmgmt.c +++ b/ct_servmgmt.c @@ -17,7 +17,6 @@ #include "locking.h" #include "xmalloc.h" #include "curvetun.h" -#include "xutils.h" #include "curve.h" #include "ct_servmgmt.h" #include "crypto_box_curve25519xsalsa20poly1305.h" diff --git a/ct_usermgmt.c b/ct_usermgmt.c index 2642986..a4978fc 100644 --- a/ct_usermgmt.c +++ b/ct_usermgmt.c @@ -22,7 +22,6 @@ #include "ioops.h" #include "str.h" #include "curvetun.h" -#include "xutils.h" #include "curve.h" #include "hash.h" #include "crypto_verify_32.h" diff --git a/curve.c b/curve.c index 243e833..9b32c03 100644 --- a/curve.c +++ b/curve.c @@ -19,7 +19,6 @@ #include "built_in.h" #include "xmalloc.h" #include "curve.h" -#include "xutils.h" #include "ioops.h" #include "rnd.h" #include "die.h" diff --git a/curvetun.c b/curvetun.c index 38e3f83..eb8bcde 100644 --- a/curvetun.c +++ b/curvetun.c @@ -25,7 +25,6 @@ #include #include -#include "xutils.h" #include "die.h" #include "str.h" #include "sig.h" diff --git a/curvetun/Makefile b/curvetun/Makefile index f66fd4d..8ae6291 100644 --- a/curvetun/Makefile +++ b/curvetun/Makefile @@ -2,7 +2,7 @@ curvetun-libs = -lnacl \ -lpthread curvetun-objs = xmalloc.o \ - xutils.o \ + epoll2.o \ str.o \ dev.o \ stun.o \ diff --git a/dev.c b/dev.c index cd18d9b..210487c 100644 --- a/dev.c +++ b/dev.c @@ -9,7 +9,6 @@ #include "sock.h" #include "die.h" #include "link.h" -#include "xutils.h" int device_ifindex(const char *ifname) { diff --git a/dissector.h b/dissector.h index 2c2c128..60bc429 100644 --- a/dissector.h +++ b/dissector.h @@ -9,7 +9,9 @@ #include #include +#include #include +#include #include "ring.h" #include "tprintf.h" diff --git a/dissector_80211.h b/dissector_80211.h index 8c22356..53059e5 100644 --- a/dissector_80211.h +++ b/dissector_80211.h @@ -11,7 +11,6 @@ #include "proto.h" #include "protos.h" #include "tprintf.h" -#include "xutils.h" #include "oui.h" extern struct hash_table ieee80211_lay2; diff --git a/dissector_eth.h b/dissector_eth.h index 4c49f28..85106bc 100644 --- a/dissector_eth.h +++ b/dissector_eth.h @@ -11,7 +11,6 @@ #include "proto.h" #include "protos.h" #include "tprintf.h" -#include "xutils.h" #include "oui.h" extern struct hash_table eth_lay2; diff --git a/epoll2.c b/epoll2.c new file mode 100644 index 0000000..71a7ac6 --- /dev/null +++ b/epoll2.c @@ -0,0 +1,30 @@ +#include +#include + +#include "epoll2.h" +#include "die.h" + +void set_epoll_descriptor(int fd_epoll, int action, int fd_toadd, int events) +{ + int ret; + struct epoll_event ev; + + memset(&ev, 0, sizeof(ev)); + ev.events = events; + ev.data.fd = fd_toadd; + + ret = epoll_ctl(fd_epoll, action, fd_toadd, &ev); + if (ret < 0) + panic("Cannot add socket for epoll!\n"); +} + +int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events) +{ + struct epoll_event ev; + + memset(&ev, 0, sizeof(ev)); + ev.events = events; + ev.data.fd = fd_toadd; + + return epoll_ctl(fd_epoll, action, fd_toadd, &ev); +} diff --git a/epoll2.h b/epoll2.h new file mode 100644 index 0000000..1ecf5f0 --- /dev/null +++ b/epoll2.h @@ -0,0 +1,7 @@ +#ifndef __EPOLL_H +#define __EPOLL_H + +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); + +#endif /* __EPOLL_H */ diff --git a/flowtop.c b/flowtop.c index 0de3cb6..95734df 100644 --- a/flowtop.c +++ b/flowtop.c @@ -33,7 +33,6 @@ #include "str.h" #include "sig.h" #include "geoip.h" -#include "xutils.h" #include "built_in.h" #include "locking.h" #include "dissector_eth.h" diff --git a/flowtop/Makefile b/flowtop/Makefile index 43f221f..7e7797a 100644 --- a/flowtop/Makefile +++ b/flowtop/Makefile @@ -7,7 +7,6 @@ flowtop-libs = -lGeoIP \ flowtop-objs = xmalloc.o \ ioops.o \ - xutils.o \ oui.o \ str.o \ sig.o \ diff --git a/geoip.c b/geoip.c index bef35fb..b403ad1 100644 --- a/geoip.c +++ b/geoip.c @@ -18,7 +18,6 @@ #include "built_in.h" #include "die.h" -#include "xutils.h" #include "ioops.h" #include "str.h" #include "xmalloc.h" diff --git a/ifpps.c b/ifpps.c index 40a3f63..3a83043 100644 --- a/ifpps.c +++ b/ifpps.c @@ -22,7 +22,6 @@ #include "sig.h" #include "link.h" #include "xmalloc.h" -#include "xutils.h" #include "ioops.h" #include "promisc.h" #include "cpus.h" diff --git a/ioops.c b/ioops.c index 091153b..6e79317 100644 --- a/ioops.c +++ b/ioops.c @@ -12,7 +12,6 @@ #include "dev.h" #include "ioops.h" #include "str.h" -#include "xutils.h" int open_or_die(const char *file, int flags) { diff --git a/irq.c b/irq.c index 1eed0d5..4132d19 100644 --- a/irq.c +++ b/irq.c @@ -1,13 +1,7 @@ -/* - * netsniff-ng - the packet sniffing beast - * Copyright 2009 - 2013 Daniel Borkmann. - * Copyright 2009, 2010 Emmanuel Roullit. - * Subject to the GPL, version 2. - */ - #include #include #include +#include #include #include #include @@ -16,7 +10,6 @@ #include "irq.h" #include "str.h" #include "die.h" -#include "xutils.h" int device_irq_number(const char *ifname) { diff --git a/mac80211.c b/mac80211.c index 1572f73..0154416 100644 --- a/mac80211.c +++ b/mac80211.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -25,7 +27,6 @@ #include "die.h" #include "str.h" #include "dev.h" -#include "xutils.h" #include "mac80211.h" #include "xmalloc.h" #include "built_in.h" diff --git a/mausezahn/Makefile b/mausezahn/Makefile index 2e9e417..ab892c6 100644 --- a/mausezahn/Makefile +++ b/mausezahn/Makefile @@ -5,9 +5,7 @@ mausezahn-libs = -lcli \ -lpthread \ -lm -mausezahn-objs = xutils.o \ - str.o \ - sock.o \ +mausezahn-objs = str.o \ staging/layer1.o \ staging/layer2.o \ staging/layer3.o \ diff --git a/netsniff-ng.c b/netsniff-ng.c index ed488aa..23c1d5b 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -26,7 +26,6 @@ #include "ring_rx.h" #include "ring_tx.h" #include "mac80211.h" -#include "xutils.h" #include "promisc.h" #include "built_in.h" #include "pcap_io.h" diff --git a/netsniff-ng/Makefile b/netsniff-ng/Makefile index 4621179..356ae2e 100644 --- a/netsniff-ng/Makefile +++ b/netsniff-ng/Makefile @@ -43,7 +43,6 @@ netsniff-ng-objs = dissector.o \ iosched.o \ ioops.o \ link.o \ - xutils.o \ xmalloc.o \ hash.o \ bpf.o \ diff --git a/oui.c b/oui.c index 2fa716a..3354ed4 100644 --- a/oui.c +++ b/oui.c @@ -9,7 +9,6 @@ #include "hash.h" #include "xmalloc.h" -#include "xutils.h" #include "oui.h" #include "str.h" diff --git a/pcap_mm.c b/pcap_mm.c index 848f7e0..ea74034 100644 --- a/pcap_mm.c +++ b/pcap_mm.c @@ -14,9 +14,8 @@ #include #include "pcap_io.h" -#include "ioops.h" -#include "xutils.h" #include "built_in.h" +#include "ioops.h" #include "iosched.h" static size_t map_size = 0; diff --git a/pcap_rw.c b/pcap_rw.c index 6c9601f..65b45cb 100644 --- a/pcap_rw.c +++ b/pcap_rw.c @@ -13,7 +13,6 @@ #include "pcap_io.h" #include "built_in.h" -#include "xutils.h" #include "die.h" #include "iosched.h" #include "ioops.h" diff --git a/pcap_sg.c b/pcap_sg.c index ea4a709..19bec40 100644 --- a/pcap_sg.c +++ b/pcap_sg.c @@ -13,7 +13,6 @@ #include "pcap_io.h" #include "xmalloc.h" -#include "xutils.h" #include "built_in.h" #include "iosched.h" #include "ioops.h" diff --git a/proto_lldp.c b/proto_lldp.c index 4e33048..205c899 100644 --- a/proto_lldp.c +++ b/proto_lldp.c @@ -13,7 +13,6 @@ #include "pkt_buff.h" #include "proto.h" #include "protos.h" -#include "xutils.h" #define EXTRACT_16BIT(x) ntohs(*((uint16_t *) (x))) #define EXTRACT_32BIT(x) ntohl(*((uint32_t *) (x))) diff --git a/ring.h b/ring.h index 9a2e05b..7ee7735 100644 --- a/ring.h +++ b/ring.h @@ -22,7 +22,6 @@ #include #include -#include "xutils.h" #include "built_in.h" #include "die.h" #include "dev.h" diff --git a/ring_rx.h b/ring_rx.h index 43b4020..6f3cdab 100644 --- a/ring_rx.h +++ b/ring_rx.h @@ -7,6 +7,8 @@ #ifndef RX_RING_H #define RX_RING_H +#include + #include "ring.h" #include "built_in.h" diff --git a/ring_tx.h b/ring_tx.h index 23caa35..adfe2a4 100644 --- a/ring_tx.h +++ b/ring_tx.h @@ -7,6 +7,8 @@ #ifndef TX_RING_H #define TX_RING_H +#include + #include "ring.h" #include "built_in.h" diff --git a/stun.c b/stun.c index 4b8dd62..2389145 100644 --- a/stun.c +++ b/stun.c @@ -19,7 +19,6 @@ #include #include "xmalloc.h" -#include "xutils.h" #include "die.h" #include "sock.h" diff --git a/tprintf.c b/tprintf.c index b57d706..82623a9 100644 --- a/tprintf.c +++ b/tprintf.c @@ -11,7 +11,6 @@ #include #include -#include "xutils.h" #include "tprintf.h" #include "die.h" #include "locking.h" diff --git a/trafgen.c b/trafgen.c index fc15e20..2d99a4b 100644 --- a/trafgen.c +++ b/trafgen.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +44,6 @@ #include "privs.h" #include "proc.h" #include "mac80211.h" -#include "xutils.h" #include "ioops.h" #include "irq.h" #include "built_in.h" diff --git a/trafgen/Makefile b/trafgen/Makefile index 9555ca0..3747661 100644 --- a/trafgen/Makefile +++ b/trafgen/Makefile @@ -4,7 +4,6 @@ trafgen-libs = $(shell pkg-config --libs libnl-3.0) \ trafgen-objs = xmalloc.o \ ioops.o \ - xutils.o \ privs.o \ proc.o \ dev.o \ diff --git a/trafgen_parser.y b/trafgen_parser.y index 85d7b01..71f5ddd 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -25,7 +25,6 @@ #include "die.h" #include "str.h" #include "csum.h" -#include "xutils.h" #define YYERROR_VERBOSE 0 #define YYDEBUG 0 diff --git a/tstamping.c b/tstamping.c index 9ef1a4a..29dec35 100644 --- a/tstamping.c +++ b/tstamping.c @@ -17,7 +17,6 @@ extern int set_sockopt_hwtimestamp(int sock, const char *dev); #include #include -#include "xutils.h" #include "str.h" int set_sockopt_hwtimestamp(int sock, const char *dev) diff --git a/xmalloc.c b/xmalloc.c index b40f14c..d5805b8 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -15,7 +15,6 @@ #include #include "xmalloc.h" -#include "xutils.h" #include "built_in.h" #include "die.h" #include "str.h" diff --git a/xutils.c b/xutils.c deleted file mode 100644 index 56b4c59..0000000 --- a/xutils.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * netsniff-ng - the packet sniffing beast - * Copyright 2009, 2010 Daniel Borkmann. - * Copyright 2009, 2010 Emmanuel Roullit. - * Subject to the GPL, version 2. - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "die.h" -#include "str.h" -#include "xutils.h" -#include "ring.h" -#include "sock.h" -#include "built_in.h" - -void set_epoll_descriptor(int fd_epoll, int action, int fd_toadd, int events) -{ - int ret; - struct epoll_event ev; - - memset(&ev, 0, sizeof(ev)); - ev.events = events; - ev.data.fd = fd_toadd; - - ret = epoll_ctl(fd_epoll, action, fd_toadd, &ev); - if (ret < 0) - panic("Cannot add socket for epoll!\n"); -} - -int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events) -{ - struct epoll_event ev; - - memset(&ev, 0, sizeof(ev)); - ev.events = events; - ev.data.fd = fd_toadd; - - return epoll_ctl(fd_epoll, action, fd_toadd, &ev); -} diff --git a/xutils.h b/xutils.h deleted file mode 100644 index 2e0e251..0000000 --- a/xutils.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * netsniff-ng - the packet sniffing beast - * Copyright 2009, 2010 Daniel Borkmann. - * Copyright 2009, 2010 Emmanuel Roullit. - * Subject to the GPL, version 2. - */ - -#ifndef XSYS_H -#define XSYS_H - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "built_in.h" - -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); - -#endif /* XSYS_H */ -- cgit v1.2.3-54-g00ecf