I need to get data out of the Cisco-AVPair attributes; based on http://lists.freeradius.org/pipermail/freeradius-users/2014-May/072096.html I'm trying this: accounting { # make cisco attributes accessible foreach Cisco-AVPair { if ("%{Foreach-Variable-0}" =~ /^client-mac-address=(.+)/ ) { update control { client-mac-address = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^connect-progress=(.+)/ ) { update control { connect-progress = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^disc-cause-ext=(.+)/ ) { update control { disc-cause-ext = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^nas-rx-speed=(.+)/ ) { update control { nas-rx-speed = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^nas-tx-speed=(.+)/ ) { update control { nas-tx-speed = "%{1}" } } } ... When I try to start radius, however, I get: /etc/raddb/sites-enabled/peak[398] Unexpected text elsif ("%{Foreach-Variable-0}" =~ /^connect-progress=(.+)/ ) {. See "man unlang" Errors reading or parsing /etc/raddb/radiusd.conf It looks correct from my reading of "man unlang" though...
On 19 Oct 2015, at 17:31, Alan Batie <alan@peak.org> wrote:
I need to get data out of the Cisco-AVPair attributes; based on
http://lists.freeradius.org/pipermail/freeradius-users/2014-May/072096.html
I'm trying this:
# make cisco attributes accessible foreach Cisco-AVPair { if ("%{Foreach-Variable-0}" =~ /^client-mac-address=(.+)/ ) { update control { client-mac-address = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^connect-progress=(.+)/ ) { update control { connect-progress = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^disc-cause-ext=(.+)/ ) { update control { disc-cause-ext = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^nas-rx-speed=(.+)/ ) { update control { nas-rx-speed = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^nas-tx-speed=(.+)/ ) { update control { nas-tx-speed = "%{1}" } } } Note the new lines :) -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 10/19/15 2:41 PM, Arran Cudbard-Bell wrote:
} elsif ("%{Foreach-Variable-0}" =~ /^nas-tx-speed=(.+)/ ) {
Note the new lines :)
Ooook, progress - now I get "Failed to find "foreach" in the "modules" section." accounting { # make cisco attributes accessible foreach Cisco-AVPair { if ("%{Foreach-Variable-0}" =~ /^client-mac-address=(.+)/ ) { update control { client-mac-address = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^connect-progress=(.+)/ ) { update control { connect-progress = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^disc-cause-ext=(.+)/ ) { update control { disc-cause-ext = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^nas-rx-speed=(.+)/ ) { update control { nas-rx-speed = "%{1}" } } elsif ("%{Foreach-Variable-0}" =~ /^nas-tx-speed=(.+)/ ) { update control { nas-tx-speed = "%{1}" } } } Module: Checking accounting {...} for more modules to load /etc/raddb/sites-enabled/peak[393]: Failed to find "foreach" in the "modules" section. /etc/raddb/sites-enabled/peak[391]: Errors parsing accounting section.
On Oct 19, 2015, at 6:55 PM, Alan Batie <alan@peak.org> wrote:
On 10/19/15 2:41 PM, Arran Cudbard-Bell wrote:
} elsif ("%{Foreach-Variable-0}" =~ /^nas-tx-speed=(.+)/ ) {
Note the new lines :)
Ooook, progress - now I get "Failed to find "foreach" in the "modules" section."
Use v3. "foreach" is a key word in that version. In v2... write a Perl program to do the re-writing. Alan DeKok.
On Oct 20, 2015, at 2:09 PM, Alan DeKok <aland@deployingradius.com> wrote:
On Oct 19, 2015, at 6:55 PM, Alan Batie <alan@peak.org> wrote:
On 10/19/15 2:41 PM, Arran Cudbard-Bell wrote:
} elsif ("%{Foreach-Variable-0}" =~ /^nas-tx-speed=(.+)/ ) {
Note the new lines :)
Ooook, progress - now I get "Failed to find "foreach" in the "modules" section."
Use v3. "foreach" is a key word in that version.
In v2... write a Perl program to do the re-writing.
Ah, yes, I assumed it was v3 as foreach was being used. In v3.1.x you can also do if (&Cisco-AVPair[*] =~ /^client-mac-address=(.+)/) { update request { Calling-Station-ID := "%{1}" } } or foreach &Stupid-VSA { if ("%{Foreach-variable-0}" =~ /^([^=]+)=(.+)$/) { update { "%{1}" = "%{2}" } } } (if you define VSAs that match the attributes encapsulated in Stupid-VSA) Note: You need to define attributes in the dictionaries before they can be used in the config, so it's best to map the Cisco attributes to RFC attrs that are already defined. Some vendors which only provide a stupid <attr>=<value> VSA, in v3.1.x, you can add real VSAs to those dictionaries and unpack the stupid text attributes into proper VSAs. -Arran
On 10/20/15 11:09 AM, Alan DeKok wrote:
In v2... write a Perl program to do the re-writing.
I'm playing with this option as it makes possible some more complex things we may want to do later, but it's not clear how to effect the rewrite: # %RAD_CHECK Read-only Check items # %RAD_REQUEST Read-only Attributes from the request # %RAD_REPLY Read-write Attributes for the reply Since %RAD_REQUEST is read-only, I'm not sure how to make changes to it... I also tried updating RAD_REPLY "just in case" although that didn't seem the right place, and as expected, it did nothing. I'm doing it in preacct, as that seems the right place to twiddle with an incoming request, though I suspect putting it at the beginning of the accounting block would have the same effect...
On Oct 21, 2015, at 6:57 PM, Alan Batie <alan@peak.org> wrote:
I'm playing with this option as it makes possible some more complex things we may want to do later, but it's not clear how to effect the rewrite:
# %RAD_CHECK Read-only Check items # %RAD_REQUEST Read-only Attributes from the request # %RAD_REPLY Read-write Attributes for the reply
They're read-write in v2. Unless you're using a version which is 5-6 years old. Alan DeKok.
On 10/22/15 8:10 AM, Alan DeKok wrote:
# %RAD_CHECK Read-only Check items # %RAD_REQUEST Read-only Attributes from the request # %RAD_REPLY Read-write Attributes for the reply
They're read-write in v2. Unless you're using a version which is 5-6 years old.
OK, thanks. I'm not sure what I did wrong before, but updating RAD_REQUEST is working.
participants (3)
-
Alan Batie -
Alan DeKok -
Arran Cudbard-Bell