resolve.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file resolve.h
  7. * \brief Header for resolve.c
  8. **/
  9. #ifndef TOR_RESOLVE_H
  10. #define TOR_RESOLVE_H
  11. #include "orconfig.h"
  12. #include "lib/cc/torint.h"
  13. #include "lib/testsupport/testsupport.h"
  14. #ifdef _WIN32
  15. #include <winsock2.h>
  16. #endif
  17. #if defined(HAVE_SECCOMP_H) && defined(__linux__)
  18. #define USE_SANDBOX_GETADDRINFO
  19. #endif
  20. MOCK_DECL(int,tor_lookup_hostname,(const char *name, uint32_t *addr));
  21. struct addrinfo;
  22. #ifdef USE_SANDBOX_GETADDRINFO
  23. /** Pre-calls getaddrinfo in order to pre-record result. */
  24. int tor_add_addrinfo(const char *addr);
  25. struct addrinfo;
  26. /** Replacement for getaddrinfo(), using pre-recorded results. */
  27. int tor_getaddrinfo(const char *name, const char *servname,
  28. const struct addrinfo *hints,
  29. struct addrinfo **res);
  30. void tor_freeaddrinfo(struct addrinfo *addrinfo);
  31. void tor_free_getaddrinfo_cache(void);
  32. void tor_make_getaddrinfo_cache_active(void);
  33. #else /* !(defined(USE_SANDBOX_GETADDRINFO)) */
  34. #define tor_getaddrinfo(name, servname, hints, res) \
  35. getaddrinfo((name),(servname), (hints),(res))
  36. #define tor_add_addrinfo(name) \
  37. ((void)(name))
  38. #define tor_freeaddrinfo(addrinfo) \
  39. freeaddrinfo((addrinfo))
  40. #define tor_free_getaddrinfo_cache()
  41. #endif /* defined(USE_SANDBOX_GETADDRINFO) */
  42. void sandbox_disable_getaddrinfo_cache(void);
  43. #endif