14 #define ADDRESS_PRIVATE
20 #ifndef WIN32_LEAN_AND_MEAN
21 #error "orconfig.h didn't define WIN32_LEAN_AND_MEAN"
24 #error "orconfig.h didn't define WINVER"
27 #error "orconfig.h didn't define _WIN32_WINNT"
30 #error "winver too low"
32 #if _WIN32_WINNT < 0x0501
33 #error "winver too low"
56 #include "ext/siphash.h"
58 #ifdef HAVE_SYS_TIME_H
67 #ifdef HAVE_ARPA_INET_H
68 #include <arpa/inet.h>
70 #ifdef HAVE_SYS_SOCKET_H
71 #include <sys/socket.h>
76 #ifdef HAVE_SYS_PARAM_H
77 #include <sys/param.h>
85 #ifdef HAVE_SYS_IOCTL_H
86 #include <sys/ioctl.h>
100 #error "We rely on AF_UNSPEC being 0. Yours isn't. Please tell us more!"
115 struct sockaddr *sa_out,
118 memset(sa_out, 0, len);
121 if (family == AF_INET) {
122 struct sockaddr_in *sin;
123 if (len < (
int)
sizeof(
struct sockaddr_in))
125 sin = (
struct sockaddr_in *)sa_out;
126 #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
127 sin->sin_len =
sizeof(
struct sockaddr_in);
129 sin->sin_family = AF_INET;
130 sin->sin_port = htons(port);
132 return sizeof(
struct sockaddr_in);
133 }
else if (family == AF_INET6) {
138 #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
141 sin6->sin6_family = AF_INET6;
142 sin6->sin6_port = htons(port);
156 memset(a, 0,
sizeof(*a));
173 memset(a, 0,
sizeof(*a));
175 if (sa->sa_family == AF_INET) {
176 struct sockaddr_in *sin = (
struct sockaddr_in *) sa;
179 *port_out = ntohs(sin->sin_port);
180 }
else if (sa->sa_family == AF_INET6) {
184 *port_out = ntohs(sin6->sin6_port);
185 }
else if (sa->sa_family == AF_UNIX) {
205 if (sa->sa_family == AF_UNIX) {
206 struct sockaddr_un *s_un = (
struct sockaddr_un *)sa;
211 if (sa->sa_family == AF_UNSPEC)
212 return tor_strdup(
"unspec");
227 memset(a, 0,
sizeof(*a));
228 a->family = AF_UNSPEC;
237 memset(a, 0,
sizeof(*a));
256 const char *filename,
int lineno)
264 if (v_family == AF_INET) {
266 }
else if (v_family == AF_INET6) {
268 uint32_t *addr32 = NULL;
276 iph4 = ntohl(addr32[3]);
280 if (v_family == AF_INET6) {
282 iph6[0] = ntohl(a32[0]);
283 iph6[1] = ntohl(a32[1]);
284 iph6[2] = ntohl(a32[2]);
285 iph6[3] = ntohl(a32[3]);
286 if (for_listening && !iph6[0] && !iph6[1] && !iph6[2] && !iph6[3])
289 if (((iph6[0] & 0xfe000000) == 0xfc000000) ||
290 ((iph6[0] & 0xffc00000) == 0xfe800000) ||
291 ((iph6[0] & 0xffc00000) == 0xfec00000))
294 if (!iph6[0] && !iph6[1] && !iph6[2] &&
295 ((iph6[3] & 0xfffffffe) == 0x00000000))
299 }
else if (v_family == AF_INET) {
301 if (for_listening && (!iph4 || ((iph4 & 0xffc00000) == 0x64400000)))
303 if (((iph4 & 0xff000000) == 0x0a000000) ||
304 ((iph4 & 0xff000000) == 0x00000000) ||
305 ((iph4 & 0xff000000) == 0x7f000000) ||
306 ((iph4 & 0xffc00000) == 0x64400000) ||
307 ((iph4 & 0xffff0000) == 0xa9fe0000) ||
308 ((iph4 & 0xfff00000) == 0xac100000) ||
309 ((iph4 & 0xffff0000) == 0xc0a80000))
316 log_warn(
LD_BUG,
"tor_addr_is_internal() called from %s:%d with a "
317 "non-IP address of type %d", filename, lineno, (
int)v_family);
338 ptr =
tor_inet_ntop(AF_INET, &addr->addr.in_addr, dest, len);
342 if (len < (3u + (decorate ? 2 : 0)))
346 ptr =
tor_inet_ntop(AF_INET6, &addr->addr.in6_addr, dest+1, len-2);
348 ptr =
tor_inet_ntop(AF_INET6, &addr->addr.in6_addr, dest, len);
350 if (ptr && decorate) {
352 memcpy(dest+strlen(dest),
"]", 2);
381 int family,
int accept_regular)
387 struct in_addr inaddr;
388 if (family == AF_INET6)
391 len = strlen(address) - strlen(
".in-addr.arpa");
395 memcpy(buf, address, len);
401 inaddr.s_addr = (uint32_t)
402 (((inaddr.s_addr & 0x000000ff) << 24)
403 |((inaddr.s_addr & 0x0000ff00) << 8)
404 |((inaddr.s_addr & 0x00ff0000) >> 8)
405 |((inaddr.s_addr & 0xff000000) >> 24));
418 if (family == AF_INET)
422 for (
int i = 0; i < 16; ++i) {
424 if (*cp++ !=
'.')
return -1;
426 if (*cp++ !=
'.')
return -1;
437 in6.s6_addr[15-i] = n0 | (n1 << 4);
439 if (strcasecmp(cp,
"ip6.arpa"))
448 if (accept_regular) {
453 if (r != family && family != AF_UNSPEC)
476 if (addr->family == AF_INET) {
479 return tor_snprintf(out, outlen,
"%d.%d.%d.%d.in-addr.arpa",
480 (
int)(uint8_t)((a )&0xff),
481 (
int)(uint8_t)((a>>8 )&0xff),
482 (
int)(uint8_t)((a>>16)&0xff),
483 (
int)(uint8_t)((a>>24)&0xff));
484 }
else if (addr->family == AF_INET6) {
490 for (i = 15; i >= 0; --i) {
491 uint8_t
byte = bytes[i];
492 *cp++ =
"0123456789abcdef"[
byte & 0x0f];
494 *cp++ =
"0123456789abcdef"[
byte >> 4];
497 memcpy(cp,
"ip6.arpa", 9);
547 uint16_t *port_min_out, uint16_t *port_max_out)
549 char *base = NULL, *address, *mask = NULL, *port = NULL, *rbracket = NULL;
551 int any_flag=0, v4map=0;
554 struct in_addr in_tmp = { .s_addr = 0 };
561 && (flags & TAPMP_STAR_IPV6_ONLY)));
565 #define MAX_ADDRESS_LENGTH (TOR_ADDR_BUF_LEN+2+(1+INET_NTOA_BUF_LEN)+12+1)
567 if (strlen(s) > MAX_ADDRESS_LENGTH) {
571 base = tor_strdup(s);
575 if (*address ==
'[') {
577 rbracket = strchr(address,
']');
580 "No closing IPv6 bracket in address pattern; rejecting.");
584 mask = strchr((rbracket?rbracket:address),
'/');
585 port = strchr((mask?mask:(rbracket?rbracket:address)),
':');
594 if (mask && rbracket)
605 if (!strcmp(address,
"*")) {
606 if (flags & TAPMP_EXTENDED_STAR) {
607 if (flags & TAPMP_STAR_IPV4_ONLY) {
610 }
else if (flags & TAPMP_STAR_IPV6_ONLY) {
611 static uint8_t nil_bytes[16] =
612 { [0]=0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
619 "'%s' expands into rules which apply to all IPv4 and IPv6 "
620 "addresses. (Use accept/reject *4:* for IPv4 or "
621 "accept[6]/reject[6] *6:* for IPv6.)", s);
628 }
else if (!strcmp(address,
"*4") && (flags & TAPMP_EXTENDED_STAR)) {
632 }
else if (!strcmp(address,
"*6") && (flags & TAPMP_EXTENDED_STAR)) {
633 static uint8_t nil_bytes[16] = { [0]=0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
644 log_warn(
LD_GENERAL,
"Malformed IP %s in address pattern; rejecting.",
654 struct in_addr v4mask;
657 bits = (int) strtol(mask, &endptr, 10);
659 if ((bits<0 || bits>128) ||
660 (family == AF_INET && bits > 32)) {
662 "Bad number of mask bits (%d) on address range; rejecting.",
671 "IPv4-style mask %s is not a prefix address; rejecting.",
677 "Malformed mask on address range %s; rejecting.",
682 if (family == AF_INET6 && v4map) {
683 if (bits > 32 && bits < 96) {
685 "Bad mask bits %d for V4-mapped V6 address; rejecting.",
694 "Found bit prefix with wildcard address; rejecting");
709 "Unexpected mask in address %s; rejecting",
escaped(s));
718 port_max_out = &port2;
722 }
else if ((*port_min_out != *port_max_out) && port_max_out == &port2) {
724 "Wanted one port from address range, but there are two.");
732 "Unexpected ports in address %s; rejecting",
escaped(s));
760 if (a32[0] == 0 && a32[1] == 0 && ntohl(a32[2]) == 0x0000ffffu)
787 return (a32[0] == 0) && (a32[1] == 0) && (a32[2] == 0) && (a32[3] == 0);
796 log_warn(
LD_BUG,
"Called with unknown address family %d",
812 return (a32[0] == 0) && (a32[1] == 0) && (a32[2] == 0) &&
813 (ntohl(a32[3]) == 1);
837 tor_addr_is_valid(
const tor_addr_t *addr,
int for_listening)
846 if (addr->family == AF_INET || addr->family == AF_INET6) {
859 tor_addr_is_valid_ipv4n(uint32_t v4n_addr,
int for_listening)
867 return v4n_addr != 0;
875 tor_port_is_valid(uint16_t port,
int for_listening)
893 dest->family = AF_INET;
894 dest->addr.in_addr.s_addr = v4addr;
905 dest->family = AF_INET6;
906 memcpy(dest->addr.in6_addr.s6_addr, ipv6_bytes, 16);
927 memcpy(dest, src->addr.in6_addr.s6_addr, 16);
953 dest->family = src->family;
957 dest->addr.in_addr.s_addr = src->addr.in_addr.s_addr;
960 memcpy(dest->addr.in6_addr.s6_addr, src->addr.in6_addr.s6_addr, 16);
1010 #define TRISTATE(a,b) (((a)<(b))?-1: (((a)==(b))?0:1))
1011 sa_family_t family1, family2, v_family1, v_family2;
1018 if (family1==family2) {
1034 r = TRISTATE(a1, a2);
1043 const int bytes = mbits >> 3;
1044 const int leftover_bits = mbits & 7;
1045 if (bytes && (r =
tor_memcmp(a1, a2, bytes))) {
1047 }
else if (leftover_bits) {
1048 uint8_t b1 = a1[bytes] >> (8-leftover_bits);
1049 uint8_t b2 = a2[bytes] >> (8-leftover_bits);
1050 return TRISTATE(b1, b2);
1069 else if (addr1 == addr2)
1079 }
else if (how == CMP_EXACT) {
1081 return TRISTATE(family1, family2);
1088 v_family1 = AF_INET;
1090 v_family2 = AF_INET;
1091 if (v_family1 == v_family2) {
1094 if (family1 == AF_INET6) {
1102 if (family2 == AF_INET6) {
1107 if (mbits > 32) mbits = 32;
1110 return TRISTATE(a1, a2);
1114 return TRISTATE(family1, family2);
1127 return siphash24g(&addr->addr.in_addr.s_addr, 4);
1131 return siphash24g(&addr->addr.in6_addr.s6_addr, 16);
1149 return siphash24(&addr->addr.in_addr.s_addr, 4, key);
1153 return siphash24(&addr->addr.in6_addr.s6_addr, 16, key);
1168 return tor_strdup(buf);
1170 return tor_strdup(
"<unknown address type>");
1187 if (!addr)
return "<null>";
1216 in.s_addr = htonl(addr);
1219 tor_assertf_nonfatal(success >= 0,
1220 "Failed to convert IP 0x%08X (HBO) to string", addr);
1236 snprintf(buf,
sizeof(buf),
"%s:%u",
fmt_addr32(addr), port);
1248 static int default_bug_once = 0;
1256 return "UNIX socket";
1258 return "unspecified";
1260 if (!default_bug_once) {
1261 log_warn(
LD_BUG,
"Called with unknown address family %d",
1263 default_bug_once = 1;
1279 return "NULL pointer";
1296 bool allow_ipv6_without_brackets)
1301 struct in_addr in_tmp;
1303 int brackets_detected = 0;
1307 size_t len = strlen(src);
1309 if (len && src[0] ==
'[' && src[len - 1] ==
']') {
1310 brackets_detected = 1;
1311 src = tmp = tor_strndup(src+1, strlen(src)-2);
1316 if (brackets_detected || allow_ipv6_without_brackets) {
1324 if (!brackets_detected) {
1354 #ifdef HAVE_IFADDRS_TO_SMARTLIST
1360 ifaddrs_to_smartlist(
const struct ifaddrs *ifa,
sa_family_t family)
1363 const struct ifaddrs *i;
1365 for (i = ifa; i; i = i->ifa_next) {
1367 if ((i->ifa_flags & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
1371 if (i->ifa_addr->sa_family != AF_INET &&
1372 i->ifa_addr->sa_family != AF_INET6)
1374 if (family != AF_UNSPEC && i->ifa_addr->sa_family != family)
1389 get_interface_addresses_ifaddrs(
int severity,
sa_family_t family)
1394 struct ifaddrs *ifa = NULL;
1396 if (getifaddrs(&ifa) < 0) {
1397 log_fn(severity,
LD_NET,
"Unable to call getifaddrs(): %s",
1402 result = ifaddrs_to_smartlist(ifa, family);
1410 #ifdef HAVE_IP_ADAPTER_TO_SMARTLIST
1417 ip_adapter_addresses_to_smartlist(
const IP_ADAPTER_ADDRESSES *addresses)
1420 const IP_ADAPTER_ADDRESSES *address;
1422 for (address = addresses; address; address = address->Next) {
1423 const IP_ADAPTER_UNICAST_ADDRESS *a;
1424 for (a = address->FirstUnicastAddress; a; a = a->Next) {
1426 const struct sockaddr *sa = a->Address.lpSockaddr;
1428 if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6)
1444 get_interface_addresses_win32(
int severity,
sa_family_t family)
1448 IP_ADAPTER_ADDRESSES *addresses = NULL;
1452 #define FLAGS (GAA_FLAG_SKIP_ANYCAST | \
1453 GAA_FLAG_SKIP_MULTICAST | \
1454 GAA_FLAG_SKIP_DNS_SERVER)
1458 addresses = tor_malloc(size);
1460 res = GetAdaptersAddresses(family, FLAGS, NULL, addresses, &size);
1461 if (res == ERROR_BUFFER_OVERFLOW) {
1464 addresses = tor_malloc(size);
1465 res = GetAdaptersAddresses(AF_UNSPEC, FLAGS, NULL, addresses, &size);
1467 if (res != NO_ERROR) {
1468 log_fn(severity,
LD_NET,
"GetAdaptersAddresses failed (result: %lu)", res);
1472 result = ip_adapter_addresses_to_smartlist(addresses);
1481 #ifdef HAVE_IFCONF_TO_SMARTLIST
1485 #define IFREQ_SIZE 4096
1488 #ifndef _SIZEOF_ADDR_IFREQ
1489 #define _SIZEOF_ADDR_IFREQ(x) sizeof(x)
1494 ifconf_free_ifc_buf(
struct ifconf *ifc)
1500 raw_free(ifc->ifc_buf);
1501 ifc->ifc_buf = NULL;
1508 ifreq_to_smartlist(
const uint8_t *buf,
size_t buflen)
1511 const uint8_t *end = buf + buflen;
1515 struct ifreq *r = tor_malloc(IFREQ_SIZE);
1520 memcpy(r, buf, end - buf < IFREQ_SIZE ? end - buf : IFREQ_SIZE);
1522 const struct sockaddr *sa = &r->ifr_addr;
1524 int valid_sa_family = (sa->sa_family == AF_INET ||
1525 sa->sa_family == AF_INET6);
1529 if (valid_sa_family && conversion_success)
1532 buf += _SIZEOF_ADDR_IFREQ(*r);
1544 get_interface_addresses_ioctl(
int severity,
sa_family_t family)
1559 if (family == AF_UNSPEC)
1561 else if (family != AF_INET)
1564 fd = socket(family, SOCK_DGRAM, 0);
1566 tor_log(severity,
LD_NET,
"socket failed: %s", strerror(errno));
1573 ifc.ifc_len = mult * IFREQ_SIZE;
1574 ifc.ifc_buf = tor_realloc(ifc.ifc_buf, ifc.ifc_len);
1578 if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
1579 tor_log(severity,
LD_NET,
"ioctl failed: %s", strerror(errno));
1584 }
while (mult * IFREQ_SIZE - ifc.ifc_len <= IFREQ_SIZE);
1585 result = ifreq_to_smartlist((
const uint8_t *)ifc.ifc_buf, ifc.ifc_len);
1590 ifconf_free_ifc_buf(&ifc);
1605 #if defined(HAVE_IFADDRS_TO_SMARTLIST)
1606 if ((result = get_interface_addresses_ifaddrs(severity, family)))
1609 #if defined(HAVE_IP_ADAPTER_TO_SMARTLIST)
1610 if ((result = get_interface_addresses_win32(severity, family)))
1613 #if defined(HAVE_IFCONF_TO_SMARTLIST)
1614 if ((result = get_interface_addresses_ioctl(severity, family)))
1627 if (family == AF_INET) {
1629 if ((ipv4h >> 24) == 0xe0)
1631 }
else if (family == AF_INET6) {
1649 struct sockaddr_storage target_addr;
1654 memset(&target_addr, 0,
sizeof(target_addr));
1658 if (family == AF_INET6) {
1661 sin6->sin6_port = htons(9);
1664 sin6->sin6_family = AF_INET6;
1665 S6_ADDR16(sin6->sin6_addr)[0] = htons(0x2002);
1666 }
else if (family == AF_INET) {
1667 struct sockaddr_in *sin = (
struct sockaddr_in*)&target_addr;
1669 sin->sin_port = htons(9);
1671 addr_len = (socklen_t)
sizeof(
struct sockaddr_in);
1672 sin->sin_family = AF_INET;
1673 sin->sin_addr.s_addr = htonl(0x12000001);
1679 int e = tor_socket_errno(-1);
1680 log_fn(severity,
LD_NET,
"unable to create socket: %s",
1681 tor_socket_strerror(e));
1687 int e = tor_socket_errno(sock);
1688 log_fn(severity,
LD_NET,
"connect() failed: %s", tor_socket_strerror(e));
1693 int e = tor_socket_errno(sock);
1694 log_fn(severity,
LD_NET,
"getsockname() to determine interface failed: %s",
1695 tor_socket_strerror(e));
1700 log_fn(severity,
LD_NET,
"Address that we determined via UDP socket"
1701 " magic is unsuitable for public comms.");
1738 const bool is_internal = tor_addr_is_internal(a, 0);
1741 log_debug(
LD_NET,
"Found %s interface address '%s'",
1742 (is_internal ?
"internal" :
"external"),
fmt_addr(addr));
1748 } SMARTLIST_FOREACH_END(a);
1750 interface_address6_list_free(addrs);
1759 if (addrs != NULL) {
1761 smartlist_free(addrs);
1777 int include_internal))
1793 if (!include_internal && tor_addr_is_internal(a, 0)) {
1798 } SMARTLIST_FOREACH_END(a);
1801 if (addrs && smartlist_len(addrs) > 0) {
1807 smartlist_free(addrs);
1813 if (family == AF_INET || family == AF_UNSPEC) {
1816 if (include_internal || !tor_addr_is_internal(&addr, 0)) {
1822 if (family == AF_INET6 || family == AF_UNSPEC) {
1825 if (include_internal || !tor_addr_is_internal(&addr, 0)) {
1863 char *addr_tmp = NULL;
1874 has_port = !! *port_out;
1878 if (default_port >= 0)
1879 *port_out = default_port;
1917 char **address_out, uint16_t *port_out)
1930 *address_out = tor_strdup(addrport);
1935 char *address_ = NULL;
1939 colon = strrchr(addrport,
':');
1941 address_ = tor_strndup(addrport, colon-addrport);
1950 "Port %s given on %s when not required",
1951 escaped(colon+1), esc_addrport);
1956 address_ = tor_strdup(addrport);
1961 *address_out = address_;
1963 *address_out = NULL;
1967 *port_out = ok ? ((uint16_t) port_) : 0;
1980 if (mask == 0xFFFFFFFFu)
1982 for (i=1; i<=32; ++i) {
1983 if (mask == (uint32_t) ~((1u<<(32-i))-1)) {
1995 uint16_t *port_max_out)
1997 int port_min, port_max, ok;
2001 if (!port || *port ==
'\0' || strcmp(port,
"*") == 0) {
2005 char *endptr = NULL;
2006 port_min = (int)
tor_parse_long(port, 10, 0, 65535, &ok, &endptr);
2009 "Malformed port %s on address range; rejecting.",
2012 }
else if (endptr && *endptr ==
'-') {
2015 port_max = (int)
tor_parse_long(port, 10, 1, 65535, &ok, &endptr);
2018 "Malformed port %s on address range; rejecting.",
2023 port_max = port_min;
2025 if (port_min > port_max) {
2026 log_warn(
LD_GENERAL,
"Insane port range on address policy; rejecting.");
2033 if (port_max > 65535)
2036 *port_min_out = (uint16_t) port_min;
2037 *port_max_out = (uint16_t) port_max;
2053 in.s_addr = htonl(addr);
2056 tor_assertf_nonfatal(ip_str,
"Failed to duplicate IP %08X", addr);
2058 return tor_strdup(buf);
2078 memset(addr, 0,
sizeof(uint32_t));
2092 return !strcasecmp(
name,
"localhost") ||
2093 !strcasecmp(
name,
"local") ||
2114 return tor_addr_eq(&a->addr, &b->addr) && a->port == b->port;
2135 struct in_addr addr;
2164 len = strlen(
string);
2169 if (
string[0] ==
'[' &&
string[len - 1] ==
']')
2170 string = tmp = tor_strndup(
string + 1, len - 2);
2191 int has_trailing_dot;
2195 if (!
string || strlen(
string) == 0)
2205 if (BUG(smartlist_len(components) == 0)) {
2207 smartlist_free(components);
2214 last_label = (
char *)smartlist_get(components,
2215 smartlist_len(components) - 1);
2216 has_trailing_dot = (last_label[0] ==
'\0');
2217 if (has_trailing_dot) {
2224 if ((c[0] ==
'-') || (*c ==
'_')) {
2230 result = (TOR_ISALNUM(*c) || (*c ==
'-') || (*c ==
'_'));
2232 }
while (result && *c);
2237 } SMARTLIST_FOREACH_END(c);
2241 } SMARTLIST_FOREACH_END(c);
2243 smartlist_free(components);
int string_is_valid_ipv6_address(const char *string)
uint64_t tor_addr_hash(const tor_addr_t *addr)
socklen_t tor_addr_to_sockaddr(const tor_addr_t *a, uint16_t port, struct sockaddr *sa_out, socklen_t len)
const char * fmt_addr_impl(const tor_addr_t *addr, int decorate)
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
static int tor_addr_parse_impl(tor_addr_t *addr, const char *src, bool allow_ipv6_without_brackets)
void tor_addr_from_ipv4n(tor_addr_t *dest, uint32_t v4addr)
const char * fmt_addrport(const tor_addr_t *addr, uint16_t port)
void tor_addr_make_unspec(tor_addr_t *a)
void interface_address6_list_free_(smartlist_t *addrs)
const char * tor_addr_to_str(char *dest, const tor_addr_t *addr, size_t len, int decorate)
int string_is_valid_ipv4_address(const char *string)
static void tor_addr_make_af_unix(tor_addr_t *a)
int tor_addr_hostname_is_local(const char *name)
const char * fmt_af_family(sa_family_t family)
int tor_addr_parse(tor_addr_t *addr, const char *src)
void tor_addr_make_null(tor_addr_t *a, sa_family_t family)
static const uint32_t unspec_hash_input[]
int tor_addr_port_parse(int severity, const char *addrport, tor_addr_t *address_out, uint16_t *port_out, int default_port)
int string_is_valid_dest(const char *string)
int tor_addr_is_loopback(const tor_addr_t *addr)
int tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2, maskbits_t mbits, tor_addr_comparison_t how)
int get_interface_address(int severity, uint32_t *addr)
int string_is_valid_nonrfc_hostname(const char *string)
int tor_addr_is_v4(const tor_addr_t *addr)
int tor_addr_compare(const tor_addr_t *addr1, const tor_addr_t *addr2, tor_addr_comparison_t how)
char * tor_addr_to_str_dup(const tor_addr_t *addr)
const char * fmt_addr32_port(uint32_t addr, uint16_t port)
void tor_addr_copy_ipv6_bytes(uint8_t *dest, const tor_addr_t *src)
const char * fmt_addr32(uint32_t addr)
int tor_addr_port_split(int severity, const char *addrport, char **address_out, uint16_t *port_out)
int tor_addr_is_null(const tor_addr_t *addr)
int tor_addr_parse_PTR_name(tor_addr_t *result, const char *address, int family, int accept_regular)
void tor_addr_port_copy(tor_addr_port_t *dest, const tor_addr_port_t *source)
int tor_addr_is_multicast(const tor_addr_t *a)
smartlist_t * get_interface_addresses_raw(int severity, sa_family_t family)
char * tor_dup_ip(uint32_t addr)
int tor_addr_is_internal_(const tor_addr_t *addr, int for_listening, const char *filename, int lineno)
const char * fmt_addr_family(const tor_addr_t *addr)
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)
int addr_mask_get_bits(uint32_t mask)
int get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr)
int tor_addr_is_v6(const tor_addr_t *addr)
smartlist_t * get_interface_address6_list(int severity, sa_family_t family, int include_internal)
void tor_addr_from_in6(tor_addr_t *dest, const struct in6_addr *in6)
uint64_t tor_addr_keyed_hash(const struct sipkey *key, const tor_addr_t *addr)
void tor_addr_copy_tight(tor_addr_t *dest, const tor_addr_t *src)
int tor_addr_from_sockaddr(tor_addr_t *a, const struct sockaddr *sa, uint16_t *port_out)
void tor_addr_from_ipv6_bytes(tor_addr_t *dest, const uint8_t *ipv6_bytes)
int parse_port_range(const char *port, uint16_t *port_min_out, uint16_t *port_max_out)
int get_interface_address6_via_udp_socket_hack(int severity, sa_family_t family, tor_addr_t *addr)
char * tor_sockaddr_to_str(const struct sockaddr *sa)
int tor_addr_port_eq(const tor_addr_port_t *a, const tor_addr_port_t *b)
int tor_addr_to_PTR_name(char *out, size_t outlen, const tor_addr_t *addr)
tor_addr_port_t * tor_addr_port_new(const tor_addr_t *addr, uint16_t port)
#define fmt_and_decorate_addr(a)
static uint32_t tor_addr_to_ipv4n(const tor_addr_t *a)
#define REVERSE_LOOKUP_NAME_BUF_LEN
static sa_family_t tor_addr_family(const tor_addr_t *a)
static uint32_t tor_addr_to_ipv4h(const tor_addr_t *a)
#define tor_addr_to_in6_addr8(x)
#define tor_addr_from_ipv4h(dest, v4addr)
#define tor_addr_from_in(dest, in)
#define TOR_ADDRPORT_BUF_LEN
static uint32_t tor_addr_to_mapped_ipv4h(const tor_addr_t *a)
static const struct in6_addr * tor_addr_to_in6_assert(const tor_addr_t *a)
#define tor_addr_to_in6_addr32(x)
#define tor_addr_eq(a, b)
Locale-independent character-type inspection (header)
static int hex_decode_digit(char c)
Header for compat_string.c.
Compile-time assertions: CTASSERT(expression).
int tor_memcmp(const void *a, const void *b, size_t len)
const char * escaped(const char *s)
char * esc_for_log(const char *s)
int tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len)
int tor_inet_aton(const char *str, struct in_addr *addr)
int tor_inet_pton(int af, const char *src, void *dst)
const char * tor_inet_ntop(int af, const void *src, char *dst, size_t len)
#define INET_NTOA_BUF_LEN
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
#define log_fn(severity, domain, args,...)
Headers for util_malloc.c.
long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next)
int tor_asprintf(char **strp, const char *fmt,...)
int tor_snprintf(char *str, size_t size, const char *format,...)
void * smartlist_pop_last(smartlist_t *sl)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
#define SMARTLIST_DEL_CURRENT_KEEPORDER(sl, var)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
int tor_close_socket(tor_socket_t s)
tor_socket_t tor_connect_socket(tor_socket_t sock, const struct sockaddr *address, socklen_t address_len)
int tor_addr_from_getsockname(struct tor_addr_t *addr_out, tor_socket_t sock)
tor_socket_t tor_open_socket(int domain, int type, int protocol)
#define MOCK_IMPL(rv, funcname, arglist)
#define tor_fragile_assert()
#define IF_BUG_ONCE(cond)
int strcasecmpend(const char *s1, const char *s2)
Header for util_string.c.