diff options
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r-- | accel-pppd/radius/acct.c | 22 | ||||
-rw-r--r-- | accel-pppd/radius/radius.c | 14 | ||||
-rw-r--r-- | accel-pppd/radius/radius_p.h | 2 |
3 files changed, 36 insertions, 2 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index 3d194474..9292fdaa 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -147,13 +147,15 @@ static void rad_acct_timeout(struct triton_timer_t *t) static void rad_acct_interim_update(struct triton_timer_t *t) { struct radius_pd_t *rpd = container_of(t, typeof(*rpd), acct_interim_timer); + struct ap_session *ses = rpd->ses; struct timespec ts; + int force = 0; if (rpd->acct_req->entry.next || rpd->acct_req->timeout.tpd) return; if (rpd->session_timeout.expire_tv.tv_sec && - rpd->session_timeout.expire_tv.tv_sec - (_time() - rpd->ses->start_time) < INTERIM_SAFE_TIME) + rpd->session_timeout.expire_tv.tv_sec - (_time() - ses->start_time) < INTERIM_SAFE_TIME) return; if (req_set_stat(rpd->acct_req, rpd->ses)) { @@ -161,7 +163,15 @@ static void rad_acct_interim_update(struct triton_timer_t *t) return; } - if (!rpd->acct_interim_interval) + if (ses->ipv6_dp && !rpd->ipv6_dp_sent) { + struct ipv6db_addr_t *a; + list_for_each_entry(a, &ses->ipv6_dp->prefix_list, entry) + rad_packet_add_ipv6prefix(rpd->acct_req->pack, NULL, "Delegated-IPv6-Prefix", &a->addr, a->prefix_len); + rpd->ipv6_dp_sent = 1; + force = 1; + } + + if (!rpd->acct_interim_interval && !force) return; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -180,6 +190,14 @@ static void rad_acct_interim_update(struct triton_timer_t *t) } } +void rad_acct_force_interim_update(struct radius_pd_t *rpd) +{ + if (!rpd->acct_req) + return; + + rad_acct_interim_update(&rpd->acct_interim_timer); +} + static int rad_acct_before_send(struct rad_req_t *req) { struct timespec ts; diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index 24ca20a3..c8eaf953 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -520,6 +520,19 @@ static void ses_finished(struct ap_session *ses) release_pd(rpd); } +static void force_interim_update(struct ap_session *ses) +{ + struct radius_pd_t *rpd = find_pd(ses); + + if (ses->terminating) + return; + + if (!rpd) + return; + + rad_acct_force_interim_update(rpd); +} + struct radius_pd_t *find_pd(struct ap_session *ses) { struct ap_private *pd; @@ -806,6 +819,7 @@ static void radius_init(void) triton_event_register_handler(EV_SES_ACCT_START, (triton_event_func)ses_acct_start); triton_event_register_handler(EV_SES_FINISHING, (triton_event_func)ses_finishing); triton_event_register_handler(EV_SES_FINISHED, (triton_event_func)ses_finished); + triton_event_register_handler(EV_FORCE_INTERIM_UPDATE, (triton_event_func)force_interim_update); triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); } diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index 0e1789fd..24cfdbd8 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -41,6 +41,7 @@ struct radius_pd_t { int authenticated:1; int acct_started:1; int ipv6_dp_assigned:1; + int ipv6_dp_sent:1; struct rad_req_t *acct_req; struct triton_timer_t acct_interim_timer; @@ -202,6 +203,7 @@ int rad_auth_null(struct radius_pd_t *rpd, const char *username, va_list args); int rad_acct_start(struct radius_pd_t *rpd); int rad_acct_stop(struct radius_pd_t *rpd); void rad_acct_stop_defer(struct radius_pd_t *rpd); +void rad_acct_force_interim_update(struct radius_pd_t *rpd); struct rad_packet_t *rad_packet_alloc(int code); int rad_packet_build(struct rad_packet_t *pack, uint8_t *RA); |