]> git.ipfire.org Git - thirdparty/squid.git/blame - compat/getaddrinfo.h
SourceFormat Enforcement
[thirdparty/squid.git] / compat / getaddrinfo.h
CommitLineData
37be9888 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
37be9888
AJ
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
0e076fb1 9#ifndef _getaddrinfo_h
10#define _getaddrinfo_h
11
12/*
13 * Shamelessly duplicated from the fetchmail public sources
14 * for use by the Squid Project under GNU Public License.
15 *
16 * Update/Maintenance History:
17 *
18 * 15-Aug-2007 : Copied from fetchmail 6.3.8
f53969cc 19 * - added protection around libray headers
0e076fb1 20 *
21 * 16-Aug-2007 : Altered configure checks
22 * Un-hacked slightly to use system gethostbyname()
23 *
0e076fb1 24 * Original License and code follows.
25 */
26
0e076fb1 27/*
28 * This file is part of libESMTP, a library for submission of RFC 2822
29 * formatted electronic mail messages using the SMTP protocol described
30 * in RFC 2821.
31 *
32 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
33 *
34 * This library is free software; you can redistribute it and/or
35 * modify it under the terms of the GNU Lesser General Public
36 * License as published by the Free Software Foundation; either
37 * version 2.1 of the License, or (at your option) any later version.
38 *
39 * This library is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 * Lesser General Public License for more details.
43 *
44 * You should have received a copy of the GNU Lesser General Public
45 * License along with this library; if not, write to the Free Software
46 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47 */
48
49/* Structure and prototypes taken from RFC 2553 */
50
c5dd4956 51/* These functions are provided by the OS */
55d7d5e9 52#if !HAVE_DECL_GETADDRINFO
0e076fb1 53
54/* SG 23/09/2007:
c5dd4956
AJ
55On Windows the following definitions are already available, may be that
56this could be needed on some other platform */
0e076fb1 57#if 0
c5dd4956 58struct addrinfo {
f53969cc
SM
59 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
60 int ai_family; /* PF_xxx */
61 int ai_socktype; /* SOCK_xxx */
62 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
63 socklen_t ai_addrlen; /* length of ai_addr */
64 char *ai_canonname; /* canonical name for nodename */
65 struct sockaddr *ai_addr; /* binary address */
66 struct addrinfo *ai_next; /* next structure in linked list */
c5dd4956 67};
0e076fb1 68
69/* Supposed to be defined in <netdb.h> */
70#define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
71#define AI_CANONNAME 2 /* Request for canonical name. */
72#define AI_NUMERICHOST 4 /* Don't use name resolution. */
73
74/* Supposed to be defined in <netdb.h> */
75#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
76#define EAI_AGAIN 2 /* temporary failure in name resolution */
77#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
78#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
79#define EAI_FAMILY 5 /* ai_family not supported */
80#define EAI_MEMORY 6 /* memory allocation failure */
81#define EAI_NODATA 7 /* no address associated with nodename */
82#define EAI_NONAME 8 /* nodename nor servname provided, or not known */
83#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
84#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
85#endif
86#ifndef EAI_SYSTEM
87/* Not defined on mingw32. */
88#define EAI_SYSTEM 11 /* System error returned in `errno'. */
89#endif
90#ifndef EAI_OVERFLOW
91/* Not defined on mingw32. */
92#define EAI_OVERFLOW 12 /* Argument buffer overflow. */
93#endif
94
95#ifndef IN_EXPERIMENTAL
96#define IN_EXPERIMENTAL(a) \
97 ((((long int) (a)) & 0xf0000000) == 0xf0000000)
98#endif
99
100/* RFC 2553 / Posix resolver */
101SQUIDCEXTERN int xgetaddrinfo (const char *nodename, const char *servname,
c5dd4956 102 const struct addrinfo *hints, struct addrinfo **res);
f53969cc 103#define getaddrinfo xgetaddrinfo
0e076fb1 104
105/* Free addrinfo structure and associated storage */
106SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai);
f53969cc 107#define freeaddrinfo xfreeaddrinfo
0e076fb1 108
109/* Convert error return from getaddrinfo() to string */
110SQUIDCEXTERN const char *xgai_strerror (int code);
b095e27d 111#if !defined(gai_strerror)
f53969cc 112#define gai_strerror xgai_strerror
b095e27d 113#endif
0e076fb1 114
55d7d5e9 115#endif /* HAVE_DECL_GETADDRINFO */
27bc2077 116#endif /* _getaddrinfo_h */
f53969cc 117