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

int nl_send ( struct nl_sock *  sk,
struct nl_msg *  msg 

Send netlink message.

  • sk Netlink socket.
  • msg Netlink message to be sent.
    See also:
    Number of characters sent on success or a negative error code.

Definition at line 240 of file nl.c.

References sockaddr_nl::nl_family, and nl_sendmsg().

Referenced by nl_send_auto_complete().

      struct sockaddr_nl *dst;
      struct ucred *creds;
      struct msghdr hdr = {
            .msg_name = (void *) &sk->s_peer,
            .msg_namelen = sizeof(struct sockaddr_nl),

      /* Overwrite destination if specified in the message itself, defaults
       * to the peer address of the socket.
      dst = nlmsg_get_dst(msg);
      if (dst->nl_family == AF_NETLINK)
            hdr.msg_name = dst;

      /* Add credentials if present. */
      creds = nlmsg_get_creds(msg);
      if (creds != NULL) {
            char buf[CMSG_SPACE(sizeof(struct ucred))];
            struct cmsghdr *cmsg;

            hdr.msg_control = buf;
            hdr.msg_controllen = sizeof(buf);

            cmsg = CMSG_FIRSTHDR(&hdr);
            cmsg->cmsg_level = SOL_SOCKET;
            cmsg->cmsg_type = SCM_CREDENTIALS;
            cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
            memcpy(CMSG_DATA(cmsg), creds, sizeof(struct ucred));

      return nl_sendmsg(sk, msg, &hdr);

Generated by  Doxygen 1.6.0   Back to index