def print_msg(msg, ofd, hdr):
payloadlen = c_int(nlmsg_len(hdr))<EOL>attrlen = <NUM_LIT:0><EOL>data = nlmsg_data(hdr)<EOL>ops = nl_cache_ops_associate_safe(msg.nm_protocol, hdr.nlmsg_type)<EOL>if ops:<EOL><INDENT>attrlen = nlmsg_attrlen(hdr, ops.co_hdrsize)<EOL>payloadlen.value -= attrlen<EOL><DEDENT>if msg.nm_protocol == libnl.linux_private.netlink.NETLINK_GENERIC:<EOL><INDENT>data = print_genl_msg(msg, ofd, hdr, ops, payloadlen)<EOL><DEDENT>if payloadlen.value:<EOL><INDENT>ofd('<STR_LIT>', payloadlen.value)<EOL>dump_hex(ofd, data, payloadlen.value, <NUM_LIT:0>)<EOL><DEDENT>if attrlen:<EOL><INDENT>attrs = nlmsg_attrdata(hdr, ops.co_hdrsize)<EOL>attrlen = nlmsg_attrlen(hdr, ops.co_hdrsize)<EOL>dump_attrs(ofd, attrs, attrlen, <NUM_LIT:0>)<EOL><DEDENT>
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L929.

    Positional arguments:
    msg -- Netlink message (nl_msg class instance).
    ofd -- function to call with arguments similar to `logging.debug`.
    hdr -- Netlink message header (nlmsghdr class instance).