]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2015 The Squid Software Foundation and contributors | |
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 | ||
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 | |
19 | * - added protection around libray headers | |
20 | * | |
21 | * 16-Aug-2007 : Altered configure checks | |
22 | * Un-hacked slightly to use system gethostbyname() | |
23 | * | |
24 | * Original License and code follows. | |
25 | */ | |
26 | ||
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 | ||
51 | /* These functions are provided by the OS */ | |
52 | #if !HAVE_DECL_GETADDRINFO | |
53 | ||
54 | /* SG 23/09/2007: | |
55 | On Windows the following definitions are already available, may be that | |
56 | this could be needed on some other platform */ | |
57 | #if 0 | |
58 | struct addrinfo { | |
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 */ | |
67 | }; | |
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 */ | |
101 | SQUIDCEXTERN int xgetaddrinfo (const char *nodename, const char *servname, | |
102 | const struct addrinfo *hints, struct addrinfo **res); | |
103 | #define getaddrinfo xgetaddrinfo | |
104 | ||
105 | /* Free addrinfo structure and associated storage */ | |
106 | SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai); | |
107 | #define freeaddrinfo xfreeaddrinfo | |
108 | ||
109 | /* Convert error return from getaddrinfo() to string */ | |
110 | SQUIDCEXTERN const char *xgai_strerror (int code); | |
111 | #if !defined(gai_strerror) | |
112 | #define gai_strerror xgai_strerror | |
113 | #endif | |
114 | ||
115 | #endif /* HAVE_DECL_GETADDRINFO */ | |
116 | #endif /* _getaddrinfo_h */ | |
117 |