summaryrefslogtreecommitdiff
path: root/accel-pppd/libnetlink
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-12-08 18:12:23 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-12-08 18:19:01 +0300
commitfc33b4c6ec83533d35db3626887fb5156478bca3 (patch)
tree86c67ea62ed87c000149ef6fe703ba53283966a3 /accel-pppd/libnetlink
parentbe063e68bbbba46048215a8fdfccf511af45c490 (diff)
downloadaccel-ppp-fc33b4c6ec83533d35db3626887fb5156478bca3.tar.gz
accel-ppp-fc33b4c6ec83533d35db3626887fb5156478bca3.zip
ipoe: fixed nat support
Diffstat (limited to 'accel-pppd/libnetlink')
-rw-r--r--accel-pppd/libnetlink/iputils.c37
-rw-r--r--accel-pppd/libnetlink/iputils.h3
2 files changed, 37 insertions, 3 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 {
diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h
index a623197f..301cfed1 100644
--- a/accel-pppd/libnetlink/iputils.h
+++ b/accel-pppd/libnetlink/iputils.h
@@ -13,8 +13,9 @@ int iplink_vlan_del(int ifindex);
int iplink_vlan_get_vid(int ifindex, int *iflink);
int ipaddr_add(int ifindex, in_addr_t addr, int mask);
-int ipaddr_add_peer(int ifindex, in_addr_t addr, int mask, in_addr_t peer_addr);
+int ipaddr_add_peer(int ifindex, in_addr_t addr, in_addr_t peer_addr);
int ipaddr_del(int ifindex, in_addr_t addr, int mask);
+int ipaddr_del_peer(int ifindex, in_addr_t addr, in_addr_t peer);
int iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto, int mask);
int iproute_del(int ifindex, in_addr_t dst, int proto, int mask);