aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2023-09-12 02:16:43 +0200
committerneels <nhofmeyr@sysmocom.de>2023-09-15 14:53:06 +0000
commitc35b6579161cc86f2a535feeb32252a53587788b (patch)
treee2d1127c2e0ea6a6a35877db14a843e3f70c0f9f
parentd3cca1dffcd8b08eeba9bd8fa59714923216645f (diff)
sip: tweak failure reporting for SIP messages
Help developers by logging message matching failures in detail. Change-Id: Id48016657ebb83953fe74f65332f318edf8f75e6
-rw-r--r--sip/SIP_Tests.ttcn79
1 files changed, 46 insertions, 33 deletions
diff --git a/sip/SIP_Tests.ttcn b/sip/SIP_Tests.ttcn
index 58000d56..935eed35 100644
--- a/sip/SIP_Tests.ttcn
+++ b/sip/SIP_Tests.ttcn
@@ -188,11 +188,32 @@ template (value) ConnHdlrPars t_Pars := {
g_cp := omit
}
+altstep as_SIP_expect_resp(template PDU_SIP_Response sip_expect) runs on ConnHdlr
+{
+ [] SIP.receive(sip_expect);
+ [] SIP.receive {
+ log("FAIL: expected SIP message ", sip_expect);
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected SIP message");
+ }
+}
+
+function f_SIP_expect_req(template PDU_SIP_Request sip_expect) runs on ConnHdlr return PDU_SIP_Request
+{
+ var PDU_SIP_Request rx;
+ alt {
+ [] SIP.receive(sip_expect) -> value rx;
+ [] SIP.receive {
+ log("FAIL: expected SIP message ", sip_expect);
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected SIP message");
+ }
+ }
+ return rx;
+}
+
/* 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 PDU_SIP_Response sip_resp;
var MNCC_PDU mncc;
/* Ask MNCC_Emulation to "expect" a call to the given called number */
@@ -202,8 +223,8 @@ function f_establish_mt(inout CallPars cp) runs on ConnHdlr {
SIP.send(ts_SIP_INVITE(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm,
cp.comp.sip_seq_nr, cp.comp.sip_body));
/* OSC -> SIP */
- SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *,
- "INVITE", 100, ?, "Trying", *));
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *,
+ "INVITE", 100, ?, "Trying", *));
alt {
/* MSC <- OSC: OSC generates MNCC_SETUP_REQ from INVITE */
@@ -231,33 +252,23 @@ function f_establish_mt(inout CallPars cp) runs on ConnHdlr {
/* MSC -> OSC: After MS is ringing and sent CC ALERTING */
MNCC.send(ts_MNCC_ALERT_ind(cp.mncc_call_id));
SIP.clear;
- alt {
- [] SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *,
- "INVITE", 180, ?, "Ringing", *));
- [] SIP.receive {
- setverdict(fail, "Received unexpected respose");
- SIP.send(ts_SIP_ACK(cp.comp.sip_call_id, cp.comp.sip_url_ext, cp.comp.sip_url_gsm,
- cp.comp.sip_seq_nr, omit));
- mtc.stop;
- }
- }
+
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *,
+ "INVITE", 180, ?, "Ringing", *));
/* MSC -> OSC: After MT user has picked up and sent CC CONNECT */
MNCC.send(ts_MNCC_SETUP_CNF(cp.mncc_call_id));
SIP.clear;
- interleave {
/* MSC <- OSC: OSC asks MSC to connect its RTP stream to remote end */
- [] MNCC.receive(tr_MNCC_RTP_CONNECT(cp.mncc_call_id, f_addrstr2addr(cp.sip_rtp_addr), cp.sip_rtp_port)) {}
+ MNCC.receive(tr_MNCC_RTP_CONNECT(cp.mncc_call_id, f_addrstr2addr(cp.sip_rtp_addr), cp.sip_rtp_port));
+
/* OSC -> SIP: OSC confirms call establishment to SIP side */
- [] SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, ?,
- "INVITE", 200, ?, "OK", ?)) -> value sip_resp {
- if (not match(sip_resp.messageBody, pattern "*" & cp.cn_rtp_addr & "*")) {
- setverdict(fail, "wrong ip addr sent in SIP SDP, not containing ", cp.cn_rtp_addr);
- mtc.stop;
- }
- }
- }
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, contact_addr := ?,
+ method := "INVITE", status_code := 200,
+ seq_nr := ?, reason := "OK",
+ body := pattern "*" & cp.cn_rtp_addr & "*"));
+
/* 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,
cp.comp.sip_seq_nr, omit));
@@ -287,12 +298,13 @@ function f_establish_mo(inout CallPars cp) runs on ConnHdlr {
mncc.u.rtp.rtp_port := cp.cn_rtp_port;
MNCC.send(mncc);
}
+
/* OSC -> SIP: Send INVITE with GSM side IP/Port in SDP */
- SIP.receive(tr_SIP_INVITE(?, sip_addr_gsm, sip_addr_ext, ?, ?)) -> value sip_req {
- cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams;
- cp.comp.sip_call_id := sip_req.msgHeader.callId.callid;
- seq_nr := sip_req.msgHeader.cSeq.seqNumber;
- }
+ sip_req := f_SIP_expect_req(tr_SIP_INVITE(?, sip_addr_gsm, sip_addr_ext, ?, ?));
+ cp.comp.sip_url_gsm.params := 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,
"INVITE", 100, seq_nr, "Trying", sip_req.msgHeader.via));
@@ -328,10 +340,11 @@ function f_release_mobile(inout CallPars cp) runs on ConnHdlr {
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.receive(tr_SIP_BYE(cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext, ?, *)) -> value sip_req {
- cp.comp.sip_url_gsm.params := sip_req.msgHeader.fromField.fromParams;
- }
+ sip_req := f_SIP_expect_req(tr_SIP_BYE(cp.comp.sip_call_id, sip_addr_gsm, sip_addr_ext, ?, *));
+ cp.comp.sip_url_gsm.params := 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,
"BYE", 200, sip_req.msgHeader.cSeq.seqNumber, "OK",
@@ -354,8 +367,8 @@ function f_release_sip(inout CallPars cp) runs on ConnHdlr {
/* 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 */
- SIP.receive(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *,
- "BYE", 200, cp.comp.sip_seq_nr, "OK", omit));
+ as_SIP_expect_resp(tr_SIP_Response(cp.comp.sip_call_id, sip_addr_ext, sip_addr_gsm, *,
+ "BYE", 200, cp.comp.sip_seq_nr, "OK", omit));
}
/* Successful MT Call, which is subsequently released by GSM side */