Просмотр исходного кода

build: make exec/totemip os detection free

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Fabio M. Di Nitto 13 лет назад
Родитель
Сommit
6098ef2c14
2 измененных файлов с 23 добавлено и 21 удалено
  1. 9 1
      configure.ac
  2. 14 20
      exec/totemip.c

+ 9 - 1
configure.ac

@@ -94,7 +94,15 @@ AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdint.h \
 		  stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h \
 		  sys/time.h syslog.h unistd.h sys/types.h getopt.h malloc.h \
-		  sys/sockio.h utmpx.h ifaddrs.h stddef.h sys/file.h])
+		  sys/sockio.h utmpx.h ifaddrs.h stddef.h sys/file.h \
+		  net/if_var.h netinet/in_var.h netinet/in.h])
+
+AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
+		[AC_DEFINE_UNQUOTED([HAVE_SOCK_SIN_LEN], [1], [sockaddr_in needs sin_len])],
+		[], [[#include <netinet/in.h>]])
+AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
+		[AC_DEFINE_UNQUOTED([HAVE_SOCK_SIN6_LEN], [1], [sockaddr_in6 needs sin6_len])],
+		[], [[#include <netinet/in.h>]])
 
 # Checks for typedefs.
 AC_TYPE_UID_T

+ 14 - 20
exec/totemip.c

@@ -43,32 +43,26 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#if defined(COROSYNC_SOLARIS)
 #include <net/if.h>
-#include <sys/sockio.h>
-#endif
-#if defined(COROSYNC_BSD) || defined(COROSYNC_DARWIN)
-#include <sys/sockio.h>
-#include <net/if.h>
-#include <net/if_var.h>
-#include <netinet/in_var.h>
-#include <netinet/in.h>
-#include <ifaddrs.h>
-#endif
 #include <string.h>
 #include <stdio.h>
 #include <errno.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
-
-#if defined(COROSYNC_LINUX)
-#include <net/if.h>
-#include <asm/types.h>
-#include <linux/rtnetlink.h>
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
 #endif
-
-#ifdef HAVE_GETIFADDRS
+#ifdef HAVE_NET_IF_VAR_H
+#include <net/if_var.h>
+#endif
+#ifdef HAVE_NETINET_IN_VAR_H
+#include <netinet/in_var.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_IFADDRS_H
 #include <ifaddrs.h>
 #endif
 
@@ -249,7 +243,7 @@ int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,
 		struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
 
 		memset(sin, 0, sizeof(struct sockaddr_in));
-#if defined(COROSYNC_BSD) || defined(COROSYNC_DARWIN)
+#ifdef HAVE_SOCK_SIN_LEN
 		sin->sin_len = sizeof(struct sockaddr_in);
 #endif
 		sin->sin_family = ip_addr->family;
@@ -263,7 +257,7 @@ int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,
 		struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr;
 
 		memset(sin, 0, sizeof(struct sockaddr_in6));
-#if defined(COROSYNC_BSD) || defined(COROSYNC_DARWIN)
+#ifdef HAVE_SOCK_SIN6_LEN
 		sin->sin6_len = sizeof(struct sockaddr_in6);
 #endif
 		sin->sin6_family = ip_addr->family;