aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSUZUKI, Shinsuke <suz@kame.net>2006-12-04 15:18:39 +0000
committerBjørn Mork <bjorn@mork.no>2010-08-06 15:37:36 +0200
commitb73261b6f5f0dbb2c0fee2c52278dfbd0ee4aba3 (patch)
tree76254482d4374ed22b5785a9a70bd10045c390fd
parent11a1e58f11dfef67d01aebf89232f93f12207bc0 (diff)
introduced a HAVE_SA_LEN macro to support OSes (other than linux) without length field in sockaddr_*
-rw-r--r--CHANGES5
-rw-r--r--addrconf.c2
-rw-r--r--common.c6
-rw-r--r--common.h2
-rwxr-xr-xconfigure68
-rw-r--r--configure.in15
-rw-r--r--dhcp6relay.c2
-rw-r--r--prefixconf.c2
8 files changed, 95 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index 6c3d134..f8117b7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+2006-12-04 SUZUKI, Shinsuke <suz@kame.net>
+ * addrconf.c, common.[ch], configure, configure.in, dhcp6relay.c,
+ prefixconf.c: introduced a HAVE_SA_LEN macro to support OSes
+ (other than linux) without length field in sockaddr_*
+
2006-11-15 SUZUKI, Shinsuke <suz@kame.net>
* dhcp6s.c: fixed an IA allocation failure from pool when it doubly
requested by the same client. (patch submitted by Hajimu UMEMOTO)
diff --git a/addrconf.c b/addrconf.c
index c8e0fc9..dfc560e 100644
--- a/addrconf.c
+++ b/addrconf.c
@@ -383,7 +383,7 @@ na_ifaddrconf(cmd, sa)
addr = &sa->addr;
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
-#ifndef __linux__
+#ifdef HAVE_SA_LEN
sin6.sin6_len = sizeof(sin6);
#endif
sin6.sin6_addr = addr->addr;
diff --git a/common.c b/common.c
index c58460b..698c716 100644
--- a/common.c
+++ b/common.c
@@ -703,7 +703,7 @@ getifaddr(addr, ifnam, prefix, plen, strong, ignoreflags)
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
-#ifndef __linux__
+#ifdef HAVE_SA_LEN
if (ifa->ifa_addr->sa_len > sizeof(sin6))
continue;
#endif
@@ -868,7 +868,7 @@ sa6_plen2mask(sa6, plen)
memset(sa6, 0, sizeof(*sa6));
sa6->sin6_family = AF_INET6;
-#ifndef __linux__
+#ifdef HAVE_SA_LEN
sa6->sin6_len = sizeof(*sa6);
#endif
@@ -905,7 +905,7 @@ in6addr2str(in6, scopeid)
memset(&sa6, 0, sizeof(sa6));
sa6.sin6_family = AF_INET6;
-#ifndef __linux__
+#ifdef HAVE_SA_LEN
sa6.sin6_len = sizeof(sa6);
#endif
sa6.sin6_addr = *in6;
diff --git a/common.h b/common.h
index c10b65d..ca68f54 100644
--- a/common.h
+++ b/common.h
@@ -103,7 +103,7 @@
static __inline u_int8_t
sysdep_sa_len (const struct sockaddr *sa)
{
-#ifdef __linux__
+#ifndef HAVE_SA_LEN
switch (sa->sa_family)
{
case AF_INET:
diff --git a/configure b/configure
index 14d0326..2a39af4 100755
--- a/configure
+++ b/configure
@@ -5397,6 +5397,74 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext;
fi
+echo "$as_me:$LINENO: checking if you have a length field in struct sockaddr*" >&5
+echo $ECHO_N "checking if you have a length field in struct sockaddr*... $ECHO_C" >&6
+if test "${ts_cv_sa_len+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include <sys/types.h>
+ #include <sys/socket.h>
+
+int
+main ()
+{
+
+ struct sockaddr a;
+ a.sa_len = 1;
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ts_cv_sa_len="yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ts_cv_sa_len="no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: result: $ts_cv_sa_len" >&5
+echo "${ECHO_T}$ts_cv_sa_len" >&6;
+if test "$ts_cv_sa_len" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SA_LEN 1
+_ACEOF
+
+fi
+
for ac_header in stdarg.h
do
diff --git a/configure.in b/configure.in
index 19e8d38..1a3c59a 100644
--- a/configure.in
+++ b/configure.in
@@ -187,6 +187,21 @@ if test $tailq_foreach = yes ; then
AC_DEFINE(HAVE_TAILQ_FOREACH_REVERSE_OLD)]);
fi
+dnl Checks for other features
+AC_MSG_CHECKING(if you have a length field in struct sockaddr*)
+AC_CACHE_VAL(ts_cv_sa_len, [dnl
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ ], [
+ struct sockaddr a;
+ a.sa_len = 1;
+ ], [ts_cv_sa_len="yes"], [ts_cv_sa_len="no"])])
+AC_MSG_RESULT($ts_cv_sa_len);
+if test "$ts_cv_sa_len" = yes; then
+ AC_DEFINE([HAVE_SA_LEN], 1, [Define to 1 if you have a length field in struct sockaddr])
+fi
+
AC_CHECK_HEADERS(stdarg.h)
AC_OUTPUT(Makefile)
diff --git a/dhcp6relay.c b/dhcp6relay.c
index 738074a..e05a47c 100644
--- a/dhcp6relay.c
+++ b/dhcp6relay.c
@@ -270,7 +270,7 @@ make_prefix(pstr0)
/* fill in each member of the entry */
memset(pent, 0, sizeof (*pent));
pent->paddr.sin6_family = AF_INET6;
-#ifndef __linux__
+#ifdef HAVE_SA_LEN
pent->paddr.sin6_len = sizeof (struct sockaddr_in6);
#endif
pent->paddr.sin6_addr = paddr;
diff --git a/prefixconf.c b/prefixconf.c
index 3fc0358..ace6ade 100644
--- a/prefixconf.c
+++ b/prefixconf.c
@@ -447,7 +447,7 @@ add_ifprefix(siteprefix, prefix, pconf)
ifpfx->ifconf = pconf;
ifpfx->paddr.sin6_family = AF_INET6;
-#ifndef __linux__
+#ifdef HAVE_SA_LEN
ifpfx->paddr.sin6_len = sizeof(struct sockaddr_in6);
#endif
ifpfx->paddr.sin6_addr = prefix->addr;