GetAddrInfo.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef netwerk_dns_GetAddrInfo_h
  6. #define netwerk_dns_GetAddrInfo_h
  7. #include "nsError.h"
  8. #include "nscore.h"
  9. #if defined(XP_WIN)
  10. #define DNSQUERY_AVAILABLE 1
  11. #define TTL_AVAILABLE 1
  12. #else
  13. #define DNSQUERY_AVAILABLE 0
  14. #define TTL_AVAILABLE 0
  15. #endif
  16. namespace mozilla {
  17. namespace net {
  18. class AddrInfo;
  19. /**
  20. * Look up a host by name. Mostly equivalent to getaddrinfo(host, NULL, ...) of
  21. * RFC 3493.
  22. *
  23. * @param aHost[in] Character string defining the host name of interest
  24. * @param aAddressFamily[in] May be AF_INET, AF_INET6, or AF_UNSPEC.
  25. * @param aFlags[in] May be either PR_AI_ADDRCONFIG or
  26. * PR_AI_ADDRCONFIG | PR_AI_NOCANONNAME. Include PR_AI_NOCANONNAME to
  27. * suppress the determination of the canonical name corresponding to
  28. * hostname (PR_AI_NOCANONNAME will be ignored if the TTL is retrieved).
  29. * @param aAddrInfo[out] Will point to the results of the host lookup, or be
  30. * null if the lookup failed.
  31. * @param aGetTtl[in] If true, and TTL_AVAILABLE is truthy, the TTL will be
  32. * retrieved if DNS provides the answers..
  33. */
  34. nsresult
  35. GetAddrInfo(const char* aHost, uint16_t aAddressFamily, uint16_t aFlags,
  36. const char* aNetworkInterface, AddrInfo** aAddrInfo, bool aGetTtl);
  37. /**
  38. * Initialize the GetAddrInfo module.
  39. *
  40. * GetAddrInfoShutdown() should be called for every time this function is
  41. * called.
  42. */
  43. nsresult
  44. GetAddrInfoInit();
  45. /**
  46. * Shutdown the GetAddrInfo module.
  47. *
  48. * This function should be called for every time GetAddrInfoInit() is called.
  49. * An assertion may throw (but is not guarenteed) if this function is called
  50. * too many times.
  51. */
  52. nsresult
  53. GetAddrInfoShutdown();
  54. } // namespace net
  55. } // namespace mozilla
  56. #endif // netwerk_dns_GetAddrInfo_h