X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=net.c;fp=net.c;h=c4f0312acd80e810ba619b35bead80bd8578df2a;hb=db17b2883bd4f6d9e202388548f59f6867064027;hp=23cd8032f5019796d601976524cb63a7067f7a43;hpb=539d39f36549c10656d8b31f3dea32702e9649df;p=paraslash.git diff --git a/net.c b/net.c index 23cd8032..c4f0312a 100644 --- a/net.c +++ b/net.c @@ -18,6 +18,13 @@ #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: *