[RADIATOR] Function get_attrs not behaving as expected.

Bruno Tiago Rodrigues bruno.tiago.rodrigues at gmail.com
Mon Jul 10 10:57:22 UTC 2023


Hi all and thanks for the feedback.

The problem was indeed I was using the definition on AttrList.pm as a
reference (instead of AttrVal.pm).

-
Bruno Tiago Rodrigues


On Mon, Jul 10, 2023 at 10:06 AM <Alexander.Hartmaier at telekom.com> wrote:

> Hi,
> get_attrs (note the s at the end for plural) returns this data structure.
> What you want is get_attr, which takes a Radius attribute name as its
> first parameter.
>
> Best regards, Alex
> ------------------------------
> *Von:* radiator <radiator-bounces at lists.open.com.au> im Auftrag von Bruno
> Tiago Rodrigues via radiator <radiator at lists.open.com.au>
> *Gesendet:* Freitag, 7. Juli 2023 18:24
> *An:* radiator at lists.open.com.au <radiator at lists.open.com.au>
> *Betreff:* [RADIATOR] Function get_attrs not behaving as expected.
>
> Hi everyone and greetings to the OSC team and all Radiator users.
>
> Inside a hook, processing the reply packet, wasn't
> get_attrs('Framed-Route') supposed to get an array of one or more values of
> the given attribute?
>
> From AttrList.pm:
> #####################################################################
> # Decode the value from all instances of the requested the attribute
> # Return an array of decoded values
> # Requires the subclass to define decode()
> sub get_attrs
> {
>     my ($self, $attrnum, $vendornum) = @_;
>
>     $vendornum = 0 unless defined $vendornum;
>     my @ret;
>     foreach (@{$self->{Attributes}})
>     {
>         if ($_->[0] == $attrnum && $_->[1] == $vendornum)
>         {
>             # Want this one
>             push(@ret, $self->decode(@$_));
>         }
>     }
>     return @ret;
> }
>
>
> I'm getting a structure that holds all values of the reply packet instead
> of just Framed-Route:
>
> #!/usr/bin/perl
> use Data::Dumper;
>
> sub {
>
> my $rp = ${$_[1]}; #this is the response object
> my @attrs = $rp->get_attrs('Framed-Route');
> print Dumper(@attrs);
>
> }
>
> Whenever two framed routes are returned, the variable holds this:
>
> $VAR1 = {
>           'Framed-Route' => [
>                               '10.10.212.20/29',
>                               '10.10.211.20/29'
>                             ],
>           'Framed-Pool' => 'test.bu'
>         };
>
>
>
> Whenever just one framed route is returned, the variable holds this:
>
> $VAR1 = {
>           'Framed-Pool' => 'test.bu',
>           'Framed-Route' => '10.10.213.20/29'
>         };
>
>
> The way I see it, the returning structure should be
>
> $VAR1 = [
>                               '10.10.212.20/29',
>                               '10.10.211.20/29'
>                             ];
>
> or
>
> $VAR1 = [
>                               '10.10.213.20/29'
>                             ]:
>
> or even an empty array if no attributes are present.
>
> Any ideas? Comments?
>
> Thanks
>
> Bruno Tiago Rodrigues
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.open.com.au/pipermail/radiator/attachments/20230710/44844e1d/attachment.html>


More information about the radiator mailing list