libnetlink: change rtnl_send() to take void *

Avoid having to cast buffer being sent.
This commit is contained in:
Stephen Hemminger 2011-12-23 10:40:04 -08:00
parent 3c7950af59
commit 6cf8398f5f
5 changed files with 8 additions and 11 deletions

View File

@ -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_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");
goto ctrl_done;
}

View File

@ -47,8 +47,8 @@ extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned groups, struct nlmsghdr *answer,
rtnl_filter_t junk,
void *jarg);
extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
extern int rtnl_send_check(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 void *buf, int);
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);

View File

@ -164,7 +164,7 @@ static int iplink_have_newlink(void)
req.n.nlmsg_type = RTM_NEWLINK;
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);
}
return have_rtnl_newlink;

View 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;

View File

@ -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_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)