def print_hdr(ofd, msg):
    """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L793.

    Positional arguments:
    ofd -- function to call with arguments similar to `logging.debug`.
    msg -- message to print (nl_msg class instance).
    """
    nlh = nlmsg_hdr(msg)
    buf = bytearray()

    ofd('    .nlmsg_len = %d', nlh.nlmsg_len)

    ops = nl_cache_ops_associate_safe(msg.nm_protocol, nlh.nlmsg_type)
    if ops:
        mt = nl_msgtype_lookup(ops, nlh.nlmsg_type)
        if not mt:
            raise BUG
        buf.extend('{0}::{1}'.format(ops.co_name, mt.mt_name).encode('ascii'))
    else:
        nl_nlmsgtype2str(nlh.nlmsg_type, buf, 128)

    ofd('    .type = %d <%s>', nlh.nlmsg_type, buf.decode('ascii'))
    ofd('    .flags = %d <%s>', nlh.nlmsg_flags, nl_nlmsg_flags2str(nlh.nlmsg_flags, buf, 128).decode('ascii'))
    ofd('    .seq = %d', nlh.nlmsg_seq)
    ofd('    .port = %d', nlh.nlmsg_pid)
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L793.

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