static 
int checkPeerReplayCounter(tAuthRsnFsm *fsm, 
                           tAniEapolKeyAvailEventData *data)
{
    int retVal = ANI_E_NULL_VALUE;
    int cmp;
    tAniEapolRsnKeyDesc *rxDesc;
    
    rxDesc = data->keyDesc;
    if( rxDesc )
    {
        cmp = aniSsmReplayCtrCmp(fsm->staCtx->peerReplayCtr, rxDesc->replayCounter);

        // The STA should have sent a newer replay ctr than its old
        // request. The first message is exempted from the check.
        if (fsm->staCtx->pastFirstPeerRequest && cmp >= 0) 
        {
            retVal = ANI_E_REPLAY_CHECK_FAILED;
        }

        fsm->staCtx->pastFirstPeerRequest = eANI_BOOLEAN_TRUE;
    }

    return retVal;
}
static int 
checkLocalReplayCounter(tAuthRsnFsm *fsm, 
                        tAniEapolKeyAvailEventData *data)
{
    int retVal = ANI_E_NULL_VALUE;
    int cmp;
    tAniEapolRsnKeyDesc *rxDesc;
    
    rxDesc = data->keyDesc;
    if( rxDesc )
    {
        cmp = aniSsmReplayCtrCmp(fsm->staCtx->localReplayCtr, rxDesc->replayCounter);

        // The STA should have sent back the same replay ctr as in our request
        if (cmp != 0) 
        {
            retVal = ANI_E_REPLAY_CHECK_FAILED;
        }
        else
        {
            retVal = ANI_OK;
        }
    }

    return retVal;
}
static 
int checkPeerReplayCounter(tSuppRsnFsm *fsm, 
                           tAniEapolKeyAvailEventData *data,
                           v_BOOL_t *retransmit,
                           v_BOOL_t actualMicFlag,
                           v_BOOL_t reTxMicFlag)
{
    int retVal = ANI_OK;
    int cmp;
    tAniEapolRsnKeyDesc *rxDesc;
    
    rxDesc = data->keyDesc;
    if( NULL == rxDesc )
    {
        return ANI_E_NULL_VALUE;
    }

    *retransmit = eANI_BOOLEAN_FALSE;
    
    cmp = aniSsmReplayCtrCmp(fsm->peerReplayCtr, rxDesc->replayCounter);
    
    // The AP should send us a replay counter greater than or equal to
    // the last one it sent
    /*Unless we are forgiving with this we will have interop issues with some vendros like CSR*/
    if (cmp > 0) 
    {
        VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
            "BP got old EAPOL replay counter from AP" );
        retVal = ANI_E_REPLAY_CHECK_FAILED;

    } 
    else if (cmp <= 0) 
    {
        if ( actualMicFlag == reTxMicFlag ) 
        { 
            *retransmit = eANI_BOOLEAN_TRUE; 
        }
    }

    return retVal;
}