MeshLink_ATTRIBUTE(__malloc__)
MeshLink_ATTRIBUTE(__warn_unused_result__)
-AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
- [#include "$srcdir/src/have.h"]
-)
-
-AC_CHECK_TYPES([struct sockaddr_storage], ,AC_MSG_ERROR([System must support struct sockaddr_storage.]),
- [#include "$srcdir/src/have.h"]
-)
-
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([asprintf fchmod fork gettimeofday random pselect select setns strdup usleep getifaddrs freeifaddrs],
AC_CHECK_FUNC(socket, [], [
AC_CHECK_LIB(socket, connect)
])
-AC_CHECK_FUNC(gethostbyname, [], [
- AC_CHECK_LIB(nsl, gethostbyname)
-])
-
-AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
- [], [], [#include "$srcdir/src/have.h"]
-)
AC_CACHE_SAVE
ecdsagen.h \
edge.c edge.h \
event.c event.h \
- fake-gai-errnos.h \
- fake-getaddrinfo.c fake-getaddrinfo.h \
- fake-getnameinfo.c fake-getnameinfo.h \
graph.c graph.h \
hash.c hash.h \
have.h \
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "fake-getaddrinfo.h"
-#include "fake-getnameinfo.h"
-
#ifndef HAVE_ASPRINTF
extern int asprintf(char **, const char *, ...);
extern int vasprintf(char **, const char *, va_list ap);
#ifdef HAVE_MINGW
#define mkdir(a, b) mkdir(a)
+
#ifndef SHUT_RDWR
#define SHUT_RDWR SD_BOTH
#endif
+
+#ifndef EAI_SYSTEM
+#define EAI_SYSTEM 0
+#endif
#endif
#endif
+++ /dev/null
-#ifndef MESHLINK_FAKE_GAI_ERRNOS_H
-#define MESHLINK_FAKE_GAI_ERRNOS_H
-
-#ifndef EAI_NODATA
-#define EAI_NODATA 1
-#endif
-
-#ifndef EAI_MEMORY
-#define EAI_MEMORY 2
-#endif
-
-#ifndef EAI_FAMILY
-#define EAI_FAMILY 3
-#endif
-
-#ifndef EAI_SYSTEM
-#define EAI_SYSTEM 4
-#endif
-
-#endif
+++ /dev/null
-/*
- * fake library for ssh
- *
- * This file includes getaddrinfo(), freeaddrinfo() and gai_strerror().
- * These functions are defined in rfc2133.
- *
- * But these functions are not implemented correctly. The minimum subset
- * is implemented for ssh use only. For example, this routine assumes
- * that ai_family is AF_INET. Don't use it for another purpose.
- */
-
-#include "system.h"
-
-#include "fake-getaddrinfo.h"
-#include "xalloc.h"
-
-
-#if !HAVE_DECL_GAI_STRERROR
-char *gai_strerror(int ecode) {
- switch(ecode) {
- case EAI_NODATA:
- return "No address associated with hostname";
-
- case EAI_MEMORY:
- return "Memory allocation failure";
-
- case EAI_FAMILY:
- return "Address family not supported";
-
- default:
- return "Unknown error";
- }
-}
-#endif /* !HAVE_GAI_STRERROR */
-
-#if !HAVE_DECL_FREEADDRINFO
-void freeaddrinfo(struct addrinfo *ai) {
- struct addrinfo *next;
-
- while(ai) {
- next = ai->ai_next;
- free(ai);
- ai = next;
- }
-}
-#endif /* !HAVE_FREEADDRINFO */
-
-#if !HAVE_DECL_GETADDRINFO
-static struct addrinfo *malloc_ai(uint16_t port, uint32_t addr) {
- struct addrinfo *ai;
-
- ai = xzalloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
-
- ai->ai_addr = (struct sockaddr *)(ai + 1);
- ai->ai_addrlen = sizeof(struct sockaddr_in);
- ai->ai_addr->sa_family = ai->ai_family = AF_INET;
-
- ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
- ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
-
- return ai;
-}
-
-int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) {
- struct addrinfo *prev = NULL;
- struct hostent *hp;
- struct in_addr in = {0};
- int i;
- uint16_t port = 0;
-
- if(hints && hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC) {
- return EAI_FAMILY;
- }
-
- if(servname) {
- port = htons(atoi(servname));
- }
-
- if(hints && hints->ai_flags & AI_PASSIVE) {
- *res = malloc_ai(port, htonl(0x00000000));
- return 0;
- }
-
- if(!hostname) {
- *res = malloc_ai(port, htonl(0x7f000001));
- return 0;
- }
-
- hp = gethostbyname(hostname);
-
- if(!hp || !hp->h_addr_list || !hp->h_addr_list[0]) {
- return EAI_NODATA;
- }
-
- for(i = 0; hp->h_addr_list[i]; i++) {
- *res = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr);
-
- if(prev) {
- prev->ai_next = *res;
- }
-
- prev = *res;
- }
-
- return 0;
-}
-#endif /* !HAVE_GETADDRINFO */
+++ /dev/null
-#ifndef MESHLINK_FAKE_GETADDRINFO_H
-#define MESHLINK_FAKE_GETADDRINFO_H
-
-#include "fake-gai-errnos.h"
-
-#ifndef AI_PASSIVE
-# define AI_PASSIVE 1
-# define AI_CANONNAME 2
-#endif
-
-#ifndef NI_NUMERICHOST
-# define NI_NUMERICHOST 2
-# define NI_NAMEREQD 4
-# define NI_NUMERICSERV 8
-#endif
-
-#ifndef AI_NUMERICHOST
-#define AI_NUMERICHOST 4
-#endif
-
-#ifndef HAVE_STRUCT_ADDRINFO
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-#endif /* !HAVE_STRUCT_ADDRINFO */
-
-#if !HAVE_DECL_GETADDRINFO
-int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) __attribute__((__warn_unused_result__));
-#endif /* !HAVE_GETADDRINFO */
-
-#if !HAVE_DECL_GAI_STRERROR
-char *gai_strerror(int ecode) __attribute__((__warn_unused_result__));
-#endif /* !HAVE_GAI_STRERROR */
-
-#if !HAVE_DECL_FREEADDRINFO
-void freeaddrinfo(struct addrinfo *ai);
-#endif /* !HAVE_FREEADDRINFO */
-
-#endif
+++ /dev/null
-/*
- * fake library for ssh
- *
- * This file includes getnameinfo().
- * These functions are defined in rfc2133.
- *
- * But these functions are not implemented correctly. The minimum subset
- * is implemented for ssh use only. For example, this routine assumes
- * that ai_family is AF_INET. Don't use it for another purpose.
- */
-
-#include "system.h"
-
-#include "fake-getnameinfo.h"
-#include "fake-getaddrinfo.h"
-
-#if !HAVE_DECL_GETNAMEINFO
-
-int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) {
- struct sockaddr_in *sin = (struct sockaddr_in *)sa;
- struct hostent *hp;
- int len;
-
- if(sa->sa_family != AF_INET) {
- return EAI_FAMILY;
- }
-
- if(serv && servlen) {
- len = snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
-
- if(len < 0 || len >= servlen) {
- return EAI_MEMORY;
- }
- }
-
- if(!host || !hostlen) {
- return 0;
- }
-
- if(flags & NI_NUMERICHOST) {
- len = snprintf(host, hostlen, "%s", inet_ntoa(sin->sin_addr));
-
- if(len < 0 || len >= hostlen) {
- return EAI_MEMORY;
- }
-
- return 0;
- }
-
- hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET);
-
- if(!hp || !hp->h_name || !hp->h_name[0]) {
- return EAI_NODATA;
- }
-
- len = snprintf(host, hostlen, "%s", hp->h_name);
-
- if(len < 0 || len >= hostlen) {
- return EAI_MEMORY;
- }
-
- return 0;
-}
-#endif /* !HAVE_GETNAMEINFO */
+++ /dev/null
-#ifndef MESHLINK_FAKE_GETNAMEINFO_H
-#define MESHLINK_FAKE_GETNAMEINFO_H
-
-#if !HAVE_DECL_GETNAMEINFO
-int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) __attribute__((__warn_unused_result__));
-#endif /* !HAVE_GETNAMEINFO */
-
-#ifndef NI_MAXSERV
-# define NI_MAXSERV 32
-#endif /* !NI_MAXSERV */
-#ifndef NI_MAXHOST
-# define NI_MAXHOST 1025
-#endif /* !NI_MAXHOST */
-
-#endif
#include "dropin.h"
-#ifndef HAVE_SOCKLEN_T
-typedef int socklen_t;
-#endif
-
#endif