2 dnl Check for 4.4 BSD sa_len member in sockaddr struct
4 dnl usage: AC_DNET_SOCKADDR_SA_LEN
5 dnl results: HAVE_SOCKADDR_SA_LEN (defined)
7 AC_DEFUN(AC_DNET_SOCKADDR_SA_LEN,
8 [AC_MSG_CHECKING(for sa_len in sockaddr struct)
9 AC_CACHE_VAL(ac_cv_dnet_sockaddr_has_sa_len,
11 # ifndef _SOCKADDR_LEN
12 # define _SOCKADDR_LEN 1
14 # include <sys/types.h>
15 # include <sys/socket.h>],
16 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
17 ac_cv_dnet_sockaddr_has_sa_len=yes,
18 ac_cv_dnet_sockaddr_has_sa_len=no))
19 AC_MSG_RESULT($ac_cv_dnet_sockaddr_has_sa_len)
20 if test $ac_cv_dnet_sockaddr_has_sa_len = yes ; then
21 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1,
22 [Define if sockaddr struct has sa_len.])
26 dnl Check for sockaddr_in6 struct in <netinet/in.h>
28 dnl usage: AC_DNET_SOCKADDR_IN6
29 dnl results: HAVE_SOCKADDR_IN6
31 AC_DEFUN(AC_DNET_SOCKADDR_IN6,
32 [AC_MSG_CHECKING(for sockaddr_in6 struct in <netinet/in.h>)
33 AC_CACHE_VAL(ac_cv_dnet_netinet_in_h_has_sockaddr_in6,
35 # include <sys/types.h>
36 # include <sys/socket.h>
37 # include <netinet/in.h>],
38 [struct sockaddr_in6 sin6; sin6.sin6_family = AF_INET6;],
39 ac_cv_dnet_netinet_in_h_has_sockaddr_in6=yes,
40 ac_cv_dnet_netinet_in_h_has_sockaddr_in6=no))
41 AC_MSG_RESULT($ac_cv_dnet_netinet_in_h_has_sockaddr_in6)
42 if test $ac_cv_dnet_netinet_in_h_has_sockaddr_in6 = yes ; then
43 AC_DEFINE(HAVE_SOCKADDR_IN6, 1,
44 [Define if <netinet/in.h> has sockaddr_in6 struct.])
48 dnl Check for arp_dev member in arpreq struct
50 dnl usage: AC_DNET_ARPREQ_ARP_DEV
51 dnl results: HAVE_ARPREQ_ARP_DEV (defined)
53 AC_DEFUN(AC_DNET_ARPREQ_ARP_DEV,
54 [AC_MSG_CHECKING(for arp_dev in arpreq struct)
55 AC_CACHE_VAL(ac_cv_dnet_arpreq_has_arp_dev,
57 # include <sys/types.h>
58 # include <sys/socket.h>
59 # include <net/if_arp.h>],
60 [void *p = ((struct arpreq *)0)->arp_dev],
61 ac_cv_dnet_arpreq_has_arp_dev=yes,
62 ac_cv_dnet_arpreq_has_arp_dev=no))
63 AC_MSG_RESULT($ac_cv_dnet_arpreq_has_arp_dev)
64 if test $ac_cv_dnet_arpreq_has_arp_dev = yes ; then
65 AC_DEFINE(HAVE_ARPREQ_ARP_DEV, 1,
66 [Define if arpreq struct has arp_dev.])
70 dnl Check for rt_msghdr struct in <net/route.h>
72 dnl usage: AC_DNET_ROUTE_RT_MSGHDR
73 dnl results: HAVE_ROUTE_RT_MSGHDR
75 AC_DEFUN(AC_DNET_ROUTE_RT_MSGHDR,
76 [AC_MSG_CHECKING(for rt_msghdr struct in <net/route.h>)
77 AC_CACHE_VAL(ac_cv_dnet_route_h_has_rt_msghdr,
79 # include <sys/types.h>
80 # include <sys/socket.h>
82 # include <net/route.h>],
83 [struct rt_msghdr rtm; rtm.rtm_msglen = 0;],
84 ac_cv_dnet_route_h_has_rt_msghdr=yes,
85 ac_cv_dnet_route_h_has_rt_msghdr=no))
86 AC_MSG_RESULT($ac_cv_dnet_route_h_has_rt_msghdr)
87 if test $ac_cv_dnet_route_h_has_rt_msghdr = yes ; then
88 AC_DEFINE(HAVE_ROUTE_RT_MSGHDR, 1,
89 [Define if <net/route.h> has rt_msghdr struct.])
93 dnl Check for the Berkeley Packet Filter
95 dnl usage: AC_DNET_BSD_BPF
96 dnl results: HAVE_BSD_BPF
98 AC_DEFUN(AC_DNET_BSD_BPF,
99 [AC_MSG_CHECKING(for Berkeley Packet Filter)
100 AC_CACHE_VAL(ac_cv_dnet_bsd_bpf,
101 if test -c /dev/bpf0 ; then
102 ac_cv_dnet_bsd_bpf=yes
104 ac_cv_dnet_bsd_bpf=no
106 AC_MSG_RESULT($ac_cv_dnet_bsd_bpf)
107 if test $ac_cv_dnet_bsd_bpf = yes ; then
108 AC_DEFINE(HAVE_BSD_BPF, 1,
109 [Define if you have the Berkeley Packet Filter.])
113 dnl Check for the Linux /proc filesystem
115 dnl usage: AC_DNET_LINUX_PROCFS
116 dnl results: HAVE_LINUX_PROCFS
118 AC_DEFUN(AC_DNET_LINUX_PROCFS,
119 [AC_MSG_CHECKING(for Linux proc filesystem)
120 AC_CACHE_VAL(ac_cv_dnet_linux_procfs,
121 if test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux" ; then
122 ac_cv_dnet_linux_procfs=yes
124 ac_cv_dnet_linux_procfs=no
126 AC_MSG_RESULT($ac_cv_dnet_linux_procfs)
127 if test $ac_cv_dnet_linux_procfs = yes ; then
128 AC_DEFINE(HAVE_LINUX_PROCFS, 1,
129 [Define if you have the Linux /proc filesystem.])
133 dnl Check for Linux PF_PACKET sockets
135 dnl usage: AC_DNET_LINUX_PF_PACKET
136 dnl results: HAVE_LINUX_PF_PACKET
138 AC_DEFUN(AC_DNET_LINUX_PF_PACKET,
139 [AC_MSG_CHECKING(for Linux PF_PACKET sockets)
140 AC_CACHE_VAL(ac_cv_dnet_linux_pf_packet,
141 if test -f /usr/include/netpacket/packet.h ; then
142 ac_cv_dnet_linux_pf_packet=yes
144 ac_cv_dnet_linux_pf_packet=no
146 AC_MSG_RESULT($ac_cv_dnet_linux_pf_packet)
147 if test $ac_cv_dnet_linux_pf_packet = yes ; then
148 AC_DEFINE(HAVE_LINUX_PF_PACKET, 1,
149 [Define if you have Linux PF_PACKET sockets.])
153 dnl Check for SNMP MIB2 STREAMS (Solaris only?)
155 dnl usage: AC_DNET_STREAMS_MIB2
156 dnl results: HAVE_STREAMS_MIB2
158 AC_DEFUN(AC_DNET_STREAMS_MIB2,
159 [AC_MSG_CHECKING(for SNMP MIB2 STREAMS)
160 AC_CACHE_VAL(ac_cv_dnet_streams_mib2,
161 if test -f /usr/include/inet/mib2.h -a -c /dev/ip ; then
162 ac_cv_dnet_streams_mib2=yes
164 ac_cv_dnet_streams_mib2=no
166 AC_MSG_RESULT($ac_cv_dnet_streams_mib2)
167 if test $ac_cv_dnet_streams_mib2 = yes ; then
168 AC_DEFINE(HAVE_STREAMS_MIB2, 1,
169 [Define if you have SNMP MIB2 STREAMS.])
173 dnl Check for route(7) STREAMS (UnixWare only?)
175 dnl usage: AC_DNET_STREAMS_ROUTE
176 dnl results: HAVE_STREAMS_ROUTE
178 AC_DEFUN(AC_DNET_STREAMS_ROUTE,
179 [AC_MSG_CHECKING(for route(7) STREAMS)
180 AC_CACHE_VAL(ac_cv_dnet_streams_route,
181 if grep RTSTR_SEND /usr/include/net/route.h >/dev/null 2>&1 ; then
182 ac_cv_dnet_streams_route=yes
184 ac_cv_dnet_streams_route=no
186 AC_MSG_RESULT($ac_cv_dnet_streams_route)
187 if test $ac_cv_dnet_streams_route = yes ; then
188 AC_DEFINE(HAVE_STREAMS_ROUTE, 1,
189 [Define if you have route(7) STREAMS.])
193 dnl Check for arp(7) ioctls
195 dnl usage: AC_DNET_IOCTL_ARP
196 dnl results: HAVE_IOCTL_ARP
198 AC_DEFUN(AC_DNET_IOCTL_ARP,
199 [AC_MSG_CHECKING(for arp(7) ioctls)
200 AC_CACHE_VAL(ac_cv_dnet_ioctl_arp,
202 # include <sys/types.h>
204 # include <sys/ioctl.h>
208 ac_cv_dnet_ioctl_arp=yes,
209 ac_cv_dnet_ioctl_arp=no))
212 ac_cv_dnet_ioctl_arp=no ;;
214 AC_MSG_RESULT($ac_cv_dnet_ioctl_arp)
215 if test $ac_cv_dnet_ioctl_arp = yes ; then
216 AC_DEFINE(HAVE_IOCTL_ARP, 1,
217 [Define if you have arp(7) ioctls.])
221 dnl Check for raw IP sockets ip_{len,off} host byte ordering
223 dnl usage: AC_DNET_RAWIP_HOST_OFFLEN
224 dnl results: HAVE_RAWIP_HOST_OFFLEN
226 AC_DEFUN(AC_DNET_RAWIP_HOST_OFFLEN,
227 [AC_MSG_CHECKING([for raw IP sockets ip_{len,off} host byte ordering])
228 AC_CACHE_VAL(ac_cv_dnet_rawip_host_offlen, [
231 ac_cv_dnet_rawip_host_offlen=no ;;
232 *bsd*|*osf*|*unixware*)
233 ac_cv_dnet_rawip_host_offlen=yes ;;
235 ac_cv_dnet_rawip_host_offlen=no ;;
237 AC_MSG_RESULT($ac_cv_dnet_rawip_host_offlen)
238 if test $ac_cv_dnet_rawip_host_offlen = yes ; then
239 AC_DEFINE(HAVE_RAWIP_HOST_OFFLEN, 1,
240 [Define if raw IP sockets require host byte ordering for ip_off, ip_len.])
244 dnl Check for cooked raw IP sockets
246 dnl usage: AC_DNET_RAWIP_COOKED
247 dnl results: HAVE_RAWIP_COOKED
249 AC_DEFUN(AC_DNET_RAWIP_COOKED,
250 [AC_MSG_CHECKING(for cooked raw IP sockets)
251 AC_CACHE_VAL(ac_cv_dnet_rawip_cooked, [
254 ac_cv_dnet_rawip_cooked=yes ;;
256 ac_cv_dnet_rawip_cooked=no ;;
258 AC_MSG_RESULT($ac_cv_dnet_rawip_cooked)
259 if test $ac_cv_dnet_rawip_cooked = yes ; then
260 AC_DEFINE(HAVE_RAWIP_COOKED, 1,
261 [Define if you have cooked raw IP sockets.])
265 dnl AC_LBL_LIBRARY_NET
267 dnl This test is for network applications that need socket() and
268 dnl gethostbyname() -ish functions. Under Solaris, those applications
269 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
270 dnl with "-lnsl" but should *not* link with "-lsocket" because
271 dnl libsocket.a breaks a number of things (for instance:
272 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
273 dnl versions of IRIX).
275 dnl Unfortunately, many application developers are not aware of this,
276 dnl and mistakenly write tests that cause -lsocket to be used under
277 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
278 dnl under operating systems where neither are necessary (or useful),
279 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
281 dnl This test exists so that every application developer does not test
282 dnl this in a different, and subtly broken fashion.
284 dnl It has been argued that this test should be broken up into two
285 dnl seperate tests, one for the resolver libraries, and one for the
286 dnl libraries necessary for using Sockets API. Unfortunately, the two
287 dnl are carefully intertwined and allowing the autoconf user to use
288 dnl them independantly potentially results in unfortunate ordering
289 dnl dependancies -- as such, such component macros would have to
290 dnl carefully use indirection and be aware if the other components were
291 dnl executed. Since other autoconf macros do not go to this trouble,
292 dnl and almost no applications use sockets without the resolver, this
293 dnl complexity has not been implemented.
295 dnl The check for libresolv is in case you are attempting to link
296 dnl statically and happen to have a libresolv.a lying around (and no
299 AC_DEFUN(AC_LBL_LIBRARY_NET, [
300 # Most operating systems have gethostbyname() in the default searched
301 # libraries (i.e. libc):
302 AC_CHECK_FUNC(gethostbyname, ,
303 # Some OSes (eg. Solaris) place it in libnsl:
304 AC_CHECK_LIB(nsl, gethostbyname, ,
305 # Some strange OSes (SINIX) have it in libsocket:
306 AC_CHECK_LIB(socket, gethostbyname, ,
307 # Unfortunately libsocket sometimes depends on libnsl.
308 # AC_CHECK_LIB's API is essentially broken so the
309 # following ugliness is necessary:
310 AC_CHECK_LIB(socket, gethostbyname,
311 LIBS="-lsocket -lnsl $LIBS",
312 AC_CHECK_LIB(resolv, gethostbyname),
314 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
315 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
317 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
318 AC_CHECK_LIB(str, putmsg)