Commit 4f2e0d82 authored by pintar's avatar pintar
Browse files

changes due to week 41

parent cda31750
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -232,6 +232,10 @@ module LibSip_PIXITS
	  */
	  boolean     PX_SIP_REGISTRATION := false;

	  /** @desc	integer for the minimun SIP user registration expires-value
	  */
	  integer     PX_SIP_REGISTRATION_exp_min := 3600;

	  /** @desc	charstring for REGISTRAR domain
	  */
	  charstring  PX_SIP_SUT_REGISTRAR_DOMAIN := "172.27.16.115";
+8 −1
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ group SimpleConstants
	  const integer c_CRlen := 2; // length of new line (0d0a)

	  const GenericParam c_Integrity_protected_yes := {"Integrity protected","yes"}
	  const GenericParam c_Integrity_protected_no := {"Integrity protected","no"}

} //end group SimpleConstants

@@ -371,6 +372,7 @@ group SubTypes{// Subtypes
		 
		// [3455]
		P_ACCESS_NETWORK_INFO_E,
		P_ASSOCIATED_URI_E,
		P_CALLED_PARTY_E,
		P_CHARGING_FUNCTION_ADDRESSES_E,
		P_CHARGING_VECTOR_E,
@@ -1138,7 +1140,11 @@ group SubTypes{// Subtypes
		  NameAddr nameAddr,
		  SemicolonParam_List genericParams optional
	  }
	  
	  //[3455/5.1]
	  type record PAssociatedURI {
		FieldName fieldName(P_ASSOCIATED_URI_E),
		NameAddrParam_List nameAddrList
	  }	  
	  //[3455/5.2]
	  type record PCalledPartyID {
		  FieldName fieldName(P_CALLED_PARTY_E),
@@ -1282,6 +1288,7 @@ group SubTypes{// Subtypes
        Organization		organization optional,
		PAccessNetworkInfo 	pAccessNetworkInfo optional, // 3455
		PAssertedID 		pAssertedID optional, // 3325
		PAssociatedURI		pAssociatedURI optional, // 3455
		Path 				path optional, // 3327
		PCalledPartyID 		pCalledPartyID optional, // 3455
		PChargingFunctionAddresses pChargingFunctionAddresses optional, // 3455
+198 −6
Original line number Diff line number Diff line
@@ -197,6 +197,94 @@ group ParameterOperations {
	  return v_result;
	}

	/**
	 * 
	 * @desc  Function to calculate credentials for request that has an empty
	 * entity body such as a REGISTER message. NO RESPONSE value to cause an error!
	 * @param p_userprofile to get important parameters
	 * @param p_method (can be "REGISTER", "INVITE",....)
	 * @param p_challenge parameter from 4xx response
	 * @return Credentials field
	 * @verdict 
	 */
	function f_calculatecCredentials_wo_response(in SipUserProfile p_userprofile, in charstring p_method, 
		in CommaParam_List p_challenge) return Credentials
	{
	  var Credentials v_result;
      
	  var charstring v_nonce := "";
      
	  // Use a fixed client nonce.
	  var charstring v_cnonce := "1317265";
      
	  // RFC 2617 3.2.2 username:
	  // The name of user in the specified realm.
	  var charstring v_username := p_userprofile.privUsername;
      
	  var charstring v_realm;
      
	  // RFC 2617 3.2.2.2 passwd:
	  // A known shared secret, the password of user of the specified
	  // username.
	  var charstring v_passwd := p_userprofile.passwd;
      
	  var charstring v_algorithm;
      
	  // Use a fixed nonce count.
	  const charstring c_nonceCount := "00000002";

	  var charstring v_qop := p_userprofile.qop;
      
	  var charstring v_uri := c_sipScheme & ":" & p_userprofile.registrarDomain;
      
	  // MD5 hash of empty entity body.
	  const charstring c_hEntity := "d41d8cd98f00b204e9800998ecf8427e";
      
	  var charstring v_response;
	  var charstring v_opaque;
      
      
	  // extract nonce, realm, algorithm, and opaque from challenge
      
	  v_nonce := f_extractParamValueFromChallenge(p_challenge, "nonce"); 
	  v_realm := f_extractParamValueFromChallenge(p_challenge, "realm"); 
	  v_algorithm := f_extractParamValueFromChallenge(p_challenge, "algorithm");
	  v_opaque := f_extractParamValueFromChallenge(p_challenge, "opaque");
      
	  // calculate a digest response for the Authorize header
	  v_response := calculateDigestResponse(
		v_nonce,
		v_cnonce,
		v_username,
		v_realm,
		v_passwd,
		v_algorithm,
		c_nonceCount,
		p_method,
		v_qop,
		v_uri,
		c_hEntity);
      
	  // Construct credentials for an Authorization field of a request.
	  v_result :=
	  {
		digestResponse :=
		{
		  { id := "Digest username", paramValue := v_username },
		  { id := "realm", paramValue := v_realm },
		  { id := "nonce", paramValue := v_nonce },
		  { id := "uri", paramValue := v_uri },
//		  { id := "response", paramValue := v_response }, // not included to cause an error
		  { id := "algorithm=md5", paramValue := omit }, // algorithm is not enclosed to " characters
		  { id := "cnonce", paramValue := v_cnonce },
		  { id := "opaque=""""", paramValue := omit }, // already enclosed to " characters
		  { id := "qop="&v_qop, paramValue := omit },//qop
		  { id := "nc="&c_nonceCount, paramValue := omit }//nonceCount
		}
	  };
      
	  return v_result;
	}

	/**
	 * 
@@ -903,6 +991,38 @@ group SetHeaders {
				
	}// end function f_setHeaders_2ndREGISTER

	/**
	 * 
	 * @desc function sets via, cseq and authorization header for the next outgoing (protected) REGISTER
	 * NO response in Authorization header to cause an error
	 * @verdict 
	 */
	function f_setHeaders_2ndREGISTER_wo_response() runs on SipComponent
	{
	  var CommaParam_List v_challenge;
		
	  vc_branch := c_brenchCookie & f_getRndTag();

	  vc_via_REG :={
		fieldName := VIA_E,
		viaBody 	 := {valueof(m_ViaBody_currIpaddr(vc_branch, vc_userprofile))}
	  };
	  
	  // Extract challenge and calculate credentials for a response.
	  v_challenge := vc_response.msgHeader.wwwAuthenticate.challenge.otherChallenge.authParams;
	            
	  // Increment CSeq sequence number 
	  vc_cSeq.seqNumber := vc_cSeq.seqNumber + 1;
      
	  // Prepair right answer      
	  vc_authorization := 
		   {
			 fieldName := AUTHORIZATION_E,
			 body := f_calculatecCredentials_wo_response(vc_userprofile, "REGISTER", v_challenge)
		   }
				
	}// end function f_setHeaders_2ndREGISTER_wo_response

	/**
	 * 
	 * @desc function sets via, cseq and authorization header with different private name for the next outgoing (protected) REGISTER
@@ -1038,8 +1158,40 @@ group SetHeaders {
		addressField := vc_caller_To.addressField,
		fromParams := vc_caller_To.toParams};
      
	} // end f_setHeadersOnReceiptOfINVITE
	} // end f_setHeadersOnReceiptOfREGISTER

	/**
	 * 
	 * @desc This function reads all necessary headers from the received SUBSCRIBE message and generate the tag for the answer
	 * @param p_Request SUBSCRIBE that has been received
	 */
	function f_setHeadersOnReceiptOfSUBSCRIBE(Request p_Request)
	runs on SipComponent {

	  f_setHeadersOnReceiptOfRequest(p_Request);
	
	  vc_callId := p_Request.msgHeader.callId;
	  vc_caller_From := vc_from;
	  f_addTagInTo(vc_to);
	  vc_caller_To := vc_to;
	  vc_requestUri := p_Request.requestLine.requestUri;
      
	  vc_cancel_To := p_Request.msgHeader.toField;
      
	  if (ispresent(p_Request.msgHeader.contact)) {
		vc_reqHostPort := f_getContactAddr(p_Request.msgHeader.contact.contactBody.contactAddresses[0]);
		}
      
	  // update callee information and pick up tag if the call need to be canceled
	  vc_callee_To := {fieldName := TO_E,
		addressField := vc_caller_From.addressField,
		toParams := vc_caller_From.fromParams};
      
	  vc_callee_From := {fieldName := FROM_E,
		addressField := vc_caller_To.addressField,
		fromParams := vc_caller_To.toParams};
      
	} // end f_setHeadersOnReceiptOfSUBSCRIBE
   
	/**
	 * 
@@ -1326,6 +1478,26 @@ group AwaitingMessage {
		}		
	}
	
	/**
	 * 
	 * @desc function awaits SUBSCRIBE
	 * @param p_register expected SUBSCRIBE request
	 */	
	function f_awaitingSUBSCRIBE(in template SUBSCRIBE_Request p_register) runs on SipComponent
	{
		var Request	v_request;
      
		tc_resp.start(PX_SIP_TRESP);
		alt
		{
		  [] SIPP.receive(p_register)-> value v_request sender vc_sent_label
			{
			  tc_resp.stop;
			  f_setHeadersOnReceiptOfSUBSCRIBE(v_request);
			}
		}		
	}
	
	/**
	 * 
	 * @desc function awaits REGISTER and sends a 200 OK response
@@ -1640,7 +1812,7 @@ group AwaitingMessage {
	*  @desc await NOTIFY request
	*		 reply with 200 OK
	*/
	function f_awaitingNOTIFY_sendReply() runs on SipComponent
	function f_awaitingNOTIFY_sendReply(in template NOTIFY_Request p_MSG) runs on SipComponent
	{
		var NOTIFY_Request	v_MSG;
      
@@ -1896,8 +2068,9 @@ group Registration {
	 * @desc  registration and authentication with MD5
	 * @param p_cSeq_s		cseq parameter 
	 * @param p_register	register template
	 * @param p_auth		flag indicating if authentication is needed
	 */
	function f_Registration(inout CSeq p_cSeq_s, template REGISTER_Request p_register) runs on SipComponent
	function f_Registration(inout CSeq p_cSeq_s, template REGISTER_Request p_register, in boolean p_auth) runs on SipComponent
	{
	  var REGISTER_Request v_request := valueof(p_register);
	  
@@ -1907,7 +2080,7 @@ group Registration {
		f_SendREGISTER(v_request); //LibSip
		
		//awaiting of 401 and sending 2nd REGISTER and awaiting 200 OK REGISTER
		if (PX_SIP_REGISTER_AUTHENTICATION_ENABLED)
		if (p_auth)
		{
		  // receiving 401 Unauthorized response.
		  // and Re-send REGISTER request with Authorization header
@@ -1943,6 +2116,7 @@ group Registration {
	  };
	}//end function f_Registration


	/**
	 * 
	 * @desc remove registration
@@ -2030,7 +2204,7 @@ group Registration {
		  f_awaitingOkResponse(p_cSeq_s);
		  
		  //await NOTIFY and send reply 200 OK
		  f_awaitingNOTIFY_sendReply();
		  f_awaitingNOTIFY_sendReply(mw_NOTIFY_Request_Base(vc_callId));
	  
		}//end function f_Subscription

@@ -2067,7 +2241,7 @@ group Preambles {
		f_SIP_preamble_woREG(p_userprofile, p_cSeq_s);
		
		//Registration, Awaiting
		f_Registration(p_cSeq_s, p_register);
		f_Registration(p_cSeq_s, p_register, PX_SIP_REGISTER_AUTHENTICATION_ENABLED);
	}	
	
}// end group Preambles
@@ -2107,6 +2281,24 @@ group Postambles {
	  }
	} // end function f_terminateCall

	function f_cancelCall(template CANCEL_Request p_request)
	runs on SipComponent
	{
	  // This function is called to bring back the IUT in idle condition
	  // in case of errors or unexpected behaviour.
      
	  // Sending of a CANCEL request with the same Cseq
	  f_SendCANCEL(p_request);
	  tc_resp.start(PX_SIP_TRESP);
	  alt
	  {
		[] SIPP.receive	(mw_Response_Base(c_statusLine200, vc_callId, vc_cSeq))
		  {
			tc_resp.stop;
		  }
	  }
	}

} // end group Postambles

group DefaultsTestStep
+124 −2
Original line number Diff line number Diff line
@@ -49,6 +49,16 @@ module LibSip_Templates
			reasonParams := m_ReasonParams(p_cause,p_text)
		};

		template RouteBody mw_routeBody (template SipUrl p_sipurl):=
		{
			nameAddr :=
			{
				displayName := *,
				addrSpec := p_sipurl
			},
			rrParam := *
		}

		template SentProtocol m_SentProtocol (charstring p_protocol) :=
		{protocolName := c_sipName,
		  protocolVersion:= c_sipVersion,
@@ -171,12 +181,24 @@ module LibSip_Templates
		template GenericParam m_Cause (template charstring p_cause):=
			{id:="cause", paramValue:=p_cause}

		template Authorization m_Authorization (template Credentials p_Credentials):=
		{
		  fieldName := AUTHORIZATION_E,
		  body := p_Credentials
		}
		
		template Authorization m_Authorization_digest (template CommaParam_List p_CommaParam_List):=
		{
		  fieldName := AUTHORIZATION_E,
		  body := {digestResponse := p_CommaParam_List}
		}

		template Authorization m_add_Authorization_digest (in Authorization p_auth, template CommaParam_List p_CommaParam_List):=
		{
		  fieldName := AUTHORIZATION_E,
		  body := {digestResponse := f_merge_CommaParam_List(p_auth.body.digestResponse,valueof(p_CommaParam_List))}
		}

		template Authorization m_Authorization_other :=
		{
		  fieldName := AUTHORIZATION_E,
@@ -213,6 +235,22 @@ module LibSip_Templates
		  } //end contactBody
		}//end m_Contact


		template Contact m_Contact_profile_expires(in SipUserProfile p_userprofile, in charstring p_expires) :=
		{
		  fieldName := CONTACT_E,
		  contactBody :=
		  {
			contactAddresses :=
			{
			  {
				addressField := { addrSpecUnion := m_SipUrl_contactIpaddr(p_userprofile)},
				contactParams := {{"expires",p_expires}}
			  }
			}
		  } //end contactBody
		}//end m_Contact

		template Event m_Event_conference := 
		{
			fieldName := EVENT_E,
@@ -233,6 +271,12 @@ module LibSip_Templates
			deltaSec := "600000"
		};

		template Expires m_Expires (charstring p_deltaSec):= 
		{
			fieldName := EXPIRES_E,
			deltaSec := p_deltaSec
		};

		template PAssertedID m_PAssertedID(template Addr_Union p_pAssertedIDValue) := 
		{
			fieldName := P_ASSERTED_ID_E,
@@ -302,6 +346,13 @@ module LibSip_Templates
		  toParams := omit
		};


		template From mw_From(template SipUrl p_sipUrl) := {
		  fieldName := FROM_E,
		  addressField := { addrSpecUnion := p_sipUrl},
		  fromParams:= *
		}

		template ViaBody m_ViaBody_currIpaddr(charstring branch_val,in SipUserProfile p_userprofile) :=
		{
		  sentProtocol := m_SentProtocol(PX_SIP_TRANSPORT),
@@ -309,6 +360,19 @@ module LibSip_Templates
		  viaParams:={{id :=c_branchId,paramValue :=branch_val}}
		}
		
		template ViaBody mw_ViaBody_interface(HostPort p_hostport) :=
		{
		  sentProtocol := m_SentProtocol(PX_SIP_TRANSPORT),
		  sentBy:={host:=p_hostport.host, portField:= p_hostport.portField},
		  viaParams:=*
		}

		template Via mw_Via(template ViaBody p_viabody) :=
		{
		  fieldName := VIA_E,
		  viaBody:= superset(p_viabody)
		}
		
		template CallId mw_CallId_any :=
		{
		  fieldName := CALL_ID_E,
@@ -333,6 +397,17 @@ module LibSip_Templates
			reasonValues := {m_ReasonValue(int2str(p_cause),?)}
		};

		template RecordRoute mw_recordroute (template RouteBody p_routeBody):=
		{   
			fieldName := RECORD_ROUTE_E,
			routeBody := superset(p_routeBody)
		};
		
		template Route mw_route (template RouteBody_List p_routeBody):=
		{   
			fieldName := ROUTE_E,
			routeBody := p_routeBody
		};
		
	} // end of group HeaderFieldTemplates

@@ -381,6 +456,7 @@ group dummy_templates {
		organization := omit,
		pAccessNetworkInfo := omit, // RFC3455
		pAssertedID := omit,
		pAssociatedURI := omit,
		path := omit, // RFC3327
		pCalledPartyID := omit, // RFC3455
		pChargingFunctionAddresses := omit, // RFC3455
@@ -465,6 +541,7 @@ group dummy_templates {
		organization := *,
		pAccessNetworkInfo := *, // RFC3455
		pAssertedID := *,
		pAssociatedURI := *,
		path := *, // RFC3327
		pCalledPartyID := *, // RFC3455
		pChargingFunctionAddresses := *, // RFC3455
@@ -891,7 +968,7 @@ group base_templates{
		}
		
		template REGISTER_Request m_REGISTER_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
			From p_from, To p_to, Via p_via, Contact p_contact, Authorization p_authorization) modifies m_REGISTER_Dummy :=
			From p_from, To p_to, Via p_via, Contact p_contact, template Authorization p_authorization) modifies m_REGISTER_Dummy :=
		{
			requestLine	:=
			{
@@ -1254,6 +1331,26 @@ group response_send {

group response_receive {

	template Response mw_Response_Expires (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template DeltaSec p_deltaSec) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			expires := {fieldName := EXPIRES_E, deltaSec := p_deltaSec}
	  }
	}

	template Response mw_Response_Via (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template Via p_via) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			via := p_via
	  }
	}
	
} // end group response_receive	

	
@@ -1642,6 +1739,31 @@ group TemplatePreparationFunctions {
		
  } // end group GiveHeaders
  
group others {  

/*
 * 
 * @desc function combines two comma parameter lists
 * @param p_list1 first list
 * @param p_list2 second list
 * @return comma parameter list that contains parameters from both input lists
 * @verdict 
 */

  function f_merge_CommaParam_List(CommaParam_List p_list1, CommaParam_List p_list2) return template CommaParam_List
  {	var CommaParam_List p_result;
  	var integer limit1 := sizeof(p_list1);
  	for (var integer i:=0; i<limit1; i:=i+1) {
  		p_result[i] := p_list1[i]
  	};
	for (var integer i:=limit1; i<limit1+sizeof(p_list2); i:=i+1) {
		p_result[i] := p_list2[i]
	};
	return p_result
  }
  
} // end group others

} //group TemplatePreparationFunctions
	

+19 −0
Original line number Diff line number Diff line
/*
 *	@author 	STF 346
 *  @version    $Id$
 *	@desc		This module provides the types used by the test component 
 *              for SIP-IMS tests. Module become from STF306 and STF334-336
 */

module LibSip_TemplatesDerived
{
	//LibSip
	import from LibSip_SIPTypesAndValues all;
	import from LibSip_SDPTypes all;
	import from LibSip_PIXITS all;
	
	group message_send {
		
	}

} // end module LibSip_Templates