LibIms_Steps.ttcn 47.6 KB
Newer Older
		 * 
		 * @desc  Sets variables and default initialization for user profile and handle registration and authentication with MD5 
		 *			(basic registration template)
		 * @param p_userprofile   	user profile of call
		 * @param p_cSeq_s		  	cseq parameter
		function f_IMS_preamble_withRegistrationBasic (in integer p_userprofile, inout CSeq p_cSeq_s) runs on ImsComponent
		{
		
			//Variables & defaults initialization
			f_IMS_preamble_woRegistration(p_userprofile, p_cSeq_s);
	
			//Preamble
   			f_Registration_IMS(p_cSeq_s, PX_SIP_REGISTER_AUTHENTICATION_ENABLED);
			f_setHeaders_SUBSCRIBE(p_cSeq_s);
			f_Subscription(p_cSeq_s, m_SUBSCRIBE_Request_UE(vc_requestUri, vc_callId, p_cSeq_s, vc_from, vc_to, vc_via, vc_contact, vc_route_REG));
		}			
		
	} // end group preambles
	
	group postambles {
		/*
		*
		* @desc  Sets variables and default initialization for user profile and handle deregistration
		* @param p_cSeq_s		  	cseq parameter
		*/
	 	function f_IMS_postamble_withDeRegistration (CSeq p_CSeq) runs on ImsComponent {
	 		f_RemoveRegistration(p_CSeq); // TODO check if applicable for IMS
	 		
    		f_terminate_component();
	 	}
		
		function f_SIP_postamble_IMS1_withoutRegistration () runs on ImsComponent
		{f_terminate_component()};
			
		function f_IMS_postamble_withoutDeRegistration () runs on ImsComponent
		{f_terminate_component()};
  
  		function f_SIP_postamble_IMS1_awaitDeRegistration () runs on ImsComponent
		{
			//Awaiting 1st REGISTER	
			f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);

			// 401 response
			f_sendResponse(m_Response_WWWauthenticate_IMS(c_statusLine401,
				vc_callId, vc_cSeq,vc_caller_From, vc_caller_To, vc_via,
				m_wwwAuthenticate(f_calculatecChallenge_forWWWAuthorization
										(PX_IMS_SUT_UE1_QOP,vc_authorization.body[0].digestResponse)))
				);

			//Awaiting 2nd REGISTER	with authorization header
			f_awaitingREGISTER(mw_REGISTER_authorizedRequest_IMS(m_Authorization_digest(mw_digestResponse(c_Integrity_protected_yes))));

			// 200OK to complete the request
			vc_contact := vc_request.msgHeader.contact;
			vc_contact.contactBody.contactAddresses[0].contactParams := {{"expires",int2str(0)}};
			f_sendResponse(m_Response_2xxonREGISTER_IMS(c_statusLine200,vc_callId, vc_cSeq,vc_callee_From, vc_callee_To, vc_via,vc_contact,f_initSipUrl(c_userProfile_SCSCFwithHomeUE)));

			f_terminate_component()
		};
		
  		function f_IMS_postamble_awaitDeRegistration () runs on ImsComponent
		{
			//Awaiting 1st REGISTER	
			f_awaitingREGISTER(mw_REGISTER_unauthorizedRequest_IMS);

			// 401 response
			f_sendResponse(m_Response_WWWauthenticate_IMS(c_statusLine401,
				vc_callId, vc_cSeq,vc_caller_From, vc_caller_To, vc_via,
				m_wwwAuthenticate(f_calculatecChallenge_forWWWAuthorization
										(PX_IMS_SUT_UE1_QOP,vc_authorization.body[0].digestResponse)))
				);

			//Awaiting 2nd REGISTER	with authorization header
			f_awaitingREGISTER(mw_REGISTER_authorizedRequest_IMS(m_Authorization_digest(mw_digestResponse(c_Integrity_protected_yes))));

			// 200OK to complete the request
			vc_contact := vc_request.msgHeader.contact;
			vc_contact.contactBody.contactAddresses[0].contactParams := {{"expires",int2str(0)}};
			f_sendResponse(m_Response_2xxonREGISTER_IMS(c_statusLine200,vc_callId, vc_cSeq,vc_callee_From, vc_callee_To, vc_via,vc_contact,f_initSipUrl(c_userProfile_SCSCFwithHomeUE)));

			f_terminate_component()
		};

		function f_SIP_postamble_UE1_withoutRegistration () runs on ImsComponent
		{f_terminate_component()};
			
		function f_SIP_postamble_UE2_withoutRegistration () runs on ImsComponent
		{f_terminate_component()};
		
		/**
		 * 
		 * @desc sends BYE and awaits response
		 * @param p_CallId parameter for outgoing BYE
		 * @param p_cSeq parameter for outgoing BYE
		 * @param p_from parameter for outgoing BYE
		 * @param p_to parameter for outgoing BYE
		 * @param p_reqHostPort parameter for outgoing BYE
		 */
		function f_terminateCall_IMS(SipUrl p_requestUri, CallId p_CallId, inout CSeq p_cSeq, From p_from,
		  template To p_to) runs on ImsComponent
		{
		  // Sending of a BYE request to release the call and expect a final response
		  f_SendBYE(m_BYE_Request_IMS(p_requestUri, p_CallId, p_cSeq, p_from, valueof(p_to), vc_via, vc_route));
      
		  tc_resp.start(PX_SIP_TRESP);
		  alt
		  {
			[] SIPP.receive	(mw_Response_Base(mw_statusLine1xx, p_CallId, p_cSeq))
			  {
				repeat;
			  }
			[] SIPP.receive	(mw_Response_Base(mw_statusLineFinal, p_CallId, p_cSeq))
			  {
				tc_resp.stop;
			  }
			// timeout should be handled in default_alt_step
		  }
		} // end function f_terminateCall
		
		
		/**
		 * 
		 * @desc  sends BYE and awaits response
		 * @param p_CallId parameter for outgoing BYE
		 * @param p_cSeq parameter for outgoing BYE
		 * @param p_from parameter for outgoing BYE
		 * @param p_to parameter for outgoing BYE
		 * @param p_reqHostPort parameter for outgoing BYE
		 */
		function f_terminateCall_UE(SipUrl p_requestUri, CallId p_CallId, inout CSeq p_cSeq, From p_from,
		  template To p_to) runs on ImsComponent
		{
poglitsch's avatar
poglitsch committed
		  LibSip_Steps.f_setHeadersBYE(p_cSeq);
		  // Sending of a BYE request to release the call and expect a final response
		  f_SendBYE(m_BYE_Request_UE(p_requestUri, p_CallId, p_cSeq, p_from, valueof(p_to), vc_via, vc_route));
      
		  tc_resp.start(PX_SIP_TRESP);
		  alt
		  {
			[] SIPP.receive	(mw_Response_Base(mw_statusLine1xx, p_CallId, p_cSeq))
			  {
				repeat;
			  }
			[] SIPP.receive	(mw_Response_Base(mw_statusLineFinal, p_CallId, p_cSeq))
			  {
				tc_resp.stop;
			  }
			// timeout should be handled in default_alt_step
		  }
		} // end function f_terminateCall_UE
		
		}
	group defaults {
	}
} // module LibIms_Steps