openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/attr.c
int nla_parse(struct nlattr* tb[], int maxtype, struct nlattr* head, int len,
              struct nla_policy* policy)
{
    struct nlattr* nla;
    int rem, err;

    memset(tb, 0, sizeof(struct nlattr*) * (maxtype + 1));

    nla_for_each_attr(nla, head, len, rem)
    {
        int type = nla_type(nla);

        if (type > maxtype)
            continue;

        if (policy)
        {
            err = validate_nla(nla, maxtype, policy);
            if (err < 0)
                goto errout;
        }

        if (tb[type])
            NL_DBG(1,
                   "Attribute of type %#x found multiple times in message, "
                   "previous attribute is being ignored.\n",
                   type);

        tb[type] = nla;
    }

    if (rem > 0)
        NL_DBG(1,
               "netlink: %d bytes leftover after parsing "
               "attributes.\n",
               rem);

    err = 0;
errout:
    return err;
}
/**
 * Create attribute index based on a stream of attributes.
 * @arg tb		Index array to be filled (maxtype+1 elements).
 * @arg maxtype		Maximum attribute type expected and accepted.
 * @arg head		Head of attribute stream.
 * @arg len		Length of attribute stream.
 * @arg policy		Attribute validation policy.
 *
 * 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 \a policy is not NULL, the attribute will be
 * validated using the specified policy.
 *
 * @see nla_validate
 * @return 0 on success or a negative error code.
 */
Create attribute index based on a stream of attributes.
@arg tb              Index array to be filled (maxtype+1 elements).
@arg maxtype         Maximum attribute type expected and accepted.
@arg head            Head of attribute stream.
@arg len             Length of attribute stream.
@arg policy          Attribute validation policy.

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 \a policy is not NULL, the attribute will be
validated using the specified policy.

@see nla_validate
@return 0 on success or a negative error code.
Create attribute index based on a stream of attributes . @arg tb Index array to be filled ( maxtype + 1 elements ) . @arg maxtype Maximum attribute type expected and accepted . @arg head Head of attribute stream . @arg len Length of attribute stream . @arg policy Attribute validation policy . 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 \ a policy is not NULL the attribute will be validated using the specified policy . @see nla_validate @return 0 on success or a negative error code .
int nla_parse(struct nlattr* tb[], int maxtype, struct nlattr* head, int len,
              struct nla_policy* policy)
{
    struct nlattr* nla;
    int rem, err;
    memset(tb, 0, sizeof(struct nlattr*) * (maxtype + 1));
    nla_for_each_attr(nla, head, len, rem)
    {
        int type = nla_type(nla);
        if (type > maxtype)
            continue;
        if (policy)
        {
            err = validate_nla(nla, maxtype, policy);
            if (err < 0)
                goto errout;
        }
        if (tb[type])
            NL_DBG(1,
                   "Attribute of type %#x found multiple times in message, "
                   "previous attribute is being ignored.\n",
                   type);
        tb[type] = nla;
    }
    if (rem > 0)
        NL_DBG(1,
               "netlink: %d bytes leftover after parsing "
               "attributes.\n",
               rem);
    err = 0;
errout:
    return err;
}
int nla_parse ( struct nlattr * tb [ ] , int maxtype , struct nlattr * head , int len , struct nla_policy * policy ) { struct nlattr * nla ; int rem , err ; memset ( tb , 0 , sizeof ( struct nlattr * ) * ( maxtype + 1 ) ) ; nla_for_each_attr ( nla , head , len , rem ) { int type = nla_type ( nla ) ; if ( type > maxtype ) continue ; if ( policy ) { err = validate_nla ( nla , maxtype , policy ) ; if ( err < 0 ) goto errout ; } if ( tb [ type ] ) NL_DBG ( 1 , " " " \n " , type ) ; tb [ type ] = nla ; } if ( rem > 0 ) NL_DBG ( 1 , " " " \n " , rem ) ; err = 0 ; errout : return err ; }
Create attribute index based on a stream of attributes.
Create attribute index based on a stream of attributes .