Tor 0.4.9.0-alpha-dev
Macros | Functions
resolve.c File Reference

Use the libc DNS resolver to convert hostnames into addresses. More...

#include "lib/net/resolve.h"
#include "lib/net/address.h"
#include "lib/net/inaddr.h"
#include "lib/malloc/malloc.h"
#include "lib/string/parse_int.h"
#include "lib/string/util_string.h"
#include "ext/siphash.h"
#include "ext/ht.h"
#include <string.h>

Go to the source code of this file.

Functions

int tor_lookup_hostname (const char *name, uint32_t *addr)
 
STATIC int tor_addr_lookup_host_impl (const char *name, uint16_t family, tor_addr_t *addr)
 
int tor_addr_lookup (const char *name, uint16_t family, tor_addr_t *addr)
 
int tor_addr_port_lookup (const char *s, tor_addr_t *addr_out, uint16_t *port_out)
 
void sandbox_disable_getaddrinfo_cache (void)
 
void tor_make_getaddrinfo_cache_active (void)
 

Detailed Description

Use the libc DNS resolver to convert hostnames into addresses.

Definition in file resolve.c.

Macro Definition Documentation

◆ RESOLVE_PRIVATE

#define RESOLVE_PRIVATE

Definition at line 11 of file resolve.c.

Function Documentation

◆ sandbox_disable_getaddrinfo_cache()

void sandbox_disable_getaddrinfo_cache ( void  )

Definition at line 508 of file resolve.c.

◆ tor_addr_lookup()

int tor_addr_lookup ( const char *  name,
uint16_t  family,
tor_addr_t addr 
)

Similar behavior to Unix gethostbyname: resolve name, and set *addr to the proper IP address and family. The family argument (which must be AF_INET, AF_INET6, or AF_UNSPEC) declares a preferred family, though another one may be returned if only one family is implemented for this address.

Like tor_addr_parse(), this function accepts IPv6 addresses with or without square brackets.

Return 0 on success, -1 on failure; 1 on transient failure.

Definition at line 190 of file resolve.c.

◆ tor_addr_lookup_host_impl()

STATIC int tor_addr_lookup_host_impl ( const char *  name,
uint16_t  family,
tor_addr_t addr 
)

Definition at line 132 of file resolve.c.

◆ tor_addr_port_lookup()

int tor_addr_port_lookup ( const char *  s,
tor_addr_t addr_out,
uint16_t *  port_out 
)

Parse an address or address-port combination from s, resolve the address as needed, and put the result in addr_out and (optionally) port_out.

Like tor_addr_port_parse(), this function accepts:

  • IPv6 address and port, when the IPv6 address is in square brackets,
  • IPv6 address with square brackets,
  • IPv6 address without square brackets.

Return 0 on success, negative on failure.

Definition at line 252 of file resolve.c.

◆ tor_lookup_hostname()

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

Similar behavior to Unix gethostbyname: resolve name, and set *addr to the proper IP address, in host byte order. Returns 0 on success, -1 on failure; 1 on transient failure.

This function only accepts IPv4 addresses.

(This function exists because standard windows gethostbyname doesn't treat raw IP addresses properly.)

Definition at line 46 of file resolve.c.

◆ tor_make_getaddrinfo_cache_active()

void tor_make_getaddrinfo_cache_active ( void  )

Definition at line 512 of file resolve.c.