summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEwald van Geffen <ewald@abcdef.be>2018-10-15 01:16:04 +0200
committerGitHub <noreply@github.com>2018-10-15 01:16:04 +0200
commit418d0113a78ba57f525553b9b150d6adeaf38c0a (patch)
tree221e63bdb1770477d84a182b83280da36a8150b6
parent89bc3caa89c28d819af2ddde6df9570c01c96e94 (diff)
downloadipaddrcheck-418d0113a78ba57f525553b9b150d6adeaf38c0a.tar.gz
ipaddrcheck-418d0113a78ba57f525553b9b150d6adeaf38c0a.zip
T816 ipaddrcheck / libcidr but on IPv6 network validation
https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s17.html or https://regex101.com/r/DMB0m2/1
-rw-r--r--src/ipaddrcheck_functions.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ipaddrcheck_functions.c b/src/ipaddrcheck_functions.c
index 82d01f9..2ce7e52 100644
--- a/src/ipaddrcheck_functions.c
+++ b/src/ipaddrcheck_functions.c
@@ -101,7 +101,7 @@ int is_ipv6_cidr(char* address_str)
const char *error;
int erroffset;
- re = pcre_compile("^((([0-9a-fA-F\\:])+)(\\/\\d{1,3}))$",
+ re = pcre_compile("^(((?:(?:(?:[A-F0-9]{1,4}:){6}|(?=(?:[A-F0-9]{0,4}:){0,6}(?:[0-9]{1,3}\.){3}[0-9]{1,3}$)(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)|::(?:[A-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}$)(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7}))(\\/\\d{1,3}))$",
0, &error, &erroffset, NULL);
rc = pcre_exec(re, NULL, address_str, strlen(address_str), 0, 0, offsets, 1);
@@ -128,7 +128,7 @@ int is_ipv6_single(char* address_str)
const char *error;
int erroffset;
- re = pcre_compile("^(([0-9a-fA-F\\:])+)$",
+ re = pcre_compile("^(?:(?:(?:[A-F0-9]{1,4}:){6}|(?=(?:[A-F0-9]{0,4}:){0,6}(?:[0-9]{1,3}\.){3}[0-9]{1,3}$)(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)|::(?:[A-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}$)(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7})$",
0, &error, &erroffset, NULL);
rc = pcre_exec(re, NULL, address_str, strlen(address_str), 0, 0, offsets, 1);