Path: blob/main/contrib/ldns/compat/fake-rfc2553.h
39482 views
/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */1/*2* Copyright (C) 2000-2003 Damien Miller. All rights reserved.3* Copyright (C) 1999 WIDE Project. All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13* 3. Neither the name of the project nor the names of its contributors14* may be used to endorse or promote products derived from this software15* without specific prior written permission.16*17* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*/2930/*31* Pseudo-implementation of RFC2553 name / address resolution functions32*33* But these functions are not implemented correctly. The minimum subset34* is implemented for ssh use only. For example, this routine assumes35* that ai_family is AF_INET. Don't use it for another purpose.36*/3738#ifndef _FAKE_RFC2553_H39#define _FAKE_RFC2553_H4041#include <sys/types.h>42#include <sys/socket.h>43#include <netdb.h>44#include <limits.h>4546#ifdef __cplusplus47extern "C" {48#endif4950/*51* First, socket and INET6 related definitions52*/53#ifndef HAVE_STRUCT_SOCKADDR_STORAGE54#ifndef _SS_MAXSIZE55# define _SS_MAXSIZE 128 /* Implementation specific max size */56# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr))57struct sockaddr_storage {58struct sockaddr ss_sa;59char __ss_pad2[_SS_PADSIZE];60};61# define ss_family ss_sa.sa_family62#endif /* _SS_MAXSIZE */63#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */6465#ifndef IN6_IS_ADDR_LOOPBACK66# define IN6_IS_ADDR_LOOPBACK(a) \67(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \68((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1))69#endif /* !IN6_IS_ADDR_LOOPBACK */7071#ifndef HAVE_STRUCT_IN6_ADDR72struct in6_addr {73uint8_t s6_addr[16];74};75#endif /* !HAVE_STRUCT_IN6_ADDR */7677#ifndef HAVE_STRUCT_SOCKADDR_IN678struct sockaddr_in6 {79unsigned short sin6_family;80uint16_t sin6_port;81uint32_t sin6_flowinfo;82struct in6_addr sin6_addr;83};84#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */8586#ifndef AF_INET687/* Define it to something that should never appear */88#define AF_INET6 AF_MAX89#endif9091/*92* Next, RFC2553 name / address resolution API93*/9495#ifndef NI_NUMERICHOST96# define NI_NUMERICHOST (1)97#endif98#ifndef NI_NAMEREQD99# define NI_NAMEREQD (1<<1)100#endif101#ifndef NI_NUMERICSERV102# define NI_NUMERICSERV (1<<2)103#endif104105#ifndef AI_PASSIVE106# define AI_PASSIVE (1)107#endif108#ifndef AI_CANONNAME109# define AI_CANONNAME (1<<1)110#endif111#ifndef AI_NUMERICHOST112# define AI_NUMERICHOST (1<<2)113#endif114115#ifndef NI_MAXSERV116# define NI_MAXSERV 32117#endif /* !NI_MAXSERV */118#ifndef NI_MAXHOST119# define NI_MAXHOST 1025120#endif /* !NI_MAXHOST */121122#ifndef INT_MAX123#define INT_MAX 0xffffffff124#endif125126#ifndef EAI_NODATA127# define EAI_NODATA (INT_MAX - 1)128#endif129#ifndef EAI_MEMORY130# define EAI_MEMORY (INT_MAX - 2)131#endif132#ifndef EAI_NONAME133# define EAI_NONAME (INT_MAX - 3)134#endif135#ifndef EAI_SYSTEM136# define EAI_SYSTEM (INT_MAX - 4)137#endif138139#ifndef HAVE_STRUCT_ADDRINFO140struct addrinfo {141int ai_flags; /* AI_PASSIVE, AI_CANONNAME */142int ai_family; /* PF_xxx */143int ai_socktype; /* SOCK_xxx */144int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */145size_t ai_addrlen; /* length of ai_addr */146char *ai_canonname; /* canonical name for hostname */147struct sockaddr *ai_addr; /* binary address */148struct addrinfo *ai_next; /* next structure in linked list */149};150#endif /* !HAVE_STRUCT_ADDRINFO */151152#ifndef HAVE_GETADDRINFO153#ifdef getaddrinfo154# undef getaddrinfo155#endif156#define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d))157int getaddrinfo(const char *, const char *,158const struct addrinfo *, struct addrinfo **);159#endif /* !HAVE_GETADDRINFO */160161#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO)162#define gai_strerror(a) (ssh_gai_strerror(a))163char *gai_strerror(int);164#endif /* !HAVE_GAI_STRERROR */165166#ifndef HAVE_FREEADDRINFO167#define freeaddrinfo(a) (ssh_freeaddrinfo(a))168void freeaddrinfo(struct addrinfo *);169#endif /* !HAVE_FREEADDRINFO */170171#ifndef HAVE_GETNAMEINFO172#define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g))173int getnameinfo(const struct sockaddr *, size_t, char *, size_t,174char *, size_t, int);175#endif /* !HAVE_GETNAMEINFO */176177#ifdef __cplusplus178}179#endif180181#endif /* !_FAKE_RFC2553_H */182183184185