1 | #ifndef HEADER_CURL_ADDRINFO_H |
2 | #define |
3 | /*************************************************************************** |
4 | * _ _ ____ _ |
5 | * Project ___| | | | _ \| | |
6 | * / __| | | | |_) | | |
7 | * | (__| |_| | _ <| |___ |
8 | * \___|\___/|_| \_\_____| |
9 | * |
10 | * Copyright (C) 1998 - 2020, 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 https://curl.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 "curl_setup.h" |
26 | |
27 | #ifdef HAVE_NETINET_IN_H |
28 | # include <netinet/in.h> |
29 | #endif |
30 | #ifdef HAVE_NETDB_H |
31 | # include <netdb.h> |
32 | #endif |
33 | #ifdef HAVE_ARPA_INET_H |
34 | # include <arpa/inet.h> |
35 | #endif |
36 | |
37 | #ifdef __VMS |
38 | # include <in.h> |
39 | # include <inet.h> |
40 | # include <stdlib.h> |
41 | #endif |
42 | |
43 | /* |
44 | * Curl_addrinfo is our internal struct definition that we use to allow |
45 | * consistent internal handling of this data. We use this even when the |
46 | * system provides an addrinfo structure definition. And we use this for |
47 | * all sorts of IPv4 and IPV6 builds. |
48 | */ |
49 | |
50 | struct Curl_addrinfo { |
51 | int ai_flags; |
52 | int ai_family; |
53 | int ai_socktype; |
54 | int ai_protocol; |
55 | curl_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */ |
56 | char *ai_canonname; |
57 | struct sockaddr *ai_addr; |
58 | struct Curl_addrinfo *ai_next; |
59 | }; |
60 | |
61 | void |
62 | Curl_freeaddrinfo(struct Curl_addrinfo *cahead); |
63 | |
64 | #ifdef HAVE_GETADDRINFO |
65 | int |
66 | Curl_getaddrinfo_ex(const char *nodename, |
67 | const char *servname, |
68 | const struct addrinfo *hints, |
69 | struct Curl_addrinfo **result); |
70 | #endif |
71 | |
72 | struct Curl_addrinfo * |
73 | Curl_he2ai(const struct hostent *he, int port); |
74 | |
75 | struct Curl_addrinfo * |
76 | Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port); |
77 | |
78 | struct Curl_addrinfo *Curl_str2addr(char *dotted, int port); |
79 | |
80 | #ifdef USE_UNIX_SOCKETS |
81 | struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, |
82 | bool abstract); |
83 | #endif |
84 | |
85 | #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \ |
86 | defined(HAVE_FREEADDRINFO) |
87 | void |
88 | curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, const char *source); |
89 | #endif |
90 | |
91 | #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) |
92 | int |
93 | curl_dbg_getaddrinfo(const char *hostname, const char *service, |
94 | const struct addrinfo *hints, struct addrinfo **result, |
95 | int line, const char *source); |
96 | #endif |
97 | |
98 | #ifdef HAVE_GETADDRINFO |
99 | #ifdef USE_RESOLVE_ON_IPS |
100 | void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port); |
101 | #else |
102 | #define Curl_addrinfo_set_port(x,y) |
103 | #endif |
104 | #endif |
105 | |
106 | #endif /* HEADER_CURL_ADDRINFO_H */ |
107 | |