summaryrefslogtreecommitdiff
path: root/accel-pppd/libnetlink/iputils.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2015-11-18 18:43:30 +0300
committerDmitry Kozlov <xeb@mail.ru>2015-11-18 18:43:30 +0300
commitdecb3de44c59f789e49250c4d2791e4219078b54 (patch)
tree27c80ce7be931a4372e13bbdb253d059dabef2e5 /accel-pppd/libnetlink/iputils.c
parent1e505332a84bef2857f07155f0c188742303be76 (diff)
downloadaccel-ppp-decb3de44c59f789e49250c4d2791e4219078b54.tar.gz
accel-ppp-decb3de44c59f789e49250c4d2791e4219078b54.zip
ipoe: for vlan name pattern implemented %P argument - VID of parent interface
Diffstat (limited to 'accel-pppd/libnetlink/iputils.c')
-rw-r--r--accel-pppd/libnetlink/iputils.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index 480f028f..7dbdf677 100644
--- a/accel-pppd/libnetlink/iputils.c
+++ b/accel-pppd/libnetlink/iputils.c
@@ -243,6 +243,60 @@ int __export iplink_vlan_del(int ifindex)
return 0;
}
+int __export iplink_vlan_get_vid(int ifindex)
+{
+ struct iplink_req {
+ struct nlmsghdr n;
+ struct ifinfomsg i;
+ char buf[4096];
+ } req;
+ struct ifinfomsg *ifi;
+ int len;
+ struct rtattr *tb[IFLA_MAX + 1];
+
+ if (!rth)
+ open_rth();
+
+ if (!rth)
+ return -1;
+
+ memset(&req, 0, sizeof(req) - 4096);
+
+ req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+ req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ req.n.nlmsg_type = RTM_GETLINK;
+ req.i.ifi_family = AF_PACKET;
+ req.i.ifi_index = ifindex;
+
+ if (rtnl_talk(rth, &req.n, 0, 0, &req.n, NULL, NULL, 0) < 0)
+ return -1;
+
+ if (req.n.nlmsg_type != RTM_NEWLINK)
+ return -1;
+
+ ifi = NLMSG_DATA(&req.n);
+
+ len = req.n.nlmsg_len;
+
+ len -= NLMSG_LENGTH(sizeof(*ifi));
+ if (len < 0)
+ return -1;
+
+ parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
+
+ if (!tb[IFLA_LINKINFO])
+ return 0;
+
+ parse_rtattr_nested(tb, IFLA_MAX, tb[IFLA_LINKINFO]);
+
+ if (strcmp(RTA_DATA(tb[IFLA_INFO_KIND]), "vlan"))
+ return 0;
+
+ parse_rtattr_nested(tb, IFLA_MAX, tb[IFLA_INFO_DATA]);
+ return *(uint16_t *)RTA_DATA(tb[IFLA_VLAN_ID]);
+}
+
+
int __export ipaddr_add(int ifindex, in_addr_t addr, int mask)
{
struct ipaddr_req {