From 2ab4b232fc1bb53cc78d7e84f5ea8b5cc74cb85e Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Fri, 21 Jun 2024 13:59:45 +0200 Subject: [PATCH] Again ported to NetBSD --- CHANGES | 3 +++ configure.ac | 10 ++++++++++ utils.c | 17 +++++++++++++++++ utils.h | 3 +++ xio-ip.c | 4 +++- xio-openssl.c | 9 +++++++-- 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 7a431d6..1fb2975 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,9 @@ Features: Total inactivity timeout option -T 0 now means 0.0 seconds; up to version 1.8.0.0 it meant no total inactivity timeout. +Porting: + Changes for building and testing on NetBSD + Testing: test.sh: lots of corrections and improvements diff --git a/configure.ac b/configure.ac index f53e8e7..74b1503 100644 --- a/configure.ac +++ b/configure.ac @@ -305,6 +305,16 @@ if test "$ac_cv_apple_use_rfc_2292" = yes; then fi AC_MSG_RESULT($ac_cv_apple_use_rfc_2292) +AC_MSG_CHECKING(if including netinet/in.h suffices) +AC_TRY_COMPILE([#include +#include ], +[struct sockaddr_in6 s;], +[ AC_MSG_RESULT(yes); WITH_IP6=1], +[ AC_MSG_RESULT(no); WITH_IP6=]) +if test "$WITH_IP6"; then + AC_DEFINE(WITH_IP6) +fi + fi AC_MSG_CHECKING(whether to include raw IP support) diff --git a/utils.c b/utils.c index 7243ca9..4ef5504 100644 --- a/utils.c +++ b/utils.c @@ -38,6 +38,23 @@ void *memdup(const void *src, size_t n) { return dest; } +#if !HAVE_PROTOTYPE_LIB_strndup +char *strndup( + const char *s, + size_t n) +{ + char *m; + m = malloc(n+1); + if (m == NULL) { + return m; + } + strncpy(m, s, n); + m[n] = '\0'; + return m; +} +#endif /* !HAVE_PROTOTYPE_LIB_strndup */ + + /* search the keyword-table for a match of the leading part of name. */ /* returns the pointer to the matching field of the keyword or NULL if no keyword was found. */ diff --git a/utils.h b/utils.h index d1ff71c..861964d 100644 --- a/utils.h +++ b/utils.h @@ -15,6 +15,9 @@ struct wordent { extern void *memrchr(const void *s, int c, size_t n); #endif extern void *memdup(const void *src, size_t n); +#if !HAVE_PROTOTYPE_LIB_strndup +extern char *strndup(const char *s, size_t n); +#endif #if !HAVE_SETENV extern int setenv(const char *name, const char *value, int overwrite); #endif /* !HAVE_SETENV */ diff --git a/xio-ip.c b/xio-ip.c index c7c776a..2f35448 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -216,9 +216,11 @@ int xiogetaddrinfo(const char *node, const char *service, if (family == PF_UNSPEC) family = PF_INET6; #endif /* WITH_IP6 */ } +#if HAVE_GETADDRINFO +#ifdef AI_ADDRCONFIG if (family == 0) hints.ai_flags |= AI_ADDRCONFIG; -#if HAVE_GETADDRINFO +#endif if (node != NULL || service != NULL) { struct addrinfo *record; diff --git a/xio-openssl.c b/xio-openssl.c index 0205146..1d87452 100644 --- a/xio-openssl.c +++ b/xio-openssl.c @@ -1121,7 +1121,7 @@ int #elif HAVE_DTLSv1_client_method method = sycDTLSv1_client_method(); #else -# error "OpenSSL does not seem to provide DTLS client methods" +# warning "OpenSSL does not seem to provide DTLS client methods" #endif *use_dtls = true; } @@ -1192,12 +1192,17 @@ int #elif HAVE_DTLSv1_server_method method = sycDTLSv1_server_method(); #else -# error "OpenSSL does not seem to provide DTLS server methods" +# warning "OpenSSL does not seem to provide DTLS server methods" #endif *use_dtls = true; } } + if (method == NULL) { + Error("no OpenSSL method available"); + return STAT_NORETRY; + } + if (opt_egd) { #if !defined(OPENSSL_NO_EGD) && HAVE_RAND_egd sycRAND_egd(opt_egd);