datapath-windows/ovsext/Netlink/Netlink.c
/*
 *----------------------------------------------------------------------------
 * Traverses all attributes in received buffer in order to insure all are valid
 *----------------------------------------------------------------------------
 */
Traverses all attributes in received buffer in order to insure all are valid
Traverses all attributes in received buffer in order to insure all are valid
BOOLEAN NlValidateAllAttrs(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
                           UINT32 totalAttrLen,
                           const NL_POLICY policy[], const UINT32 numPolicy)
{
    PNL_ATTR nla;
    INT left;
    BOOLEAN ret = TRUE;
    if ((NlMsgSize(nlMsg) < attrOffset)) {
        OVS_LOG_WARN("No attributes in nlMsg: %p at offset: %d",
            nlMsg, attrOffset);
        ret = FALSE;
        goto done;
    }
    NL_ATTR_FOR_EACH_UNSAFE(nla, left, NlMsgAt(nlMsg, attrOffset),
                            totalAttrLen)
    {
        if (!NlAttrIsValid(nla, left)) {
            ret = FALSE;
            goto done;
        }
        UINT16 type = NlAttrType(nla);
        if (type < numPolicy && policy[type].type != NL_A_NO_ATTR) {
            const PNL_POLICY e = (const PNL_POLICY)(&policy[type]);
            if (!NlAttrValidate(nla, e)) {
                ret = FALSE;
                goto done;
            }
        }
    }
done:
    return ret;
}
BOOLEAN NlValidateAllAttrs ( const PNL_MSG_HDR nlMsg , UINT32 attrOffset , UINT32 totalAttrLen , const NL_POLICY policy [ ] , const UINT32 numPolicy ) { PNL_ATTR nla ; INT left ; BOOLEAN ret = TRUE ; if ( ( NlMsgSize ( nlMsg ) < attrOffset ) ) { OVS_LOG_WARN ( " " , nlMsg , attrOffset ) ; ret = FALSE ; goto done ; } NL_ATTR_FOR_EACH_UNSAFE ( nla , left , NlMsgAt ( nlMsg , attrOffset ) , totalAttrLen ) { if ( ! NlAttrIsValid ( nla , left ) ) { ret = FALSE ; goto done ; } UINT16 type = NlAttrType ( nla ) ; if ( type < numPolicy && policy [ type ] . type != NL_A_NO_ATTR ) { const PNL_POLICY e = ( const PNL_POLICY ) ( & policy [ type ] ) ; if ( ! NlAttrValidate ( nla , e ) ) { ret = FALSE ; goto done ; } } } done : return ret ; }
Traverses all attributes in received buffer in order to insure all are valid
Traverses all attributes in received buffer in order to insure all are valid
/* Typecasting to keep the compiler happy */