curl_addrinfo.h 2.9 KB

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