Thanks for the reply Alan. I understand the correct place to put it now. Is there a reason you are setting a new variable and then assigning that to the next update request? Would this not work? if (Mikrotik-Host-IP) { update request { Acct-Input-Octets = "%{Acct-Output-Octets}" Acct-Output-Octets = "%{Acct-Input-Octets}" } } Thanks, James -----Original Message----- From: freeradius-users-bounces+james.wood=purplewifi.com@lists.freeradius.org [mailto:freeradius-users-bounces+james.wood=purplewifi.com@lists.freeradius.org] On Behalf Of Alan DeKok Sent: 22 October 2014 15:34 To: FreeRadius users mailing list Subject: Re: Conditional statements in dialup.conf? James Wood wrote:
On all NAS’s apart from Mikrotik routers, when the radius accounting packets are sent, the correct figures are in the Acct-Input-Octets and Acct-Output-Octets respectively.
OK.
When using Mikrotik, they switch those around (i.e. the download octets are upload and vice versa), and because I use an SQL DB, it means that the values are also stored the wrong way round, as the queries in dialup.conf are fixed to insert in to the same columns.
So... fix the values *before* you put them into SQL.
So, I’m looking to detect a Mikrotik accounting request and then change the columns round so that the DB is always correct.
That is completely backwards. Don't fix the columns. Fix the accounting packet in the "preacct" section: if (Mikrotik-Host-IP) { update request { Tmp-Integer-0 := "%{Acct-Input-Octets} Tmp-Integer-1 := "%{Acct-Output-Octets} } update request { Acct-Input-Octets = "%{Tmp-Integer-0}" Acct-Output-Octets = "%{Tmp-Integer-01}" } }
I’ve tried doing this inside the dialup.conf but not sure it accepts conditional statements inside there.
It doesn't. See "man unlang". The documentation says where you can put conditions. Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html