]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add rules for ip addresses, hostnames, and prefixes
authorAlan T. DeKok <aland@freeradius.org>
Wed, 17 Nov 2021 18:05:38 +0000 (13:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 17 Nov 2021 18:11:15 +0000 (13:11 -0500)
src/lib/util/sbuff.c
src/lib/util/sbuff.h

index 6b55971e0db29fc5254b8cadd375c4ea4da26229..14a02c5453fe640bd0a095d9b74762e9f17f82e6 100644 (file)
@@ -68,6 +68,21 @@ bool const sbuff_char_class_zero[UINT8_MAX + 1] = {
        ['0'] = true
 };
 
+/*
+ *     Anything which vaguely resembles an IP address, prefix, or host name.
+ */
+bool const sbuff_char_class_hostname[UINT8_MAX + 1] = {
+       SBUFF_CHAR_CLASS_ALPHA_NUM,
+       ['.'] = true,           /* only for IPv4 and host names */
+       [':'] = true,           /* only for IPv6 numerical addresses */
+       ['-'] = true,           /* only for host names */
+       ['/'] = true,           /* only for prefixes */
+       ['['] = true,           /* only for IPv6 numerical addresses */
+       [']'] = true,           /* only for IPv6 numerical addresses */
+       ['_'] = true,           /* only for certain host name labels */
+       ['*'] = true,           /* really only for ipv4 addresses */
+};
+
 bool const sbuff_char_class_hex[UINT8_MAX + 1] = { SBUFF_CHAR_CLASS_HEX };
 bool const sbuff_char_alpha_num[UINT8_MAX + 1] = { SBUFF_CHAR_CLASS_ALPHA_NUM };
 bool const sbuff_char_whitespace[UINT8_MAX + 1] = {
index d675cb2c57ce13ab187d4cb36ca3ebdd893e7212..dee5033902e3fabe3d8ca142e27dbd1c1b8c196b 100644 (file)
@@ -265,6 +265,7 @@ extern bool const sbuff_char_alpha_num[UINT8_MAX + 1];
 extern bool const sbuff_char_whitespace[UINT8_MAX + 1];
 extern bool const sbuff_char_line_endings[UINT8_MAX + 1];
 extern bool const sbuff_char_blank[UINT8_MAX + 1];
+extern bool const sbuff_char_class_hostname[UINT8_MAX + 1];
 
 /** Matches a-z,A-Z
  */