BSC_Tests: use correct payload types and encoding names on MGCP

The test currently use a hardcoded payload type and encoding name.
This does mean in practice that even when an assignment with EFR
is happeining. The MGCP responses to the BSC tell that the codec
is AMR. This is not correct. The testcases should always pick a
suitable payload type / encoding name in the MGCP response

- Add constants for IANA/3GPP assigned payload types
- Add function to lookup the right encoding name for a payload type
- Initalize the encoding name and payload type in g_media according
  to the BSSAP PDU.

Change-Id: I2735267091059e2f2169da80bdcd30abc2b1554b
Realted: OS#2728
This commit is contained in:
Philipp Maier 2018-06-25 16:40:48 +02:00 committed by Harald Welte
parent 04fc4bcc18
commit 11a5894165
3 changed files with 67 additions and 6 deletions

View File

@ -32,6 +32,24 @@ import from Osmocom_VTY_Functions all;
* Media related handling
***********************************************************************/
/* Get the matching payload type for a specified BSSAP codec type
* (see also: BSSAP_Types.ttcn */
private function f_get_mgcp_pt(BSSMAP_FIELD_CodecType codecType) return SDP_FIELD_PayloadType {
if (codecType == GSM_FR) {
return PT_GSM;
} else if (codecType == GSM_HR) {
return PT_GSMHR;
} else if (codecType == GSM_EFR) {
return PT_GSMEFR;
} else if (codecType == FR_AMR or codecType == HR_AMR) {
return PT_AMR;
} else if (codecType == FR_AMR_WB or codecType == OHR_AMR or codecType == OFR_AMR_WB or codecType == OHR_AMR_WB) {
return PT_AMRWB;
}
return PT_PCMU;
}
/* Tuple containing host/ip and port */
type record HostPort {
HostName host,
@ -66,7 +84,7 @@ type record MediaState {
BtsMediaState bts1 /* only during hand-over */
};
function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, HostName mgw) {
function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, HostName mgw, BSSMAP_FIELD_CodecType codecType) {
/* BTS Side */
g_media.bts := {
ipa_crcx_seen := false,
@ -93,10 +111,10 @@ function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, H
g_media.mgcp_ep := "rtpbridge/" & int2str(nr) & "@mgw";
for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) {
g_media.mgcp_conn[i].mime_type := "AMR";
g_media.mgcp_conn[i].mime_type := f_encoding_name_from_pt(f_get_mgcp_pt(codecType));
g_media.mgcp_conn[i].sample_rate := 8000;
g_media.mgcp_conn[i].ptime := 20;
g_media.mgcp_conn[i].rtp_pt := 98;
g_media.mgcp_conn[i].rtp_pt := enum2int(f_get_mgcp_pt(codecType));
g_media.mgcp_conn[i].crcx_seen := false;
g_media.mgcp_conn[i].conn_id := f_mgcp_alloc_conn_id();
}
@ -301,8 +319,8 @@ type component MSC_ConnHdlr extends BSSAP_ConnHdlr, RSL_DchanHdlr, MGCP_ConnHdlr
}
/* initialize all parameters */
function f_MscConnHdlr_init(integer i, HostName bts, HostName mgw) runs on MSC_ConnHdlr {
f_MediaState_init(g_media, i, bts, mgw);
function f_MscConnHdlr_init(integer i, HostName bts, HostName mgw, BSSMAP_FIELD_CodecType codecType) runs on MSC_ConnHdlr {
f_MediaState_init(g_media, i, bts, mgw, codecType);
if (not g_vty_initialized) {
map(self:BSCVTY, system:BSCVTY);
f_vty_set_prompts(BSCVTY);
@ -754,7 +772,18 @@ function f_ass_patch_lcls(inout template (omit) PDU_BSSAP ass_tpl,
/* establish a channel fully, expecting an assignment matching 'exp' */
function f_establish_fully(template (omit) PDU_BSSAP ass_tpl, template PDU_BSSAP exp_ass_cpl)
runs on MSC_ConnHdlr {
f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3");
var BSSMAP_FIELD_CodecType codecType;
if (isvalue(ass_tpl.pdu.bssmap.assignmentRequest.codecList)) {
codecType := valueof(ass_tpl.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);
} else {
/* Make sure a meaningful default is assigned in case the
* codecList is not populated */
codecType := FR_AMR;
}
f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", codecType);
/* patch in the LCLS related items, as needed */
f_ass_patch_lcls(ass_tpl, exp_ass_cpl);

View File

@ -441,5 +441,26 @@ runs on MGCP_Emulation_CT return template MgcpMessage {
return omit;
}
/* Determine encoding name for a specified payload type number */
function f_encoding_name_from_pt(SDP_FIELD_PayloadType pt) return charstring {
if (pt == PT_PCMU) {
return "PCMU";
} else if (pt == PT_GSM) {
return "GSM";
} else if (pt == PT_PCMA) {
return "PCMA";
} else if (pt == PT_GSMEFR) {
return "GSM-EFR";
} else if (pt == PT_GSMHR) {
return "GSM-HR-08";
} else if (pt == PT_AMR) {
return "AMR";
} else if (pt == PT_AMRWB) {
return "AMR-WB";
}
setverdict(fail);
return "";
}
}

View File

@ -121,5 +121,16 @@ module MGCP_Types {
external function dec_MgcpMessage(in charstring id) return MgcpMessage
with { extension "prototype(convert) decode(TEXT)" };
/* IANA / 3gpp assigned payload type numbers */
type enumerated SDP_FIELD_PayloadType {
PT_PCMU(0),
PT_GSM(3),
PT_PCMA(8),
PT_G729(18),
PT_GSMEFR(110),
PT_GSMHR(111),
PT_AMR(112),
PT_AMRWB(113)
}
} with { encode "TEXT" }