curl_addrinfo.h 2.9 KB

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