hostip.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef __HOSTIP_H
  2. #define __HOSTIP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2004, 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: hostip.h,v 1.28 2004/01/07 09:19:35 bagder Exp $
  24. ***************************************************************************/
  25. #include "setup.h"
  26. #include "hash.h"
  27. struct addrinfo;
  28. struct hostent;
  29. struct SessionHandle;
  30. struct connectdata;
  31. void Curl_global_host_cache_init(void);
  32. void Curl_global_host_cache_dtor(void);
  33. curl_hash *Curl_global_host_cache_get(void);
  34. #define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
  35. struct Curl_dns_entry {
  36. Curl_addrinfo *addr;
  37. time_t timestamp;
  38. long inuse; /* use-counter, make very sure you decrease this
  39. when you're done using the address you received */
  40. };
  41. /*
  42. * Curl_resolv() returns an entry with the info for the specified host
  43. * and port.
  44. *
  45. * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
  46. * use, or we'll leak memory!
  47. */
  48. int Curl_resolv(struct connectdata *conn,
  49. char *hostname,
  50. int port,
  51. struct Curl_dns_entry **dnsentry);
  52. CURLcode Curl_is_resolved(struct connectdata *conn,
  53. struct Curl_dns_entry **dns);
  54. CURLcode Curl_wait_for_resolv(struct connectdata *conn,
  55. struct Curl_dns_entry **dnsentry);
  56. CURLcode Curl_multi_ares_fdset(struct connectdata *conn,
  57. fd_set *read_fd_set,
  58. fd_set *write_fd_set,
  59. int *max_fdp);
  60. /* unlock a previously resolved dns entry */
  61. void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns);
  62. /* for debugging purposes only: */
  63. void Curl_scan_cache_used(void *user, void *ptr);
  64. /* free name info */
  65. void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
  66. /* free cached name info */
  67. void Curl_freednsinfo(void *freethis);
  68. /* prune old entries from the DNS cache */
  69. void Curl_hostcache_prune(struct SessionHandle *data);
  70. #ifdef CURLDEBUG
  71. void curl_freeaddrinfo(struct addrinfo *freethis,
  72. int line, const char *source);
  73. int curl_getaddrinfo(char *hostname, char *service,
  74. struct addrinfo *hints,
  75. struct addrinfo **result,
  76. int line, const char *source);
  77. #endif
  78. #ifndef INADDR_NONE
  79. #define CURL_INADDR_NONE (in_addr_t) ~0
  80. #else
  81. #define CURL_INADDR_NONE INADDR_NONE
  82. #endif
  83. #endif