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"
23 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
24 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
31 for tool
in $_tools ; do
36 *) TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool" ;;
38 *) TOOLS
="$TOOLS $tool" ;;
43 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
48 echo -n "[*] Checking pkg-config ... "
50 if [ "x$(which pkg-config 2>> config.log)" == "x" ] ; then
60 echo -n "[*] Checking flex ... "
62 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
65 tools_remove
"trafgen"
74 echo -n "[*] Checking bison ... "
76 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
79 tools_remove
"trafgen"
88 echo -n "[*] Checking nacl ... "
90 cat > $TMPDIR/nacltest.c
<< EOF
91 #include "crypto_hash_sha512.h"
92 #include "crypto_verify_32.h"
93 #include "crypto_hash_sha512.h"
94 #include "crypto_box_curve25519xsalsa20poly1305.h"
95 #include "crypto_scalarmult_curve25519.h"
96 #include "crypto_auth_hmacsha512256.h"
101 if [ -z $NACL_INC_DIR ] ; then
102 NACL_INC_DIR
="/usr/include/nacl"
105 if [ -z $NACL_LIB_DIR ] ; then
106 NACL_LIB_DIR
="/usr/lib"
109 if [ -z $NACL_LIB ] ; then
113 LDFLAGS
="-L $NACL_LIB_DIR"
114 CFLAGS
="-I $NACL_INC_DIR"
116 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
117 if [ ! -x $TMPDIR/nacltest
] ; then
120 tools_remove
"curvetun"
123 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
124 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
125 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
131 echo -n "[*] Checking libnl ... "
133 cat > $TMPDIR/libnltest.c
<< EOF
134 #include <libnl3/netlink/genl/genl.h>
135 #include <libnl3/netlink/genl/family.h>
136 #include <libnl3/netlink/genl/ctrl.h>
137 #include <libnl3/netlink/msg.h>
138 #include <libnl3/netlink/attr.h>
139 #include <libnl3/netlink/version.h>
141 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
142 # error incompatible libnl version
147 struct nl_sock *sock = nl_socket_alloc();
148 struct nl_cache *nl_cache;
149 int ret = genl_connect(sock);
151 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
156 $
(pkg-config
--cflags libnl-3.0
2>> config.log
) \
157 $
(pkg-config
--cflags libnl-genl-3.0
2>> config.log
) \
158 -o $TMPDIR/libnltest \
159 $TMPDIR/libnltest.c \
160 $
(pkg-config
--libs libnl-3.0
2>> config.log
) \
161 $
(pkg-config
--libs libnl-genl-3.0
2>> config.log
) \
163 if [ ! -x $TMPDIR/libnltest
] ; then
166 tools_remove
"trafgen"
167 tools_remove
"netsniff-ng"
175 echo -n "[*] Checking tpacket_v3 ... "
177 cat > $TMPDIR/tpacketv3test.c
<< EOF
179 #include <linux/if_packet.h>
183 struct tpacket3_hdr *hdr;
188 printf("%d\n", hdr->tp_status);
192 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
193 if [ ! -x $TMPDIR/tpacketv3test
] ; then
204 echo -n "[*] Checking tpacket_v2 ... "
206 cat > $TMPDIR/tpacketv2test.c
<< EOF
208 #include <linux/if_packet.h>
212 struct tpacket2_hdr *hdr;
215 TP_STATUS_SEND_REQUEST,
221 printf("%d\n", hdr->tp_status);
225 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
226 if [ ! -x $TMPDIR/tpacketv2test
] ; then
229 tools_remove
"netsniff-ng"
230 tools_remove
"trafgen"
239 echo -n "[*] Checking ncurses ... "
241 cat > $TMPDIR/ncursestest.c
<< EOF
246 WINDOW *screen = initscr();
251 $
(pkg-config
--cflags ncurses
2>> config.log
) \
252 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
253 $
(pkg-config
--libs ncurses
2>> config.log \
254 ||
echo '-lncurses' ) \
256 if [ ! -x $TMPDIR/ncursestest
] ; then
259 tools_remove
"flowtop"
268 echo -n "[*] Checking libGeoIP ... "
270 cat > $TMPDIR/geoiptest.c
<< EOF
272 #include <GeoIPCity.h>
277 GEOIP_CITY_EDITION_REV1,
278 GEOIP_CITY_EDITION_REV1_V6,
279 GEOIP_COUNTRY_EDITION,
280 GEOIP_COUNTRY_EDITION_V6,
282 GEOIP_ASNUM_EDITION_V6,
284 GeoIP *geoip = GeoIP_new(0);
288 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
289 if [ ! -x $TMPDIR/geoiptest
] ; then
300 echo -n "[*] Checking libnetfilter-conntrack ... "
302 cat > $TMPDIR/nfcttest.c
<< EOF
303 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
304 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
305 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
306 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
310 struct nf_conntrack *ct;
311 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
315 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> config.log
2>&1
316 if [ ! -x $TMPDIR/nfcttest
] ; then
319 tools_remove
"flowtop"
327 echo -n "[*] Checking libz ... "
329 cat > $TMPDIR/ztest.c
<< EOF
334 gzFile fp = gzopen("foo.gz", "rb");
338 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
339 if [ ! -x $TMPDIR/ztest
] ; then
341 echo "CONFIG_LIBZ=0" >> Config
343 tools_remove
"astraceroute"
344 tools_remove
"flowtop"
347 echo "CONFIG_LIBZ=1" >> Config
354 echo -n "[*] Checking liburcu ... "
356 cat > $TMPDIR/urcutest.c
<< EOF
366 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
367 if [ ! -x $TMPDIR/urcutest
] ; then
370 tools_remove
"flowtop"
378 echo -n "[*] Checking libpcap ... "
380 cat > $TMPDIR/pcaptest.c
<< EOF
385 struct bpf_program bpf;
386 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
390 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
391 if [ ! -x $TMPDIR/pcaptest
] ; then
393 echo "CONFIG_LIBPCAP=0" >> Config
395 tools_remove
"mausezahn"
398 echo "CONFIG_LIBPCAP=1" >> Config
405 echo -n "[*] Checking hw timestamping ... "
407 cat > $TMPDIR/hwtstest.c
<< EOF
409 #include <arpa/inet.h>
410 #include <sys/ioctl.h>
411 #include <sys/types.h>
412 #include <sys/socket.h>
413 #include <linux/sockios.h>
414 #include <linux/net_tstamp.h>
415 #include <linux/if_packet.h>
416 #include <linux/if_ether.h>
417 #include <linux/if.h>
421 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
422 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
423 struct hwtstamp_config hwconfig;
426 memset(&hwconfig, 0, sizeof(hwconfig));
427 hwconfig.tx_type = HWTSTAMP_TX_OFF;
428 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
430 memset(&ifr, 0, sizeof(ifr));
431 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
432 ifr.ifr_data = &hwconfig;
434 ioctl(sock, SIOCSHWTSTAMP, &ifr);
435 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
440 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
441 if [ ! -x $TMPDIR/hwtstest
] ; then
443 echo "CONFIG_HWTSTAMP=0" >> Config
446 echo "CONFIG_HWTSTAMP=1" >> Config
453 echo -n "[*] Checking libcli ... "
455 cat > $TMPDIR/clitest.c
<< EOF
456 #include <sys/time.h>
461 struct cli_def *cli = cli_init();
465 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
466 if [ ! -x $TMPDIR/clitest
] ; then
469 tools_remove
"mausezahn"
477 echo -n "[*] Checking libnet ... "
479 cat > $TMPDIR/nettest.c
<< EOF
484 char err_buf[LIBNET_ERRBUF_SIZE];
485 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
489 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
490 if [ ! -x $TMPDIR/nettest
] ; then
493 tools_remove
"mausezahn"
499 gen_version_appendix
()
503 git rev-parse
> /dev
/null
2>&1
504 if [ "$?" == "0" ] ; then
505 if [ ! "`git describe --always`" == \
506 "`git describe --abbrev=0 --tags`" ] ; then
511 echo "CONFIG_RC=\"$_appendix\"" >> Config
517 local _have_libpcap
=""
518 local _have_libgeoip
=""
523 echo "[*] Generating config.h ..."
525 git rev-parse
> /dev
/null
2>&1
526 if [ "$?" == "0" ] ; then
527 _version
="`git describe --always`"
532 if [ "$HAVE_LIBPCAP" == "1" ] ; then
533 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
536 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
537 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
540 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
541 _have_libgeoip
="#define HAVE_GEOIP 1"
544 if [ "$HAVE_LIBZ" == "1" ] ; then
545 _have_libz
="#define HAVE_LIBZ 1"
548 if [ "$HAVE_TPACKET3" == "1" ] ; then
549 _have_tp3
="#define HAVE_TPACKET3 1"
552 cat > config.h
<< EOF
555 #define FILE_CLIENTS ".curvetun/clients"
556 #define FILE_SERVERS ".curvetun/servers"
557 #define FILE_PRIVKEY ".curvetun/priv.key"
558 #define FILE_PUBKEY ".curvetun/pub.key"
559 #define FILE_USERNAM ".curvetun/username"
560 #define GITVERSION "$_version"
566 #endif /* CONFIG_H */
572 echo "# This file is autogenerated by the configure script" > Config
575 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
576 echo "[!] pkg-config is not installed on your system or not in the PATH"
599 if [ "$MISSING_DEFS" == "1" ] ; then
600 echo "[!] Some libraries or header definitions are missing or too old. Thus"
601 echo " certain tools will not be built (see below). Please refer to the"
602 echo " INSTALL file for the libraries needed to build the complete"
603 echo " netsniff-ng toolkit."
606 if [ "$MISSING_NACL" == "1" ] ; then
607 echo "[!] The NaCl crypto library is currently not present on your system or"
608 echo " could not be found. Either install it from your distro or build it"
609 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
610 echo " NACL_LIB_DIR environment variables are set appropriately."
613 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
614 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
615 echo "[*] The following tools will be built: $TOOLS"
617 echo "[*] Looks good! All tools will be built!"
620 if [ -s config.log
] ; then
621 echo "[!] There were errors in the configure script. Please check the file"
622 echo " config.log for details."
625 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
626 echo "CONFIG_GEOIP=1" >> Config
628 echo "CONFIG_GEOIP=0" >> Config
631 echo "CONFIG_TOOLS=$TOOLS" >> Config
632 echo "CONFIG_OK=1" >> Config