resolve.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef TOR_RESOLVE_H
  6. #define TOR_RESOLVE_H
  7. #include "orconfig.h"
  8. #include "lib/cc/torint.h"
  9. #include "lib/testsupport/testsupport.h"
  10. #ifdef _WIN32
  11. #include <winsock2.h>
  12. #endif
  13. #if defined(HAVE_SECCOMP_H) && defined(__linux__)
  14. #define USE_SANDBOX_GETADDRINFO
  15. #endif
  16. MOCK_DECL(int,tor_lookup_hostname,(const char *name, uint32_t *addr));
  17. struct addrinfo;
  18. #ifdef USE_SANDBOX_GETADDRINFO
  19. /** Pre-calls getaddrinfo in order to pre-record result. */
  20. int tor_add_addrinfo(const char *addr);
  21. struct addrinfo;
  22. /** Replacement for getaddrinfo(), using pre-recorded results. */
  23. int tor_getaddrinfo(const char *name, const char *servname,
  24. const struct addrinfo *hints,
  25. struct addrinfo **res);
  26. void tor_freeaddrinfo(struct addrinfo *addrinfo);
  27. void tor_free_getaddrinfo_cache(void);
  28. void tor_make_getaddrinfo_cache_active(void);
  29. #else /* !(defined(USE_SANDBOX_GETADDRINFO)) */
  30. #define tor_getaddrinfo(name, servname, hints, res) \
  31. getaddrinfo((name),(servname), (hints),(res))
  32. #define tor_add_addrinfo(name) \
  33. ((void)(name))
  34. #define tor_freeaddrinfo(addrinfo) \
  35. freeaddrinfo((addrinfo))
  36. #define tor_free_getaddrinfo_cache()
  37. #endif /* defined(USE_SANDBOX_GETADDRINFO) */
  38. void sandbox_disable_getaddrinfo_cache(void);
  39. #endif