def nlmsg_put(n, pid, seq, type_, payload, flags):
if n.nm_nlh.nlmsg_len < libnl.linux_private.netlink.NLMSG_HDRLEN:<EOL><INDENT>raise BUG<EOL><DEDENT>nlh = n.nm_nlh<EOL>nlh.nlmsg_type = type_<EOL>nlh.nlmsg_flags = flags<EOL>nlh.nlmsg_pid = pid<EOL>nlh.nlmsg_seq = seq<EOL>_LOGGER.debug('<STR_LIT>', id(n), type_, flags, pid, seq)<EOL>if payload > <NUM_LIT:0> and nlmsg_reserve(n, payload, libnl.linux_private.netlink.NLMSG_ALIGNTO) is None:<EOL><INDENT>return None<EOL><DEDENT>return nlh<EOL>
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.