diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-04 11:55:28 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-04 11:55:28 +0200 |
commit | 83ef345503943cc6f7c2f02381f71113601e8261 (patch) | |
tree | c86227397301650996a2b2db5d4b75b8ad33f7d1 | |
parent | 7bd73747fff54cf51642dbbf042c621e59a2c005 (diff) |
xutils: eliminate xutils, move rest to epoll2
Finally eliminate xutils.{c,h} and move the rest to epoll2.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | astraceroute.c | 1 | ||||
-rw-r--r-- | astraceroute/Makefile | 1 | ||||
-rw-r--r-- | bpf.c | 1 | ||||
-rw-r--r-- | bpf_parser.y | 1 | ||||
-rw-r--r-- | bpfc.c | 2 | ||||
-rw-r--r-- | bpfc/Makefile | 2 | ||||
-rw-r--r-- | ct_client.c | 1 | ||||
-rw-r--r-- | ct_server.c | 2 | ||||
-rw-r--r-- | ct_servmgmt.c | 1 | ||||
-rw-r--r-- | ct_usermgmt.c | 1 | ||||
-rw-r--r-- | curve.c | 1 | ||||
-rw-r--r-- | curvetun.c | 1 | ||||
-rw-r--r-- | curvetun/Makefile | 2 | ||||
-rw-r--r-- | dev.c | 1 | ||||
-rw-r--r-- | dissector.h | 2 | ||||
-rw-r--r-- | dissector_80211.h | 1 | ||||
-rw-r--r-- | dissector_eth.h | 1 | ||||
-rw-r--r-- | epoll2.c | 30 | ||||
-rw-r--r-- | epoll2.h | 7 | ||||
-rw-r--r-- | flowtop.c | 1 | ||||
-rw-r--r-- | flowtop/Makefile | 1 | ||||
-rw-r--r-- | geoip.c | 1 | ||||
-rw-r--r-- | ifpps.c | 1 | ||||
-rw-r--r-- | ioops.c | 1 | ||||
-rw-r--r-- | irq.c | 9 | ||||
-rw-r--r-- | mac80211.c | 3 | ||||
-rw-r--r-- | mausezahn/Makefile | 4 | ||||
-rw-r--r-- | netsniff-ng.c | 1 | ||||
-rw-r--r-- | netsniff-ng/Makefile | 1 | ||||
-rw-r--r-- | oui.c | 1 | ||||
-rw-r--r-- | pcap_mm.c | 3 | ||||
-rw-r--r-- | pcap_rw.c | 1 | ||||
-rw-r--r-- | pcap_sg.c | 1 | ||||
-rw-r--r-- | proto_lldp.c | 1 | ||||
-rw-r--r-- | ring.h | 1 | ||||
-rw-r--r-- | ring_rx.h | 2 | ||||
-rw-r--r-- | ring_tx.h | 2 | ||||
-rw-r--r-- | stun.c | 1 | ||||
-rw-r--r-- | tprintf.c | 1 | ||||
-rw-r--r-- | trafgen.c | 3 | ||||
-rw-r--r-- | trafgen/Makefile | 1 | ||||
-rw-r--r-- | trafgen_parser.y | 1 | ||||
-rw-r--r-- | tstamping.c | 1 | ||||
-rw-r--r-- | xmalloc.c | 1 | ||||
-rw-r--r-- | xutils.c | 73 | ||||
-rw-r--r-- | xutils.h | 31 |
46 files changed, 53 insertions, 154 deletions
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 \ @@ -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 @@ -7,13 +7,13 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <getopt.h> #include <ctype.h> #include <unistd.h> #include <sys/fsuid.h> #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 <linux/if_tun.h> #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" @@ -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" @@ -25,7 +25,6 @@ #include <unistd.h> #include <signal.h> -#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 \ @@ -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 <stdlib.h> #include <stdint.h> +#include <sys/socket.h> #include <linux/if_packet.h> +#include <linux/if.h> #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 <sys/epoll.h> +#include <string.h> + +#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 */ @@ -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 \ @@ -18,7 +18,6 @@ #include "built_in.h" #include "die.h" -#include "xutils.h" #include "ioops.h" #include "str.h" #include "xmalloc.h" @@ -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" @@ -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) { @@ -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 <stdio.h> #include <string.h> #include <stdlib.h> +#include <stdbool.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> @@ -16,7 +10,6 @@ #include "irq.h" #include "str.h" #include "die.h" -#include "xutils.h" int device_irq_number(const char *ifname) { @@ -15,6 +15,8 @@ #include <errno.h> #include <string.h> #include <limits.h> +#include <sys/socket.h> +#include <linux/if.h> #include <linux/nl80211.h> #include <libnl3/netlink/genl/genl.h> #include <libnl3/netlink/genl/family.h> @@ -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 \ @@ -9,7 +9,6 @@ #include "hash.h" #include "xmalloc.h" -#include "xutils.h" #include "oui.h" #include "str.h" @@ -14,9 +14,8 @@ #include <sys/mman.h> #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; @@ -13,7 +13,6 @@ #include "pcap_io.h" #include "built_in.h" -#include "xutils.h" #include "die.h" #include "iosched.h" #include "ioops.h" @@ -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))) @@ -22,7 +22,6 @@ #include <poll.h> #include <sys/poll.h> -#include "xutils.h" #include "built_in.h" #include "die.h" #include "dev.h" @@ -7,6 +7,8 @@ #ifndef RX_RING_H #define RX_RING_H +#include <stdbool.h> + #include "ring.h" #include "built_in.h" @@ -7,6 +7,8 @@ #ifndef TX_RING_H #define TX_RING_H +#include <stdbool.h> + #include "ring.h" #include "built_in.h" @@ -19,7 +19,6 @@ #include <sys/select.h> #include "xmalloc.h" -#include "xutils.h" #include "die.h" #include "sock.h" @@ -11,7 +11,6 @@ #include <stdarg.h> #include <sys/ioctl.h> -#include "xutils.h" #include "tprintf.h" #include "die.h" #include "locking.h" @@ -10,6 +10,7 @@ #include <getopt.h> #include <ctype.h> #include <stdbool.h> +#include <sched.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/fsuid.h> @@ -21,6 +22,7 @@ #include <netinet/in.h> #include <netinet/ip.h> #include <linux/icmp.h> +#include <linux/if.h> #include <arpa/inet.h> #include <signal.h> #include <stdint.h> @@ -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 <linux/if_packet.h> #include <linux/if.h> -#include "xutils.h" #include "str.h" int set_sockopt_hwtimestamp(int sock, const char *dev) @@ -15,7 +15,6 @@ #include <sys/types.h> #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 <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <stdarg.h> -#include <ctype.h> -#include <signal.h> -#include <arpa/inet.h> -#include <time.h> -#include <sched.h> -#include <limits.h> -#include <stdbool.h> -#include <netdb.h> -#include <ifaddrs.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <sys/resource.h> -#include <sys/epoll.h> -#include <sys/syscall.h> -#include <asm/unistd.h> -#include <linux/if.h> -#include <linux/socket.h> -#include <linux/types.h> -#include <linux/if_ether.h> -#include <linux/if_packet.h> -#include <linux/sockios.h> -#include <netinet/tcp.h> -#include <netinet/udp.h> - -#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 <errno.h> -#include <stdint.h> -#include <sys/socket.h> -#include <unistd.h> -#include <linux/ethtool.h> -#include <linux/if.h> -#include <linux/wireless.h> -#include <poll.h> -#include <sys/poll.h> -#include <sched.h> -#include <stdbool.h> -#include <sys/resource.h> -#include <sys/time.h> - -#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 */ |