Commit 6cf8398f authored by Stephen Hemminger's avatar Stephen Hemminger

libnetlink: change rtnl_send() to take void *

Avoid having to cast buffer being sent.
parent 3c7950af
...@@ -350,7 +350,7 @@ static int ctrl_list(int cmd, int argc, char **argv) ...@@ -350,7 +350,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
nlh->nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; nlh->nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
nlh->nlmsg_seq = rth.dump = ++rth.seq; nlh->nlmsg_seq = rth.dump = ++rth.seq;
if (rtnl_send(&rth, (const char *) nlh, nlh->nlmsg_len) < 0) { if (rtnl_send(&rth, nlh, nlh->nlmsg_len) < 0) {
perror("Failed to send dump request\n"); perror("Failed to send dump request\n");
goto ctrl_done; goto ctrl_done;
} }
......
...@@ -47,8 +47,8 @@ extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, ...@@ -47,8 +47,8 @@ extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned groups, struct nlmsghdr *answer, unsigned groups, struct nlmsghdr *answer,
rtnl_filter_t junk, rtnl_filter_t junk,
void *jarg); void *jarg);
extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int); extern int rtnl_send(struct rtnl_handle *rth, const void *buf, int);
extern int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int); extern int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int);
extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data); extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen); extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen);
......
...@@ -164,7 +164,7 @@ static int iplink_have_newlink(void) ...@@ -164,7 +164,7 @@ static int iplink_have_newlink(void)
req.n.nlmsg_type = RTM_NEWLINK; req.n.nlmsg_type = RTM_NEWLINK;
req.i.ifi_family = AF_UNSPEC; req.i.ifi_family = AF_UNSPEC;
rtnl_send(&rth, (char *)&req.n, req.n.nlmsg_len); rtnl_send(&rth, &req.n, req.n.nlmsg_len);
rtnl_listen(&rth, accept_msg, NULL); rtnl_listen(&rth, accept_msg, NULL);
} }
return have_rtnl_newlink; return have_rtnl_newlink;
......
...@@ -107,12 +107,12 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) ...@@ -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); 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); 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; struct nlmsghdr *h;
int status; int status;
...@@ -148,7 +148,7 @@ int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len) ...@@ -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) int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
{ {
struct nlmsghdr nlh; struct nlmsghdr nlh;
struct sockaddr_nl nladdr; struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK };
struct iovec iov[2] = { struct iovec iov[2] = {
{ .iov_base = &nlh, .iov_len = sizeof(nlh) }, { .iov_base = &nlh, .iov_len = sizeof(nlh) },
{ .iov_base = req, .iov_len = len } { .iov_base = req, .iov_len = len }
...@@ -160,9 +160,6 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) ...@@ -160,9 +160,6 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
.msg_iovlen = 2, .msg_iovlen = 2,
}; };
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
nlh.nlmsg_len = NLMSG_LENGTH(len); nlh.nlmsg_len = NLMSG_LENGTH(len);
nlh.nlmsg_type = type; nlh.nlmsg_type = type;
nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
......
...@@ -281,7 +281,7 @@ int respond_to_kernel(int ifindex, __u32 addr, char *lla, int llalen) ...@@ -281,7 +281,7 @@ int respond_to_kernel(int ifindex, __u32 addr, char *lla, int llalen)
addattr_l(&req.n, sizeof(req), NDA_DST, &addr, 4); addattr_l(&req.n, sizeof(req), NDA_DST, &addr, 4);
addattr_l(&req.n, sizeof(req), NDA_LLADDR, lla, llalen); addattr_l(&req.n, sizeof(req), NDA_LLADDR, lla, llalen);
return rtnl_send(&rth, (char*)&req, req.n.nlmsg_len) <= 0; return rtnl_send(&rth, &req, req.n.nlmsg_len) <= 0;
} }
void prepare_neg_entry(__u8 *ndata, __u32 stamp) void prepare_neg_entry(__u8 *ndata, __u32 stamp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment