def print_genl_msg(_, ofd, hdr, ops, payloadlen):
    """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L831.

    Positional arguments:
    _ -- unused.
    ofd -- function to call with arguments similar to `logging.debug`.
    hdr -- Netlink message header (nlmsghdr class instance).
    ops -- cache operations (nl_cache_ops class instance).
    payloadlen -- length of payload in message (ctypes.c_int instance).

    Returns:
    data (bytearray_ptr).
    """
    data = nlmsg_data(hdr)
    if payloadlen.value < GENL_HDRLEN:
        return data

    print_genl_hdr(ofd, data)
    payloadlen.value -= GENL_HDRLEN
    data = bytearray_ptr(data, GENL_HDRLEN)

    if ops:
        hdrsize = ops.co_hdrsize - GENL_HDRLEN
        if hdrsize > 0:
            if payloadlen.value < hdrsize:
                return data
            ofd('  [HEADER] %d octets', hdrsize)
            dump_hex(ofd, data, hdrsize, 0)
            payloadlen.value -= hdrsize
            data = bytearray_ptr(data, hdrsize)

    return data
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L831.

    Positional arguments:
    _ -- unused.
    ofd -- function to call with arguments similar to `logging.debug`.
    hdr -- Netlink message header (nlmsghdr class instance).
    ops -- cache operations (nl_cache_ops class instance).
    payloadlen -- length of payload in message (ctypes.c_int instance).

    Returns:
    data (bytearray_ptr).