dnet.m4 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. # dnet.m4 serial 1 (libdnet-1.11)
  2. dnl
  3. dnl Check for 4.4 BSD sa_len member in sockaddr struct
  4. dnl
  5. dnl usage: AC_DNET_SOCKADDR_SA_LEN
  6. dnl results: HAVE_SOCKADDR_SA_LEN (defined)
  7. dnl
  8. AC_DEFUN([AC_DNET_SOCKADDR_SA_LEN],
  9. [AC_MSG_CHECKING(for sa_len in sockaddr struct)
  10. AC_CACHE_VAL(ac_cv_dnet_sockaddr_has_sa_len,
  11. AC_TRY_COMPILE([
  12. # ifndef _SOCKADDR_LEN
  13. # define _SOCKADDR_LEN 1
  14. # endif
  15. # include <sys/types.h>
  16. # include <sys/socket.h>],
  17. [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
  18. ac_cv_dnet_sockaddr_has_sa_len=yes,
  19. ac_cv_dnet_sockaddr_has_sa_len=no))
  20. AC_MSG_RESULT($ac_cv_dnet_sockaddr_has_sa_len)
  21. if test $ac_cv_dnet_sockaddr_has_sa_len = yes ; then
  22. AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1,
  23. [Define if sockaddr struct has sa_len.])
  24. fi])
  25. dnl
  26. dnl Check for sockaddr_in6 struct in <netinet/in.h>
  27. dnl
  28. dnl usage: AC_DNET_SOCKADDR_IN6
  29. dnl results: HAVE_SOCKADDR_IN6
  30. dnl
  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,
  34. AC_TRY_COMPILE([
  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.])
  45. fi])
  46. dnl
  47. dnl Check for arp_dev member in arpreq struct
  48. dnl
  49. dnl usage: AC_DNET_ARPREQ_ARP_DEV
  50. dnl results: HAVE_ARPREQ_ARP_DEV (defined)
  51. dnl
  52. AC_DEFUN([AC_DNET_ARPREQ_ARP_DEV],
  53. [AC_MSG_CHECKING(for arp_dev in arpreq struct)
  54. AC_CACHE_VAL(ac_cv_dnet_arpreq_has_arp_dev,
  55. AC_TRY_COMPILE([
  56. # include <sys/types.h>
  57. # include <sys/socket.h>
  58. # include <net/if_arp.h>],
  59. [void *p = ((struct arpreq *)0)->arp_dev],
  60. ac_cv_dnet_arpreq_has_arp_dev=yes,
  61. ac_cv_dnet_arpreq_has_arp_dev=no))
  62. AC_MSG_RESULT($ac_cv_dnet_arpreq_has_arp_dev)
  63. if test $ac_cv_dnet_arpreq_has_arp_dev = yes ; then
  64. AC_DEFINE(HAVE_ARPREQ_ARP_DEV, 1,
  65. [Define if arpreq struct has arp_dev.])
  66. fi])
  67. dnl
  68. dnl Check for rt_msghdr struct in <net/route.h>
  69. dnl
  70. dnl usage: AC_DNET_ROUTE_RT_MSGHDR
  71. dnl results: HAVE_ROUTE_RT_MSGHDR
  72. dnl
  73. AC_DEFUN([AC_DNET_ROUTE_RT_MSGHDR],
  74. [AC_MSG_CHECKING(for rt_msghdr struct in <net/route.h>)
  75. AC_CACHE_VAL(ac_cv_dnet_route_h_has_rt_msghdr,
  76. AC_TRY_COMPILE([
  77. # include <sys/types.h>
  78. # include <sys/socket.h>
  79. # include <net/if.h>
  80. # include <net/route.h>],
  81. [struct rt_msghdr rtm; rtm.rtm_msglen = 0;],
  82. ac_cv_dnet_route_h_has_rt_msghdr=yes,
  83. ac_cv_dnet_route_h_has_rt_msghdr=no))
  84. AC_MSG_RESULT($ac_cv_dnet_route_h_has_rt_msghdr)
  85. if test $ac_cv_dnet_route_h_has_rt_msghdr = yes ; then
  86. AC_DEFINE(HAVE_ROUTE_RT_MSGHDR, 1,
  87. [Define if <net/route.h> has rt_msghdr struct.])
  88. fi])
  89. dnl
  90. dnl Check for the Berkeley Packet Filter
  91. dnl
  92. dnl usage: AC_DNET_BSD_BPF
  93. dnl results: HAVE_BSD_BPF
  94. dnl
  95. AC_DEFUN([AC_DNET_BSD_BPF],
  96. [AC_MSG_CHECKING(for Berkeley Packet Filter)
  97. AC_CACHE_VAL(ac_cv_dnet_bsd_bpf,
  98. if test -c /dev/bpf0 ; then
  99. ac_cv_dnet_bsd_bpf=yes
  100. else
  101. ac_cv_dnet_bsd_bpf=no
  102. fi)
  103. AC_MSG_RESULT($ac_cv_dnet_bsd_bpf)
  104. if test $ac_cv_dnet_bsd_bpf = yes ; then
  105. AC_DEFINE(HAVE_BSD_BPF, 1,
  106. [Define if you have the Berkeley Packet Filter.])
  107. fi])
  108. dnl
  109. dnl Check for the Linux /proc filesystem
  110. dnl
  111. dnl usage: AC_DNET_LINUX_PROCFS
  112. dnl results: HAVE_LINUX_PROCFS
  113. dnl
  114. AC_DEFUN([AC_DNET_LINUX_PROCFS],
  115. [AC_MSG_CHECKING(for Linux proc filesystem)
  116. AC_CACHE_VAL(ac_cv_dnet_linux_procfs,
  117. if test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux" ; then
  118. ac_cv_dnet_linux_procfs=yes
  119. else
  120. ac_cv_dnet_linux_procfs=no
  121. fi)
  122. AC_MSG_RESULT($ac_cv_dnet_linux_procfs)
  123. if test $ac_cv_dnet_linux_procfs = yes ; then
  124. AC_DEFINE(HAVE_LINUX_PROCFS, 1,
  125. [Define if you have the Linux /proc filesystem.])
  126. fi])
  127. dnl
  128. dnl Check for Linux PF_PACKET sockets
  129. dnl
  130. dnl usage: AC_DNET_LINUX_PF_PACKET
  131. dnl results: HAVE_LINUX_PF_PACKET
  132. dnl
  133. AC_DEFUN([AC_DNET_LINUX_PF_PACKET],
  134. [AC_MSG_CHECKING(for Linux PF_PACKET sockets)
  135. AC_CACHE_VAL(ac_cv_dnet_linux_pf_packet,
  136. if test -f /usr/include/netpacket/packet.h ; then
  137. ac_cv_dnet_linux_pf_packet=yes
  138. else
  139. ac_cv_dnet_linux_pf_packet=no
  140. fi)
  141. AC_MSG_RESULT($ac_cv_dnet_linux_pf_packet)
  142. if test $ac_cv_dnet_linux_pf_packet = yes ; then
  143. AC_DEFINE(HAVE_LINUX_PF_PACKET, 1,
  144. [Define if you have Linux PF_PACKET sockets.])
  145. fi])
  146. dnl
  147. dnl Check for SNMP MIB2 STREAMS (Solaris only?)
  148. dnl
  149. dnl usage: AC_DNET_STREAMS_MIB2
  150. dnl results: HAVE_STREAMS_MIB2
  151. dnl
  152. AC_DEFUN([AC_DNET_STREAMS_MIB2],
  153. [AC_MSG_CHECKING(for SNMP MIB2 STREAMS)
  154. AC_CACHE_VAL(ac_cv_dnet_streams_mib2,
  155. if test -f /usr/include/inet/mib2.h -a -c /dev/ip ; then
  156. ac_cv_dnet_streams_mib2=yes
  157. else
  158. ac_cv_dnet_streams_mib2=no
  159. fi)
  160. AC_MSG_RESULT($ac_cv_dnet_streams_mib2)
  161. if test $ac_cv_dnet_streams_mib2 = yes ; then
  162. AC_DEFINE(HAVE_STREAMS_MIB2, 1,
  163. [Define if you have SNMP MIB2 STREAMS.])
  164. fi])
  165. dnl
  166. dnl Check for route(7) STREAMS (UnixWare only?)
  167. dnl
  168. dnl usage: AC_DNET_STREAMS_ROUTE
  169. dnl results: HAVE_STREAMS_ROUTE
  170. dnl
  171. AC_DEFUN([AC_DNET_STREAMS_ROUTE],
  172. [AC_MSG_CHECKING(for route(7) STREAMS)
  173. AC_CACHE_VAL(ac_cv_dnet_streams_route,
  174. if grep RTSTR_SEND /usr/include/net/route.h >/dev/null 2>&1 ; then
  175. ac_cv_dnet_streams_route=yes
  176. else
  177. ac_cv_dnet_streams_route=no
  178. fi)
  179. AC_MSG_RESULT($ac_cv_dnet_streams_route)
  180. if test $ac_cv_dnet_streams_route = yes ; then
  181. AC_DEFINE(HAVE_STREAMS_ROUTE, 1,
  182. [Define if you have route(7) STREAMS.])
  183. fi])
  184. dnl
  185. dnl Check for arp(7) ioctls
  186. dnl
  187. dnl usage: AC_DNET_IOCTL_ARP
  188. dnl results: HAVE_IOCTL_ARP
  189. dnl
  190. AC_DEFUN([AC_DNET_IOCTL_ARP],
  191. [AC_MSG_CHECKING(for arp(7) ioctls)
  192. AC_CACHE_VAL(ac_cv_dnet_ioctl_arp,
  193. AC_EGREP_CPP(werd, [
  194. # include <sys/types.h>
  195. # define BSD_COMP
  196. # include <sys/ioctl.h>
  197. # ifdef SIOCGARP
  198. werd
  199. # endif],
  200. ac_cv_dnet_ioctl_arp=yes,
  201. ac_cv_dnet_ioctl_arp=no))
  202. case "$host_os" in
  203. irix*)
  204. ac_cv_dnet_ioctl_arp=no ;;
  205. esac
  206. AC_MSG_RESULT($ac_cv_dnet_ioctl_arp)
  207. if test $ac_cv_dnet_ioctl_arp = yes ; then
  208. AC_DEFINE(HAVE_IOCTL_ARP, 1,
  209. [Define if you have arp(7) ioctls.])
  210. fi])
  211. dnl
  212. dnl Check for raw IP sockets ip_{len,off} host byte ordering
  213. dnl
  214. dnl usage: AC_DNET_RAWIP_HOST_OFFLEN
  215. dnl results: HAVE_RAWIP_HOST_OFFLEN
  216. dnl
  217. AC_DEFUN([AC_DNET_RAWIP_HOST_OFFLEN],
  218. [AC_MSG_CHECKING([for raw IP sockets ip_{len,off} host byte ordering])
  219. AC_CACHE_VAL(ac_cv_dnet_rawip_host_offlen, [
  220. case "$host_os" in
  221. *openbsd*)
  222. ac_cv_dnet_rawip_host_offlen=no ;;
  223. *bsd*|*osf*|*unixware*)
  224. ac_cv_dnet_rawip_host_offlen=yes ;;
  225. *)
  226. ac_cv_dnet_rawip_host_offlen=no ;;
  227. esac])
  228. AC_MSG_RESULT($ac_cv_dnet_rawip_host_offlen)
  229. if test $ac_cv_dnet_rawip_host_offlen = yes ; then
  230. AC_DEFINE(HAVE_RAWIP_HOST_OFFLEN, 1,
  231. [Define if raw IP sockets require host byte ordering for ip_off, ip_len.])
  232. fi])
  233. dnl
  234. dnl Check for cooked raw IP sockets
  235. dnl
  236. dnl usage: AC_DNET_RAWIP_COOKED
  237. dnl results: HAVE_RAWIP_COOKED
  238. dnl
  239. AC_DEFUN([AC_DNET_RAWIP_COOKED],
  240. [AC_MSG_CHECKING(for cooked raw IP sockets)
  241. AC_CACHE_VAL(ac_cv_dnet_rawip_cooked, [
  242. case "$host_os" in
  243. solaris*|irix*)
  244. ac_cv_dnet_rawip_cooked=yes ;;
  245. *)
  246. ac_cv_dnet_rawip_cooked=no ;;
  247. esac])
  248. AC_MSG_RESULT($ac_cv_dnet_rawip_cooked)
  249. if test $ac_cv_dnet_rawip_cooked = yes ; then
  250. AC_DEFINE(HAVE_RAWIP_COOKED, 1,
  251. [Define if you have cooked raw IP sockets.])
  252. fi])
  253. dnl
  254. dnl AC_LBL_LIBRARY_NET
  255. dnl
  256. dnl This test is for network applications that need socket() and
  257. dnl gethostbyname() -ish functions. Under Solaris, those applications
  258. dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
  259. dnl with "-lnsl" but should *not* link with "-lsocket" because
  260. dnl libsocket.a breaks a number of things (for instance:
  261. dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
  262. dnl versions of IRIX).
  263. dnl
  264. dnl Unfortunately, many application developers are not aware of this,
  265. dnl and mistakenly write tests that cause -lsocket to be used under
  266. dnl IRIX. It is also easy to write tests that cause -lnsl to be used
  267. dnl under operating systems where neither are necessary (or useful),
  268. dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
  269. dnl
  270. dnl This test exists so that every application developer does not test
  271. dnl this in a different, and subtly broken fashion.
  272. dnl It has been argued that this test should be broken up into two
  273. dnl seperate tests, one for the resolver libraries, and one for the
  274. dnl libraries necessary for using Sockets API. Unfortunately, the two
  275. dnl are carefully intertwined and allowing the autoconf user to use
  276. dnl them independantly potentially results in unfortunate ordering
  277. dnl dependancies -- as such, such component macros would have to
  278. dnl carefully use indirection and be aware if the other components were
  279. dnl executed. Since other autoconf macros do not go to this trouble,
  280. dnl and almost no applications use sockets without the resolver, this
  281. dnl complexity has not been implemented.
  282. dnl
  283. dnl The check for libresolv is in case you are attempting to link
  284. dnl statically and happen to have a libresolv.a lying around (and no
  285. dnl libnsl.a).
  286. dnl
  287. AC_DEFUN([AC_LBL_LIBRARY_NET], [
  288. # Most operating systems have gethostbyname() in the default searched
  289. # libraries (i.e. libc):
  290. AC_CHECK_FUNC(gethostbyname, ,
  291. # Some OSes (eg. Solaris) place it in libnsl:
  292. AC_CHECK_LIB(nsl, gethostbyname, ,
  293. # Some strange OSes (SINIX) have it in libsocket:
  294. AC_CHECK_LIB(socket, gethostbyname, ,
  295. # Unfortunately libsocket sometimes depends on libnsl.
  296. # AC_CHECK_LIB's API is essentially broken so the
  297. # following ugliness is necessary:
  298. AC_CHECK_LIB(socket, gethostbyname,
  299. LIBS="-lsocket -lnsl $LIBS",
  300. AC_CHECK_LIB(resolv, gethostbyname),
  301. -lnsl))))
  302. AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
  303. AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
  304. -lnsl)))
  305. # DLPI needs putmsg under HPUX so test for -lstr while we're at it
  306. AC_CHECK_LIB(str, putmsg)
  307. ])