Unlang policy to remove duplicate attributes from reply?

Nick Porter nick at portercomputing.co.uk
Wed Jun 25 09:30:10 UTC 2025


On 25/06/2025 10:22, tach yon wrote:
> if (number of Framed-IP-Address attributes > 1) {

You want to use the [#] suffix to get the number of instances of an 
attribute - so

if (&reply:Framed-IP-Address[#] > 1) { ....

>     update control {
>         # Save the first Framed-IP-Address to a temporary String (because I read ipaddr type isn't available).
>         &Tmp-String-0 := &reply:Framed-IP-Address[0]

Why use Tmp-String-0 - just use Tmp-IP-Address-0 to keep the data type 
consistent - then there won't be any casting issues.

Of, since you're putting the result you want in the control list, you 
can just use Framed-IP-Address- so

update control { &Framed-IP-Address := &reply:Framed-IP-Address[0] }

-- 
Nick Porter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 665 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20250625/4b07fa56/attachment.sig>


More information about the Freeradius-Users mailing list