From: Florian Forster Date: Mon, 5 Apr 2010 14:22:30 +0000 (+0200) Subject: Build system: Check for the "if_indextoname" function. X-Git-Tag: collectd-4.10.0~23 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b6d95bf9f5713c62286851c1782ac95b2eb2fa21;p=collectd.git Build system: Check for the "if_indextoname" function. Use this information rather than hard-coding "if Linux …" --- diff --git a/configure.in b/configure.in index b5ce7812..f3206cb6 100644 --- a/configure.in +++ b/configure.in @@ -477,7 +477,7 @@ AC_HEADER_TIME # Checks for library functions. # AC_PROG_GCC_TRADITIONAL -AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf) +AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf if_indextoname) AC_FUNC_STRERROR_R diff --git a/src/network.c b/src/network.c index 6d0381b7..9cb8c38e 100644 --- a/src/network.c +++ b/src/network.c @@ -1653,7 +1653,7 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai } } -#if KERNEL_LINUX +#if defined(HAVE_IF_INDEXTONAME) && HAVE_IF_INDEXTONAME && defined(SO_BINDTODEVICE) if (se->interface != 0) { char interface_name[IFNAMSIZ]; @@ -1673,7 +1673,7 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai return (-1); } } -#endif +#endif /* HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */ return (0); } /* }}} network_set_interface */ @@ -1798,7 +1798,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int } } -#if KERNEL_LINUX +#if defined(HAVE_IF_INDEXTONAME) && HAVE_IF_INDEXTONAME && defined(SO_BINDTODEVICE) /* if a specific interface was set, bind the socket to it. But to avoid * possible problems with multicast routing, only do that for non-multicast * addresses */ @@ -1821,7 +1821,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int return (-1); } } -#endif +#endif /* HAVE_IF_INDEXTONAME && SO_BINDTODEVICE */ return (0); } /* int network_bind_socket */