From a64770739a28b05f6c5a033a3f2085959662b447 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sun, 2 Jun 2013 00:22:53 -0700 Subject: Add missing IPv6 and protocol-agnostic format validation functions. --- src/ipaddrcheck_functions.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/ipaddrcheck_functions.c') diff --git a/src/ipaddrcheck_functions.c b/src/ipaddrcheck_functions.c index bb86ee7..dfcdcfb 100644 --- a/src/ipaddrcheck_functions.c +++ b/src/ipaddrcheck_functions.c @@ -145,6 +145,42 @@ int is_ipv6_single(char* address_str) return(result); } +/* Is it a CIDR-formatted IPv4 or IPv6 address? */ +int is_any_cidr(char* address_str) +{ + int result; + + if( (is_ipv4_cidr(address_str) == RESULT_SUCCESS) || + (is_ipv6_cidr(address_str) == RESULT_SUCCESS) ) + { + result = RESULT_SUCCESS; + } + else + { + result = RESULT_FAILURE; + } + + return(result); +} + +/* Is it a single IPv4 or IPv6 address? */ +int is_any_single(char* address_str) +{ + int result; + + if( (is_ipv4_single(address_str) == RESULT_SUCCESS) || + (is_ipv6_single(address_str) == RESULT_SUCCESS) ) + { + result = RESULT_SUCCESS; + } + else + { + result = RESULT_FAILURE; + } + + return(result); +} + /* * Address checking functions that rely on libcidr */ -- cgit v1.2.3