diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-10-29 20:57:59 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-10-29 20:57:59 +0300 |
commit | 4492abfd6b7a410d24fdc488545efd64a22c05b8 (patch) | |
tree | b65fdc433e4c36253174f4248c14e5c75619fad0 /accel-pppd/ctrl | |
parent | 5ea15c8f7be55992cb874d38d8c7c17280448d82 (diff) | |
download | accel-ppp-4492abfd6b7a410d24fdc488545efd64a22c05b8.tar.gz accel-ppp-4492abfd6b7a410d24fdc488545efd64a22c05b8.zip |
ipoe: implemneted ability to send L4 redirect table/L4 redirect ipset via radius attributes
Introduced following options:
attr-l4-redirect-table (type integer)
attr-l4-redirect-ipset (type string)
Please note, to enable L4 redirect attr-l4-redirect must be specified and sent
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 31 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.h | 2 |
2 files changed, 25 insertions, 8 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index a32b87a..a4809b0 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -117,6 +117,8 @@ static int conf_attr_dhcp_router_ip; static int conf_attr_dhcp_mask; static int conf_attr_dhcp_lease_time; static int conf_attr_l4_redirect; +static int conf_attr_l4_redirect_table; +static int conf_attr_l4_redirect_ipset; static const char *conf_attr_dhcp_opt82; #endif static int conf_l4_redirect_table; @@ -442,22 +444,22 @@ static void ipoe_change_l4_redirect(struct ipoe_session *ses, int del) else addr = ses->yiaddr; - if (conf_l4_redirect_table) { + if (ses->l4_redirect_table) { if (del) { - iprule_del(addr, conf_l4_redirect_table); + iprule_del(addr, ses->l4_redirect_table); ses->l4_redirect_set = 0; } else { - iprule_add(addr, conf_l4_redirect_table); + iprule_add(addr, ses->l4_redirect_table); ses->l4_redirect_set = 1; } } - if (conf_l4_redirect_ipset) { + if (conf_l4_redirect_ipset || ses->l4_redirect_ipset) { if (del) { - ipset_del(conf_l4_redirect_ipset, addr); + ipset_del(ses->l4_redirect_ipset ?: conf_l4_redirect_ipset, addr); ses->l4_redirect_set = 0; } else { - ipset_add(conf_l4_redirect_ipset, addr); + ipset_add(ses->l4_redirect_ipset ?: conf_l4_redirect_ipset, addr); ses->l4_redirect_set = 1; } } @@ -1049,6 +1051,9 @@ static void ipoe_session_free(struct ipoe_session *ses) if (ses->ctrl.calling_station_id) _free(ses->ctrl.calling_station_id); + + if (ses->l4_redirect_ipset) + _free(ses->l4_redirect_ipset); triton_context_unregister(&ses->ctx); @@ -1772,6 +1777,7 @@ struct ipoe_session *ipoe_session_alloc(void) ses->ctrl.terminate = ipoe_session_terminate; ses->ctrl.type = CTRL_TYPE_IPOE; ses->ctrl.name = "ipoe"; + ses->l4_redirect_table = conf_l4_redirect_table; ses->ses.ctrl = &ses->ctrl; @@ -1838,6 +1844,12 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) ses->l4_redirect = 1; } else if (attr->attr->id == conf_attr_dhcp_lease_time) ses->lease_time = attr->val.integer; + else if (attr->attr->id == conf_attr_l4_redirect_table) + ses->l4_redirect_table = attr->val.integer; + else if (attr->attr->id == conf_attr_l4_redirect_ipset) { + if (attr->attr->type == ATTR_TYPE_STRING) + ses->l4_redirect_ipset = _strdup(attr->val.string); + } } } @@ -2657,6 +2669,8 @@ static void parse_conf_rad_attr(const char *opt, int *val) struct rad_dict_attr_t *attr; opt = conf_get_opt("ipoe", opt); + + *val = 0; if (opt) { if (atoi(opt) > 0) @@ -2668,8 +2682,7 @@ static void parse_conf_rad_attr(const char *opt, int *val) else log_emerg("ipoe: couldn't find '%s' in dictionary\n", opt); } - } else - *val = -1; + } } static void load_radius_attrs(void) @@ -2679,6 +2692,8 @@ static void load_radius_attrs(void) parse_conf_rad_attr("attr-dhcp-mask", &conf_attr_dhcp_mask); parse_conf_rad_attr("attr-dhcp-lease-time", &conf_attr_dhcp_lease_time); parse_conf_rad_attr("attr-l4-redirect", &conf_attr_l4_redirect); + parse_conf_rad_attr("attr-l4-redirect-table", &conf_attr_l4_redirect_table); + parse_conf_rad_attr("attr-l4-redirect-ipset", &conf_attr_l4_redirect_ipset); conf_attr_dhcp_opt82 = conf_get_opt("ipoe", "attr-dhcp-opt82"); } #endif diff --git a/accel-pppd/ctrl/ipoe/ipoe.h b/accel-pppd/ctrl/ipoe/ipoe.h index 555d314..72da499 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.h +++ b/accel-pppd/ctrl/ipoe/ipoe.h @@ -74,6 +74,8 @@ struct ipoe_session { uint32_t siaddr; uint32_t router; uint32_t relay_server_id; + int l4_redirect_table; + char *l4_redirect_ipset; int mask; int lease_time; uint8_t *data; |