From: Alan T. DeKok Date: Mon, 3 Apr 2023 20:53:07 +0000 (-0400) Subject: rename to "PROTO.encode" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02150eba1f2cea9d739cd97a42985cc4b7aa729e;p=thirdparty%2Ffreeradius-server.git rename to "PROTO.encode" as most everything else is hiearchical based on protocol name --- diff --git a/doc/antora/modules/reference/pages/xlat/builtin.adoc b/doc/antora/modules/reference/pages/xlat/builtin.adoc index b320af3056..fb6b6c1541 100644 --- a/doc/antora/modules/reference/pages/xlat/builtin.adoc +++ b/doc/antora/modules/reference/pages/xlat/builtin.adoc @@ -182,21 +182,22 @@ That being said, the main use of these expansions is for the decode any attribute from any protocol. If you need to store attributes in an external database, then it is -possible to encode them via `%(encode.internal:...)`. The result will +possible to encode them via `%(internal.encode:...)`. The result will be an opaque hex string which can be treated as an opaque blob, and stored externally. Then, when the data is needed again, it can be -turned back into attributes via `%(decode.internal:...)`. +turned back into attributes via `%(internal.decode:...)`. -=== %(decode.PROTO:) +=== %(PROTO.decode:) -Decodes _hex_ as the named protocol. The _hex_ string can be an expansion, too. +Decodes _data_ as the named protocol. The _data_ string can be an +expansion, which is usually a reference to an attribute of type `octets. -The `decode.PROTO` expansion is automatically registered for every +The `PROTO.decode` expansion is automatically registered for every protocol which is used by the server. Note that the output attributes _must_ come from the same dictionary as the `request` they are being added to. For example, you cannot use -`decode.dhcpv4` inside of a virtual server which has `namespace = +`dhcpv4.decode` inside of a virtual server which has `namespace = radius`. Doing so would result in DHCPv4 attributes being inside of a RADIUS virtual server, which is not allowed. @@ -219,11 +220,11 @@ It returns the number of attributes which were decoded. &User-Name = "ABCD" ``` -=== %(encode.PROTO:) +=== %(PROTO.encode:) Encodes _list_ as the named protocol. The _list_ can also be a series of attributes. -The `encode.PROTO` expansion is automatically registered for every +The `PROTO.encode` expansion is automatically registered for every protocol which is used by the server. .Return: _octets_ @@ -234,8 +235,8 @@ It returns the raw encoded data [source,unlang] ---- -%(encode.dhcpv4:&Relay-Agent-Information.Circuit-Id = 0xabcdef &Relay-Agent-Information.Remote-Id = 0x010203040506) -%(encode.radius:&User-Name = "ABCD") +%(dhcpv4.encode:&Relay-Agent-Information.Circuit-Id = 0xabcdef &Relay-Agent-Information.Remote-Id = 0x010203040506) +%(radius.radius:&User-Name = "ABCD") ---- .Output diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 08e104badc..213e175aa6 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -3011,7 +3011,7 @@ static xlat_arg_parser_t const protocol_decode_xlat_args[] = { * * Example: @verbatim -%(decode.dhcpv4:%{Tmp-Octets-0}) +%(dhcpv4.decode:%{Tmp-Octets-0}) @endverbatim * * @ingroup xlat_functions @@ -3068,7 +3068,7 @@ static xlat_arg_parser_t const protocol_encode_xlat_args[] = { * * Example: @verbatim -%(encode.dhcpv4:&request[*]) +%(dhcpv4.encode:&request[*]) @endverbatim * * @ingroup xlat_functions @@ -3189,7 +3189,7 @@ static int xlat_protocol_register(fr_dict_t const *dict) snprintf(buffer, sizeof(buffer), "%s_tp_decode_pair", name); tp_decode = dlsym(dl->handle, buffer); if (tp_decode) { - snprintf(buffer, sizeof(buffer), "decode.%s", name); + snprintf(buffer, sizeof(buffer), "%s.decode", name); if (unlikely((xlat = xlat_func_register(NULL, buffer, protocol_decode_xlat, FR_TYPE_UINT32)) == NULL)) return -1; xlat_func_args_set(xlat, protocol_decode_xlat_args); @@ -3204,7 +3204,7 @@ static int xlat_protocol_register(fr_dict_t const *dict) snprintf(buffer, sizeof(buffer), "%s_tp_encode_pair", name); tp_encode = dlsym(dl->handle, buffer); if (tp_encode) { - snprintf(buffer, sizeof(buffer), "encode.%s", name); + snprintf(buffer, sizeof(buffer), "%s.encode", name); if (unlikely((xlat = xlat_func_register(NULL, buffer, protocol_encode_xlat, FR_TYPE_OCTETS)) == NULL)) return -1; xlat_func_args_set(xlat, protocol_encode_xlat_args); diff --git a/src/tests/keywords/xlat-dhcpv4 b/src/tests/keywords/xlat-dhcpv4 index 8503d7207a..6035c5d0fa 100644 --- a/src/tests/keywords/xlat-dhcpv4 +++ b/src/tests/keywords/xlat-dhcpv4 @@ -3,7 +3,7 @@ # &Tmp-Octets-0 := 0x520d0103abcdef0206010203040506 -if (!("%(decode.dhcpv4:%{Tmp-Octets-0})" == 2)) { +if (!("%(dhcpv4.decode:%{Tmp-Octets-0})" == 2)) { test_fail } @@ -15,7 +15,7 @@ if (!(&Relay-Agent-Information.Remote-Id == 0x010203040506)) { test_fail } -&Tmp-Octets-1 := %(encode.dhcpv4:&request.[*]) +&Tmp-Octets-1 := %(dhcpv4.encode:&request.[*]) if !(&Tmp-Octets-1 == 0x520d0103abcdef0206010203040506) { test_fail