asterisk: Allow passing full templates to {tr,ts}_SIP_msgh_std
It may have been a great idea at first to have this SipAddr record
unifying several records, and it may be so under certain circumstances,
but clearly it's not the case when passing them to generic tr_* templates
(like the _std_ one in SIP) which then have to access specific fields of
those records. This will crash if for instance a (tr_...(), tr_...())
compound is passed.
This is a next step towards getting rid of SipAddress in lower level
templates, which the SIP specific enc/dec doesn't understand and creates
several kinds of troubles like the one mentioned above.
Change-Id: I3a85701822d7b76ec078b1a7c615e5ef50f36902
diff --git a/asterisk/IMS_ConnectionHandler.ttcn b/asterisk/IMS_ConnectionHandler.ttcn
index a55935a..a253c9f 100644
--- a/asterisk/IMS_ConnectionHandler.ttcn
+++ b/asterisk/IMS_ConnectionHandler.ttcn
@@ -388,8 +388,8 @@
var template (present) PDU_SIP_Request exp_req :=
tr_SIP_REGISTER(g_pars.registrar_sip_req_uri,
?,
- tr_SipAddr(),
- tr_SipAddr(),
+ tr_From(),
+ tr_To(),
tr_Via_from(?),
require := tr_Require(superset("sec-agree")),
security_client := tr_Security_client(superset(tr_Security_mechanism("ipsec-3gpp",
@@ -402,8 +402,8 @@
var Via via;
var CallidString sip_call_id;
var Contact contact;
- var template (value) SipAddr from_addr;
- var template (value) SipAddr to_addr;
+ var template (value) From from_addr;
+ var template (value) To 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({});
@@ -418,10 +418,8 @@
sip_call_id := g_rx_sip_req.msgHeader.callId.callid;
via := g_rx_sip_req.msgHeader.via;
via.viaBody[0].viaParams := f_sip_param_set(via.viaBody[0].viaParams, "rport", "1234"); /* TODO: set remote src port of the REGISTER */
- from_addr := ts_SipAddr_from_Addr_Union(g_rx_sip_req.msgHeader.fromField.addressField,
- g_rx_sip_req.msgHeader.fromField.fromParams);
- to_addr := ts_SipAddr_from_Addr_Union(g_rx_sip_req.msgHeader.toField.addressField,
- g_rx_sip_req.msgHeader.toField.toParams);
+ from_addr := g_rx_sip_req.msgHeader.fromField;
+ to_addr := g_rx_sip_req.msgHeader.toField;
sip_seq_nr := g_rx_sip_req.msgHeader.cSeq.seqNumber;
contact := g_rx_sip_req.msgHeader.contact;
@@ -455,7 +453,7 @@
f_ims_parse_security_client(g_rx_sip_req.msgHeader.security_client);
f_ims_setup_ipsec();
- to_addr.params := f_sip_param_set(to_addr.params, "tag", f_sip_rand_tag());
+ to_addr.toParams := f_sip_param_set(to_addr.toParams, "tag", f_sip_rand_tag());
digestCln := {
ts_Param("realm", f_sip_str_quote(g_pars.realm)),
@@ -512,18 +510,16 @@
exp_req :=
tr_SIP_REGISTER(g_pars.registrar_sip_req_uri,
?,
- tr_SipAddr(),
- tr_SipAddr(),
+ tr_From(),
+ tr_To(),
tr_Via_from(?),
authorization := authorization);
SIP.receive(exp_req) -> value g_rx_sip_req;
sip_call_id := g_rx_sip_req.msgHeader.callId.callid;
via := g_rx_sip_req.msgHeader.via;
- from_addr := ts_SipAddr_from_Addr_Union(g_rx_sip_req.msgHeader.fromField.addressField,
- g_rx_sip_req.msgHeader.fromField.fromParams);
- to_addr := ts_SipAddr_from_Addr_Union(g_rx_sip_req.msgHeader.toField.addressField,
- g_rx_sip_req.msgHeader.toField.toParams);
+ from_addr := g_rx_sip_req.msgHeader.fromField;
+ to_addr := g_rx_sip_req.msgHeader.toField;
sip_seq_nr := g_rx_sip_req.msgHeader.cSeq.seqNumber;
/* Tx 100 Trying */
@@ -552,7 +548,7 @@
});
/* Tx 200 OK */
- to_addr.params := f_sip_param_set(to_addr.params, "tag", f_sip_rand_tag());
+ to_addr.toParams := f_sip_param_set(to_addr.toParams, "tag", f_sip_rand_tag());
tx_resp := ts_SIP_Response(sip_call_id,
from_addr,
to_addr,
diff --git a/asterisk/SIP_ConnectionHandler.ttcn b/asterisk/SIP_ConnectionHandler.ttcn
index 9c7cca5..41a29e4 100644
--- a/asterisk/SIP_ConnectionHandler.ttcn
+++ b/asterisk/SIP_ConnectionHandler.ttcn
@@ -80,8 +80,8 @@
SipAddr calling optional,
SipAddr called optional,
- SipAddr from_addr optional,
- SipAddr to_addr optional,
+ From from_addr optional,
+ To to_addr optional,
CallidString sip_call_id,
integer sip_seq_nr,
@@ -263,7 +263,9 @@
var template (present) PDU_SIP_Response exp;
var Authorization authorization;
var Via via := g_pars.local_via;
- var SipAddr from_sipaddr := g_pars.registrar_sip_record;
+ var From from_addr := valueof(ts_From(g_pars.registrar_sip_record.addr, g_pars.registrar_sip_record.params));
+ var To to_addr := valueof(ts_To(g_pars.registrar_sip_record.addr, g_pars.registrar_sip_record.params));
+ var template (present) To to_addr_exp := tr_To(tr_Addr_Union_from_val(to_addr.addressField), *);
var charstring branch_value;
branch_value := f_sip_gen_branch(f_sip_SipAddr_to_str(g_pars.registrar_sip_record),
@@ -272,11 +274,11 @@
g_pars.registrar_sip_seq_nr);
via.viaBody[0].viaParams := f_sip_param_set(via.viaBody[0].viaParams, "branch", branch_value);
- from_sipaddr.params := f_sip_param_set(from_sipaddr.params, "tag", f_sip_rand_tag());
+ from_addr.fromParams := f_sip_param_set(from_addr.fromParams, "tag", f_sip_rand_tag());
SIP.send(ts_SIP_REGISTER(g_pars.registrar_sip_req_uri,
g_pars.registrar_sip_call_id,
- from_sipaddr,
- g_pars.registrar_sip_record,
+ from_addr,
+ to_addr,
via,
g_pars.registrar_sip_seq_nr,
g_pars.local_contact,
@@ -284,8 +286,8 @@
exp := tr_SIP_Response_Unauthorized(
g_pars.registrar_sip_call_id,
- from_sipaddr,
- f_tr_To_response(g_pars.registrar_sip_record),
+ from_addr,
+ to_addr_exp,
f_tr_Via_response(via),
*,
tr_WwwAuthenticate({tr_Challenge_digestCln(?)}),
@@ -308,8 +310,8 @@
SIP.send(ts_SIP_REGISTER(g_pars.registrar_sip_req_uri,
g_pars.registrar_sip_call_id,
- from_sipaddr,
- g_pars.registrar_sip_record,
+ from_addr,
+ to_addr,
via,
g_pars.registrar_sip_seq_nr,
g_pars.local_contact,
@@ -319,8 +321,8 @@
/* Wait for OK answer */
exp := tr_SIP_Response(
g_pars.registrar_sip_call_id,
- from_sipaddr,
- f_tr_To_response(g_pars.registrar_sip_record),
+ from_addr,
+ to_addr_exp,
f_tr_Via_response(via),
*,
"REGISTER", 200,
@@ -336,17 +338,21 @@
{
var template (value) PDU_SIP_Request req;
var template (present) PDU_SIP_Response exp;
+ var template (present) From from_addr_exp;
+ var template (present) To to_addr_exp;
var Via via;
var charstring tx_sdp := f_gen_sdp();
var default d_trying, d_ringing;
var charstring branch_value;
/* RFC 3261 8.1.1.3 From */
- g_pars.cp.from_addr := g_pars.cp.calling;
- g_pars.cp.from_addr.params := f_sip_param_set(g_pars.cp.from_addr.params, "tag", f_sip_rand_tag());
- g_pars.cp.to_addr := g_pars.cp.called;
- branch_value := f_sip_gen_branch(f_sip_SipAddr_to_str(g_pars.cp.from_addr),
- f_sip_SipAddr_to_str(valueof(g_pars.cp.to_addr)),
+ g_pars.cp.from_addr := valueof(ts_From(g_pars.cp.calling.addr, g_pars.cp.calling.params));
+ g_pars.cp.from_addr.fromParams := f_sip_param_set(g_pars.cp.from_addr.fromParams, "tag", f_sip_rand_tag());
+ g_pars.cp.to_addr := valueof(ts_To(g_pars.cp.called.addr, g_pars.cp.called.params));
+ from_addr_exp := tr_From(tr_Addr_Union_from_val(g_pars.cp.from_addr.addressField), *);
+ to_addr_exp := tr_To(tr_Addr_Union_from_val(g_pars.cp.to_addr.addressField), *);
+ branch_value := f_sip_gen_branch(f_sip_Addr_Union_to_str(g_pars.cp.from_addr.addressField),
+ f_sip_Addr_Union_to_str(valueof(g_pars.cp.to_addr.addressField)),
g_pars.cp.sip_call_id,
g_pars.cp.sip_seq_nr);
via := g_pars.local_via;
@@ -365,8 +371,8 @@
/* RFC 3261 22.2: */
exp := tr_SIP_Response_Unauthorized(
g_pars.cp.sip_call_id,
- f_tr_From(g_pars.cp.from_addr),
- f_tr_To_response(g_pars.cp.to_addr),
+ from_addr_exp,
+ to_addr_exp,
f_tr_Via_response(via),
*,
tr_WwwAuthenticate({tr_Challenge_digestCln(?)}),
@@ -385,16 +391,16 @@
/* Conditionally match and accept 100 Trying. */
exp := tr_SIP_Response_Trying(g_pars.cp.sip_call_id,
- g_pars.cp.from_addr,
- f_tr_To_response(g_pars.cp.to_addr),
+ from_addr_exp,
+ to_addr_exp,
f_tr_Via_response(via),
g_pars.cp.sip_seq_nr, "INVITE");
d_trying := activate(as_SIP_ignore_resp(exp));
/* Conditionally match and accept 180 Ringing */
exp := tr_SIP_Response_Ringing(g_pars.cp.sip_call_id,
- g_pars.cp.from_addr,
- f_tr_To_response(g_pars.cp.to_addr),
+ from_addr_exp,
+ to_addr_exp,
f_tr_Via_response(via),
g_pars.cp.sip_seq_nr, "INVITE");
d_ringing := activate(as_SIP_ignore_resp(exp));
@@ -402,8 +408,8 @@
/* Wait for OK answer */
exp := tr_SIP_Response(
g_pars.cp.sip_call_id,
- g_pars.cp.from_addr,
- f_tr_To_response(g_pars.cp.to_addr),
+ from_addr_exp,
+ to_addr_exp,
f_tr_Via_response(via),
*,
"INVITE", 200,
@@ -415,8 +421,7 @@
deactivate(d_ringing);
/* Update To with the tags received from peer: */
- g_pars.cp.to_addr := valueof(ts_SipAddr_from_Addr_Union(g_rx_sip_resp.msgHeader.toField.addressField,
- g_rx_sip_resp.msgHeader.toField.toParams));
+ g_pars.cp.to_addr := g_rx_sip_resp.msgHeader.toField;
/* Transmit ACK */
g_pars.cp.sip_seq_nr := g_pars.cp.sip_seq_nr + 1;
@@ -437,11 +442,9 @@
/* Obtain params: */
g_pars.cp.sip_call_id := rx_sip_req.msgHeader.callId.callid;
- g_pars.cp.from_addr := valueof(ts_SipAddr_from_Addr_Union(rx_sip_req.msgHeader.fromField.addressField,
- rx_sip_req.msgHeader.fromField.fromParams));
- g_pars.cp.to_addr := valueof(ts_SipAddr_from_Addr_Union(rx_sip_req.msgHeader.toField.addressField,
- rx_sip_req.msgHeader.toField.toParams));
- g_pars.cp.to_addr.params := f_sip_param_set(g_pars.cp.to_addr.params, "tag", f_sip_rand_tag());
+ g_pars.cp.from_addr := rx_sip_req.msgHeader.fromField;
+ g_pars.cp.to_addr := rx_sip_req.msgHeader.toField;
+ g_pars.cp.to_addr.toParams := f_sip_param_set(g_pars.cp.to_addr.toParams, "tag", f_sip_rand_tag());
g_pars.cp.sip_seq_nr := rx_sip_req.msgHeader.cSeq.seqNumber;
}
@@ -452,8 +455,8 @@
var template (present) PDU_SIP_Request exp_req :=
tr_SIP_INVITE(f_tr_SipUrl_opt_defport(g_pars.local_sip_url_ext),
?,
- f_tr_From(g_pars.cp.calling),
- g_pars.cp.called,
+ tr_From(tr_Addr_Union_from_val(g_pars.cp.calling.addr), *),
+ tr_To(tr_Addr_Union_from_val(g_pars.cp.called.addr), *),
tr_Via_from(f_tr_HostPort(g_pars.remote_sip_host, g_pars.remote_sip_port)),
?, ?);
var charstring sip_expect_str := log2str(exp_req);
@@ -518,8 +521,8 @@
var template (present) PDU_SIP_Request exp_req :=
tr_SIP_INVITE(f_tr_SipUrl_opt_defport(g_pars.local_sip_url_ext),
?,
- f_tr_From(g_pars.cp.calling),
- g_pars.cp.called,
+ tr_From(tr_Addr_Union_from_val(g_pars.cp.calling.addr), *),
+ tr_To(tr_Addr_Union_from_val(g_pars.cp.called.addr), *),
tr_Via_from(f_tr_HostPort(g_pars.remote_sip_host, g_pars.remote_sip_port)),
?, ?);
var charstring sip_expect_str := log2str(exp_req);
@@ -527,7 +530,7 @@
[] SIP.receive(exp_req) -> value g_rx_sip_req {
var template (value) PDU_SIP_Response tx_resp;
var Via via;
- var template (present) SipAddr exp_to_addr;
+ var template (present) To exp_to_addr;
var charstring tx_sdp;
/* Obtain params: */
@@ -550,8 +553,7 @@
/* Wait for CANCEL */
/* Cancel may come even before we send Ringing, hence To's "tag"
* may not be known by peer, so g_pars.to_addr can't be used here: */
- exp_to_addr := ts_SipAddr_from_Addr_Union(g_rx_sip_req.msgHeader.toField.addressField,
- g_rx_sip_req.msgHeader.toField.toParams);
+ exp_to_addr := g_rx_sip_req.msgHeader.toField;
exp_req := tr_SIP_CANCEL(f_tr_SipUrl_opt_defport(g_pars.local_sip_url_ext),
g_pars.cp.sip_call_id,
g_pars.cp.from_addr,
@@ -636,8 +638,8 @@
var Via via;
var charstring branch_value;
- branch_value := f_sip_gen_branch(f_sip_SipAddr_to_str(g_pars.cp.from_addr),
- f_sip_SipAddr_to_str(valueof(g_pars.cp.to_addr)),
+ branch_value := f_sip_gen_branch(f_sip_Addr_Union_to_str(g_pars.cp.from_addr.addressField),
+ f_sip_Addr_Union_to_str(valueof(g_pars.cp.to_addr.addressField)),
g_pars.cp.sip_call_id,
g_pars.cp.sip_seq_nr);
@@ -657,7 +659,7 @@
exp_resp := tr_SIP_Response(
g_pars.cp.sip_call_id,
g_pars.cp.from_addr,
- f_tr_To_response(g_pars.cp.to_addr),
+ tr_To(tr_Addr_Union_from_val(g_pars.cp.to_addr.addressField), *),
f_tr_Via_response(via),
*,
"BYE", 200,