How can I output Cisco-AVPair Attributes in linelog?
Greetings, I'm playing with using the linelog module to syslog accounting records. The basics are pretty straightforward to configure, and I have them working. What I can't figure out is how to include the ssid in the linelog output. 'radiusd -X' kindly dumps the contents of the received accounting requests: rad_recv: Accounting-Request packet from host 10.2.2.2 port 1646, id=62, length=234 Acct-Session-Id = "0000004D" Called-Station-Id = "001b.d517.4080" Calling-Station-Id = "0026.4aea.ba42" Cisco-AVPair = "ssid=TEST" Cisco-AVPair = "vlan-id=228" Cisco-AVPair = "nas-location=Office" WISPr-Location-Name = "Office" User-Name = "testuser" Cisco-AVPair = "connect-progress=Call Up" Acct-Authentic = RADIUS Acct-Status-Type = Start NAS-Port-Type = Wireless-802.11 Cisco-NAS-Port = "301" NAS-Port = 301 Service-Type = Framed-User NAS-IP-Address = 10.2.2.2 Acct-Delay-Time = 0 The SSID is in a Cisco-AVPair. I can include them all via Start = "Connect: User: %{User-Name} ( client: %{Calling-Station-Id} location: %{WISPr-Location-Name}) %{Cisco-AVPair[*]}" or the first one by using %{Cisco-AVPair[1]}. But I have no guarantee that the ssid will be the first AV pair. I've tried using unlang constructs to pull the data out, but can't figure out the right syntax. I'm trying something like the config below, just to see if the 'if/else' clauses even fire and they don't. No matter what I put in for the regexp, SSID never gets redefined to TRUE or FALSE. It always outputs as 'Junk'. I'm sure this is doable, I just don't know the exact syntax. Any ideas? Thanks in advance.
From linelog configuration:
Accounting-Request { SSID="Junk" Pairs = "%{Cisco-AVPair[0]}" if ( Pairs =~ /.*/ ) { SSID="TRUE" } else { SSID = "FALSE" } Start = "Connect: User: %{User-Name} ( client: %{Calling-Station-Id} location: %{WISPr-Location-Name}) SSID:${SSID} ${Pairs}" -- ----------------------------------------------------------------- | David Mitchell (mitchell@ucar.edu) Network Engineer IV | | Tel: (303) 497-1845 National Center for | | FAX: (303) 497-1818 Atmospheric Research | -----------------------------------------------------------------
David Mitchell wrote:
The SSID is in a Cisco-AVPair. I can include them all via
Start = "Connect: User: %{User-Name} ( client: %{Calling-Station-Id} location: %{WISPr-Location-Name}) %{Cisco-AVPair[*]}"
or the first one by using %{Cisco-AVPair[1]}. But I have no guarantee that the ssid will be the first AV pair.
Yes... there's no simple way to do that right now.
I've tried using unlang constructs to pull the data out, but can't figure out the right syntax. I'm trying something like the config below, just to see if the 'if/else' clauses even fire and they don't. No matter what I put in for the regexp, SSID never gets redefined to TRUE or FALSE. It always outputs as 'Junk'. I'm sure this is doable, I just don't know the exact syntax. Any ideas? Thanks in advance.
From linelog configuration:
Accounting-Request { SSID="Junk" Pairs = "%{Cisco-AVPair[0]}"
You can't do that. The configuration files are NOT a programming language. If you want to set temporary variables (really attributes), see the "update" section. Alan DeKok.
On Tue, 6 Oct 2009, Alan DeKok wrote:
Start = "Connect: User: %{User-Name} ( client: %{Calling-Station-Id} location: %{WISPr-Location-Name}) %{Cisco-AVPair[*]}"
or the first one by using %{Cisco-AVPair[1]}. But I have no guarantee that the ssid will be the first AV pair.
Yes... there's no simple way to do that right now.
We do this: elsif ("%{Cisco-AVPair}" =~ /^ssid=(.+)$/) { # a Cisco AP update request { UCam-Location-Id := "%{NAS-IP-Address}" UCam-Essid-Name := "%{1}" } [We use UCam-Essid-Name and UCam-Location-Id as local dictionary items to handle different types of APs by setting a common field.] I've never seen another Cisco-AVPair attribute (only 'ssid=xxx') -- what happens if there is and I'm doing the above? Will it match the first (or an abitrary one) or will it find one which matches and return false if there if isn't? - Bob -- Bob Franklin <rcf34@cam.ac.uk> +44 1223 748479 Network Division, University of Cambridge Computing Service
Bob Franklin wrote:
On Tue, 6 Oct 2009, Alan DeKok wrote:
Start = "Connect: User: %{User-Name} ( client: %{Calling-Station-Id} location: %{WISPr-Location-Name}) %{Cisco-AVPair[*]}"
or the first one by using %{Cisco-AVPair[1]}. But I have no guarantee that the ssid will be the first AV pair.
Yes... there's no simple way to do that right now.
We do this:
elsif ("%{Cisco-AVPair}" =~ /^ssid=(.+)$/) { # a Cisco AP
update request { UCam-Location-Id := "%{NAS-IP-Address}" UCam-Essid-Name := "%{1}" }
[We use UCam-Essid-Name and UCam-Location-Id as local dictionary items to handle different types of APs by setting a common field.]
I've never seen another Cisco-AVPair attribute (only 'ssid=xxx') -- what happens if there is and I'm doing the above? Will it match the first (or an abitrary one) or will it find one which matches and return false if there if isn't?
That's a good question. I get about six AVPair's so I could test. What portion of the config do you put that code into? -David Mitchell
- Bob
-- ----------------------------------------------------------------- | David Mitchell (mitchell@ucar.edu) Network Engineer IV | | Tel: (303) 497-1845 National Center for | | FAX: (303) 497-1818 Atmospheric Research | -----------------------------------------------------------------
On Tue, 6 Oct 2009, David Mitchell wrote:
elsif ("%{Cisco-AVPair}" =~ /^ssid=(.+)$/) { # a Cisco AP
update request { UCam-Location-Id := "%{NAS-IP-Address}" UCam-Essid-Name := "%{1}" }
I've never seen another Cisco-AVPair attribute (only 'ssid=xxx') -- what happens if there is and I'm doing the above? Will it match the first (or an abitrary one) or will it find one which matches and return false if there if isn't?
That's a good question. I get about six AVPair's so I could test. What portion of the config do you put that code into?
It's in the authorize { } section (and the accounting { } section, too, I think). - Bob -- Bob Franklin <rcf34@cam.ac.uk> +44 1223 748479 Network Division, University of Cambridge Computing Service
Alan DeKok wrote:
David Mitchell wrote:
The SSID is in a Cisco-AVPair. I can include them all via
Start = "Connect: User: %{User-Name} ( client: %{Calling-Station-Id} location: %{WISPr-Location-Name}) %{Cisco-AVPair[*]}"
or the first one by using %{Cisco-AVPair[1]}. But I have no guarantee that the ssid will be the first AV pair.
Yes... there's no simple way to do that right now.
Is usage of Cisco-AVPair, or other similar variables, common enough to include code for it? For example, perhaps they could be accessed via a Perl hash-like structure as %{Cisco-AVPair[ssid]} to get "TEST" from Cisco-AVPair = "ssid=TEST". I don't think the coe would be hard to write, but I have no idea where it would fit in.
I've tried using unlang constructs to pull the data out, but can't figure out the right syntax. I'm trying something like the config below, just to see if the 'if/else' clauses even fire and they don't. No matter what I put in for the regexp, SSID never gets redefined to TRUE or FALSE. It always outputs as 'Junk'. I'm sure this is doable, I just don't know the exact syntax. Any ideas? Thanks in advance.
From linelog configuration:
Accounting-Request { SSID="Junk" Pairs = "%{Cisco-AVPair[0]}"
You can't do that. The configuration files are NOT a programming language. If you want to set temporary variables (really attributes), see the "update" section.
Oddly, I can do that. It works fine and I can reference the variables later as ${SSID} and ${Pairs}. I was hoping that I could use unlang constructs in the linelog config file but it sounds like that isn't the case. I can live with just dumping %{Cisco-AVPair[*]} into my logs, I just end up with some extra junk I don't care about. I've never been 100% clear on where I can and can't use unlang syntax. Thanks for the help, -David Mitchell
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- ----------------------------------------------------------------- | David Mitchell (mitchell@ucar.edu) Network Engineer IV | | Tel: (303) 497-1845 National Center for | | FAX: (303) 497-1818 Atmospheric Research | -----------------------------------------------------------------
Is usage of Cisco-AVPair, or other similar variables, common enough to include code for it? For example, perhaps they could be accessed via a Perl hash-like structure as %{Cisco-AVPair[ssid]} to get "TEST" from Cisco-AVPair = "ssid=TEST". I don't think the coe would be hard to write, but I have no idea where it would fit in.
Do guidlines from man unlang work in perl? If they do, you can get number of avpairs from %{Cisco-AVPair[#]}, and the loop through %{Cisco-AVPair[i]} until you find the one with ssid. Ivan Kalik Kalik Informatika ISP
participants (4)
-
Alan DeKok -
Bob Franklin -
David Mitchell -
Ivan Kalik