I have SIP server SER configured to route calls to PSTN over CISCO AS5300 gateway. I would like to restrict users to certain amount of time which they can use to make these calls.

For this I've installed freeradius 1.0.1 with experimental module rlm_sqlcounter (everything is set up as described in doc/rlm_sqlcounter) and I'm using MySQL.

I don't need authentication (it's done on SER server and only authenticated users are allowed to make calls to PSTN) just accounting and time restriction using sqlcounter.

Radius is doing accounting. This works fine. I have in raddacct table data. But the sqlcounter does not work. When I run radiusd -X I get this output

Module: Loaded SQL Counter
sqlcounter: counter-name = "Max-All-Session-Time"
sqlcounter: check-name = "Max-All-Session"
sqlcounter: key = "User-Name"
sqlcounter: sqlmod-inst = "sql"
sqlcounter: query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}'"
sqlcounter: reset = "never"
rlm_sqlcounter: Counter attribute Max-All-Session-Time is number 1671
rlm_sqlcounter: Check attribute Max-All-Session is number 1672
rlm_sqlcounter: Current Time: 1104920610 [2005-01-05 11:23:30], Next reset 0 [2005-01-05 11:00:00]
rlm_sqlcounter: Current Time: 1104920610 [2005-01-05 11:23:30], Prev reset 0 [2005-01-05 11:00:00]
Module: Instantiated sqlcounter (noresetcounter)


This is so far OK. module is loaded. Now when I make a call I receive something like this:

rad_recv: Accounting-Request packet from host 192.168.22.133:21645, id=60, length=536
Acct-Session-Id = "0000003D"
Cisco-AVPair = "[EMAIL PROTECTED]"
Cisco-AVPair = "iphop=count:1"
Cisco-AVPair = "iphop=hop1:192.168.22.55"
h323-setup-time = "h323-setup-time=12:02:14.185 UTC Wed Jan 5 2005"
h323-gw-id = "h323-gw-id=gateway2."
h323-conf-id = "h323-conf-id=78D1C91C 5E4811D9 8010BBC8 ACB832E9"
h323-call-origin = "h323-call-origin=answer"
h323-call-type = "h323-call-type=VoIP"
Cisco-AVPair = "h323-incoming-conf-id=78D1C91C 5E4811D9 8010BBC8 ACB832E9"
Cisco-AVPair = "subscriber=Unknown"
Cisco-AVPair = "session-protocol=sipv2"
Cisco-AVPair = "gw-rxd-cdn=ton:0,npi:0,#:022"
User-Name = "10"
Acct-Status-Type = Start
Calling-Station-Id = "10"
Called-Station-Id = "022"
Service-Type = Login-User
NAS-IP-Address = 192.168.22.133
Acct-Delay-Time = 0
Processing the preacct section of radiusd.conf
modcall: entering group preacct for request 0
Invalid operator for item Suffix: reverting to '=='
Invalid operator for item Suffix: reverting to '=='
Invalid operator for item Suffix: reverting to '=='
modcall[preacct]: module "preprocess" returns noop for request 0
rlm_acct_unique: WARNING: Attribute NAS-Port was not found in request, unique ID MAY be inconsistent
rlm_acct_unique: Hashing ',Client-IP-Address = 192.168.22.133,NAS-IP-Address = 192.168.22.133,Acct-Session-Id = "0000003D",User-Name = "10"'
rlm_acct_unique: Acct-Unique-Session-ID = "39ff838efa44eab9".
modcall[preacct]: module "acct_unique" returns ok for request 0
rlm_realm: No '@' in User-Name = "10", looking up realm NULL
rlm_realm: No such realm "NULL"
modcall[preacct]: module "suffix" returns noop for request 0
modcall: group preacct returns ok for request 0
Processing the accounting section of radiusd.conf
modcall: entering group accounting for request 0
radius_xlat: '/var/log/radius/radacct/192.168.22.133/detail-20050105'
rlm_detail: /var/log/radius/radacct/%{Client-IP-Address}/detail-%Y%m%d expands to /var/log/radius/radacct/192.168.22.133/detail-20050105
modcall[accounting]: module "detail" returns ok for request 0
radius_xlat: '/var/log/radius/radutmp'
radius_xlat: '10'
rlm_radutmp: No NAS-Port seen. Cannot do anything.
rlm_radumtp: WARNING: checkrad will probably not work!
modcall[accounting]: module "radutmp" returns noop for request 0
radius_xlat: '10'
rlm_sql (sql): sql_set_user escaped user --> '10'
radius_xlat: 'INSERT into radacct (RadAcctId, 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) values('', '0000003D', '39ff838efa44eab9', '10', '', '192.168.22.133', '', '', '2005-01-05 11:25:24', '0', '0', '', '', '', '0', '0', '022', '10', '', 'Login-User', '', '', '0', '0')'
rlm_sql (sql): Reserving sql socket id: 4
rlm_sql (sql): Released sql socket id: 4
modcall[accounting]: module "sql" returns ok for request 0
modcall: group accounting returns ok for request 0
Sending Accounting-Response of id 60 to 192.168.22.133:21645
Finished request 0
Going to the next request


........


It just processes start and stop accounting packets but never uses noresetcounter which was correctly loaded.


MySQL tables look like this:

usergroup

id | UserName | GroupName
--------------------------
 1 | 10       | voip

radcheck

id | UserName | Attribute | Value | Op
---------------------------------------
 1 | 10       | Max-All-Session | 30 | :=

radreply

id | UserName | Attribute | Value | Op
---------------------------------------
 1 | 10       | Auth-Type | Reject | :=
 2 | 10       | Reply-Message | You've used all your time | =

What might by wrong? I think that those lines in MySQL are incorrect.

Igor Cahoj

- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to