summaryrefslogtreecommitdiff
path: root/accel-pppd/ifcfg.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2018-05-25 10:38:02 +0300
committerDmitry Kozlov <xeb@mail.ru>2018-05-25 10:38:02 +0300
commit969ba07f29a93180a0a8a6e94dc4205a5b6cf531 (patch)
treef20fa1fdd2706aad69b8772962a21b4a3e92b0bb /accel-pppd/ifcfg.c
parent4e39b82b126bcee5b19f482a0f5048b25692abb3 (diff)
downloadaccel-ppp-969ba07f29a93180a0a8a6e94dc4205a5b6cf531.tar.gz
accel-ppp-969ba07f29a93180a0a8a6e94dc4205a5b6cf531.zip
ifcfg: assign address using ipaddr_add_peer instead SIOCSIFADDR/SIOCSIFDSTADDR
Diffstat (limited to 'accel-pppd/ifcfg.c')
-rw-r--r--accel-pppd/ifcfg.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index 109751a0..3035e13c 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -74,7 +74,6 @@ void __export ap_session_accounting_started(struct ap_session *ses)
//struct rtentry rt;
struct in6_ifreq ifr6;
struct npioctl np;
- struct sockaddr_in addr;
struct ppp_t *ppp;
if (ses->stop_time)
@@ -105,37 +104,8 @@ void __export ap_session_accounting_started(struct ap_session *ses)
if (!ses->backup || !ses->backup->internal) {
#endif
if (ses->ipv4) {
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = ses->ipv4->addr;
- memcpy(&ifr.ifr_addr, &addr, sizeof(addr));
-
- if (net->sock_ioctl(SIOCSIFADDR, &ifr))
+ if (ipaddr_add_peer(ses->ifindex, ses->ipv4->addr, ses->ipv4->peer_addr, ses->ipv4->mask ?: 32))
log_ppp_error("failed to set IPv4 address: %s\n", strerror(errno));
-
- /*if (ses->ctrl->type == CTRL_TYPE_IPOE) {
- addr.sin_addr.s_addr = 0xffffffff;
- memcpy(&ifr.ifr_netmask, &addr, sizeof(addr));
- if (ioctl(sock_fd, SIOCSIFNETMASK, &ifr))
- log_ppp_error("failed to set IPv4 nask: %s\n", strerror(errno));
- }*/
-
- addr.sin_addr.s_addr = ses->ipv4->peer_addr;
-
- /*if (ses->ctrl->type == CTRL_TYPE_IPOE) {
- memset(&rt, 0, sizeof(rt));
- memcpy(&rt.rt_dst, &addr, sizeof(addr));
- rt.rt_flags = RTF_HOST | RTF_UP;
- rt.rt_metric = 1;
- rt.rt_dev = ifr.ifr_name;
- if (ioctl(sock_fd, SIOCADDRT, &rt, sizeof(rt)))
- log_ppp_error("failed to add route: %s\n", strerror(errno));
- } else*/ {
- memcpy(&ifr.ifr_dstaddr, &addr, sizeof(addr));
-
- if (net->sock_ioctl(SIOCSIFDSTADDR, &ifr))
- log_ppp_error("failed to set peer IPv4 address: %s\n", strerror(errno));
- }
}
if (ses->ipv6) {