fi
dnl
AC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl
-AC_ARG_ENABLE([ipv6], , AC_MSG_WARN(enable/disable-ipv6 option is deprecated))dnl
-AC_MSG_CHECKING(for IPv6 compile-time support)
+AC_MSG_CHECKING(for IPv6 compile-time support without -DINET6)
AC_CACHE_VAL(krb5_cv_inet6,[
if test "$ac_cv_func_inet_ntop" != "yes" ; then
krb5_cv_inet6=no
if test "$krb5_cv_inet6_with_dinet6" = yes; then
AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX])
fi
- AC_DEFINE(KRB5_USE_INET6,1,[Define if we should compile in IPv6 support (even if we can't use it at run time)])
fi
])dnl
dnl
memcpy (&sinp->sin_addr, a->contents, 4);
}
break;
-#ifdef KRB5_USE_INET6
case ADDRTYPE_INET6:
if (a->length != 16)
goto broken;
memcpy (&sin6p->sin6_addr, a->contents, 16);
}
break;
-#endif
default:
printf(_("unknown addrtype %d"), a->addrtype);
return;
# define AI_DEFAULT (AI_ADDRCONFIG|AI_V4MAPPED)
#endif
-#if defined(KRB5_USE_INET6) && defined(NEED_INSIXADDR_ANY)
+#if defined(NEED_INSIXADDR_ANY)
/* If compiling with IPv6 support and C library does not define in6addr_any */
extern const struct in6_addr krb5int_in6addr_any;
#undef in6addr_any
Do NOT install this file. */
-/* for HAVE_SOCKLEN_T, KRB5_USE_INET6, etc */
+/* for HAVE_SOCKLEN_T etc */
#include "autoconf.h"
/* for sockaddr_storage */
#include "port-sockets.h"
{
return (struct sockaddr_in *) (void *) sa;
}
-#ifdef KRB5_USE_INET6
static inline struct sockaddr_in6 *sa2sin6 (struct sockaddr *sa)
{
return (struct sockaddr_in6 *) (void *) sa;
}
-#endif
static inline struct sockaddr *ss2sa (struct sockaddr_storage *ss)
{
return (struct sockaddr *) ss;
{
return (struct sockaddr_in *) ss;
}
-#ifdef KRB5_USE_INET6
static inline struct sockaddr_in6 *ss2sin6 (struct sockaddr_storage *ss)
{
return (struct sockaddr_in6 *) ss;
}
-#endif
#if !defined (socklen)
/* socklen_t socklen (struct sockaddr *) */
# ifdef HAVE_SA_LEN
# define socklen(X) ((X)->sa_len)
# else
-# ifdef KRB5_USE_INET6
-# define socklen(X) ((X)->sa_family == AF_INET6 ? (socklen_t) sizeof (struct sockaddr_in6) : (X)->sa_family == AF_INET ? (socklen_t) sizeof (struct sockaddr_in) : (socklen_t) sizeof (struct sockaddr))
-# else
-# define socklen(X) ((X)->sa_family == AF_INET ? (socklen_t) sizeof (struct sockaddr_in) : (socklen_t) sizeof (struct sockaddr))
-# endif
+# define socklen(X) ((X)->sa_family == AF_INET6 ? (socklen_t) sizeof (struct sockaddr_in6) : (X)->sa_family == AF_INET ? (socklen_t) sizeof (struct sockaddr_in) : (socklen_t) sizeof (struct sockaddr))
# endif
#endif
#define SYS_ERRLIST_DECLARED
/* if __STDC_VERSION__ >= 199901L this shouldn't be needed */
#define inline __inline
-#define KRB5_USE_INET6
#define NEED_INSIXADDR_ANY
#define ENABLE_THREADS
#endif
salen = sizeof(*sin);
break;
}
-#ifdef KRB5_USE_INET6
case ADDRTYPE_INET6: {
struct sockaddr_in6 *sin6 = ss2sin6(&ss);
salen = sizeof(*sin6);
break;
}
-#endif
default: {
struct sockaddr *sa = ss2sa(&ss);
#define max(a, b) ((a) > (b) ? (a) : (b))
#endif
-#ifdef KRB5_USE_INET6
#define ADDRTYPE2FAMILY(X) \
((X) == ADDRTYPE_INET6 ? AF_INET6 : (X) == ADDRTYPE_INET ? AF_INET : -1)
-#else
-#define ADDRTYPE2FAMILY(X) \
- ((X) == ADDRTYPE_INET ? AF_INET : -1)
-#endif
/* RFC 4120: KRB5KDC_ERR_KEY_TOO_WEAK
* RFC 4556: KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED */
case AF_INET:
sa2sin(addr)->sin_port = port;
break;
-#ifdef KRB5_USE_INET6
case AF_INET6:
sa2sin6(addr)->sin6_port = port;
break;
-#endif
default:
break;
}
static int
ipv6_enabled()
{
-#ifdef KRB5_USE_INET6
static int result = -1;
if (result == -1) {
int s;
result = 0;
}
return result;
-#else
- return 0;
-#endif
}
static int
return setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(value));
}
-#if defined(KRB5_USE_INET6) && defined(IPV6_V6ONLY)
+#if defined(IPV6_V6ONLY)
static int
setv6only(int sock, int value)
{
_("Cannot enable SO_REUSEADDR on fd %d"), sock);
}
-#ifdef KRB5_USE_INET6
if (addr->sa_family == AF_INET6) {
#ifdef IPV6_V6ONLY
if (setv6only(sock, 1))
krb5_klog_syslog(LOG_INFO, _("no IPV6_V6ONLY socket option support"));
#endif /* IPV6_V6ONLY */
}
-#endif /* KRB5_USE_INET6 */
if (bind(sock, addr, socklen(addr)) == -1) {
data->retval = errno;
setup_tcp_listener_ports(struct socksetup *data)
{
struct sockaddr_in sin4;
-#ifdef KRB5_USE_INET6
struct sockaddr_in6 sin6;
-#endif
int i, port;
memset(&sin4, 0, sizeof(sin4));
#endif
sin4.sin_addr.s_addr = INADDR_ANY;
-#ifdef KRB5_USE_INET6
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
#ifdef SIN6_LEN
sin6.sin6_len = sizeof(sin6);
#endif
sin6.sin6_addr = in6addr_any;
-#endif
FOREACH_ELT (tcp_port_data, i, port) {
int s4, s6;
return -1;
s6 = -1;
} else {
-#ifndef KRB5_USE_INET6
- abort();
-#else
s4 = s6 = -1;
set_sa_port((struct sockaddr *)&sin6, htons(port));
return -1;
s4 = setup_a_tcp_listener(data, (struct sockaddr *)&sin4);
-#endif /* KRB5_USE_INET6 */
}
/* Sockets are created, prepare to listen on them. */
s4, paddr((struct sockaddr *)&sin4));
}
}
-#ifdef KRB5_USE_INET6
if (s6 >= 0) {
if (add_tcp_listener_fd(data, s6) == NULL) {
close(s6);
krb5_klog_syslog(LOG_INFO,
_("assuming IPv6 socket accepts IPv4"));
}
-#endif
}
return 0;
}
setup_rpc_listener_ports(struct socksetup *data)
{
struct sockaddr_in sin4;
-#ifdef KRB5_USE_INET6
struct sockaddr_in6 sin6;
-#endif
int i;
struct rpc_svc_data svc;
#endif
sin4.sin_addr.s_addr = INADDR_ANY;
-#ifdef KRB5_USE_INET6
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
#ifdef HAVE_SA_LEN
sin6.sin6_len = sizeof(sin6);
#endif
sin6.sin6_addr = in6addr_any;
-#endif
FOREACH_ELT (rpc_svc_data, i, svc) {
int s4;
-#ifdef KRB5_USE_INET6
int s6;
-#endif
set_sa_port((struct sockaddr *)&sin4, htons(svc.port));
s4 = create_server_socket(data, (struct sockaddr *)&sin4, SOCK_STREAM);
krb5_klog_syslog(LOG_INFO, _("listening on fd %d: rpc %s"),
s4, paddr((struct sockaddr *)&sin4));
-#ifdef KRB5_USE_INET6
if (ipv6_enabled()) {
set_sa_port((struct sockaddr *)&sin6, htons(svc.port));
s6 = create_server_socket(data, (struct sockaddr *)&sin6,
krb5_klog_syslog(LOG_INFO, _("listening on fd %d: rpc %s"),
s6, paddr((struct sockaddr *)&sin6));
}
-#endif
}
return 0;
break;
#ifdef AF_INET6
case AF_INET6:
-#ifdef KRB5_USE_INET6
break;
-#else
- {
- static int first = 1;
- if (first) {
- krb5_klog_syslog(LOG_INFO, _("skipping local ipv6 addresses"));
- first = 0;
- }
- return 0;
- }
-#endif
#endif
#ifdef AF_LINK /* some BSD systems, AIX */
case AF_LINK:
faddr->address->contents = (krb5_octet *) &sa2sin(sa)->sin_addr;
faddr->port = ntohs(sa2sin(sa)->sin_port);
break;
-#ifdef KRB5_USE_INET6
case AF_INET6:
if (IN6_IS_ADDR_V4MAPPED(&sa2sin6(sa)->sin6_addr)) {
faddr->address->addrtype = ADDRTYPE_INET;
}
faddr->port = ntohs(sa2sin6(sa)->sin6_port);
break;
-#endif
default:
faddr->address->addrtype = -1;
faddr->address->length = 0;
return r;
}
#endif
-#if defined(KRB5_USE_INET6) && defined(IPV6_PKTINFO) && \
- defined(HAVE_STRUCT_IN6_PKTINFO)
+#if defined(IPV6_PKTINFO) && defined(HAVE_STRUCT_IN6_PKTINFO)
if (cmsgptr->cmsg_level == IPPROTO_IPV6
&& cmsgptr->cmsg_type == IPV6_PKTINFO
&& *tolen >= sizeof(struct sockaddr_in6)) {
msg.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
break;
#endif
-#if defined(KRB5_USE_INET6) && defined(IPV6_PKTINFO) && \
- defined(HAVE_STRUCT_IN6_PKTINFO)
+#if defined(IPV6_PKTINFO) && defined(HAVE_STRUCT_IN6_PKTINFO)
case AF_INET6:
if (fromlen != sizeof(struct sockaddr_in6))
goto use_sendto;
SET (ap->port, ss2sin(a)->sin_port, ADDRTYPE_IPPORT);
SET (ap->addr, ss2sin(a)->sin_addr, ADDRTYPE_INET);
return a;
-#ifdef KRB5_USE_INET6
case AF_INET6:
SET (ap->port, ss2sin6(a)->sin6_port, ADDRTYPE_IPPORT);
if (IN6_IS_ADDR_V4MAPPED (&ss2sin6(a)->sin6_addr)) {
} else
SET (ap->addr, ss2sin6(a)->sin6_addr, ADDRTYPE_INET6);
return a;
-#endif
default:
return 0;
}
for (i = 0, aip = ai; aip; aip = aip->ai_next) {
switch (aip->ai_addr->sa_family) {
case AF_INET:
-#ifdef KRB5_USE_INET6
case AF_INET6:
-#endif
i++;
default:
/* Ignore addresses of unknown families. */
ptr = &((struct sockaddr_in *)aip->ai_addr)->sin_addr;
atype = ADDRTYPE_INET;
break;
-#ifdef KRB5_USE_INET6
case AF_INET6:
addrlen = sizeof (struct in6_addr);
ptr = &((struct sockaddr_in6 *)aip->ai_addr)->sin6_addr;
atype = ADDRTYPE_INET6;
break;
-#endif
default:
continue;
}
*/
-#if defined(__linux__) && defined(KRB5_USE_INET6) && !defined(HAVE_IFADDRS_H)
+#if defined(__linux__) && !defined(HAVE_IFADDRS_H)
#define LINUX_IPV6_HACK
#endif
struct sockaddr_in *s4 = (struct sockaddr_in *)sa;
return s4->sin_addr.s_addr == htonl(INADDR_LOOPBACK);
}
-#ifdef KRB5_USE_INET6
case AF_INET6: {
struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)sa;
return IN6_IS_ADDR_LOOPBACK(&s6->sin6_addr);
}
-#endif
default:
return 0;
}
struct localaddr_data *data = P_data;
switch (a->sa_family) {
case AF_INET:
-#ifdef KRB5_USE_INET6
case AF_INET6:
-#endif
#ifdef KRB5_USE_NS
case AF_XNS:
#endif
data->mem_err++;
break;
-#ifdef KRB5_USE_INET6
case AF_INET6:
{
const struct sockaddr_in6 *in = (const struct sockaddr_in6 *) a;
data->mem_err++;
break;
}
-#endif /* KRB5_USE_INET6 */
#endif /* netinet/in.h */
#ifdef KRB5_USE_NS
#endif
break;
}
-#ifdef KRB5_USE_INET6
case ADDRTYPE_INET6:
{
struct sockaddr_in6 *sin6p = ss2sin6 (&ss);
#endif
break;
}
-#endif
default:
ss2sa(&ss)->sa_family = 0;
break;
return 0;
if (sa->sa_family == AF_INET)
addrlen = sizeof(struct sockaddr_in);
-#ifdef KRB5_USE_INET6
else if (sa->sa_family == AF_INET6)
addrlen = sizeof(struct sockaddr_in6);
-#endif
else
return 0;
if (add_addr_to_list(d->list, socktype, sa->sa_family, addrlen,
ntohs(s_sin->sin_port));
}
break;
-#ifdef KRB5_USE_INET6
case AF_INET6:
{
struct sockaddr_in6 *s_sin6 = (struct sockaddr_in6 *)&entry->addr;
printf("/%d", ntohs(s_sin6->sin6_port));
break;
}
-#endif
default:
printf(" unknown-af-%d", entry->family);
break;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
-#ifdef KRB5_USE_INET6
hints.ai_family = AF_INET6;
error = getaddrinfo(NULL, port, &hints, res);
if (error == 0)
return 0;
-#endif
hints.ai_family = AF_INET;
return getaddrinfo(NULL, port, &hints, res);
}
if (setsockopt(finet, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0)
com_err(progname, errno, _("while setting SO_REUSEADDR option"));
-#if defined(KRB5_USE_INET6) && defined(IPV6_V6ONLY)
+#if defined(IPV6_V6ONLY)
/* Make sure dual-stack support is enabled on IPv6 listener sockets if
* possible. */
val = 0;
if (n == 0)
return EAI_MEMORY;
if (template->ai_family != AF_INET
-#ifdef KRB5_USE_INET6
&& template->ai_family != AF_INET6
-#endif
)
return EAI_FAMILY;
*n = *template;
sin4->sin_len = sizeof (struct sockaddr_in);
#endif
}
-#ifdef KRB5_USE_INET6
if (template->ai_family == AF_INET6) {
struct sockaddr_in6 *sin6;
sin6 = malloc (sizeof (struct sockaddr_in6));
sin6->sin6_len = sizeof (struct sockaddr_in6);
#endif
}
-#endif
n->ai_next = *result;
*result = n;
return 0;
}
#endif
-#if defined(KRB5_USE_INET6)
/* Some systems don't define in6addr_any. */
const struct in6_addr krb5int_in6addr_any = IN6ADDR_ANY_INIT;
-#else
-/* Are any of the systems without IPv6 support among those where
- we cross-check the actual exported symbols against the export
- list? Not sure, play it safe. */
-const char krb5int_in6addr_any = 0;
-#endif
int krb5int_getaddrinfo (const char *node, const char *service,
const struct addrinfo *hints,