blob: 504c2e61ba6002905e753468b353caed23a4052e [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2018 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
///////////////////////////////////////////////////////////////////////////////
//
// File: MBT_SUT_SIP_Phone.ttcn
// Rev: <RnXnn>
// Prodnr: CNL 113 659
// Updated: 2009-10-01
// Contact: http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
module MBT_SUT_SIP_Phone
{
import from MBT_Qtronic_Types all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_RBTScheduler_Functions all;
import from EPTF_CLL_LGenBase_Definitions all;
import from EPTF_CLL_LGenBase_ConfigFunctions all;
import from EPTF_CLL_LGenBase_EventHandlingFunctions all;
import from EPTF_MBT_LGen_Definitions all;
import from EPTF_MBT_LGen_Functions all;
import from EPTF_SIP_LGen_Definitions all;
import from EPTF_SIP_LGen_Functions all;
import from EPTF_SIP_Common_Functions all;
import from EPTF_SIP_UserDatabase_Functions all;
import from EPTF_SIP_Transport_Definitions all;
import from EPTF_SIP_Transport_Functions all;
import from EPTF_SIP_MessageHandler_Functions all;
import from EPTF_SIP_TestSteps all;
import from EPTF_SIP_Templates all;
import from EPTF_SIP_Events all;
modulepar
{
charstring tsp_MBT_SUT_LocalIP := "159.107.193.33";
integer tsp_MBT_SUT_LocalPort := 20000;
charstring tsp_MBT_SUT_RemoteIP := "159.107.193.33";
integer tsp_MBT_SUT_RemotePort := 15000;
charstring tsp_MBT_SUT_SIP_Transport := "udp";
}
type component MBT_Qtronic_Demo_SUT_CT
extends
EPTF_MBT_LGen_CT,
EPTF_SIP_LGen_CT, EPTF_SIP_LocalTransport_CT
{
port userInPort userIn;
port userOutPort userOut;
var integer v_SUT_myBIdx := -1;
}
function f_MBT_Qtronic_Demo_SUT_behavior() runs on MBT_Qtronic_Demo_SUT_CT
{
// map(self:IPL4_PCO, system:IPL4_PCO);
activate(as_MBT_Qtronic_Demo_SUT_userMessageHandler());
f_EPTF_MBT_init("MBT_Demo_SUT",0, "MBT_")
f_SIP_applibInit("MBT_Demo_SUT");
f_EPTF_SIP_LocalTransport_init(tsp_MBT_SUT_SIP_Transport);
vf_EPTF_SIP_LocalTransport_receive := refers(f_EPTF_SIP_Message_MsgHandler); //receive callback function on LocalTransport
vf_EPTF_SIP_LGen_msgSender := refers(f_EPTF_SIP_LocalTransport_sendSIPMessage); //send callback function on LGen
v_removeUAS := refers(fcb_EPTF_SIP_LocalTransport_removeUAS);
v_SUT_myBIdx := f_EPTF_LGenBase_declareBehaviorType("SUT_Behavior", -1, null, null, null);
var integer vl_temp := -1;
vl_temp := f_EPTF_LGenBase_declareFsmEvent("SUT_Behavior", "SUT_INVITE");
f_EPTF_Base_assert(%definitionId&": Error during registration of SUT_INVITE", vl_temp == c_MBT_Qtronic_Demo_SUT_Event_invite);
vl_temp := f_EPTF_LGenBase_declareFsmEvent("SUT_Behavior", "SUT_CANCEL");
f_EPTF_Base_assert(%definitionId&": Error during registration of SUT_CANCEL", vl_temp == c_MBT_Qtronic_Demo_SUT_Event_cancel);
vl_temp := f_EPTF_LGenBase_declareFsmEvent("SUT_Behavior", "SUT_BYE");
f_EPTF_Base_assert(%definitionId&": Error during registration of SUT_BYE", vl_temp == c_MBT_Qtronic_Demo_SUT_Event_bye);
f_EPTF_LGenBase_declareCompactFsmTable(f_IMBT_Qtronic_Demo_SUT_getFSM());
f_EPTF_MBT_initLGenFsm
(
refers(f_MBT_Qtronic_Demo_SUT_createUserMessage),
refers(f_MBT_Qtronic_Demo_SUT_fillInDB)
);
EPTF_MBT_PCO.send(EPTF_MBT_CommandResponse:{ ready := {}}) to mtc;
f_EPTF_Base_wait4Shutdown();
}
altstep as_MBT_Qtronic_Demo_SUT_userMessageHandler()
runs on MBT_Qtronic_Demo_SUT_CT
{
var UserInput vl_UserInput;
[] userIn.receive(UserInput:?) -> value vl_UserInput
{
f_EPTF_SchedulerComp_refreshSnapshotTime();
action(%definitionId, " incoming: ", vl_UserInput);
if (vl_UserInput.input1 == "invite")
{
f_EPTF_LGenBase_dispatchEvent({{v_SUT_myBIdx, c_MBT_Qtronic_Demo_SUT_Event_invite,{ 0, 0}, omit},{}});
}
else if (vl_UserInput.input1 == "cancel")
{
f_EPTF_LGenBase_dispatchEvent({{v_SUT_myBIdx, c_MBT_Qtronic_Demo_SUT_Event_cancel,{ 0, 0}, omit},{}});
}
else if (vl_UserInput.input1 == "bye")
{
f_EPTF_LGenBase_dispatchEvent({{v_SUT_myBIdx, c_MBT_Qtronic_Demo_SUT_Event_bye,{ 0, 0}, omit},{}});
}
else
{
action(%definitionId & "(): UserInput not recognized: ", vl_UserInput);
}
repeat;
}
}
function f_MBT_Qtronic_Demo_SUT_createUserMessage(in EPTF_LGenBase_TestStepArgs pl_ptr)
runs on MBT_Qtronic_Demo_SUT_CT
return boolean
{
action(%definitionId & "(): creating message for: ", pl_ptr, "\n", pl_ptr.reportedEvent);
return true;
}
function f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication(in EPTF_LGenBase_TestStepArgs pl_ptr)
runs on MBT_Qtronic_Demo_SUT_CT
{
userOut.send(TimeOutIndication:{});
}
function f_MBT_Qtronic_Demo_SUT_fillInDB(in EPTF_MBT_ConfigRequest p_req) runs on MBT_Qtronic_Demo_SUT_CT
{
var integer vl_grpIdx := f_EPTF_LGenBase_entityGrpNameIndex(p_req.entityGroupName);
var integer vl_entityIdx := f_EPTF_LGenBase_getEGrpBaseOffset(vl_grpIdx);
for (var integer i:=0; i<p_req.noEntities; i:=i+1)
{
var EPTF_IntegerList vl_bCtx := f_EPTF_LGenBase_getBehaviorCtx(i + vl_entityIdx, v_SIP_myBIdx);
f_EPTF_SIP_IPL4asp_SetUserData
(
vl_bCtx[0],
tsp_MBT_SUT_LocalIP, // local IP
{tsp_MBT_SUT_LocalPort, tsp_MBT_SUT_LocalPort+1},
tsp_MBT_SUT_SIP_Transport,
tsp_MBT_SUT_RemoteIP, // proxy ip
tsp_MBT_SUT_RemotePort // proxy port
);
f_EPTF_SIP_User_SetUserData(
vl_bCtx[0],
{
{
addr := {
nameAddr := {
displayName := "titansim_user_7465001",
addrSpec := {
scheme := "sip",
userInfo := {
userOrTelephoneSubscriber := "titansim_user_7465001",
password := omit
},
hostPort := {
host := "tcj.ics.se",
portField := tsp_MBT_SUT_LocalPort
},
urlParameters := omit,
headers := omit
}
}
},
password := "pass2ICS"
}
},
tsp_MBT_SUT_LocalIP,
{tsp_MBT_SUT_LocalPort, tsp_MBT_SUT_LocalPort+1},
i + vl_entityIdx //entity index
);
f_EPTF_SIP_Session_AddData(vl_bCtx[0], f_EPTF_SIP_getTransport(tsp_MBT_SUT_SIP_Transport),345600);
f_EPTF_SIP_Session_addCalledUser(
i,
{
nameAddr := {
displayName := "titansim_user_7465000",
addrSpec := {
scheme := "sip",
userInfo := {
userOrTelephoneSubscriber := "titansim_user_7465000",
password := omit
},
hostPort := {
host := "tcj.ics.se",
portField := tsp_MBT_SUT_RemotePort
},
urlParameters := omit,
headers := omit
}
}
}
);
f_EPTF_SIP_IPL4asp_startListening(vl_bCtx[0], true); // Both UDP and TCP
}
}
const integer c_MBT_Qtronic_Demo_SUT_Event_invite := 0;
const integer c_MBT_Qtronic_Demo_SUT_Event_cancel := 1;
const integer c_MBT_Qtronic_Demo_SUT_Event_bye := 2;
const integer c_MBT_Qtronic_Demo_SUT_State_idle := 0;
const integer c_MBT_Qtronic_Demo_SUT_State_initiated := 1;
const integer c_MBT_Qtronic_Demo_SUT_State_canceling := 2;
const integer c_MBT_Qtronic_Demo_SUT_State_established := 3;
const integer c_MBT_Qtronic_Demo_SUT_State_closing := 4;
function f_IMBT_Qtronic_Demo_SUT_getFSM()
runs on MBT_Qtronic_Demo_SUT_CT
return EPTF_LGenBase_CompactFsmTable
{
return
{
//DOT: digraph c_MBT_Qtronic_Demo_SUT_FSM {
name := "MBT_Qtronic_Demo_SUT_FSM",
stateList := {"idle", "initiated", "canceling", "established", "closing"},
timerList := {},
table :=
{
{eventToListen := {v_SUT_myBIdx, c_MBT_Qtronic_Demo_SUT_Event_invite, entity},
cellRow := {
//state=idle
{ {
//DOT: idle -> initiated [label="i:invite\n o:INVITE"]
{refers(f_SIP_step_init), {}},
{refers(f_SIP_step_createINVITE),{0,0}}
},omit, c_MBT_Qtronic_Demo_SUT_State_initiated},
//state=initiated
{ omit, omit, omit },
//state=canceling
{ omit, omit, omit },
//state=established
{ omit, omit, omit },
//state=closing
{ omit, omit, omit }
}
},
{eventToListen := {v_SUT_myBIdx, c_MBT_Qtronic_Demo_SUT_Event_cancel, entity},
cellRow := {
//state=idle
{ omit, omit, omit },
//state=initiated
{ {
//DOT: initiated -> canceling [label="i:cancel\n o:CANCEL"]
{refers(f_SIP_step_createCANCEL),{}}
},omit, c_MBT_Qtronic_Demo_SUT_State_canceling},
//state=canceling
{ omit, omit, omit },
//state=established
{ omit, omit, omit },
//state=closing
{ omit, omit, omit }
}
},
{eventToListen := {v_SUT_myBIdx, c_MBT_Qtronic_Demo_SUT_Event_bye, entity},
cellRow := {
//state=idle
{ omit, omit, omit },
//state=initiated
{ omit, omit, omit },
//state=canceling
{ omit, omit, omit },
//state=established
{ {
//DOT: established -> closing [label="i:bye\n o:BYE"]
{refers(f_SIP_step_createBYE),{}}
},omit, c_MBT_Qtronic_Demo_SUT_State_closing},
//state=closing
{ omit, omit, omit }
}
},
{eventToListen := {v_SIP_myBIdx, 200, fsm},
cellRow := {
//state=idle
{ omit, omit, omit },
//state=initiated
{ {
//DOT: initiated -> established [label="i:200\n o:ACK"]
{refers(f_SIP_step_createACK),{}}
},omit, c_MBT_Qtronic_Demo_SUT_State_established},
//state=canceling
{ omit, omit, omit },
//state=established
{ omit, omit, omit },
//state=closing
{ {
//DOT: closing -> idle [label="i:200"]
},omit, c_MBT_Qtronic_Demo_SUT_State_idle }
}
},
{eventToListen := {v_SIP_myBIdx, 486, fsm},
cellRow := {
//state=idle
{ omit, omit, omit },
//state=initiated
{ {
//DOT: initiated -> idle [label="i:486\n o:ACK"]
{refers(f_SIP_step_createACK),{}}
},omit, c_MBT_Qtronic_Demo_SUT_State_idle},
//state=canceling
{ omit, omit, omit },
//state=established
{ omit, omit, omit },
//state=closing
{ omit, omit, omit }
}
},
{eventToListen := {v_SIP_myBIdx, 487, fsm},
cellRow := {
//state=idle
{ omit, omit, omit },
//state=initiated
{ omit, omit, omit },
//state=canceling
{ {
//DOT: canceling -> idle [label="i:487\n o:ACK"]
{refers(f_SIP_step_createACK),{}}
},omit, c_MBT_Qtronic_Demo_SUT_State_idle},
//state=established
{ omit, omit, omit },
//state=closing
{ omit, omit, omit }
}
},
{eventToListen := {v_SIP_myBIdx, c_SIP_eventIdx_BYE, fsm},
cellRow := {
//state=idle
{ omit, omit, omit },
//state=initiated
{ omit, omit, omit },
//state=canceling
{ omit, omit, omit },
//state=established
{ {
//DOT: canceling -> idle [label="i:487\n o:ACK"]
{refers(f_SIP_step_handleBYE), {}},
{refers(f_SIP_step_createResponse),{c_status_200OK_idx}}
},omit, c_MBT_Qtronic_Demo_SUT_State_idle},
//state=closing
{ omit, omit, omit }
}
},
{eventToListen := {v_SIP_myBIdx, c_SIP_eventIdx_UACTransactionTimeout, fsm},
cellRow := {
//state=idle
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=initiated
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=canceling
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=established
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=closing
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit }
}
},
{eventToListen := {v_SIP_myBIdx, c_SIP_eventIdx_UASTransactionTimeout, fsm},
cellRow := {
//state=idle
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=initiated
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=canceling
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=established
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit },
//state=closing
{ { {refers(f_MBT_Qtronic_Demo_SUT_stepSendTimeoutIndication), {}} }, omit, omit }
}
}//row
}//table
}//fsm
//DOT: }
}
}