datapath-windows/ovsext/Netlink/Netlink.c
/*
 *----------------------------------------------------------------------------
 * Parses the netlink message at a given offset (attrOffset)
 * as a series of attributes. A pointer to the attribute with type
 * 'type' is stored in attrs at index 'type'. policy is used to define the
 * attribute type validation parameters.
 * 'nla_offset' should be NLMSG_HDRLEN + GENL_HDRLEN + OVS_HEADER
 *
 * Returns BOOLEAN to indicate success/failure.
 *----------------------------------------------------------------------------
 */
Parses the netlink message at a given offset (attrOffset)
as a series of attributes. A pointer to the attribute with type
'type' is stored in attrs at index 'type'. policy is used to define the
attribute type validation parameters.

Returns BOOLEAN to indicate success/failure.
Parses the netlink message at a given offset ( attrOffset ) as a series of attributes . A pointer to the attribute with type ' type ' is stored in attrs at index ' type ' . policy is used to define the attribute type validation parameters . Returns BOOLEAN to indicate success / failure .
BOOLEAN
NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
            UINT32 totalAttrLen,
            const NL_POLICY policy[], const UINT32 numPolicy,
            PNL_ATTR attrs[], UINT32 numAttrs)
{
    PNL_ATTR nla;
    INT left;
    UINT32 iter;
    BOOLEAN ret = FALSE;
    UINT32 numPolicyAttr = MIN(numPolicy, numAttrs);
    RtlZeroMemory(attrs, numAttrs * sizeof *attrs);
    if ((NlMsgSize(nlMsg) < attrOffset)) {
        OVS_LOG_WARN("No attributes in nlMsg: %p at offset: %d",
                     nlMsg, attrOffset);
        goto done;
    }
    NL_ATTR_FOR_EACH (nla, left, NlMsgAt(nlMsg, attrOffset),
                      totalAttrLen)
    {
        UINT16 type = NlAttrType(nla);
        if (type < numPolicyAttr && policy[type].type != NL_A_NO_ATTR) {
            const PNL_POLICY e = (const PNL_POLICY)(&policy[type]);
            if (!NlAttrValidate(nla, e)) {
                goto done;
            }
            if (attrs[type]) {
                OVS_LOG_WARN("Duplicate attribute in nlMsg: %p, "
                             "type: %u", nlMsg, type);
            }
            attrs[type] = nla;
        }
    }
    if (left) {
        OVS_LOG_ERROR("Attributes followed by garbage");
        goto done;
    }
    for (iter = 0; iter < numPolicyAttr; iter++) {
        const PNL_POLICY e = (const PNL_POLICY)(&policy[iter]);
        if (!e->optional && e->type != NL_A_NO_ATTR && !attrs[iter]) {
            OVS_LOG_ERROR("Required attr:%d missing", iter);
            goto done;
        }
    }
    ret = TRUE;
done:
    return ret;
}
BOOLEAN NlAttrParse ( const PNL_MSG_HDR nlMsg , UINT32 attrOffset , UINT32 totalAttrLen , const NL_POLICY policy [ ] , const UINT32 numPolicy , PNL_ATTR attrs [ ] , UINT32 numAttrs ) { PNL_ATTR nla ; INT left ; UINT32 iter ; BOOLEAN ret = FALSE ; UINT32 numPolicyAttr = MIN ( numPolicy , numAttrs ) ; RtlZeroMemory ( attrs , numAttrs * sizeof * attrs ) ; if ( ( NlMsgSize ( nlMsg ) < attrOffset ) ) { OVS_LOG_WARN ( " " , nlMsg , attrOffset ) ; goto done ; } NL_ATTR_FOR_EACH ( nla , left , NlMsgAt ( nlMsg , attrOffset ) , totalAttrLen ) { UINT16 type = NlAttrType ( nla ) ; if ( type < numPolicyAttr && policy [ type ] . type != NL_A_NO_ATTR ) { const PNL_POLICY e = ( const PNL_POLICY ) ( & policy [ type ] ) ; if ( ! NlAttrValidate ( nla , e ) ) { goto done ; } if ( attrs [ type ] ) { OVS_LOG_WARN ( " " " " , nlMsg , type ) ; } attrs [ type ] = nla ; } } if ( left ) { OVS_LOG_ERROR ( " " ) ; goto done ; } for ( iter = 0 ; iter < numPolicyAttr ; iter ++ ) { const PNL_POLICY e = ( const PNL_POLICY ) ( & policy [ iter ] ) ; if ( ! e -> optional && e -> type != NL_A_NO_ATTR && ! attrs [ iter ] ) { OVS_LOG_ERROR ( " " , iter ) ; goto done ; } } ret = TRUE ; done : return ret ; }
Parses the netlink message at a given offset (attrOffset)
 as a series of attributes.
Parses the netlink message at a given offset ( attrOffset ) as a series of attributes .
/* Typecasting to keep the compiler happy */