Re: sqlcounter returning wrong value?

2008-11-13 Thread Venkatesh K
Hi Liran,

here is the patch. I have done some initial testing.


--- freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c   
2008-11-13
11:21:14.0 +0530
+++ freeradius-1.1.7/src/modules/rlm_sqlcounter/rlm_sqlcounter.c
2008-11-13
14:35:58.0 +0530
@@ -72,6 +72,8 @@
char *sqlmod_inst;  /* instance of SQL module to use, usually just 
'sql' */
char *query;/* SQL query to retrieve current session time */
char *reset;/* daily, weekly, monthly, never or user 
defined */
+   char *counter_type; /* Type of counter (data / time) */
+   char *check_unit;   /* Unit of Check Value in 
Octets/KibiOctets/MibiOctets */
char *allowed_chars;/* safe characters list for SQL queries */
time_t reset_time;
time_t last_reset;
@@ -96,6 +98,8 @@
   { key, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,key_name),
NULL, NULL },
   { sqlmod-inst, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,sqlmod_inst), NULL, NULL },
   { query, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,query),
NULL, NULL },
+  { counter-type, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,counter_type), NULL, NULL },
+  { check-unit, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,check_unit), NULL, NULL },
   { reset, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,reset),
NULL,  NULL },
   { safe-characters, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,allowed_chars), NULL,
@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:
/},
   { NULL, -1, 0, NULL, NULL }
@@ -587,7 +591,7 @@
rlm_sqlcounter_t *data = (rlm_sqlcounter_t *) instance;
int ret=RLM_MODULE_NOOP;
int counter=0;
-   int res=0;
+   uint32_t res=0;
DICT_ATTR *dattr;
VALUE_PAIR *key_vp, *check_vp;
VALUE_PAIR *reply_item;
@@ -612,7 +616,6 @@
find_next_reset(data,request-timestamp);
}

-
/*
 *  Look for the key.  User-Name is special.  It means
 *  The REAL username, after stripping.
@@ -658,6 +661,25 @@
res=check_vp-lvalue - counter;
if (res  0) {
DEBUG2(rlm_sqlcounter: (Check item - counter) is greater than 
zero);
+
+   if(data-check_unit) {
+   if(strcasecmp(data-check_unit,KibiOctets)==0) {
+   if(res = 4194303) {
+   res = 4294967295;
+   } else {
+   res = res * 1024;
+   }
+   } else if(strcasecmp(data-check_unit,MibiOctets)==0) 
{
+   if(res = 4095) {
+   res = 4294967295;
+   } else {
+   res = res * 1024 * 1024;
+   }
+   }
+   }
+
+   DEBUG2(rlm_sqlcounter: Post processing result=%u, res);
+
/*
 *  We are assuming that simultaneous-use=1. But
 *  even if that does not happen then our user
@@ -675,10 +697,17 @@
 *  limit, so that the user will not need to
 *  login again
 */
-   if (data-reset_time  (
-   res = (data-reset_time - request-timestamp))) {
-   res = data-reset_time - request-timestamp;
-   res += check_vp-lvalue;
+
+   /*
+* While counting data transfer, We don't have to add the next 
limit.
+*
+*/
+   if((data-counter_type)  
(strcmp(data-counter_type,time)==0)) {
+   if (data-reset_time  (
+   res = (data-reset_time - 
request-timestamp))) {
+   res = data-reset_time - request-timestamp;
+   res += check_vp-lvalue;
+   }
}

if ((reply_item = pairfind(request-reply-vps, 
data-reply_attr)) != NULL) {
@@ -695,9 +724,9 @@

ret=RLM_MODULE_OK;

-   DEBUG2(rlm_sqlcounter: Authorized user %s, check_item=%d, 
counter=%d,
+   DEBUG2(rlm_sqlcounter: Authorized user %s, check_item=%u, 
counter=%d,
key_vp-strvalue,check_vp-lvalue,counter);
-   DEBUG2(rlm_sqlcounter: Sent Reply-Item for user %s, Type=%s, 
value=%d,
+   DEBUG2(rlm_sqlcounter: Sent Reply-Item for user %s, Type=%s, 
value=%u,

key_vp-strvalue,data-reply_name,reply_item-lvalue);
}
else{
-

Here is a 

Re: sqlcounter returning wrong value?

2008-11-12 Thread Flamur Rogova

liran tal wrote:
 
Waiting for that traffic limitation patch, Venkatesh.

Thanks.



Hi,
I was stuck with this problem too, and I came up with this solution, 
which works in my test environment.


The idea is to store allowed bytes in Tmp-Integer-0, than just use 
unlang to compare user's allowed and actual traffic bytes.


btw, maximum traffic count is 2^31 bytes, if you do it this way.


if(control:Tmp-Integer-0) {
if(%{sql:SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct 
WHERE UserName='%{User-Name}' }  %{control:Tmp-Integer-0} ) {

# traffic bytes limit reached
reject
}
}

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


Re: sqlcounter returning wrong value?

2008-11-12 Thread Venkatesh K
Hi,

On Wed, Nov 12, 2008 at 2:06 AM, liran tal [EMAIL PROTECTED] wrote:

 Waiting for that traffic limitation patch, Venkatesh.
 Thanks.

I am sorry. I had few busy days this week. You can expect a patch tomorrow.


 On Sun, Nov 9, 2008 at 6:00 AM, Venkatesh K [EMAIL PROTECTED] wrote:

 Hi Liran,

 On Sun, Nov 9, 2008 at 4:16 AM, liran tal [EMAIL PROTECTED] wrote:
  Hey Venkatesh,
 
  On Fri, Oct 31, 2008 at 2:26 AM, Venkatesh K [EMAIL PROTECTED] wrote:
 
  2008/10/31  [EMAIL PROTECTED]:
   It does make sense. rlm_sqlcounterworks like this toward the time of
   the
   reset: lets say you have an hour left, your limit is 20 hours and you
   have signed in 15 minutes before counter reset time.  When code
   calculates that you can be online at reset time it doesn't return
   your
   allowance (1 hour) but adds the limit for the next conting period (20
   hours) to the remaining time (15 minutes) and returns that value (20
   hours and 15 minutes). Reasoning is that your session shouldn't be
   discontinued after an hour becouse 15 minutes into the session new
   limit
   should come into force (and session limit can't be changed during the
   session).
  
   In your case there is about 2,000,000 left on the counter but only a
   few
   thousand seconds left to the end of the reset period, so code will
   add
   those few thousands to the next period limit (26,000,000) and return
   that value. Code doesn't know are you counting data or time as
   there is  no such configuration item.
  
   Venkatesh had posted the patch that switches off this peace of code
   for
   data counters by introducing that configuration item. You should try
   it.
 
  rlm_sqlcounter has one more limitation. In version 1.1.7, the maximum
  counter value was limited to 2G whereas in 2.1.1 it seems to be 4G.
  This imposes an artificial limitation of maximum of 4GB of downloads.
  I had a workaround where I patched rlm_sqlcounter to limit the per
  session downloads to 4GB if allowed usage exceeds 4GB.
 
  Except this issue, I think, with the patch I posted earlier, one
  should be fine with rlm_sqlcounter. If someone needs a patch to work
  around the 2GB/4GB limit, I will post the patch.
 
 
  Sorry for the late reply.
  I applied your patch and now data counters work as expected with a minor
  exception, the 2Gb limit
  as you have stated previously. Possibly you could also post the patch
  for
  the 2Gb/4Gb limit?
  I'm hoping it's compatible with FR 1.1.7 as well.
 

 It is ok. I am happy to know it works for you. I will email you a
 patch for 1.1.7 in couple of days. The patch is going to impose
 certain limitations on you. The maximum return value should be less
 than unsigned integer(32bit). The maximum reply value for data will be
 limited to 4GB even if actual value is more than 4GB. So, there will
 be a per session limit of 4GB though user is authorized to transfer
 more data.

 Regards,

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


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


Regards,

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


Re: sqlcounter returning wrong value?

2008-11-12 Thread liran tal
Hey,

Thanks for the tip, though that's FR2-specific solution and I'd like to be
able to get this sort out with older deployments
running 1.1.7 or earlier (god forbid! :-) )

That patch for rlm_sqlcounter would be ideal I think.
I think this should also be already pushed into the formal release, this
entire support for data information too.

Regards,
Liran.

On Wed, Nov 12, 2008 at 11:02 AM, Flamur Rogova [EMAIL PROTECTED] wrote:

 liran tal wrote:

  Waiting for that traffic limitation patch, Venkatesh.
 Thanks.


 Hi,
 I was stuck with this problem too, and I came up with this solution, which
 works in my test environment.

 The idea is to store allowed bytes in Tmp-Integer-0, than just use unlang
 to compare user's allowed and actual traffic bytes.

 btw, maximum traffic count is 2^31 bytes, if you do it this way.


 if(control:Tmp-Integer-0) {
if(%{sql:SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct
 WHERE UserName='%{User-Name}' }  %{control:Tmp-Integer-0} ) {
# traffic bytes limit reached
reject
}
 }

 Regards,
 Flamur

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

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

Re: sqlcounter returning wrong value?

2008-11-11 Thread liran tal
Waiting for that traffic limitation patch, Venkatesh.
Thanks.

On Sun, Nov 9, 2008 at 6:00 AM, Venkatesh K [EMAIL PROTECTED] wrote:

 Hi Liran,

 On Sun, Nov 9, 2008 at 4:16 AM, liran tal [EMAIL PROTECTED] wrote:
  Hey Venkatesh,
 
  On Fri, Oct 31, 2008 at 2:26 AM, Venkatesh K [EMAIL PROTECTED] wrote:
 
  2008/10/31  [EMAIL PROTECTED]:
   It does make sense. rlm_sqlcounterworks like this toward the time of
 the
   reset: lets say you have an hour left, your limit is 20 hours and you
   have signed in 15 minutes before counter reset time.  When code
   calculates that you can be online at reset time it doesn't return your
   allowance (1 hour) but adds the limit for the next conting period (20
   hours) to the remaining time (15 minutes) and returns that value (20
   hours and 15 minutes). Reasoning is that your session shouldn't be
   discontinued after an hour becouse 15 minutes into the session new
 limit
   should come into force (and session limit can't be changed during the
   session).
  
   In your case there is about 2,000,000 left on the counter but only a
 few
   thousand seconds left to the end of the reset period, so code will add
   those few thousands to the next period limit (26,000,000) and return
   that value. Code doesn't know are you counting data or time as
   there is  no such configuration item.
  
   Venkatesh had posted the patch that switches off this peace of code
 for
   data counters by introducing that configuration item. You should try
 it.
 
  rlm_sqlcounter has one more limitation. In version 1.1.7, the maximum
  counter value was limited to 2G whereas in 2.1.1 it seems to be 4G.
  This imposes an artificial limitation of maximum of 4GB of downloads.
  I had a workaround where I patched rlm_sqlcounter to limit the per
  session downloads to 4GB if allowed usage exceeds 4GB.
 
  Except this issue, I think, with the patch I posted earlier, one
  should be fine with rlm_sqlcounter. If someone needs a patch to work
  around the 2GB/4GB limit, I will post the patch.
 
 
  Sorry for the late reply.
  I applied your patch and now data counters work as expected with a minor
  exception, the 2Gb limit
  as you have stated previously. Possibly you could also post the patch for
  the 2Gb/4Gb limit?
  I'm hoping it's compatible with FR 1.1.7 as well.
 

 It is ok. I am happy to know it works for you. I will email you a
 patch for 1.1.7 in couple of days. The patch is going to impose
 certain limitations on you. The maximum return value should be less
 than unsigned integer(32bit). The maximum reply value for data will be
 limited to 4GB even if actual value is more than 4GB. So, there will
 be a per session limit of 4GB though user is authorized to transfer
 more data.

 Regards,

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

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

Re: sqlcounter returning wrong value?

2008-11-09 Thread liran tal
On Sun, Nov 9, 2008 at 6:00 AM, Venkatesh K [EMAIL PROTECTED] wrote:

 Hi Liran,

 On Sun, Nov 9, 2008 at 4:16 AM, liran tal [EMAIL PROTECTED] wrote:
  Hey Venkatesh,
 
  On Fri, Oct 31, 2008 at 2:26 AM, Venkatesh K [EMAIL PROTECTED] wrote:
 
  rlm_sqlcounter has one more limitation. In version 1.1.7, the maximum
  counter value was limited to 2G whereas in 2.1.1 it seems to be 4G.
  This imposes an artificial limitation of maximum of 4GB of downloads.
  I had a workaround where I patched rlm_sqlcounter to limit the per
  session downloads to 4GB if allowed usage exceeds 4GB.
 
  Sorry for the late reply.
  I applied your patch and now data counters work as expected with a minor
  exception, the 2Gb limit
  as you have stated previously. Possibly you could also post the patch for
  the 2Gb/4Gb limit?
  I'm hoping it's compatible with FR 1.1.7 as well.
 
 It is ok. I am happy to know it works for you. I will email you a
 patch for 1.1.7 in couple of days. The patch is going to impose
 certain limitations on you. The maximum return value should be less
 than unsigned integer(32bit). The maximum reply value for data will be
 limited to 4GB even if actual value is more than 4GB. So, there will
 be a per session limit of 4GB though user is authorized to transfer
 more data.

So the check value of the attribute remains a number bigger than 4GB, for
example an 8GB
limit but the reply attribute that is sent will contain a value of = 4GB
due to the limit?

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

Re: sqlcounter returning wrong value?

2008-11-09 Thread Anders Holm

Answers before questions? Novel idea.

limited to 4GB

Sent from my iPhone

On 9 Nov 2008, at 14:00, liran tal [EMAIL PROTECTED] wrote:



On Sun, Nov 9, 2008 at 6:00 AM, Venkatesh K [EMAIL PROTECTED] wrote:
Hi Liran,

On Sun, Nov 9, 2008 at 4:16 AM, liran tal [EMAIL PROTECTED]  
wrote:

 Hey Venkatesh,

 On Fri, Oct 31, 2008 at 2:26 AM, Venkatesh K [EMAIL PROTECTED]  
wrote:


 rlm_sqlcounter has one more limitation. In version 1.1.7, the  
maximum
 counter value was limited to 2G whereas in 2.1.1 it seems to be  
4G.
 This imposes an artificial limitation of maximum of 4GB of  
downloads.

 I had a workaround where I patched rlm_sqlcounter to limit the per
 session downloads to 4GB if allowed usage exceeds 4GB.

 Sorry for the late reply.
 I applied your patch and now data counters work as expected with a  
minor

 exception, the 2Gb limit
 as you have stated previously. Possibly you could also post the  
patch for

 the 2Gb/4Gb limit?
 I'm hoping it's compatible with FR 1.1.7 as well.

It is ok. I am happy to know it works for you. I will email you a
patch for 1.1.7 in couple of days. The patch is going to impose
certain limitations on you. The maximum return value should be less
than unsigned integer(32bit). The maximum reply value for data will be
limited to 4GB even if actual value is more than 4GB. So, there will
be a per session limit of 4GB though user is authorized to transfer
more data.
So the check value of the attribute remains a number bigger than  
4GB, for example an 8GB
limit but the reply attribute that is sent will contain a value of  
= 4GB due to the limit?


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

Re: sqlcounter returning wrong value?

2008-11-08 Thread liran tal
Hey Venkatesh,

On Fri, Oct 31, 2008 at 2:26 AM, Venkatesh K [EMAIL PROTECTED] wrote:

 2008/10/31  [EMAIL PROTECTED]:
  It does make sense. rlm_sqlcounterworks like this toward the time of the
  reset: lets say you have an hour left, your limit is 20 hours and you
  have signed in 15 minutes before counter reset time.  When code
  calculates that you can be online at reset time it doesn't return your
  allowance (1 hour) but adds the limit for the next conting period (20
  hours) to the remaining time (15 minutes) and returns that value (20
  hours and 15 minutes). Reasoning is that your session shouldn't be
  discontinued after an hour becouse 15 minutes into the session new limit
  should come into force (and session limit can't be changed during the
  session).
 
  In your case there is about 2,000,000 left on the counter but only a few
  thousand seconds left to the end of the reset period, so code will add
  those few thousands to the next period limit (26,000,000) and return
  that value. Code doesn't know are you counting data or time as
  there is  no such configuration item.
 
  Venkatesh had posted the patch that switches off this peace of code for
  data counters by introducing that configuration item. You should try it.

 rlm_sqlcounter has one more limitation. In version 1.1.7, the maximum
 counter value was limited to 2G whereas in 2.1.1 it seems to be 4G.
 This imposes an artificial limitation of maximum of 4GB of downloads.
 I had a workaround where I patched rlm_sqlcounter to limit the per
 session downloads to 4GB if allowed usage exceeds 4GB.

 Except this issue, I think, with the patch I posted earlier, one
 should be fine with rlm_sqlcounter. If someone needs a patch to work
 around the 2GB/4GB limit, I will post the patch.


Sorry for the late reply.
I applied your patch and now data counters work as expected with a minor
exception, the 2Gb limit
as you have stated previously. Possibly you could also post the patch for
the 2Gb/4Gb limit?
I'm hoping it's compatible with FR 1.1.7 as well.

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

Re: sqlcounter returning wrong value?

2008-11-08 Thread Venkatesh K
Hi Liran,

On Sun, Nov 9, 2008 at 4:16 AM, liran tal [EMAIL PROTECTED] wrote:
 Hey Venkatesh,

 On Fri, Oct 31, 2008 at 2:26 AM, Venkatesh K [EMAIL PROTECTED] wrote:

 2008/10/31  [EMAIL PROTECTED]:
  It does make sense. rlm_sqlcounterworks like this toward the time of the
  reset: lets say you have an hour left, your limit is 20 hours and you
  have signed in 15 minutes before counter reset time.  When code
  calculates that you can be online at reset time it doesn't return your
  allowance (1 hour) but adds the limit for the next conting period (20
  hours) to the remaining time (15 minutes) and returns that value (20
  hours and 15 minutes). Reasoning is that your session shouldn't be
  discontinued after an hour becouse 15 minutes into the session new limit
  should come into force (and session limit can't be changed during the
  session).
 
  In your case there is about 2,000,000 left on the counter but only a few
  thousand seconds left to the end of the reset period, so code will add
  those few thousands to the next period limit (26,000,000) and return
  that value. Code doesn't know are you counting data or time as
  there is  no such configuration item.
 
  Venkatesh had posted the patch that switches off this peace of code for
  data counters by introducing that configuration item. You should try it.

 rlm_sqlcounter has one more limitation. In version 1.1.7, the maximum
 counter value was limited to 2G whereas in 2.1.1 it seems to be 4G.
 This imposes an artificial limitation of maximum of 4GB of downloads.
 I had a workaround where I patched rlm_sqlcounter to limit the per
 session downloads to 4GB if allowed usage exceeds 4GB.

 Except this issue, I think, with the patch I posted earlier, one
 should be fine with rlm_sqlcounter. If someone needs a patch to work
 around the 2GB/4GB limit, I will post the patch.


 Sorry for the late reply.
 I applied your patch and now data counters work as expected with a minor
 exception, the 2Gb limit
 as you have stated previously. Possibly you could also post the patch for
 the 2Gb/4Gb limit?
 I'm hoping it's compatible with FR 1.1.7 as well.


It is ok. I am happy to know it works for you. I will email you a
patch for 1.1.7 in couple of days. The patch is going to impose
certain limitations on you. The maximum return value should be less
than unsigned integer(32bit). The maximum reply value for data will be
limited to 4GB even if actual value is more than 4GB. So, there will
be a per session limit of 4GB though user is authorized to transfer
more data.

Regards,

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


Re: sqlcounter returning wrong value?

2008-10-30 Thread liran tal
Well, taking this issue back to the begining - it all started with my report
that using the attribute Chilli-Max-Total-Octets
in the sqlcounter provided as follows yields wrong results for all of the
reset times (daily/weekly/monthly):

sqlcounter counterChilliSpotMaxDailyOctets {
counter-name = ChilliSpot-Max-Daily-Octets
check-name = ChilliSpot-Max-Daily-Octets
reply-name = ChilliSpot-Max-Total-Octets
sqlmod-inst = sql
key = User-Name
reset = daily
error-msg = Sorry, your maximum traffic usage (download and
upload) has exceed the provided limit
query = SELECT (SUM(AcctInputOctets + AcctOutputOctets))
FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime  '%b'
}

For a user defined with the following entry in radcheck:
| 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |

The result returned by freeradius is:
check_item=26214400 and counter=24004370, return value=26239950 (which makes
no sense).



Regards,
Liran.


2008/10/30 Venkatesh K [EMAIL PROTECTED]

 The patch I posted was out of the hat just to skip the routine
 which adds additional quota.

 We have stopped using rlm_sqlcounter long back as we moved
 from radius schema to our own custom schema and patched
 the rlm_sql to work with our custom schema.

 If you or someone list out what one would like to see in rlm_sql_counter,
 I will try to come up with the patch. Back porting to previous versions
 of radius should not be a big problem as rlm_sql and rlm_sqlcounter
 have't changed much.

 Thanks,

 Venkatesh K


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

Re: sqlcounter returning wrong value?

2008-10-30 Thread tnt
It does make sense. rlm_sqlcounterworks like this toward the time of the
reset: lets say you have an hour left, your limit is 20 hours and you
have signed in 15 minutes before counter reset time.  When code
calculates that you can be online at reset time it doesn't return your
allowance (1 hour) but adds the limit for the next conting period (20
hours) to the remaining time (15 minutes) and returns that value (20
hours and 15 minutes). Reasoning is that your session shouldn't be
discontinued after an hour becouse 15 minutes into the session new limit
should come into force (and session limit can't be changed during the
session).

In your case there is about 2,000,000 left on the counter but only a few
thousand seconds left to the end of the reset period, so code will add
those few thousands to the next period limit (26,000,000) and return
that value. Code doesn't know are you counting data or time as
there is  no such configuration item.

Venkatesh had posted the patch that switches off this peace of code for
data counters by introducing that configuration item. You should try it.

Ivan Kalik
Kalik Informatika ISP


Dana 30/10/2008, liran tal [EMAIL PROTECTED] piše:

Well, taking this issue back to the begining - it all started with my report
that using the attribute Chilli-Max-Total-Octets
in the sqlcounter provided as follows yields wrong results for all of the
reset times (daily/weekly/monthly):

sqlcounter counterChilliSpotMaxDailyOctets {
counter-name = ChilliSpot-Max-Daily-Octets
check-name = ChilliSpot-Max-Daily-Octets
reply-name = ChilliSpot-Max-Total-Octets
sqlmod-inst = sql
key = User-Name
reset = daily
error-msg = Sorry, your maximum traffic usage (download and
upload) has exceed the provided limit
query = SELECT (SUM(AcctInputOctets + AcctOutputOctets))
FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime  '%b'
}

For a user defined with the following entry in radcheck:
| 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |

The result returned by freeradius is:
check_item=26214400 and counter=24004370, return value=26239950 (which makes
no sense).



Regards,
Liran.


2008/10/30 Venkatesh K [EMAIL PROTECTED]

 The patch I posted was out of the hat just to skip the routine
 which adds additional quota.

 We have stopped using rlm_sqlcounter long back as we moved
 from radius schema to our own custom schema and patched
 the rlm_sql to work with our custom schema.

 If you or someone list out what one would like to see in rlm_sql_counter,
 I will try to come up with the patch. Back porting to previous versions
 of radius should not be a big problem as rlm_sql and rlm_sqlcounter
 have't changed much.

 Thanks,

 Venkatesh K





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


Re: sqlcounter returning wrong value?

2008-10-30 Thread Venkatesh K
2008/10/31  [EMAIL PROTECTED]:
 It does make sense. rlm_sqlcounterworks like this toward the time of the
 reset: lets say you have an hour left, your limit is 20 hours and you
 have signed in 15 minutes before counter reset time.  When code
 calculates that you can be online at reset time it doesn't return your
 allowance (1 hour) but adds the limit for the next conting period (20
 hours) to the remaining time (15 minutes) and returns that value (20
 hours and 15 minutes). Reasoning is that your session shouldn't be
 discontinued after an hour becouse 15 minutes into the session new limit
 should come into force (and session limit can't be changed during the
 session).

 In your case there is about 2,000,000 left on the counter but only a few
 thousand seconds left to the end of the reset period, so code will add
 those few thousands to the next period limit (26,000,000) and return
 that value. Code doesn't know are you counting data or time as
 there is  no such configuration item.

 Venkatesh had posted the patch that switches off this peace of code for
 data counters by introducing that configuration item. You should try it.

rlm_sqlcounter has one more limitation. In version 1.1.7, the maximum
counter value was limited to 2G whereas in 2.1.1 it seems to be 4G.
This imposes an artificial limitation of maximum of 4GB of downloads.
I had a workaround where I patched rlm_sqlcounter to limit the per
session downloads to 4GB if allowed usage exceeds 4GB.

Except this issue, I think, with the patch I posted earlier, one
should be fine with rlm_sqlcounter. If someone needs a patch to work
around the 2GB/4GB limit, I will post the patch.

Regards,

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


Re: sqlcounter returning wrong value?

2008-10-29 Thread liran tal
Thanks for the patch, I have not checked it yet.
What is the status on this issue though? A patch is nice but I'd like to see
support for data counters
to find it's place in the newer version as well as the old one (well, a
backport would be nice. Many of us still have
production systems running 1.1.X)

What still disturbs me is that many of the hotspot forums (coovachilli and
chillispot) has post on how to add an sqlcounter
which performs these data queries successfully and user's feedback is that
everything is good and working. Not that it's
something to count on but I'd guess if somsone had an issue then we'd know
about it...


Regards,
Liran.



2008/10/25 Venkatesh K [EMAIL PROTECTED]

 I have had hard time using sqlcounter for data. It has (at least had)
 limitations for counting data like 2GB limit. I ended up writing my
 own code for counting data.

 Here is a small patch which will skip adding additional quota if
 counter-type=time in sqlcounter.conf file.


 
 diff -u
 ../../../freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c
 rlm_sqlcounter/rlm_sqlcounter.c
 ---
 ../../../freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c
  2007-04-08
 04:51:42.0 +0530
 +++ rlm_sqlcounter/rlm_sqlcounter.c 2008-10-25 22:05:58.0 +0530
 @@ -72,6 +72,7 @@
char *sqlmod_inst;  /* instance of SQL module to use, usually
 just 'sql' */
char *query;/* SQL query to retrieve current session
 time */
char *reset;/* daily, weekly, monthly, never or user
 defined */
 +char *counter_type;/* Type of counter (data / time) */
char *allowed_chars;/* safe characters list for SQL queries */
time_t reset_time;
time_t last_reset;
 @@ -97,6 +98,7 @@
   { sqlmod-inst, PW_TYPE_STRING_PTR,
 offsetof(rlm_sqlcounter_t,sqlmod_inst), NULL, NULL },
   { query, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,query),
 NULL, NULL },
   { reset, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,reset),
 NULL,  NULL },
 +  { counter-type, PW_TYPE_STRING_PTR,
 offsetof(rlm_sqlcounter_t,counter_type), NULL,  NULL },
   { safe-characters, PW_TYPE_STRING_PTR,
 offsetof(rlm_sqlcounter_t,allowed_chars), NULL,
 @abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:
 /},
   { NULL, -1, 0, NULL, NULL }
  };
 @@ -675,10 +677,13 @@
 *  limit, so that the user will not need to
 *  login again
 */
 -   if (data-reset_time  (
 -   res = (data-reset_time - request-timestamp))) {
 -   res = data-reset_time - request-timestamp;
 -   res += check_vp-lvalue;
 +   if(strcmp(data-counter_type,time)==0)
 +   {
 +   if (data-reset_time  (
 +   res = (data-reset_time -
 request-timestamp))) {
 +   res = data-reset_time -
 request-timestamp;
 +   res += check_vp-lvalue;
 +   }
}

if ((reply_item = pairfind(request-reply-vps,
 data-reply_attr)) != NULL) {

 -

 I did compile the code successfully. I have not checked it. Let me
 know if  you have
 any issues.

 Thanks,

 Venkatesh K

 2008/10/25  [EMAIL PROTECTED]:
   And they won't. It's nothing to do with the settings - it's this peace
  of the code.
 
  Let's take your example. Limit was 26MB and about 2MB was left.
  2,000,000 seconds is about 23 days. So this part of the code will kick
  in (there are 6 days left in this month) and returned value will be
  26MB + number of seconds untill 1.11. Run debug twice. You will see that
  the returned value will be reduced by the number of seconds between two
  requests.
 
  Allowance left would have to be well below 1MB for data counter to start
  working properly for monthly reset towards the end of the month, 100KB
  for weekly reset and 10KB for daily. Which is of no practical use.
 
  I don't know when was this part of the code added but data counters
  would work fine without it. I was testing time counter and still
  reproduced this only because limit value was so high (10 million). When
  I reduced it to 10,000 it worked fine.
 
  Ivan Kalik
  Kalik Informatika ISP
 
 
  Dana 25/10/2008, liran tal [EMAIL PROTECTED] piše:
 
 I've actually tested the sqlcounter for a data counter for both weekly
 and
 monthly resets and that doesn't work well either...
 This is odd because people have reported this working so... it is either
 something in the configuration that I'm missing
 or I really don't know what's going on but the counter seem to behave as
 expected.
 
 
 Regards,
 

Re: sqlcounter returning wrong value?

2008-10-29 Thread Venkatesh K
The patch I posted was out of the hat just to skip the routine
which adds additional quota.

We have stopped using rlm_sqlcounter long back as we moved
from radius schema to our own custom schema and patched
the rlm_sql to work with our custom schema.

If you or someone list out what one would like to see in rlm_sql_counter,
I will try to come up with the patch. Back porting to previous versions
of radius should not be a big problem as rlm_sql and rlm_sqlcounter
have't changed much.

Thanks,

Venkatesh K

2008/10/30 liran tal [EMAIL PROTECTED]:

 Thanks for the patch, I have not checked it yet.
 What is the status on this issue though? A patch is nice but I'd like to see
 support for data counters
 to find it's place in the newer version as well as the old one (well, a
 backport would be nice. Many of us still have
 production systems running 1.1.X)

 What still disturbs me is that many of the hotspot forums (coovachilli and
 chillispot) has post on how to add an sqlcounter
 which performs these data queries successfully and user's feedback is that
 everything is good and working. Not that it's
 something to count on but I'd guess if somsone had an issue then we'd know
 about it...


 Regards,
 Liran.


 2008/10/25 Venkatesh K [EMAIL PROTECTED]

 I have had hard time using sqlcounter for data. It has (at least had)
 limitations for counting data like 2GB limit. I ended up writing my
 own code for counting data.

 Here is a small patch which will skip adding additional quota if
 counter-type=time in sqlcounter.conf file.


 
 diff -u
 ../../../freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c
 rlm_sqlcounter/rlm_sqlcounter.c
 ---
 ../../../freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c
  2007-04-08
 04:51:42.0 +0530
 +++ rlm_sqlcounter/rlm_sqlcounter.c 2008-10-25 22:05:58.0
 +0530
 @@ -72,6 +72,7 @@
char *sqlmod_inst;  /* instance of SQL module to use, usually
 just 'sql' */
char *query;/* SQL query to retrieve current session
 time */
char *reset;/* daily, weekly, monthly, never or user
 defined */
 +char *counter_type;/* Type of counter (data / time) */
char *allowed_chars;/* safe characters list for SQL queries */
time_t reset_time;
time_t last_reset;
 @@ -97,6 +98,7 @@
   { sqlmod-inst, PW_TYPE_STRING_PTR,
 offsetof(rlm_sqlcounter_t,sqlmod_inst), NULL, NULL },
   { query, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,query),
 NULL, NULL },
   { reset, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,reset),
 NULL,  NULL },
 +  { counter-type, PW_TYPE_STRING_PTR,
 offsetof(rlm_sqlcounter_t,counter_type), NULL,  NULL },
   { safe-characters, PW_TYPE_STRING_PTR,
 offsetof(rlm_sqlcounter_t,allowed_chars), NULL,
 @abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:
 /},
   { NULL, -1, 0, NULL, NULL }
  };
 @@ -675,10 +677,13 @@
 *  limit, so that the user will not need to
 *  login again
 */
 -   if (data-reset_time  (
 -   res = (data-reset_time - request-timestamp))) {
 -   res = data-reset_time - request-timestamp;
 -   res += check_vp-lvalue;
 +   if(strcmp(data-counter_type,time)==0)
 +   {
 +   if (data-reset_time  (
 +   res = (data-reset_time -
 request-timestamp))) {
 +   res = data-reset_time -
 request-timestamp;
 +   res += check_vp-lvalue;
 +   }
}

if ((reply_item = pairfind(request-reply-vps,
 data-reply_attr)) != NULL) {

 -

 I did compile the code successfully. I have not checked it. Let me
 know if  you have
 any issues.

 Thanks,

 Venkatesh K

 2008/10/25  [EMAIL PROTECTED]:
  And they won't. It's nothing to do with the settings - it's this peace
  of the code.
 
  Let's take your example. Limit was 26MB and about 2MB was left.
  2,000,000 seconds is about 23 days. So this part of the code will kick
  in (there are 6 days left in this month) and returned value will be
  26MB + number of seconds untill 1.11. Run debug twice. You will see that
  the returned value will be reduced by the number of seconds between two
  requests.
 
  Allowance left would have to be well below 1MB for data counter to start
  working properly for monthly reset towards the end of the month, 100KB
  for weekly reset and 10KB for daily. Which is of no practical use.
 
  I don't know when was this part of the code added but data counters
  would work fine without it. I was testing time counter and still
  

Re: sqlcounter returning wrong value?

2008-10-25 Thread tnt
OK. This where the problem comes from:

/*
 *  If we are near a reset then add the next
 *  limit, so that the user will not need to
 *  login again
 */
if (data-reset_time 
(res = (data-reset_time - request-timestamp))) {
res = data-reset_time - request-timestamp;
res += check_vp-vp_integer;
}

(that's rlm_sqlcounter.c line about 710 in 2.0.5)

Sqlcounter was designed for time counters. When your allowance (limit -
time used) is greater than the time left in the period, time left in the
period is added to the limit and sent as reply.

This will create problems for data counters since limit values are much
greater than those for time counters. As a workaround I would suggest
that you comment this out if you are using data counters.

Perhaps there is a case for adding another configuration item to
sqlcounter that would determine what is counted time or data. Then for
data counters this can be skipped or replaced with something like:

if (data-reset_time  (trigger = (data-reset_time -
request-timestamp))) {
 res += check_vp-vp_integer;
}

where trigger would be set to a minute for hourly counter and hour for
daily, weekly and monthly counters. I am sorry but I don't know how to
write a patch.

Ivan Kalik
Kalik Informatika ISP

Dana 24/10/2008, liran tal [EMAIL PROTECTED] piše:

Hey Ivan

2008/10/24 [EMAIL PROTECTED]

 It (daily sqlcounter) does the same in 2.0.5:

 rlm_sqlcounter: Authorized user jagoda, check_item=1000, counter=2635
 rlm_sqlcounter: Sent Reply-Item for user jagoda, Type=Session-Timeout,
 value=10027850

 Returns value that is greater than the limit. I am using noreset
 sqlcounter and that one works fine.


Thanks for confirming this on a more up to date version.
Alan, this smells like a bug (unless we missed something along the way),
should I open up a bug ticket?
And what would be the chances it can be backported to 1.1.7?

Thanks,
Liran.

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


Re: sqlcounter returning wrong value?

2008-10-25 Thread liran tal
I've actually tested the sqlcounter for a data counter for both weekly and
monthly resets and that doesn't work well either...
This is odd because people have reported this working so... it is either
something in the configuration that I'm missing
or I really don't know what's going on but the counter seem to behave as
expected.


Regards,
Liran.

2008/10/25 [EMAIL PROTECTED]

 OK. This where the problem comes from:

/*
 *  If we are near a reset then add the next
 *  limit, so that the user will not need to
 *  login again
 */
if (data-reset_time 
(res = (data-reset_time - request-timestamp))) {
res = data-reset_time - request-timestamp;
res += check_vp-vp_integer;
}

 (that's rlm_sqlcounter.c line about 710 in 2.0.5)

 Sqlcounter was designed for time counters. When your allowance (limit -
 time used) is greater than the time left in the period, time left in the
 period is added to the limit and sent as reply.

 This will create problems for data counters since limit values are much
 greater than those for time counters. As a workaround I would suggest
 that you comment this out if you are using data counters.

 Perhaps there is a case for adding another configuration item to
 sqlcounter that would determine what is counted time or data. Then for
 data counters this can be skipped or replaced with something like:

 if (data-reset_time  (trigger = (data-reset_time -
 request-timestamp))) {
 res += check_vp-vp_integer;
 }

 where trigger would be set to a minute for hourly counter and hour for
 daily, weekly and monthly counters. I am sorry but I don't know how to
 write a patch.

 Ivan Kalik
 Kalik Informatika ISP

 Dana 24/10/2008, liran tal [EMAIL PROTECTED] piše:

 Hey Ivan
 
 2008/10/24 [EMAIL PROTECTED]
 
  It (daily sqlcounter) does the same in 2.0.5:
 
  rlm_sqlcounter: Authorized user jagoda, check_item=1000,
 counter=2635
  rlm_sqlcounter: Sent Reply-Item for user jagoda, Type=Session-Timeout,
  value=10027850
 
  Returns value that is greater than the limit. I am using noreset
  sqlcounter and that one works fine.
 
 
 Thanks for confirming this on a more up to date version.
 Alan, this smells like a bug (unless we missed something along the way),
 should I open up a bug ticket?
 And what would be the chances it can be backported to 1.1.7?
 
 Thanks,
 Liran.

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

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

Re: sqlcounter returning wrong value?

2008-10-25 Thread tnt
And they won't. It's nothing to do with the settings - it's this peace
of the code.

Let's take your example. Limit was 26MB and about 2MB was left.
2,000,000 seconds is about 23 days. So this part of the code will kick
in (there are 6 days left in this month) and returned value will be
26MB + number of seconds untill 1.11. Run debug twice. You will see that
the returned value will be reduced by the number of seconds between two
requests.

Allowance left would have to be well below 1MB for data counter to start
working properly for monthly reset towards the end of the month, 100KB
for weekly reset and 10KB for daily. Which is of no practical use.

I don't know when was this part of the code added but data counters
would work fine without it. I was testing time counter and still
reproduced this only because limit value was so high (10 million). When
I reduced it to 10,000 it worked fine.

Ivan Kalik
Kalik Informatika ISP


Dana 25/10/2008, liran tal [EMAIL PROTECTED] piše:

I've actually tested the sqlcounter for a data counter for both weekly and
monthly resets and that doesn't work well either...
This is odd because people have reported this working so... it is either
something in the configuration that I'm missing
or I really don't know what's going on but the counter seem to behave as
expected.


Regards,
Liran.

2008/10/25 [EMAIL PROTECTED]

 OK. This where the problem comes from:

/*
 *  If we are near a reset then add the next
 *  limit, so that the user will not need to
 *  login again
 */
if (data-reset_time 
(res = (data-reset_time - request-timestamp))) {
res = data-reset_time - request-timestamp;
res += check_vp-vp_integer;
}

 (that's rlm_sqlcounter.c line about 710 in 2.0.5)

 Sqlcounter was designed for time counters. When your allowance (limit -
 time used) is greater than the time left in the period, time left in the
 period is added to the limit and sent as reply.

 This will create problems for data counters since limit values are much
 greater than those for time counters. As a workaround I would suggest
 that you comment this out if you are using data counters.

 Perhaps there is a case for adding another configuration item to
 sqlcounter that would determine what is counted time or data. Then for
 data counters this can be skipped or replaced with something like:

 if (data-reset_time  (trigger = (data-reset_time -
 request-timestamp))) {
 res += check_vp-vp_integer;
 }

 where trigger would be set to a minute for hourly counter and hour for
 daily, weekly and monthly counters. I am sorry but I don't know how to
 write a patch.

 Ivan Kalik
 Kalik Informatika ISP

 Dana 24/10/2008, liran tal [EMAIL PROTECTED] piše:

 Hey Ivan
 
 2008/10/24 [EMAIL PROTECTED]
 
  It (daily sqlcounter) does the same in 2.0.5:
 
  rlm_sqlcounter: Authorized user jagoda, check_item=1000,
 counter=2635
  rlm_sqlcounter: Sent Reply-Item for user jagoda, Type=Session-Timeout,
  value=10027850
 
  Returns value that is greater than the limit. I am using noreset
  sqlcounter and that one works fine.
 
 
 Thanks for confirming this on a more up to date version.
 Alan, this smells like a bug (unless we missed something along the way),
 should I open up a bug ticket?
 And what would be the chances it can be backported to 1.1.7?
 
 Thanks,
 Liran.

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



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


Re: sqlcounter returning wrong value?

2008-10-25 Thread Venkatesh K
I have had hard time using sqlcounter for data. It has (at least had)
limitations for counting data like 2GB limit. I ended up writing my
own code for counting data.

Here is a small patch which will skip adding additional quota if
counter-type=time in sqlcounter.conf file.


diff -u 
../../../freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c
rlm_sqlcounter/rlm_sqlcounter.c
--- ../../../freeradius-1.1.7.orig/src/modules/rlm_sqlcounter/rlm_sqlcounter.c  
2007-04-08
04:51:42.0 +0530
+++ rlm_sqlcounter/rlm_sqlcounter.c 2008-10-25 22:05:58.0 +0530
@@ -72,6 +72,7 @@
char *sqlmod_inst;  /* instance of SQL module to use, usually just 
'sql' */
char *query;/* SQL query to retrieve current session time */
char *reset;/* daily, weekly, monthly, never or user 
defined */
+char *counter_type;/* Type of counter (data / time) */
char *allowed_chars;/* safe characters list for SQL queries */
time_t reset_time;
time_t last_reset;
@@ -97,6 +98,7 @@
   { sqlmod-inst, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,sqlmod_inst), NULL, NULL },
   { query, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,query),
NULL, NULL },
   { reset, PW_TYPE_STRING_PTR, offsetof(rlm_sqlcounter_t,reset),
NULL,  NULL },
+  { counter-type, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,counter_type), NULL,  NULL },
   { safe-characters, PW_TYPE_STRING_PTR,
offsetof(rlm_sqlcounter_t,allowed_chars), NULL,
@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:
/},
   { NULL, -1, 0, NULL, NULL }
 };
@@ -675,10 +677,13 @@
 *  limit, so that the user will not need to
 *  login again
 */
-   if (data-reset_time  (
-   res = (data-reset_time - request-timestamp))) {
-   res = data-reset_time - request-timestamp;
-   res += check_vp-lvalue;
+   if(strcmp(data-counter_type,time)==0)
+   {
+   if (data-reset_time  (
+   res = (data-reset_time - 
request-timestamp))) {
+   res = data-reset_time - request-timestamp;
+   res += check_vp-lvalue;
+   }
}

if ((reply_item = pairfind(request-reply-vps, 
data-reply_attr)) != NULL) {
-

I did compile the code successfully. I have not checked it. Let me
know if  you have
any issues.

Thanks,

Venkatesh K

2008/10/25  [EMAIL PROTECTED]:
 And they won't. It's nothing to do with the settings - it's this peace
 of the code.

 Let's take your example. Limit was 26MB and about 2MB was left.
 2,000,000 seconds is about 23 days. So this part of the code will kick
 in (there are 6 days left in this month) and returned value will be
 26MB + number of seconds untill 1.11. Run debug twice. You will see that
 the returned value will be reduced by the number of seconds between two
 requests.

 Allowance left would have to be well below 1MB for data counter to start
 working properly for monthly reset towards the end of the month, 100KB
 for weekly reset and 10KB for daily. Which is of no practical use.

 I don't know when was this part of the code added but data counters
 would work fine without it. I was testing time counter and still
 reproduced this only because limit value was so high (10 million). When
 I reduced it to 10,000 it worked fine.

 Ivan Kalik
 Kalik Informatika ISP


 Dana 25/10/2008, liran tal [EMAIL PROTECTED] piše:

I've actually tested the sqlcounter for a data counter for both weekly and
monthly resets and that doesn't work well either...
This is odd because people have reported this working so... it is either
something in the configuration that I'm missing
or I really don't know what's going on but the counter seem to behave as
expected.


Regards,
Liran.

2008/10/25 [EMAIL PROTECTED]

 OK. This where the problem comes from:

/*
 *  If we are near a reset then add the next
 *  limit, so that the user will not need to
 *  login again
 */
if (data-reset_time 
(res = (data-reset_time - request-timestamp))) {
res = data-reset_time - request-timestamp;
res += check_vp-vp_integer;
}

 (that's rlm_sqlcounter.c line about 710 in 2.0.5)

 Sqlcounter was designed for time counters. When your allowance (limit -
 time used) is greater than the time left in the period, time left in the
 period is added to the limit and sent as reply.

 This will 

RE: sqlcounter returning wrong value?

2008-10-24 Thread mulianto
hi..i think you should fix this one :

reply-name = ChilliSpot-Max-Total-Octets to :
reply-name = Session-Timeout

try it..
rgds,
Mulianto

http://www.indohotspot.net
Your Hotspot solution
  -Original Message-
  From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of liran tal
  Sent: Friday, October 24, 2008 1:07 AM
  To: FreeRadius users mailing list
  Subject: sqlcounter returning wrong value?



  Hey,

  I'm experimenting with some sqlcounter directives in radiusd.conf and
chilli as the NAS.
  I've defined the following sqlcounter stanza for a daily traffic limit:

  sqlcounter defined in radiusd.conf:
  (the query was corrected as suggested by tnt on a previous thread on the
list, correct me if I got it wrong please)

  sqlcounter counterChilliSpotMaxDailyOctets {
  counter-name = ChilliSpot-Max-Daily-Octets
  check-name = ChilliSpot-Max-Daily-Octets
  reply-name = ChilliSpot-Max-Total-Octets
  sqlmod-inst = sql
  key = User-Name
  reset = daily
  error-msg = Sorry, your maximum traffic usage (download
and upload) has exceed the provided limit
  query = SELECT (SUM(AcctInputOctets + AcctOutputOctets))
FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime  '%b'
  }



  In the authorization phase, I'm seeing the following in debug log:
rlm_sqlcounter: Entering module authorize code
sqlcounter_expand:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
FROM radacct WHERE UserName='%{User-Name}''
radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM
radacct WHERE UserName='tester1''
sqlcounter_expand:  '%{sql:SELECT
(SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
UserName='tester1'}'
radius_xlat: Running registered xlat function of module sql for string
'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
UserName='tester1''
rlm_sql (sql): - sql_xlat
radius_xlat:  'tester1'
rlm_sql (sql): sql_set_user escaped user -- 'tester1'
radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM
radacct WHERE UserName='tester1''
rlm_sql (sql): Reserving sql socket id: 2
rlm_sql (sql): - sql_xlat finished
rlm_sql (sql): Released sql socket id: 2
radius_xlat:  '24004370'
rlm_sqlcounter: (Check item - counter) is greater than zero
rlm_sqlcounter: Authorized user tester1, check_item=26214400,
counter=24004370
rlm_sqlcounter: Sent Reply-Item for user tester1,
Type=ChilliSpot-Max-Total-Octets, value=26239950
  modcall[authorize]: module counterChilliSpotMaxDailyOctets returns
ok for request 0
  The entry in radcheck is as follows:

| 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |
  What happens is that it seems the counter doesn't work as expected. When a
user logs in, performs some traffic usage, logs out and logs in again,
  the replied back attribute for chilli doesn't contain a value which is the
remainder of the traffic usage, but something else.

  According to the radius debug above, if check_item=26214400 and
counter=24004370, how come value=26239950?
  So I'm guessing I'm missing something but I'm too obsessed with the
sqlcounter to notice it. (is the subtractation not a normal decimal action?)

  The FreeRADIUS version used is 1.1.7



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

RE: sqlcounter returning wrong value?

2008-10-24 Thread tnt
No, he wants a data not time counter.

Ivan Kalik
Kalik Informatika ISP


Dana 24/10/2008, mulianto [EMAIL PROTECTED] piše:

hi..i think you should fix this one :

reply-name = ChilliSpot-Max-Total-Octets to :
reply-name = Session-Timeout

try it..
rgds,
Mulianto

http://www.indohotspot.net
Your Hotspot solution
  -Original Message-
  From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of liran tal
  Sent: Friday, October 24, 2008 1:07 AM
  To: FreeRadius users mailing list
  Subject: sqlcounter returning wrong value?



  Hey,

  I'm experimenting with some sqlcounter directives in radiusd.conf and
chilli as the NAS.
  I've defined the following sqlcounter stanza for a daily traffic limit:

  sqlcounter defined in radiusd.conf:
  (the query was corrected as suggested by tnt on a previous thread on the
list, correct me if I got it wrong please)

  sqlcounter counterChilliSpotMaxDailyOctets {
  counter-name = ChilliSpot-Max-Daily-Octets
  check-name = ChilliSpot-Max-Daily-Octets
  reply-name = ChilliSpot-Max-Total-Octets
  sqlmod-inst = sql
  key = User-Name
  reset = daily
  error-msg = Sorry, your maximum traffic usage (download
and upload) has exceed the provided limit
  query = SELECT (SUM(AcctInputOctets + AcctOutputOctets))
FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime  '%b'
  }



  In the authorization phase, I'm seeing the following in debug log:
rlm_sqlcounter: Entering module authorize code
sqlcounter_expand:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
FROM radacct WHERE UserName='%{User-Name}''
radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM
radacct WHERE UserName='tester1''
sqlcounter_expand:  '%{sql:SELECT
(SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
UserName='tester1'}'
radius_xlat: Running registered xlat function of module sql for string
'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
UserName='tester1''
rlm_sql (sql): - sql_xlat
radius_xlat:  'tester1'
rlm_sql (sql): sql_set_user escaped user -- 'tester1'
radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM
radacct WHERE UserName='tester1''
rlm_sql (sql): Reserving sql socket id: 2
rlm_sql (sql): - sql_xlat finished
rlm_sql (sql): Released sql socket id: 2
radius_xlat:  '24004370'
rlm_sqlcounter: (Check item - counter) is greater than zero
rlm_sqlcounter: Authorized user tester1, check_item=26214400,
counter=24004370
rlm_sqlcounter: Sent Reply-Item for user tester1,
Type=ChilliSpot-Max-Total-Octets, value=26239950
  modcall[authorize]: module counterChilliSpotMaxDailyOctets returns
ok for request 0
  The entry in radcheck is as follows:

| 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |
  What happens is that it seems the counter doesn't work as expected. When a
user logs in, performs some traffic usage, logs out and logs in again,
  the replied back attribute for chilli doesn't contain a value which is the
remainder of the traffic usage, but something else.

  According to the radius debug above, if check_item=26214400 and
counter=24004370, how come value=26239950?
  So I'm guessing I'm missing something but I'm too obsessed with the
sqlcounter to notice it. (is the subtractation not a normal decimal action?)

  The FreeRADIUS version used is 1.1.7



  Regards,
  Liran.



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


Re: sqlcounter returning wrong value?

2008-10-24 Thread liran tal
Hey,

2008/10/24 [EMAIL PROTECTED]

 No, he wants a data not time counter.


That's right Evan. Moreover, there is no sense in changing the attribute to
be Session-Timeout when Chilli expects something else.
Any thoughts on this issue?


Thanks,



Dana 24/10/2008, mulianto [EMAIL PROTECTED] piše:


 hi..i think you should fix this one :
 
 reply-name = ChilliSpot-Max-Total-Octets to :
 reply-name = Session-Timeout
 
 try it..
 rgds,
 Mulianto
 
 http://www.indohotspot.net
 Your Hotspot solution
   -Original Message-
   From: [EMAIL PROTECTED]
 [mailto:freeradius-users-bounces+muliantofreeradius-users-bounces%2Bmulianto
 [EMAIL PROTECTED]
 Behalf Of liran tal
   Sent: Friday, October 24, 2008 1:07 AM
   To: FreeRadius users mailing list
   Subject: sqlcounter returning wrong value?
 
 
 
   Hey,
 
   I'm experimenting with some sqlcounter directives in radiusd.conf and
 chilli as the NAS.
   I've defined the following sqlcounter stanza for a daily traffic limit:
 
   sqlcounter defined in radiusd.conf:
   (the query was corrected as suggested by tnt on a previous thread on the
 list, correct me if I got it wrong please)
 
   sqlcounter counterChilliSpotMaxDailyOctets {
   counter-name = ChilliSpot-Max-Daily-Octets
   check-name = ChilliSpot-Max-Daily-Octets
   reply-name = ChilliSpot-Max-Total-Octets
   sqlmod-inst = sql
   key = User-Name
   reset = daily
   error-msg = Sorry, your maximum traffic usage (download
 and upload) has exceed the provided limit
   query = SELECT (SUM(AcctInputOctets +
 AcctOutputOctets))
 FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
 AcctSessionTime  '%b'
   }
 
 
 
   In the authorization phase, I'm seeing the following in debug log:
 rlm_sqlcounter: Entering module authorize code
 sqlcounter_expand:  'SELECT
 (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
 FROM radacct WHERE UserName='%{User-Name}''
 radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
 FROM
 radacct WHERE UserName='tester1''
 sqlcounter_expand:  '%{sql:SELECT
 (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
 UserName='tester1'}'
 radius_xlat: Running registered xlat function of module sql for string
 'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
 UserName='tester1''
 rlm_sql (sql): - sql_xlat
 radius_xlat:  'tester1'
 rlm_sql (sql): sql_set_user escaped user -- 'tester1'
 radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
 FROM
 radacct WHERE UserName='tester1''
 rlm_sql (sql): Reserving sql socket id: 2
 rlm_sql (sql): - sql_xlat finished
 rlm_sql (sql): Released sql socket id: 2
 radius_xlat:  '24004370'
 rlm_sqlcounter: (Check item - counter) is greater than zero
 rlm_sqlcounter: Authorized user tester1, check_item=26214400,
 counter=24004370
 rlm_sqlcounter: Sent Reply-Item for user tester1,
 Type=ChilliSpot-Max-Total-Octets, value=26239950
   modcall[authorize]: module counterChilliSpotMaxDailyOctets returns
 ok for request 0
   The entry in radcheck is as follows:
 
 | 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |
   What happens is that it seems the counter doesn't work as expected. When
 a
 user logs in, performs some traffic usage, logs out and logs in again,
   the replied back attribute for chilli doesn't contain a value which is
 the
 remainder of the traffic usage, but something else.
 
   According to the radius debug above, if check_item=26214400 and
 counter=24004370, how come value=26239950?
   So I'm guessing I'm missing something but I'm too obsessed with the
 sqlcounter to notice it. (is the subtractation not a normal decimal
 action?)
 
   The FreeRADIUS version used is 1.1.7


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

Re: sqlcounter returning wrong value?

2008-10-24 Thread tnt
It (daily sqlcounter) does the same in 2.0.5:

rlm_sqlcounter: Authorized user jagoda, check_item=1000, counter=2635
rlm_sqlcounter: Sent Reply-Item for user jagoda, Type=Session-Timeout,
value=10027850

Returns value that is greater than the limit. I am using noreset
sqlcounter and that one works fine.

Ivan Kalik
Kalik Informatika ISP


Dana 24/10/2008, liran tal [EMAIL PROTECTED] piše:

Hey,

2008/10/24 [EMAIL PROTECTED]

 No, he wants a data not time counter.


That's right Evan. Moreover, there is no sense in changing the attribute to
be Session-Timeout when Chilli expects something else.
Any thoughts on this issue?


Thanks,



Dana 24/10/2008, mulianto [EMAIL PROTECTED] piše:


 hi..i think you should fix this one :
 
 reply-name = ChilliSpot-Max-Total-Octets to :
 reply-name = Session-Timeout
 
 try it..
 rgds,
 Mulianto
 
 http://www.indohotspot.net
 Your Hotspot solution
   -Original Message-
   From: [EMAIL PROTECTED]
 [mailto:freeradius-users-bounces+muliantofreeradius-users-bounces%2Bmulianto
 [EMAIL PROTECTED]
 Behalf Of liran tal
   Sent: Friday, October 24, 2008 1:07 AM
   To: FreeRadius users mailing list
   Subject: sqlcounter returning wrong value?
 
 
 
   Hey,
 
   I'm experimenting with some sqlcounter directives in radiusd.conf and
 chilli as the NAS.
   I've defined the following sqlcounter stanza for a daily traffic limit:
 
   sqlcounter defined in radiusd.conf:
   (the query was corrected as suggested by tnt on a previous thread on the
 list, correct me if I got it wrong please)
 
   sqlcounter counterChilliSpotMaxDailyOctets {
   counter-name = ChilliSpot-Max-Daily-Octets
   check-name = ChilliSpot-Max-Daily-Octets
   reply-name = ChilliSpot-Max-Total-Octets
   sqlmod-inst = sql
   key = User-Name
   reset = daily
   error-msg = Sorry, your maximum traffic usage (download
 and upload) has exceed the provided limit
   query = SELECT (SUM(AcctInputOctets +
 AcctOutputOctets))
 FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
 AcctSessionTime  '%b'
   }
 
 
 
   In the authorization phase, I'm seeing the following in debug log:
 rlm_sqlcounter: Entering module authorize code
 sqlcounter_expand:  'SELECT
 (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
 FROM radacct WHERE UserName='%{User-Name}''
 radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
 FROM
 radacct WHERE UserName='tester1''
 sqlcounter_expand:  '%{sql:SELECT
 (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
 UserName='tester1'}'
 radius_xlat: Running registered xlat function of module sql for string
 'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
 UserName='tester1''
 rlm_sql (sql): - sql_xlat
 radius_xlat:  'tester1'
 rlm_sql (sql): sql_set_user escaped user -- 'tester1'
 radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
 FROM
 radacct WHERE UserName='tester1''
 rlm_sql (sql): Reserving sql socket id: 2
 rlm_sql (sql): - sql_xlat finished
 rlm_sql (sql): Released sql socket id: 2
 radius_xlat:  '24004370'
 rlm_sqlcounter: (Check item - counter) is greater than zero
 rlm_sqlcounter: Authorized user tester1, check_item=26214400,
 counter=24004370
 rlm_sqlcounter: Sent Reply-Item for user tester1,
 Type=ChilliSpot-Max-Total-Octets, value=26239950
   modcall[authorize]: module counterChilliSpotMaxDailyOctets returns
 ok for request 0
   The entry in radcheck is as follows:
 
 | 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |
   What happens is that it seems the counter doesn't work as expected. When
 a
 user logs in, performs some traffic usage, logs out and logs in again,
   the replied back attribute for chilli doesn't contain a value which is
 the
 remainder of the traffic usage, but something else.
 
   According to the radius debug above, if check_item=26214400 and
 counter=24004370, how come value=26239950?
   So I'm guessing I'm missing something but I'm too obsessed with the
 sqlcounter to notice it. (is the subtractation not a normal decimal
 action?)
 
   The FreeRADIUS version used is 1.1.7




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


Re: sqlcounter returning wrong value?

2008-10-24 Thread liran tal
Hey Ivan

2008/10/24 [EMAIL PROTECTED]

 It (daily sqlcounter) does the same in 2.0.5:

 rlm_sqlcounter: Authorized user jagoda, check_item=1000, counter=2635
 rlm_sqlcounter: Sent Reply-Item for user jagoda, Type=Session-Timeout,
 value=10027850

 Returns value that is greater than the limit. I am using noreset
 sqlcounter and that one works fine.


Thanks for confirming this on a more up to date version.
Alan, this smells like a bug (unless we missed something along the way),
should I open up a bug ticket?
And what would be the chances it can be backported to 1.1.7?

Thanks,
Liran.






 Dana 24/10/2008, liran tal [EMAIL PROTECTED] piše:

 Hey,
 
 2008/10/24 [EMAIL PROTECTED]
 
  No, he wants a data not time counter.
 
 
 That's right Evan. Moreover, there is no sense in changing the attribute
 to
 be Session-Timeout when Chilli expects something else.
 Any thoughts on this issue?
 
 
 Thanks,
 
 
 
 Dana 24/10/2008, mulianto [EMAIL PROTECTED] piše:
 
 
  hi..i think you should fix this one :
  
  reply-name = ChilliSpot-Max-Total-Octets to :
  reply-name = Session-Timeout
  
  try it..
  rgds,
  Mulianto
  
  http://www.indohotspot.net
  Your Hotspot solution
-Original Message-
From: freeradius-users-bounces+mulianto=cni.co.id@
 lists.freeradius.org
   
 [mailto:freeradius-users-bounces+muliantofreeradius-users-bounces%2Bmulianto
 freeradius-users-bounces%2Bmulianto
  [EMAIL PROTECTED]
  Behalf Of liran tal
Sent: Friday, October 24, 2008 1:07 AM
To: FreeRadius users mailing list
Subject: sqlcounter returning wrong value?
  
  
  
Hey,
  
I'm experimenting with some sqlcounter directives in radiusd.conf and
  chilli as the NAS.
I've defined the following sqlcounter stanza for a daily traffic
 limit:
  
sqlcounter defined in radiusd.conf:
(the query was corrected as suggested by tnt on a previous thread on
 the
  list, correct me if I got it wrong please)
  
sqlcounter counterChilliSpotMaxDailyOctets {
counter-name = ChilliSpot-Max-Daily-Octets
check-name = ChilliSpot-Max-Daily-Octets
reply-name = ChilliSpot-Max-Total-Octets
sqlmod-inst = sql
key = User-Name
reset = daily
error-msg = Sorry, your maximum traffic usage
 (download
  and upload) has exceed the provided limit
query = SELECT (SUM(AcctInputOctets +
  AcctOutputOctets))
  FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) +
  AcctSessionTime  '%b'
}
  
  
  
In the authorization phase, I'm seeing the following in debug log:
  rlm_sqlcounter: Entering module authorize code
  sqlcounter_expand:  'SELECT
  (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
  FROM radacct WHERE UserName='%{User-Name}''
  radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
  FROM
  radacct WHERE UserName='tester1''
  sqlcounter_expand:  '%{sql:SELECT
  (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
  UserName='tester1'}'
  radius_xlat: Running registered xlat function of module sql for
 string
  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE
  UserName='tester1''
  rlm_sql (sql): - sql_xlat
  radius_xlat:  'tester1'
  rlm_sql (sql): sql_set_user escaped user -- 'tester1'
  radius_xlat:  'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets))
  FROM
  radacct WHERE UserName='tester1''
  rlm_sql (sql): Reserving sql socket id: 2
  rlm_sql (sql): - sql_xlat finished
  rlm_sql (sql): Released sql socket id: 2
  radius_xlat:  '24004370'
  rlm_sqlcounter: (Check item - counter) is greater than zero
  rlm_sqlcounter: Authorized user tester1, check_item=26214400,
  counter=24004370
  rlm_sqlcounter: Sent Reply-Item for user tester1,
  Type=ChilliSpot-Max-Total-Octets, value=26239950
modcall[authorize]: module counterChilliSpotMaxDailyOctets
 returns
  ok for request 0
The entry in radcheck is as follows:
  
  | 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |
What happens is that it seems the counter doesn't work as expected.
 When
  a
  user logs in, performs some traffic usage, logs out and logs in again,
the replied back attribute for chilli doesn't contain a value which
 is
  the
  remainder of the traffic usage, but something else.
  
According to the radius debug above, if check_item=26214400 and
  counter=24004370, how come value=26239950?
So I'm guessing I'm missing something but I'm too obsessed with the
  sqlcounter to notice it. (is the subtractation not a normal decimal
  action?)
  
The FreeRADIUS version used is 1.1.7
 
 
 

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

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