aboutsummaryrefslogtreecommitdiff
path: root/src/lib/net/resolve.h
blob: f2280ae7e8b81da964a81dba7d5ff934d4150ec8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Copyright (c) 2003-2004, Roger Dingledine
 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
 * Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */

#ifndef TOR_RESOLVE_H
#define TOR_RESOLVE_H

#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/testsupport/testsupport.h"
#ifdef _WIN32
#include <winsock2.h>
#endif

#if defined(HAVE_SECCOMP_H) && defined(__linux__)
#define USE_SANDBOX_GETADDRINFO
#endif

MOCK_DECL(int,tor_lookup_hostname,(const char *name, uint32_t *addr));

struct addrinfo;
#ifdef USE_SANDBOX_GETADDRINFO
/** Pre-calls getaddrinfo in order to pre-record result. */
int tor_add_addrinfo(const char *addr);

struct addrinfo;
/** Replacement for getaddrinfo(), using pre-recorded results. */
int tor_getaddrinfo(const char *name, const char *servname,
                        const struct addrinfo *hints,
                        struct addrinfo **res);
void tor_freeaddrinfo(struct addrinfo *addrinfo);
void tor_free_getaddrinfo_cache(void);
void tor_make_getaddrinfo_cache_active(void);
#else /* !(defined(USE_SANDBOX_GETADDRINFO)) */
#define tor_getaddrinfo(name, servname, hints, res)  \
  getaddrinfo((name),(servname), (hints),(res))
#define tor_add_addrinfo(name) \
  ((void)(name))
#define tor_freeaddrinfo(addrinfo) \
  freeaddrinfo((addrinfo))
#define tor_free_getaddrinfo_cache()
#endif /* defined(USE_SANDBOX_GETADDRINFO) */

void sandbox_disable_getaddrinfo_cache(void);

#endif