I'm having some trouble working with attribute arrays. My Cisco NASes don't seem to always want to send their Cisco-AVPair attribute in the same order, so I can't be sure I want to reference %{Cisco-AVPair[0]}, or %{Cisco-AVPair[1]}, or other positions. So far, I've worked around this by doing things like this: if ("%{Cisco-AVPair[0]}" =~ /^client-mac-address=(.+)$/ || "%{Cisco-AVPair[1]}" =~ /^client-mac-address=(.+)$/) { update request { Client-MAC-Address := "%{1}" } } I also have other Cisco-AVPairs that I'm checking, and they are also not always coming in a guaranteed order. Is there a way to do a each, while, for, or foreach on an attribute array? Thanks! --Aaron
Aw. Thanks anyways though. I guess I'll just add a few more 'or's. --Aaron On 05/07/2010 04:26 PM, Arran Cudbard-Bell wrote:
Is there a way to do a each, while, for, or foreach on an attribute array?
Not in unlang no, there are no looping structures of any kind.
-Arran
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On May 7, 2010, at 3:20 PM, Aaron Paetznick wrote:
Aw. Thanks anyways though. I guess I'll just add a few more 'or's.
Easiest way to do what you're doing is to implode all the variable instances. I don't think the regex engine stops matching on new lines, but I could be wrong. if("%{Cisco-AVPair[*]}" =~ /client-mac-address=([0-9a-f]{2})[-:]?([0-9a-f]{2})[-:]?([0-9a-f]{2})[-:]?([0-9a-f]{2})[-:]?([0-9a-f]{2})[-:]?([0-9a-f]{2}))/i){ update request { Client-MAC-Address := "%{1}%{2}%{3}%{4}%{5}%{6}" } } -Arran
--Aaron
Is there a way to do a each, while, for, or foreach on an attribute array?
Not in unlang no, there are no looping structures of any kind.
-Arran
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On 05/07/2010 04:26 PM, Arran Cudbard-Bell wrote: - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (2)
-
Aaron Paetznick -
Arran Cudbard-Bell