tor  master
Data Structures | Macros | Typedefs | Enumerations | Functions
address.h File Reference

Headers for address.h. More...

#include "orconfig.h"
#include "torint.h"
#include "compat.h"
#include "container.h"
Include dependency graph for address.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tor_addr_t
 
struct  tor_addr_port_t
 

Macros

#define TOR_ADDR_NULL   {AF_UNSPEC, {0}}
 
#define tor_addr_to_in6_addr8(x)   tor_addr_to_in6_assert(x)->s6_addr
 
#define tor_addr_to_in6_addr16(x)   S6_ADDR16(*tor_addr_to_in6_assert(x))
 
#define tor_addr_to_in6_addr32(x)   S6_ADDR32(*tor_addr_to_in6_assert(x))
 
#define TOR_ADDR_BUF_LEN   48
 
#define fmt_addr(a)   fmt_addr_impl((a), 0)
 
#define fmt_and_decorate_addr(a)   fmt_addr_impl((a), 1)
 
#define interface_address6_list_free(addrs)   FREE_AND_NULL(smartlist_t, interface_address6_list_free_, (addrs))
 
#define tor_addr_eq(a, b)   (0==tor_addr_compare((a),(b),CMP_EXACT))
 
#define tor_addr_is_internal(addr, for_listening)   tor_addr_is_internal_((addr), (for_listening), SHORT_FILE__, __LINE__)
 
#define REVERSE_LOOKUP_NAME_BUF_LEN   73
 
#define TAPMP_EXTENDED_STAR   1
 
#define TAPMP_STAR_IPV4_ONLY   (1 << 1)
 
#define TAPMP_STAR_IPV6_ONLY   (1 << 2)
 
#define tor_addr_from_ipv4h(dest, v4addr)   tor_addr_from_ipv4n((dest), htonl(v4addr))
 
#define tor_addr_from_in(dest, in)   tor_addr_from_ipv4n((dest), (in)->s_addr);
 
#define tor_addr_is_valid_ipv4h(v4h_addr, for_listening)   tor_addr_is_valid_ipv4n(htonl(v4h_addr), (for_listening))
 
#define tor_addr_port_is_valid(addr, port, for_listening)
 
#define tor_addr_port_is_valid_ap(ap, for_listening)   tor_addr_port_is_valid(&(ap)->addr, (ap)->port, (for_listening))
 
#define tor_addr_port_is_valid_ipv4n(v4n_addr, port, for_listening)
 
#define tor_addr_port_is_valid_ipv4h(v4h_addr, port, for_listening)
 
#define INET_NTOA_BUF_LEN   16
 
#define interface_address_list_free(lst)   interface_address6_list_free(lst)
 

Typedefs

typedef uint8_t maskbits_t
 
typedef struct tor_addr_t tor_addr_t
 
typedef struct tor_addr_port_t tor_addr_port_t
 

Enumerations

enum  tor_addr_comparison_t { CMP_EXACT, CMP_SEMANTIC }
 

Functions

socklen_t tor_addr_to_sockaddr (const tor_addr_t *a, uint16_t port, struct sockaddr *sa_out, socklen_t len)
 
int tor_addr_from_sockaddr (tor_addr_t *a, const struct sockaddr *sa, uint16_t *port_out)
 
void tor_addr_make_unspec (tor_addr_t *a)
 
void tor_addr_make_null (tor_addr_t *a, sa_family_t family)
 
char * tor_sockaddr_to_str (const struct sockaddr *sa)
 
 MOCK_DECL (int, tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr_out))
 
char * tor_addr_to_str_dup (const tor_addr_t *addr) ATTR_MALLOC
 
const char * fmt_addr_impl (const tor_addr_t *addr, int decorate)
 
const char * fmt_addrport (const tor_addr_t *addr, uint16_t port)
 
const char * fmt_addr32 (uint32_t addr)
 
 MOCK_DECL (int, get_interface_address6,(int severity, sa_family_t family, tor_addr_t *addr))
 
void interface_address6_list_free_ (smartlist_t *addrs)
 
 MOCK_DECL (smartlist_t *, get_interface_address6_list,(int severity, sa_family_t family, int include_internal))
 
int tor_addr_compare (const tor_addr_t *addr1, const tor_addr_t *addr2, tor_addr_comparison_t how)
 
int tor_addr_compare_masked (const tor_addr_t *addr1, const tor_addr_t *addr2, maskbits_t mask, tor_addr_comparison_t how)
 
uint64_t tor_addr_hash (const tor_addr_t *addr)
 
uint64_t tor_addr_keyed_hash (const struct sipkey *key, const tor_addr_t *addr)
 
int tor_addr_is_v4 (const tor_addr_t *addr)
 
int tor_addr_is_internal_ (const tor_addr_t *ip, int for_listening, const char *filename, int lineno)
 
int tor_addr_is_multicast (const tor_addr_t *a)
 
int tor_addr_to_PTR_name (char *out, size_t outlen, const tor_addr_t *addr)
 
int tor_addr_parse_PTR_name (tor_addr_t *result, const char *address, int family, int accept_regular)
 
int tor_addr_port_lookup (const char *s, tor_addr_t *addr_out, uint16_t *port_out)
 
int tor_addr_parse_mask_ports (const char *s, unsigned flags, tor_addr_t *addr_out, maskbits_t *mask_out, uint16_t *port_min_out, uint16_t *port_max_out)
 
const char * tor_addr_to_str (char *dest, const tor_addr_t *addr, size_t len, int decorate)
 
int tor_addr_parse (tor_addr_t *addr, const char *src)
 
void tor_addr_copy (tor_addr_t *dest, const tor_addr_t *src)
 
void tor_addr_copy_tight (tor_addr_t *dest, const tor_addr_t *src)
 
void tor_addr_from_ipv4n (tor_addr_t *dest, uint32_t v4addr)
 
void tor_addr_from_ipv6_bytes (tor_addr_t *dest, const char *bytes)
 
void tor_addr_from_in6 (tor_addr_t *dest, const struct in6_addr *in6)
 
int tor_addr_is_null (const tor_addr_t *addr)
 
int tor_addr_is_loopback (const tor_addr_t *addr)
 
int tor_addr_is_valid (const tor_addr_t *addr, int for_listening)
 
int tor_addr_is_valid_ipv4n (uint32_t v4n_addr, int for_listening)
 
int tor_port_is_valid (uint16_t port, int for_listening)
 
int tor_addr_port_split (int severity, const char *addrport, char **address_out, uint16_t *port_out)
 
int tor_addr_port_parse (int severity, const char *addrport, tor_addr_t *address_out, uint16_t *port_out, int default_port)
 
int tor_addr_hostname_is_local (const char *name)
 
int addr_port_lookup (int severity, const char *addrport, char **address, uint32_t *addr, uint16_t *port_out)
 
int parse_port_range (const char *port, uint16_t *port_min_out, uint16_t *port_max_out)
 
int addr_mask_get_bits (uint32_t mask)
 
int tor_inet_ntoa (const struct in_addr *in, char *buf, size_t buf_len)
 
char * tor_dup_ip (uint32_t addr) ATTR_MALLOC
 
 MOCK_DECL (int, get_interface_address,(int severity, uint32_t *addr))
 
tor_addr_port_ttor_addr_port_new (const tor_addr_t *addr, uint16_t port)
 
int tor_addr_port_eq (const tor_addr_port_t *a, const tor_addr_port_t *b)
 

Detailed Description

Headers for address.h.

Macro Definition Documentation

◆ fmt_addr

#define fmt_addr (   a)    fmt_addr_impl((a), 0)

Wrapper function of fmt_addr_impl(). It does not decorate IPv6 addresses.

◆ fmt_and_decorate_addr

#define fmt_and_decorate_addr (   a)    fmt_addr_impl((a), 1)

Wrapper function of fmt_addr_impl(). It decorates IPv6 addresses.

◆ INET_NTOA_BUF_LEN

#define INET_NTOA_BUF_LEN   16

Length of a buffer to allocate to hold the results of tor_inet_ntoa.

◆ REVERSE_LOOKUP_NAME_BUF_LEN

#define REVERSE_LOOKUP_NAME_BUF_LEN   73

Longest length that can be required for a reverse lookup name.

◆ TOR_ADDR_BUF_LEN

#define TOR_ADDR_BUF_LEN   48

Length of a buffer that you need to allocate to be sure you can encode any tor_addr_t.

This allows enough space for "[ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]", plus a terminating NUL.

◆ tor_addr_eq

#define tor_addr_eq (   a,
 
)    (0==tor_addr_compare((a),(b),CMP_EXACT))

Return true iff a and b are the same address. The comparison is done "exactly".

◆ tor_addr_from_in

#define tor_addr_from_in (   dest,
  in 
)    tor_addr_from_ipv4n((dest), (in)->s_addr);

Set dest to the IPv4 address incoded in in.

◆ tor_addr_from_ipv4h

#define tor_addr_from_ipv4h (   dest,
  v4addr 
)    tor_addr_from_ipv4n((dest), htonl(v4addr))

Set dest to the IPv4 address encoded in v4addr in host order.

◆ tor_addr_port_is_valid

#define tor_addr_port_is_valid (   addr,
  port,
  for_listening 
)
Value:
(tor_addr_is_valid((addr), (for_listening)) && \
tor_port_is_valid((port), (for_listening)))

◆ tor_addr_port_is_valid_ipv4h

#define tor_addr_port_is_valid_ipv4h (   v4h_addr,
  port,
  for_listening 
)
Value:
(tor_addr_is_valid_ipv4h((v4h_addr), (for_listening)) && \
tor_port_is_valid((port), (for_listening)))

◆ tor_addr_port_is_valid_ipv4n

#define tor_addr_port_is_valid_ipv4n (   v4n_addr,
  port,
  for_listening 
)
Value:
(tor_addr_is_valid_ipv4n((v4n_addr), (for_listening)) && \
tor_port_is_valid((port), (for_listening)))

◆ tor_addr_to_in6_addr16

#define tor_addr_to_in6_addr16 (   x)    S6_ADDR16(*tor_addr_to_in6_assert(x))

Given an IPv6 address x, yield it as an array of uint16_t.

Requires that x is actually an IPv6 address.

◆ tor_addr_to_in6_addr32

#define tor_addr_to_in6_addr32 (   x)    S6_ADDR32(*tor_addr_to_in6_assert(x))

Given an IPv6 address x, yield it as an array of uint32_t.

Requires that x is actually an IPv6 address.

◆ tor_addr_to_in6_addr8

#define tor_addr_to_in6_addr8 (   x)    tor_addr_to_in6_assert(x)->s6_addr

Given an IPv6 address x, yield it as an array of uint8_t.

Requires that x is actually an IPv6 address.

Typedef Documentation

◆ maskbits_t

typedef uint8_t maskbits_t

The number of bits from an address to consider while doing a masked comparison.

◆ tor_addr_port_t

Holds an IP address and a TCP/UDP port.

◆ tor_addr_t

typedef struct tor_addr_t tor_addr_t

Holds an IPv4 or IPv6 address. (Uses less memory than struct sockaddr_storage.)

Enumeration Type Documentation

◆ tor_addr_comparison_t

Flag to specify how to do a comparison between addresses. In an "exact" comparison, addresses are equivalent only if they are in the same family with the same value. In a "semantic" comparison, IPv4 addresses match all IPv6 encodings of those addresses.

Function Documentation

◆ addr_mask_get_bits()

int addr_mask_get_bits ( uint32_t  mask)

If mask is an address mask for a bit-prefix, return the number of bits. Otherwise, return -1.

◆ addr_port_lookup()

int addr_port_lookup ( int  severity,
const char *  addrport,
char **  address,
uint32_t *  addr,
uint16_t *  port_out 
)

Parse a string of the form "host[:port]" from addrport. If address is provided, set *address to a copy of the host portion of the string. If addr is provided, try to resolve the host portion of the string and store it into *addr (in host byte order). If port_out is provided, store the port number into *port_out, or 0 if no port is given. If port_out is NULL, then there must be no port number in addrport. Return 0 on success, -1 on failure.

◆ fmt_addr32()

const char* fmt_addr32 ( uint32_t  addr)

Like fmt_addr(), but takes addr as a host-order IPv4 addresses. Also not thread-safe, also clobbers its return buffer on repeated calls.

Here is the call graph for this function:

◆ fmt_addr_impl()

const char* fmt_addr_impl ( const tor_addr_t addr,
int  decorate 
)

Return a string representing the address addr. This string is statically allocated, and must not be freed. Each call to fmt_addr_impl invalidates the last result of the function. This function is not thread-safe. If decorate is set, add brackets to IPv6 addresses.

It's better to use the wrapper macros of this function: fmt_addr() and fmt_and_decorate_addr().

Here is the call graph for this function:

◆ fmt_addrport()

const char* fmt_addrport ( const tor_addr_t addr,
uint16_t  port 
)

Return a string representing the pair addr and port. This calls fmt_and_decorate_addr internally, so IPv6 addresses will have brackets, and the caveats of fmt_addr_impl apply.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ interface_address6_list_free_()

void interface_address6_list_free_ ( smartlist_t addrs)

Free a smartlist of IP addresses returned by get_interface_address6_list.

◆ parse_port_range()

int parse_port_range ( const char *  port,
uint16_t *  port_min_out,
uint16_t *  port_max_out 
)

Parse a string s in the format of (*|port(-maxport)?)?, setting the various *out pointers as appropriate. Return 0 on success, -1 on failure.

Here is the call graph for this function:

◆ tor_addr_compare()

int tor_addr_compare ( const tor_addr_t addr1,
const tor_addr_t addr2,
tor_addr_comparison_t  how 
)

Given two addresses addr1 and addr2, return 0 if the two addresses are equivalent under the mask mbits, less than 0 if addr1 precedes addr2, and greater than 0 otherwise.

Different address families (IPv4 vs IPv6) are always considered unequal if how is CMP_EXACT; otherwise, IPv6-mapped IPv4 addresses are considered equivalent to their IPv4 equivalents.

As a special case, all pointer-wise distinct AF_UNIX addresses are always considered unequal since tor_addr_t currently does not contain the information required to make the comparison.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tor_addr_compare_masked()

int tor_addr_compare_masked ( const tor_addr_t addr1,
const tor_addr_t addr2,
maskbits_t  mbits,
tor_addr_comparison_t  how 
)

As tor_addr_compare(), but only looks at the first mask bits of the address.

Reduce over-specific masks (>128 for ipv6, >32 for ipv4) to 128 or 32.

The mask is interpreted relative to addr1, so that if a is ::ffff:1.2.3.4, and b is 3.4.5.6, tor_addr_compare_masked(a,b,100,CMP_SEMANTIC) is the same as -tor_addr_compare_masked(b,a,4,CMP_SEMANTIC).

We guarantee that the ordering from tor_addr_compare_masked is a total order on addresses, but not that it is any particular order, or that it will be the same from one version to the next.

Helper: Evaluates to -1 if a is less than b, 0 if a equals b, or 1 if a is greater than b. May evaluate a and b more than once.

Here is the caller graph for this function:

◆ tor_addr_copy()

void tor_addr_copy ( tor_addr_t dest,
const tor_addr_t src 
)

Copy a tor_addr_t from src to dest.

Here is the caller graph for this function:

◆ tor_addr_copy_tight()

void tor_addr_copy_tight ( tor_addr_t dest,
const tor_addr_t src 
)

Copy a tor_addr_t from src to dest, taking extra care to copy only the well-defined portions. Used for computing hashes of addresses.

◆ tor_addr_from_in6()

void tor_addr_from_in6 ( tor_addr_t dest,
const struct in6_addr in6 
)

Set dest equal to the IPv6 address in the in6_addr in6.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tor_addr_from_ipv4n()

void tor_addr_from_ipv4n ( tor_addr_t dest,
uint32_t  v4addr 
)

Set dest to equal the IPv4 address in v4addr (given in network order).

Here is the caller graph for this function:

◆ tor_addr_from_ipv6_bytes()

void tor_addr_from_ipv6_bytes ( tor_addr_t dest,
const char *  ipv6_bytes 
)

Set dest to equal the IPv6 address in the 16 bytes at ipv6_bytes.

Here is the caller graph for this function:

◆ tor_addr_from_sockaddr()

int tor_addr_from_sockaddr ( tor_addr_t a,
const struct sockaddr *  sa,
uint16_t *  port_out 
)

Set the tor_addr_t in a to contain the socket address contained in sa. IF port_out is non-NULL and sa contains a port, set *port_out to that port. Return 0 on success and -1 on failure.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tor_addr_hash()

uint64_t tor_addr_hash ( const tor_addr_t addr)

Return a hash code based on the address addr. DOCDOC extra

◆ tor_addr_hostname_is_local()

int tor_addr_hostname_is_local ( const char *  name)

Return true if we can tell that name is a canonical name for the loopback address. Return true also for *.local hostnames, which are multicast DNS names for hosts on the local network.

◆ tor_addr_is_internal_()

int tor_addr_is_internal_ ( const tor_addr_t addr,
int  for_listening,
const char *  filename,
int  lineno 
)

Return true iff ip is an IP reserved to localhost or local networks in RFC1918 or RFC4193 or RFC4291. (fec0::/10, deprecated by RFC3879, is also treated as internal for now.)

◆ tor_addr_is_loopback()

int tor_addr_is_loopback ( const tor_addr_t addr)

Return true iff addr is a loopback address

Here is the caller graph for this function:

◆ tor_addr_is_multicast()

int tor_addr_is_multicast ( const tor_addr_t a)

Return true iff a is a multicast address.

Here is the caller graph for this function:

◆ tor_addr_is_null()

int tor_addr_is_null ( const tor_addr_t addr)

Determine whether an address addr is null, either all zeroes or belonging to family AF_UNSPEC.

Here is the caller graph for this function:

◆ tor_addr_is_v4()

int tor_addr_is_v4 ( const tor_addr_t addr)

Determine whether an address is IPv4, either native or IPv4-mapped IPv6. Note that this is about representation only, as any decent stack will reject IPv4-mapped addresses received on the wire (and won't use them on the wire either).

◆ tor_addr_keyed_hash()

uint64_t tor_addr_keyed_hash ( const struct sipkey key,
const tor_addr_t addr 
)

As tor_addr_hash, but use a particular siphash key.

Here is the caller graph for this function:

◆ tor_addr_make_null()

void tor_addr_make_null ( tor_addr_t a,
sa_family_t  family 
)

Set address a to the null address in address family family. The null address for AF_INET is 0.0.0.0. The null address for AF_INET6 is [::]. AF_UNSPEC is all null.

Here is the caller graph for this function:

◆ tor_addr_make_unspec()

void tor_addr_make_unspec ( tor_addr_t a)

Set address a to the unspecified address. This address belongs to no family.

Here is the caller graph for this function:

◆ tor_addr_parse()

int tor_addr_parse ( tor_addr_t addr,
const char *  src 
)

Convert the string in src to a tor_addr_t addr. The string may be an IPv4 address, an IPv6 address, or an IPv6 address surrounded by square brackets.

Return an address family on success, or -1 if an invalid address string is provided.

Here is the caller graph for this function:

◆ tor_addr_parse_mask_ports()

int tor_addr_parse_mask_ports ( const char *  s,
unsigned  flags,
tor_addr_t addr_out,
maskbits_t maskbits_out,
uint16_t *  port_min_out,
uint16_t *  port_max_out 
)

Parse a string s containing an IPv4/IPv6 address, and possibly a mask and port or port range. Store the parsed address in addr_out, a mask (if any) in mask_out, and port(s) (if any) in port_min_out and port_max_out.

The syntax is: Address OptMask OptPortRange Address ::= IPv4Address / "[" IPv6Address "]" / "*" OptMask ::= "/" Integer / OptPortRange ::= ":*" / ":" Integer / ":" Integer "-" Integer /

  • If mask, minport, or maxport are NULL, we do not want these options to be set; treat them as an error if present.
  • If the string has no mask, the mask is set to /32 (IPv4) or /128 (IPv6).
  • If the string has one port, it is placed in both min and max port variables.
  • If the string has no port(s), port_(min|max)_out are set to 1 and 65535.

Return an address family on success, or -1 if an invalid address string is provided.

If 'flags & TAPMP_EXTENDED_STAR' is false, then the wildcard address '*' yield an IPv4 wildcard.

If 'flags & TAPMP_EXTENDED_STAR' is true, then the wildcard address '*' yields an AF_UNSPEC wildcard address, which expands to corresponding wildcard IPv4 and IPv6 rules, and the following change is made in the grammar above: Address ::= IPv4Address / "[" IPv6Address "]" / "*" / "*4" / "*6" with the new "*4" and "*6" productions creating a wildcard to match IPv4 or IPv6 addresses.

If 'flags & TAPMP_EXTENDED_STAR' and 'flags & TAPMP_STAR_IPV4_ONLY' are both true, then the wildcard address '*' yields an IPv4 wildcard.

If 'flags & TAPMP_EXTENDED_STAR' and 'flags & TAPMP_STAR_IPV6_ONLY' are both true, then the wildcard address '*' yields an IPv6 wildcard.

TAPMP_STAR_IPV4_ONLY and TAPMP_STAR_IPV6_ONLY are mutually exclusive.

Longest possible length for an address, mask, and port-range combination. Includes IP, [], /mask, :, ports

◆ tor_addr_parse_PTR_name()

int tor_addr_parse_PTR_name ( tor_addr_t result,
const char *  address,
int  family,
int  accept_regular 
)

Parse an .in-addr.arpa or .ip6.arpa address from address. Return 0 if this is not an .in-addr.arpa address or an .ip6.arpa address. Return -1 if this is an ill-formed .in-addr.arpa address or an .ip6.arpa address. Also return -1 if family is not AF_UNSPEC, and the parsed address family does not match family. On success, return 1, and store the result, if any, into result, if provided.

If accept_regular is set and the address is in neither recognized reverse lookup hostname format, try parsing the address as a regular IPv4 or IPv6 address too.

Here is the call graph for this function:

◆ tor_addr_port_eq()

int tor_addr_port_eq ( const tor_addr_port_t a,
const tor_addr_port_t b 
)

Return true iff a and b are the same address and port

◆ 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. Return 0 on success, negative on failure.

Here is the call graph for this function:

◆ tor_addr_port_new()

tor_addr_port_t* tor_addr_port_new ( const tor_addr_t addr,
uint16_t  port 
)

Return a newly allocated tor_addr_port_t with addr and port filled in.

◆ tor_addr_port_parse()

int tor_addr_port_parse ( int  severity,
const char *  addrport,
tor_addr_t address_out,
uint16_t *  port_out,
int  default_port 
)

Given an address of the form "ip:port", try to divide it into its ip and port portions, setting *address_out to a newly allocated string holding the address portion and *port_out to the port.

Don't do DNS lookups and don't allow domain names in the "ip" field.

If default_port is less than 0, don't accept addrport of the form "ip" or "ip:0". Otherwise, accept those forms, and set *port_out to default_port.

Return 0 on success, -1 on failure.

Here is the call graph for this function:

◆ tor_addr_port_split()

int tor_addr_port_split ( int  severity,
const char *  addrport,
char **  address_out,
uint16_t *  port_out 
)

Given an address of the form "host[:port]", try to divide it into its host and port portions, setting *address_out to a newly allocated string holding the address portion and *port_out to the port (or 0 if no port is given). Return 0 on success, -1 on failure.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tor_addr_to_PTR_name()

int tor_addr_to_PTR_name ( char *  out,
size_t  outlen,
const tor_addr_t addr 
)

Convert addr to an in-addr.arpa name or a .ip6.arpa name, and store the result in the outlen-byte buffer at out. Returns a non-negative integer on success. Returns -1 on failure.

◆ tor_addr_to_sockaddr()

socklen_t tor_addr_to_sockaddr ( const tor_addr_t a,
uint16_t  port,
struct sockaddr *  sa_out,
socklen_t  len 
)

Convert the tor_addr_t in a, with port in port, into a sockaddr object in *sa_out of object size len. If not enough room is available in sa_out, or on error, return 0. On success, return the length of the sockaddr.

Interface note: ordinarily, we return -1 for error. We can't do that here, since socklen_t is unsigned on some platforms.

◆ tor_addr_to_str()

const char* tor_addr_to_str ( char *  dest,
const tor_addr_t addr,
size_t  len,
int  decorate 
)

Convert a tor_addr_t addr into a string, and store it in dest of size len. Returns a pointer to dest on success, or NULL on failure. If decorate, surround IPv6 addresses with brackets.

Here is the caller graph for this function:

◆ tor_addr_to_str_dup()

char* tor_addr_to_str_dup ( const tor_addr_t addr)

Return a newly allocated string with a representation of addr.

Here is the call graph for this function:

◆ tor_dup_ip()

char* tor_dup_ip ( uint32_t  addr)

Given a host-order addr, call tor_inet_ntop() on it and return a strdup of the resulting address.

Here is the call graph for this function:

◆ tor_inet_ntoa()

int tor_inet_ntoa ( const struct in_addr *  in,
char *  buf,
size_t  buf_len 
)

Given an IPv4 in_addr struct *in (in network order, as usual), write it as a string into the buf_len-byte buffer in buf. Returns a non-negative integer on success. Returns -1 on failure.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tor_sockaddr_to_str()

char* tor_sockaddr_to_str ( const struct sockaddr *  sa)

Return a newly allocated string holding the address described in sa. AF_UNIX, AF_UNSPEC, AF_INET, and AF_INET6 are supported.

Here is the call graph for this function: