diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2023-10-06 02:36:59 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-10-06 04:59:47 +0200 |
commit | c5c3a22bccda5454775b48ad318a7fd4bf197f86 (patch) | |
tree | ef97b0adc90255c61c2387bdce4c45112291b780 | |
parent | e83beb70bd14923cece5b35411606ade6fb8fbee (diff) |
Conf: Bytestrings with hex: should use the same general format as ones without.
Either hex:01234567, or hex:01:23:45:67. No confusing formats like
hex:0123:4567:ab:cdef, which looks like there is an implicit zero byte.
-rw-r--r-- | conf/cf-lex.l | 2 | ||||
-rw-r--r-- | doc/bird.sgml | 24 | ||||
-rw-r--r-- | lib/strtoul.c | 2 |
3 files changed, 12 insertions, 16 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 0fa4628a..2f95f2e1 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -242,7 +242,7 @@ WHITE [ \t] return IP4; } -({XIGIT}{2}){16,}|{XIGIT}{2}(:{XIGIT}{2}){15,}|hex:({XIGIT}{2}(:?{XIGIT}{2})*)? { +({XIGIT}{2}){16,}|{XIGIT}{2}(:{XIGIT}{2}){15,}|hex:({XIGIT}{2}*|{XIGIT}{2}(:{XIGIT}{2})*) { char *s = yytext; struct adata *bs; diff --git a/doc/bird.sgml b/doc/bird.sgml index d5bc8d57..eb8205d5 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1561,22 +1561,18 @@ in the foot). This is a sequences of arbitrary bytes. There are no ways to modify bytestrings in filters. You can pass them between function, assign them to variables of type <cf/bytestring/, print such values, - compare bytestings (<cf/=, !=/). Bytestring literals are written - in several ways: + compare bytestings (<cf/=, !=/). - A sequence of hexadecimal digit pairs, optionally colon-separated. - A bytestring specified this way must be at least 16 bytes (32 digits) - long: <cf/01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef/ or - <cf/0123456789abcdef0123456789abcdef/. - - A sequence of hexadecimal digit pairs of any lengh (including zero) - with the <cf/hex:/ prefix. Colon separators can be inserted - arbitrarily between any bytes: <cf/hex:/, <cf/hex:1234/, - <cf/hex:1234:56:78/. + Bytestring literals are written as a sequence of hexadecimal digit + pairs, optionally colon-separated. A bytestring specified this way + must be either at least 16 bytes (32 digits) long, or prefixed by the + <cf/hex:/ prefix: <cf/01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef/, + <cf/0123456789abcdef0123456789abcdef/, <cf/hex:/, <cf/hex:12:34:56/, + <cf/hex:12345678/. A bytestring can be made from a hex string using <cf/from_hex()/ - function. Source strings can use any number of colons, hyphens and - spaces as byte separators: <cf/from_hex(" 1234 56:78 ab-cd-ef ")/. + function. Source strings can use any number of dots, colons, hyphens + and spaces as byte separators: <cf/from_hex(" 12.34 56:78 ab-cd-ef ")/. <tag><label id="type-ip">ip</tag> This type can hold a single IP address. The IPv4 addresses are stored as @@ -5006,7 +5002,7 @@ definitions, prefix definitions and DNS definitions: <label id="radv-custom-option-exam"> <p><code> -custom option type 38 value hex:0e10:2001:0db8:000a:000b:0000:0000; +custom option type 38 value hex:0e:10:20:01:0d:b8:00:0a:00:0b:00:00:00:00; </code> <tag><label id="radv-trigger">trigger <m/prefix/</tag> diff --git a/lib/strtoul.c b/lib/strtoul.c index e0c0142f..420931a4 100644 --- a/lib/strtoul.c +++ b/lib/strtoul.c @@ -87,7 +87,7 @@ bstrhextobin(const char *s, byte *b) int v = fromxdigit(*s); if (v < 0) { - if (strchr(" :-", *s) && !hi) + if (strchr(" -.:", *s) && !hi) continue; else return -1; |