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"
21 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
22 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
28 for tool
in $_tools ; do
31 m
=`expr match \"$TOOLS_NOBUILD\" '$1'`
32 if [ "$m" == "0" ] ; then
33 TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool"
36 *) TOOLS
="$TOOLS $tool" ;;
41 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
46 echo -n "[*] Checking pkg-config ... "
48 if [ "x$(which pkg-config)" == "x" ] ; then
58 echo -n "[*] Checking ccache ... "
60 if [ "x$(which ccache)" == "x" ] ; then
62 echo "CONFIG_CCACHE=" >> Config
65 echo "CONFIG_CCACHE=ccache" >> Config
71 echo -n "[*] Checking flex ... "
73 if [ "x$(which flex)" == "x" ] ; then
76 tools_remove
"trafgen"
85 echo -n "[*] Checking bison ... "
87 if [ "x$(which bison)" == "x" ] ; then
90 tools_remove
"trafgen"
99 echo -n "[*] Checking nacl ... "
101 cat > $TMPDIR/nacltest.c
<< EOF
102 #include "crypto_hash_sha512.h"
103 #include "crypto_verify_32.h"
104 #include "crypto_hash_sha512.h"
105 #include "crypto_box_curve25519xsalsa20poly1305.h"
106 #include "crypto_scalarmult_curve25519.h"
107 #include "crypto_auth_hmacsha512256.h"
112 if [ -z $NACL_INC_DIR ] ; then
113 NACL_INC_DIR
="/usr/include/nacl"
116 if [ -z $NACL_LIB_DIR ] ; then
117 NACL_LIB_DIR
="/usr/lib"
120 LDFLAGS
="-L $NACL_LIB_DIR"
121 CFLAGS
="-I $NACL_INC_DIR"
123 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> $TMPDIR/config.log
2>&1
124 if [ ! -x $TMPDIR/nacltest
] ; then
127 tools_remove
"curvetun"
130 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
131 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
137 echo -n "[*] Checking libnl ... "
139 cat > $TMPDIR/libnltest.c
<< EOF
140 #include <libnl3/netlink/genl/genl.h>
141 #include <libnl3/netlink/genl/family.h>
142 #include <libnl3/netlink/genl/ctrl.h>
143 #include <libnl3/netlink/msg.h>
144 #include <libnl3/netlink/attr.h>
145 #include <libnl3/netlink/version.h>
147 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
148 # error incompatible libnl version
153 struct nl_sock *sock = nl_socket_alloc();
154 struct nl_cache *nl_cache;
155 int ret = genl_connect(sock);
157 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
162 $
(pkg-config
--cflags libnl-3.0
) \
163 $
(pkg-config
--cflags libnl-genl-3.0
) \
164 -o $TMPDIR/libnltest \
165 $TMPDIR/libnltest.c \
166 $
(pkg-config
--libs libnl-3.0
) \
167 $
(pkg-config
--libs libnl-genl-3.0
) \
168 >> $TMPDIR/config.log
2>&1
169 if [ ! -x $TMPDIR/libnltest
] ; then
172 tools_remove
"trafgen"
173 tools_remove
"netsniff-ng"
181 echo -n "[*] Checking tpacket_v3 ... "
183 cat > $TMPDIR/tpacketv3test.c
<< EOF
185 #include <linux/if_packet.h>
189 struct tpacket3_hdr *hdr;
194 printf("%d\n", hdr->tp_status);
198 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> $TMPDIR/config.log
2>&1
199 if [ ! -x $TMPDIR/tpacketv3test
] ; then
202 tools_remove
"netsniff-ng"
210 echo -n "[*] Checking tpacket_v2 ... "
212 cat > $TMPDIR/tpacketv2test.c
<< EOF
214 #include <linux/if_packet.h>
218 struct tpacket2_hdr *hdr;
221 TP_STATUS_SEND_REQUEST,
227 printf("%d\n", hdr->tp_status);
231 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> $TMPDIR/config.log
2>&1
232 if [ ! -x $TMPDIR/tpacketv2test
] ; then
235 tools_remove
"netsniff-ng"
236 tools_remove
"trafgen"
245 echo -n "[*] Checking ncurses ... "
247 cat > $TMPDIR/ncursestest.c
<< EOF
252 WINDOW *screen = initscr();
257 $
(pkg-config
--cflags ncurses
) \
258 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
259 $
(pkg-config
--libs ncurses
) \
260 >> $TMPDIR/config.log
2>&1
261 if [ ! -x $TMPDIR/ncursestest
] ; then
264 tools_remove
"flowtop"
273 echo -n "[*] Checking libGeoIP ... "
275 cat > $TMPDIR/geoiptest.c
<< EOF
277 #include <GeoIPCity.h>
282 GEOIP_CITY_EDITION_REV1,
283 GEOIP_CITY_EDITION_REV1_V6,
284 GEOIP_COUNTRY_EDITION,
285 GEOIP_COUNTRY_EDITION_V6,
287 GEOIP_ASNUM_EDITION_V6,
289 GeoIP *geoip = GeoIP_new(0);
293 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> $TMPDIR/config.log
2>&1
294 if [ ! -x $TMPDIR/geoiptest
] ; then
296 echo "CONFIG_LIBGEOIP=0" >> Config
298 tools_remove
"astraceroute"
299 tools_remove
"flowtop"
302 echo "CONFIG_LIBGEOIP=1" >> Config
309 echo -n "[*] Checking libnetfilter-conntrack ... "
311 cat > $TMPDIR/nfcttest.c
<< EOF
312 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
313 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
314 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
315 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
319 struct nf_conntrack *ct;
320 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
324 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> $TMPDIR/config.log
2>&1
325 if [ ! -x $TMPDIR/nfcttest
] ; then
328 tools_remove
"libnetfilter-conntrack"
336 echo -n "[*] Checking libz ... "
338 cat > $TMPDIR/ztest.c
<< EOF
343 gzFile fp = gzopen("foo.gz", "rb");
347 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> $TMPDIR/config.log
2>&1
348 if [ ! -x $TMPDIR/ztest
] ; then
351 tools_remove
"netsniff-ng"
352 tools_remove
"astraceroute"
353 tools_remove
"flowtop"
361 echo -n "[*] Checking liburcu ... "
363 cat > $TMPDIR/urcutest.c
<< EOF
373 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> $TMPDIR/config.log
2>&1
374 if [ ! -x $TMPDIR/urcutest
] ; then
377 tools_remove
"flowtop"
385 echo -n "[*] Checking libpcap ... "
387 cat > $TMPDIR/pcaptest.c
<< EOF
392 struct bpf_program bpf;
393 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
397 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> $TMPDIR/config.log
2>&1
398 if [ ! -x $TMPDIR/pcaptest
] ; then
400 echo "CONFIG_LIBPCAP=0" >> Config
402 tools_remove
"mausezahn"
405 echo "CONFIG_LIBPCAP=1" >> Config
412 echo -n "[*] Checking hw timestamping ... "
414 cat > $TMPDIR/hwtstest.c
<< EOF
416 #include <arpa/inet.h>
417 #include <sys/ioctl.h>
418 #include <sys/types.h>
419 #include <sys/socket.h>
420 #include <linux/sockios.h>
421 #include <linux/net_tstamp.h>
422 #include <linux/if_packet.h>
423 #include <linux/if_ether.h>
424 #include <linux/if.h>
428 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
429 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
430 struct hwtstamp_config hwconfig;
433 memset(&hwconfig, 0, sizeof(hwconfig));
434 hwconfig.tx_type = HWTSTAMP_TX_OFF;
435 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
437 memset(&ifr, 0, sizeof(ifr));
438 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
439 ifr.ifr_data = &hwconfig;
441 ioctl(sock, SIOCSHWTSTAMP, &ifr);
442 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
447 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> $TMPDIR/config.log
2>&1
448 if [ ! -x $TMPDIR/hwtstest
] ; then
450 echo "CONFIG_HWTSTAMP=0" >> Config
453 echo "CONFIG_HWTSTAMP=1" >> Config
460 echo -n "[*] Checking libcli ... "
462 cat > $TMPDIR/clitest.c
<< EOF
467 struct cli_def *cli = cli_init();
471 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> $TMPDIR/config.log
2>&1
472 if [ ! -x $TMPDIR/clitest
] ; then
475 tools_remove
"mausezahn"
483 echo -n "[*] Checking libnet ... "
485 cat > $TMPDIR/nettest.c
<< EOF
490 char err_buf[LIBNET_ERRBUF_SIZE];
491 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
495 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> $TMPDIR/config.log
2>&1
496 if [ ! -x $TMPDIR/nettest
] ; then
499 tools_remove
"mausezahn"
507 local _version
="`git describe --always`"
508 local _have_libpcap
=""
509 local _have_libgeoip
=""
512 echo "[*] Generating config.h ... "
514 if [ "$HAVE_LIBPCAP" == "1" ] ; then
515 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
518 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
519 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
522 if [ "$HAVE_LIBGEOIP" == "1" ] ; then
523 _have_libgeoip
="#define HAVE_GEOIP 1"
526 cat > config.h
<< EOF
529 #define FILE_CLIENTS ".curvetun/clients"
530 #define FILE_SERVERS ".curvetun/servers"
531 #define FILE_PRIVKEY ".curvetun/priv.key"
532 #define FILE_PUBKEY ".curvetun/pub.key"
533 #define FILE_USERNAM ".curvetun/username"
534 #define GITVERSION "$_version"
538 #endif /* CONFIG_H */
542 echo "# This file is autogenerated by the configure script" > Config
545 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
546 echo "[!] pkg-config is not installed on your system or not in the PATH"
569 if [ "$MISSING_DEFS" == "1" ] ; then
570 echo "[!] Some libraries or header definitions are missing or too old."
571 echo " Thus certain tools will not be built (see below). Please"
572 echo " refer to the INSTALL file for the libraries needed to build"
573 echo " the complete netsniff-ng toolkit."
576 if [ "$MISSING_NACL" == "1" ] ; then
577 echo "[!] The NaCl crypto library is currently not present on your"
578 echo " system or could not be found. Either install it from your"
579 echo " distro or build it manually using 'make nacl' and make sure"
580 echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
581 echo " appropriately."
584 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
585 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
586 echo "[*] The following tools will be built: $TOOLS"
588 echo "[*] Looks good! All tools will be built!"
591 echo "CONFIG_TOOLS=$TOOLS" >> Config
592 echo "CONFIG_OK=1" >> Config