summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2017-04-04 11:59:23 +0300
committerDmitry Kozlov <xeb@mail.ru>2017-04-04 11:59:23 +0300
commit974f6a33e3983880051470d1676745fd136f5d61 (patch)
tree11ea2ad27f98e0a194fb953d5f43bf65444319bd /accel-pppd/ctrl/ipoe
parent82dd32fa8a99596243f07971c97343878c5ef674 (diff)
downloadaccel-ppp-974f6a33e3983880051470d1676745fd136f5d61.tar.gz
accel-ppp-974f6a33e3983880051470d1676745fd136f5d61.zip
ipoe: implemented ability to change ipset by CoA
For this need to send 2 attributes: L4-Redirect=1,L4-Redirect-Ipset=new-set
Diffstat (limited to 'accel-pppd/ctrl/ipoe')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 6834071..62c06f0 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -2179,8 +2179,9 @@ static void ev_radius_coa(struct ev_radius_t *ev)
{
struct ipoe_session *ses = container_of(ev->ses, typeof(*ses), ses);
struct rad_attr_t *attr;
- int l4_redirect;
+ int l4_redirect = -1;
int lease_time_set = 0, renew_time_set = 0;
+ char *ipset = NULL;
if (ev->ses->ctrl->type != CTRL_TYPE_IPOE)
return;
@@ -2190,9 +2191,9 @@ static void ev_radius_coa(struct ev_radius_t *ev)
list_for_each_entry(attr, &ev->request->attrs, entry) {
if (attr->attr->id == conf_attr_l4_redirect) {
if (attr->attr->type == ATTR_TYPE_STRING)
- ses->l4_redirect = attr->len && attr->val.string[0] != '0';
+ l4_redirect = attr->len && attr->val.string[0] != '0';
else
- ses->l4_redirect = ((unsigned int)attr->val.integer) > 0;
+ l4_redirect = ((unsigned int)attr->val.integer) > 0;
} else if (strcmp(attr->attr->name, "Framed-IP-Address") == 0) {
if (ses->ses.ipv4 && ses->ses.ipv4->peer_addr != attr->val.ipaddr)
ipoe_change_addr(ses, attr->val.ipaddr);
@@ -2206,10 +2207,8 @@ static void ev_radius_coa(struct ev_radius_t *ev)
ses->l4_redirect_table = attr->val.integer;
else if (attr->attr->id == conf_attr_l4_redirect_ipset) {
if (attr->attr->type == ATTR_TYPE_STRING) {
- if (ses->l4_redirect_ipset && strcmp(ses->l4_redirect_ipset, attr->val.string)) {
- _free(ses->l4_redirect_ipset);
- ses->l4_redirect_ipset = _strdup(attr->val.string);
- }
+ if (!ses->l4_redirect_ipset || strcmp(ses->l4_redirect_ipset, attr->val.string))
+ ipset = attr->val.string;
}
}
}
@@ -2221,9 +2220,23 @@ static void ev_radius_coa(struct ev_radius_t *ev)
ses->renew_time = ses->lease_time / 2;
}
- //if (l4_redirect && !ses->l4_redirect) || (!l4_redirect && ses->l4_redirect))
- if (l4_redirect != ses->l4_redirect && ev->ses->state == AP_STATE_ACTIVE)
- ipoe_change_l4_redirect(ses, l4_redirect);
+ if (l4_redirect >= 0 && ev->ses->state == AP_STATE_ACTIVE) {
+ if (ses->l4_redirect && l4_redirect && ipset) {
+ ipoe_change_l4_redirect(ses, 1);
+ ses->l4_redirect = 0;
+ }
+
+ if (ipset) {
+ if (ses->l4_redirect_ipset)
+ _free(ses->l4_redirect_ipset);
+ ses->l4_redirect_ipset = _strdup(ipset);
+ }
+
+ if (l4_redirect != ses->l4_redirect ) {
+ ipoe_change_l4_redirect(ses, l4_redirect == 0);
+ ses->l4_redirect = l4_redirect;
+ }
+ }
}
static int ipoe_rad_send_acct_request(struct rad_plugin_t *rad, struct rad_packet_t *pack)