# -*- autoconf -*- ######################################### ## # Miscellaneous Operating-System characteristics ## ######################################### # Determine how to test for character devices # [We assume that /dev/null does actually exist!] # if test -c /dev/null; then CDEV_TEST_FLAG="-c" elif test -f /dev/null; then CDEV_TEST_FLAG="-f" else AC_MSG_WARN([Can't reliably detect character devices]) # Is it actually sensible to fall back on "test -f" ? CDEV_TEST_FLAG="-f" fi # Kernel Location # used in library/agent # AC_CACHE_CHECK([for location of system kernel], ac_cv_KERNEL_LOC, [ac_cv_KERNEL_LOC="unknown" for i in /vmunix /hp-ux /stand/vmunix /dev/ksyms /kernel/unix /kernel/genunix /netbsd /unix /kernel /bsd /mach_kernel /boot/kernel/kernel do if test $CDEV_TEST_FLAG $i; then ac_cv_KERNEL_LOC="$i" break; fi done # # In principle, this test is meant to provide a default path to the kernel # In practice, the test is broken and the kernel path is set to "unknown" # # Note that on certain systems (e.g. some Linux distributions), # it is impossible to predict the name of the kernel, # particularly if it includes the kernel version, architecture, etc # # Since this default will never actually be used, then don't try to set it # if test $i = "unknown"; then AC_MSG_WARN([Can't find system kernel... hopefully this won't be needed!]) fi ]) AC_DEFINE_UNQUOTED(KERNEL_LOC,"$ac_cv_KERNEL_LOC", [location of UNIX kernel]) # /dev/kmem existence # used in agent only # AC_CACHE_CHECK([for /dev/kmem], ac_cv_HAVE_KMEM, [if test $CDEV_TEST_FLAG /dev/kmem; then ac_cv_HAVE_KMEM="/dev/kmem" fi ]) # # Note that it's OK if this device is not found # if test "x$ac_cv_HAVE_KMEM" = "x/dev/kmem"; then AC_DEFINE_UNQUOTED(HAVE_KMEM,"$ac_cv_HAVE_KMEM", [Define if you have /dev/kmem]) fi # Swap device Location # (/dev/dmem or /dev/drum) # used in agent only # AC_CACHE_CHECK([for location of swap device], ac_cv_DMEM_LOC, [if test $CDEV_TEST_FLAG /dev/dmem; then ac_cv_DMEM_LOC="/dev/dmem" elif test $CDEV_TEST_FLAG /dev/drum; then ac_cv_DMEM_LOC="/dev/drum" else ac_cv_DMEM_LOC="none" fi ]) # # Note that it's OK if this device is not found # if test "x$ac_cv_DMEM_LOC" != "xnone"; then AC_DEFINE_UNQUOTED(DMEM_LOC,"$ac_cv_DMEM_LOC", [location of swap device]) fi # Mount table Location # used in agent only # AC_CACHE_CHECK([for mount table location], ac_cv_ETC_MNTTAB, [ac_cv_ETC_MNTTAB="${with_mnttab:-unknown}" if test "$ac_cv_ETC_MNTTAB" = "unknown"; then for i in /etc/mnttab /etc/mtab /etc/filesystems /dev/mnttab do if test -f $i -o -c $i; then ac_cv_ETC_MNTTAB="$i" break; fi done fi ]) AC_DEFINE_UNQUOTED(ETC_MNTTAB,"$ac_cv_ETC_MNTTAB", [location of mount table list]) # Printing # used in agent only # AC_PATH_PROG([LPSTAT_PATH],lpstat) if test x$LPSTAT_PATH != x; then AC_DEFINE_UNQUOTED(LPSTAT_PATH, "$LPSTAT_PATH", [Path to the lpstat command]) AC_DEFINE(HAVE_LPSTAT, 1, [Set if the lpstat command is available]) fi if test -r /etc/printcap; then AC_DEFINE(HAVE_PRINTCAP, 1, [Set if /etc/printcap exists]) fi # Check ps args # used in agent only # AC_CACHE_CHECK([for correct flags to ps], ac_cv_ps_flags, [ if test "`($PSPROG -e 2>&1) | $EGREP ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then ac_cv_ps_flags="-e" elif test "`($PSPROG -el 2>&1) | $EGREP ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then ac_cv_ps_flags="-el" elif test "`($PSPROG acx 2>&1) | $EGREP ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then ac_cv_ps_flags="acx" elif test "`($PSPROG -acx 2>&1) | $EGREP ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then ac_cv_ps_flags="-acx" elif test "`($PSPROG -o pid,tt,state,time,ucomm 2>&1) | $EGREP ' ps *$' | awk '{print $NF}'`" = "ps" ; then ac_cv_ps_flags="-o pid,tt,state,time,ucomm" elif test "`($PSPROG ax 2>&1) | $EGREP ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then ac_cv_ps_flags="ax" elif test "x$PARTIALTARGETOS" = "xcygwin"; then ac_cv_ps_flags="-e" elif test "x$PARTIALTARGETOS" = "xmingw32" -o "x$PARTIALTARGETOS" = "xmingw32msvc"; then ac_cv_ps_flags="-e" else AC_MSG_WARN([Unable to determine valid ps flags... defaulting...]) ac_cv_ps_flags="-acx" fi ]) PSCMD="$PSPROG $ac_cv_ps_flags" AC_SUBST(PSCMD) AC_DEFINE_UNQUOTED(PSCMD, "$PSPROG $ac_cv_ps_flags", [Command to generate ps output, the final column must be the process name withOUT arguments]) ## # System/Compilation-related ## # Test for SIGHUP # AC_MSG_CHECKING([for SIGHUP]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([#include ], [return SIGHUP])], [netsnmp_have_sighup=yes], [netsnmp_have_sighup=no] ) AC_MSG_RESULT([$netsnmp_have_sighup]) if test "x$netsnmp_have_sighup" = xyes; then AC_DEFINE([HAVE_SIGHUP], [1], [Define if SIGHUP is defined in .]) fi # Check whether sysctl() is usable # used in library/agent # if test $cross_compiling = yes; then AC_MSG_WARN([Can't check sysctl, manually define NETSNMP_CAN_USE_SYSCTL if platform support available]) else AC_CACHE_CHECK([if sysctl can read kernel information], ac_cv_NETSNMP_CAN_USE_SYSCTL, [AC_TRY_RUN([ #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #if HAVE_SYS_PARAM_H # include #endif #include #if HAVE_SYS_SYSCTL_H # include #endif main() { int mib[2]; size_t len; struct timeval boottime; mib[0] = CTL_KERN; mib[1] = KERN_BOOTTIME; len = sizeof(boottime); sysctl(mib, 2, &boottime, &len, NULL, NULL); if (boottime.tv_sec != 0) exit(0); else exit(1); } ], ac_cv_NETSNMP_CAN_USE_SYSCTL=yes, ac_cv_NETSNMP_CAN_USE_SYSCTL=no, ac_cv_NETSNMP_CAN_USE_SYSCTL=no)]) fi if test "x$ac_cv_NETSNMP_CAN_USE_SYSCTL" = "xyes"; then AC_DEFINE(NETSNMP_CAN_USE_SYSCTL, 1, [sysctl works to get boottime, etc...]) fi # Check whether TCP timer constants are indeed constant # or depend on the kernel clock tick 'hz'. (FreeBSD 4.x) # # If the latter, then we will need to have a local # variable 'hz' defined and with a suitable value, # whenever we want to use one one of these 'constants'. # # used in agent only # AC_CACHE_CHECK([whether TCP timers depend on 'hz'], ac_cv_TCPTV_NEEDS_HZ, [AC_EGREP_CPP(hz, [ #include TCPTV_SRTTDFLT ], ac_cv_TCPTV_NEEDS_HZ=yes, ac_cv_TCPTV_NEEDS_HZ=no)]) if test "x$ac_cv_TCPTV_NEEDS_HZ" = "xyes"; then AC_DEFINE(TCPTV_NEEDS_HZ, 1, [Define if the TCP timer constants in depend on the integer variable 'hz'. @<:@FreeBSD 4.x@:>@]) fi # Check whether IP Route table is cached (Solaris) # used in agent only # case $target_os in solaris*) # Header checks (Solaris 2.6/7) # AC_CHECK_HEADERS(inet/common.h) AC_CHECK_HEADERS(inet/ip.h,ac_inet_ip_h=yes,ac_inet_ip_h=no, AC_INCLUDES_DEFAULT([]) [ #if HAVE_SYS_STREAM_H #include #endif #if HAVE_INET_COMMON_H #include #endif ]) if test $ac_inet_ip_h = yes ; then AC_CACHE_CHECK([for mib2_ipRouteEntry_t in inet/mib2.h], ac_cv_mib2_ipRouteEntry_t, [AC_TRY_COMPILE([ #if HAVE_INET_MIB2_H #include #endif ],[ mib2_ipRouteEntry_t testit; if(sizeof(testit)) return(0); ], ac_cv_mib2_ipRouteEntry_t=yes, ac_cv_mib2_ipRouteEntry_t=no)]) if test "x$ac_cv_mib2_ipRouteEntry_t" = "xyes" ; then AC_CACHE_CHECK([whether IRE_CACHE is defined in inet/ip.h], ac_cv_ire_cache, [AC_TRY_COMPILE([ #if HAVE_INET_IP_H #include #endif ],[ int testit=IRE_CACHE; if(testit) return(0); ], ac_cv_ire_cache=yes, ac_cv_ire_cache=no)]) else ac_cv_ire_cache=no fi if test "x$ac_cv_ire_cache" = "xyes" ; then AC_DEFINE(HAVE_DEFINED_IRE_CACHE,[], [define to 1 if you have IRE_CACHE defined in header file.]) else AC_MSG_WARN([It seems that you have inet/ip.h, but IRE_CACHE is not defined. \ That means that your query to ipRoute MIB could generate over 20k results! \ And this can be very slow.]) fi fi # "test $ac_inet_ip_h = yes" ;; esac # Check whether IP_PKTINFO is usable. # AC_CACHE_CHECK([for IP_PKTINFO ], [ac_cv_have_ip_pktinfo], [AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include /* printf() */ #include /* malloc() */ #include /* memset() */ #include #include #include ], [ void *buf; int len; void *from; socklen_t *fromlen; struct iovec iov; char *cmsg = malloc(CMSG_SPACE(sizeof(struct in_pktinfo))); struct cmsghdr *cm; struct msghdr msg; iov.iov_base = buf; iov.iov_len = len; memset(&msg, 0, sizeof msg); msg.msg_name = from; msg.msg_namelen = *fromlen; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = &cmsg; msg.msg_controllen = sizeof(cmsg); for (cm = CMSG_FIRSTHDR(&msg); cm; cm = CMSG_NXTHDR(&msg, cm)) { if (cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_PKTINFO) { struct in_pktinfo* src = (struct in_pktinfo *)CMSG_DATA(cm); printf("Address: %s; index: %d\n", inet_ntoa(src->ipi_addr), src->ipi_ifindex); } } ])], [ac_cv_have_ip_pktinfo=yes], [ac_cv_have_ip_pktinfo=no] )]) if test x$ac_cv_have_ip_pktinfo = xyes; then AC_DEFINE(HAVE_IP_PKTINFO, 1, [Set if IP_PKTINFO is usable]) fi # Check whether IP_RECVDSTADDR is usable. # AC_CACHE_CHECK([for IP_RECVDSTADDR ], [ac_cv_have_ip_recvdstaddr], [AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include /* printf() */ #include /* malloc() */ #include /* memset() */ #include #include #include ], [ void *buf; int len; void *from; socklen_t *fromlen; struct iovec iov; char *cmsg = malloc(CMSG_SPACE(sizeof(struct in_addr))); struct cmsghdr *cm; struct msghdr msg; iov.iov_base = buf; iov.iov_len = len; memset(&msg, 0, sizeof msg); msg.msg_name = from; msg.msg_namelen = *fromlen; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = &cmsg; msg.msg_controllen = sizeof(cmsg); for (cm = CMSG_FIRSTHDR(&msg); cm; cm = CMSG_NXTHDR(&msg, cm)) { if (cm->cmsg_level == IPPROTO_IP && cm->cmsg_type == IP_RECVDSTADDR) { struct in_addr* src = (struct in_addr *)CMSG_DATA(cm); printf("Address: %s\n", inet_ntoa(src)); } } ])], [ac_cv_have_ip_recvdstaddr=yes], [ac_cv_have_ip_recvdstaddr=no] )]) if test x$ac_cv_have_ip_recvdstaddr = xyes; then AC_DEFINE(HAVE_IP_RECVDSTADDR, 1, [Set if IP_RECVDSTADDR is usable]) fi