asterisk: Send P-Associated-URI in IMS Register Response

Change-Id: I4c163f34c052d0463baba799c44fecaaa15be394
diff --git a/asterisk/IMS_ConnectionHandler.ttcn b/asterisk/IMS_ConnectionHandler.ttcn
index 091f5da..a55935a 100644
--- a/asterisk/IMS_ConnectionHandler.ttcn
+++ b/asterisk/IMS_ConnectionHandler.ttcn
@@ -66,6 +66,7 @@
 	charstring user,
 	charstring display_name,
 	charstring password,
+	charstring msisdn,
 	/* Expected User-Location-Info in P-Access-Network-Info */
 	charstring uli_str,
 	octetstring rand,
@@ -150,6 +151,7 @@
 	user := user,
 	display_name := f_sip_str_quote(display_name),
 	password := password,
+	msisdn := "90828",
 	uli_str := "2380100010000101",
 	/* The Nonce field is the Base64 encoded version of the RAND value and concatenated with the AUTN: */
 	rand := '14987631f65f8e3788a0798b6ebcd08e'O,
@@ -404,6 +406,7 @@
 		var template (value) SipAddr to_addr;
 		var template (value) CommaParam_List digestCln ;
 		var template (value) WwwAuthenticate wwwAuthenticate;
+		var template (value) P_Associated_Uri p_associated_uri := ts_P_Associated_Uri({});
 		var template (value) Security_server security_server;
 		var template (value) Server server_name := ts_Server({c_sip_server_name});
 		var template (value) Require require := ts_Require({"sec-agree"});
@@ -487,6 +490,7 @@
 					wwwAuthenticate,
 					sip_seq_nr,
 					"REGISTER",
+					p_associated_uri := p_associated_uri,
 					security_server := security_server,
 					server := server_name,
 					supported := supported,
@@ -537,6 +541,16 @@
 		/* Validate P-Access-Network-Info: */
 		f_ims_validate_register_P_Access_Network_info(g_rx_sip_req, exp_present := true);
 
+		p_associated_uri := ts_P_Associated_Uri({
+				ts_P_Assoc_uri_spec(ts_NameAddr(ts_SipUrl(ts_HostPort(g_pars.realm),
+									  ts_UserInfo(g_pars.msisdn),
+									  scheme := "sip"))),
+				ts_P_Assoc_uri_spec(ts_NameAddr(ts_SipUrl(ts_HostPort(g_pars.msisdn),
+									  omit,
+									  scheme := "tel"))),
+				ts_P_Assoc_uri_spec(g_rx_sip_req.msgHeader.toField.addressField.nameAddr)
+			});
+
 		/* Tx 200 OK */
 		to_addr.params := f_sip_param_set(to_addr.params, "tag", f_sip_rand_tag());
 		tx_resp := ts_SIP_Response(sip_call_id,
@@ -546,6 +560,7 @@
 			sip_seq_nr,
 			"OK",
 			via,
+			p_associated_uri := p_associated_uri,
 			require := require,
 			server := server_name,
 			supported := supported,
diff --git a/library/SIP_Templates.ttcn b/library/SIP_Templates.ttcn
index 56404da..72a4426 100644
--- a/library/SIP_Templates.ttcn
+++ b/library/SIP_Templates.ttcn
@@ -37,16 +37,18 @@
 }
 
 template (value) SipUrl ts_SipUrl(template (value) HostPort host_port,
-				  template (omit) UserInfo user_info := omit) := {
-	scheme := "sip",
+				  template (omit) UserInfo user_info := omit,
+				  template (value) charstring scheme := "sip") := {
+	scheme := scheme,
 	userInfo := user_info,
 	hostPort := host_port,
 	urlParameters := omit,
 	headers := omit
 }
 template (present) SipUrl tr_SipUrl(template (present) HostPort host_port := ?,
-				    template UserInfo user_info := *) := {
-	scheme := "sip",
+				    template UserInfo user_info := *,
+				    template (present) charstring scheme := "sip") := {
+	scheme := scheme,
 	userInfo := user_info,
 	hostPort := host_port,
 	urlParameters := *,
@@ -54,8 +56,9 @@
 }
 
 template (value) SipUrl ts_SipUrlHost(template (value) charstring host,
-				      template (omit) integer portField := omit)
-	:= ts_SipUrl(ts_HostPort(host, portField));
+				      template (omit) integer portField := omit,
+				      template (value) charstring scheme := "sip")
+	:= ts_SipUrl(ts_HostPort(host, portField), scheme := scheme);
 
 function ts_SipUrl_from_Addr_Union(template (value) Addr_Union au)
 return template (value) SipUrl {
@@ -241,6 +244,27 @@
 	access_net_specs := access_net_specs
 }
 
+// [RFC3455 4.1]
+template (present) P_Assoc_uri_spec tr_P_Assoc_uri_spec(template (present) NameAddr p_asso_uri := ?,
+							template SemicolonParam_List ai_params := *) := {
+	p_asso_uri := p_asso_uri,
+	ai_params := ai_params
+}
+template (value) P_Assoc_uri_spec ts_P_Assoc_uri_spec(template (value) NameAddr p_asso_uri,
+						      template (omit) SemicolonParam_List ai_params := omit) := {
+	p_asso_uri := p_asso_uri,
+	ai_params := ai_params
+}
+
+// [RFC3455 4.1]
+template (present) P_Associated_Uri tr_P_Associated_Uri(template (present) P_Assoc_uri_spec_list p_assoc_uris := ?) := {
+	fieldName := P_ASSOCIATED_URI,
+	p_assoc_uris := p_assoc_uris
+}
+template (value) P_Associated_Uri ts_P_Associated_Uri(template (value) P_Assoc_uri_spec_list p_assoc_uris := {}) := {
+	fieldName := P_ASSOCIATED_URI,
+	p_assoc_uris := p_assoc_uris
+}
 
 // [20.32]
 template (value) Require ts_Require(template (value) OptionTag_List optionsTags := {}) := {
@@ -588,6 +612,7 @@
 		template (omit)Authorization authorization := omit,
 		template (omit) Allow allow := ts_Allow(c_SIP_defaultMethods),
 		template (omit) Expires expires := omit,
+		template (omit) P_Associated_Uri p_associated_uri := omit,
 		template (omit) Require require := omit,
 		template (omit) Security_client security_client := omit,
 		template (omit) Security_server security_server := omit,
@@ -616,6 +641,7 @@
 		addressField := from_addr.addr,
 		fromParams := from_addr.params
 	},
+	p_associated_uri := p_associated_uri,
 	require := require,
 	security_client := security_client,
 	security_server := security_server,
@@ -644,6 +670,7 @@
 		template Allow allow := *,
 		template Authorization authorization := *,
 		template Expires expires := *,
+		template P_Associated_Uri p_associated_uri := *,
 		template Require require := *,
 		template Security_client security_client := *,
 		template Security_server security_server := *,
@@ -672,6 +699,7 @@
 		addressField := from_addr.addr,
 		fromParams := from_addr.params
 	},
+	p_associated_uri := p_associated_uri,
 	require := require,
 	security_client := security_client,
 	security_server := security_server,
@@ -864,6 +892,7 @@
 		charstring reason,
 		Via via,
 		template (omit) Allow allow := omit,
+		template (omit) P_Associated_Uri p_associated_uri := omit,
 		template (omit) Require require := omit,
 		template (omit) Server server := omit,
 		template (omit) Supported supported := omit,
@@ -875,6 +904,7 @@
 				     content_length := f_ContentLength(body),
 				     content_type := f_ContentTypeOrOmit(ts_CT_SDP, body),
 				     allow := allow,
+				     p_associated_uri := p_associated_uri,
 				     require := require,
 				     server := server,
 				     supported := supported,
@@ -936,6 +966,7 @@
 	integer seq_nr,
 	charstring method := "REGISTER",
 	template (omit) Allow allow := omit,
+	template (omit) P_Associated_Uri p_associated_uri := omit,
 	template (omit) Security_server security_server := omit,
 	template (omit) Server server := omit,
 	template (omit) Supported supported := omit,
@@ -947,6 +978,7 @@
 				     content_length := f_ContentLength(body),
 				     content_type := f_ContentTypeOrOmit(ts_CT_SDP, body),
 				     allow := allow,
+				     p_associated_uri := p_associated_uri,
 				     security_server := security_server,
 				     server := server,
 				     supported := supported,