2 # This isn't a configure generated by autoconf!
3 # netsniff-ng build system
4 # Copyright 2013 Tobias Klauser <tklauser@distanz.ch>
5 # Copyright 2013 Daniel Borkmann <borkmann@gnumaniacs.org>
6 # Subject to the GNU GPL, version 2.
12 TOOLS
="netsniff-ng trafgen astraceroute flowtop ifpps bpfc curvetun mausezahn"
22 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
23 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
30 for tool
in $_tools ; do
35 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
37 *) TOOLS
="$TOOLS $tool" ;;
42 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
47 echo -n "[*] Checking pkg-config ... "
49 if [ "x$(which pkg-config 2>> config.log)" == "x" ] ; then
59 echo -n "[*] Checking ccache ... "
61 if [ "x$(which ccache 2>> config.log)" == "x" ] ; then
63 echo "CONFIG_CCACHE=" >> Config
66 echo "CONFIG_CCACHE=ccache" >> Config
72 echo -n "[*] Checking flex ... "
74 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
77 tools_remove
"trafgen"
86 echo -n "[*] Checking bison ... "
88 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
91 tools_remove
"trafgen"
100 echo -n "[*] Checking nacl ... "
102 cat > $TMPDIR/nacltest.c
<< EOF
103 #include "crypto_hash_sha512.h"
104 #include "crypto_verify_32.h"
105 #include "crypto_hash_sha512.h"
106 #include "crypto_box_curve25519xsalsa20poly1305.h"
107 #include "crypto_scalarmult_curve25519.h"
108 #include "crypto_auth_hmacsha512256.h"
113 if [ -z $NACL_INC_DIR ] ; then
114 NACL_INC_DIR
="/usr/include/nacl"
117 if [ -z $NACL_LIB_DIR ] ; then
118 NACL_LIB_DIR
="/usr/lib"
121 LDFLAGS
="-L $NACL_LIB_DIR"
122 CFLAGS
="-I $NACL_INC_DIR"
124 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
125 if [ ! -x $TMPDIR/nacltest
] ; then
128 tools_remove
"curvetun"
131 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
132 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
138 echo -n "[*] Checking libnl ... "
140 cat > $TMPDIR/libnltest.c
<< EOF
141 #include <libnl3/netlink/genl/genl.h>
142 #include <libnl3/netlink/genl/family.h>
143 #include <libnl3/netlink/genl/ctrl.h>
144 #include <libnl3/netlink/msg.h>
145 #include <libnl3/netlink/attr.h>
146 #include <libnl3/netlink/version.h>
148 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
149 # error incompatible libnl version
154 struct nl_sock *sock = nl_socket_alloc();
155 struct nl_cache *nl_cache;
156 int ret = genl_connect(sock);
158 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
163 $
(pkg-config
--cflags libnl-3.0
2>> config.log
) \
164 $
(pkg-config
--cflags libnl-genl-3.0
2>> config.log
) \
165 -o $TMPDIR/libnltest \
166 $TMPDIR/libnltest.c \
167 $
(pkg-config
--libs libnl-3.0
2>> config.log
) \
168 $
(pkg-config
--libs libnl-genl-3.0
2>> config.log
) \
170 if [ ! -x $TMPDIR/libnltest
] ; then
173 tools_remove
"trafgen"
174 tools_remove
"netsniff-ng"
182 echo -n "[*] Checking tpacket_v3 ... "
184 cat > $TMPDIR/tpacketv3test.c
<< EOF
186 #include <linux/if_packet.h>
190 struct tpacket3_hdr *hdr;
195 printf("%d\n", hdr->tp_status);
199 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
200 if [ ! -x $TMPDIR/tpacketv3test
] ; then
203 tools_remove
"netsniff-ng"
211 echo -n "[*] Checking tpacket_v2 ... "
213 cat > $TMPDIR/tpacketv2test.c
<< EOF
215 #include <linux/if_packet.h>
219 struct tpacket2_hdr *hdr;
222 TP_STATUS_SEND_REQUEST,
228 printf("%d\n", hdr->tp_status);
232 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
233 if [ ! -x $TMPDIR/tpacketv2test
] ; then
236 tools_remove
"netsniff-ng"
237 tools_remove
"trafgen"
246 echo -n "[*] Checking ncurses ... "
248 cat > $TMPDIR/ncursestest.c
<< EOF
253 WINDOW *screen = initscr();
258 $
(pkg-config
--cflags ncurses
2>> config.log
) \
259 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
260 $
(pkg-config
--libs ncurses
2>> config.log
) \
262 if [ ! -x $TMPDIR/ncursestest
] ; then
265 tools_remove
"flowtop"
274 echo -n "[*] Checking libGeoIP ... "
276 cat > $TMPDIR/geoiptest.c
<< EOF
278 #include <GeoIPCity.h>
283 GEOIP_CITY_EDITION_REV1,
284 GEOIP_CITY_EDITION_REV1_V6,
285 GEOIP_COUNTRY_EDITION,
286 GEOIP_COUNTRY_EDITION_V6,
288 GEOIP_ASNUM_EDITION_V6,
290 GeoIP *geoip = GeoIP_new(0);
294 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
295 if [ ! -x $TMPDIR/geoiptest
] ; then
297 echo "CONFIG_LIBGEOIP=0" >> Config
299 tools_remove
"astraceroute"
300 tools_remove
"flowtop"
303 echo "CONFIG_LIBGEOIP=1" >> Config
310 echo -n "[*] Checking libnetfilter-conntrack ... "
312 cat > $TMPDIR/nfcttest.c
<< EOF
313 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
314 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
315 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
316 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
320 struct nf_conntrack *ct;
321 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
325 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> config.log
2>&1
326 if [ ! -x $TMPDIR/nfcttest
] ; then
329 tools_remove
"flowtop"
337 echo -n "[*] Checking libz ... "
339 cat > $TMPDIR/ztest.c
<< EOF
344 gzFile fp = gzopen("foo.gz", "rb");
348 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
349 if [ ! -x $TMPDIR/ztest
] ; then
351 echo "CONFIG_LIBZ=0" >> Config
353 tools_remove
"astraceroute"
354 tools_remove
"flowtop"
357 echo "CONFIG_LIBZ=1" >> Config
364 echo -n "[*] Checking liburcu ... "
366 cat > $TMPDIR/urcutest.c
<< EOF
376 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
377 if [ ! -x $TMPDIR/urcutest
] ; then
380 tools_remove
"flowtop"
388 echo -n "[*] Checking libpcap ... "
390 cat > $TMPDIR/pcaptest.c
<< EOF
395 struct bpf_program bpf;
396 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
400 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
401 if [ ! -x $TMPDIR/pcaptest
] ; then
403 echo "CONFIG_LIBPCAP=0" >> Config
405 tools_remove
"mausezahn"
408 echo "CONFIG_LIBPCAP=1" >> Config
415 echo -n "[*] Checking hw timestamping ... "
417 cat > $TMPDIR/hwtstest.c
<< EOF
419 #include <arpa/inet.h>
420 #include <sys/ioctl.h>
421 #include <sys/types.h>
422 #include <sys/socket.h>
423 #include <linux/sockios.h>
424 #include <linux/net_tstamp.h>
425 #include <linux/if_packet.h>
426 #include <linux/if_ether.h>
427 #include <linux/if.h>
431 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
432 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
433 struct hwtstamp_config hwconfig;
436 memset(&hwconfig, 0, sizeof(hwconfig));
437 hwconfig.tx_type = HWTSTAMP_TX_OFF;
438 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
440 memset(&ifr, 0, sizeof(ifr));
441 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
442 ifr.ifr_data = &hwconfig;
444 ioctl(sock, SIOCSHWTSTAMP, &ifr);
445 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
450 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
451 if [ ! -x $TMPDIR/hwtstest
] ; then
453 echo "CONFIG_HWTSTAMP=0" >> Config
456 echo "CONFIG_HWTSTAMP=1" >> Config
463 echo -n "[*] Checking libcli ... "
465 cat > $TMPDIR/clitest.c
<< EOF
470 struct cli_def *cli = cli_init();
474 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
475 if [ ! -x $TMPDIR/clitest
] ; then
478 tools_remove
"mausezahn"
486 echo -n "[*] Checking libnet ... "
488 cat > $TMPDIR/nettest.c
<< EOF
493 char err_buf[LIBNET_ERRBUF_SIZE];
494 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
498 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
499 if [ ! -x $TMPDIR/nettest
] ; then
502 tools_remove
"mausezahn"
508 gen_version_appendix
()
512 git rev-parse
> /dev
/null
2>&1
513 if [ "$?" == "0" ] ; then
514 if [ ! "`git describe --always`" == \
515 "`git describe --abbrev=0 --tags`" ] ; then
520 echo "CONFIG_RC=\"$_appendix\"" >> Config
526 local _have_libpcap
=""
527 local _have_libgeoip
=""
531 echo "[*] Generating config.h ... "
533 git rev-parse
> /dev
/null
2>&1
534 if [ "$?" == "0" ] ; then
535 _version
="`git describe --always`"
540 if [ "$HAVE_LIBPCAP" == "1" ] ; then
541 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
544 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
545 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
548 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
549 _have_libgeoip
="#define HAVE_GEOIP 1"
552 if [ "$HAVE_LIBZ" == "1" ] ; then
553 _have_libz
="#define HAVE_LIBZ 1"
556 cat > config.h
<< EOF
559 #define FILE_CLIENTS ".curvetun/clients"
560 #define FILE_SERVERS ".curvetun/servers"
561 #define FILE_PRIVKEY ".curvetun/priv.key"
562 #define FILE_PUBKEY ".curvetun/pub.key"
563 #define FILE_USERNAM ".curvetun/username"
564 #define GITVERSION "$_version"
569 #endif /* CONFIG_H */
575 echo "# This file is autogenerated by the configure script" > Config
578 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
579 echo "[!] pkg-config is not installed on your system or not in the PATH"
603 if [ "$MISSING_DEFS" == "1" ] ; then
604 echo "[!] Some libraries or header definitions are missing or too old."
605 echo " Thus certain tools will not be built (see below). Please"
606 echo " refer to the INSTALL file for the libraries needed to build"
607 echo " the complete netsniff-ng toolkit."
610 if [ "$MISSING_NACL" == "1" ] ; then
611 echo "[!] The NaCl crypto library is currently not present on your"
612 echo " system or could not be found. Either install it from your"
613 echo " distro or build it manually using 'make nacl' and make sure"
614 echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
615 echo " appropriately."
618 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
619 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
620 echo "[*] The following tools will be built: $TOOLS"
622 echo "[*] Looks good! All tools will be built!"
625 if [ -s config.log
] ; then
626 echo "[!] There were errors in the configure script. Please see"
627 echo " the file config.log for details."
630 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
631 echo "CONFIG_GEOIP=1" >> Config
633 echo "CONFIG_GEOIP=0" >> Config
636 echo "CONFIG_TOOLS=$TOOLS" >> Config
637 echo "CONFIG_OK=1" >> Config