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 if [ -z $NACL_LIB ] ; then
126 LDFLAGS
="-L $NACL_LIB_DIR"
127 CFLAGS
="-I $NACL_INC_DIR"
129 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> config.log
2>&1
130 if [ ! -x $TMPDIR/nacltest
] ; then
133 tools_remove
"curvetun"
136 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
137 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
138 echo "CONFIG_NACL_LIB:=$NACL_LIB" >> Config
144 echo -n "[*] Checking libnl ... "
146 cat > $TMPDIR/libnltest.c
<< EOF
147 #include <libnl3/netlink/genl/genl.h>
148 #include <libnl3/netlink/genl/family.h>
149 #include <libnl3/netlink/genl/ctrl.h>
150 #include <libnl3/netlink/msg.h>
151 #include <libnl3/netlink/attr.h>
152 #include <libnl3/netlink/version.h>
154 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
155 # error incompatible libnl version
160 struct nl_sock *sock = nl_socket_alloc();
161 struct nl_cache *nl_cache;
162 int ret = genl_connect(sock);
164 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
169 $
(pkg-config
--cflags libnl-3.0
2>> config.log
) \
170 $
(pkg-config
--cflags libnl-genl-3.0
2>> config.log
) \
171 -o $TMPDIR/libnltest \
172 $TMPDIR/libnltest.c \
173 $
(pkg-config
--libs libnl-3.0
2>> config.log
) \
174 $
(pkg-config
--libs libnl-genl-3.0
2>> config.log
) \
176 if [ ! -x $TMPDIR/libnltest
] ; then
179 tools_remove
"trafgen"
180 tools_remove
"netsniff-ng"
188 echo -n "[*] Checking tpacket_v3 ... "
190 cat > $TMPDIR/tpacketv3test.c
<< EOF
192 #include <linux/if_packet.h>
196 struct tpacket3_hdr *hdr;
201 printf("%d\n", hdr->tp_status);
205 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> config.log
2>&1
206 if [ ! -x $TMPDIR/tpacketv3test
] ; then
209 tools_remove
"netsniff-ng"
218 echo -n "[*] Checking tpacket_v2 ... "
220 cat > $TMPDIR/tpacketv2test.c
<< EOF
222 #include <linux/if_packet.h>
226 struct tpacket2_hdr *hdr;
229 TP_STATUS_SEND_REQUEST,
235 printf("%d\n", hdr->tp_status);
239 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> config.log
2>&1
240 if [ ! -x $TMPDIR/tpacketv2test
] ; then
243 tools_remove
"netsniff-ng"
244 tools_remove
"trafgen"
253 echo -n "[*] Checking ncurses ... "
255 cat > $TMPDIR/ncursestest.c
<< EOF
260 WINDOW *screen = initscr();
265 $
(pkg-config
--cflags ncurses
2>> config.log
) \
266 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
267 $
(pkg-config
--libs ncurses
2>> config.log \
268 ||
echo '-lncurses' ) \
270 if [ ! -x $TMPDIR/ncursestest
] ; then
273 tools_remove
"flowtop"
282 echo -n "[*] Checking libGeoIP ... "
284 cat > $TMPDIR/geoiptest.c
<< EOF
286 #include <GeoIPCity.h>
291 GEOIP_CITY_EDITION_REV1,
292 GEOIP_CITY_EDITION_REV1_V6,
293 GEOIP_COUNTRY_EDITION,
294 GEOIP_COUNTRY_EDITION_V6,
296 GEOIP_ASNUM_EDITION_V6,
298 GeoIP *geoip = GeoIP_new(0);
302 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> config.log
2>&1
303 if [ ! -x $TMPDIR/geoiptest
] ; then
314 echo -n "[*] Checking libnetfilter-conntrack ... "
316 cat > $TMPDIR/nfcttest.c
<< EOF
317 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
318 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
319 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
320 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
324 struct nf_conntrack *ct;
325 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
329 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> config.log
2>&1
330 if [ ! -x $TMPDIR/nfcttest
] ; then
333 tools_remove
"flowtop"
341 echo -n "[*] Checking libz ... "
343 cat > $TMPDIR/ztest.c
<< EOF
348 gzFile fp = gzopen("foo.gz", "rb");
352 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> config.log
2>&1
353 if [ ! -x $TMPDIR/ztest
] ; then
355 echo "CONFIG_LIBZ=0" >> Config
357 tools_remove
"astraceroute"
358 tools_remove
"flowtop"
361 echo "CONFIG_LIBZ=1" >> Config
368 echo -n "[*] Checking liburcu ... "
370 cat > $TMPDIR/urcutest.c
<< EOF
380 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> config.log
2>&1
381 if [ ! -x $TMPDIR/urcutest
] ; then
384 tools_remove
"flowtop"
392 echo -n "[*] Checking libpcap ... "
394 cat > $TMPDIR/pcaptest.c
<< EOF
399 struct bpf_program bpf;
400 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
404 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> config.log
2>&1
405 if [ ! -x $TMPDIR/pcaptest
] ; then
407 echo "CONFIG_LIBPCAP=0" >> Config
409 tools_remove
"mausezahn"
412 echo "CONFIG_LIBPCAP=1" >> Config
419 echo -n "[*] Checking hw timestamping ... "
421 cat > $TMPDIR/hwtstest.c
<< EOF
423 #include <arpa/inet.h>
424 #include <sys/ioctl.h>
425 #include <sys/types.h>
426 #include <sys/socket.h>
427 #include <linux/sockios.h>
428 #include <linux/net_tstamp.h>
429 #include <linux/if_packet.h>
430 #include <linux/if_ether.h>
431 #include <linux/if.h>
435 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
436 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
437 struct hwtstamp_config hwconfig;
440 memset(&hwconfig, 0, sizeof(hwconfig));
441 hwconfig.tx_type = HWTSTAMP_TX_OFF;
442 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
444 memset(&ifr, 0, sizeof(ifr));
445 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
446 ifr.ifr_data = &hwconfig;
448 ioctl(sock, SIOCSHWTSTAMP, &ifr);
449 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
454 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> config.log
2>&1
455 if [ ! -x $TMPDIR/hwtstest
] ; then
457 echo "CONFIG_HWTSTAMP=0" >> Config
460 echo "CONFIG_HWTSTAMP=1" >> Config
467 echo -n "[*] Checking libcli ... "
469 cat > $TMPDIR/clitest.c
<< EOF
470 #include <sys/time.h>
475 struct cli_def *cli = cli_init();
479 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> config.log
2>&1
480 if [ ! -x $TMPDIR/clitest
] ; then
483 tools_remove
"mausezahn"
491 echo -n "[*] Checking libnet ... "
493 cat > $TMPDIR/nettest.c
<< EOF
498 char err_buf[LIBNET_ERRBUF_SIZE];
499 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
503 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> config.log
2>&1
504 if [ ! -x $TMPDIR/nettest
] ; then
507 tools_remove
"mausezahn"
513 gen_version_appendix
()
517 git rev-parse
> /dev
/null
2>&1
518 if [ "$?" == "0" ] ; then
519 if [ ! "`git describe --always`" == \
520 "`git describe --abbrev=0 --tags`" ] ; then
525 echo "CONFIG_RC=\"$_appendix\"" >> Config
531 local _have_libpcap
=""
532 local _have_libgeoip
=""
537 echo "[*] Generating config.h ..."
539 git rev-parse
> /dev
/null
2>&1
540 if [ "$?" == "0" ] ; then
541 _version
="`git describe --always`"
546 if [ "$HAVE_LIBPCAP" == "1" ] ; then
547 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
550 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
551 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
554 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
555 _have_libgeoip
="#define HAVE_GEOIP 1"
558 if [ "$HAVE_LIBZ" == "1" ] ; then
559 _have_libz
="#define HAVE_LIBZ 1"
562 if [ "$HAVE_TPACKET3" == "1" ] ; then
563 _have_tp3
="#define HAVE_TPACKET3 1"
566 cat > config.h
<< EOF
569 #define FILE_CLIENTS ".curvetun/clients"
570 #define FILE_SERVERS ".curvetun/servers"
571 #define FILE_PRIVKEY ".curvetun/priv.key"
572 #define FILE_PUBKEY ".curvetun/pub.key"
573 #define FILE_USERNAM ".curvetun/username"
574 #define GITVERSION "$_version"
580 #endif /* CONFIG_H */
586 echo "# This file is autogenerated by the configure script" > Config
589 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
590 echo "[!] pkg-config is not installed on your system or not in the PATH"
614 if [ "$MISSING_DEFS" == "1" ] ; then
615 echo "[!] Some libraries or header definitions are missing or too old. Thus"
616 echo " certain tools will not be built (see below). Please refer to the"
617 echo " INSTALL file for the libraries needed to build the complete"
618 echo " netsniff-ng toolkit."
621 if [ "$MISSING_NACL" == "1" ] ; then
622 echo "[!] The NaCl crypto library is currently not present on your system or"
623 echo " could not be found. Either install it from your distro or build it"
624 echo " manually using 'make nacl' and make sure that the NACL_INC_DIR and"
625 echo " NACL_LIB_DIR environment variables are set appropriately."
628 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
629 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
630 echo "[*] The following tools will be built: $TOOLS"
632 echo "[*] Looks good! All tools will be built!"
635 if [ -s config.log
] ; then
636 echo "[!] There were errors in the configure script. Please check the file"
637 echo " config.log for details."
640 if [ "$HAVE_LIBGEOIP" == "1" -a "$HAVE_LIBZ" == "1" ] ; then
641 echo "CONFIG_GEOIP=1" >> Config
643 echo "CONFIG_GEOIP=0" >> Config
646 echo "CONFIG_TOOLS=$TOOLS" >> Config
647 echo "CONFIG_OK=1" >> Config