diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-07-13 12:26:06 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-07-13 12:26:06 +0400 |
commit | 178b27b0b6d60afdc5039dc3d995f4ad000b5486 (patch) | |
tree | c62192e3d18b50f1796c094451b75324f08e08dc /accel-pppd/radius/dm_coa.c | |
parent | 7e81417530acd05125a485b7d586b0b322e26706 (diff) | |
download | accel-ppp-178b27b0b6d60afdc5039dc3d995f4ad000b5486.tar.gz accel-ppp-178b27b0b6d60afdc5039dc3d995f4ad000b5486.zip |
radius: update Class attribute by CoA request
Diffstat (limited to 'accel-pppd/radius/dm_coa.c')
-rw-r--r-- | accel-pppd/radius/dm_coa.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/accel-pppd/radius/dm_coa.c b/accel-pppd/radius/dm_coa.c index f6197e7c..b96f3e0c 100644 --- a/accel-pppd/radius/dm_coa.c +++ b/accel-pppd/radius/dm_coa.c @@ -145,6 +145,8 @@ static void disconnect_request(struct radius_pd_t *rpd) static void coa_request(struct radius_pd_t *rpd) { + struct rad_attr_t *class; + void *prev_class; struct ev_radius_t ev = { .ppp = rpd->ppp, .request = rpd->dm_coa_req, @@ -159,8 +161,30 @@ static void coa_request(struct radius_pd_t *rpd) if (ev.res) dm_coa_send_nak(serv.hnd.fd, rpd->dm_coa_req, &rpd->dm_coa_addr, 0); - else + else { + class = rad_packet_find_attr(rpd->dm_coa_req, NULL, "Class"); + if (class) { + prev_class = rpd->attr_class; + + if (rpd->attr_class_len < class->len) { + if (rpd->attr_class) + _free(rpd->attr_class); + rpd->attr_class = _malloc(class->len); + } + + memcpy(rpd->attr_class, class->val.octets, class->len); + rpd->attr_class_len = class->len; + } + + if (rpd->acct_req && rpd->acct_req->pack) { + if (prev_class) + rad_packet_change_octets(rpd->acct_req->pack, NULL, "Class", rpd->attr_class, rpd->attr_class_len); + else + rad_packet_add_octets(rpd->acct_req->pack, NULL, "Class", rpd->attr_class, rpd->attr_class_len); + } + dm_coa_send_ack(serv.hnd.fd, rpd->dm_coa_req, &rpd->dm_coa_addr); + } rad_packet_free(rpd->dm_coa_req); |