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.