/* do a netlink command and, if max > 0, fetch the reply ; nh's size >1024B */
static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max)
{
- struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK };
- socklen_t addr_len;
void *data = nh;
int rem, ret;
int err = 0;
}
nh->nlmsg_len = len;
- ret = sendto(fd, data, len, 0, (void *)&nladdr, sizeof(nladdr));
+ ret = send(fd, data, len, 0);
if (ret != len)
error(1, errno, "send netlink: %uB != %uB\n", ret, len);
- addr_len = sizeof(nladdr);
- rem = ret = recvfrom(fd, data, max, 0, (void *)&nladdr, &addr_len);
+ ret = recv(fd, data, max, 0);
if (ret < 0)
error(1, errno, "recv netlink: %uB\n", ret);
+ rem = ret;
/* Beware: the NLMSG_NEXT macro updates the 'rem' argument */
for (; NLMSG_OK(nh, rem); nh = NLMSG_NEXT(nh, rem)) {
if (nh->nlmsg_type == NLMSG_DONE)