blob: 8f6f3d106478a4b67410b7b9069f6fa10db18b0f [file] [log] [blame]
Kristian Monsen5ab50182010-05-14 18:53:44 +01001#ifndef HEADER_CURL_ADDRINFO_H
2#define HEADER_CURL_ADDRINFO_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
Alex Deymoe3149cc2016-10-05 11:18:42 -070010 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
Kristian Monsen5ab50182010-05-14 18:53:44 +010011 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
Alex Deymod15eaac2016-06-28 14:49:26 -070014 * are also available at https://curl.haxx.se/docs/copyright.html.
Kristian Monsen5ab50182010-05-14 18:53:44 +010015 *
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
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070025#include "curl_setup.h"
Kristian Monsen5ab50182010-05-14 18:53:44 +010026
Kristian Monsen5ab50182010-05-14 18:53:44 +010027#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/*
45 * Curl_addrinfo is our internal struct definition that we use to allow
46 * consistent internal handling of this data. We use this even when the
47 * system provides an addrinfo structure definition. And we use this for
48 * all sorts of IPv4 and IPV6 builds.
49 */
50
51struct Curl_addrinfo {
52 int ai_flags;
53 int ai_family;
54 int ai_socktype;
55 int ai_protocol;
56 curl_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
57 char *ai_canonname;
58 struct sockaddr *ai_addr;
59 struct Curl_addrinfo *ai_next;
60};
61typedef struct Curl_addrinfo Curl_addrinfo;
62
63void
64Curl_freeaddrinfo(Curl_addrinfo *cahead);
65
66#ifdef HAVE_GETADDRINFO
67int
68Curl_getaddrinfo_ex(const char *nodename,
69 const char *servname,
70 const struct addrinfo *hints,
71 Curl_addrinfo **result);
72#endif
73
74Curl_addrinfo *
75Curl_he2ai(const struct hostent *he, int port);
76
77Curl_addrinfo *
78Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
79
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070080Curl_addrinfo *Curl_str2addr(char *dotted, int port);
81
82#ifdef USE_UNIX_SOCKETS
Elliott Hughes82be86d2017-09-20 17:00:17 -070083Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract);
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070084#endif
85
Alex Deymod15eaac2016-06-28 14:49:26 -070086#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
87 defined(HAVE_FREEADDRINFO)
Kristian Monsen5ab50182010-05-14 18:53:44 +010088void
89curl_dofreeaddrinfo(struct addrinfo *freethis,
90 int line, const char *source);
91#endif
92
93#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
94int
95curl_dogetaddrinfo(const char *hostname,
96 const char *service,
97 const struct addrinfo *hints,
98 struct addrinfo **result,
99 int line, const char *source);
100#endif
101
Alex Deymoe3149cc2016-10-05 11:18:42 -0700102#ifdef HAVE_GETADDRINFO
103#ifdef USE_RESOLVE_ON_IPS
104void Curl_addrinfo_set_port(Curl_addrinfo *addrinfo, int port);
105#else
106#define Curl_addrinfo_set_port(x,y)
107#endif
108#endif
109
Kristian Monsen5ab50182010-05-14 18:53:44 +0100110#endif /* HEADER_CURL_ADDRINFO_H */