From: Alan T. DeKok Date: Wed, 17 Nov 2021 18:05:38 +0000 (-0500) Subject: add rules for ip addresses, hostnames, and prefixes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=304ba6a8f272b7b4514efc3fded56c1ac7cbf1d6;p=thirdparty%2Ffreeradius-server.git add rules for ip addresses, hostnames, and prefixes --- diff --git a/src/lib/util/sbuff.c b/src/lib/util/sbuff.c index 6b55971e0d..14a02c5453 100644 --- a/src/lib/util/sbuff.c +++ b/src/lib/util/sbuff.c @@ -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] = { diff --git a/src/lib/util/sbuff.h b/src/lib/util/sbuff.h index d675cb2c57..dee5033902 100644 --- a/src/lib/util/sbuff.h +++ b/src/lib/util/sbuff.h @@ -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 */