util-net: added is_ipaddress_v6()
authorAndrew Tridgell <tridge@samba.org>
Mon, 6 Jun 2011 00:11:13 +0000 (10:11 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 6 Jun 2011 02:26:11 +0000 (12:26 +1000)
lib/util/util_net.c
lib/util/util_net.h

index 57a0b1e40c32b5ab64f331dacca789558ced01fe..64aa674d8b024b8342bfef80ac5c4c306a541d74 100644 (file)
@@ -306,10 +306,10 @@ bool is_ipaddress_v4(const char *str)
 }
 
 /**
- * Return true if a string could be an IPv4 or IPv6 address.
+ * Return true if a string could be a IPv6 address.
  */
 
-bool is_ipaddress(const char *str)
+bool is_ipaddress_v6(const char *str)
 {
 #if defined(HAVE_IPV6)
        int ret = -1;
@@ -337,7 +337,16 @@ bool is_ipaddress(const char *str)
                }
        }
 #endif
-       return is_ipaddress_v4(str);
+       return false;
+}
+
+/**
+ * Return true if a string could be an IPv4 or IPv6 address.
+ */
+
+bool is_ipaddress(const char *str)
+{
+       return is_ipaddress_v4(str) || is_ipaddress_v6(str);
 }
 
 /**
index 38b6d5a959d221faf040dd44671678b84cffa54d..fc2776a32b1f8b93dd181130bc595f918891717b 100644 (file)
@@ -85,6 +85,7 @@ _PUBLIC_ uint32_t interpret_addr(const char *str);
 _PUBLIC_ struct in_addr interpret_addr2(const char *str);
 
 _PUBLIC_ bool is_ipaddress_v4(const char *str);
+_PUBLIC_ bool is_ipaddress_v6(const char *str);
 
 bool is_address_any(const struct sockaddr *psa);
 bool same_net(const struct sockaddr *ip1,