void AS_Base::DoRequest(AsyncSlave* c, AS_Base* apNext, const APDU& arAPDU, SequenceInfo aSeqInfo) { c->mRspIIN.Zero(); try { this->SwitchOnFunction(c, apNext, arAPDU, aSeqInfo); } catch(ParameterException ex) { ChangeState(c, apNext); ERROR_LOGGER_BLOCK(c->mpLogger, LEV_ERROR, ex.Message(), ex.ErrorCode()); c->mRspIIN.SetParameterError(true); c->ConfigureAndSendSimpleResponse(); } catch(NotSupportedException ex) { ChangeState(c, apNext); ERROR_LOGGER_BLOCK(c->mpLogger, LEV_ERROR, ex.Message(), ex.ErrorCode()); c->mRspIIN.SetFuncNotSupported(true); c->ConfigureAndSendSimpleResponse(); } c->mLastRequest = arAPDU; c->mHaveLastRequest = true; }
void ACS_Base::ProcessResponse(AppLayerChannel* c, APDU& arAPDU, bool aExpectFIR) { AppControlField acf = arAPDU.GetControl(); if(acf.SEQ == c->Sequence()) { if(acf.FIR == aExpectFIR) { c->CancelTimer(); if(acf.FIN) { c->ChangeState(ACS_Idle::Inst()); c->DoFinalResponse(arAPDU); } else { c->IncrSequence(); c->ChangeState(ACS_WaitForFinalResponse::Inst()); c->StartTimer(); c->DoPartialResponse(arAPDU); } } else { ERROR_LOGGER_BLOCK(c->GetLogger(), LEV_WARNING, "Unexpected fir bit " << acf.FIR, ALERR_BAD_FIR_FIN); } } else { ERROR_LOGGER_BLOCK(c->GetLogger(), LEV_WARNING, "Bad sequence number " << acf.SEQ, ALERR_BAD_SEQUENCE); } }
void PLLS_ResetLinkWait::OnTimeout(LinkLayer* apLL) { if(apLL->Retry()) { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "Confirmed data timeout, retrying, " << apLL->RetryRemaining() << " remaining", DLERR_TIMEOUT_RETRY); apLL->StartTimer(); apLL->SendResetLinks(); } else { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "Confirmed data final timeout", DLERR_TIMEOUT_NO_RETRY); apLL->ChangeState(PLLS_SecNotReset::Inst()); apLL->DoSendFailure(); } }
void PLLS_ConfDataWait::OnTimeout(LinkLayer* apLL) { if(apLL->Retry()) { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "Retry confirmed data", DLERR_TIMEOUT_RETRY); apLL->StartTimer(); apLL->ChangeState(PLLS_ConfDataWait::Inst()); apLL->SendDelayedUserData(apLL->NextWriteFCB()); } else { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "Confirmed data timeout", DLERR_TIMEOUT_NO_RETRY); apLL->ChangeState(PLLS_SecNotReset::Inst()); apLL->DoSendFailure(); } }
void SLLS_Reset::ConfirmedUserData(LinkLayer* apLL, bool aFcb, const uint8_t* apData, size_t aDataLength) { apLL->SendAck(); if(apLL->NextReadFCB() == aFcb) { apLL->ToggleReadFCB(); apLL->DoDataUp(apData, aDataLength); } else { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "Confirmed data w/ wrong FCB", DLERR_WRONG_FCB_ON_RECEIVE_DATA); } }
void SLLS_Reset::TestLinkStatus(LinkLayer* apLL, bool aFcb) { if(apLL->NextReadFCB() == aFcb) { apLL->ToggleReadFCB(); apLL->SendAck(); } else { // "Re-transmit most recent response that contained function code 0 (ACK) or 1 (NACK)." // This is a pain in the pass to implement. ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "TestLinkStatus with invalid FCB", DLERR_WRONG_FCB_ON_TEST); } }
void ACS_WaitForConfirm::OnConfirm(AppLayerChannel* c, int aSeq) { // does the confirm sequence match what we expect? if(c->Sequence() == aSeq) { c->CancelTimer(); c->ChangeState(ACS_Idle::Inst()); c->DoSendSuccess(); } else { ERROR_LOGGER_BLOCK(c->GetLogger(), LEV_WARNING, "Unexpected confirm w/ sequence " << aSeq, ALERR_UNEXPECTED_CONFIRM); } }
void ACS_Base::OnConfirm(AppLayerChannel* c, int aSeq) { ERROR_LOGGER_BLOCK(c->GetLogger(), LEV_WARNING, "Unexpected confirm with sequence: " << aSeq, ALERR_UNEXPECTED_CONFIRM); }
void SLLS_NotReset::ConfirmedUserData(LinkLayer* apLL, bool aFcb, const uint8_t* apData, size_t aDataLength) { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "ConfirmedUserData ignored", DLERR_UNEXPECTED_FRAME); }
void SLLS_NotReset::TestLinkStatus(LinkLayer* apLL, bool aFcb) { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "TestLinkStatus ignored", DLERR_UNEXPECTED_FRAME); }
void PriStateBase::NotSupported (LinkLayer* apLL, bool aIsRcvBuffFull) { ERROR_LOGGER_BLOCK(apLL->GetLogger(), LEV_WARNING, "Frame context not understood", DLERR_UNEXPECTED_FRAME); }