code: def nlmsg_put(n, pid, seq, type_, payload, flags):
      
      if n.nm_nlh.nlmsg_len < libnl.linux_private.netlink.NLMSG_HDRLEN:
          raise BUG
  
      nlh = n.nm_nlh
      nlh.nlmsg_type = type_
      nlh.nlmsg_flags = flags
      nlh.nlmsg_pid = pid
      nlh.nlmsg_seq = seq
  
      _LOGGER.debug('msg 0x%x: Added netlink header type=%d, flags=%d, pid=%d, seq=%d', id(n), type_, flags, pid, seq)
  
      if payload > 0 and nlmsg_reserve(n, payload, libnl.linux_private.netlink.NLMSG_ALIGNTO) is None:
          return None
  
      return nlh
docs: Add a Netlink message header to a Netlink message.
  
      https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L503
  
      Adds or overwrites the Netlink message header in an existing message object.
  
      Positional arguments:
      n -- Netlink message (nl_msg class instance).
      pid -- Netlink process id or NL_AUTO_PID (c_uint32).
      seq -- sequence number of message or NL_AUTO_SEQ (c_uint32).
      type_ -- message type (integer).
      payload -- length of message payload (integer).
      flags -- message flags (integer).
  
      Returns:
      nlmsghdr class instance or None.