LibSip_Templates.ttcn 79.2 KB
Newer Older
 *  @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 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"
				userInfo:= {userOrTelephoneSubscriber:=?, password:=*},
				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 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) :=
		{
		  host  := p_host,
		  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_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 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,
			pAssertedIDValueList := {p_pAssertedIDValue}
		};

		template PAssertedIDValue mw_PAssertedIDValue(template SipUrl p_SipUrl) := 
		{
			addrSpecUnion := 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}
		};
rennoch's avatar
rennoch committed
		template Privacy mw_Privacy_without(PrivacyValue p_privacy) := 
		{
			fieldName := PRIVACY_E,
reinaortega's avatar
reinaortega committed
			privValueList := ?//superset(complement(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 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"
		}
		
		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)),
			toParams := omit
		}

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

		template ViaBody m_ViaBody_currIpaddr(charstring branch_val,in SipUserProfile p_userprofile) :=
		{
		  sentProtocol := m_SentProtocol(PX_SIP_TRANSPORT),
		  sentBy:={host:=p_userprofile.currIpaddr, portField:= p_userprofile.currPort},
		  viaParams:={{id :=c_branchId,paramValue :=branch_val}}
		}
		
		template ViaBody mw_ViaBody_interface(HostPort p_hostport) :=
		{
		  sentProtocol := m_SentProtocol(PX_SIP_TRANSPORT),
		  sentBy:={host:=p_hostport.host, portField:= p_hostport.portField},
		  viaParams:=*
		}

		template Via mw_Via(template ViaBody p_viabody) :=
		{
		  fieldName := VIA_E,
		  viaBody:= ? //*  superset(p_viabody)
		}
		
		template CallId mw_CallId_any :=
		{
		  fieldName := CALL_ID_E,
		  callid := ?
		}

		template Privacy mw_Privacy_id := 
		{
			fieldName := PRIVACY_E,
			privValueList := {*,"id",*}
		};
		
		template Privacy mw_Privacy_notId := 
		{
			fieldName := PRIVACY_E,
reinaortega's avatar
reinaortega committed
			privValueList := ?//superset(complement("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)
		}
				
		template Contact mw_Contact_conference :=
		{
		  fieldName := CONTACT_E,
		  contactBody :=
		  {
			contactAddresses :=
			{
			  {
				contactParams := {{"isfocus",*}}
			  }
			}
		  } 
		}
	} //*  end of group HeaderFieldTemplates


group MessageTemplates {
group dummy_templates {
  group dummy_parameter_send {

	template RequestLine m_requestLine_dummy := 
	{
		method := ACK_E,
		requestUri := c_empty_RequestUri,
		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,
		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 := ACK_E,
		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
		inReplyTo := *,
		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 := *,
		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,
		msgHeader := m_msgHeader_dummy,
		messageBody := omit,
		payload := omit
	}

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

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

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

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

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

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

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

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

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

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

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

	template UPDATE_Request m_UPDATE_Dummy :=
	{
		requestLine	:= m_requestLine_dummy,
		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,
		msgHeader := mw_msgHeader_dummy,
		messageBody := *,
		payload := *
	}

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

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

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

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

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

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

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

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

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

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

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

	template UPDATE_Request mw_UPDATE_Dummy :=
	{
		requestLine	:= mw_requestLine_dummy,
		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	:=
			{
				method := ACK_E,
				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	:=
			{
				method := BYE_E,
				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	:=
			{
				method := CANCEL_E,
				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	:=
			{
				method := INFO_E,
				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	:=
		  	{
				method := INVITE_E,
				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	:=
			{
				method := MESSAGE_E,
				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	:=
			{
				method := NOTIFY_E,
				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	:=
			{
				method := PRACK_E,
				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	:=
			{
				method := PUBLISH_E,
				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	:=
			{
				method := REFER_E,
				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 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	:=
			{
				method := REGISTER_E,
				requestUri := p_requestUri
			},
			msgHeader :=
			{
				authorization := p_authorization,
				callId := p_callId,
				contact	:= p_contact,
				cSeq		:= p_cSeq,
				fromField	:= p_from,
				toField		:= p_to,
				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	:=
			{
				method := SUBSCRIBE_E,
				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	:=
			{
				method := UPDATE_E,
				requestUri :=
				{
					hostPort:= p_requestUri.hostPort
				}
			},
			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 :=
		{
			requestLine	:=
			{
				method := ACK_E
			},
			msgHeader :=
			{
				callId		:= p_callId
			}
		}
		
		template BYE_Request mw_BYE_Request_Base(template CallId p_callId) modifies mw_BYE_Dummy :=
		  {
			requestLine	:=
			{
				method := BYE_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template CANCEL_Request mw_CANCEL_Request_Base (template CallId p_callId) modifies mw_CANCEL_Dummy :=
		{
			requestLine	:=
			{
				method := CANCEL_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}
  
		template INFO_Request mw_INFO_Request_Base(template CallId p_callId) modifies mw_INFO_Dummy :=
		{
			requestLine	:=
			{
				method := INFO_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}

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

		template MESSAGE_Request mw_MESSAGE_Request_Base(template CallId p_callId) modifies mw_MESSAGE_Dummy :=
		{
			requestLine	:=
			{
				method := MESSAGE_E
			},
			msgHeader :=
			{
				callId := p_callId,
				contact := omit
			}
		}

		template NOTIFY_Request mw_NOTIFY_Request_Base (CallId p_callId) modifies mw_NOTIFY_Dummy :=
		{
			requestLine	:=
			{
				method := NOTIFY_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template PRACK_Request mw_PRACK_Request_Base(template CallId p_callId) modifies mw_PRACK_Dummy :=
		{
			requestLine	:=
			{
				method := PRACK_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		template PUBLISH_Request mw_PUBLISH_Request_Base(template CallId p_callId) modifies mw_PUBLISH_Dummy :=
		{
			requestLine	:=
			{
				method := PUBLISH_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}

		template REFER_Request mw_REFER_Request_Base (CallId p_callId) modifies mw_REFER_Dummy :=
		{
			requestLine	:=
			{
				method := REFER_E
			},
			msgHeader :=
			{
				callId := p_callId
			}
		}
		
		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 :=
		{
			requestLine	:=
			{
				method := UPDATE_E
			},
			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)
		}
	}

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 (CallId p_callId, template MessageBody p_mb) modifies mw_INVITE_Request_Base :=
	{
		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
	}
	
    template NOTIFY_Request mw_NOTIFY_Request_MB (CallId p_callId, template MessageBody p_mb) modifies mw_NOTIFY_Request_Base :=
    {
		messageBody := p_mb
    }
} //*  end group request_receive	

group response_send {	

	template Response m_Response_ext (StatusLine p_statusLine, CallId p_callId, CSeq p_cSeq,
	  From p_from, To p_to, Via p_via) modifies m_Response_Base:=
	{
		msgHeader :={
			route 		:= f_route(),
			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, 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 PAssertedID p_pAssertedID, template Privacy p_privacy) modifies m_Response_ext:=
	{
		msgHeader :=
				{
						pAssertedID := p_pAssertedID,
						privacy := p_privacy
				}
	}
			
	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 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
	  }
	}
	
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
       }
     }
	
} //*  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,
				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}}
			}
		}
	}
}
/*
 * @desc group TemplatePreparationFunctions contain functions which are used for templates
 */
group TemplatePreparationFunctions {

  group SDPlen_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:=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; j<sizeof(p_mb.times[i].time_repeat[j].offsets[k]); 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= "
		  	v_result := v_result + 2+c_CRlen + lengthof(p_mb.media_list[i].bandwidth.modifier)
						+ 1 + lengthof(int2str(p_mb.media_list[i].bandwidth.bandwidth));
		  };
		  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

	/**
		 * 
		 * @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:=2;
	  v_result:=v_result+lengthof(p_mb.textplain);
	  
	  return v_result;
	};//* end function f_SDPlength
		
	/**
	 * 
	 * @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;

		//*  assume SDP_Message ONLY in the message body
		if (ischosen(p_mb_par.sdpMessageBody))
		{ 
			v_result := f_SDPlength(p_mb_par.sdpMessageBody);
		};
// TODO f_XMLlength and f_MIMElength
 /*       //  assume XML_Message ONLY in the message body
        if (ischosen(p_mb_par.xmlBody))
        { 
        	v_result := f_XMLlength(p_mb_par.xmlBody);
        };

		//  assume MIME_Message in the message body
		if (ischosen(p_mb_par.mimeMessageBody))
		{ 
			v_result := f_MIMElength(p_mb_par.mimeMessageBody);
		};
*/
	return v_result
	};

	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	

  


  group GiveHeaders {
	/**
	 * 
	 * @desc Return component variable of recordRoute header if vc_boo_recordRoute is true
	 * @return component variable of recordRoute header
	 */
rennoch's avatar
rennoch committed
//TODO: clarify if function defined on SipComponent can be used in templates
//	function f_recordroute() runs on SipComponent return template RecordRoute
//	{
//	  if (vc_boo_recordRoute)
//		  {return vc_recordRoute}
//	  else {return(omit)}
//	}
	function f_recordroute() return template RecordRoute
rennoch's avatar
rennoch committed
		return(omit)
	}	
	
	/**
	 * 
	 * @desc Return component variable of Route header if vc_boo_route is true
	 * @return component variable of recordRoute header
	 */	
rennoch's avatar
rennoch committed
//TODO: clarify if function defined on SipComponent can be used in templates
//	function f_route() runs on SipComponent return template RecordRoute
//	{
//	  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(omit)}
//	}
	function f_route() return template RecordRoute
	{
		return(omit)
	}	
	/**
		* 
		* @desc Return RecordRoute (2nd parameter) if recordRoute indicator (1st parameter) is true
		* @return recordRoute header
		*/
	function f_recordroute_par(in boolean p_boo_recordRoute, in RecordRoute p_RecordRoute) return template RecordRoute
	{
			if (p_boo_recordRoute)
				{return p_RecordRoute}
			else {return(omit)}
	}
	
	/**
		* 
		* @desc Return Route (2nd parameter) if recordRoute indicator (1st parameter) is true
		* @return Route header
		*/	
	function f_route_par(in boolean p_boo_recordRoute, in Route p_Route) return template Route
rennoch's avatar
rennoch committed
			if (p_boo_recordRoute)
				{return p_Route} //*  TODO: Route header need to be in reverse order than RecordRoute, question of return value - RecordRoute 
			else {return(omit)}
  } //*  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 CommaParam_List p_result;
  	var integer limit1 := sizeof(p_list1);
  	for (var integer i:=0; i<limit1; i:=i+1) {
  		p_result[i] := p_list1[i]
  	};
	for (var integer i:=limit1; i<limit1+sizeof(p_list2); i:=i+1) {
		p_result[i] := p_list2[i]
	};
	return p_result
  }
  
} //* group TemplatePreparationFunctions
} //*  end module LibSip_Templates