From: Alan T. DeKok Date: Tue, 6 Apr 2021 11:16:02 +0000 (-0400) Subject: combo-ip and combo-ip-prefix have a special format in RADIUS X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc29f5734cd7eea535decaf87e9d21e0faebba05;p=thirdparty%2Ffreeradius-server.git combo-ip and combo-ip-prefix have a special format in RADIUS --- diff --git a/src/protocols/radius/encode.c b/src/protocols/radius/encode.c index 9a8162de6f..4e1c647e0b 100644 --- a/src/protocols/radius/encode.c +++ b/src/protocols/radius/encode.c @@ -465,13 +465,24 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, } switch (da->type) { + /* + * IPv4 addresses are normal, but IPv6 addresses are special to RADIUS. + */ + case FR_TYPE_COMBO_IP_ADDR: + if (vp->vp_ip.af == AF_INET) goto encode; + FALL_THROUGH; + /* - * Common encoder might add scope byte + * Common encoder might add scope byte, which we don't want. */ case FR_TYPE_IPV6_ADDR: FR_DBUFF_IN_MEMCPY_RETURN(&value_dbuff, vp->vp_ipv6addr, sizeof(vp->vp_ipv6addr)); break; + case FR_TYPE_COMBO_IP_PREFIX: + if (vp->vp_ip.af == AF_INET) goto ipv4_prefix; + FALL_THROUGH; + /* * Common encoder doesn't add reserved byte */ @@ -486,6 +497,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, * Common encoder doesn't add reserved byte */ case FR_TYPE_IPV4_PREFIX: + ipv4_prefix: FR_DBUFF_IN_BYTES_RETURN(&value_dbuff, 0x00, vp->vp_ip.prefix); FR_DBUFF_IN_MEMCPY_RETURN(&value_dbuff, (uint8_t const *)&vp->vp_ipv4addr, sizeof(vp->vp_ipv4addr)); break; @@ -508,6 +520,7 @@ static ssize_t encode_value(fr_dbuff_t *dbuff, * Simple data types use the common encoder. */ default: + encode: slen = fr_value_box_to_network(&value_dbuff, &vp->data); if (slen < 0) return slen; break; diff --git a/src/tests/unit/protocols/radius/wimax.txt b/src/tests/unit/protocols/radius/wimax.txt index cd79ff26c1..15232dc82b 100644 --- a/src/tests/unit/protocols/radius/wimax.txt +++ b/src/tests/unit/protocols/radius/wimax.txt @@ -243,5 +243,14 @@ match 1a 1d 00 00 60 b5 1c 17 00 0b 14 05 12 01 06 7f 00 00 01 04 04 08 40 05 06 decode-pair - match Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.IP-Address = 127.0.0.1, Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.Port = 2112, Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.Port-Range.Start = 2112, Vendor-Specific.WiMAX.Packet-Flow-Descriptor.Classifier.Src-Spec.Port-Range.End = 6809 +encode-pair Framed-IP-Address = ::1 +match Failed resolving "::1" to IPv4 address: nodename nor servname provided, or not known + +encode-pair Vendor-Specific.WiMAX.DNS-Server = ::1 +match 1a 19 00 00 60 b5 34 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 + +encode-pair Vendor-Specific.WiMAX.DNS-Server = 127.0.0.1 +match 1a 0d 00 00 60 b5 34 07 00 7f 00 00 01 + count -match 112 +match 118