Can translation of RADIUS packet attributes (e.g., NAS-Port-Type) be configured?
I am running FreeRADIUS 2.1.7. I am attempting to write accounting data to Postgres database. In the database the NAS port type from the request is stored as the integer value that defines the port type in RFC2865 (e.g., 19 - 'Wireless - IEEE 802.11'). The database table is fixed and cannot be changed. When I send a test packet from radclient that contains a port type: Called-Station-Id = "xx-xx-xx-xx-xx-xx" User-Name = "REALM/user" Framed-IP-Address = xxx.xxx.xxx.xxx NAS-IP-Address = xxx.xxx.xxx.xxx NAS-Port-Type = 19 [...] Then when it is received by the server the port type has always been translated into its string value: rad_recv: Accounting-Request packet from host 127.0.0.1 port 54361, id=245, length=262 Called-Station-Id = "xx-xx-xx-xx-xx-xx" User-Name = "REALM/user" Framed-IP-Address = xxx.xxx.xxx.xxx NAS-IP-Address = xxx.xxx.xxx.xxx NAS-Port-Type = Wireless-802.11 Acct-Status-Type = Start [....] +- entering group preacct {...} ++[preprocess] returns ok Obviously, I can't insert 'Wireless-802.11' into an integer field in the database. Is there away of disabling this lookup so that FreeRADIUS does not translate these values when it receives a packet, or am I going to have to code my own reverse lookup into my accounting module? I also have the same problem for other fields like Acct-Termination-Cause. Jack.
Guess I should have persevered for another 10 minutes. I have found a solution to my problem, which is to change my accounting_*_query from: [...] '%{NAS-Port-Type}', [...] to: [...] '%{sql:SELECT shortname FROM ${nas_table} WHERE nasname = %{NAS-Port-Type}}', \ [...] However, I'm still curious if it's possible to configure the behaviour of FreeRADIUS in this regard? Jack. On 17 August 2011 09:56, Jack Patmos <jack.patmos@googlemail.com> wrote:
I am running FreeRADIUS 2.1.7.
I am attempting to write accounting data to Postgres database. In the database the NAS port type from the request is stored as the integer value that defines the port type in RFC2865 (e.g., 19 - 'Wireless - IEEE 802.11'). The database table is fixed and cannot be changed.
When I send a test packet from radclient that contains a port type:
Called-Station-Id = "xx-xx-xx-xx-xx-xx" User-Name = "REALM/user" Framed-IP-Address = xxx.xxx.xxx.xxx NAS-IP-Address = xxx.xxx.xxx.xxx NAS-Port-Type = 19 [...]
Then when it is received by the server the port type has always been translated into its string value:
rad_recv: Accounting-Request packet from host 127.0.0.1 port 54361, id=245, length=262 Called-Station-Id = "xx-xx-xx-xx-xx-xx" User-Name = "REALM/user" Framed-IP-Address = xxx.xxx.xxx.xxx NAS-IP-Address = xxx.xxx.xxx.xxx NAS-Port-Type = Wireless-802.11 Acct-Status-Type = Start [....] +- entering group preacct {...} ++[preprocess] returns ok
Obviously, I can't insert 'Wireless-802.11' into an integer field in the database. Is there away of disabling this lookup so that FreeRADIUS does not translate these values when it receives a packet, or am I going to have to code my own reverse lookup into my accounting module?
I also have the same problem for other fields like Acct-Termination-Cause.
Jack.
On Wed, Aug 17, 2011 at 4:13 PM, Jack Patmos <jack.patmos@googlemail.com> wrote:
Guess I should have persevered for another 10 minutes.
I have found a solution to my problem, which is to change my accounting_*_query from:
[...] '%{NAS-Port-Type}', [...]
to: [...] '%{sql:SELECT shortname FROM ${nas_table} WHERE nasname = %{NAS-Port-Type}}', \ [...]
It's not really the same thing, since you're using whatever is on nas_table instead of the original integer value. Also, "%{sql:" doesn't really work with redundant sql modules instances.
However, I'm still curious if it's possible to configure the behaviour of FreeRADIUS in this regard?
Git log shows this commit b74612c710d3d7e9fdfa4ebf8763877d25a0d3a9 Author: Alan T. DeKok <aland@freeradius.org> Date: Tue Dec 21 10:01:16 2010 +0100 Added %{integer:...} Which takes an argument like %{integer:Event-Timestamp}, and prints it as an integer, bypassing all of the named enumeration and date/time expansion It'd probably do what you want. If you want to use that, I recommend using v2.1.x branch from git instead of 2.1.11. -- Fajar
It's not really the same thing, since you're using whatever is on nas_table instead of the original integer value. Also, "%{sql:" doesn't really work with redundant sql modules instances.
Understood, I will avoid doing that.
Git log shows this
...
It'd probably do what you want. If you want to use that, I recommend using v2.1.x branch from git instead of 2.1.11.
Thanks for the tip- that does look like what I need. Unfortunately I'm not in a position to change the version of FreeRADIUS that's being used here so I will have to find another solution. Thanks, Jack On 17 August 2011 10:59, Fajar A. Nugraha <list@fajar.net> wrote:
On Wed, Aug 17, 2011 at 4:13 PM, Jack Patmos <jack.patmos@googlemail.com> wrote:
Guess I should have persevered for another 10 minutes.
I have found a solution to my problem, which is to change my accounting_*_query from:
[...] '%{NAS-Port-Type}', [...]
to: [...] '%{sql:SELECT shortname FROM ${nas_table} WHERE nasname = %{NAS-Port-Type}}', \ [...]
It's not really the same thing, since you're using whatever is on nas_table instead of the original integer value. Also, "%{sql:" doesn't really work with redundant sql modules instances.
However, I'm still curious if it's possible to configure the behaviour of FreeRADIUS in this regard?
Git log shows this
commit b74612c710d3d7e9fdfa4ebf8763877d25a0d3a9 Author: Alan T. DeKok <aland@freeradius.org> Date: Tue Dec 21 10:01:16 2010 +0100
Added %{integer:...}
Which takes an argument like %{integer:Event-Timestamp}, and prints it as an integer, bypassing all of the named enumeration and date/time expansion
It'd probably do what you want. If you want to use that, I recommend using v2.1.x branch from git instead of 2.1.11.
-- Fajar - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Jack Patmos wrote:
I am attempting to write accounting data to Postgres database. In the database the NAS port type from the request is stored as the integer value that defines the port type in RFC2865 (e.g., 19 - 'Wireless - IEEE 802.11'). The database table is fixed and cannot be changed. ... Obviously, I can't insert 'Wireless-802.11' into an integer field in the database. Is there away of disabling this lookup so that FreeRADIUS does not translate these values when it receives a packet, or am I going to have to code my own reverse lookup into my accounting module?
Yes, this is documented. See "man unlang". %{NAS-Port-Type#} Alan DeKok.
participants (3)
-
Alan DeKok -
Fajar A. Nugraha -
Jack Patmos