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