Skip to content
LibSip_Templates.ttcn 98 KiB
Newer Older
3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317
		/**
		* 
		* @desc Calculation of XML length
		* @param p_mb contain XML message
		* @return xml_length
		*/
		function f_XMLlength(XMLMessage p_mb, boolean p_ext_func) return integer
		{
			var integer v_result:=0;
			
			if ( p_ext_func){
				v_result := fx_calculateXMLMessageLen(p_mb);
			}else{
				if (ispresent(p_mb.header)){
					v_result := f_XMLHeader_Length(p_mb.header);
				}
				
				//false given, because decision of external function usage is done in first if statement
				v_result := v_result + f_XMLBody_Length(p_mb.body, false); 
			}
			return v_result
		} //* f_XMLlength
		
		/**
		* 
		* @desc Calculation of XML header length
		* @param p_mh contain XML header 
		* @return xml_header_length
		*/
		function f_XMLHeader_Length(XmlHeader p_mh) return integer
		{
			var integer v_result:=0;
			
			//*<?xml version="1.0" encoding="UTF-8"?>\n len=39*/
			//* 2 3          1   1          1     1 2 1*/
			
			v_result:=2+3+lengthof(" version=")+1+lengthof(p_mh.version)+1;  //<?xml version="1.0"
			
			if (ispresent(p_mh.encoding)){
				
				v_result:=v_result+lengthof(" encoding=")+1+lengthof(p_mh.encoding)+1;  // encoding="UTF-8"
			}
			
			if (ispresent(p_mh.anyAttributes)){
				for (var integer i:=0; i<sizeof(p_mh.anyAttributes); i:=i+1){
					v_result := v_result + 1 + lengthof(p_mh.anyAttributes[i].name)+ 2 + lengthof(p_mh.anyAttributes[i].val) + 1;
					//vresult + " "(1)+ length(name) + "=\""(2) + length(val) + "\""(1)
				}
			}
			
			v_result:=v_result+2+1; //?>\n
			
			return v_result
		} //* f_XMLHeaderLength
		
		/**
		* 
		* @desc Calculation of XML body length
		* @param p_mb contain XML body
		* @return xml_length
		*/
		function f_XMLBody_Length(XmlBody p_mb, boolean p_ext_func) return integer
		{
			var integer v_result:=0;
			
			if ( p_ext_func){
				v_result := fx_calculateXMLBodyLen(p_mb);
			}else{
				//  assume ConferenceInfo ONLY in the XML message body
				if (ischosen(p_mb.conferenceInfo))
				{ 
					v_result := f_XMLBody_ConferenceInfo_Length(p_mb.conferenceInfo);
				};
				
				//  assume CUG ONLY in the XML message body
				if (ischosen(p_mb.cug))
				{ 
					v_result := f_XMLBody_Cug_Length(p_mb.cug);
				};
				
				//  assume MCID ONLY in the XML message body
				if (ischosen(p_mb.mcid))
				{ 
					v_result := f_XMLBody_Mcid_Length(p_mb.mcid);
				};
				
				//  assume PSTNTransit ONLY in the XML message body
				if (ischosen(p_mb.pstnTransit))
				{ 
					v_result := f_XMLBody_PSTNTransit_Length(p_mb.pstnTransit);
				};
				
				//  assume Simservs ONLY in the XML message body
				if (ischosen(p_mb.simservs))
				{ 
					v_result := f_XMLBody_Simservs_Length(p_mb.simservs);
				};
				
				//  assume CDIV ONLY in the XML message body
				if (ischosen(p_mb.cdivn))
				{ 
					v_result := f_XMLBody_CDIV_Length(p_mb.cdivn);
				};
				
				//  assume ICB ONLY in the XML message body
				if (ischosen(p_mb.icb))
				{ 
					v_result := f_XMLBody_ICB_Length(p_mb.icb);
				};
				
				//  assume OCB ONLY in the XML message body
				if (ischosen(p_mb.ocb))
				{ 
					v_result := f_XMLBody_OCB_Length(p_mb.ocb);
				};
				
				//  assume ResourceLists ONLY in the XML message body
				if (ischosen(p_mb.resourceLists))
				{ 
					v_result := f_XMLBody_ResourceList_Length(p_mb.resourceLists);
				};
				
				//  assume Ims3GPP ONLY in the XML message body
				if (ischosen(p_mb.ims3gpp))
				{ 
					v_result := f_XMLBody_Ims3GPP_Length(p_mb.ims3gpp);
				};
				
				/** Add aditional checks regarding to new variants,
				 *  also implement appropriate function for calculation
				 */
			}
			return v_result
		} //* f_XMLBodyLength
		
		group XMLBodies_calculation{
		
			/**
			* 
			* @desc Calculation of XML ConferenceInfo element length
			* @param p_mb contain XML ConfInfo body
			* @return xml_length
			*/
			function f_XMLBody_ConferenceInfo_Length(Conference_info p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_ConferenceInfo_Length
			
			/**
			* 
			* @desc Calculation of XML CUG element length
			* @param p_mb contain XML CUG body
			* @return xml_length
			*/
			function f_XMLBody_Cug_Length(Cug p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_Cug_Length
			
			/**
			* 
			* @desc Calculation of XML MCID element length
			* @param p_mb contain XML MCID body
			* @return xml_length
			*/
			function f_XMLBody_Mcid_Length(Mcid p_mb) return integer
			{
				var integer v_result:=0;
				
				if (ischosen(p_mb.choice.request)){
				
				}
				
				if (ischosen(p_mb.choice.response)){
				
				}
				
				return v_result
			} //* f_XMLBody_Mcid_Length
			
			/**
			* 
			* @desc Calculation of XML PSTNTransit element length
			* @param p_mb contain XML PSTNTransit body
			* @return xml_length
			*/
			function f_XMLBody_PSTNTransit_Length(PSTN_transit p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_PSTNTransit_Length
			
			/** @desc Calculation of XML Simservs element length
			* @param p_mb contain XML Simservs body
			* @return xml_length
			*/
			function f_XMLBody_Simservs_Length(Simservs p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_Simservs_Length	
			
			/** @desc Calculation of XML CDIV element length
			* @param p_mb contain XML CDIV body
			* @return xml_length
			*/
			function f_XMLBody_CDIV_Length(Comm_div_info p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_CDIV_Length		
			
			/** @desc Calculation of XML ICB length
			* @param p_mb contain XML ICB body
			* @return xml_length
			*/
			function f_XMLBody_ICB_Length(Incoming_communication_barring p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_ICB_Length
			
			/** @desc Calculation of XML OCB length
			* @param p_mb contain XML OCB body
			* @return xml_length
			*/
			function f_XMLBody_OCB_Length(Outgoing_communication_barring p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_OCB_Length
			
			/** @desc Calculation of XML ResourceList length
			* @param p_mb contain XML ResourceList body
			* @return xml_length
			*/
			function f_XMLBody_ResourceList_Length(Resource_lists p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_ResourceList_Length
			
			/** @desc Calculation of XML Ims3GPP length
			* @param p_mb contain XML Ims3GPP body
			* @return xml_length
			*/
			function f_XMLBody_Ims3GPP_Length(Ims_3gpp p_mb) return integer
			{
				var integer v_result:=0;
				//TODO: write function body
				return v_result
			} //* f_XMLBody_Ims3GPP_Length
			
		} //* XMLBodies_calculation
  	
  }//* group XMLlen_calculation

  group MIME_Len_calculation{
		/**
		* 
		* @desc Calculation of MIME length
		* @param p_mb contain MIME message
		* @return xml_length
		*/
		function f_MIMElength(MIME_Message p_mb) return integer
		{
			var integer v_result:=2; //0d0a
			
			v_result := v_result + lengthof(p_mb.boundary) + 2/*0d0a*/;
			
			for (var integer i:=0; i<sizeof(p_mb.mimeEncapsulatedList); i:=i+1){
				
				v_result := v_result + lengthof("Content-Type: ")+ lengthof(p_mb.mimeEncapsulatedList[i].content_type) + 2/*0d0a*/ ;
				
				if (ispresent(p_mb.mimeEncapsulatedList[i].content_disposition)){
					v_result := v_result + lengthof("Content-Disposition: ")+ lengthof(p_mb.mimeEncapsulatedList[i].content_disposition) + 2/*0d0a*/ ;
				}
				
				//v_result := v_result +2/*0d0a*/; ??? to check
				
				//		assume SDP_Message ONLY in the message body
        		if (ischosen(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.sdpMessageBody))
        		{ 
        			v_result := v_result + f_SDPlength(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.sdpMessageBody);
        		};
				
				//  assume XML_Body ONLY in the message body
            	if (ischosen(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.xmlBody))
            	{ 
            		v_result := v_result + f_XMLBody_Length(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.xmlBody, USE_FX_FOR_XML_LENGTH );
            	};
		
				//assume XML_Message ONLY in the message body
				if (ischosen(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.xmlMessage))
				{ 
					v_result := v_result + f_XMLlength(p_mb.mimeEncapsulatedList[i].mime_encapsulated_part.xmlMessage, USE_FX_FOR_XML_LENGTH );
				};
                
                //v_result := v_result +2/*0d0a*/; ??? to check
			}
			
			//v_result := v_result +2/*0d0a*/; ??? to check
			
			return v_result
		} //* f_MIMElength
  	
  }//* group MIMElen_calculation
  group TextPlain_Len_calculation{
		/**
		* 
		* @desc Calculation of messagebody-textplain type length
		* @param p_mb contain textplain message
		* @return lenght
		*/
		function f_TextPlainLength(MessageBody p_mb) return integer
		{
			var integer v_result:=0;

			v_result:=v_result+lengthof(p_mb.textplain);
			
			return v_result;
		}//* end function f_TextPlainLength
		
  }//*end group TextPlainLen_calculation

  }//*group MessageBody_Calculation


  group GiveHeaders {
	/**
	 * 
	 * @desc Return component variable of recordRoute header if vc_boo_recordRoute is true
	 * @return component variable of recordRoute header
	 */

	function f_recordroute() runs on SipComponent return template RecordRoute
	{
	  template RecordRoute v_recordRoute := omit;
	  if (vc_boo_recordRoute)
		  {return vc_recordRoute}
	  else {return(v_recordRoute)} //* TODO: RecordRoute is not OPTIONAL!!! Check IT!
	
	/**
	 * 
	 * @desc Return component variable of Route header if vc_boo_route is true
	 * @return component variable of recordRoute header
	 */	
	function f_route() runs on SipComponent return template Route
	  template Route v_route := omit;
	  if (vc_boo_route)
		  {return vc_route} //*  TODO: Route header need to be in reverse order than RecordRoute, question of return value - RecordRoute 
	  else {return(v_route)} //* TODO: Route is not OPTIONAL!!! Check IT!
  } //*  end group GiveHeaders
reinaortega's avatar
reinaortega committed
 * 
 * @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 template 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:=0; i<sizeof(p_list2); i:=i+1) {
		p_result[i+limit1] := p_list2[i]
} //* group TemplatePreparationFunctions
} //*  end module LibSip_Templates