From 98274bdf7a1f7c0ec250de263298cc6954645e22 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Sun, 19 Mar 2017 17:00:45 +0300 Subject: radius: introduced radius_plugin_t:send_accounting_update function (called each time when accounting interim update is about to send) --- accel-pppd/radius/acct.c | 14 ++++++++++++++ accel-pppd/radius/radius.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'accel-pppd') diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index 9292fdaa..c58a2b97 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -150,6 +150,7 @@ static void rad_acct_interim_update(struct triton_timer_t *t) struct ap_session *ses = rpd->ses; struct timespec ts; int force = 0; + struct rad_plugin_t *plugin; if (rpd->acct_req->entry.next || rpd->acct_req->timeout.tpd) return; @@ -171,6 +172,11 @@ static void rad_acct_interim_update(struct triton_timer_t *t) force = 1; } + list_for_each_entry(plugin, &rpd->plugin_list, entry) { + if (plugin->send_accounting_update) + plugin->send_accounting_update(plugin, rpd->acct_req->pack); + } + if (!rpd->acct_interim_interval && !force) return; @@ -430,6 +436,7 @@ int rad_acct_stop(struct radius_pd_t *rpd) { struct rad_req_t *req = rpd->acct_req; struct timespec ts; + struct rad_plugin_t *plugin; if (rpd->acct_interim_timer.tpd) triton_timer_del(&rpd->acct_interim_timer); @@ -486,7 +493,14 @@ int rad_acct_stop(struct radius_pd_t *rpd) } rad_packet_change_val(req->pack, NULL, "Acct-Status-Type", "Stop"); + req_set_stat(req, rpd->ses); + + list_for_each_entry(plugin, &rpd->plugin_list, entry) { + if (plugin->send_accounting_update) + plugin->send_accounting_update(plugin, rpd->acct_req->pack); + } + req_set_RA(req, req->serv->secret); req->recv = rad_acct_stop_recv; diff --git a/accel-pppd/radius/radius.h b/accel-pppd/radius/radius.h index ad27b898..aaa6269f 100644 --- a/accel-pppd/radius/radius.h +++ b/accel-pppd/radius/radius.h @@ -100,6 +100,7 @@ struct rad_plugin_t struct list_head entry; int (*send_access_request)(struct rad_plugin_t *, struct rad_packet_t *pack); int (*send_accounting_request)(struct rad_plugin_t *, struct rad_packet_t *pack); + int (*send_accounting_update)(struct rad_plugin_t *, struct rad_packet_t *pack); }; struct ap_session; @@ -122,6 +123,7 @@ int rad_packet_add_octets(struct rad_packet_t *pack, const char *vendor, const c int rad_packet_change_int(struct rad_packet_t *pack, const char *vendor, const char *name, int val); int rad_packet_change_val(struct rad_packet_t *pack, const char *vendor, const char *name, const char *val); int rad_packet_change_octets(struct rad_packet_t *pack, const char *vendor, const char *name, const uint8_t *val, int len); +int rad_packet_change_str(struct rad_packet_t *pack, const char *vendor_name, const char *name, const char *val, int len); int rad_packet_add_ipaddr(struct rad_packet_t *pack, const char *vendor, const char *name, in_addr_t ipaddr); int rad_packet_add_ifid(struct rad_packet_t *pack, const char *vendor, const char *name, uint64_t ifid); int rad_packet_add_ipv6prefix(struct rad_packet_t *pack, const char *vendor, const char *name, struct in6_addr *prefix, int len); -- cgit v1.2.3