Dump message in human readable format to callable.

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

    Positional arguments:
    msg -- message to print (nl_msg class instance).

    Keyword arguments:
    ofd -- function to call with arguments similar to `logging.debug`.

def nl_msg_dump(msg, ofd=_LOGGER.debug):
    """Dump message in human readable format to callable.

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

    Positional arguments:
    msg -- message to print (nl_msg class instance).

    Keyword arguments:
    ofd -- function to call with arguments similar to `logging.debug`.
    """
    hdr = nlmsg_hdr(msg)

    ofd('--------------------------   BEGIN NETLINK MESSAGE ---------------------------')

    ofd('  [NETLINK HEADER] %d octets', hdr.SIZEOF)
    print_hdr(ofd, msg)

    if hdr.nlmsg_type == libnl.linux_private.netlink.NLMSG_ERROR:
        dump_error_msg(msg, ofd)
    elif nlmsg_len(hdr) > 0:
        print_msg(msg, ofd, hdr)

    ofd('---------------------------  END NETLINK MESSAGE   ---------------------------')