summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c11
-rw-r--r--src/common/util.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index ba9d78afac..e9ee437190 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -968,6 +968,17 @@ string_is_valid_ipv4_address(const char *string)
return (tor_inet_pton(AF_INET,string,&sockaddr) == 1);
}
+/** Return true if <b>string</b> represents a valid IPv6 address in
+ * a form that inet_pton() can parse.
+ */
+int
+string_is_valid_ipv6_address(const char *string)
+{
+ struct sockaddr_in sockaddr_dummy;
+
+ return (inet_pton(AF_INET6,string,&sockaddr_dummy) == 1);
+}
+
/** Return true iff <b>string</b> matches a pattern of DNS names
* that we allow Tor clients to connect to.
*/
diff --git a/src/common/util.h b/src/common/util.h
index dcb54f0aea..5eecfada28 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -229,6 +229,7 @@ int string_is_C_identifier(const char *string);
int string_is_key_value(int severity, const char *string);
int string_is_valid_hostname(const char *string);
int string_is_valid_ipv4_address(const char *string);
+int string_is_valid_ipv6_address(const char *string);
int tor_mem_is_zero(const char *mem, size_t len);
int tor_digest_is_zero(const char *digest);