]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blobdiff - lib/libnetlink.c
libnetlink: change rtnl_send() to take void *
[lisovros/iproute2_canprio.git] / lib / libnetlink.c
index ee4f045a06e75c7676575bd03d1a00d3cb02158c..7c29985c541ad8d4d216644af42c398feda52fb5 100644 (file)
@@ -107,12 +107,12 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
        return send(rth->fd, (void*)&req, sizeof(req), 0);
 }
 
-int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
+int rtnl_send(struct rtnl_handle *rth, const void *buf, int len)
 {
        return send(rth->fd, buf, len, 0);
 }
 
-int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)
+int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len)
 {
        struct nlmsghdr *h;
        int status;
@@ -148,7 +148,7 @@ int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)
 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
 {
        struct nlmsghdr nlh;
-       struct sockaddr_nl nladdr;
+       struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK };
        struct iovec iov[2] = {
                { .iov_base = &nlh, .iov_len = sizeof(nlh) },
                { .iov_base = req, .iov_len = len }
@@ -160,9 +160,6 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
                .msg_iovlen = 2,
        };
 
-       memset(&nladdr, 0, sizeof(nladdr));
-       nladdr.nl_family = AF_NETLINK;
-
        nlh.nlmsg_len = NLMSG_LENGTH(len);
        nlh.nlmsg_type = type;
        nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
@@ -493,7 +490,7 @@ int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler,
        nladdr.nl_groups = 0;
 
        while (1) {
-               int err, len, type;
+               int err, len;
                int l;
 
                status = fread(&buf, 1, sizeof(*h), rtnl);
@@ -508,7 +505,6 @@ int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler,
                        return 0;
 
                len = h->nlmsg_len;
-               type= h->nlmsg_type;
                l = len - sizeof(*h);
 
                if (l<0 || len>sizeof(buf)) {