* \brief Use the libc DNS resolver to convert hostnames into addresses.
**/
+#define RESOLVE_PRIVATE
#include "lib/net/resolve.h"
#include "lib/net/address.h"
*
* See tor_addr_lookup() for details.
*/
-static int
-tor_addr_lookup_host_impl(const char *name,
+MOCK_IMPL(STATIC int,
+tor_addr_lookup_host_impl,(const char *name,
uint16_t family,
- tor_addr_t *addr)
+ tor_addr_t *addr))
{
int err;
struct addrinfo *res=NULL, *res_p;
*
* See tor_addr_lookup() for details.
*/
-static int
-tor_addr_lookup_host_impl(const char *name,
+MOCK_IMPL(STATIC int,
+tor_addr_lookup_host_impl,(const char *name,
uint16_t family,
- tor_addr_t *addr)
+ tor_addr_t *addr))
{
(void) family;
struct hostent *ent;
return (err == TRY_AGAIN) ? 1 : -1;
#endif
}
-
#endif /* defined(HAVE_GETADDRINFO) */
/** Similar behavior to Unix gethostbyname: resolve <b>name</b>, and set
struct tor_addr_t;
+/*
+ * Primary lookup functions.
+ */
MOCK_DECL(int, tor_lookup_hostname,(const char *name, uint32_t *addr));
MOCK_DECL(int, tor_addr_lookup,(const char *name, uint16_t family,
struct tor_addr_t *addr_out));
int tor_addr_port_lookup(const char *s, struct tor_addr_t *addr_out,
uint16_t *port_out);
+/*
+ * Sandbox helpers
+ */
struct addrinfo;
#ifdef USE_SANDBOX_GETADDRINFO
/** Pre-calls getaddrinfo in order to pre-record result. */
void sandbox_disable_getaddrinfo_cache(void);
void tor_make_getaddrinfo_cache_active(void);
+/*
+ * Internal resolver wrapper; exposed for mocking.
+ */
+#ifdef RESOLVE_PRIVATE
+MOCK_DECL(STATIC int, tor_addr_lookup_host_impl, (const char *name,
+ uint16_t family,
+ struct tor_addr_t *addr));
+#endif
+
#endif /* !defined(TOR_RESOLVE_H) */