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 flex ... "
72 if [ "x$(which flex)" == "x" ] ; then
75 tools_remove
"trafgen"
84 echo -n "[*] Checking bison ... "
86 if [ "x$(which bison)" == "x" ] ; then
89 tools_remove
"trafgen"
98 echo -n "[*] Checking nacl ... "
100 cat > $TMPDIR/nacltest.c
<< EOF
101 #include "crypto_hash_sha512.h"
102 #include "crypto_verify_32.h"
103 #include "crypto_hash_sha512.h"
104 #include "crypto_box_curve25519xsalsa20poly1305.h"
105 #include "crypto_scalarmult_curve25519.h"
106 #include "crypto_auth_hmacsha512256.h"
111 if [ -z $NACL_INC_DIR ] ; then
112 NACL_INC_DIR
="/usr/include/nacl"
115 if [ -z $NACL_LIB_DIR ] ; then
116 NACL_LIB_DIR
="/usr/lib"
119 LDFLAGS
="-L $NACL_LIB_DIR"
120 CFLAGS
="-I $NACL_INC_DIR"
122 $CC $CFLAGS $LDFLAGS -o $TMPDIR/nacltest
$TMPDIR/nacltest.c
>> $TMPDIR/config.log
2>&1
123 if [ ! -x $TMPDIR/nacltest
] ; then
126 tools_remove
"curvetun"
129 echo "CONFIG_NACL_INC_DIR:=$NACL_INC_DIR" >> Config
130 echo "CONFIG_NACL_LIB_DIR:=$NACL_LIB_DIR" >> Config
136 echo -n "[*] Checking libnl ... "
138 cat > $TMPDIR/libnltest.c
<< EOF
139 #include <libnl3/netlink/genl/genl.h>
140 #include <libnl3/netlink/genl/family.h>
141 #include <libnl3/netlink/genl/ctrl.h>
142 #include <libnl3/netlink/msg.h>
143 #include <libnl3/netlink/attr.h>
144 #include <libnl3/netlink/version.h>
146 #if LIBNL_VER_NUM < LIBNL_VER(3,0)
147 # error incompatible libnl version
152 struct nl_sock *sock = nl_socket_alloc();
153 struct nl_cache *nl_cache;
154 int ret = genl_connect(sock);
156 ret = genl_ctrl_alloc_cache(sock, &nl_cache);
161 $
(pkg-config
--cflags libnl-3.0
) \
162 $
(pkg-config
--cflags libnl-genl-3.0
) \
163 -o $TMPDIR/libnltest \
164 $TMPDIR/libnltest.c \
165 $
(pkg-config
--libs libnl-3.0
) \
166 $
(pkg-config
--libs libnl-genl-3.0
) \
167 >> $TMPDIR/config.log
2>&1
168 if [ ! -x $TMPDIR/libnltest
] ; then
171 tools_remove
"trafgen"
172 tools_remove
"netsniff-ng"
180 echo -n "[*] Checking tpacket_v3 ... "
182 cat > $TMPDIR/tpacketv3test.c
<< EOF
184 #include <linux/if_packet.h>
188 struct tpacket3_hdr *hdr;
193 printf("%d\n", hdr->tp_status);
197 $CC -o $TMPDIR/tpacketv3test
$TMPDIR/tpacketv3test.c
>> $TMPDIR/config.log
2>&1
198 if [ ! -x $TMPDIR/tpacketv3test
] ; then
201 tools_remove
"netsniff-ng"
209 echo -n "[*] Checking tpacket_v2 ... "
211 cat > $TMPDIR/tpacketv2test.c
<< EOF
213 #include <linux/if_packet.h>
217 struct tpacket2_hdr *hdr;
220 TP_STATUS_SEND_REQUEST,
226 printf("%d\n", hdr->tp_status);
230 $CC -o $TMPDIR/tpacketv2test
$TMPDIR/tpacketv2test.c
>> $TMPDIR/config.log
2>&1
231 if [ ! -x $TMPDIR/tpacketv2test
] ; then
234 tools_remove
"netsniff-ng"
235 tools_remove
"trafgen"
244 echo -n "[*] Checking ncurses ... "
246 cat > $TMPDIR/ncursestest.c
<< EOF
251 WINDOW *screen = initscr();
256 $
(pkg-config
--cflags ncurses
) \
257 -o $TMPDIR/ncursestest
$TMPDIR/ncursestest.c \
258 $
(pkg-config
--libs ncurses
) \
259 >> $TMPDIR/config.log
2>&1
260 if [ ! -x $TMPDIR/ncursestest
] ; then
263 tools_remove
"flowtop"
272 echo -n "[*] Checking libGeoIP ... "
274 cat > $TMPDIR/geoiptest.c
<< EOF
276 #include <GeoIPCity.h>
281 GEOIP_CITY_EDITION_REV1,
282 GEOIP_CITY_EDITION_REV1_V6,
283 GEOIP_COUNTRY_EDITION,
284 GEOIP_COUNTRY_EDITION_V6,
286 GEOIP_ASNUM_EDITION_V6,
288 GeoIP *geoip = GeoIP_new(0);
292 $CC -o $TMPDIR/geoiptest
$TMPDIR/geoiptest.c
-lGeoIP >> $TMPDIR/config.log
2>&1
293 if [ ! -x $TMPDIR/geoiptest
] ; then
296 tools_remove
"netsniff-ng"
297 tools_remove
"astraceroute"
298 tools_remove
"flowtop"
306 echo -n "[*] Checking libnetfilter-conntrack ... "
308 cat > $TMPDIR/nfcttest.c
<< EOF
309 #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
310 #include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
311 #include <libnetfilter_conntrack/libnetfilter_conntrack_dccp.h>
312 #include <libnetfilter_conntrack/libnetfilter_conntrack_sctp.h>
316 struct nf_conntrack *ct;
317 const uint32_t id = nfct_get_attr_u32(ct, ATTR_ID);
321 $CC -o $TMPDIR/nfcttest
$TMPDIR/nfcttest.c
-lnetfilter_conntrack >> $TMPDIR/config.log
2>&1
322 if [ ! -x $TMPDIR/nfcttest
] ; then
325 tools_remove
"libnetfilter-conntrack"
333 echo -n "[*] Checking libz ... "
335 cat > $TMPDIR/ztest.c
<< EOF
340 gzFile fp = gzopen("foo.gz", "rb");
344 $CC -o $TMPDIR/ztest
$TMPDIR/ztest.c
-lz >> $TMPDIR/config.log
2>&1
345 if [ ! -x $TMPDIR/ztest
] ; then
348 tools_remove
"netsniff-ng"
349 tools_remove
"astraceroute"
350 tools_remove
"flowtop"
358 echo -n "[*] Checking liburcu ... "
360 cat > $TMPDIR/urcutest.c
<< EOF
370 $CC -o $TMPDIR/urcutest
$TMPDIR/urcutest.c
-lurcu >> $TMPDIR/config.log
2>&1
371 if [ ! -x $TMPDIR/urcutest
] ; then
374 tools_remove
"flowtop"
382 echo -n "[*] Checking libpcap ... "
384 cat > $TMPDIR/pcaptest.c
<< EOF
389 struct bpf_program bpf;
390 int ret = pcap_compile_nopcap(65535, 1, &bpf, "foo.bpf", 1, 0xffffffff);
394 $CC -o $TMPDIR/pcaptest
$TMPDIR/pcaptest.c
-lpcap >> $TMPDIR/config.log
2>&1
395 if [ ! -x $TMPDIR/pcaptest
] ; then
397 echo "CONFIG_LIBPCAP=0" >> Config
399 tools_remove
"mausezahn"
402 echo "CONFIG_LIBPCAP=1" >> Config
409 echo -n "[*] Checking hw timestamping ... "
411 cat > $TMPDIR/hwtstest.c
<< EOF
413 #include <arpa/inet.h>
414 #include <sys/ioctl.h>
415 #include <sys/types.h>
416 #include <sys/socket.h>
417 #include <linux/sockios.h>
418 #include <linux/net_tstamp.h>
419 #include <linux/if_packet.h>
420 #include <linux/if_ether.h>
421 #include <linux/if.h>
425 int timesource = SOF_TIMESTAMPING_RAW_HARDWARE, ret;
426 int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
427 struct hwtstamp_config hwconfig;
430 memset(&hwconfig, 0, sizeof(hwconfig));
431 hwconfig.tx_type = HWTSTAMP_TX_OFF;
432 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
434 memset(&ifr, 0, sizeof(ifr));
435 strncpy(ifr.ifr_name, "lo", sizeof(ifr.ifr_name));
436 ifr.ifr_data = &hwconfig;
438 ioctl(sock, SIOCSHWTSTAMP, &ifr);
439 setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, ×ource,
444 $CC -o $TMPDIR/hwtstest
$TMPDIR/hwtstest.c
>> $TMPDIR/config.log
2>&1
445 if [ ! -x $TMPDIR/hwtstest
] ; then
447 echo "CONFIG_HWTSTAMP=0" >> Config
450 echo "CONFIG_HWTSTAMP=1" >> Config
457 echo -n "[*] Checking libcli ... "
459 cat > $TMPDIR/clitest.c
<< EOF
464 struct cli_def *cli = cli_init();
468 $CC -o $TMPDIR/clitest
$TMPDIR/clitest.c
-lcli >> $TMPDIR/config.log
2>&1
469 if [ ! -x $TMPDIR/clitest
] ; then
472 tools_remove
"mausezahn"
480 echo -n "[*] Checking libnet ... "
482 cat > $TMPDIR/nettest.c
<< EOF
487 char err_buf[LIBNET_ERRBUF_SIZE];
488 libnet_t *l = libnet_init(LIBNET_LINK_ADV, "ethX", err_buf);
492 $CC -o $TMPDIR/nettest
$TMPDIR/nettest.c
-lnet >> $TMPDIR/config.log
2>&1
493 if [ ! -x $TMPDIR/nettest
] ; then
496 tools_remove
"mausezahn"
504 local _version
="`git describe --always`"
505 local _have_libpcap
=""
508 echo "[*] Generating config.h ... "
510 if [ "$HAVE_LIBPCAP" == "1" ] ; then
511 _have_libpcap
="#define HAVE_TCPDUMP_LIKE_FILTER 1"
514 if [ "$HAVE_HWTSTAMP" == "1" ] ; then
515 _have_hwts
="#define HAVE_HARDWARE_TIMESTAMPING 1"
518 cat > config.h
<< EOF
521 #define FILE_CLIENTS ".curvetun/clients"
522 #define FILE_SERVERS ".curvetun/servers"
523 #define FILE_PRIVKEY ".curvetun/priv.key"
524 #define FILE_PUBKEY ".curvetun/pub.key"
525 #define FILE_USERNAM ".curvetun/username"
526 #define GITVERSION "$_version"
529 #endif /* CONFIG_H */
533 echo "# This file is autogenerated by the configure script" > Config
536 if [ "$MISSING_PKG_CONFIG" == "1" ] ; then
537 echo "[!] pkg-config is not installed on your system or not in the PATH"
560 if [ "$MISSING_DEFS" == "1" ] ; then
561 echo "[!] Some libraries or header definitions are missing or too old."
562 echo " Thus certain tools will not be built (see below). Please"
563 echo " refer to the INSTALL file for the libraries needed to build"
564 echo " the complete netsniff-ng toolkit."
567 if [ "$MISSING_NACL" == "1" ] ; then
568 echo "[!] The NaCl crypto library is currently not present on your"
569 echo " system or could not be found. Either install it from your"
570 echo " distro or build it manually using 'make nacl' and make sure"
571 echo " that the NACL_INC_DIR and NACL_LIB_DIR variables are set"
572 echo " appropriately."
575 if [ "x$TOOLS_NOBUILD" != "x" ] ; then
576 echo "[!] The following tools will *not* be built: $TOOLS_NOBUILD"
577 echo "[*] The following tools will be built: $TOOLS"
579 echo "[*] Looks good! All tools will be built!"
582 echo "CONFIG_TOOLS=$TOOLS" >> Config
583 echo "CONFIG_OK=1" >> Config