def nla_parse(tb, maxtype, head, len_, policy):
rem = c_int()<EOL>for nla in nla_for_each_attr(head, len_, rem):<EOL><INDENT>type_ = nla_type(nla)<EOL>if type_ > maxtype:<EOL><INDENT>continue<EOL><DEDENT>if policy:<EOL><INDENT>err = validate_nla(nla, maxtype, policy)<EOL>if err < <NUM_LIT:0>:<EOL><INDENT>return err<EOL><DEDENT><DEDENT>if type_ in tb and tb[type_]:<EOL><INDENT>_LOGGER.debug('<STR_LIT>',<EOL>type_)<EOL><DEDENT>tb[type_] = nla<EOL><DEDENT>if rem.value > <NUM_LIT:0>:<EOL><INDENT>_LOGGER.debug('<STR_LIT>', rem.value)<EOL><DEDENT>return <NUM_LIT:0><EOL>
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.