blob: 0e0330fe03599b4f9c07884d985146ef6dd00f79 [file] [log] [blame]
system
{
Inbound userIn : UserInput;
Outbound userOut : TimeOutIndication;
Inbound fwIn : EPTF_MBT_TestStepRequest;
Outbound fwOut : EPTF_MBT_TestStepResponse;
}
/* ====================================================
* Message Definitions
*/
record TimeOutIndication { }
record UserInput
{
public String input1;
public String input2;
}
record SIPResp
{
public int status;
public String cseq;
}
record SIPReq
{
public String op;
public String param;
}
/* ====================================================
* SIPClient
*/
class SIPClient extends StateMachine {
const float T1 = 0.5; // For UDP transport
public float timeoutA = T1; // 17.1.1.2
public float timeoutB = 16 * T1; // 17.1.1.2
public float timeoutE = T1; // 17.1.2.2
public float timeoutF = 16 * T1; // 17.1.2.2
public boolean initialized = false;
/* -----------------------------------------
* SIP addresses
* src = caller, dst = callee
*/
public String src = "sip:127.0.0.1";
public String dst = "sip:127.0.0.1:5061";
/* -----------------------------------------
* Methods to send SIP messages to network.
*/
public EPTF_MBT_TestStepRequest incomingRequest(String p_stepName)
{
EPTF_MBT_TestStepRequest r = c_EPTF_MBT_TestStepRequest_empty();
r.stepName = p_stepName;
r.stepArgs = {};
r.addr.entityGroupName = "MBT_EntityType";
r.addr.eIdx = 0;
r.addr.fIdx = 0;
return r;
}
public EPTF_MBT_TestStepRequest incomingResponse(int p_answerCode)
{
EPTF_MBT_TestStepRequest r = c_EPTF_MBT_TestStepRequest_empty();
r.stepName = c_SIP_stepFunction_createResponse;
r.stepArgs = {f_EPTF_SIP_mapAnswerCode2SipTemplateCode(p_answerCode)};
r.addr.entityGroupName = "MBT_EntityType";
r.addr.eIdx = 0;
r.addr.fIdx = 0;
return r;
}
public EPTF_MBT_TestStepRequest incomingResponse(int p_answerCode, int p_methodCode)
{
EPTF_MBT_TestStepRequest r = c_EPTF_MBT_TestStepRequest_empty();
r.stepName = c_SIP_stepFunction_createResponse;
r.stepArgs = {f_EPTF_SIP_mapAnswerCode2SipTemplateCode(p_answerCode), p_methodCode};
r.addr.entityGroupName = "MBT_EntityType";
r.addr.eIdx = 0;
r.addr.fIdx = 0;
return r;
}
public void Invite() {
EPTF_MBT_TestStepResponse r = c_EPTF_MBT_TestStepResponse_empty();
r.bName = c_SIP_Behavior;
r.iName = c_SIP_eventName_INVITE;
r.addr.fIdx = -1;
fwOut.send(r, 1.0);
if (!initialized)
{
EPTF_MBT_TestStepRequest req = c_EPTF_MBT_TestStepRequest_empty();;
req.stepName = c_SIP_stepFunction_init;
req.stepArgs = {};
req.addr.entityGroupName = "MBT_EntityType";
req.addr.eIdx = 0;
req.addr.fIdx = 0;
AnyRecord a = fwIn.receive();
require a == req;
req.stepName = c_SIP_stepFunction_handleINVITE;
req.stepArgs = {};
req.addr.entityGroupName = "MBT_EntityType";
req.addr.eIdx = 0;
req.addr.fIdx = 0;
a = fwIn.receive();
require a == req;
initialized = true;
}
}
protected void Cancel() {
EPTF_MBT_TestStepResponse r = c_EPTF_MBT_TestStepResponse_empty();
r.bName = c_SIP_Behavior;
r.iName = c_SIP_eventName_CANCEL;
fwOut.send(r, 1.0);
}
protected void Ack() {
EPTF_MBT_TestStepResponse r = c_EPTF_MBT_TestStepResponse_empty();
r.bName = c_SIP_Behavior;
r.iName = c_SIP_eventName_ACK;
fwOut.send(r, 1.0);
}
protected void Bye() {
EPTF_MBT_TestStepResponse r = c_EPTF_MBT_TestStepResponse_empty();
r.bName = c_SIP_Behavior;
r.iName = c_SIP_eventName_BYE;
fwOut.send(r, 1.0);
}
protected void RetransmittedRequest()
{
EPTF_MBT_TestStepResponse r = c_EPTF_MBT_TestStepResponse_empty();
r.bName = c_SIP_Behavior;
r.iName = c_SIP_eventName_RetransmittedRequest;
fwOut.send(r, 1.0);
}
protected void SendOK(String cseq) {
EPTF_MBT_TestStepResponse r = c_EPTF_MBT_TestStepResponse_empty();
r.bName = c_SIP_Behavior;
r.iName = "200";
fwOut.send(r, 1.0);
}
/* -----------------------------------------
* Methods to provide indications to the
* user interface.
*/
private void TimeOut()
{
// Indicate timeout
TimeOutIndication timeout;
userOut.send(timeout);
}
}
/* ====================================================
* main() - Starting Point
*/
void main()
{
var a = new SIPClient();
a.start();
}