summaryrefslogtreecommitdiff
path: root/accel-pppd/libnetlink/iputils.c
diff options
context:
space:
mode:
authorMichael Furmur <m.furmur@gmail.com>2016-08-30 13:45:24 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-11-12 10:35:48 +0300
commitaaedc70f5ef82bbc8c711dcd5f1e5913bc2118d0 (patch)
tree328775e320a71cb9246c74aea357193e71ed7dac /accel-pppd/libnetlink/iputils.c
parent938d3e852f8ef51f9f284e13e3a79c2f501f6d74 (diff)
downloadaccel-ppp-aaedc70f5ef82bbc8c711dcd5f1e5913bc2118d0.tar.gz
accel-ppp-aaedc70f5ef82bbc8c711dcd5f1e5913bc2118d0.zip
ipoe: add support for peer-to-peer client interfaces
Diffstat (limited to 'accel-pppd/libnetlink/iputils.c')
-rw-r--r--accel-pppd/libnetlink/iputils.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index 7a29d08..8bcee50 100644
--- a/accel-pppd/libnetlink/iputils.c
+++ b/accel-pppd/libnetlink/iputils.c
@@ -329,6 +329,39 @@ 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)
+{
+ 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 | NLM_F_CREATE;
+ req.n.nlmsg_type = RTM_NEWADDR;
+ req.i.ifa_family = AF_INET;
+ req.i.ifa_index = ifindex;
+ req.i.ifa_prefixlen = mask;
+
+ addattr32(&req.n, sizeof(req), IFA_LOCAL, addr);
+ addattr32(&req.n, sizeof(req), IFA_ADDRESS, peer_addr);
+
+ if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0)
+ r = -1;
+
+ net->rtnl_put(rth);
+
+ return r;
+}
+
int __export ipaddr_del(int ifindex, in_addr_t addr, int mask)
{
struct ipaddr_req {