]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - net.c
net: Make is_valid_ipv{4,6}_address() local to net.c.
[paraslash.git] / net.c
diff --git a/net.c b/net.c
index 23cd8032f5019796d601976524cb63a7067f7a43..c4f0312acd80e810ba619b35bead80bd8578df2a 100644 (file)
--- a/net.c
+++ b/net.c
 #include "list.h"
 #include "fd.h"
 
+/* Whether the given address conforms to the IPv4 address format. */
+static inline bool is_valid_ipv4_address(const char *address)
+{
+       struct in_addr test_it;
+       return inet_pton(AF_INET, address, &test_it) != 0;
+}
+
 /**
  * Parse and validate IPv4 address/netmask string.
  *
@@ -77,6 +84,13 @@ static bool is_v4_dot_quad(const char *address)
        return result;
 }
 
+/* Whether a string conforms to IPv6 address format (RFC 4291). */
+static inline bool is_valid_ipv6_address(const char *address)
+{
+       struct in6_addr test_it;
+       return inet_pton(AF_INET6, address, &test_it) != 0;
+}
+
 /**
  * Perform basic syntax checking on the host-part of an URL:
  *