netdb.h revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id$ */
/*! \file */
#ifndef IRS_NETDB_H
#define IRS_NETDB_H 1
#include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */
/*
* Define if <netdb.h> does not declare struct addrinfo.
*/
#ifdef ISC_IRS_NEEDADDRINFO
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 */
char *ai_canonname; /* Canonical name for hostname */
};
#endif
/*
* Undefine all #defines we are interested in as <netdb.h> may or may not have
* defined them.
*/
/*
* Error return codes from gethostbyname() and gethostbyaddr()
* (left in extern int h_errno).
*/
#define NETDB_SUCCESS 0 /* no problem */
/*
* Error return codes from getaddrinfo(). EAI_INSECUREDATA is our own extension
* and it's very unlikely to be already defined, but undef it just in case; it
* at least doesn't do any harm.
*/
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_OVERFLOW 14
#define EAI_INSECUREDATA 15
#define EAI_MAX 16
/*
* Flag values for getaddrinfo()
*/
#define AI_PASSIVE 0x00000001
#define AI_CANONNAME 0x00000002
#define AI_NUMERICHOST 0x00000004
/*
* Flag values for getipnodebyname()
*/
#define AI_V4MAPPED 0x00000008
#define AI_ALL 0x00000010
#define AI_ADDRCONFIG 0x00000020
/*
* Constants for lwres_getnameinfo()
*/
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
/*
* Flag values for lwres_getnameinfo()
*/
#define NI_NOFQDN 0x00000001
#define NI_NUMERICHOST 0x00000002
#define NI_NAMEREQD 0x00000004
#define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010
/*
* Define to map into irs_ namespace.
*/
#define IRS_NAMESPACE
#ifdef IRS_NAMESPACE
/*
* Use our versions not the ones from the C library.
*/
#ifdef getnameinfo
#endif
#define getnameinfo irs_getnameinfo
#ifdef getaddrinfo
#endif
#define getaddrinfo irs_getaddrinfo
#ifdef freeaddrinfo
#endif
#define freeaddrinfo irs_freeaddrinfo
#ifdef gai_strerror
#endif
#define gai_strerror irs_gai_strerror
#endif
int getaddrinfo(const char *, const char *,
void freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
/*
* Tell Emacs to use C mode on this file.
* Local variables:
* mode: c
* End:
*/
#endif /* IRS_NETDB_H */