length of the struct. Often, sizeof(struct sockaddr) is not equal to
sockaddr.sa_len. Unfortunately, this effects the side of structures
containing sockaddrs, like struct ifreq. The size of an ifreq is,
under BSD 4.4, max(sizeof(struct ifreq),
sizeof(ifreq.ifr_name)+ifreq.ifr_caddr.sa_len). To get
krb5_xcrypto_os_localaddr to work under NetBSD and other 4.4-based
systems, the following changes were made:
* aclocal.m4: Ad KRB5_SOCKADDR_SA_LEN to determine if there appears
to be a sa_len element of struct sockaddr.
* lib/crypto/os/configure.in: use this test
* lib/crypto/os/localaddr.c: Deal with size changes if appropriate.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6310
dc483132-0cff-0310-8789-
dd5450dbe970
+Sun Jul 16 05:02:41 1995 Sam Hartman <hartmans@tertius.mit.edu>
+
+ * aclocal.m4 : Defined KRB5_SOCKADDR_SA_LEN, a test to determine
+ if sockaddr has the sa_len field.
Wed Jul 12 11:47:43 EDT 1995 Paul Park (pjpark@mit.edu)
* aclocal.m4 - Add LDFLAGS setting to KRB5_LIBRARIES. This allows
],
CONF_FRAGDIR=$srcdir/${ac_config_fragdir} )])dnl
dnl
+dnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len
+dnl component
+dnl
+AC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl
+AC_MSG_CHECKING(Whether struct sockaddr contains sa_len)
+AC_CACHE_VAL(krb5_cv_sockaddr_sa_len,
+[AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>
+],
+[struct sockaddr sa;
+sa.sa_len;],
+krb5_cv_sockaddr_sa_len=yes,krb5_cv_sockaddr_sa_len=no)])
+AC_MSG_RESULT([$]krb5_cv_sockaddr_sa_len)
+if $krb5_cv_sockaddr_sa_len= yes; then
+ AC_DEFINE_UNQUOTED(HAVE_SA_LEN)
+ fi
+])
+dnl
+dnl
dnl CHECK_UTMP: check utmp structure and functions
dnl
define(CHECK_UTMP,[
+Mon Jul 17 16:04:00 1995 Sam Hartman <hartmans@tertius.mit.edu>
+
+ * localaddr.c (krb5_crypto_os_localaddr): Deal with variable sized
+ ifreq structures if sockaddr contains sa_len field.
+
+ * configure.in: Check to see if struct sockaddr has sa_len.
+
Thu Jul 6 17:13:11 1995 Tom Yu <tlyu@lothlorien.MIT.EDU>
* localaddr.c: migrated from lib/krb5/os
AC_LN_S
AC_REPLACE_FUNCS(memmove)
AC_HAVE_FUNCS(srand48 srand srandom getpid)
+KRB5_SOCKADDR_SA_LEN
V5_AC_OUTPUT_MAKEFILE
* Add more address families here.
*/
+/*
+ * BSD 4.4 defines the size of an ifreq to be max(sizeof(ifreq), sizeof(ifr.ifr_name)+ifreq.ifr_ifr_addr.sa_len
+ * However, under earlier systems, sa_len isn't present, so the size is
+ * just sizeof(struct ifreq)
+ */
+#ifdef HAVE_SA_LEN
+#define ifreq_size(i) max(sizeof(struct ifreq),\
+ sizeof(i.ifr_name)+i.ifr_addr.sa_len)
+#else
+#define ifreq_size(i) sizeof(struct ifreq)
+#endif /* HAVE_SA_LEN*/
+
+
+
extern int errno;
/*
closesocket (s);
return retval;
}
- n = ifc.ifc_len / sizeof (struct ifreq);
+ n = ifc.ifc_len;
- for (n_found=0, i=0; i<n && ! mem_err; i++) {
+n_found = 0;
+ for (i = 0; i < n; i+= ifreq_size(*ifr) ) {
krb5_address *address;
- ifr = &ifc.ifc_req[i];
+ ifr = (struct ifreq *)((caddr_t) ifc.ifc_buf+i);
if (ioctl (s, SIOCGIFFLAGS, (char *)ifr) < 0)
continue;