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 ccache ... "
62 if [ "x$(which ccache 2>> config.log)" == "x" ] ; then
64 echo "CONFIG_CCACHE=" >> Config
67 echo "CONFIG_CCACHE=ccache" >> Config
73 echo -n "[*] Checking flex ... "
75 if [ "x$(which flex 2>> config.log)" == "x" ] ; then
78 tools_remove
"trafgen"
87 echo -n "[*] Checking bison ... "
89 if [ "x$(which bison 2>> config.log)" == "x" ] ; then
92 tools_remove
"trafgen"
101 echo -n "[*] Checking nacl ... "
103 cat > $TMPDIR/nacltest.c
<< EOF
104 #include "crypto_hash_sha512.h"
105 #include "crypto_verify_32.h"
106 #include "crypto_hash_sha512.h"
107 #include "crypto_box_curve25519xsalsa20poly1305.h"
108 #include "crypto_scalarmult_curve25519.h"
109 #include "crypto_auth_hmacsha512256.h"
114 if [ -z $NACL_INC_DIR ] ; then
115 NACL_INC_DIR
="/usr/include/nacl"
118 if [ -z $NACL_LIB_DIR ] ; then
119 NACL_LIB_DIR
="/usr/lib"
122 LDFLAGS
="-L $NACL_LIB_DIR"
123 CFLAGS
="-I $NACL_INC_DIR"
125 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
126 if [ ! -x $TMPDIR/nacltest
] ; then
129 tools_remove
"curvetun"
132 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
133 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
139 echo -n "[*] Checking libnl ... "
141 cat > $TMPDIR/libnltest.c
<< EOF
142 #include <libnl3/netlink/genl/genl.h>
143 #include <libnl3/netlink/genl/family.h>
144 #include <libnl3/netlink/genl/ctrl.h>
145 #include <libnl3/netlink/msg.h>
146 #include <libnl3/netlink/attr.h>
147 #include <libnl3/netlink/version.h>
149 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
150 # error incompatible libnl version
155 struct nl_sock *sock = nl_socket_alloc();
156 struct nl_cache *nl_cache;
157 int ret = genl_connect(sock);
159 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
164 $
(pkg-config
--cflags libnl-3.0
2>> config.log
) \
165 $
(pkg-config
--cflags libnl-genl-3.0
2>> config.log
) \
166 -o $TMPDIR/libnltest \
167 $TMPDIR/libnltest.c \
168 $
(pkg-config
--libs libnl-3.0
2>> config.log
) \
169 $
(pkg-config
--libs libnl-genl-3.0
2>> config.log
) \
171 if [ ! -x $TMPDIR/libnltest
] ; then
174 tools_remove
"trafgen"
175 tools_remove
"netsniff-ng"
183 echo -n "[*] Checking tpacket_v3 ... "
185 cat > $TMPDIR/tpacketv3test.c
<< EOF
187 #include <linux/if_packet.h>
191 struct tpacket3_hdr *hdr;
196 printf("%d\n", hdr->tp_status);
200 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
201 if [ ! -x $TMPDIR/tpacketv3test
] ; then
204 tools_remove
"netsniff-ng"
213 echo -n "[*] Checking tpacket_v2 ... "
215 cat > $TMPDIR/tpacketv2test.c
<< EOF
217 #include <linux/if_packet.h>
221 struct tpacket2_hdr *hdr;
224 TP_STATUS_SEND_REQUEST,
230 printf("%d\n", hdr->tp_status);
234 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
235 if [ ! -x $TMPDIR/tpacketv2test
] ; then
238 tools_remove
"netsniff-ng"
239 tools_remove
"trafgen"
248 echo -n "[*] Checking ncurses ... "
250 cat > $TMPDIR/ncursestest.c
<< EOF
255 WINDOW *screen = initscr();
260 $
(pkg-config
--cflags ncurses
2>> config.log
) \
261 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
262 $
(pkg-config
--libs ncurses
2>> config.log
) \
264 if [ ! -x $TMPDIR/ncursestest
] ; then
267 tools_remove
"flowtop"
276 echo -n "[*] Checking libGeoIP ... "
278 cat > $TMPDIR/geoiptest.c
<< EOF
280 #include <GeoIPCity.h>
285 GEOIP_CITY_EDITION_REV1,
286 GEOIP_CITY_EDITION_REV1_V6,
287 GEOIP_COUNTRY_EDITION,
288 GEOIP_COUNTRY_EDITION_V6,
290 GEOIP_ASNUM_EDITION_V6,
292 GeoIP *geoip = GeoIP_new(0);
296 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
297 if [ ! -x $TMPDIR/geoiptest
] ; then
299 echo "CONFIG_LIBGEOIP=0" >> Config
301 tools_remove
"astraceroute"
302 tools_remove
"flowtop"
305 echo "CONFIG_LIBGEOIP=1" >> Config
312 echo -n "[*] Checking libnetfilter-conntrack ... "
314 cat > $TMPDIR/nfcttest.c
<< EOF
315 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
316 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
317 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
318 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
322 struct nf_conntrack *ct;
323 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
327 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> config.log
2>&1
328 if [ ! -x $TMPDIR/nfcttest
] ; then
331 tools_remove
"flowtop"
339 echo -n "[*] Checking libz ... "
341 cat > $TMPDIR/ztest.c
<< EOF
346 gzFile fp = gzopen("foo.gz", "rb");
350 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
351 if [ ! -x $TMPDIR/ztest
] ; then
353 echo "CONFIG_LIBZ=0" >> Config
355 tools_remove
"astraceroute"
356 tools_remove
"flowtop"
359 echo "CONFIG_LIBZ=1" >> Config
366 echo -n "[*] Checking liburcu ... "
368 cat > $TMPDIR/urcutest.c
<< EOF
378 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
379 if [ ! -x $TMPDIR/urcutest
] ; then
382 tools_remove
"flowtop"
390 echo -n "[*] Checking libpcap ... "
392 cat > $TMPDIR/pcaptest.c
<< EOF
397 struct bpf_program bpf;
398 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
402 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
403 if [ ! -x $TMPDIR/pcaptest
] ; then
405 echo "CONFIG_LIBPCAP=0" >> Config
407 tools_remove
"mausezahn"
410 echo "CONFIG_LIBPCAP=1" >> Config
417 echo -n "[*] Checking hw timestamping ... "
419 cat > $TMPDIR/hwtstest.c
<< EOF
421 #include <arpa/inet.h>
422 #include <sys/ioctl.h>
423 #include <sys/types.h>
424 #include <sys/socket.h>
425 #include <linux/sockios.h>
426 #include <linux/net_tstamp.h>
427 #include <linux/if_packet.h>
428 #include <linux/if_ether.h>
429 #include <linux/if.h>
433 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
434 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
435 struct hwtstamp_config hwconfig;
438 memset(&hwconfig, 0, sizeof(hwconfig));
439 hwconfig.tx_type = HWTSTAMP_TX_OFF;
440 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
442 memset(&ifr, 0, sizeof(ifr));
443 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
444 ifr.ifr_data = &hwconfig;
446 ioctl(sock, SIOCSHWTSTAMP, &ifr);
447 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
452 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
453 if [ ! -x $TMPDIR/hwtstest
] ; then
455 echo "CONFIG_HWTSTAMP=0" >> Config
458 echo "CONFIG_HWTSTAMP=1" >> Config
465 echo -n "[*] Checking libcli ... "
467 cat > $TMPDIR/clitest.c
<< EOF
468 #include <sys/time.h>
473 struct cli_def *cli = cli_init();
477 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
478 if [ ! -x $TMPDIR/clitest
] ; then
481 tools_remove
"mausezahn"
489 echo -n "[*] Checking libnet ... "
491 cat > $TMPDIR/nettest.c
<< EOF
496 char err_buf[LIBNET_ERRBUF_SIZE];
497 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
501 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
502 if [ ! -x $TMPDIR/nettest
] ; then
505 tools_remove
"mausezahn"
511 gen_version_appendix
()
515 git rev-parse
> /dev
/null
2>&1
516 if [ "$?" == "0" ] ; then
517 if [ ! "`git describe --always`" == \
518 "`git describe --abbrev=0 --tags`" ] ; then
523 echo "CONFIG_RC=\"$_appendix\"" >> Config
529 local _have_libpcap
=""
530 local _have_libgeoip
=""
535 echo "[*] Generating config.h ... "
537 git rev-parse
> /dev
/null
2>&1
538 if [ "$?" == "0" ] ; then
539 _version
="`git describe --always`"
544 if [ "$HAVE_LIBPCAP" == "1" ] ; then
545 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
548 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
549 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
552 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
553 _have_libgeoip
="#define HAVE_GEOIP 1"
556 if [ "$HAVE_LIBZ" == "1" ] ; then
557 _have_libz
="#define HAVE_LIBZ 1"
560 if [ "$HAVE_TPACKET3" == "1" ] ; then
561 _have_tp3
="#define HAVE_TPACKET3 1"
564 cat > config.h
<< EOF
567 #define FILE_CLIENTS ".curvetun/clients"
568 #define FILE_SERVERS ".curvetun/servers"
569 #define FILE_PRIVKEY ".curvetun/priv.key"
570 #define FILE_PUBKEY ".curvetun/pub.key"
571 #define FILE_USERNAM ".curvetun/username"
572 #define GITVERSION "$_version"
578 #endif /* CONFIG_H */
584 echo "# This file is autogenerated by the configure script" > Config
587 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
588 echo "[!] pkg-config is not installed on your system or not in the PATH"
612 if [ "$MISSING_DEFS" == "1" ] ; then
613 echo "[!] Some libraries or header definitions are missing or too old."
614 echo " Thus certain tools will not be built (see below). Please"
615 echo " refer to the INSTALL file for the libraries needed to build"
616 echo " the complete netsniff-ng toolkit."
619 if [ "$MISSING_NACL" == "1" ] ; then
620 echo "[!] The NaCl crypto library is currently not present on your"
621 echo " system or could not be found. Either install it from your"
622 echo " distro or build it manually using 'make nacl' and make sure"
623 echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
624 echo " appropriately."
627 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
628 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
629 echo "[*] The following tools will be built: $TOOLS"
631 echo "[*] Looks good! All tools will be built!"
634 if [ -s config.log
] ; then
635 echo "[!] There were errors in the configure script. Please see"
636 echo " the file config.log for details."
639 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
640 echo "CONFIG_GEOIP=1" >> Config
642 echo "CONFIG_GEOIP=0" >> Config
645 echo "CONFIG_TOOLS=$TOOLS" >> Config
646 echo "CONFIG_OK=1" >> Config