コード例 #1
0
void AS_Base::SwitchOnFunction(AsyncSlave* c, AS_Base* apNext, const APDU& arRequest, SequenceInfo aSeqInfo)
{	
	switch(arRequest.GetFunction())
	{
		case(FC_READ):
		{
			ChangeState(c, apNext);
			c->mRspContext.Reset();			
			IINField iin = c->mRspContext.Configure(arRequest);
			c->mRspContext.LoadResponse(c->mResponse);
			c->Send(c->mResponse, iin);
			break;
		}
		case(FC_WRITE):
			ChangeState(c, apNext);
			c->HandleWrite(arRequest);
			c->ConfigureAndSendSimpleResponse();
			break;
		case(FC_SELECT):
			ChangeState(c, apNext);
			c->HandleSelect(arRequest, aSeqInfo);
			c->Send(c->mResponse);
			break;
		case(FC_OPERATE):
			ChangeState(c, apNext);
			c->HandleOperate(arRequest, aSeqInfo);
			c->Send(c->mResponse);
			break;
		case(FC_DIRECT_OPERATE):
			ChangeState(c, apNext);
			c->HandleDirectOperate(arRequest, aSeqInfo);
			c->Send(c->mResponse);
			break;
		case(FC_DIRECT_OPERATE_NO_ACK):			
			c->HandleDirectOperate(arRequest, aSeqInfo);
			break;
		case(FC_ENABLE_UNSOLICITED):
			ChangeState(c, apNext);
			c->HandleEnableUnsolicited(arRequest, true);
			c->Send(c->mResponse);
			break;
		case(FC_DISABLE_UNSOLICITED):
			ChangeState(c, apNext);
			c->HandleEnableUnsolicited(arRequest, false);
			c->Send(c->mResponse);
			break;
		case(FC_DELAY_MEASURE):
			ChangeState(c, apNext);
			c->ConfigureDelayMeasurement(arRequest);
			c->Send(c->mResponse);
			break;
		default:
		{
			std::ostringstream oss;
			oss << "Function not supported: " << arRequest.GetFunction();
			throw NotSupportedException(LOCATION, oss.str(), SERR_FUNC_NOT_SUPPORTED);			
		}
	}
}
コード例 #2
0
ファイル: AppLayer.cpp プロジェクト: diverger/dnp3
void AppLayer::SendRequest(APDU& arAPDU)
{
	this->Validate(arAPDU.GetControl(), true, true, false, false);

	if(!IsRequest(arAPDU.GetFunction()))
		throw ArgumentException(LOCATION, "Non-request function code");

	mSolicited.Send(arAPDU, this->GetRetries(arAPDU.GetFunction()));
}
コード例 #3
0
void ACS_Idle::Send(AppLayerChannel* c, APDU& arAPDU, size_t aNumRetry)
{
	AppControlField acf = arAPDU.GetControl();
	FunctionCodes func = arAPDU.GetFunction();
	acf.SEQ = (acf.FIR && func == FC_RESPONSE) ? c->Sequence() : c->IncrSequence();
	arAPDU.SetControl(acf);
	c->ChangeState(NextState(c, arAPDU.GetFunction(), acf.CON));
	c->SetRetry(aNumRetry);
	c->QueueSend(arAPDU);
}
コード例 #4
0
ファイル: SlaveStates.cpp プロジェクト: prakashnsm/dnp3-1
void AS_Base::SwitchOnFunction(Slave* c, AS_Base* apNext, const APDU& arRequest, SequenceInfo aSeqInfo)
{
	switch (arRequest.GetFunction()) {
	case (FC_READ): {
			ChangeState(c, apNext);
			c->mRspContext.Reset();
			IINField iin = c->mRspContext.Configure(arRequest);
			c->mRspContext.LoadResponse(c->mResponse);
			c->Send(c->mResponse, iin);
			break;
		}
	case (FC_WRITE):
		ChangeState(c, apNext);
		if(aSeqInfo != SI_PREV) c->HandleWrite(arRequest);
		c->ConfigureAndSendSimpleResponse();
		break;
	case (FC_PROPRIETARY_VTO_TRANSFER):
		ChangeState(c, apNext);
		if(aSeqInfo != SI_PREV) c->HandleVtoTransfer(arRequest);
		c->ConfigureAndSendSimpleResponse();
		break;
	case (FC_SELECT):
		ChangeState(c, apNext);
		c->HandleSelect(arRequest, aSeqInfo);
		c->Send(c->mResponse);
		break;
	case (FC_OPERATE):
		ChangeState(c, apNext);
		c->HandleOperate(arRequest, aSeqInfo);
		c->Send(c->mResponse);
		break;
	case (FC_DIRECT_OPERATE):
		ChangeState(c, apNext);
		c->HandleDirectOperate(arRequest, aSeqInfo);
		c->Send(c->mResponse);
		break;
	case (FC_DIRECT_OPERATE_NO_ACK):
		c->HandleDirectOperate(arRequest, aSeqInfo);
		break;
	case (FC_ENABLE_UNSOLICITED):
		ChangeState(c, apNext);
		c->HandleEnableUnsolicited(arRequest, true);
		c->Send(c->mResponse);
		break;
	case (FC_DISABLE_UNSOLICITED):
		ChangeState(c, apNext);
		c->HandleEnableUnsolicited(arRequest, false);
		c->Send(c->mResponse);
		break;
	case (FC_DELAY_MEASURE):
		ChangeState(c, apNext);
		c->ConfigureDelayMeasurement(arRequest);
		c->Send(c->mResponse);
		break;
	default: 
		MACRO_THROW_EXCEPTION_COMPLEX_WITH_CODE(NotSupportedException, "Function not supported: " << arRequest.GetFunction() , SERR_FUNC_NOT_SUPPORTED);
	}
}
コード例 #5
0
ファイル: AppLayer.cpp プロジェクト: diverger/dnp3
void AppLayer::SendUnsolicited(APDU& arAPDU)
{
	this->Validate(arAPDU.GetControl(), false, true, true, true);

	if(arAPDU.GetFunction() != FC_UNSOLICITED_RESPONSE )
		throw ArgumentException(LOCATION, "Non-unsolicited function code");
	
	mUnsolicited.Send(arAPDU, this->GetRetries(FC_UNSOLICITED_RESPONSE));	
}
コード例 #6
0
ファイル: AppLayer.cpp プロジェクト: diverger/dnp3
void AppLayer::SendResponse(APDU& arAPDU)
{
	this->Validate(arAPDU.GetControl(), false, false, true, false);
		
	if(arAPDU.GetFunction() != FC_RESPONSE)
		throw ArgumentException(LOCATION, "Non-response function code");	

	mSolicited.Send(arAPDU, this->GetRetries(FC_RESPONSE));	
}
コード例 #7
0
void AS_WaitForUnsolSuccess::OnRequest(AsyncSlave* c, const APDU& arAPDU, SequenceInfo aSeqInfo)
{
	if(arAPDU.GetFunction() == FC_READ) { //read requests should be defered until after the unsol
		c->mRequest = arAPDU;
		c->mSeqInfo = aSeqInfo;
		c->mDeferredRequest = true;
	}
	else { // all other requests should be handled immediately
		c->mDeferredRequest = false;
		this->DoRequest(c, AS_WaitForSolUnsolSuccess::Inst(), arAPDU, aSeqInfo);
	}
}