Logo Search packages:      
Sourcecode: libnl version File versions  Download package

int nl_sendmsg ( struct nl_handle *  handle,
struct nl_msg *  msg,
struct msghdr *  hdr 
)

Send netlink message with control over sendmsg() message header.

  • handle Netlink handle.
  • msg Netlink message to be sent.
  • hdr Sendmsg() message header.
    Returns:
    Number of characters sent on sucess or a negative error code.

Definition at line 290 of file nl.c.

References NL_CB_MSG_OUT, NL_OK, nlmsg_hdr(), and nlmsghdr::nlmsg_len.

Referenced by nl_send().

{
      struct nl_cb *cb;
      int ret;

      struct iovec iov = {
            .iov_base = (void *) nlmsg_hdr(msg),
            .iov_len = nlmsg_hdr(msg)->nlmsg_len,
      };

      hdr->msg_iov = &iov;
      hdr->msg_iovlen = 1;

      nlmsg_set_src(msg, &handle->h_local);

      cb = handle->h_cb;
      if (cb->cb_set[NL_CB_MSG_OUT])
            if (nl_cb_call(cb, NL_CB_MSG_OUT, msg) != NL_OK)
                  return 0;

      ret = sendmsg(handle->h_fd, hdr, 0);
      if (ret < 0)
            return nl_errno(errno);

      return ret;
}


Generated by  Doxygen 1.6.0   Back to index