1 dnl aclocal.m4 generated automatically by aclocal 1.4
3 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
13 dnl $Id: aclocal.m4,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
15 dnl Libnet specific autoconf macros
16 dnl Copyright (c) 1998, 1999, 2000 Mike D. Schiffman <mike@infonexus.com>
17 dnl All rights reserved.
21 dnl Checks to see if this linux kernel has a working PF_PACKET
25 dnl AC_LIBNET_CHECK_PF_PACKET
29 dnl HAVE_PF_PACKET (DEFINED)
32 AC_DEFUN(AC_LIBNET_CHECK_PF_PACKET,
34 AC_MSG_CHECKING(for PF_PACKET)
35 AC_CACHE_VAL(ac_libnet_have_pf_packet,
40 ac_libnet_have_pf_packet = no
44 cat > pf_packet-test.c << EOF
47 #include <netinet/if_ether.h>
48 #include <net/if_arp.h>
50 #include <linux/if_arp.h>
51 #include <linux/if_ether.h>
55 #define SOL_PACKET 263
56 #endif /* SOL_PACKET */
57 #include <linux/if_packet.h>
60 #include <linux/sockios.h>
67 struct sockaddr_ll sa;
69 struct packet_mreq mr;
72 fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
79 memset(&sa, 0, sizeof(sa));
80 strcpy(ifr.ifr_name, device);
81 if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)
86 sa.sll_family = AF_PACKET;
87 sa.sll_ifindex = ifr.ifr_ifindex;
88 sa.sll_protocol = htons(ETH_P_ALL);
90 memset(&mr, 0, sizeof (mr));
91 mr.mr_ifindex = sa.sll_ifindex;
92 mr.mr_type = PACKET_MR_ALLMULTI;
94 if (setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, (char *)&mr,
100 /* yay. we made it and it workz! */
102 #else /* PF_PACKET */
108 ${CC-cc} -o pf_packet-test $CFLAGS pf_packet-test.c >/dev/null 2>&1
110 # Oopz 4.3 BSD doesn't have this. Sorry.
111 if test ! -x ./pf_packet-test ; then
112 ac_libnet_have_pf_packet=choked
114 ac_libnet_have_pf_packet=`./pf_packet-test`;
117 if test $ac_libnet_have_pf_packet = choked; then
118 AC_MSG_RESULT(test program choked... assuming no)
119 elif test $ac_libnet_have_pf_packet = yes; then
120 AC_DEFINE(HAVE_PF_PACKET)
121 LIBNET_CONFIG_DEFINES="$LIBNET_CONFIG_DEFINES -DHAVE_PF_PACKET"
124 if test $ac_libnet_have_pf_packet != choked; then
125 AC_MSG_RESULT($ac_libnet_have_pf_packet)
127 rm -f pf_packet-test* core core.pf_packet-test
133 dnl Looks for a previous libnet version and attempts to determine which verion
134 dnl it is. Version 0.8 was the first version that actually knew internally
135 dnl what version it was.
139 dnl AC_LIBNET_CHECK_LIBNET_VERSION
146 AC_DEFUN(AC_LIBNET_CHECK_LIBNET_VER,
148 AC_CHECK_LIB(net, libnet_build_ip, AC_MSG_CHECKING(version) \
150 changequote(<<, >>)dnl
151 if [[ ! -f $LIB_PREFIX/libnet.a ]] ; then
153 AC_MSG_RESULT($LIB_PREFIX/libnet.a doesn't exist)
154 AC_MSG_RESULT(previous libnet install lives elsewhere, you should probably find it)
156 __LIBNET_VERSION=`strings $LIB_PREFIX/libnet.a | grep "libnet version"\
158 if test -z "$__LIBNET_VERSION"; then
161 AC_MSG_RESULT($__LIBNET_VERSION)
169 dnl Checks to see if this linux kernel uses ip_sum or ip_csum
170 dnl (Pulled from queso)
174 dnl AC_LIBNET_CHECK_IP_CSUM
178 dnl HAVE_STRUCT_IP_CSUM (DEFINED)
181 AC_DEFUN(AC_LIBNET_CHECK_IP_CSUM,
183 AC_MSG_CHECKING([struct ip contains ip_csum])
187 #include <sys/types.h>
188 #include <netinet/in.h>
189 #include <netinet/in_systm.h>
190 #include <netinet/ip.h>],
196 AC_DEFINE(HAVE_STRUCT_IP_CSUM)],
202 dnl Checks to see if unaligned memory accesses fail
203 dnl (Pulled from libpcap)
207 dnl AC_LBL_UNALIGNED_ACCESS
211 dnl LBL_ALIGN (DEFINED)
214 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
215 [AC_MSG_CHECKING(if unaligned accesses fail)
216 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
217 [case "$target_cpu" in
219 alpha|hp*|mips|sparc)
220 ac_cv_lbl_unaligned_fail=yes
224 cat >conftest.c <<EOF
225 # include <sys/types.h>
226 # include <sys/wait.h>
228 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
234 /* avoid "core dumped" message */
243 pid = waitpid(pid, &status, 0);
248 exit(!WIFEXITED(status));
251 i = *(unsigned int *)&a[[1]];
256 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
257 conftest.c $LIBS > /dev/null 2>&1
258 # Oopz 4.3 BSD doesn't have this. Sorry.
259 if test ! -x conftest ; then
260 dnl failed to compile for some reason
261 ac_cv_lbl_unaligned_fail=yes
263 ./conftest > conftest.out
264 if test ! -s conftest.out ; then
265 ac_cv_lbl_unaligned_fail=yes
267 ac_cv_lbl_unaligned_fail=no
270 rm -f conftest* core core.conftest
273 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
274 if test $ac_cv_lbl_unaligned_fail = yes ; then
285 dnl AC_LIBNET_ENDIAN_CHECK
289 dnl LIBNET_BIG_ENDIAN = 1 or
290 dnl LIBNET_LIL_ENDIAN = 1
293 AC_DEFUN(AC_LIBNET_ENDIAN_CHECK,
294 [AC_MSG_CHECKING(machine endianess)
296 cat > conftest.c << EOF
305 char c[[sizeof(short)]];
309 if (sizeof (short) == 2)
311 if (un.c [[0]] == 1 && un.c [[1]] == 2)
317 if (un.c [[0]] == 2 && un.c [[1]] == 1)
327 return (EXIT_SUCCESS);
330 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS > /dev/null 2>&1
331 # Oopz 4.3 BSD doesn't have this. Sorry.
332 if test ! -x conftest ; then
333 dnl failed to compile for some reason
334 ac_cv_libnet_endianess=unknown
336 ./conftest > conftest.out
337 result=`cat conftest.out`
338 if test $result = "B"; then
339 ac_cv_libnet_endianess=big
340 elif test $result = "L"; then
341 ac_cv_libnet_endianess=lil
343 ac_cv_libnet_endianess=unknown
346 rm -f conftest* core core.conftest
348 AC_MSG_RESULT($ac_cv_libnet_endianess)
350 if test $ac_cv_libnet_endianess = big ; then
351 AC_DEFINE(LIBNET_BIG_ENDIAN)
352 LIBNET_CONFIG_DEFINES="$LIBNET_CONFIG_DEFINES -DLIBNET_BIG_ENDIAN"
353 elif test $ac_cv_libnet_endianess = lil ; then
354 AC_DEFINE(LIBNET_LIL_ENDIAN)
355 LIBNET_CONFIG_DEFINES="$LIBNET_CONFIG_DEFINES -DLIBNET_LIL_ENDIAN"