code: def print_msg(msg, ofd, hdr):
      
      payloadlen = c_int(nlmsg_len(hdr))
      attrlen = 0
      data = nlmsg_data(hdr)
      ops = nl_cache_ops_associate_safe(msg.nm_protocol, hdr.nlmsg_type)
      if ops:
          attrlen = nlmsg_attrlen(hdr, ops.co_hdrsize)
          payloadlen.value -= attrlen
      if msg.nm_protocol == libnl.linux_private.netlink.NETLINK_GENERIC:
          data = print_genl_msg(msg, ofd, hdr, ops, payloadlen)
      if payloadlen.value:
          ofd('  [PAYLOAD] %d octets', payloadlen.value)
          dump_hex(ofd, data, payloadlen.value, 0)
      if attrlen:
          attrs = nlmsg_attrdata(hdr, ops.co_hdrsize)
          attrlen = nlmsg_attrlen(hdr, ops.co_hdrsize)
          dump_attrs(ofd, attrs, attrlen, 0)
docs: 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).