Index is not an integer

Franks Andy (IT Technical Architecture Manager) Andy.Franks at sath.nhs.uk
Tue Dec 15 14:17:11 CET 2015


So .. nearly.. there now with this sql thingy.
Has anyone had any direct experience with using "%{xlat:..}". I can't seem to find much about using it directly, obviously xlats are used in ldap/sql/files etc a lot, any time you want to do anything directly outside a module, and they are super-useful but I haven't seen this used before to allow resolution of various levels of variable.
I can't get it to do much, tried a simple:

Update control {
  Tmp-Integer-0 := 3
  Tmp-String-1 := "%{control:Tmp-Integer-0}"
  Tmp-String-1 := "%{xlat:%{control:Tmp-Integer-0}}"
}

EXPAND %{control:Tmp-Integer-0}
(3)                --> 3
(3)             Tmp-String-1 := "3"
(3)             EXPAND %{xlat:%{control:Tmp-Integer-0}}
(3)                -->
(3)             Tmp-String-1 := ""


.. the first works as it should, but this xlat one is a mystery. Sorry for being a bit thick, possibly got it completely wrong.
I could do a switch .. case dependent on a tracked variable, but it's not very nice and would result it lots of identical code blocks to maintain.

Sorry to be a pain, I did search around first even had a look at the source code, but it hurts my head.
Andy

  

-----Original Message-----
From: Freeradius-Users [mailto:freeradius-users-bounces+andy.franks=sath.nhs.uk at lists.freeradius.org] On Behalf Of Franks Andy (IT Technical Architecture Manager)
Sent: 14 December 2015 18:00
To: FreeRadius users mailing list
Subject: RE: Index is not an integer

Hmm, can I just double check :

Variables going in :
(1)         control:Tmp-string-1 += 4685a44565edf4d8aae476f8ed3b0ab9
(1)         control:Tmp-string-2 += 000E0000009C
(1)         control:Tmp-string-3 += 20b399f37010
(1)         control:Tmp-string-4 += radacct_lan0
(1)         control:Tmp-string-1 += 4ae6bd20c2955bdbc7a61703bd811c5b
(1)         control:Tmp-string-2 += 000E0000004B
(1)         control:Tmp-string-3 += 20b399f37010
(1)         control:Tmp-string-4 += radacct_lant
(1)         control:Tmp-string-1 += bac91c23dbdab2d01c15ae88fcf7f2ae
(1)         control:Tmp-string-2 += 000E000000B0
(1)         control:Tmp-string-3 += 20b399f37010
(1)         control:Tmp-string-4 += radacct_lan0
(1)         control:Tmp-string-1 += ccbc421c66a4b053a7ad970d1ccf40f2
(1)         control:Tmp-string-2 += 000E000000AF
(1)         control:Tmp-string-3 += 20b399f37010
(1)         control:Tmp-string-4 += radacct_lan0

.. but not coming out:
(1)        update control {
(1)           Tmp-Integer-0 := 0
(1)         } # update control (noop)
(1)         foreach &control:Tmp-String-1 {
(1)         foreach &control:Tmp-String-1
(1)         # Foreach-Variable-0 = "4685a44565edf4d8aae476f8ed3b0ab9"
(1)           update control {
(1)             CoA-Failure-Reason !* ANY
(1)             EXPAND Foreach-Variable-0
(1)                --> 4685a44565edf4d8aae476f8ed3b0ab9
(1)             EXPAND %{Foreach-Variable-0}
(1)                --> 4685a44565edf4d8aae476f8ed3b0ab9
(1)             CoA-Acct-Unique-Session-Id := "4685a44565edf4d8aae476f8ed3b0ab9"
(1)             EXPAND %{xlat:%%{control:Tmp-String-2[%{control:Tmp-Integer-0}]%}}
(1)                -->
(1)             CoA-Acct-Session-Id := ""
(1)             EXPAND %{xlat:%%{control:Tmp-String-3[%{control:Tmp-Integer-0}]%}}
(1)                -->
(1)             CoA-User-Name := ""

I presumed the use of quotes around the expansion?
"%{xlat:%%{control:Tmp-String-3[%{control:Tmp-Integer-0}]%}}"

Thanks
Andy

-----Original Message-----
From: Freeradius-Users [mailto:freeradius-users-bounces+andy.franks=sath.nhs.uk at lists.freeradius.org] On Behalf Of Franks Andy (IT Technical Architecture Manager)
Sent: 14 December 2015 17:49
To: FreeRadius users mailing list
Subject: RE: Index is not an integer

Thanks Arran,
  Discovered the multiple disconnect thing by trial and error, using radclient seems to work, albeit not preferable calling something "external", but there we are, I can judge by return string whether to close off accounting sessions that never got updated and so on, not too bad..
Wish there was some interface to directly query the switch for account sessions, mac addresses etc on there by port rather than use accounting, but afaics snmp isn't going to help, I don't know what else to do with that one.
Thanks for the help anyway, much appreciated.
Andy

-----Original Message-----
From: Freeradius-Users [mailto:freeradius-users-bounces+andy.franks=sath.nhs.uk at lists.freeradius.org] On Behalf Of Arran Cudbard-Bell
Sent: 14 December 2015 17:32
To: FreeRadius users mailing list
Subject: Re: Index is not an integer


> On 14 Dec 2015, at 12:30, Arran Cudbard-Bell <a.cudbardb at freeradius.org> wrote:
> 
> 
>> On 14 Dec 2015, at 12:24, Franks Andy (IT Technical Architecture Manager) <Andy.Franks at sath.nhs.uk> wrote:
>> 
>> Hi all,
>> Is there a way of doing this or its equivalent? I'm tracking the index of a variable via expr and then trying to get the output of other variables respectively - I need to do this via a changing index that's housed in a variable, but (and I may be doing this wrong) FR won't start with the following:
> 
> Array index is not an integer, it's an attribute reference, which is not supported.
> 
> You'd need to use 
> %{xlat:%%{control:Tmp-String-3[%{control:Tmp-Integer-0}]%}}
> 
> It's probably not hard to implement array indexes as templates,  but I don't have time to look at it right now.

You also can't send multiple disconnects unless you call out to radclient and do it that way.

-Arran

Arran Cudbard-Bell <a.cudbardb at freeradius.org> FreeRADIUS development team

FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html



More information about the Freeradius-Users mailing list