LibSip_Templates.ttcn 95.6 KB
Newer Older
schmitting's avatar
schmitting committed
/*
 *  @author   STF 346, STF366, STF368, STF369
 *  @version  $Id$
 *	@desc     This module defines SIP Templates for message, header, and 
 *            structured types. <br>
 *            Note that any changes made to the definitions in this module
 *            may be overwritten by future releases of this library
 *            End users are encouraged to contact the distributers of this  
 *            module regarding their modifications or additions
 *  @remark   Any additions to the templates shall follow the design rules
 *            and always modify base templates only;
 *            Existing templates shall not be changed or removed -
 *            change requests shall be made to http://t-ort.etsi.org
module LibSip_Templates
{
	//LibSip
	import from LibSip_SIPTypesAndValues all;
	import from LibSip_SDPTypes all;
	import from LibSip_Interface all;
	import from LibSip_PIXITS all;
	import from LibSip_XMLTypes all;
	
	group ModuleParameters {
	
	    modulepar boolean MB_LENGTH_FROM_ENCVAL:=true; //* to get length of message body from ecoded value
	    modulepar boolean USE_FX_FOR_XML_LENGTH:=true; //* To use external functions for calculation of XML message/body length
	    
	}//* group ModuleParameters
	
	group SubFields
	{

		template Addr_Union m_AddrUnion_NameAddr(template NameAddr p_nameAddr) :=
		{
		  nameAddr := p_nameAddr
		}

		template Addr_Union m_AddrUnion_DisplayAndSipUrl(template charstring p_displayName, template SipUrl p_addrSpec) :=
		{
		  nameAddr := m_CallingAddr(p_displayName, p_addrSpec)
		}
		
		template NameAddr m_CallingAddr(template charstring p_displayName, template SipUrl p_addrSpec) :=
		{
		  displayName := p_displayName,
		  addrSpec := p_addrSpec
		}		

		template CommaParam_List mw_digestResponse(in GenericParam p_genericParam) :=
		{
		  *,p_genericParam,* //* c_Integrity_protected_yes
		}	

		template SemicolonParam_List m_cpc :=
		{{"cpc",PX_SIP_ISUP_CPC_VALUE}};

		template SemicolonParam_List m_ReasonParams
			(template charstring p_cause, template charstring p_text) :=
		{m_Cause(p_cause),m_Text(p_text)};
				
		template ReasonValue m_ReasonValue
			(template charstring p_cause, template charstring p_text) :=
		{		  
			token := "Q.850",
			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,
		  transport:= p_protocol};

		template SipUrl m_SipUrl_currDomain(in SipUserProfile p_userprofile) :=  	//*  SIP-URL of the test system on SIP side
		  scheme := c_sipScheme,  		//*  contains "sip"
		  userInfo := 			//*  optional
			userOrTelephoneSubscriber := p_userprofile.publUsername,//*  charstring
			password := omit		//*  optional charstring
			host := p_userprofile.homeDomain,	//*  hostname, IPv4 or IPv6 as a charstring
			portField := omit	//* p_userprofile.currPort	//* optional integer
		  },
		  urlParameters := omit,
		  headers := omit
		}

		template SipUrl m_SipUrl_contactIpaddr(in SipUserProfile p_userprofile) :=  	//*  SIP-URL of the test system on SIP side
		  scheme := c_sipScheme,  		//*  contains "sip"
		  userInfo := 			//*  optional
			userOrTelephoneSubscriber := p_userprofile.publUsername,//*  charstring
			password := omit		//*  optional charstring
			host := p_userprofile.contactIpaddr,	//*  hostname, IPv4 or IPv6 as a charstring
			portField := p_userprofile.contactPort	//* optional integer
		  },
		  urlParameters := omit,
		  headers := omit
		}

		template SipUrl m_SipUrl_contactIpaddrAndCpc(in SipUserProfile p_userprofile) :=  	//*  SIP-URL of the test system on SIP side
				scheme := c_sipScheme,  		//*  contains "sip"
				userInfo := 			//*  optional
			userOrTelephoneSubscriber := p_userprofile.publUsername & "; cpc=" & PX_SIP_ISUP_CPC_VALUE,//*  charstring
			password := omit		//*  optional charstring
			host := p_userprofile.contactIpaddr,	//*  hostname, IPv4 or IPv6 as a charstring
			portField := p_userprofile.contactPort	//* optional integer
				},
				urlParameters := omit,
				headers := omit
		}

		template SipUrl m_SipUrl_currIpaddr(in SipUserProfile p_userprofile) :=  	//*  SIP-URL of the test system on SIP side
		  scheme := c_sipScheme,  		//*  contains "sip"
		  userInfo := 			//*  optional
			userOrTelephoneSubscriber := p_userprofile.publUsername,//*  charstring
			password := omit		//*  optional charstring
			host := p_userprofile.currIpaddr,	//*  hostname, IPv4 or IPv6 as a charstring
			portField := p_userprofile.currPort	//* optional integer
		  },
		  urlParameters := omit,
		  headers := omit
		} 
   
		template SipUrl m_SipUrl_Anonymous :=  	//*  SIP-URL with a calles party number
		  scheme := c_sipScheme,  		//*  contains "sip"
		  userInfo := 			//*  optional
			userOrTelephoneSubscriber := "Anonymous",//*  charstring
			password := omit		//*  optional charstring
			host := "Anonymous.invalid",	//*  hostname, IPv4 or IPv6 as a charstring
			portField := omit	//* optional integer
		  },
		  urlParameters := omit,
		  headers := omit
		};
		
		template SipUrl m_TelUrl_publUser(in SipUserProfile p_userprofile) :=  	//*  SIP-URL of the test system on SIP side
		  scheme := c_telScheme,  		//*  contains "tel"
		  userInfo := 			//*  optional
			userOrTelephoneSubscriber := p_userprofile.publUsername,//*  charstring
			password := omit		//*  optional charstring
			host := omit,	//*  hostname, IPv4 or IPv6 as a charstring
			portField := omit	//* p_userprofile.currPort	//* optional integer
		  },
		  urlParameters := omit,
		  headers := omit
		}

	
		template SipUrl mw_TelSip_unavailableInvalidUri :=
		{
				scheme  := (c_telScheme,c_sipScheme),
				userInfo := {userOrTelephoneSubscriber:="unavailable", password:=omit},
				hostPort := {host:="anonymous.invalid", portField:=c_defaultSipPort},
				urlParameters := omit,
				headers := omit
		};		

	
		template SipUrl mw_TelSip_unavailableUri (charstring p_host):=
		{
				scheme  := (c_telScheme,c_sipScheme),
				userInfo := {userOrTelephoneSubscriber:="unavailable", password:=omit},
				hostPort := {host:=p_host, portField:=c_defaultSipPort},
				urlParameters := omit,
				headers := omit
		};		

		template SipUrl mw_SipUrl_Number(charstring p_number) :=  	//*  SIP-URL with a calling party number
		  scheme := c_sipScheme,  		//*  contains "sip"
		  userInfo:= {userOrTelephoneSubscriber:=p_number, password:=*},
		  hostPort := ?,
		  urlParameters := *,
		  headers := *
		};

		template SipUrl mw_TelSipUrl_Number(template charstring p_number) :=  	//*  SIP-URL with a calling party number
				scheme := (c_telScheme,c_sipScheme), //*  contains "sip" or "tel"
				userInfo:= {userOrTelephoneSubscriber:=p_number, password:=*}, //*  nat or int format
				hostPort := ?,
				urlParameters := *,
				headers := *
		};
		
		template SipUrl mw_SipUrl_Host(charstring p_host) :=  	//*  SIP-URL with a calling party number
				scheme := c_sipScheme,  		//*  contains "sip"
poglitsch's avatar
poglitsch committed
				userInfo:= *,
				hostPort := {host:=p_host, portField:=*},
				urlParameters := *,
				headers := *
		};

          template SipUrl mw_SipUrl_NumberHost(charstring p_number, charstring p_host) :=  	//*  SIP-URL with a calling party number
            scheme := c_sipScheme,  		//*  contains "sip"
            userInfo:= {userOrTelephoneSubscriber:=p_number, password:=*},
            hostPort := {host:=p_host, portField:=*},
            urlParameters := *,
            headers := *
          };
rennoch's avatar
rennoch committed
          
		template SipUrl mw_SipUrl_NumberHostParam(charstring p_number, charstring p_host, template SemicolonParam_List p_urlParameters) :=  	//*  SIP-URL with a calling party number
		{
				scheme := c_sipScheme,  		//*  contains "sip"
				userInfo:= {userOrTelephoneSubscriber:=p_number, password:=*},
				hostPort := {host:=p_host, portField:=*},
				urlParameters := p_urlParameters,
				headers := *
		};
		
		template SipUrl m_SipUrl_NumberHostParam(charstring p_number, charstring p_host, template SemicolonParam_List p_urlParameters) :=  	//*  SIP-URL with a calling party number
		{
				scheme := c_sipScheme,  		//*  contains "sip"
				userInfo:= {userOrTelephoneSubscriber:=p_number, password:=omit},
				hostPort := {host:=p_host, portField:=c_defaultSipPort},
				urlParameters := p_urlParameters,
				headers := omit
		};
		
		template SipUrl mw_SipUrl_Anonymous :=  	//*  SIP-URL with a calles party number
		  scheme := c_sipScheme,  		//*  contains "sip"
		  userInfo := 			//*  optional
			userOrTelephoneSubscriber := "Anonymous",//*  charstring
			password := omit		//*  optional charstring
			host := "anonymous.invalid",	//*  hostname, IPv4 or IPv6 as a charstring
			portField := *	//* optional integer
		  },
		  urlParameters := *,
		  headers := *
		};

		template SipUrl mw_SipUrl_urlParam(template SemicolonParam_List p_urlParameters) :=  	//*  SIP-URL with a calling party number
				scheme := c_sipScheme,  		//*  contains "sip"
				userInfo:= *,
				hostPort := *,
				urlParameters := p_urlParameters,
				headers := *
		};
		
		template ContactAddress mw_ContactAddress :=
		{
		  addressField  := ?,
		  contactParams := *
		};

		template HostPort mw_hostPort(template charstring p_host, template integer p_portField) :=
		  portField := p_portField
		};
		
		template StatusLine mw_statusLine1xx   := {sipVersion := c_sipNameVersion, statusCode := (100..199), reasonPhrase := ?};
		template StatusLine mw_statusLine4xx   := {sipVersion := c_sipNameVersion, statusCode := (400..499), reasonPhrase := ?};
		template StatusLine mw_statusLine5xx   := {sipVersion := c_sipNameVersion, statusCode := (500..599), reasonPhrase := ?};
		template StatusLine mw_statusLineFinal := {sipVersion := c_sipNameVersion, statusCode := (200..699), reasonPhrase := ?};

		template NameAddr mw_NameAddr_DispName_User_Host(template charstring p_dn, template charstring p_user, template charstring p_host) := 
		{
			displayName := p_dn,
			addrSpec :=
			{
				scheme := c_sipScheme,  //*  contains "sip"
				userInfo := {userOrTelephoneSubscriber :=p_user,	password := *},
				hostPort :=
				{
					host := p_host,		//*  hostname, IPv4 or IPv6 as a charstring
					portField := *	//* optional integer
				},
			urlParameters := {m_UserPhone},
			headers := *
			}
		}
		
		template Addr_Union mw_AddrUnion_Nameaddr(template charstring p_dn, template charstring p_user, template charstring p_host):=
		{
			nameAddr:=mw_NameAddr_DispName_User_Host(p_dn,p_user,p_host)
		}
		
		template SipUrl mw_SipUrl_User_Host(template charstring p_user, template charstring p_host) :=
		{
			scheme := c_sipScheme,  //*  contains "sip"
			userInfo := {userOrTelephoneSubscriber :=p_user,	password := *},
			hostPort :=
			{
				host := p_host,		//*  hostname, IPv4 or IPv6 as a charstring
				portField := *	//* optional integer
			},
			urlParameters := {m_UserPhone},
			headers := *
		}
		template Addr_Union mw_AddrUnion_SipUrl(template charstring p_user, template charstring p_host):=
		{
			addrSpecUnion:=mw_SipUrl_User_Host(p_user,p_host)
		}
		

poglitsch's avatar
poglitsch committed
		template Allow m_Allow (template Method_List p_methods) := {
			fieldName := ALLOW_E,
			methods := p_methods
		}
		
		template Allow mw_Allow (charstring p_method) := {
			fieldName := ALLOW_E,
			methods := superset(p_method)
		}

		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[0].digestResponse,valueof(p_CommaParam_List))}}
		}

		template Authorization m_Authorization_other :=
		{
		  fieldName := AUTHORIZATION_E,
		  body := {{otherResponse := ?}}
		}

		template Contact m_Contact(template SipUrl p_sipUrl) :=
		{
		  fieldName := CONTACT_E,
		  contactBody :=
		  {
			contactAddresses :=
			{
			  {
				addressField := { addrSpecUnion := p_sipUrl},
				contactParams := omit
			  }
			}
		  } //* end contactBody
		}//* end m_Contact

		template Contact m_Contact_profile(in SipUserProfile p_userprofile) :=
		{
		  fieldName := CONTACT_E,
		  contactBody :=
		  {
			contactAddresses :=
			{
			  {
				addressField := { addrSpecUnion := m_SipUrl_contactIpaddr(p_userprofile)},
				contactParams := omit
			  }
			}
		  } //* 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 From m_From(template NameAddr p_nameAddr, charstring p_tag_str) :=
		{
		  fieldName := FROM_E,
		  addressField :=
		  {nameAddr := p_nameAddr},//* end addressField
		  fromParams := {{id := c_tagId, paramValue := p_tag_str}}
		};
		
pintar's avatar
pintar committed
		template From m_From_Anonymous(charstring p_tag_str) :=
		{
				fieldName := FROM_E,
				addressField :=
				{nameAddr := {
						displayName := "Anonymous",	 	 	//*  optional charstring
						addrSpec := m_SipUrl_Anonymous		//*  SipUrl
				}},//* end addressField
				fromParams := {{id := c_tagId, paramValue := p_tag_str}}
		};
		
		template From m_From_SipUrl(template SipUrl p_sipUrl) :=
		{
				fieldName := FROM_E,
				addressField :=
				{nameAddr := {
						displayName := omit, 	 			//*  optional charstring
						addrSpec := p_sipUrl		//*  SipUrl
				}},//* end addressField
				fromParams := omit
		};
		
		template Event m_Event_refer := 
		{
			fieldName := EVENT_E,
			eventType := "refer",
			eventParams := omit
		};

		template Event m_Event_conference := 
		{
			fieldName := EVENT_E,
			eventType := "conference",
			eventParams := omit
		};

		template Event m_Event_presence := 
		{
			fieldName := EVENT_E,
			eventType := "presence",
			eventParams := omit
		};

		template Event m_Event_reg := 
		{
			fieldName := EVENT_E,
			eventType := "reg",
			eventParams := omit
		};

		template Expires m_Expires_600000 := 
		{
			fieldName := EXPIRES_E,
			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,
			pAssertedIDValueList := {p_pAssertedIDValue}
		};

rennoch's avatar
rennoch committed
		template HistoryInfo mw_HistoryInfo(template HistoryInfo_List p_HistoryInfo_List) := 
		{
			fieldName := HISTORY_INFO_E,
			historyInfoList := p_HistoryInfo_List
		};

		template HistoryInfoEntry mw_HistoryInfoEntry(template SipUrl p_Url, template IntegerList p_index, template SemicolonParam_List p_paramlist) :=
		{
			nameAddr := {displayName:=*, addrSpec:= p_Url},
			hiIndex := p_index,
			hiExtention := p_paramlist
		}
		
      	template HistoryInfo m_HistoryInfo(template HistoryInfo_List p_HistoryInfo_List) := 
      	{
       		fieldName := HISTORY_INFO_E,
       		historyInfoList := p_HistoryInfo_List
      	};
    
     	template HistoryInfoEntry m_HistoryInfoEntry(template SipUrl p_Url, template IntegerList p_index, template SemicolonParam_List p_paramlist) :=
      	{
       		nameAddr := {displayName:=omit, addrSpec:= p_Url},
       		hiIndex := p_index,
      		hiExtention := p_paramlist
      	}
  
		template PAssertedID m_PAssertedID_2x(template Addr_Union p_pAssertedIDValue1, template Addr_Union p_pAssertedIDValue2) := 
		{
			fieldName := P_ASSERTED_ID_E,
			pAssertedIDValueList := {p_pAssertedIDValue1, p_pAssertedIDValue2}
		};
	
		template PAssertedID mw_PAssertedID(template PAssertedIDValue p_pAssertedIDValue) := 
		{
			fieldName := P_ASSERTED_ID_E,
poglitsch's avatar
poglitsch committed
			pAssertedIDValueList := {*, p_pAssertedIDValue, *}
		};

		template PAssertedIDValue mw_PAssertedIDValue(template SipUrl p_SipUrl) := 
		{
poglitsch's avatar
poglitsch committed
			nameAddr :={displayName := *, addrSpec:=p_SipUrl}
		};
		
		template PPreferredID m_PPreferredID(template Addr_Union p_pPreferredIDValue) := 
		{
			fieldName := P_PREFERRED_ID_E,
			pPreferredIDValueList := {p_pPreferredIDValue}
		};

		template Privacy m_Privacy(PrivacyValue p_privacy) := 
		{
			fieldName := PRIVACY_E,
			privValueList := {p_privacy}
		};
		template RAck m_RAck(integer p_responseNum, integer p_seqNumber, charstring p_method) :=
		{
		  	fieldName := RACK_E,
		  	responseNum := p_responseNum,
		  	seqNumber := p_seqNumber,
		  	method  := p_method
	  	};

		template Reason m_Reason(integer p_cause) :=
		{		  
			fieldName := REASON_E,
			reasonValues := {m_ReasonValue(int2str(p_cause),"dummy")}
		};

		template Reason m_Reason21 :=
		{		  
			fieldName := REASON_E,
			reasonValues := {m_ReasonValue(int2str(21),"call reject")}
		};

		template RecordRoute m_recordRoute_currIpAddr (in SipUserProfile p_userprofile):=
		{   
			fieldName := RECORD_ROUTE_E,
			routeBody := {{nameAddr := {displayName := omit, 
									   addrSpec := 	{scheme := c_sipScheme,  			//*  contains "sip"
													userInfo := omit,
													hostPort := {host:=p_userprofile.currIpaddr, portField:= p_userprofile.currPort},
													urlParameters := omit,
													headers := omit}
									   },
						  rrParam := omit}
		}};
	
		template ReferredBy m_ReferredBy_SipUrl(template SipUrl p_sipUrl) := 
		{
			fieldName := REFERRED_BY_E,
			nameAddr :={displayName := omit, addrSpec:=p_sipUrl},
			referredbyIdParams := omit
		}

		template ReferTo m_ReferTo_SipUrl(template SipUrl p_sipUrl, charstring p_method) := 
		{
			fieldName := REFER_TO_E,
			nameAddr :={displayName := omit, addrSpec:=p_sipUrl},
			referToParams := {{id:="method",paramValue :=p_method}}

		template Replaces m_Replaces(
			charstring p_callId, 
			charstring p_toTag,
			charstring p_fromTag
		) := {
			fieldName := REPLACES_E,
			replacesParams := {
				{id := p_callId, paramValue := omit},
				{id := "to-tag", paramValue := p_toTag},
				{id := "from-tag", paramValue := p_fromTag}
			}
		}

		template Require m_Require_replaces :=
		{		  
			fieldName := REQUIRE_E,
			optionsTags := {c_replaces}
		};
		
		template Require m_Require_100rel :=
		{		  
			fieldName := REQUIRE_E,
			optionsTags := {c_tag100rel}
		};
		
		template Require m_Require_prec :=
		{		  
			fieldName := REQUIRE_E,
			optionsTags := {c_tagPrecond}
		};
		
pintar's avatar
pintar committed
        template Supported m_Supported_fromChange :=
        {
       		fieldName:=SUPPORTED_E, 
       		optionsTags:={c_tagFromChange}
      	}
		
		template Supported m_Supported_prec :=
		{
			fieldName:=SUPPORTED_E, 
			optionsTags:={c_tagPrecond}
		}
		
poglitsch's avatar
poglitsch committed
		template Supported m_Supported_100rel :=
		{
			fieldName:=SUPPORTED_E, 
			optionsTags:={c_tag100rel}
		}
		
		template Supported m_Supported_100rel_prec :=
		{
			fieldName:=SUPPORTED_E, 
			optionsTags:={c_tag100rel, c_tagPrecond}
		}

		template GenericParam m_Text (template charstring p_text):=
			{id:="text", paramValue:=p_text}
		
		template GenericParam m_UserPhone :=
		{
			id := "user",
			paramValue := "phone"
		}
rennoch's avatar
rennoch committed
  		
  		template GenericParam m_UserToUserEncodingHex :=
        {
          id := "encoding",
     	  paramValue := "hex"
        }
        
        template UserToUser m_UserToUserData(template charstring p_U2UData):=
        {
          fieldName := USER_TO_USER_E,
          uuiData := p_U2UData,
          uuiParam := m_UserToUserEncodingHex
        }
        
		template To m_To(template SipUrl p_sipUrl) :=
		{
		  fieldName := TO_E,
		  addressField :=
		  {nameAddr := {
			  displayName := "ETSI Tester", //*  optional charstring
			  addrSpec :=	p_sipUrl		//*  SipUrl
			}},//* end addressField
		  toParams := omit
		};

		template To m_To_SipUrl(SipUrl p_sipUrl) :=
		{
		  fieldName := TO_E,
		  addressField :=
		  {nameAddr := {
			  displayName := omit, 	 			//*  optional charstring
			  addrSpec := p_sipUrl		//*  SipUrl
			}},//* end addressField
		  toParams := omit
		};

		template To mw_To_NameAddr_SipUrl(template charstring p_dn, template charstring p_user, template charstring p_host) :=
		{
			fieldName := TO_E,
			addressField := (mw_AddrUnion_Nameaddr(p_dn,p_user,p_host),mw_AddrUnion_SipUrl(p_user,p_host)),
rennoch's avatar
rennoch committed
			toParams := *
		}

		template From mw_From(template SipUrl p_sipUrl) := {
		  fieldName := FROM_E,
poglitsch's avatar
poglitsch committed
		  addressField := { nameAddr := {displayName := *, addrSpec := p_sipUrl}},
rennoch's avatar
rennoch committed
		template From mw_From_NameAddr_SipUrl(template charstring p_dn, template charstring p_user, template charstring p_host) :=
		{
			fieldName := FROM_E,
			addressField := (mw_AddrUnion_Nameaddr(p_dn,p_user,p_host),mw_AddrUnion_SipUrl(p_user,p_host)),
			fromParams := *
		}
		template ViaBody m_ViaBody_currIpaddr(charstring branch_val,in SipUserProfile p_userprofile) :=
		{
		  sentProtocol := m_SentProtocol(PX_SIP_TRANSPORT),
		  sentBy:={host:=p_userprofile.currIpaddr, portField:= p_userprofile.currPort},
		  viaParams:={{id :=c_branchId,paramValue :=branch_val}}
		}
		
		template ViaBody mw_ViaBody_interface(template 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,
		  callid := ?
		}

		template Privacy mw_Privacy_id := 
		{
			fieldName := PRIVACY_E,
			privValueList := {*,"id",*}
		};
		

		template Privacy mw_Privacy_user := 
		{
			fieldName := PRIVACY_E,
			privValueList := {*,"user",*}
		};
		
		template Reason mw_Reason(integer p_cause) :=
		{		  
			fieldName := REASON_E,
			reasonValues := {m_ReasonValue(int2str(p_cause),?)}
		};
		
		template Require mw_Require_not_100rel :=
		{		  
			fieldName := REQUIRE_E,
rennoch's avatar
rennoch committed
			optionsTags := superset(complement(c_tag100rel))
poglitsch's avatar
poglitsch committed
		
		template Require mw_require_100rel :=
    	{
    		fieldName := REQUIRE_E,
    		optionsTags := superset(c_tag100rel)
    	};

		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
		};
		
poglitsch's avatar
poglitsch committed
		template Supported mw_Supported_100rel_prec :=
		{
			fieldName:=SUPPORTED_E, 
			optionsTags:= superset(c_tag100rel, c_tagPrecond)
		}
		
		template Supported mw_Supported_100rel :=
		{
			fieldName:=SUPPORTED_E, 
			optionsTags:= superset(c_tag100rel)
		}
rennoch's avatar
rennoch committed

		template Supported mw_Supported_fromChange :=
		{
			fieldName:=SUPPORTED_E, 
			optionsTags:= superset(c_tagFromChange)
		}
juvancic's avatar
juvancic committed
        
		template UserToUser mw_UserToUserData(template charstring p_U2UData):=
		{
			fieldName := USER_TO_USER_E,
			uuiData := p_U2UData,
			uuiParam := ?
		}
rennoch's avatar
rennoch committed
				
		template Contact mw_Contact_conference :=
		{
		  fieldName := CONTACT_E,
		  contactBody :=
		  {
			contactAddresses :=
			{
			  {
				contactParams := {{"isfocus",*}}
			  }
			}
		  } 
		}
		
		template AlertInfo m_AlertInfo(charstring p_urn) := {
			fieldName := ALERT_INFO_E,
			alertInfoBody := {{p_urn, omit}}
		}
		
		template AlertInfo mw_AlertInfo(template charstring p_urn) := {
			fieldName := ALERT_INFO_E,
			alertInfoBody := superset({p_urn, omit})
		}
	} //*  end of group HeaderFieldTemplates


group MessageTemplates {
group dummy_templates {
  group dummy_parameter_send {

	template RequestLine m_requestLine_dummy(Method p_method) := 
		method := p_method,
poglitsch's avatar
poglitsch committed
		requestUri := c_unavailableUri,
		sipVersion := c_sipNameVersion
	}

	template MessageHeader m_msgHeader_dummy := 
	{
		accept := omit,
		acceptContact := omit,
		acceptEncoding := omit,
		acceptLanguage := omit,
		alertInfo := omit,
		allow := omit,
		allowEvents := omit, //*  RFC3265
		authenticationInfo := omit,
		authorization := omit,
		callId := c_empty_CallId,
		callInfo := omit,
		contact := omit,
		contentDisposition := omit,
		contentEncoding := omit,
		contentLanguage := omit,
		contentLength := {fieldName := CONTENT_LENGTH_E, len:=  0},
		contentType := omit, //* if message body present m, else not present
		cSeq := c_empty_cSeq,
		date := omit,
		errorInfo := omit,
		event := omit, //*  RFC3265
		expires := omit,
		fromField := c_empty_From,
		historyInfo := omit, //*  RFC4244
		inReplyTo := omit,
		maxForwards := c_maxForwards70,
		mimeVersion := omit,
		minExpires := omit,
		minSE := omit, //*  RFC4028
		organization := omit,
		pAccessNetworkInfo := omit, //*  RFC3455
		pAssertedID := omit,
		pAssertedService := omit,
		pAssociatedURI := omit,
		path := omit, //*  RFC3327
		pCalledPartyID := omit, //*  RFC3455
		pChargingFunctionAddresses := omit, //*  RFC3455
		pChargingVector := omit, //*  RFC3455
		pEarlyMedia := omit, //*  RFC5009
		pMediaAuthorization := omit, //*  RFC3313
		pPreferredID := omit,
		priority := omit,
		privacy := omit,
		proxyAuthenticate := omit,
		proxyAuthorization := omit,
		proxyRequire := omit,
		pVisitedNetworkID := omit, //*  RFC3455
		rAck := omit,
		rSeq := omit,
		reason := omit,
		recordRoute := omit,
		referredBy := omit, //*  RFC3892 - REFER method
		referTo := omit, //*  RFC3515 - REFER method
		replyTo := omit,
		require := omit,
		retryAfter := omit,
		route := omit,
		securityClient := omit, //*  RFC3329
		securityServer := omit, //*  RFC3329
		securityVerify := omit, //*  RFC3329
		serviceRoute := omit, //*  RFC3608
		sessionExpires := omit, //*  RFC4028
		subscriptionState := omit, //*  RFC3265
		supported := omit,
		timestamp := omit,
		toField := c_empty_To,
		unsupported := omit,
		userToUser := omit,
		userAgent := omit,
		via := c_empty_Via,
		warning := omit,
		wwwAuthenticate := omit,
		undefinedHeader_List := omit
	}
  } //*  group dummy_parameter_send
  
  group dummy_parameter_receive {

	template RequestLine mw_requestLine_dummy(Method p_method) := 
		method := p_method,
		requestUri := ?,
		sipVersion := c_sipNameVersion
	}

	template MessageHeader mw_msgHeader_dummy := 
	{
		accept := *,
		acceptContact := *,
		acceptEncoding := *,
		acceptLanguage := *,
		alertInfo := *,
		allow := *,
		allowEvents := *, //*  RFC3265
		authenticationInfo := *,
		authorization := *,
		callId := ?,
		callInfo := *,
		contact := *,
		contentDisposition := *,
		contentEncoding := *,
		contentLanguage := *,
		contentLength := ?,
		contentType := *,
		cSeq := ?,
		date := *,
		errorInfo := *,
		expires := *,
		fromField := ?,
		historyInfo := *, //*  RFC4244
poglitsch's avatar
poglitsch committed
		maxForwards := *,
		mimeVersion := *,
		minExpires := *,
		organization := *,
		pAccessNetworkInfo := *, //*  RFC3455
		pAssertedID := *,
		pAssertedService := *,
		pAssociatedURI := *,
		path := *, //*  RFC3327
		pCalledPartyID := *, //*  RFC3455
		pChargingFunctionAddresses := *, //*  RFC3455
		pChargingVector := *, //*  RFC3455
		pEarlyMedia := *, //*  RFC5009
		pMediaAuthorization := *, //*  RFC3313
		pPreferredID := *,
		priority := *,
		privacy := *,
		proxyAuthenticate := *,
		proxyAuthorization := *,
		proxyRequire := *,
		pVisitedNetworkID := *, //*  RFC3455
		rAck := *,
		rSeq := *,
		reason := *,
		recordRoute := *,
		referredBy := *, //*  RFC3892 - REFER method
		referTo := *, //*  RFC3515 - REFER method
		replyTo := *,
		require := *,
		retryAfter := *,
		route := *,
		securityClient := *, //*  RFC3329
		securityServer := *, //*  RFC3329
		securityVerify := *, //*  RFC3329
		serviceRoute := *, //*  RFC3608
		sessionExpires := *, //*  RFC4028
		subscriptionState := *, //*  RFC3265
		supported := *,
		timestamp := *,
		toField := ?,
		unsupported := *,
		userToUser := *,
		userAgent := *,
		via := ?,
		warning := *,
		wwwAuthenticate := *,
		undefinedHeader_List := *
	}
  }//* end group dummy_parameter_receive
  
  group dummy_request_templates_send {

	template ACK_Request m_ACK_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(ACK_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template BYE_Request m_BYE_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(BYE_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template CANCEL_Request m_CANCEL_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(CANCEL_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

pintar's avatar
pintar committed
	template INFO_Request m_INFO_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(INFO_E),
pintar's avatar
pintar committed
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template INVITE_Request m_INVITE_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(INVITE_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template MESSAGE_Request m_MESSAGE_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(MESSAGE_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template NOTIFY_Request m_NOTIFY_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(NOTIFY_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template PRACK_Request m_PRACK_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(PRACK_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template PUBLISH_Request m_PUBLISH_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(PUBLISH_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template REGISTER_Request m_REGISTER_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(REGISTER_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template REFER_Request m_REFER_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(REFER_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template SUBSCRIBE_Request m_SUBSCRIBE_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(SUBSCRIBE_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

	template UPDATE_Request m_UPDATE_Dummy :=
	{
		requestLine	:= m_requestLine_dummy(UPDATE_E),
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}
  }//* end group dummy_request_templates_send
  group dummy_request_templates_receive{

	template ACK_Request mw_ACK_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(ACK_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template BYE_Request mw_BYE_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(BYE_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template CANCEL_Request mw_CANCEL_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(CANCEL_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template INFO_Request mw_INFO_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(INFO_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template INVITE_Request mw_INVITE_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(INVITE_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template MESSAGE_Request mw_MESSAGE_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(MESSAGE_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template NOTIFY_Request mw_NOTIFY_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(NOTIFY_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template PRACK_Request mw_PRACK_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(PRACK_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template PUBLISH_Request mw_PUBLISH_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(PUBLISH_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template REFER_Request mw_REFER_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(REFER_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template REGISTER_Request mw_REGISTER_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(REGISTER_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template SUBSCRIBE_Request mw_SUBSCRIBE_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(SUBSCRIBE_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

	template UPDATE_Request mw_UPDATE_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy(UPDATE_E),
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}
  }//* end group dummy_request_templates_receive
  
  group dummy_response_templates_send{
  	
	template Response m_Response_Dummy :=
	{
		statusLine	:= c_statusLine100,
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}
  } //*  group dummy_response_templates_send
  
  group dummy_response_templates_receive{
	template Response mw_Response_Dummy :=
	{
		statusLine	:= ?,
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}
  } //*  group dummy_response_templates_receive
}

group base_templates{
	
	group request_send {
		
		
		template ACK_Request m_ACK_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
			From p_from, To p_to, Via p_via) modifies m_ACK_Dummy :=
		{
			requestLine	:=
			{
				requestUri := p_requestUri
			},
			msgHeader :=
			{
				callId := p_callId,
				cSeq := {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "ACK"},
				fromField := p_from,
				toField := p_to,
				via := p_via
			}
		}
		
		template BYE_Request m_BYE_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to, 
			Via p_via) modifies m_BYE_Dummy :=
		{	
			requestLine	:=
			{
poglitsch's avatar
poglitsch committed
				requestUri := p_requestUri
//				{
//					hostPort:= p_requestUri.hostPort
//				}
			},
			msgHeader :=
			{
				callId := p_callId,
				cSeq := p_cSeq,
				fromField := p_from,
				toField := p_to,
				via := p_via
			}
		}
		
		template CANCEL_Request m_CANCEL_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to, 
			Via p_via) modifies m_CANCEL_Dummy :=
		{
			requestLine	:=
			{
				requestUri :=
					{
						hostPort:= p_requestUri.hostPort
					}
			},
			msgHeader :=
			{
				callId := p_callId,
				cSeq := p_cSeq,
				fromField := p_from,
				toField := p_to,
				via := p_via
			}
		}
		
pintar's avatar
pintar committed
		template INFO_Request m_INFO_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to, 
			Via p_via) modifies m_INFO_Dummy :=
		{	
			requestLine	:=
			{
				requestUri := 
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			msgHeader :=
			{
				callId := p_callId,
				cSeq := p_cSeq,
				fromField := p_from,
				toField := p_to,
				via := p_via
			}
		}
		
		template INVITE_Request m_INVITE_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
			 From p_from, To p_to, Via p_via, Contact p_contact) modifies m_INVITE_Dummy :=
		{
			requestLine	:=
		  	{
				requestUri := p_requestUri
		  	},
		  	msgHeader :=
		  	{
		  		callId := p_callId,
				contact := p_contact,
				cSeq := p_cSeq,
				fromField := p_from,
				toField := p_to,
				via := p_via
			}
		}

		template MESSAGE_Request m_MESSAGE_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to, Via p_via) modifies m_MESSAGE_Dummy :=
		{
			requestLine	:=
			{
				requestUri := p_requestUri
			},
			msgHeader :=
			{
				callId := p_callId,
				cSeq := p_cSeq,
				fromField := p_from,
				toField := p_to,
				via := p_via
			}
		}

		template NOTIFY_Request m_NOTIFY_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
		  From p_from, To p_to, Via p_via) modifies m_NOTIFY_Dummy :=
		{
			requestLine	:=
			{
				requestUri :=
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			msgHeader :=
			{
				callId := p_callId,
				//* contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
				//* contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication},
				cSeq :=  {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "NOTIFY"},
				fromField := p_from,
				toField := p_to,
				via := p_via
		}
		
		template PRACK_Request m_PRACK_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
		  From p_from, To p_to, Via p_via, RAck p_RAck) 
		  modifies m_PRACK_Dummy :=
		{
			requestLine	:=
			{
				requestUri :=
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			msgHeader :=
			{
				callId := p_callId,
				cSeq := {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "PRACK"},
				fromField := p_from,
				rAck := p_RAck,
				toField := p_to,
				via := p_via
			},
			messageBody := omit
		}
		
		//* in reality PUBLISH request contain xml in content
		template PUBLISH_Request m_PUBLISH_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
		  From p_from, To p_to, Via p_via, template Event p_event, template RAck p_RAck, template MessageBody p_mb) 
		  modifies m_PUBLISH_Dummy :=
		{
			requestLine	:=
			{
				requestUri :=
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			msgHeader :=
			{
				callId := p_callId,
				contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
				contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication},
				cSeq := {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "PUBLISH"},
				event := p_event, 
				fromField := p_from,
				toField := p_to,
				via := p_via
			},
			messageBody := p_mb
		}

		template REFER_Request m_REFER_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, Contact p_contact,
			From p_from, template To p_to, Via p_via, template ReferTo p_referTo, template ReferredBy p_referredBy)
			modifies m_REFER_Dummy :=
		{
			requestLine	:=
			{
				requestUri := p_requestUri
		  	},
		  	msgHeader :=
	  		{
				callId		:= p_callId,
				contact := p_contact,
				cSeq		:= {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "REFER"},
				fromField	:= p_from,
				referTo := p_referTo,
				referredBy := p_referredBy,
				toField		:= p_to,
				via		:= p_via
	  		}
		}
		
		template REFER_Request m_REFER_Request_replaces (
			SipUrl p_requestUri, 
			CallId p_callId, 
			CSeq p_cSeq, 
			Contact p_contact,
			From p_from, 
			template To p_to, 
			Via p_via, 
			template ReferTo p_referTo, 
			template ReferredBy p_referredBy,
			template Replaces p_replaces,
		) modifies m_REFER_Request_Base := {
			msgHeader :=
			{
				replaces := p_replaces,
				require := p_require
			}
		}
		
		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, template Authorization p_authorization) modifies m_REGISTER_Dummy :=
		{
			requestLine	:=
			{
				requestUri := p_requestUri
			},
			msgHeader :=
			{
				authorization := p_authorization,
				callId 		:= p_callId,
				contact		:= p_contact,
				cSeq		:= p_cSeq,
				fromField	:= p_from,
				toField		:= p_to,
				supported := {
					fieldName := SUPPORTED_E, optionsTags := {"path"}
				},
				via		:= p_via
			}
		}

		template SUBSCRIBE_Request m_SUBSCRIBE_Request_Base (SipUrl p_requestUri, CallId p_callId, 
			CSeq p_cSeq, From p_from, To p_to, Via p_via)  modifies m_SUBSCRIBE_Dummy :=
		{
			requestLine	:=
			{
				requestUri :=
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			msgHeader :=
			{
				callId		:= p_callId,
				cSeq		:= {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "SUBSCRIBE"},
				fromField	:= p_from,
				toField		:= p_to,
				via		:= p_via
			}
		}

		template UPDATE_Request m_UPDATE_Request_Base (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
		  From p_from, To p_to, Via p_via, Contact p_contact, template MessageBody p_mb) modifies m_UPDATE_Dummy :=
		{
			requestLine	:=
			{
poglitsch's avatar
poglitsch committed
				requestUri := p_requestUri
			},
			msgHeader :=
			{
				callId		:= p_callId,
				contact		:= p_contact,
				contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
				contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication},
				cSeq		:= {fieldName:=CSEQ_E, seqNumber:= p_cSeq.seqNumber, method:= "UPDATE"},
				fromField	:= p_from,
				toField		:= p_to,
				via		:= p_via
			 },
			messageBody := p_mb
		}
		  
	} //*  end of group message_send

	group request_receive {
		
		template ACK_Request mw_ACK_Request_Base (template CallId p_callId) modifies mw_ACK_Dummy :=
		{
			msgHeader :=
			{
				callId		:= p_callId
			}
		}
		
		template BYE_Request mw_BYE_Request_Base(template CallId p_callId) modifies mw_BYE_Dummy :=
		  {
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template CANCEL_Request mw_CANCEL_Request_Base (template CallId p_callId) modifies mw_CANCEL_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}
  
		template INFO_Request mw_INFO_Request_Base(template CallId p_callId) modifies mw_INFO_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}

		template INVITE_Request mw_INVITE_Request_Base modifies mw_INVITE_Dummy :=
		{
			requestLine	:=
			{
				method := INVITE_E
			}
		}

poglitsch's avatar
poglitsch committed
		template MESSAGE_Request mw_MESSAGE_Request_Base modifies mw_MESSAGE_Dummy :=
berge's avatar
berge committed
				contact := *
poglitsch's avatar
poglitsch committed
		template NOTIFY_Request mw_NOTIFY_Request_Base (template CallId p_callId) modifies mw_NOTIFY_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template PRACK_Request mw_PRACK_Request_Base(template CallId p_callId) modifies mw_PRACK_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template PUBLISH_Request mw_PUBLISH_Request_Base(template CallId p_callId) modifies mw_PUBLISH_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}

		template REFER_Request mw_REFER_Request_Base (CallId p_callId) modifies mw_REFER_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template REFER_Request
		mw_REFER_Request(CallId p_callId, SipUrl p_requestUri,
						 SipUrl p_referredBy)
		modifies mw_REFER_Request_Base := {
			requestLine := {requestUri := p_requestUri},
			msgHeader := {
				callId := p_callId,
				referredBy := {
					fieldName := REFERRED_BY_E,
					nameAddr := {displayName := *, addrSpec := p_referredBy},
					referredbyIdParams := *
				}
			}
		}
	
		template INVITE_Request mw_INVITE_Request(template Require p_require,
						 SipUrl p_referredBy) modifies mw_INVITE_Request_Base := {
			msgHeader := {
				require := p_require,
				referredBy := {
					fieldName := REFERRED_BY_E,
					nameAddr := {displayName := *, addrSpec := p_referredBy},
					referredbyIdParams := *
				}
			}
		}
		
		template REGISTER_Request mw_REGISTER_Request_Base modifies mw_REGISTER_Dummy :=
		{
			requestLine	:=
			{
				method := REGISTER_E
			}
		}

		template SUBSCRIBE_Request mw_SUBSCRIBE_Request_Base modifies mw_SUBSCRIBE_Dummy :=
		{
			requestLine	:=
			{
				method := SUBSCRIBE_E
			}
		}

		template UPDATE_Request mw_UPDATE_Request_Base(template CallId p_callId) modifies mw_UPDATE_Dummy :=
		{
			msgHeader :=
			{
				callId := p_callId
			}
		}

	} //*  end group request_receive
	
	group response_send {

		template Response m_Response_Base (StatusLine p_statusLine, CallId p_callId, CSeq p_cSeq,
		  From p_from, To p_to, Via p_via) modifies m_Response_Dummy:=
		{
			statusLine := p_statusLine,
			msgHeader :=
			{
				callId		:= p_callId,
				cSeq		:= p_cSeq,
				fromField	:= p_from,
				maxForwards := omit,
				toField		:= p_to,
				via		:= p_via
			},
			messageBody := omit,
			payload			:= omit
		}

	

	} //*  end group response_send

	group response_receive {

		template Response mw_Response_Base (template StatusLine p_statusLine, template CallId p_callId,
			template CSeq p_cSeq) modifies mw_Response_Dummy:=
		{
			statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
			msgHeader :=
			{
			  callId		:= p_callId,
			  contentLength	:= *,
			  cSeq		:= p_cSeq,
			  fromField	:= ?,
			  maxForwards := *,
			  toField		:= ?,
			  via		:= ?
		  }
		}
	} //*  end group message_receive
} //*  end group full_templates

group modified_templates {
	
group request_send {
	
	template ACK_Request m_ACK_Request_route (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
	From p_from, To p_to, Via p_via, Route p_route)
	  modifies m_ACK_Request_Base
	  :=
	  {
		msgHeader :=
		{
		  route		:= p_route
		}
	  }

	template ACK_Request m_ACK_Request_sdp (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq,
	From p_from, To p_to, Via p_via,template MessageBody p_mb )
	  modifies m_ACK_Request_Base
	  :=
	  {
		msgHeader :=
		{
			contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
			contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication}
		},
		messageBody := p_mb
	  }
	  
	template BYE_Request m_BYE_Request_cause
	  (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to, Via p_via, integer p_cause)
	  modifies m_BYE_Request_Base
	  :=
	  {
		msgHeader :=
		{
			  reason := m_Reason(p_cause) //*  PIXIT value
		}
	  }
	
	template INVITE_Request m_INVITE_Request_sdp
	(SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to,
	  Via p_via, Contact p_contact, template MessageBody p_mb)
	modifies m_INVITE_Request_Base
	:=
	{
	  msgHeader :=
	  {
		contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
		contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication}
	  },
	  messageBody := p_mb
	}
	
	template INVITE_Request m_INVITE_Request_ResourceList
	(SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, From p_from, To p_to,
	  Via p_via, Contact p_contact, template MessageBody p_mb)
	modifies m_INVITE_Request_Base
	:=
	{
	  msgHeader :=
	  {
		contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
		contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  "application/resource-lists+xml"},
		contentDisposition := {
			fieldName := CONTENT_DISPOSITION_E,
poglitsch's avatar
poglitsch committed
			dispositionType := "recipient-list",
			dispositionParams := omit
		},
		require := {
			fieldName := REQUIRE_E,
poglitsch's avatar
poglitsch committed
			optionsTags := {"recipient-list-invite"}
		}
	  },
	  messageBody := p_mb
	}	

	template REGISTER_Request m_REGISTER_Request_expires
	  (SipUrl p_requestUri, CallId p_callId, CSeq p_cSeq, 
	  From p_from, To p_to, Via p_via, Contact p_contact,
	  template Authorization p_authorization, charstring p_expires)
	  modifies  m_REGISTER_Request_Base
	  :=
	  {
		msgHeader :=
		{
			authorization := p_authorization,
		    expires := {
			fieldName := EXPIRES_E,
			deltaSec  := p_expires }
		}
	  }
	  
	  template NOTIFY_Request m_NOTIFY_Request_sipfrag (
	  	SipUrl p_requestUri, 
	  	CallId p_callId, 
	  	CSeq p_cSeq,
		From p_from, 
		To p_to, 
		Via p_via, 
		charstring p_state, 
		charstring p_sipfrag
	) modifies m_NOTIFY_Request_Base := {
			requestLine	:=
			{
				method := NOTIFY_E,
				requestUri :=
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			msgHeader :=
			{
				contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= lengthof(p_sipfrag)},
				contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  "message/sipfrag"},
				subscriptionState := {
					fieldName := SUBSCRIPTION_STATE_E,
    				subState := p_state,
    				substateParams := omit	
				},
				event := m_Event_refer
			},
			messageBody := {
				sipfrag := 	p_sipfrag
			}
		}
} //*  end group request_send	


group request_receive {
		
	template BYE_Request mw_BYE_Request_Reason(template CallId p_callId, integer p_cause) modifies mw_BYE_Request_Base :=
	{
		msgHeader :=
		{
			reason := mw_Reason(p_cause)
		}
	}

rennoch's avatar
rennoch committed
	template BYE_Request mw_BYE_Request_UserToUser(template CallId p_callId) modifies mw_BYE_Request_Base :=
	{
		msgHeader :=
		{
			userToUser := ?
		}
	}


	template INVITE_Request mw_INVITE_Request_RequestURI (template SipUrl p_sipUrl) modifies mw_INVITE_Dummy :=
	{
		requestLine	:=
		{
			requestUri := p_sipUrl,
			sipVersion := c_sipNameVersion
		}
	}

pintar's avatar
pintar committed
    template INFO_Request mw_INFO_Request_MB (template CallId p_callId, template MessageBody p_mb) modifies mw_INFO_Request_Base :=
    {
     messageBody := p_mb
    }

	template INVITE_Request mw_INVITE_Request_expires modifies  mw_INVITE_Request_Base
	  :=
	  {
		msgHeader := {expires := ?}
	  }
	  
	template INVITE_Request mw_INVITE_Request_callid(CallId p_callid) modifies  mw_INVITE_Request_Base
	  :=
	  {
		msgHeader := {callId := p_callid}
	  }
pintar's avatar
pintar committed
	
	template INVITE_Request mw_INVITE_Request_MB (template CallId p_callId, template MessageBody p_mb) modifies mw_INVITE_Request_Base :=
pintar's avatar
pintar committed
	{
		msgHeader := {callId := p_callId},
		messageBody := p_mb
	}

	template INVITE_Request mw_INVITE_Request_noPaccessNetworkInfo	(template CallId p_callId)
		modifies mw_INVITE_Request_Base
		:=
		{
		  msgHeader := {  pAccessNetworkInfo := omit}
		}
	template INVITE_Request mw_INVITE_Request_PaccessNetworkInfo	(template CallId p_callId)
		modifies mw_INVITE_Request_Base
		:=
		{
		  msgHeader := {  pAccessNetworkInfo := ?}
		}

pintar's avatar
pintar committed
	template REGISTER_Request mw_REGISTER_Request_ISC (template  PAccessNetworkInfo p_access , template  PVisitedNetworkID p_visited )modifies mw_REGISTER_Request_Base :=
	{
	  msgHeader := {  
		  pAccessNetworkInfo := p_access,
		  pVisitedNetworkID  := p_visited
		  }
pintar's avatar
pintar committed
	}
pintar's avatar
pintar committed
	template UPDATE_Request mw_UPDATE_Request_SDP(template CallId p_callId, template MessageBody p_mb) modifies mw_UPDATE_Dummy :=
	{
		messageBody := p_mb
	}
	
poglitsch's avatar
poglitsch committed
    template NOTIFY_Request mw_NOTIFY_Request_MB (template CallId p_callId, template MessageBody p_mb) modifies mw_NOTIFY_Request_Base :=
pintar's avatar
pintar committed
    {
		messageBody := p_mb
    }
} //*  end group request_receive	
group response_send {
	
	template Response m_Response_AlertInfo (
		StatusLine p_statusLine, 
		CallId p_callId, 
		CSeq p_cSeq,
	  	From p_from, 
	  	To p_to,
	  	Via p_via, 
	  	AlertInfo p_alertInfo
	) modifies m_Response_Base:= {
		msgHeader := {
			alertInfo := p_alertInfo
		}
	}

	template Response m_Response_ext (StatusLine p_statusLine, CallId p_callId, CSeq p_cSeq,
	  From p_from, To p_to, Via p_via, template Route p_route, template RecordRoute p_recordroute) modifies m_Response_Base:=
			route 		:= p_route, //f_route(),
			recordRoute := p_recordroute //f_recordroute()
			}
	}
			
	template Response m_Response_mbody (StatusLine p_statusLine, CallId p_callId, CSeq p_cSeq,
	  From p_from, To p_to, Via p_via,  template Route p_route, template RecordRoute p_recordroute, MessageBody p_mb) modifies m_Response_ext:=
	{
		msgHeader :=
			 {
			   contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
			   contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication}
			 },
	  	messageBody := p_mb
	}
			
	template Response m_Response_PAsserted_Privacy (StatusLine p_statusLine, CallId p_callId, CSeq p_cSeq,
			From p_from, To p_to, Via p_via,  template Route p_route, template RecordRoute p_recordroute, template PAssertedID p_pAssertedID, template Privacy p_privacy) modifies m_Response_ext:=
	{
		msgHeader :=
				{
						pAssertedID := p_pAssertedID,
						privacy := p_privacy
				}
	}
rennoch's avatar
rennoch committed
	
	template Response mw_Response_PAsserted_Privacy_Supported (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template PAssertedID p_pAssertedID, template Privacy p_privacy, template Supported p_supported) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			pAssertedID := p_pAssertedID,
			privacy := p_privacy,
			supported := p_supported
		}
	}
			
	template Response m_Response_PAsserted_Privacy_mbody (StatusLine p_statusLine, CallId p_callId, CSeq p_cSeq,
			From p_from, To p_to, Via p_via,  template Route p_route, template RecordRoute p_recordroute, template PAssertedID p_pAssertedID, template Privacy p_privacy, MessageBody p_mb) modifies m_Response_ext:=
	{
		msgHeader :=
				{
						contentLength	:= {fieldName := CONTENT_LENGTH_E, len:= f_MessageBodyLength(valueof(p_mb))},
						contentType := {fieldName := CONTENT_TYPE_E, mediaType :=  c_sdpAplication},
						pAssertedID := p_pAssertedID,
						privacy := p_privacy
				},
				messageBody := p_mb
	}

} //*  end 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_PAsserted_Privacy (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template PAssertedID p_pAssertedID, template Privacy p_privacy) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			pAssertedID := p_pAssertedID,
			privacy := p_privacy
		}
	}

	template Response mw_Response_Reason (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, integer p_cause) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			reason := mw_Reason(p_cause)
			}
	}

	template Response mw_Response_RecordRoute (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template RecordRoute p_recordRoute) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			recordRoute := p_recordRoute
	  }
	}

	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
	  }
	}
	
	template Response mw_Response_Contact (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template Contact p_contact) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			contact := p_contact
	  }
	}
	
	template Response mw_Response_AlertInfo (
		template StatusLine p_statusLine, 
		template CallId p_callId,
		template CSeq p_cSeq, 
		template AlertInfo p_alertInfo
	) modifies mw_Response_Base:= {
		statusLine := {
			sipVersion := c_sipNameVersion, 
			statusCode := p_statusLine.statusCode, 
			reasonPhrase := ?
		},
		msgHeader :=
		{
			alertInfo := p_alertInfo
	  }
	}
	
rennoch's avatar
rennoch committed
	template Response mw_Response_HistoryInfo (template StatusLine p_statusLine, template CallId p_callId,
			template CSeq p_cSeq, template HistoryInfo p_historyInfo) modifies mw_Response_Base:=
		{
			statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
			msgHeader :=
			{
				historyInfo:=p_historyInfo
				}
		}
	
poglitsch's avatar
poglitsch committed
	template Response mw_Response_messageBody (
		template StatusLine p_statusLine, 
		template CallId p_callId,
		template CSeq p_cSeq, 
		template Require p_require,
		template MessageBody p_mb
	) modifies mw_Response_Base:= {
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			require := p_require
	    },
	    messageBody := p_mb
	}
	
	template Response mw_Response_Require (template StatusLine p_statusLine, template CallId p_callId,
		template CSeq p_cSeq, template Require p_require) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			require := p_require
	  }
	}
	
poglitsch's avatar
poglitsch committed
	template Response mw_Response_Require_ifpresent (template StatusLine p_statusLine, template CallId p_callId,
	template CSeq p_cSeq, template Require p_require) modifies mw_Response_Base:=
	{
		statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
		msgHeader :=
		{
			require := p_require ifpresent
	  }
	}
	
     template Response mw_Response_Supported (template StatusLine p_statusLine, template CallId p_callId,
      template CSeq p_cSeq, template Supported p_supported) modifies mw_Response_Base:=
     {
      statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
      msgHeader :=
      {
       supported := p_supported
       }
     }
rennoch's avatar
rennoch committed
     
     template Response mw_Response_UserToUser (template StatusLine p_statusLine, template CallId p_callId,
      template CSeq p_cSeq) modifies mw_Response_Base:=
     {
     statusLine := {sipVersion := c_sipNameVersion, statusCode := p_statusLine.statusCode, reasonPhrase := ?},
     msgHeader :=
     {
     	userToUser := ?
       }
     }
} //*  end group response_receive	
} //*  end group modified_templates	
} //*  end group MessageTemplates

group SDP_Templates {
	
	group SDP_Messages {

	group base_templates {
    	
    	template SDP_Message m_SDP(SDP_media_desc p_media, in SipUserProfile p_userprofile) := {
    		protocol_version := 0, //*  v=0
    		origin := {
    			user_name := "voicesession",
    			session_id := "30000",
    			session_version := "0",
    			net_type := c_in,
    			addr_type := c_ip4,
    			addr := p_userprofile.contactIpaddr },
    		//*  o=voicesession 12345 12345 IN IP4 172.27.1.219
    		session_name := "Voice Session", //*  s=Voice Session
    		information := omit,
    		uri := omit,
    		emails := omit,
    		phone_numbers := omit,
    		connection := {
    			net_type := c_in,
    			addr_type := c_ip4,
    			conn_addr := { addr:= p_userprofile.bearerIpaddr, ttl:=omit, num_of_addr:=omit }
    		}, //* c=IN IP4 172.27.1.219
    		bandwidth := omit,
    		times := { { time_field := { "0", "0" }, time_repeat:=omit
    			}
    		timezone_adjustments := omit,
    		key := omit,
    		attributes := omit,
    		media_list := {p_media}
    	};
    	
    	template SDP_Message m_SDP_mediaList(SDP_media_desc_list p_media_list, in SipUserProfile p_userprofile)
    	:= {
			protocol_version := 0, //*  v=0
			origin := {
				user_name := "voicesession",
				session_id := "30000",
				session_version := "0",
				net_type := c_in,
				addr_type := c_ip4,
				addr := p_userprofile.contactIpaddr },
			//*  o=voicesession 12345 12345 IN IP4 172.27.1.219
			session_name := "Voice Session", //*  s=Voice Session
			information := omit,
			uri := omit,
			emails := omit,
			phone_numbers := omit,
			connection := {
				net_type := c_in,
				addr_type := c_ip4,
				conn_addr := { addr:= p_userprofile.bearerIpaddr, ttl:=omit, num_of_addr:=omit }
			}, //* c=IN IP4 172.27.1.219
			bandwidth := omit,
			times := { { time_field := { "0", "0" }, time_repeat:=omit
				}
			timezone_adjustments := omit,
			key := omit,
			attributes := omit,
			media_list := p_media_list
		};

poglitsch's avatar
poglitsch committed
		template SDP_Message m_SDP_media_attr_preconditions(SDP_media_desc p_media, in SipUserProfile p_userprofile, SDP_attribute_list p_attribute_list)
		modifies m_SDP
		:= {
			media_list := {
				{
					media_field := {
						media := c_audio,
						ports := { port_number := 8500, num_of_ports:=omit },
						transport := c_rtpAvp,
						fmts := { "0" }
					}, //* m=audio 8500 RTP/AVP 0				
					information := omit,
					connections := omit,
					bandwidth := omit,
					key := omit,						
poglitsch's avatar
poglitsch committed
					attributes := p_attribute_list
				}}
			}
	
    		template SDP_Message m_SDP_attribute(SDP_media_desc p_media, in SipUserProfile p_userprofile, SDP_attribute loc_attribute) 
    		modifies m_SDP
    		:= {
    			attributes := {loc_attribute}
    		};

			template SDP_Message mw_SDP := {
				protocol_version := 0, //*  v=0
				origin := ?,
				session_name := ?, 
				information := omit,
				uri := omit,
				emails := omit,
				phone_numbers := omit,
				connection := ?,
				bandwidth := omit,
				times := { { time_field := { "0", "0" }, time_repeat:=omit
					}
				timezone_adjustments := omit,
				key := omit,
				attributes := omit,
				media_list := ?
			};
		
		
	}//* end group base_templates

	group modified_templates{
    	template SDP_Message m_SDP_bandwidth(SDP_media_desc p_media, in SipUserProfile p_userprofile) 
    	modifies m_SDP
    	:= {
    		bandwidth := {{PX_SIP_SDP_b_modifier, PX_SIP_SDP_b_bandwidth}}
    	};
    
    	template SDP_Message m_SDP_unacceptable(SDP_media_desc p_media, in SipUserProfile p_userprofile) 
    	modifies m_SDP
    	:= {
    		protocol_version := 1, //*  v=1 unacceptable version of SDP
    		bandwidth := {{PX_SIP_SDP_b_modifier, PX_SIP_SDP_b_bandwidth}}
    	};
    	
    	template SDP_Message m_SDP_encrypted(SDP_media_desc p_media, in SipUserProfile p_userprofile) 
    		modifies m_SDP
    		:= {
    			protocol_version := 1, //*  v=1 unacceptable version of SDP
    			bandwidth := {{PX_SIP_SDP_b_modifier, PX_SIP_SDP_b_bandwidth}}
    		};
    }//* end group modified_templates
	} //*  end group	SDP_Messages	
		
	group SDP_Fields {

		template SDP_media_desc m_media(template SDP_media_field p_mf) := {
				media_field := p_mf, 
				information := omit,
				connections := omit,
				bandwidth := omit,
				key := omit,						
				attributes := omit
		};
poglitsch's avatar
poglitsch committed
		template SDP_media_desc m_mediaFieldBandwdthAttributes(template SDP_media_field p_mf, template SDP_bandwidth p_bw, template SDP_attribute_list p_attributes) := {
				media_field := p_mf, 
				information := omit,
				connections := omit,
poglitsch's avatar
poglitsch committed
				bandwidth := {p_bw},
				key := omit,						
				attributes := p_attributes
		};
		template SDP_media_desc m_media_dynPT(charstring p_PT, charstring p_encod) := {
				media_field := {
					media := c_audio,//* "audio",
					ports := { port_number := 8500, num_of_ports:=omit },
					transport := c_rtpAvp,//* "RTP/AVP",
				}, //* m=audio 8500 RTP/AVP 8
				information := omit,
				connections := omit,
				bandwidth := omit,
				key := omit,						
				attributes := { { rtpmap := { attr_value := p_PT & " " & p_encod }
								}
		};
	
		template SDP_media_desc m_media_unsupported := {
				media_field := {
					media := "video",
					ports := { port_number := 11500, num_of_ports:=omit },
					transport := "RTP/AVP",
					fmts := { "99" }
				}, //* m=audio 8500 RTP/AVP 0
				information := omit,
				connections := omit,
				bandwidth := omit,
				key := omit,						
				attributes := { { 
					rtpmap := { attr_value := "99 X-Experimental/180000"}
				}}
		};

		template SDP_bandwidth m_bandwidth(template charstring loc_m, template integer loc_b) := {
			modifier:=loc_m, 
			bandwidth:=loc_b
		};

		template SDP_bandwidth m_bandwidth_as_64:= 
		{
					modifier:="AS", 
					bandwidth:=64
		}
		
		template SDP_bandwidth mw_bandwidth_rs:= 
		{
					modifier:="RS", 
					bandwidth:=?
		}
		
		template SDP_bandwidth mw_bandwidth_rr:= 
		{
					modifier:="RR", 
					bandwidth:=?
		}

		template SDP_media_field m_media_field(charstring p_media, integer p_portNum, charstring p_transport, charstring p_fmts) :=
		{
			media := p_media,
			ports := { port_number := p_portNum, num_of_ports:=omit },
			transport := p_transport,
			fmts := { p_fmts }
		}		

        template SDP_media_field mw_media_PCMU :=
        {
			media := c_audio,
			ports := { port_number := ?, num_of_ports:=* },
			transport := c_rtpAvp,
			fmts := { "0" }
        }

		template SDP_media_field mw_media_PCMA :=
		{
			media := c_audio,
poglitsch's avatar
poglitsch committed
			ports := { port_number := 8500, num_of_ports:=omit },
			transport := c_rtpAvp,
			fmts := { "8" }
		}
		
		template SDP_media_field mw_media_PCMA_U_DPT :=
		{
			media := c_audio,
			ports := { port_number := ?, num_of_ports:=* },
			transport := c_rtpAvp,
			fmts := { * }
		}
		
		template SDP_media_field mw_media_T38 :=
		{
			media := c_image,
			ports := { port_number := ?, num_of_ports:=* },
			transport := pattern "*ptl", //* udptl,tcptl
			fmts := { "t38" }
		}

		template SDP_media_field mw_media_G722 :=
		{
			media := c_audio,
			ports := { port_number := ?, num_of_ports:=* },
			transport := "RTP/AVP",
			fmts := { "9" }
		}

		template SDP_media_field mw_media_AMR_DPT :=
		{
			media := c_audio,
			ports := { port_number := ?, num_of_ports:=* },
			transport := c_rtpAvp,
			fmts := { * }
		}
		

		template SDP_attribute m_attribute_sendonly	 := {sendonly:={}};
		template SDP_attribute mw_attribute_sendonly	 := {sendonly:={}};//MRO
		template SDP_attribute m_attribute_recvonly	 := {recvonly:={}};
		template SDP_attribute mw_attribute_recvonly	 := {recvonly:={}};//MRO
		template SDP_attribute m_attribute_sendrecv	 := {sendrecv:={}};
		template SDP_attribute mw_attribute_sendrecv	 := {sendrecv:={}};//MRO
		template SDP_attribute m_attribute_inactive	 := {inactive:={}};
		template SDP_attribute mw_attribute_inactive	 := {inactive:={}};//MRO
		template SDP_attribute mw_attribute_sendonly_inactive := (mw_attribute_sendonly,mw_attribute_inactive);
		template SDP_attribute mw_attribute_sendrecv_recvonly_omit := (mw_attribute_sendrecv,mw_attribute_recvonly,omit);
		template SDP_attribute m_attribute_AMR_DPT	 := { rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " AMR" }};
		template SDP_attribute m_attribute_CLEARMODE_DPT	 := {rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " CLEARMODE/8000" }};
		template SDP_attribute m_attribute_G722	 := { rtpmap := { attr_value := "9 G722/8000" }};
		template SDP_attribute m_attribute_PCMU	 := { rtpmap := { attr_value := "0 PCMU/8000" }};
		template SDP_attribute m_attribute_PCMU_DPT	 := { rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " PCMU/8000" }};
		template SDP_attribute m_attribute_PCMA	 := { rtpmap := { attr_value := "8 PCMA/8000" }};
		template SDP_attribute m_attribute_PCMA_DPT	 := { rtpmap := { attr_value := /*pattern "**/PX_SIP_SDP_dyn & " PCMA/8000" }};
		template SDP_attribute m_attribute_T38	 := { unknown := { name:=?, attr_value := pattern "*t38*" }};
		
		template SDP_attribute m_attribute_curr (charstring p_preconditionType, charstring p_statusType, charstring p_direction):= 
		{
			curr:={preconditionType := p_preconditionType, 
			statusType := p_statusType, 
			direction := p_direction}
		};
poglitsch's avatar
poglitsch committed
		
		template SDP_attribute mw_attribute_curr := 
		{
			curr := ?
		};
		
		template SDP_attribute m_attribute_des (charstring p_preconditionType, charstring p_strength, charstring p_statusType, charstring p_direction):= 
		{
			des:={preconditionType := p_preconditionType, 
			strength := p_strength,
			statusType := p_statusType, 
			direction := p_direction}
		};
poglitsch's avatar
poglitsch committed
		
		template SDP_attribute mw_attribute_des := 
		{
			des := ?
		};
		
		template SDP_attribute m_attribute_conf (charstring p_preconditionType, charstring p_statusType, charstring p_direction):= 
		{
			conf:={preconditionType := p_preconditionType, 
			statusType := p_statusType, 
			direction := p_direction}
poglitsch's avatar
poglitsch committed
		};		
} //*  end group SDP_Templates

group MessageBodies {
	
	template MessageBody m_MBody_SDP(template SDP_Message p_SDP):=
	{
		sdpMessageBody := p_SDP
	};
	
	template MessageBody m_MBody_XML(template XmlBody p_xmlBody):=
	{
		xmlBody := p_xmlBody
	};
	
	template MessageBody m_MBody_longPlainText:=
	{
		textplain :=  c_longMessageContent_1300Bytes
	};

	template MessageBody m_mBody_plainText(charstring p_plaitext):=
	{
		textplain :=  p_plaitext
	};
	
	template MessageBody m_MBody_sipfrag(charstring p_sipfrag) := {
		sipfrag := p_sipfrag	
	} 
	
	template MessageBody m_MBody_MIMESdpXml(template SDP_Message p_sdp, template XmlBody p_xmlBody):=
	{
		mimeMessageBody := {boundary:="PX_SIP_MIME_Boundary", 
			mimeEncapsulatedList:= {
			{content_type:="PX_SIP_SDP_ContentType", 
				content_disposition:=omit,
				mime_encapsulated_part:={sdpMessageBody := p_sdp}},
			{content_type:="PX_SIP_ISUP_ContentType", 
				content_disposition:=omit,
				mime_encapsulated_part:={xmlBody := p_xmlBody}}
			}
		}
	}
	
	template MessageBody mw_MBody_SDP(template SDP_Message p_SDP):=
	{
		sdpMessageBody := p_SDP
	};
	
	template MessageBody mw_MBody_XML(template XmlBody p_xmlBody):=
	{
		xmlBody := p_xmlBody
	};
	
	template MessageBody mw_MBody_MIMESdpXml(template SDP_Message p_sdp, template XmlBody p_xmlBody):=
	{
		mimeMessageBody := {boundary:=?, 
			mimeEncapsulatedList:= {
			{content_type:=?, 
				content_disposition:=*,
				mime_encapsulated_part:={sdpMessageBody := p_sdp}},
			{content_type:=?, 
				content_disposition:=*,
				mime_encapsulated_part:={xmlBody := p_xmlBody}}
			}
		}
	}
	
	template MessageBody mw_MBody_MIME_Ims3gpp(
		template charstring p_disposition, 
		template Ims_3gpp p_ims3gpp
	):= {
		mimeMessageBody := {boundary:=?, 
			mimeEncapsulatedList:= {
    			*,
    			{	
    				content_type:= c_ims3gppAplication, 
    				content_disposition:= p_disposition,
    				mime_encapsulated_part :={
    					xmlBody := {
    						ims3gpp := 	p_ims3gpp
    					}
    				}
    			},
    			*
			}
		}
	}
	
	template MessageBody mw_MBody_MIME_Ims3gppCW(
		template charstring p_disposition, 
		template Ims_3gpp p_ims3gpp
	):= {
		mimeMessageBody := {boundary:=?, 
			mimeEncapsulatedList:= {
							*,
							{	
								content_type:= c_ims3gppCwApplication, 
								content_disposition:= p_disposition,
								mime_encapsulated_part :={
									xmlBody := {
										ims3gpp := 	p_ims3gpp
									}
								}
							},
							*
			}
		}
	}	
	
 * @desc group TemplatePreparationFunctions contain functions which are used for templates
 */
group TemplatePreparationFunctions {

  group MessageBody_Calculation{
  	
	/**
	* 
	* @desc Calculation of Message Body length
	* @param p_mb_par contain message body part
	* @return message body length
	*/
	function f_MessageBodyLength(MessageBody p_mb_par) return integer {

		var integer v_result:=0;
		if (MB_LENGTH_FROM_ENCVAL){ //by default it is set to true 
			
            v_result:= lengthof(encvalue(p_mb_par))/8; // length in bypes, let get length of encoded value
		}
		else{ 
        
            //  assume SDP_Message ONLY in the message body
    		if (ischosen(p_mb_par.sdpMessageBody))
    		{ 
    			v_result := f_SDPlength(p_mb_par.sdpMessageBody);
    		};
    
    	    //  assume XML_Body ONLY in the message body
    		if (ischosen(p_mb_par.xmlBody))
    		{ 
    			v_result := f_XMLBody_Length(p_mb_par.xmlBody, USE_FX_FOR_XML_LENGTH );
    		};
    		
            //assume XML_Message ONLY in the message body
            if (ischosen(p_mb_par.xmlMessage))
            { 
            	v_result := f_XMLlength(p_mb_par.xmlMessage, USE_FX_FOR_XML_LENGTH );
            };
    
    		//  assume MIME_Message in the message body
    		if (ischosen(p_mb_par.mimeMessageBody))
    		{ 
    			v_result := f_MIMElength(p_mb_par.mimeMessageBody);
    		};
    		
            //assume sipfrag in the message body
            if (ischosen(p_mb_par.sipfrag))
            { 
            	v_result := f_TextPlainLength(p_mb_par); //same function due to same type with textplain
            };
            
            //assume textplain in the message body
            if (ischosen(p_mb_par.textplain))
            { 
            	v_result := f_TextPlainLength(p_mb_par);
            };
		}

	  return v_result
	}
  	
  	
  group SDP_Len_calculation {	
reinaortega's avatar
reinaortega committed
	 * 
	 * @desc Calculation of SDP length
	 * @param p_mb contain sdp message
	 * @return sdp_lenght
	 */
	function f_SDPlength(SDP_Message p_mb) return integer
	{
	  var integer v_result:=2; //*  due to empty line beginning of message body
	  var charstring v_auxstring;
	  	
	  v_result := 2+c_CRlen + lengthof(int2str(p_mb.protocol_version)); //*  "v="
	  v_result := v_result + 2+c_CRlen + lengthof(p_mb.origin.user_name & " " & 
								  p_mb.origin.session_id & " " & 
								  p_mb.origin.session_version & " " & 
								  p_mb.origin.net_type & " " & 
								  p_mb.origin.addr_type & " " & 
								  p_mb.origin.addr           
								  ); //*  "o="
	  v_result := v_result + 2+c_CRlen + lengthof(p_mb.session_name); //*  "s="
	  if (ispresent(p_mb.information)) 
		{v_auxstring:=p_mb.information; v_result := v_result + 2+c_CRlen + lengthof(v_auxstring);}; //*  "i= "
	  if (ispresent(p_mb.uri)) 
		{v_auxstring:=p_mb.uri; v_result := v_result + 2+c_CRlen + lengthof(v_auxstring);}; //*  "u="
			
	  if (ispresent(p_mb.emails)) {
		for (var integer i:=0; i<sizeof(p_mb.emails); i:=i+1)
		{v_result := v_result + 2+c_CRlen + lengthof(p_mb.emails[i].addr_or_phone); //*  "e="
		if (ispresent(p_mb.emails[i].disp_name)) 
		  {v_auxstring:=p_mb.emails[i].disp_name; v_result := v_result + 1 + lengthof(v_auxstring);};
		};
	  };
			
	  if (ispresent(p_mb.phone_numbers)) {
		for (var integer i:=0; i<sizeof(p_mb.phone_numbers); i:=i+1)
		  {v_result := v_result + 2+c_CRlen + lengthof(p_mb.phone_numbers[i].addr_or_phone); //*  "p= "
		  if (ispresent(p_mb.phone_numbers[i].disp_name)) 
			{v_auxstring:=p_mb.phone_numbers[i].disp_name; v_result := v_result + 1 + lengthof(v_auxstring);};
		};
	  }; 
		    
	  if (ispresent(p_mb.connection)) 
	  {
		var integer v_len_con0 := f_SDPlength_connection(p_mb.connection);
		v_result := v_result + v_len_con0;
			
	  if (ispresent(p_mb.bandwidth))   
	  { 
		for (var integer i:=0; i<sizeof(p_mb.bandwidth); i:=i+1) { //*  "b= "
		  v_result := v_result + 2+c_CRlen + lengthof(p_mb.bandwidth[i].modifier & " ") + 
		  lengthof(int2str(p_mb.bandwidth[i].bandwidth));
		}						
	  };
	
reinaortega's avatar
reinaortega committed
	  for (var integer i:=0; i<sizeof(p_mb.times); i:=i+1) {
		v_result := v_result + 2+c_CRlen + lengthof(p_mb.times[i].time_field.start_time & " "
					 & p_mb.times[i].time_field.stop_time);//*  "t="
									  
		if (ispresent(p_mb.times[i].time_repeat))
		{
		  for (var integer j:=0; j<sizeof(p_mb.times[i].time_repeat); j:=j+1)
			v_result := v_result + 2+c_CRlen + lengthof(int2str(p_mb.times[i].time_repeat[j].repeat_interval.time)); //*  "r="
			if (ispresent(p_mb.times[i].time_repeat[j].repeat_interval.unit)) 
			{
			  v_auxstring:=p_mb.times[i].time_repeat[j].repeat_interval.unit; 
			  v_result := v_result + 1 + lengthof(v_auxstring);
			};					
					
			v_result := v_result + 1 + lengthof(int2str(p_mb.times[i].time_repeat[j].active.time));
			if (ispresent(p_mb.times[i].time_repeat[j].active.unit)) 
			{
			  v_auxstring:=p_mb.times[i].time_repeat[j].active.unit; 
			  v_result := v_result + 1 + lengthof(v_auxstring);
			};
										
			for (var integer k:=0; k<sizeof(p_mb.times[i].time_repeat[j].offsets); k:=k+1)
			{
			  v_result := v_result + 1 + lengthof(int2str(p_mb.times[i].time_repeat[j].offsets[k].time));
			  if (ispresent(p_mb.times[i].time_repeat[j].offsets[k].unit)) 
			  {
				v_auxstring:=p_mb.times[i].time_repeat[j].offsets[k].unit; 
				v_result := v_result + 1 + lengthof(v_auxstring);
			  };
			}		
		  }
		};
	  };

	  if (ispresent(p_mb.timezone_adjustments)) 
		{log("timezone adjustments have not been considered in SDP length calculation yet");
				
	  if (ispresent(p_mb.key)) {
		v_result := v_result + 2+c_CRlen + lengthof(p_mb.key.method); //*  "k= "
		if (ispresent(p_mb.key.key)) 
		   {v_auxstring:=p_mb.key.key; v_result := v_result + 1 + lengthof(v_auxstring);};
	  }; 
	  if (ispresent(p_mb.attributes)) {
		for (var integer i:=0; i<sizeof(p_mb.attributes); i:=i+1){ //*  "a= "
			var integer v_len_con1 := f_SDPlength_attribute(p_mb.attributes[i]);
			v_result := v_result + v_len_con1;
		};

	  if (ispresent(p_mb.media_list)) 
	  {  
        for (var integer i:=0; i<sizeof(p_mb.media_list); i:=i+1){ //*  "m= "
		  //*  for each media_field
		  //* log("p_mb.media_list[i] ",p_mb.media_list[i]);
		  v_result := v_result + 2+c_CRlen + lengthof(p_mb.media_list[i].media_field.media)
							 + 1 + lengthof(int2str(p_mb.media_list[i].media_field.ports.port_number));


		  if (ispresent(p_mb.media_list[i].media_field.ports.num_of_ports)) 
			{v_result := v_result + 1 + lengthof(int2str(p_mb.media_list[i].media_field.ports.num_of_ports));};
		  v_result := v_result + 1 + lengthof(p_mb.media_list[i].media_field.transport);
		  for (var integer j:=0; j<sizeof(p_mb.media_list[i].media_field.fmts); j:=j+1){	
			v_result := v_result + 1 + lengthof(valueof(p_mb.media_list[i].media_field.fmts[j]));
		  }
						
		  if (ispresent(p_mb.media_list[i].information)) {
			v_auxstring:=p_mb.media_list[i].information;
			v_result := v_result + 2+c_CRlen + lengthof(v_auxstring);  //*  "i= "
		  };
		  if (ispresent(p_mb.media_list[i].connections)) {
			for (var integer j:=0; j<sizeof(p_mb.media_list[i].media_field.fmts); j:=j+1){	
			  var integer v_len_con2 :=  f_SDPlength_connection(p_mb.media_list[i].connections[j]);
			  v_result := v_result + v_len_con2;
		  if (ispresent(p_mb.media_list[i].bandwidth)) {  //*  "b= "
poglitsch's avatar
poglitsch committed
			for (var integer j:=0; j<sizeof(p_mb.media_list[i].bandwidth); j:=j+1){	
				v_result := v_result + 2+c_CRlen + lengthof(p_mb.media_list[i].bandwidth[j].modifier)
				+ 1 + lengthof(int2str(p_mb.media_list[i].bandwidth[j].bandwidth));
			}; //*  end for
		  if (ispresent(p_mb.media_list[i].key)) {   //*  "k= "
			v_result := v_result + 1 + lengthof(p_mb.media_list[i].key.method);
			if (ispresent(p_mb.media_list[i].key.key)) {
			  v_auxstring := p_mb.media_list[i].key.key;
			  v_result := v_result + 1 + lengthof(v_auxstring);
			};				
		  };
		  if (ispresent(p_mb.media_list[i].attributes)) {
			for (var integer j:=0; j<sizeof(p_mb.media_list[i].attributes); j:=j+1){ //*  "a= "
			  var integer v_len_attr := f_SDPlength_attribute(p_mb.media_list[i].attributes[j]);
			  v_result := v_result + v_len_attr;
		}; //*  end for i	  	
	  }; //*  end if media_list
	};//* end function f_SDPlength
	function f_SDPlength_connection(SDP_connection p_element) return integer //*  "c="
	{
	  var integer v_result:=0;
	  var charstring v_auxstring;
	  v_result := v_result + 2+c_CRlen + lengthof(p_element.net_type & " " & 
	  p_element.addr_type & " " & 
	  p_element.conn_addr.addr);
	   if (ispresent(p_element.conn_addr.ttl)) 
		  {v_result := v_result + 1 + lengthof(int2str(p_element.conn_addr.ttl));}; 
	   if (ispresent(p_element.conn_addr.num_of_addr)) 
		  {v_result := v_result + 1 + lengthof(int2str(p_element.conn_addr.num_of_addr));};
	   return v_result
	} //*  f_SDPlength_connection
	function f_SDPlength_attribute(SDP_attribute p_element) return integer //*  "a="
	{
	  var integer v_result:=0;
	  var charstring v_auxstring;
	  if (ischosen(p_element.cat)) {v_result := v_result + 2+c_CRlen + lengthof("cat:" & p_element.cat.attr_value)};
	  if (ischosen(p_element.keywds)) {v_result := v_result + 2+c_CRlen + lengthof("keywds:" & p_element.keywds.attr_value)};
	  if (ischosen(p_element.tool)) {v_result := v_result + 2+c_CRlen + lengthof("tool:" & p_element.tool.attr_value)};
	  if (ischosen(p_element.ptime)) {v_result := v_result + 2+c_CRlen + lengthof("ptime:" & p_element.ptime.attr_value)};
	  if (ischosen(p_element.recvonly)) {v_result := v_result + 2+c_CRlen + lengthof("recvonly")};
	  if (ischosen(p_element.sendrecv)) {v_result := v_result + 2+c_CRlen + lengthof("sendrecv")};
	  if (ischosen(p_element.sendonly)) {v_result := v_result + 2+c_CRlen + lengthof("sendonly")};
	  if (ischosen(p_element.inactive)) {v_result := v_result + 2+c_CRlen + lengthof("inactive")};
	  if (ischosen(p_element.orient)) {v_result := v_result + 2+c_CRlen + lengthof("orient:" & p_element.orient.attr_value)};
	  if (ischosen(p_element.sdp_type)) {v_result := v_result + 2+c_CRlen + lengthof("type:" & p_element.sdp_type.attr_value)};
	  if (ischosen(p_element.charset)) {v_result := v_result + 2+c_CRlen + lengthof("charset" & p_element.charset.attr_value)};
	  if (ischosen(p_element.sdplang)) {v_result := v_result + 2+c_CRlen + lengthof("sdplang:" & p_element.sdplang.attr_value)};
	  if (ischosen(p_element.lang)) {v_result := v_result + 2+c_CRlen + lengthof("lang:" & p_element.lang.attr_value)};
	  if (ischosen(p_element.framerate)) {v_result := v_result + 2+c_CRlen + lengthof("framerate:" & p_element.framerate.attr_value)};
	  if (ischosen(p_element.quality)) {v_result := v_result + 2+c_CRlen + lengthof("quality:" & p_element.quality.attr_value)};
	  if (ischosen(p_element.fmtp)) {v_result := v_result + 2+c_CRlen + lengthof("fmtp:" & p_element.fmtp.attr_value)};
	  if (ischosen(p_element.curr)) {v_result := v_result + 2+c_CRlen + lengthof("curr:" & p_element.curr.preconditionType & " " 
										& p_element.curr.statusType & " " & p_element.curr.direction)};
	  if (ischosen(p_element.des)) {v_result := v_result + 2+c_CRlen + lengthof("des:" & p_element.des.preconditionType & " " 
										& p_element.des.strength & " " & p_element.des.statusType & " " & p_element.des.direction)};
	  if (ischosen(p_element.conf)) {v_result := v_result + 2+c_CRlen + lengthof("conf:" & p_element.conf.preconditionType & " " 
										& p_element.des.statusType & " " & p_element.des.direction)};
	  if (ischosen(p_element.rtpmap)) {v_result := v_result + 2+c_CRlen + lengthof("rtpmap:" & p_element.rtpmap.attr_value)};
	  if (ischosen(p_element.rtcp)) {v_result := v_result + 2+c_CRlen + lengthof("rtcp:" & p_element.rtcp.attr_value)};
	  if (ischosen(p_element.unknown)) 
	  {v_result := v_result + 2+c_CRlen + lengthof(p_element.unknown.name);
		if (ispresent(p_element.unknown.attr_value))		   		
		  {var charstring aux := p_element.unknown.attr_value;
			v_result := v_result + lengthof(":" & p_element.unknown.attr_value);
		};
	  };
	  //*  log("axr: length attribute=", v_result);
	} //*  f_SDPlength_attribute
  } //*  group SDPlen_calculation	
2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 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
  group XML_Len_calculation{
		
		/**
		* @desc Declaration of external functions to calculate length of message bodies
		* switching of internal or external functions are made by boolean module parameter/PIXIT
		* USE_FX_FOR_XML_LENGTH declared at top of this module
		*/
		external function fx_calculateXMLMessageLen(XMLMessage p_mb) return integer;
		external function fx_calculateXMLBodyLen(XmlBody p_mb) return integer;
		
		/**
		* 
		* @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)}
	
	/**
	 * 
	 * @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)}
  } //*  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