curl_addrinfo.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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, <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. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include "curl_setup.h"
  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. #ifdef __VMS
  37. # include <in.h>
  38. # include <inet.h>
  39. # include <stdlib.h>
  40. #endif
  41. /*
  42. * Curl_addrinfo is our internal struct definition that we use to allow
  43. * consistent internal handling of this data. We use this even when the
  44. * system provides an addrinfo structure definition. And we use this for
  45. * all sorts of IPv4 and IPV6 builds.
  46. */
  47. struct Curl_addrinfo {
  48. int ai_flags;
  49. int ai_family;
  50. int ai_socktype;
  51. int ai_protocol;
  52. curl_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
  53. char *ai_canonname;
  54. struct sockaddr *ai_addr;
  55. struct Curl_addrinfo *ai_next;
  56. };
  57. void
  58. Curl_freeaddrinfo(struct Curl_addrinfo *cahead);
  59. #ifdef HAVE_GETADDRINFO
  60. int
  61. Curl_getaddrinfo_ex(const char *nodename,
  62. const char *servname,
  63. const struct addrinfo *hints,
  64. struct Curl_addrinfo **result);
  65. #endif
  66. struct Curl_addrinfo *
  67. Curl_he2ai(const struct hostent *he, int port);
  68. struct Curl_addrinfo *
  69. Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
  70. struct Curl_addrinfo *Curl_str2addr(char *dotted, int port);
  71. #ifdef USE_UNIX_SOCKETS
  72. struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
  73. bool abstract);
  74. #endif
  75. #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
  76. defined(HAVE_FREEADDRINFO)
  77. void
  78. curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, const char *source);
  79. #endif
  80. #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
  81. int
  82. curl_dbg_getaddrinfo(const char *hostname, const char *service,
  83. const struct addrinfo *hints, struct addrinfo **result,
  84. int line, const char *source);
  85. #endif
  86. #ifdef HAVE_GETADDRINFO
  87. #ifdef USE_RESOLVE_ON_IPS
  88. void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port);
  89. #else
  90. #define Curl_addrinfo_set_port(x,y)
  91. #endif
  92. #endif
  93. #endif /* HEADER_CURL_ADDRINFO_H */