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"
20 TMPDIR
=$
(mktemp
-d config.XXXXXX
)
21 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
27 for tool
in $_tools ; do
30 m
=`expr match \"$TOOLS_NOBUILD\" '$1'`
31 if [ "$m" == "0" ] ; then
32 TOOLS_NOBUILD
="$TOOLS_NOBUILD $tool"
35 *) TOOLS
="$TOOLS $tool" ;;
40 TOOLS_NOBUILD
=${TOOLS_NOBUILD# }
45 echo -n "[*] Checking pkg-config ... "
47 if [ "x$(which pkg-config)" == "x" ] ; then
57 echo -n "[*] Checking ccache ... "
59 if [ "x$(which ccache)" == "x" ] ; then
61 echo "CONFIG_CCACHE=" >> Config
64 echo "CONFIG_CCACHE=ccache" >> Config
70 echo -n "[*] Checking nacl ... "
72 cat > $TMPDIR/nacltest.c
<< EOF
73 #include "crypto_hash_sha512.h"
74 #include "crypto_verify_32.h"
75 #include "crypto_hash_sha512.h"
76 #include "crypto_box_curve25519xsalsa20poly1305.h"
77 #include "crypto_scalarmult_curve25519.h"
78 #include "crypto_auth_hmacsha512256.h"
83 if [ -z $NACL_INC_DIR ] ; then
84 NACL_INC_DIR
="/usr/include/nacl"
87 if [ -z $NACL_LIB_DIR ] ; then
88 NACL_LIB_DIR
="/usr/lib"
91 LDFLAGS
="-L $NACL_LIB_DIR"
92 CFLAGS
="-I $NACL_INC_DIR"
94 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> $TMPDIR/config.log
2>&1
95 if [ ! -x $TMPDIR/nacltest
] ; then
98 tools_remove
"curvetun"
101 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
102 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
108 echo -n "[*] Checking libnl ... "
110 cat > $TMPDIR/libnltest.c
<< EOF
111 #include <libnl3/netlink/genl/genl.h>
112 #include <libnl3/netlink/genl/family.h>
113 #include <libnl3/netlink/genl/ctrl.h>
114 #include <libnl3/netlink/msg.h>
115 #include <libnl3/netlink/attr.h>
116 #include <libnl3/netlink/version.h>
118 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
119 # error incompatible libnl version
124 struct nl_sock *sock = nl_socket_alloc();
125 struct nl_cache *nl_cache;
126 int ret = genl_connect(sock);
128 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
133 $
(pkg-config
--cflags libnl-3.0
) \
134 $
(pkg-config
--cflags libnl-genl-3.0
) \
135 -o $TMPDIR/libnltest \
136 $TMPDIR/libnltest.c \
137 $
(pkg-config
--libs libnl-3.0
) \
138 $
(pkg-config
--libs libnl-genl-3.0
) \
139 >> $TMPDIR/config.log
2>&1
140 if [ ! -x $TMPDIR/libnltest
] ; then
143 tools_remove
"trafgen"
144 tools_remove
"netsniff-ng"
152 echo -n "[*] Checking tpacket_v3 ... "
154 cat > $TMPDIR/tpacketv3test.c
<< EOF
156 #include <linux/if_packet.h>
160 struct tpacket3_hdr *hdr;
165 printf("%d\n", hdr->tp_status);
169 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> $TMPDIR/config.log
2>&1
170 if [ ! -x $TMPDIR/tpacketv3test
] ; then
173 tools_remove
"netsniff-ng"
181 echo -n "[*] Checking tpacket_v2 ... "
183 cat > $TMPDIR/tpacketv2test.c
<< EOF
185 #include <linux/if_packet.h>
189 struct tpacket2_hdr *hdr;
192 TP_STATUS_SEND_REQUEST,
198 printf("%d\n", hdr->tp_status);
202 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> $TMPDIR/config.log
2>&1
203 if [ ! -x $TMPDIR/tpacketv2test
] ; then
206 tools_remove
"netsniff-ng"
207 tools_remove
"trafgen"
216 echo -n "[*] Checking ncurses ... "
218 cat > $TMPDIR/ncursestest.c
<< EOF
223 WINDOW *screen = initscr();
228 $
(pkg-config
--cflags ncurses
) \
229 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
230 $
(pkg-config
--libs ncurses
) \
231 >> $TMPDIR/config.log
2>&1
232 if [ ! -x $TMPDIR/ncursestest
] ; then
235 tools_remove
"flowtop"
244 echo -n "[*] Checking libGeoIP ... "
246 cat > $TMPDIR/geoiptest.c
<< EOF
248 #include <GeoIPCity.h>
253 GEOIP_CITY_EDITION_REV1,
254 GEOIP_CITY_EDITION_REV1_V6,
255 GEOIP_COUNTRY_EDITION,
256 GEOIP_COUNTRY_EDITION_V6,
258 GEOIP_ASNUM_EDITION_V6,
260 GeoIP *geoip = GeoIP_new(0);
264 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> $TMPDIR/config.log
2>&1
265 if [ ! -x $TMPDIR/geoiptest
] ; then
268 tools_remove
"netsniff-ng"
269 tools_remove
"astraceroute"
270 tools_remove
"flowtop"
278 echo -n "[*] Checking libnetfilter-conntrack ... "
280 cat > $TMPDIR/nfcttest.c
<< EOF
281 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
282 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
283 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
284 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
288 struct nf_conntrack *ct;
289 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
293 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> $TMPDIR/config.log
2>&1
294 if [ ! -x $TMPDIR/nfcttest
] ; then
297 tools_remove
"libnetfilter-conntrack"
305 echo -n "[*] Checking libz ... "
307 cat > $TMPDIR/ztest.c
<< EOF
312 gzFile fp = gzopen("foo.gz", "rb");
316 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> $TMPDIR/config.log
2>&1
317 if [ ! -x $TMPDIR/ztest
] ; then
320 tools_remove
"netsniff-ng"
321 tools_remove
"astraceroute"
322 tools_remove
"flowtop"
330 echo -n "[*] Checking liburcu ... "
332 cat > $TMPDIR/urcutest.c
<< EOF
342 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> $TMPDIR/config.log
2>&1
343 if [ ! -x $TMPDIR/urcutest
] ; then
346 tools_remove
"flowtop"
354 echo -n "[*] Checking libpcap ... "
356 cat > $TMPDIR/pcaptest.c
<< EOF
361 struct bpf_program bpf;
362 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
366 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> $TMPDIR/config.log
2>&1
367 if [ ! -x $TMPDIR/pcaptest
] ; then
369 echo "CONFIG_LIBPCAP=0" >> Config
371 tools_remove
"mausezahn"
374 echo "CONFIG_LIBPCAP=1" >> Config
381 echo -n "[*] Checking hw timestamping ... "
383 cat > $TMPDIR/hwtstest.c
<< EOF
385 #include <arpa/inet.h>
386 #include <sys/ioctl.h>
387 #include <sys/types.h>
388 #include <sys/socket.h>
389 #include <linux/sockios.h>
390 #include <linux/net_tstamp.h>
391 #include <linux/if_packet.h>
392 #include <linux/if_ether.h>
393 #include <linux/if.h>
397 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
398 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
399 struct hwtstamp_config hwconfig;
402 memset(&hwconfig, 0, sizeof(hwconfig));
403 hwconfig.tx_type = HWTSTAMP_TX_OFF;
404 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
406 memset(&ifr, 0, sizeof(ifr));
407 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
408 ifr.ifr_data = &hwconfig;
410 ioctl(sock, SIOCSHWTSTAMP, &ifr);
411 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
416 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> $TMPDIR/config.log
2>&1
417 if [ ! -x $TMPDIR/hwtstest
] ; then
419 echo "CONFIG_HWTSTAMP=0" >> Config
422 echo "CONFIG_HWTSTAMP=1" >> Config
429 echo -n "[*] Checking libcli ... "
431 cat > $TMPDIR/clitest.c
<< EOF
436 struct cli_def *cli = cli_init();
440 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> $TMPDIR/config.log
2>&1
441 if [ ! -x $TMPDIR/clitest
] ; then
444 tools_remove
"mausezahn"
452 echo -n "[*] Checking libnet ... "
454 cat > $TMPDIR/nettest.c
<< EOF
459 char err_buf[LIBNET_ERRBUF_SIZE];
460 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
464 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> $TMPDIR/config.log
2>&1
465 if [ ! -x $TMPDIR/nettest
] ; then
468 tools_remove
"mausezahn"
476 local _version
="`git describe --always`"
477 local _have_libpcap
=""
480 echo "[*] Generating config.h ... "
482 if [ "$HAVE_LIBPCAP" == "1" ] ; then
483 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
486 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
487 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
490 cat > config.h
<< EOF
493 #define FILE_CLIENTS ".curvetun/clients"
494 #define FILE_SERVERS ".curvetun/servers"
495 #define FILE_PRIVKEY ".curvetun/priv.key"
496 #define FILE_PUBKEY ".curvetun/pub.key"
497 #define FILE_USERNAM ".curvetun/username"
498 #define GITVERSION "$_version"
501 #endif /* CONFIG_H */
505 echo "# This file is autogenerated by the configure script" > Config
508 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
509 echo "[!] pkg-config is not installed on your system or not in the PATH"
530 if [ "$MISSING_DEFS" == "1" ] ; then
531 echo "[!] Some libraries or header definitions are missing or too old."
532 echo " Thus certain tools will not be built (see below). Please"
533 echo " refer to the INSTALL file for the libraries needed to build"
534 echo " the complete netsniff-ng toolkit."
537 if [ "$MISSING_NACL" == "1" ] ; then
538 echo "[!] The NaCl crypto library is currently not present on your"
539 echo " system or could not be found. Either install it from your"
540 echo " distro or build it manually using 'make nacl' and make sure"
541 echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
542 echo " appropriately."
545 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
546 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
547 echo "[*] The following tools will be built: $TOOLS"
549 echo "[*] Looks good! All tools will be built!"
552 echo "CONFIG_TOOLS=$TOOLS" >> Config
553 echo "CONFIG_OK=1" >> Config