Conditional statements in dialup.conf?
James Wood
james.wood at purplewifi.com
Wed Oct 22 10:02:16 CEST 2014
Hi All,
I'm wondering if you can advise on the best way to deal with the below.
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.
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, I'm looking to detect a Mikrotik accounting request and then change the
columns round so that the DB is always correct.
I've tried doing this inside the dialup.conf but not sure it accepts
conditional statements inside there. (I use other conditional statements in
sites-enabled/default etc, so have an understanding on that in general).
---------------------------------
if (Mikrotik-Host-IP) {
accounting_start_query = " \
INSERT INTO ${acct_table1} \
(acctsessionid, acctuniqueid, username, \
realm, nasipaddress, nasportid, \
nasporttype, acctstarttime, acctstoptime, \
acctsessiontime, acctauthentic, connectinfo_start, \
connectinfo_stop, acctoutputoctets, acctinputoctets, \
calledstationid, callingstationid, acctterminatecause, \
servicetype, framedprotocol, framedipaddress, \
acctstartdelay, acctstopdelay, xascendsessionsvrkey) \
VALUES \
('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
'%{SQL-User-Name}', \
'%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
'%{NAS-Port-Type}', '%S', NULL, \
'0', '%{Acct-Authentic}', '%{Connect-Info}', \
'', '0', '0', \
REPLACE(SUBSTRING('%{Called-Station-Id}',1,17),':','-'), \
REPLACE(SUBSTRING('%{Calling-Station-Id}',1,17),':','-'), '', \
'%{Service-Type}', '%{Framed-Protocol}',
'%{Framed-IP-Address}', \
'%{%{Acct-Delay-Time}:-0}', '0',
'%{X-Ascend-Session-Svr-Key}')"
} else {
accounting_start_query = " \
INSERT INTO ${acct_table1} \
(acctsessionid, acctuniqueid, username, \
realm, nasipaddress, nasportid, \
nasporttype, acctstarttime, acctstoptime, \
acctsessiontime, acctauthentic, connectinfo_start, \
connectinfo_stop, acctinputoctets, acctoutputoctets, \
calledstationid, callingstationid, acctterminatecause, \
servicetype, framedprotocol, framedipaddress, \
acctstartdelay, acctstopdelay, xascendsessionsvrkey) \
VALUES \
('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', \
'%{SQL-User-Name}', \
'%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', \
'%{NAS-Port-Type}', '%S', NULL, \
'0', '%{Acct-Authentic}', '%{Connect-Info}', \
'', '0', '0', \
REPLACE(SUBSTRING('%{Called-Station-Id}',1,17),':','-'), \
REPLACE(SUBSTRING('%{Calling-Station-Id}',1,17),':','-'), '', \
'%{Service-Type}', '%{Framed-Protocol}',
'%{Framed-IP-Address}', \
'%{%{Acct-Delay-Time}:-0}', '0',
'%{X-Ascend-Session-Svr-Key}')"
}
-------------------------------------
This doesn't work; it throws a config error strangely, which goes away if I
comment out the if statement.
[.]
Wed Oct 22 07:59:28 2014 : Debug: including configuration file
/usr/local/etc/raddb/sql.conf
Wed Oct 22 07:59:28 2014 : Debug: including configuration file
/usr/local/etc/raddb/sql/mysql/dialup.conf
Wed Oct 22 07:59:28 2014 : Debug: WARNING: No such configuration item
acct_table1
Wed Oct 22 07:59:28 2014 : Error:
/usr/local/etc/raddb/sql/mysql/dialup.conf[165]: Reference "
UPDATE ${acct_table1} SET framedipaddress =
'%{Framed-IP-Address}', acctsessiontime =
'%{Acct-Session-Time}', acctoutputoctets =
'%{%{Acct-Input-Gigawords}:-0}' << 32 |
'%{%{Acct-Input-Octets}:-0}', acctinputoctets =
'%{%{Acct-Output-Gigawords}:-0}' << 32 |
'%{%{Acct-Output-Octets}:-0}' WHERE acctsessionid =
'%{Acct-Session-Id}' AND username = '%{SQL-User-Name}'
AND nasipaddress = '%{NAS-IP-Address}'" not found
Wed Oct 22 07:59:28 2014 : Error: Errors reading
/usr/local/etc/raddb/radiusd.conf
If I'm doing it wrong can you point me in the direction of how else to
change the incoming request so that I can switch the download/upload values
for Mikrotik?
Thanks,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20141022/c785f979/attachment.html>
More information about the Freeradius-Users
mailing list