neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/35141?usp=email )


Change subject: test_call: codecs: allow specific PT numbers [2/2]
......................................................................

test_call: codecs: allow specific PT numbers [2/2]

In msc_vlr_test_call.c, allow to tell MO non-default payload type
numbers in the SDP, to verify that it adopts the other call leg's PT
numbers.

Actually apply the non-default payload type number (AMR=96 instead of
the default of 112 from codec_mapping.c) and see the effects in
msc_vlr_test_call.err.

The diff shows that, as intended, the change in payload type number
should result in modifying the MGW endpoint to change the earlier '112'
to the modified '96' used in this test.

Related: OS#6258
Change-Id: I25df2ed7ad792fbe66dfd0fbf08182c9cf6cfc5b
---
M tests/msc_vlr/msc_vlr_test_call.c
M tests/msc_vlr/msc_vlr_test_call.err
2 files changed, 77 insertions(+), 26 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/41/35141/1

diff --git a/tests/msc_vlr/msc_vlr_test_call.c 
b/tests/msc_vlr/msc_vlr_test_call.c
index d249b2e..1a34a47 100644
--- a/tests/msc_vlr/msc_vlr_test_call.c
+++ b/tests/msc_vlr/msc_vlr_test_call.c
@@ -1071,9 +1071,9 @@
                        LIST_END
                },
                .mt_rx_assigned_codec = "AMR",
-               .mt_tx_sdp_mncc_rtp_create = { "AMR", "GSM-EFR", "GSM", 
"GSM-HR-08" },
-               .mt_tx_sdp_mncc_alert_ind = { "AMR", "GSM-EFR", "GSM", 
"GSM-HR-08" },
-               .mt_tx_sdp_mncc_setup_cnf = { "AMR", "GSM-EFR", "GSM", 
"GSM-HR-08" },
+               .mt_tx_sdp_mncc_rtp_create = { "AMR#96", "GSM-EFR", "GSM", 
"GSM-HR-08" },
+               .mt_tx_sdp_mncc_alert_ind = { "AMR#96", "GSM-EFR", "GSM", 
"GSM-HR-08" },
+               .mt_tx_sdp_mncc_setup_cnf = { "AMR#96", "GSM-EFR", "GSM", 
"GSM-HR-08" },
                .mo_tx_sdp_mncc_setup_compl_ind = {},
        },
 };
@@ -1146,6 +1146,24 @@
        return sb.buf;
 }

+/* Split an input string of "AMR#96" into "AMR" and 96: copy the subtype name 
without the "#96" part to
+ * split_subtype_name_and_pt_nr which must be a char[16]. If pt_nr is 
non-NULL, write the 96 to *pt_nr.
+ */
+static void split_subtype_name_and_pt_nr(char subtype_name_wo_pt[], int 
*pt_nr, const char *input)
+{
+       char *hash;
+       osmo_strlcpy(subtype_name_wo_pt, input, 16);
+       hash = strchr(subtype_name_wo_pt, '#');
+       if (hash) {
+               *hash = '\0';
+               if (pt_nr)
+                       *pt_nr = atoi(hash + 1);
+       }
+}
+
+/* Validate that the codecs in sdp_str appear in the order as expected by the 
list of subtype names in expected_codecs.
+ * Ignore any payload type numbers ("#96") in expected_codecs.
+ */
 static bool validate_sdp(const char *func, const char *desc,
                         const char *sdp_str, const char * const 
expected_codecs[])
 {
@@ -1159,11 +1177,13 @@

        expect_pos = expected_codecs;
        foreach_sdp_audio_codec(codec, &sdp.audio_codecs) {
+               char subtype_name_wo_pt[16];
                if (!*expect_pos) {
                        BTW("%s: %s: ERROR: did not expect %s", func, desc, 
codec->subtype_name);
                        return false;
                }
-               if (strcmp(*expect_pos, codec->subtype_name)) {
+               split_subtype_name_and_pt_nr(subtype_name_wo_pt, NULL, 
*expect_pos);
+               if (strcmp(subtype_name_wo_pt, codec->subtype_name)) {
                        BTW("%s: %s: ERROR: mismatch: in idx %d, expect %s, got 
%s", func, desc,
                            (int)(expect_pos - expected_codecs), *expect_pos, 
codec->subtype_name);
                        return false;
@@ -1229,6 +1249,8 @@
                } \
        } while (0)

+/* Compose a valid SDP string from the list of codec subtype names given. If a 
subtype name includes a payload type
+ * number ("AMR#96") then use that PT number in the SDP instead of the default 
from codec_mapping.c. */
 static struct sdp_msg *sdp_from_subtype_names(const char *const *subtype_names)
 {
        static struct sdp_msg sdp;
@@ -1236,12 +1258,19 @@
        const char *const *subtype_name;
        osmo_sockaddr_str_from_str(&sdp.rtp, "1.2.3.4", 56);
        for (subtype_name = subtype_names; *subtype_name; subtype_name++) {
-               const struct codec_mapping *m = 
codec_mapping_by_subtype_name(*subtype_name);
+               char subtype_name_wo_pt[16];
+               const struct codec_mapping *m;
+               struct sdp_audio_codec *ac;
+               int set_pt = -1;
+               split_subtype_name_and_pt_nr(subtype_name_wo_pt, &set_pt, 
*subtype_name);
+               m = codec_mapping_by_subtype_name(subtype_name_wo_pt);
                if (!m) {
                        BTW("ERROR: unknown subtype_name: %s", *subtype_name);
                        abort();
                }
-               sdp_audio_codecs_add_copy(&sdp.audio_codecs, &m->sdp);
+               ac = sdp_audio_codecs_add_copy(&sdp.audio_codecs, &m->sdp);
+               if (set_pt >= 0)
+                       ac->payload_type = set_pt;
        }
        return &sdp;
 }
diff --git a/tests/msc_vlr/msc_vlr_test_call.err 
b/tests/msc_vlr/msc_vlr_test_call.err
index 697cee0..2d67c42 100644
--- a/tests/msc_vlr/msc_vlr_test_call.err
+++ b/tests/msc_vlr/msc_vlr_test_call.err
@@ -5773,29 +5773,29 @@
 DMSC dummy_msc_i(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ){0}: 
Received Event MSC_I_EV_FROM_A_FORWARD_ACCESS_SIGNALLING_REQUEST
 DBSSAP 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}:
 Assignment for this trans already started earlier
 - Total time passed: 1251.000933 s
-- The other call leg got established (not shown here), MNCC tells us so, with 
codecs { AMR GSM-EFR GSM GSM-HR-08 }
+- The other call leg got established (not shown here), MNCC tells us so, with 
codecs { AMR#96 GSM-EFR GSM GSM-HR-08 }
   MSC <-- MNCC: callref 0x80000009: MNCC_ALERT_REQ
 v=0
 o=OsmoMSC 0 0 IN IP4 1.2.3.4
 s=GSM Call
 c=IN IP4 1.2.3.4
 t=0 0
-m=audio 56 RTP/AVP 112 110 3 111
-a=rtpmap:112 AMR/8000
-a=fmtp:112 octet-align=1
+m=audio 56 RTP/AVP 96 110 3 111
+a=rtpmap:96 AMR/8000
+a=fmtp:96 octet-align=1
 a=rtpmap:110 GSM-EFR/8000
 a=rtpmap:3 GSM/8000
 a=rtpmap:111 GSM-HR-08/8000
 a=ptime:20

-DMNCC trans(CC:MO_CALL_PROC 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) rx MNCC_ALERT_REQ 
(RTP=1.2.3.4:56{AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111})
+DMNCC trans(CC:MO_CALL_PROC 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) rx MNCC_ALERT_REQ 
(RTP=1.2.3.4:56{AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111})
 DCC trans(CC:MO_CALL_PROC 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) stopping pending guard timer
 DCC trans(CC:MO_CALL_PROC 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) starting guard timer with 180 seconds
 DCC trans(CC:MO_CALL_PROC 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) new state MO_CALL_PROC -> CALL_DELIVERED
-DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) codecs: 
10.23.23.1:23{AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} (from: 
assigned=AMR:octet-align=1#112 
remote=1.2.3.4:56{AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
bss={GSM#3,GSM-EFR#110,AMR:octet-align=1#112,GSM-HR-08#111} 
RAN={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111})
+DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) codecs: 
10.23.23.1:23{AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111} (from: 
assigned=AMR:octet-align=1#112 
remote=1.2.3.4:56{AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
bss={GSM#3,GSM-EFR#110,AMR:octet-align=1#112,GSM-HR-08#111} 
RAN={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111})
 DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) msg_type=MNCC_ALERT_REQ
-DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI){UNINITIALIZED}:
 no change: codecs already set to 
AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111
-DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI){UNINITIALIZED}:
 setting remote addr to 1.2.3.4:56
+DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI){UNINITIALIZED}:
 setting codecs to AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111
+DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI:local-10-23-23-1-23){UNINITIALIZED}:
 setting remote addr to 1.2.3.4:56
 DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI:local-10-23-23-1-23:remote-1-2-3-4-56){UNINITIALIZED}:
 Not committing: no MGW endpoint CI set up
 DBSSAP 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}:
 Sending DTAP: CC GSM48_MT_CC_ALERTING
 DMSC 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}:
 RAN encode: DTAP on GERAN-A
@@ -5808,22 +5808,22 @@
 s=GSM Call
 c=IN IP4 1.2.3.4
 t=0 0
-m=audio 56 RTP/AVP 112 110 3 111
-a=rtpmap:112 AMR/8000
-a=fmtp:112 octet-align=1
+m=audio 56 RTP/AVP 96 110 3 111
+a=rtpmap:96 AMR/8000
+a=fmtp:96 octet-align=1
 a=rtpmap:110 GSM-EFR/8000
 a=rtpmap:3 GSM/8000
 a=rtpmap:111 GSM-HR-08/8000
 a=ptime:20

-DMNCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) rx MNCC_SETUP_RSP 
(RTP=1.2.3.4:56{AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111})
+DMNCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) rx MNCC_SETUP_RSP 
(RTP=1.2.3.4:56{AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111})
 DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) stopping pending guard timer
 DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) starting guard timer with 180 seconds
 DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) starting timer T313 with 30 seconds
 DCC trans(CC:CALL_DELIVERED 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) new state CALL_DELIVERED -> CONNECT_IND
-DCC trans(CC:CONNECT_IND 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) codecs: 
10.23.23.1:23{AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} (from: 
assigned=AMR:octet-align=1#112 
remote=1.2.3.4:56{AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
bss={GSM#3,GSM-EFR#110,AMR:octet-align=1#112,GSM-HR-08#111} 
RAN={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111})
+DCC trans(CC:CONNECT_IND 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) codecs: 
10.23.23.1:23{AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111} (from: 
assigned=AMR:octet-align=1#112 
remote=1.2.3.4:56{AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
MS={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111} 
bss={GSM#3,GSM-EFR#110,AMR:octet-align=1#112,GSM-HR-08#111} 
RAN={AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111})
 DCC trans(CC:CONNECT_IND 
IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ callref-0x80000009 
tid-8) msg_type=MNCC_SETUP_RSP
-DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI:local-10-23-23-1-23:remote-1-2-3-4-56){UNINITIALIZED}:
 no change: codecs already set to 
AMR:octet-align=1#112,GSM-EFR#110,GSM#3,GSM-HR-08#111
+DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI:local-10-23-23-1-23:remote-1-2-3-4-56){UNINITIALIZED}:
 no change: codecs already set to 
AMR:octet-align=1#96,GSM-EFR#110,GSM#3,GSM-HR-08#111
 DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI:local-10-23-23-1-23:remote-1-2-3-4-56){UNINITIALIZED}:
 remote addr already 1.2.3.4:56, no change
 DCC 
rtp_stream(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ:trans-8:call-16:RTP_TO_CN:no-CI:local-10-23-23-1-23:remote-1-2-3-4-56){UNINITIALIZED}:
 Not committing: no MGW endpoint CI set up
 DBSSAP 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:CM_SERVICE_REQ){MSC_A_ST_COMMUNICATING}:
 Sending DTAP: CC GSM48_MT_CC_CONNECT
@@ -5868,9 +5868,9 @@
 s=GSM Call
 c=IN IP4 1.2.3.4
 t=0 0
-m=audio 56 RTP/AVP 112 110 3 111
-a=rtpmap:112 AMR/8000
-a=fmtp:112 octet-align=1
+m=audio 56 RTP/AVP 96 110 3 111
+a=rtpmap:96 AMR/8000
+a=fmtp:96 octet-align=1
 a=rtpmap:110 GSM-EFR/8000
 a=rtpmap:3 GSM/8000
 a=rtpmap:111 GSM-HR-08/8000
@@ -6105,7 +6105,7 @@
 a=rtpmap:111 GSM-HR-08/8000
 a=ptime:20

-- VALIDATE_SDP OK: cc_to_mncc_tx_last_sdp == t->mt_tx_sdp_mncc_rtp_create == 
AMR GSM-EFR GSM GSM-HR-08
+- VALIDATE_SDP OK: cc_to_mncc_tx_last_sdp == t->mt_tx_sdp_mncc_rtp_create == 
AMR#96 GSM-EFR GSM GSM-HR-08
 - Total time passed: 1376.001024 s
   MSC <--GERAN-A-- MS: GSM48_MT_CC_ALERTING
 DREF 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:PAGING_RESP){MSC_A_ST_COMMUNICATING}:
 + rx_from_ms: now used by 2 (cc,rx_from_ms)
@@ -6132,7 +6132,7 @@
 a=ptime:20

 DREF 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:PAGING_RESP){MSC_A_ST_COMMUNICATING}:
 - rx_from_ms: now used by 1 (cc)
-- VALIDATE_SDP OK: cc_to_mncc_tx_last_sdp == t->mt_tx_sdp_mncc_alert_ind == 
AMR GSM-EFR GSM GSM-HR-08
+- VALIDATE_SDP OK: cc_to_mncc_tx_last_sdp == t->mt_tx_sdp_mncc_alert_ind == 
AMR#96 GSM-EFR GSM GSM-HR-08
 - Total time passed: 1377.001047 s
   MSC <--GERAN-A-- MS: GSM48_MT_CC_CONNECT
 DREF 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:PAGING_RESP){MSC_A_ST_COMMUNICATING}:
 + rx_from_ms: now used by 2 (cc,rx_from_ms)
@@ -6158,7 +6158,7 @@
 a=ptime:20

 DREF 
msc_a(IMSI-901700000010650:MSISDN-46071:GERAN-A:PAGING_RESP){MSC_A_ST_COMMUNICATING}:
 - rx_from_ms: now used by 1 (cc)
-- VALIDATE_SDP OK: cc_to_mncc_tx_last_sdp == t->mt_tx_sdp_mncc_setup_cnf == 
AMR GSM-EFR GSM GSM-HR-08
+- VALIDATE_SDP OK: cc_to_mncc_tx_last_sdp == t->mt_tx_sdp_mncc_setup_cnf == 
AMR#96 GSM-EFR GSM GSM-HR-08
   MSC <-- MNCC: callref 0x423: MNCC_SETUP_COMPL_REQ

 DMNCC trans(CC:CONNECT_REQUEST 
IMSI-901700000010650:MSISDN-46071:GERAN-A:PAGING_RESP callref-0x423 tid-0) rx 
MNCC_SETUP_COMPL_REQ

--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/35141?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I25df2ed7ad792fbe66dfd0fbf08182c9cf6cfc5b
Gerrit-Change-Number: 35141
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofm...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to