113498266Sopenharmony_ci#ifndef HEADER_CURL_ADDRINFO_H
213498266Sopenharmony_ci#define HEADER_CURL_ADDRINFO_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci
2713498266Sopenharmony_ci#include "curl_setup.h"
2813498266Sopenharmony_ci
2913498266Sopenharmony_ci#ifdef HAVE_NETINET_IN_H
3013498266Sopenharmony_ci#  include <netinet/in.h>
3113498266Sopenharmony_ci#endif
3213498266Sopenharmony_ci#ifdef HAVE_NETDB_H
3313498266Sopenharmony_ci#  include <netdb.h>
3413498266Sopenharmony_ci#endif
3513498266Sopenharmony_ci#ifdef HAVE_ARPA_INET_H
3613498266Sopenharmony_ci#  include <arpa/inet.h>
3713498266Sopenharmony_ci#endif
3813498266Sopenharmony_ci
3913498266Sopenharmony_ci#ifdef __VMS
4013498266Sopenharmony_ci#  include <in.h>
4113498266Sopenharmony_ci#  include <inet.h>
4213498266Sopenharmony_ci#  include <stdlib.h>
4313498266Sopenharmony_ci#endif
4413498266Sopenharmony_ci
4513498266Sopenharmony_ci/*
4613498266Sopenharmony_ci * Curl_addrinfo is our internal struct definition that we use to allow
4713498266Sopenharmony_ci * consistent internal handling of this data. We use this even when the
4813498266Sopenharmony_ci * system provides an addrinfo structure definition. And we use this for
4913498266Sopenharmony_ci * all sorts of IPv4 and IPV6 builds.
5013498266Sopenharmony_ci */
5113498266Sopenharmony_ci
5213498266Sopenharmony_cistruct Curl_addrinfo {
5313498266Sopenharmony_ci  int                   ai_flags;
5413498266Sopenharmony_ci  int                   ai_family;
5513498266Sopenharmony_ci  int                   ai_socktype;
5613498266Sopenharmony_ci  int                   ai_protocol;
5713498266Sopenharmony_ci  curl_socklen_t        ai_addrlen;   /* Follow rfc3493 struct addrinfo */
5813498266Sopenharmony_ci  char                 *ai_canonname;
5913498266Sopenharmony_ci  struct sockaddr      *ai_addr;
6013498266Sopenharmony_ci  struct Curl_addrinfo *ai_next;
6113498266Sopenharmony_ci};
6213498266Sopenharmony_ci
6313498266Sopenharmony_civoid
6413498266Sopenharmony_ciCurl_freeaddrinfo(struct Curl_addrinfo *cahead);
6513498266Sopenharmony_ci
6613498266Sopenharmony_ci#ifdef HAVE_GETADDRINFO
6713498266Sopenharmony_ciint
6813498266Sopenharmony_ciCurl_getaddrinfo_ex(const char *nodename,
6913498266Sopenharmony_ci                    const char *servname,
7013498266Sopenharmony_ci                    const struct addrinfo *hints,
7113498266Sopenharmony_ci                    struct Curl_addrinfo **result);
7213498266Sopenharmony_ci#endif
7313498266Sopenharmony_ci
7413498266Sopenharmony_cistruct Curl_addrinfo *
7513498266Sopenharmony_ciCurl_he2ai(const struct hostent *he, int port);
7613498266Sopenharmony_ci
7713498266Sopenharmony_cistruct Curl_addrinfo *
7813498266Sopenharmony_ciCurl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
7913498266Sopenharmony_ci
8013498266Sopenharmony_cistruct Curl_addrinfo *Curl_str2addr(char *dotted, int port);
8113498266Sopenharmony_ci
8213498266Sopenharmony_ci#ifdef USE_UNIX_SOCKETS
8313498266Sopenharmony_cistruct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
8413498266Sopenharmony_ci                                     bool abstract);
8513498266Sopenharmony_ci#endif
8613498266Sopenharmony_ci
8713498266Sopenharmony_ci#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
8813498266Sopenharmony_ci    defined(HAVE_FREEADDRINFO)
8913498266Sopenharmony_civoid
9013498266Sopenharmony_cicurl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, const char *source);
9113498266Sopenharmony_ci#endif
9213498266Sopenharmony_ci
9313498266Sopenharmony_ci#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
9413498266Sopenharmony_ciint
9513498266Sopenharmony_cicurl_dbg_getaddrinfo(const char *hostname, const char *service,
9613498266Sopenharmony_ci                     const struct addrinfo *hints, struct addrinfo **result,
9713498266Sopenharmony_ci                     int line, const char *source);
9813498266Sopenharmony_ci#endif
9913498266Sopenharmony_ci
10013498266Sopenharmony_ci#ifdef HAVE_GETADDRINFO
10113498266Sopenharmony_ci#ifdef USE_RESOLVE_ON_IPS
10213498266Sopenharmony_civoid Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port);
10313498266Sopenharmony_ci#else
10413498266Sopenharmony_ci#define Curl_addrinfo_set_port(x,y)
10513498266Sopenharmony_ci#endif
10613498266Sopenharmony_ci#endif
10713498266Sopenharmony_ci
10813498266Sopenharmony_ci#endif /* HEADER_CURL_ADDRINFO_H */
109