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

struct nlmsghdr* nlmsg_put ( struct nl_msg *  n,
uint32_t  pid,
uint32_t  seq,
int  type,
int  payload,
int  flags 
) [read]

Add a netlink message header to a netlink message

  • n netlink message
  • pid netlink process id or NL_AUTO_PID
  • seq sequence number of message or NL_AUTO_SEQ
  • type message type
  • payload length of message payload
  • flags message flags
Adds or overwrites the netlink message header in an existing message object. If payload is greater-than zero additional room will be reserved, f.e. for family specific headers. It can be accesed via nlmsg_data().

A pointer to the netlink message header or NULL.

Definition at line 611 of file msg.c.

References nlmsghdr::nlmsg_flags, nlmsghdr::nlmsg_pid, nlmsg_reserve(), nlmsghdr::nlmsg_seq, and nlmsghdr::nlmsg_type.

Referenced by genlmsg_put(), and nfnlmsg_put().

      struct nlmsghdr *nlh;

      if (n->nm_nlh->nlmsg_len < NLMSG_HDRLEN)

      nlh = (struct nlmsghdr *) n->nm_nlh;
      nlh->nlmsg_type = type;
      nlh->nlmsg_flags = flags;
      nlh->nlmsg_pid = pid;
      nlh->nlmsg_seq = seq;

      NL_DBG(2, "msg %p: Added netlink header type=%d, flags=%d, pid=%d, "
              "seq=%d\n", n, type, flags, pid, seq);

      if (payload > 0 &&
          nlmsg_reserve(n, payload, NLMSG_ALIGNTO) == NULL)
            return NULL;

      return nlh;

Generated by  Doxygen 1.6.0   Back to index