]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/libnetlink.c
ip address: Set device index in dump request
[mirror_iproute2.git] / lib / libnetlink.c
index 56a1cadeb3db5dfb445c6f33d6b5307e7bd1fa2a..0ddd646a87758113843be12185f962485f88925e 100644 (file)
@@ -234,11 +234,13 @@ int rtnl_open(struct rtnl_handle *rth, unsigned int subscriptions)
        return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE);
 }
 
-int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
+int rtnl_addrdump_req(struct rtnl_handle *rth, int family,
+                     req_filter_fn_t filter_fn)
 {
        struct {
                struct nlmsghdr nlh;
                struct ifaddrmsg ifm;
+               char buf[128];
        } req = {
                .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
                .nlh.nlmsg_type = RTM_GETADDR,
@@ -247,6 +249,14 @@ int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
                .ifm.ifa_family = family,
        };
 
+       if (filter_fn) {
+               int err;
+
+               err = filter_fn(&req.nlh, sizeof(req));
+               if (err)
+                       return err;
+       }
+
        return send(rth->fd, &req, sizeof(req), 0);
 }