diff options
author | Kozlov Dmitry <dima@server> | 2011-05-31 13:12:39 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2011-05-31 13:12:39 +0400 |
commit | 12be733cb9b36cc6ba2f6dda9662ae66e1a707b5 (patch) | |
tree | 894ed113ffb80a6f76f2a9acb67deaa54fd255f7 /accel-pppd | |
parent | 4497c1bae58e5920a250df95abb959d4b3d980b4 (diff) | |
download | accel-ppp-12be733cb9b36cc6ba2f6dda9662ae66e1a707b5.tar.gz accel-ppp-12be733cb9b36cc6ba2f6dda9662ae66e1a707b5.zip |
radius: Acct-Delay-Time attribute becomes optional and disabled by default
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/accel-ppp.conf | 1 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 3 | ||||
-rw-r--r-- | accel-pppd/radius/acct.c | 43 | ||||
-rw-r--r-- | accel-pppd/radius/radius.c | 13 | ||||
-rw-r--r-- | accel-pppd/radius/radius_p.h | 1 |
5 files changed, 41 insertions, 20 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 1f3e7f89..c1bace8c 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -74,6 +74,7 @@ verbose=1 #timeout=3 #max-try=3 #acct-timeout=120 +#acct-delay-time=0 [client-ip-range] 10.0.0.0/8 diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 1c120784..eadb5bc9 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -291,6 +291,9 @@ Specifies number of tries to send Access-Request/Accounting-Request queries. .BI "acct-timeout=" n Specifies timeout of accounting interim update. .TP +.BI "acct-delay-time=" 0|1 +Specifies whether radius client should include Acct-Delay-Time attribute to accounting requests (default 0). +.TP .SH [log] .br Configuration of log and log_file modules. diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index 2c12d2a1..31ab298f 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -144,10 +144,12 @@ static void rad_acct_timeout(struct triton_timer_t *t) } } - req->pack->id++; - - rad_packet_change_int(req->pack, NULL, "Acct-Delay-Time", dt); - req_set_RA(req, conf_acct_secret); + if (conf_acct_delay_time) { + req->pack->id++; + rad_packet_change_int(req->pack, NULL, "Acct-Delay-Time", dt); + req_set_RA(req, conf_acct_secret); + } + rad_req_send(req, conf_interim_verbose); __sync_add_and_fetch(&stat_interim_sent, 1); } @@ -171,12 +173,13 @@ static void rad_acct_interim_update(struct triton_timer_t *t) rpd->acct_req->pack->id++; rad_packet_change_val(rpd->acct_req->pack, NULL, "Acct-Status-Type", "Interim-Update"); - rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", 0); + if (conf_acct_delay_time) + rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", 0); req_set_RA(rpd->acct_req, conf_acct_secret); rad_req_send(rpd->acct_req, conf_interim_verbose); __sync_add_and_fetch(&stat_interim_sent, 1); if (conf_acct_timeout) { - rpd->acct_req->timeout.period = conf_acct_timeout * 1000; + rpd->acct_req->timeout.period = conf_timeout * 1000; triton_timer_add(rpd->ppp->ctrl->ctx, &rpd->acct_req->timeout, 0); } } @@ -213,17 +216,23 @@ int rad_acct_start(struct radius_pd_t *rpd) time(&rpd->acct_timestamp); + if (req_set_RA(rpd->acct_req, conf_acct_secret)) + goto out_err; + for (i = 0; i < conf_max_try; i++) { - time(&ts); - rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", ts - rpd->acct_timestamp); - if (req_set_RA(rpd->acct_req, conf_acct_secret)) - goto out_err; + if (conf_acct_delay_time) { + time(&ts); + rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", ts - rpd->acct_timestamp); + if (req_set_RA(rpd->acct_req, conf_acct_secret)) + goto out_err; + } if (rad_req_send(rpd->acct_req, conf_verbose)) goto out_err; __sync_add_and_fetch(&stat_acct_sent, 1); rad_req_wait(rpd->acct_req, conf_timeout); if (!rpd->acct_req->reply) { - rpd->acct_req->pack->id++; + if (conf_acct_delay_time) + rpd->acct_req->pack->id++; __sync_add_and_fetch(&stat_acct_lost, 1); stat_accm_add(stat_acct_lost_1m, 1); stat_accm_add(stat_acct_lost_5m, 1); @@ -332,11 +341,13 @@ void rad_acct_stop(struct radius_pd_t *rpd) time(&rpd->acct_timestamp); for(i = 0; i < conf_max_try; i++) { - time(&ts); - rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", ts - rpd->acct_timestamp); - rpd->acct_req->pack->id++; - if (req_set_RA(rpd->acct_req, conf_acct_secret)) - break; + if (conf_acct_delay_time) { + time(&ts); + rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", ts - rpd->acct_timestamp); + rpd->acct_req->pack->id++; + if (req_set_RA(rpd->acct_req, conf_acct_secret)) + break; + } if (rad_req_send(rpd->acct_req, conf_verbose)) break; __sync_add_and_fetch(&stat_acct_sent, 1); diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index d3f1248a..5663af99 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -26,6 +26,7 @@ int conf_max_try = 3; int conf_timeout = 3; int conf_acct_timeout = 3; +int conf_acct_delay_time; char *conf_nas_identifier; in_addr_t conf_nas_ip_address; in_addr_t conf_gw_ip_address; @@ -521,17 +522,21 @@ static int load_config(void) } opt = conf_get_opt("radius", "sid_in_auth"); - if (opt && atoi(opt) > 0) - conf_sid_in_auth = 1; + if (opt) + conf_sid_in_auth = atoi(opt); opt = conf_get_opt("radius", "require-nas-identification"); - if (opt && atoi(opt) > 0) - conf_require_nas_ident = 1; + if (opt) + conf_require_nas_ident = atoi(opt); opt = conf_get_opt("radius", "acct-interim-interval"); if (opt && atoi(opt) > 0) conf_acct_interim_interval = atoi(opt); + opt = conf_get_opt("radius", "acct-delay-time"); + if (opt) + conf_acct_delay_time = atoi(opt); + return 0; } diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index 32acd497..929fe8e6 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -62,6 +62,7 @@ struct rad_req_t extern int conf_max_try; extern int conf_timeout; extern int conf_acct_timeout; +extern int conf_acct_delay_time; extern int conf_verbose; extern int conf_interim_verbose; extern char *conf_nas_identifier; |