tor  0.4.2.0-alpha-dev
resolve.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_RESOLVE_H
12 #define TOR_RESOLVE_H
13 
14 #include "orconfig.h"
15 #include "lib/cc/torint.h"
17 #ifdef _WIN32
18 #include <winsock2.h>
19 #endif
20 
21 #if defined(HAVE_SECCOMP_H) && defined(__linux__)
22 #define USE_SANDBOX_GETADDRINFO
23 #endif
24 
25 struct tor_addr_t;
26 
27 MOCK_DECL(int, tor_lookup_hostname,(const char *name, uint32_t *addr));
28 MOCK_DECL(int, tor_addr_lookup,(const char *name, uint16_t family,
29  struct tor_addr_t *addr_out));
30 int tor_addr_port_lookup(const char *s, struct tor_addr_t *addr_out,
31  uint16_t *port_out);
32 
33 struct addrinfo;
34 #ifdef USE_SANDBOX_GETADDRINFO
35 
36 int tor_add_addrinfo(const char *addr);
37 
38 struct addrinfo;
40 int tor_getaddrinfo(const char *name, const char *servname,
41  const struct addrinfo *hints,
42  struct addrinfo **res);
43 void tor_freeaddrinfo(struct addrinfo *addrinfo);
44 void tor_free_getaddrinfo_cache(void);
45 #else /* !(defined(USE_SANDBOX_GETADDRINFO)) */
46 #define tor_getaddrinfo(name, servname, hints, res) \
47  getaddrinfo((name),(servname), (hints),(res))
48 #define tor_add_addrinfo(name) \
49  ((void)(name))
50 #define tor_freeaddrinfo(addrinfo) \
51  freeaddrinfo((addrinfo))
52 #define tor_free_getaddrinfo_cache()
53 #endif /* defined(USE_SANDBOX_GETADDRINFO) */
54 
55 void sandbox_disable_getaddrinfo_cache(void);
56 void tor_make_getaddrinfo_cache_active(void);
57 
58 #endif /* !defined(TOR_RESOLVE_H) */
int tor_addr_port_lookup(const char *s, struct tor_addr_t *addr_out, uint16_t *port_out)
Definition: resolve.c:255
Integer definitions used throughout Tor.
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94