提交 928aefd7 编写于 作者: D Dmitry Kozlov

ipoe: implemented support for vendor specific attrbiutes

introduced new config option:
[ipoe]
vendor=Name

this affects to all attributes specified in attr-xxx options
上级 a596ef53
......@@ -126,6 +126,7 @@ start=dhcpv4
#nat=0
#proto=100
#relay=10.10.10.10
#vendor=Custom
#attr-dhcp-client-ip=DHCP-Client-IP-Address
#attr-dhcp-router-ip=DHCP-Router-IP-Address
#attr-dhcp-mask=DHCP-Mask
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册