Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmcurl/lib/curl_addrinfo.h
5020 views
1
#ifndef HEADER_CURL_ADDRINFO_H
2
#define HEADER_CURL_ADDRINFO_H
3
/***************************************************************************
4
* _ _ ____ _
5
* Project ___| | | | _ \| |
6
* / __| | | | |_) | |
7
* | (__| |_| | _ <| |___
8
* \___|\___/|_| \_\_____|
9
*
10
* Copyright (C) Daniel Stenberg, <[email protected]>, 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
* SPDX-License-Identifier: curl
24
*
25
***************************************************************************/
26
#include "curl_setup.h"
27
28
#ifdef HAVE_NETINET_IN_H
29
# include <netinet/in.h>
30
#endif
31
#ifdef HAVE_NETDB_H
32
# include <netdb.h>
33
#endif
34
#ifdef HAVE_ARPA_INET_H
35
# include <arpa/inet.h>
36
#endif
37
38
#ifdef __VMS
39
# include <in.h>
40
# include <inet.h>
41
# include <stdlib.h>
42
#endif
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 system
47
* provides an addrinfo structure definition. We use this for all sorts of
48
* IPv4 and IPV6 builds.
49
*/
50
51
struct 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
};
61
62
void Curl_freeaddrinfo(struct Curl_addrinfo *cahead);
63
64
#ifdef HAVE_GETADDRINFO
65
int Curl_getaddrinfo_ex(const char *nodename,
66
const char *servname,
67
const struct addrinfo *hints,
68
struct Curl_addrinfo **result);
69
#endif
70
71
#if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE))
72
struct Curl_addrinfo *Curl_he2ai(const struct hostent *he, int port);
73
#endif
74
75
bool Curl_is_ipaddr(const char *address);
76
CURLcode Curl_str2addr(const char *dotted, int port, struct Curl_addrinfo **);
77
78
#ifdef USE_UNIX_SOCKETS
79
struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
80
bool abstract);
81
#endif
82
83
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
84
defined(HAVE_FREEADDRINFO)
85
void curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line,
86
const char *source);
87
#endif
88
89
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
90
int curl_dbg_getaddrinfo(const char *hostname, const char *service,
91
const struct addrinfo *hints,
92
struct addrinfo **result, int line,
93
const char *source);
94
#endif
95
96
#ifdef HAVE_GETADDRINFO
97
#ifdef USE_RESOLVE_ON_IPS
98
void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port);
99
#else
100
#define Curl_addrinfo_set_port(x, y)
101
#endif
102
#endif
103
104
#endif /* HEADER_CURL_ADDRINFO_H */
105
106