Git init
[external/curl.git] / lib / curl_addrinfo.h
1 #ifndef HEADER_CURL_ADDRINFO_H
2 #define HEADER_CURL_ADDRINFO_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at http://curl.haxx.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  ***************************************************************************/
24
25 #include "setup.h"
26
27 #ifdef HAVE_SYS_SOCKET_H
28 #  include <sys/socket.h>
29 #endif
30 #ifdef HAVE_NETINET_IN_H
31 #  include <netinet/in.h>
32 #endif
33 #ifdef HAVE_NETDB_H
34 #  include <netdb.h>
35 #endif
36 #ifdef HAVE_ARPA_INET_H
37 #  include <arpa/inet.h>
38 #endif
39
40 #ifdef __VMS
41 #  include <in.h>
42 #  include <inet.h>
43 #  include <stdlib.h>
44 #endif
45
46
47 /*
48  * Curl_addrinfo is our internal struct definition that we use to allow
49  * consistent internal handling of this data. We use this even when the
50  * system provides an addrinfo structure definition. And we use this for
51  * all sorts of IPv4 and IPV6 builds.
52  */
53
54 struct Curl_addrinfo {
55   int                   ai_flags;
56   int                   ai_family;
57   int                   ai_socktype;
58   int                   ai_protocol;
59   curl_socklen_t        ai_addrlen;   /* Follow rfc3493 struct addrinfo */
60   char                 *ai_canonname;
61   struct sockaddr      *ai_addr;
62   struct Curl_addrinfo *ai_next;
63 };
64 typedef struct Curl_addrinfo Curl_addrinfo;
65
66 void
67 Curl_freeaddrinfo(Curl_addrinfo *cahead);
68
69 #ifdef HAVE_GETADDRINFO
70 int
71 Curl_getaddrinfo_ex(const char *nodename,
72                     const char *servname,
73                     const struct addrinfo *hints,
74                     Curl_addrinfo **result);
75 #endif
76
77 Curl_addrinfo *
78 Curl_he2ai(const struct hostent *he, int port);
79
80 Curl_addrinfo *
81 Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
82
83 Curl_addrinfo *Curl_str2addr(char *dotted, int port);
84
85 #if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO)
86 void
87 curl_dofreeaddrinfo(struct addrinfo *freethis,
88                     int line, const char *source);
89 #endif
90
91 #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
92 int
93 curl_dogetaddrinfo(const char *hostname,
94                    const char *service,
95                    const struct addrinfo *hints,
96                    struct addrinfo **result,
97                    int line, const char *source);
98 #endif
99
100 #endif /* HEADER_CURL_ADDRINFO_H */