diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-05-12 17:44:20 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-05-12 17:44:20 +0400 |
commit | c0cf8924783347c4f4b4faccba88247f3cd6accd (patch) | |
tree | 8ba9631e36d54fc7da8d644a879b2af1b9820c1e | |
parent | d0fa7ad6fb1d0ace4c292c7084ff1752ef5c45b7 (diff) | |
download | accel-ppp-c0cf8924783347c4f4b4faccba88247f3cd6accd.tar.gz accel-ppp-c0cf8924783347c4f4b4faccba88247f3cd6accd.zip |
radius: use NAS-Port-Id in Access-Accept for interface renaming
-rw-r--r-- | accel-pppd/ifcfg.c | 25 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 1 | ||||
-rw-r--r-- | accel-pppd/radius/radius.c | 4 |
3 files changed, 30 insertions, 0 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c index ea1ac2f9..bbbcc02d 100644 --- a/accel-pppd/ifcfg.c +++ b/accel-pppd/ifcfg.c @@ -230,3 +230,28 @@ void __export ap_session_ifdown(struct ap_session *ses) } } +void __export ap_session_rename(struct ap_session *ses, const char *ifname, int len) +{ + struct ifreq ifr; + + if (len == -1) + len = strlen(ifname); + + if (len >= IFNAMSIZ - 1) { + log_ppp_warn("cannot rename interface (name it too long)\n"); + return; + } + + ifr.ifr_ifindex = ses->ifindex; + strcpy(ifr.ifr_name, ses->ifname); + memcpy(ifr.ifr_newname, ifname, len); + ifr.ifr_newname[len] = 0; + + if (ioctl(sock_fd, SIOCSIFNAME, &ifr)) + log_ppp_warn("interface rename failed: %s\n", strerror(errno)); + else { + memcpy(ses->ifname, ifname, len); + ses->ifname[len] = 0; + } +} + diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index ecbac53f..86a777c2 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -128,6 +128,7 @@ int ap_session_check_single(const char *username); void ap_session_ifup(struct ap_session *ses); void ap_session_ifdown(struct ap_session *ses); +void ap_session_rename(struct ap_session *ses, const char *ifname, int len); int ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats *stats); diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index d6d7de07..26e59bad 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -142,11 +142,15 @@ int rad_proc_attrs(struct rad_req_t *req) a->addr = attr->val.ipv6prefix.prefix; list_add_tail(&a->entry, &req->rpd->ipv6_dp.prefix_list); break; + case NAS_Port_Id: + ap_session_rename(req->rpd->ses, attr->val.string, attr->len); + break; } } if (dns.ses) triton_event_fire(EV_DNS, &dns); + if (wins.ses) triton_event_fire(EV_WINS, &wins); |