diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2016-12-08 18:12:23 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2016-12-08 18:19:01 +0300 |
commit | fc33b4c6ec83533d35db3626887fb5156478bca3 (patch) | |
tree | 86c67ea62ed87c000149ef6fe703ba53283966a3 /accel-pppd/libnetlink/iputils.c | |
parent | be063e68bbbba46048215a8fdfccf511af45c490 (diff) | |
download | accel-ppp-fc33b4c6ec83533d35db3626887fb5156478bca3.tar.gz accel-ppp-fc33b4c6ec83533d35db3626887fb5156478bca3.zip |
ipoe: fixed nat support
Diffstat (limited to 'accel-pppd/libnetlink/iputils.c')
-rw-r--r-- | accel-pppd/libnetlink/iputils.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c index 8bcee50d..1052b609 100644 --- a/accel-pppd/libnetlink/iputils.c +++ b/accel-pppd/libnetlink/iputils.c @@ -329,7 +329,7 @@ int __export ipaddr_add(int ifindex, in_addr_t addr, int mask) return r; } -int __export ipaddr_add_peer(int ifindex, in_addr_t addr, int mask, in_addr_t peer_addr) +int __export ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr) { struct ipaddr_req { struct nlmsghdr n; @@ -349,7 +349,7 @@ int __export ipaddr_add_peer(int ifindex, in_addr_t addr, int mask, in_addr_t pe req.n.nlmsg_type = RTM_NEWADDR; req.i.ifa_family = AF_INET; req.i.ifa_index = ifindex; - req.i.ifa_prefixlen = mask; + req.i.ifa_prefixlen = 32; addattr32(&req.n, sizeof(req), IFA_LOCAL, addr); addattr32(&req.n, sizeof(req), IFA_ADDRESS, peer_addr); @@ -394,6 +394,39 @@ int __export ipaddr_del(int ifindex, in_addr_t addr, int mask) return r; } +int __export ipaddr_del_peer(int ifindex, in_addr_t addr, in_addr_t peer) +{ + struct ipaddr_req { + struct nlmsghdr n; + struct ifaddrmsg i; + char buf[4096]; + } req; + struct rtnl_handle *rth = net->rtnl_get(); + int r = 0; + + if (!rth) + return -1; + + memset(&req, 0, sizeof(req) - 4096); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = RTM_DELADDR; + req.i.ifa_family = AF_INET; + req.i.ifa_index = ifindex; + req.i.ifa_prefixlen = 32; + + addattr32(&req.n, sizeof(req), IFA_LOCAL, addr); + addattr32(&req.n, sizeof(req), IFA_ADDRESS, peer); + + if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) + r = -1; + + net->rtnl_put(rth); + + return r; +} + int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto, int mask) { struct ipaddr_req { |