def nl_send_simple(sk, type_, flags, buf=None, size=0):
    """Construct and transmit a Netlink message.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L549

    Allocates a new Netlink message based on `type_` and `flags`. If `buf` points to payload of length `size` that
    payload will be appended to the message.

    Sends out the message using `nl_send_auto()`.

    Positional arguments:
    sk -- Netlink socket (nl_sock class instance).
    type_ -- Netlink message type (integer).
    flags -- Netlink message flags (integer).

    Keyword arguments:
    buf -- payload data.
    size -- size of `data` (integer).

    Returns:
    Number of characters sent on success or a negative error code.
    """
    msg = nlmsg_alloc_simple(type_, flags)
    if buf is not None and size:
        err = nlmsg_append(msg, buf, size, NLMSG_ALIGNTO)
        if err < 0:
            return err
    return nl_send_auto(sk, msg)