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,
diff --git a/library/SIP_Templates.ttcn b/library/SIP_Templates.ttcn
index 72a4426..9f45b9f 100644
--- a/library/SIP_Templates.ttcn
+++ b/library/SIP_Templates.ttcn
@@ -227,6 +227,20 @@
deltaSec := deltaSec
}
+// [20.20]
+template (value) From ts_From(template (value) Addr_Union addressField,
+ template (omit) SemicolonParam_List fromParams := omit) := {
+ fieldName := FROM_E,
+ addressField := addressField,
+ fromParams := fromParams
+}
+template (present) From tr_From(template (present) Addr_Union addressField := ?,
+ template SemicolonParam_List fromParams := *) := {
+ fieldName := FROM_E,
+ addressField := addressField,
+ fromParams := fromParams
+}
+
// [RFC3455 5.4] + 3GPP 24.229 V8.7.0
template (present) Access_net_spec tr_Access_net_spec(template (present) charstring access_type := ?,
template SemicolonParam_List access_info := *) := {
@@ -296,6 +310,20 @@
optionsTags := optionsTags
}
+// [20.39]
+template (value) To ts_To(template (value) Addr_Union addressField,
+ template (omit) SemicolonParam_List toParams := omit) := {
+ fieldName := TO_E,
+ addressField := addressField,
+ toParams := toParams
+}
+template (present) To tr_To(template (present) Addr_Union addressField := ?,
+ template SemicolonParam_List toParams := *) := {
+ fieldName := TO_E,
+ addressField := addressField,
+ toParams := toParams
+}
+
// [20.41 RFC2616 14.43]
template (value) UserAgent ts_UserAgent(template (value) ServerVal_List userAgentBody := {}) := {
fieldName := USER_AGENT_E,
@@ -347,17 +375,24 @@
return ret;
}
+function tr_Addr_Union_from_val(template (value) Addr_Union tin) return template (present) Addr_Union {
+ var template (present) Addr_Union ret := tin;
+
+ if (not ispresent(tin.nameAddr.displayName)) {
+ ret.nameAddr.displayName := *;
+ } else if (f_str_tolower(f_sip_str_unquote(tin.nameAddr.displayName)) == "anonymous") {
+ /* if the user is Anonymous, it may be omitted */
+ ret.nameAddr.displayName := tin.nameAddr.displayName ifpresent;
+ }
+
+ ret.nameAddr.addrSpec := tr_SipUrl_from_val(tin.nameAddr.addrSpec);
+
+ return ret;
+}
function tr_SipAddr_from_val(template (value) SipAddr tin) return template (present) SipAddr {
var template (present) SipAddr ret := tin;
- if (not ispresent(tin.addr.nameAddr.displayName)) {
- ret.addr.nameAddr.displayName := *;
- } else if (f_str_tolower(f_sip_str_unquote(tin.addr.nameAddr.displayName)) == "anonymous") {
- /* if the user is Anonymous, it may be omitted */
- ret.addr.nameAddr.displayName := tin.addr.nameAddr.displayName ifpresent;
- }
-
- ret.addr.nameAddr.addrSpec := tr_SipUrl_from_val(tin.addr.nameAddr.addrSpec);
+ ret.addr := tr_Addr_Union_from_val(tin.addr);
if (not ispresent(tin.params)) {
ret.params := *;
@@ -601,8 +636,8 @@
template (value) MessageHeader ts_SIP_msgHeader_empty := c_SIP_msgHeader_empty;
template (value) MessageHeader
ts_SIP_msgh_std(template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
template (omit) Contact contact,
template (value) charstring method,
template (value) integer seq_nr,
@@ -636,22 +671,14 @@
method := method
},
expires := expires,
- fromField := {
- fieldName := FROM_E,
- addressField := from_addr.addr,
- fromParams := from_addr.params
- },
+ fromField := from_addr,
p_associated_uri := p_associated_uri,
require := require,
security_client := security_client,
security_server := security_server,
server := server,
supported := supported,
- toField := {
- fieldName := TO_E,
- addressField := to_addr.addr,
- toParams := to_addr.params
- },
+ toField := to_addr,
userAgent := userAgent,
via := via,
wwwAuthenticate := wwwAuthenticate
@@ -659,8 +686,8 @@
template (present) MessageHeader
tr_SIP_msgh_std(template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template Contact contact,
template (present) Via via := tr_Via_from(?),
template charstring method,
@@ -694,22 +721,14 @@
method := method
},
expires := expires,
- fromField := {
- fieldName := FROM_E,
- addressField := from_addr.addr,
- fromParams := from_addr.params
- },
+ fromField := from_addr,
p_associated_uri := p_associated_uri,
require := require,
security_client := security_client,
security_server := security_server,
server := server,
supported := supported,
- toField := {
- fieldName := TO_E,
- addressField := to_addr.addr,
- toParams := to_addr.params
- },
+ toField := to_addr,
userAgent := userAgent,
via := via,
wwwAuthenticate := wwwAuthenticate
@@ -719,8 +738,8 @@
template (value) PDU_SIP_Request
ts_SIP_REGISTER(template (value) SipUrl sip_url_host_port,
template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
template (value) Via via,
integer seq_nr,
template (omit) Contact contact,
@@ -746,8 +765,8 @@
template (present) PDU_SIP_Request
tr_SIP_REGISTER(template (present) SipUrl sip_url_host_port := ?,
template (present) CallidString call_id := ?,
- template (present) SipAddr from_addr := ?,
- template (present) SipAddr to_addr := ?,
+ template (present) From from_addr := ?,
+ template (present) To to_addr := ?,
template (present) Via via := tr_Via_from(f_tr_HostPort_opt_defport(?)),
template integer seq_nr := *,
template Authorization authorization := *,
@@ -771,13 +790,13 @@
template (value) PDU_SIP_Request
ts_SIP_INVITE(template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
template (value) Via via,
template (value) Contact contact,
integer seq_nr,
template (omit) charstring body := omit) := {
- requestLine := ts_SIP_ReqLine(INVITE_E, to_addr.addr.nameAddr.addrSpec),
+ requestLine := ts_SIP_ReqLine(INVITE_E, to_addr.addressField.nameAddr.addrSpec),
msgHeader := ts_SIP_msgh_std(call_id, from_addr, to_addr, contact,
"INVITE", seq_nr,
via,
@@ -789,8 +808,8 @@
template (present) PDU_SIP_Request
tr_SIP_INVITE(template (present) SipUrl uri,
template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template Via via := tr_Via_from(f_tr_HostPort_opt_defport(?)),
template integer seq_nr,
template charstring body) := {
@@ -803,12 +822,12 @@
template (value) PDU_SIP_Request
ts_SIP_BYE(CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
template (value) Via via,
integer seq_nr,
template (omit) charstring body) := {
- requestLine := ts_SIP_ReqLine(BYE_E, to_addr.addr.nameAddr.addrSpec),
+ requestLine := ts_SIP_ReqLine(BYE_E, to_addr.addressField.nameAddr.addrSpec),
msgHeader := ts_SIP_msgh_std(call_id, from_addr, to_addr, omit, "BYE", seq_nr,
via,
content_length := f_ContentLength(body),
@@ -820,8 +839,8 @@
template (present) PDU_SIP_Request
tr_SIP_BYE(template (present) SipUrl uri,
template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template Via via,
template integer seq_nr,
template charstring body := *) := {
@@ -835,14 +854,14 @@
template (value) PDU_SIP_Request
ts_SIP_ACK(template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
template (value) Via via,
integer seq_nr,
template (omit) charstring body) := {
- requestLine := ts_SIP_ReqLine(ACK_E, to_addr.addr.nameAddr.addrSpec),
+ requestLine := ts_SIP_ReqLine(ACK_E, to_addr.addressField.nameAddr.addrSpec),
msgHeader := ts_SIP_msgh_std(call_id, from_addr, to_addr,
- ts_Contact_SipAddr(from_addr),
+ ts_Contact({ ts_ContactAddress(from_addr.addressField, from_addr.fromParams) }),
"ACK", seq_nr,
via,
content_length := f_ContentLength(body),
@@ -853,8 +872,8 @@
template (present) PDU_SIP_Request
tr_SIP_ACK(template (present) SipUrl uri,
template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template Via via,
template integer seq_nr,
template charstring body) := {
@@ -869,8 +888,8 @@
template (present) PDU_SIP_Request
tr_SIP_CANCEL(template (present) SipUrl uri,
template (present) CallidString call_id,
- template (present) SipAddr from_addr,
- template (present) SipAddr to_addr,
+ template (present) From from_addr,
+ template (present) To to_addr,
template (present) Via via,
template (present) integer seq_nr,
template charstring body := *) := {
@@ -884,8 +903,8 @@
template (value) PDU_SIP_Response
ts_SIP_Response(template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
charstring method,
integer status_code,
integer seq_nr,
@@ -916,8 +935,8 @@
template (value) PDU_SIP_Response
ts_SIP_Response_Trying(
template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
Via via,
integer seq_nr,
charstring method := "INVITE",
@@ -940,8 +959,8 @@
template (value) PDU_SIP_Response
ts_SIP_Response_Ringing(
template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
Via via,
integer seq_nr,
charstring method := "INVITE",
@@ -959,8 +978,8 @@
template (value) PDU_SIP_Response
ts_SIP_Response_Unauthorized(
template (value) CallidString call_id,
- template (value) SipAddr from_addr,
- template (value) SipAddr to_addr,
+ template (value) From from_addr,
+ template (value) To to_addr,
Via via,
template (value) WwwAuthenticate wwwAuthenticate,
integer seq_nr,
@@ -990,8 +1009,8 @@
template (present) PDU_SIP_Response
tr_SIP_Response(template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template (present) Via via := tr_Via_from(?),
template Contact contact,
template charstring method,
@@ -1011,8 +1030,8 @@
template (present) PDU_SIP_Response
tr_SIP_Response_Unauthorized(
template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template (present) Via via := tr_Via_from(?),
template Contact contact := *,
template (present) WwwAuthenticate wwwAuthenticate := ?,
@@ -1034,8 +1053,8 @@
template (present) PDU_SIP_Response
tr_SIP_Response_Trying(
template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template (present) Via via := tr_Via_from(?),
template integer seq_nr := ?,
template charstring method := "INVITE",
@@ -1054,8 +1073,8 @@
template (present) PDU_SIP_Response
tr_SIP_Response_Ringing(
template CallidString call_id,
- template SipAddr from_addr,
- template SipAddr to_addr,
+ template From from_addr,
+ template To to_addr,
template (present) Via via := tr_Via_from(?),
template integer seq_nr := ?,
template charstring method := "INVITE",
@@ -1474,12 +1493,16 @@
}
}
-function f_sip_SipAddr_to_str(SipAddr sip_addr) return charstring {
- if (ischosen(sip_addr.addr.nameAddr)) {
- return f_sip_NameAddr_to_str(sip_addr.addr.nameAddr);
+function f_sip_Addr_Union_to_str(Addr_Union addru) return charstring {
+ if (ischosen(addru.nameAddr)) {
+ return f_sip_NameAddr_to_str(addru.nameAddr);
} else {
- return f_sip_SipUrl_to_str(sip_addr.addr.addrSpecUnion);
+ return f_sip_SipUrl_to_str(addru.addrSpecUnion);
}
}
+function f_sip_SipAddr_to_str(SipAddr sip_addr) return charstring {
+ return f_sip_Addr_Union_to_str(sip_addr.addr);
+}
+
}
diff --git a/sip/SIP_Tests.ttcn b/sip/SIP_Tests.ttcn
index 84ddcb5..9c376f3 100644
--- a/sip/SIP_Tests.ttcn
+++ b/sip/SIP_Tests.ttcn
@@ -231,8 +231,12 @@
/* Establish a mobile terminated call described in 'cp' */
function f_establish_mt(inout CallPars cp) runs on ConnHdlr {
- var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm);
- var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext);
+ var template (value) From from_addr := ts_From(cp.comp.sip_url_ext.addr, cp.comp.sip_url_ext.params);
+ var template (value) To to_addr := ts_To(cp.comp.sip_url_gsm.addr, cp.comp.sip_url_gsm.params);
+ var template (value) Via via := ts_Via_from(cp.comp.sip_url_ext.addr.nameAddr.addrSpec.hostPort);
+ var template (present) From from_addr_exp := tr_From(tr_Addr_Union_from_val(cp.comp.sip_url_ext.addr), *);
+ var template (present) To to_addr_exp := tr_To(tr_Addr_Union_from_val(cp.comp.sip_url_gsm.addr), *);
+ var template (present) Via via_exp := tr_Via_from(f_tr_HostPort_opt_defport(from_addr_exp.addressField.nameAddr.addrSpec.hostPort));
var MNCC_PDU mncc;
/* The last SDP that the MSC received via MNCC from osmo-sip-connector */
@@ -266,8 +270,8 @@
f_create_mncc_expect(cp.called);
/* OSC <- SIP: A party sends SIP invite for a MT-call into OSC */
- SIP.send(ts_SIP_INVITE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm,
- ts_Via_from(cp.comp.sip_url_ext.addr.nameAddr.addrSpec.hostPort),
+ SIP.send(ts_SIP_INVITE(cp.comp.sip_call_id, from_addr, to_addr,
+ via,
ts_Contact_SipAddr(cp.comp.sip_url_ext),
cp.comp.sip_seq_nr, cp.comp.sip_body));
if (cp.mncc_with_sdp) {
@@ -276,8 +280,8 @@
}
/* OSC -> SIP */
- as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)),
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, from_addr_exp, to_addr_exp,
+ via_exp,
*,
"INVITE", 100, ?, "Trying", *));
@@ -291,8 +295,8 @@
[] SIP.receive {
setverdict(fail, "Received unexpected SIP response");
SIP.send(ts_SIP_ACK(cp.comp.sip_call_id,
- cp.comp.sip_url_ext, cp.comp.sip_url_gsm,
- ts_Via_from(cp.comp.sip_url_ext.addr.nameAddr.addrSpec.hostPort),
+ from_addr, to_addr,
+ via,
cp.comp.sip_seq_nr, omit));
mtc.stop;
}
@@ -334,8 +338,8 @@
SIP.clear;
/* 180 Ringing should not contain any SDP. */
- as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)),
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, from_addr_exp, to_addr_exp,
+ via_exp,
*,
"INVITE", 180, ?, "Ringing", omit));
@@ -350,8 +354,8 @@
}
/* OSC -> SIP: OSC confirms call establishment to SIP side */
- as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)),
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, from_addr_exp, to_addr_exp,
+ via_exp,
contact := ?,
method := "INVITE", status_code := 200,
seq_nr := ?, reason := "OK",
@@ -359,8 +363,8 @@
/* OSC <- SIP: SIP world acknowledges "200 OK" */
SIP.send(ts_SIP_ACK(cp.comp.sip_call_id,
- cp.comp.sip_url_ext, cp.comp.sip_url_gsm,
- ts_Via_from(cp.comp.sip_url_ext.addr.nameAddr.addrSpec.hostPort),
+ from_addr, to_addr,
+ via,
cp.comp.sip_seq_nr, omit));
/* MSC <- OSC: OSC sends SETUP COMPL to MNCC (which triggers CC CONNECT ACK */
MNCC.receive(tr_MNCC_SETUP_COMPL_req(cp.mncc_call_id)) -> value mncc {
@@ -372,8 +376,15 @@
function f_establish_mo(inout CallPars cp) runs on ConnHdlr {
var MNCC_number dst := valueof(ts_MNCC_number(cp.called, GSM48_TON_UNKNOWN));
var MNCC_number src := valueof(ts_MNCC_number(cp.calling, GSM48_TON_UNKNOWN));
- var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm);
- var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext);
+
+ var template (value) From from_addr := ts_From(cp.comp.sip_url_gsm.addr, cp.comp.sip_url_gsm.params);
+ var template (value) To to_addr := ts_To(cp.comp.sip_url_ext.addr, cp.comp.sip_url_ext.params);
+ var template (value) Via via := ts_Via_from(cp.comp.sip_url_gsm.addr.nameAddr.addrSpec.hostPort);
+ var template (present) From from_addr_exp := tr_From(tr_Addr_Union_from_val(cp.comp.sip_url_gsm.addr), *);
+ var template (present) To to_addr_exp := tr_To(tr_Addr_Union_from_val(cp.comp.sip_url_ext.addr), *);
+ var template (present) Via via_exp := tr_Via_from(f_tr_HostPort_opt_defport(from_addr_exp.addressField.nameAddr.addrSpec.hostPort));
+
+
var PDU_SIP_Request sip_req;
var integer seq_nr;
var MNCC_PDU mncc;
@@ -436,16 +447,16 @@
* "a=sendrecv;" */
expect_sdp_to_sip := pattern cn_sdp & "*";
}
- sip_req := f_SIP_expect_req(tr_SIP_INVITE(sip_addr_ext.addr.nameAddr.addrSpec, ?,
- sip_addr_gsm, sip_addr_ext,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_gsm.addr.nameAddr.addrSpec.hostPort)),
+ sip_req := f_SIP_expect_req(tr_SIP_INVITE(to_addr_exp.addressField.nameAddr.addrSpec, ?,
+ from_addr_exp, to_addr_exp,
+ via_exp,
?, expect_sdp_to_sip));
- cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams;
+ from_addr.fromParams := sip_req.msgHeader.fromField.fromParams;
cp.comp.sip_call_id := sip_req.msgHeader.callId.callid;
seq_nr := sip_req.msgHeader.cSeq.seqNumber;
/* OSC <- SIP: Notify call is proceeding */
- SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext,
+ SIP.send(ts_SIP_Response(cp.comp.sip_call_id, from_addr, to_addr,
"INVITE", 100, seq_nr, "Trying", sip_req.msgHeader.via));
/* MSC <- OSC: "100 Trying" translated to MNCC_CALL_PROC_REQ */
MNCC.receive(tr_MNCC_CALL_PROC_req(cp.mncc_call_id)) -> value mncc {
@@ -453,7 +464,7 @@
}
/* OSC <- SIP: SIP-terminated user is ringing now. 180 Ringing should not contain any SDP. */
- SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext,
+ SIP.send(ts_SIP_Response(cp.comp.sip_call_id, from_addr, to_addr,
"INVITE", 180, seq_nr, "Ringing", sip_req.msgHeader.via, omit));
/* MSC <- OSC: "180 Ringing" translated to MNCC_ALERT_REQ */
@@ -462,7 +473,7 @@
}
/* OSC <- SIP: SIP-terminated user has accepted the call */
- SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext,
+ SIP.send(ts_SIP_Response(cp.comp.sip_call_id, from_addr, to_addr,
"INVITE", 200, seq_nr, "OK", sip_req.msgHeader.via,
body := cp.comp.sip_body));
@@ -483,32 +494,36 @@
/* MSC -> OSC: CC CONNECT ACK was received from MS */
MNCC.send(ts_MNCC_SETUP_COMPL_ind(cp.mncc_call_id));
/* OSC -> SIP: Acknowledge the call */
- SIP.receive(tr_SIP_ACK(sip_addr_ext.addr.nameAddr.addrSpec,
+ SIP.receive(tr_SIP_ACK(to_addr_exp.addressField.nameAddr.addrSpec,
cp.comp.sip_call_id,
- sip_addr_gsm,
- sip_addr_ext,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_gsm.addr.nameAddr.addrSpec.hostPort)),
+ from_addr_exp,
+ to_addr_exp,
+ via_exp,
?, omit));
}
/* Release call from the mobile side */
function f_release_mobile(inout CallPars cp) runs on ConnHdlr {
- var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm);
- var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext);
+ var template (value) From from_addr := ts_From(cp.comp.sip_url_gsm.addr, cp.comp.sip_url_gsm.params);
+ var template (value) To to_addr := ts_To(cp.comp.sip_url_ext.addr, cp.comp.sip_url_ext.params);
+ var template (value) Via via := ts_Via_from(cp.comp.sip_url_gsm.addr.nameAddr.addrSpec.hostPort);
+ var template (present) From from_addr_exp := tr_From(tr_Addr_Union_from_val(cp.comp.sip_url_gsm.addr), *);
+ var template (present) To to_addr_exp := tr_To(tr_Addr_Union_from_val(cp.comp.sip_url_ext.addr), *);
+ var template (present) Via via_exp := tr_Via_from(f_tr_HostPort_opt_defport(from_addr_exp.addressField.nameAddr.addrSpec.hostPort));
var PDU_SIP_Request sip_req;
SIP.clear;
/* MSC -> OSC: Simulate a CC DISCONNET from the MT user */
MNCC.send(ts_MNCC_DISC_ind(cp.mncc_call_id, ts_MNCC_cause(0)));
/* OSC -> SIP: Expect BYE from OSC to SIP side */
- sip_req := f_SIP_expect_req(tr_SIP_BYE(sip_addr_ext.addr.nameAddr.addrSpec,
- cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_gsm.addr.nameAddr.addrSpec.hostPort)),
+ sip_req := f_SIP_expect_req(tr_SIP_BYE(to_addr_exp.addressField.nameAddr.addrSpec,
+ cp.comp.sip_call_id, from_addr_exp, to_addr_exp,
+ via_exp,
?, *));
- cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams;
+ from_addr.fromParams := sip_req.msgHeader.fromField.fromParams;
/* OSC <- SIP: Acknowledge the BYE */
- SIP.send(ts_SIP_Response(cp.comp.sip_call_id, cp.comp.sip_url_gsm, cp.comp.sip_url_ext,
+ SIP.send(ts_SIP_Response(cp.comp.sip_call_id, from_addr, to_addr,
"BYE", 200, sip_req.msgHeader.cSeq.seqNumber, "OK",
sip_req.msgHeader.via));
/* MSC <- OSC: Send REL_REQ to MSC, triggers CC RELEASE REQ to MS */
@@ -519,19 +534,23 @@
/* Release call from the SIP side */
function f_release_sip(inout CallPars cp) runs on ConnHdlr {
- var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm);
- var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext);
+ var template (value) From from_addr := ts_From(cp.comp.sip_url_ext.addr, cp.comp.sip_url_ext.params);
+ var template (value) To to_addr := ts_To(cp.comp.sip_url_gsm.addr, cp.comp.sip_url_gsm.params);
+ var template (value) Via via := ts_Via_from(cp.comp.sip_url_ext.addr.nameAddr.addrSpec.hostPort);
+ var template (present) From from_addr_exp := tr_From(tr_Addr_Union_from_val(cp.comp.sip_url_ext.addr), *);
+ var template (present) To to_addr_exp := tr_To(tr_Addr_Union_from_val(cp.comp.sip_url_gsm.addr), *);
+ var template (present) Via via_exp := tr_Via_from(f_tr_HostPort_opt_defport(from_addr_exp.addressField.nameAddr.addrSpec.hostPort));
/* OSC <- SIP: SIP-side sends a BYE to OSC */
- SIP.send(ts_SIP_BYE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm,
- ts_Via_from(cp.comp.sip_url_ext.addr.nameAddr.addrSpec.hostPort),
+ SIP.send(ts_SIP_BYE(cp.comp.sip_call_id, from_addr, to_addr,
+ via,
cp.comp.sip_seq_nr, omit));
/* MSC <- OSC: Expect OSC to cause MNCC Disconnect Request */
MNCC.receive(tr_MNCC_DISC_req(cp.mncc_call_id));
/* MSC -> OSC: Indicate GSM side release */
MNCC.send(ts_MNCC_REL_ind(cp.mncc_call_id, ts_MNCC_cause(0)));
/* OSC -> SIP: Confirmation to SIP side */
- as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_ext.addr.nameAddr.addrSpec.hostPort)),
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, from_addr_exp, to_addr_exp,
+ via_exp,
*,
"BYE", 200, cp.comp.sip_seq_nr, "OK", omit));
}
@@ -675,8 +694,12 @@
var MNCC_number dst := valueof(ts_MNCC_number(cp.called, GSM48_TON_UNKNOWN));
var MNCC_number src := valueof(ts_MNCC_number(cp.calling, GSM48_TON_UNKNOWN));
- var template SipAddr sip_addr_gsm := tr_SipAddr_from_val(cp.comp.sip_url_gsm);
- var template SipAddr sip_addr_ext := tr_SipAddr_from_val(cp.comp.sip_url_ext);
+ var template (value) From from_addr := ts_From(cp.comp.sip_url_gsm.addr, cp.comp.sip_url_gsm.params);
+ var template (value) To to_addr := ts_To(cp.comp.sip_url_ext.addr, cp.comp.sip_url_ext.params);
+ var template (value) Via via := ts_Via_from(cp.comp.sip_url_gsm.addr.nameAddr.addrSpec.hostPort);
+ var template (present) From from_addr_exp := tr_From(tr_Addr_Union_from_val(cp.comp.sip_url_gsm.addr), *);
+ var template (present) To to_addr_exp := tr_To(tr_Addr_Union_from_val(cp.comp.sip_url_ext.addr), *);
+ var template (present) Via via_exp := tr_Via_from(f_tr_HostPort_opt_defport(from_addr_exp.addressField.nameAddr.addrSpec.hostPort));
f_create_sip_expect(cp.comp.sip_url_ext.addr.nameAddr.addrSpec);
@@ -700,9 +723,9 @@
timer T := 10.0;
T.start;
alt {
- [] SIP.receive(tr_SIP_INVITE(sip_addr_ext.addr.nameAddr.addrSpec, ?,
- sip_addr_gsm, sip_addr_ext,
- tr_Via_from(f_tr_HostPort_opt_defport(sip_addr_gsm.addr.nameAddr.addrSpec.hostPort)),
+ [] SIP.receive(tr_SIP_INVITE(to_addr_exp.addressField.nameAddr.addrSpec, ?,
+ from_addr_exp, to_addr_exp,
+ via_exp,
?, ?)) {
setverdict(fail, "Received unexpected INVITE");
}