diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2017-05-08 23:37:12 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2017-05-08 23:37:12 +0300 |
commit | 928aefd7779593961beca41376dd829c26d58de5 (patch) | |
tree | 53ac9725b56d93bdda289b275adcca7094181300 /accel-pppd/ctrl | |
parent | a596ef53a689f0ecbf24d0043a4ad571cc8a4bf3 (diff) | |
download | accel-ppp-928aefd7779593961beca41376dd829c26d58de5.tar.gz accel-ppp-928aefd7779593961beca41376dd829c26d58de5.zip |
ipoe: implemented support for vendor specific attrbiutes
introduced new config option:
[ipoe]
vendor=Name
this affects to all attributes specified in attr-xxx options
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 7ac9f64a..09d0a5df 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -125,6 +125,7 @@ static const char *conf_password; static int conf_unit_cache; static int conf_noauth; #ifdef RADIUS +static int conf_vendor; static int conf_attr_dhcp_client_ip; static int conf_attr_dhcp_router_ip; static int conf_attr_dhcp_mask; @@ -2121,6 +2122,11 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) return; list_for_each_entry(attr, &ev->reply->attrs, entry) { + int vendor_id = attr->vendor ? attr->vendor->id : 0; + + if (conf_vendor != vendor_id) + continue; + if (attr->attr->id == conf_attr_dhcp_client_ip) ses->yiaddr = attr->val.ipaddr; else if (attr->attr->id == conf_attr_dhcp_router_ip) @@ -2198,6 +2204,11 @@ static void ev_radius_coa(struct ev_radius_t *ev) l4_redirect = ses->l4_redirect; list_for_each_entry(attr, &ev->request->attrs, entry) { + int vendor_id = attr->vendor ? attr->vendor->id : 0; + + if (conf_vendor != vendor_id) + continue; + if (attr->attr->id == conf_attr_l4_redirect) { if (attr->attr->type == ATTR_TYPE_STRING) l4_redirect = attr->len && attr->val.string[0] != '0'; @@ -3114,25 +3125,43 @@ static void parse_conf_rad_attr(const char *opt, int *val) { struct rad_dict_attr_t *attr; + *val = 0; + opt = conf_get_opt("ipoe", opt); + if (!opt) + return; - *val = 0; + if (conf_vendor) { + struct rad_dict_vendor_t *vendor = rad_dict_find_vendor_id(conf_vendor); + attr = rad_dict_find_vendor_attr(vendor, opt); + } else + attr = rad_dict_find_attr(opt); - if (opt) { - if (atoi(opt) > 0) - *val = atoi(opt); - else { - attr = rad_dict_find_attr(opt); - if (attr) - *val = attr->id; - else - log_emerg("ipoe: couldn't find '%s' in dictionary\n", opt); - } - } + if (attr) + *val = attr->id; + else if (atoi(opt) > 0) + *val = atoi(opt); + else + log_emerg("ipoe: couldn't find '%s' in dictionary\n", opt); } static void load_radius_attrs(void) { + const char *vendor = conf_get_opt("ipoe", "vendor"); + + if (vendor) { + struct rad_dict_vendor_t *v = rad_dict_find_vendor_name(vendor); + if (v) + conf_vendor = v->id; + else { + conf_vendor = atoi(vendor); + if (!rad_dict_find_vendor_id(conf_vendor)) { + conf_vendor = 0; + log_emerg("ipoe: vendor '%s' not found\n", vendor); + } + } + } + parse_conf_rad_attr("attr-dhcp-client-ip", &conf_attr_dhcp_client_ip); parse_conf_rad_attr("attr-dhcp-router-ip", &conf_attr_dhcp_router_ip); parse_conf_rad_attr("attr-dhcp-mask", &conf_attr_dhcp_mask); |