Netlink Message Flags Translations.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L664

    Positional arguments:
    flags -- integer.
    buf -- bytearray().

    Keyword arguments:
    _ -- unused.

    Returns:
    Reference to `buf`.

def nl_nlmsg_flags2str(flags, buf, _=None):
    """Netlink Message Flags Translations.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L664

    Positional arguments:
    flags -- integer.
    buf -- bytearray().

    Keyword arguments:
    _ -- unused.

    Returns:
    Reference to `buf`.
    """
    del buf[:]
    all_flags = (
        ('REQUEST', libnl.linux_private.netlink.NLM_F_REQUEST),
        ('MULTI', libnl.linux_private.netlink.NLM_F_MULTI),
        ('ACK', libnl.linux_private.netlink.NLM_F_ACK),
        ('ECHO', libnl.linux_private.netlink.NLM_F_ECHO),
        ('ROOT', libnl.linux_private.netlink.NLM_F_ROOT),
        ('MATCH', libnl.linux_private.netlink.NLM_F_MATCH),
        ('ATOMIC', libnl.linux_private.netlink.NLM_F_ATOMIC),
        ('REPLACE', libnl.linux_private.netlink.NLM_F_REPLACE),
        ('EXCL', libnl.linux_private.netlink.NLM_F_EXCL),
        ('CREATE', libnl.linux_private.netlink.NLM_F_CREATE),
        ('APPEND', libnl.linux_private.netlink.NLM_F_APPEND),
    )
    print_flags = []
    for k, v in all_flags:
        if not flags & v:
            continue
        flags &= ~v
        print_flags.append(k)
    if flags:
        print_flags.append('0x{0:x}'.format(flags))
    buf.extend(','.join(print_flags).encode('ascii'))
    return buf