From 12be733cb9b36cc6ba2f6dda9662ae66e1a707b5 Mon Sep 17 00:00:00 2001 From: Kozlov Dmitry Date: Tue, 31 May 2011 13:12:39 +0400 Subject: radius: Acct-Delay-Time attribute becomes optional and disabled by default --- accel-pppd/radius/acct.c | 43 +++++++++++++++++++++++++++---------------- accel-pppd/radius/radius.c | 13 +++++++++---- accel-pppd/radius/radius_p.h | 1 + 3 files changed, 37 insertions(+), 20 deletions(-) (limited to 'accel-pppd/radius') 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; -- cgit v1.2.3