code: def nla_parse(tb, maxtype, head, len_, policy):
      
      rem = c_int()
      for nla in nla_for_each_attr(head, len_, rem):
          type_ = nla_type(nla)
          if type_ > maxtype:
              continue
  
          if policy:
              err = validate_nla(nla, maxtype, policy)
              if err < 0:
                  return err
  
          if type_ in tb and tb[type_]:
              _LOGGER.debug('Attribute of type %d found multiple times in message, previous attribute is being ignored.',
                            type_)
          tb[type_] = nla
  
      if rem.value > 0:
          _LOGGER.debug('netlink: %d bytes leftover after parsing attributes.', rem.value)
  
      return 0
docs: Create attribute index based on a stream of attributes.
  
      https://github.com/thom311/libnl/blob/libnl3_2_25/lib/attr.c#L242
  
      Iterates over the stream of attributes and stores a pointer to each attribute in the index array using the attribute
      type as index to the array. Attribute with a type greater than the maximum type specified will be silently ignored
      in order to maintain backwards compatibility. If `policy` is not None, the attribute will be validated using the
      specified policy.
  
      Positional arguments:
      tb -- dictionary to be filled (maxtype+1 elements).
      maxtype -- maximum attribute type expected and accepted (integer).
      head -- first nlattr with more in its bytearray payload (nlattr class instance).
      len_ -- length of attribute stream (integer).
      policy -- dictionary of nla_policy class instances as values, with nla types as keys.
  
      Returns:
      0 on success or a negative error code.