From: Alan T. DeKok Date: Sun, 28 Jan 2024 17:06:40 +0000 (-0500) Subject: add foreign encoder to DHCPv6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58d113c7d8fd4ef8b3f19dc2cd2f3ccdbd7f3b00;p=thirdparty%2Ffreeradius-server.git add foreign encoder to DHCPv6 update dictionaries and tests --- diff --git a/share/dictionary/dhcpv6/dictionary.rfc7037 b/share/dictionary/dhcpv6/dictionary.rfc7037 index a040c1c14fb..9f5d435c2f0 100644 --- a/share/dictionary/dhcpv6/dictionary.rfc7037 +++ b/share/dictionary/dhcpv6/dictionary.rfc7037 @@ -10,4 +10,4 @@ # ############################################################################## -ATTRIBUTE RADIUS 81 octets # Foreign protocol (RADIUS) +ATTRIBUTE RADIUS 81 group ref=..RADIUS diff --git a/src/protocols/dhcpv6/encode.c b/src/protocols/dhcpv6/encode.c index 7472678bf8c..157cba0cdf8 100644 --- a/src/protocols/dhcpv6/encode.c +++ b/src/protocols/dhcpv6/encode.c @@ -278,6 +278,12 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, case FR_TYPE_GROUP: { fr_dcursor_t child_cursor; + fr_dict_attr_t const *ref = fr_dict_attr_ref(vp->da); + + if (ref && (ref->dict != dict_dhcpv6)) { + slen = fr_pair_ref_to_network(&work_dbuff, da_stack, depth, cursor); + break; + } /* * Encode the child options. diff --git a/src/tests/unit/protocols/radius/foreign.txt b/src/tests/unit/protocols/radius/foreign.txt index a8ecc50ad0b..f9286418a45 100644 --- a/src/tests/unit/protocols/radius/foreign.txt +++ b/src/tests/unit/protocols/radius/foreign.txt @@ -40,6 +40,18 @@ match f5 10 03 00 00 0e 00 00 00 20 00 04 00 00 1a 99 decode-pair - match Extended-Attribute-5 = { DHCPv6-Options = { Rapid-Commit = yes, Information-Refresh-Time = 6809 } } +###################################################################### +# +# RADIUS encapsulates DHCPv6, which in turn encapsulates RADIUS +# +encode-pair Extended-Attribute-5 = { DHCPv6-Options = { Rapid-Commit = yes, RADIUS = { User-Name = "bob" } } } +match f5 11 03 00 00 0e 00 00 00 51 00 05 01 05 62 6f 62 + +# +# Not yet +# +#decode-pair - +#match Extended-Attribute-5 = { DHCPv6-Options = { RADIUS = { User-Name = "bob" } } } ###################################################################### # @@ -57,4 +69,4 @@ decode-proto 04ac00edd604040404040404040404040302d700f30303f5040402f50303f504030 match Packet-Type = Accounting-Request, Packet-Authentication-Vector = 0xd604040404040404040404040302d700, raw.Extended-Attribute-3 = 0x03, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, raw.Extended-Attribute-5 = 0x0303, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, User-Password = "\366\356", raw.Extended-Attribute-3 = 0x03, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, raw.Extended-Attribute-5 = 0x0402, User-Password = "\366\356", raw.Extended-Attribute-3 = 0x03, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, User-Password = "\366\356", raw.Extended-Attribute-3 = 0x03, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, raw.Extended-Attribute-5 = 0x0403, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x02, raw.214 = 0x0402, User-Password = "\366\356", raw.Extended-Attribute-3 = 0x03, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, User-Password = "\366\356", raw.Extended-Attribute-3 = 0x03, raw.Extended-Attribute-5 = 0x0402, raw.Extended-Attribute-5 = 0x03, Extended-Attribute-5 = { raw.DHCPv4-Options = 0x2a006004040404040404f30303f5040402f50303040202046000f30303f5040402f50303f5040303f5040402f50303040202046000f30303f5040402f50303f5040402020203023d046000f30303f5040303f5030402040404 }, raw.NAS-IP-Address = 0x0404, raw.NAS-IP-Address = 0x0404 count -match 23 +match 25