From b2168516f34be9bed449850420dbda391cf893c7 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 11 Nov 2019 03:40:26 +0100 Subject: hlr: add tests for GSUP proxy routing GSUP proxy routing, as it is implemented in an upcoming osmo-hlr patch, requires that osmo-hlr returns a received Source Name IE back as Destination Name IE. Add tests for these, for various situations. These tests pass since GSUP request handling with request->response association was introduced to osmo-hlr in I179ebb0385b5b355f4740e14d43be97bf93622e3. Implement this by adding a source_name to the g_pars, which should be sent out in ts_GSUP_* to osmo-hlr, and expected back as destination_name in returned messages. Add source_name and destination_name to various templates, with default := omit. Add f_gen_ts_ies() and f_gen_tr_ies() to compose expected IEs more generically. Change-Id: I3728776d862c5e5fa7628ca28d74c1ef247459fa --- library/GSUP_Types.ttcn | 152 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 31 deletions(-) (limited to 'library') diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn index fa912c1c..41181e8a 100644 --- a/library/GSUP_Types.ttcn +++ b/library/GSUP_Types.ttcn @@ -495,9 +495,10 @@ template GSUP_PDU tr_GSUP_SAI_RES(template hexstring imsi) := tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, { tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE), * }); -template (value) GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS) := - ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, { - valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_CnDomain(dom)) }); +template GSUP_PDU ts_GSUP_UL_REQ(hexstring imsi, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS, + template octetstring source_name := omit) := + ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, f_gen_ts_ies(imsi, dom := dom, + source_name := source_name)); template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) := tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, imsi); @@ -506,30 +507,34 @@ template (value) GSUP_PDU ts_GSUP_UL_RES(hexstring imsi, octetstring destination ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Destination_Name(destination_name))}); -template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi) := - tr_GSUP_IMSI(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, imsi); +template GSUP_PDU tr_GSUP_UL_RES(template hexstring imsi, template octetstring destination_name := omit) := + tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, f_gen_tr_ies(imsi, destination_name := destination_name)); template (value) GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) := ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, { valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) }); -template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?) := - tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, { - tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) }); +template GSUP_PDU tr_GSUP_UL_ERR(template hexstring imsi, template integer cause := ?, + template octetstring destination_name := omit) := + tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, + f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name)); template (value) GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn, octetstring destination_name := ''O) := ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)), valueof(ts_GSUP_IE_Destination_Name(destination_name))}); -template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?) := - tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, { - tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE_MSISDN(msisdn), * }); +template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi, template hexstring msisdn := ?, + template octetstring destination_name := omit) := + tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, + f_gen_tr_ies(imsi, msisdn := msisdn, destination_name := destination_name)); -template (value) GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi, octetstring destination_name := ''O) := - ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, { - valueof(ts_GSUP_IE_IMSI(imsi)), - valueof(ts_GSUP_IE_Destination_Name(destination_name))}); +template GSUP_PDU ts_GSUP_ISD_RES(hexstring imsi, + template octetstring source_name := omit, + template octetstring destination_name := omit) := + ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, + f_gen_ts_ies(imsi, source_name := source_name, + destination_name := destination_name)); template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) := tr_GSUP_IMSI(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, imsi); @@ -568,9 +573,9 @@ template GSUP_PDU tr_GSUP_PURGE_MS_ERR(template hexstring imsi, template integer tr_GSUP(OSMO_GSUP_MSGT_PURGE_MS_ERROR, { tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) }); -template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei) := - ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, { - valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI(imei)) }); +template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_REQ(hexstring imsi, hexstring imei, + template (omit) octetstring source_name := omit) := + ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST, f_gen_ts_ies(imsi, imei := imei, source_name := source_name)); template GSUP_PDU tr_GSUP_CHECK_IMEI_REQ( template hexstring imsi, @@ -588,17 +593,18 @@ template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_RES(hexstring imsi, GSUP_IMEIResult ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_IMEI_Result(result)) }); -template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result) := - tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, { - tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_IMEI_Result(result) }); +template GSUP_PDU tr_GSUP_CHECK_IMEI_RES(template hexstring imsi, template GSUP_IMEIResult result, + template octetstring destination_name := omit) := + tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, + f_gen_tr_ies(imsi, imei_result := result, destination_name := destination_name)); template (value) GSUP_PDU ts_GSUP_CHECK_IMEI_ERR(hexstring imsi, integer cause) := ts_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, { valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) }); -template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause) := - tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, { - tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) }); +template GSUP_PDU tr_GSUP_CHECK_IMEI_ERR(template hexstring imsi, template integer cause, + template octetstring destination_name := omit) := + tr_GSUP(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR, f_gen_tr_ies(imsi, cause := cause, destination_name := destination_name)); template (value) GSUP_IE ts_GSUP_IE_CancelType(GSUP_CancelType ctype) := { @@ -758,7 +764,7 @@ template (value) GSUP_IE ts_GSUP_IE_APN(octetstring apn) := { } } -template (value) GSUP_IE ts_GSUP_IE_CnDomain(GSUP_CnDomain dom) := { +template GSUP_IE ts_GSUP_IE_CnDomain(template GSUP_CnDomain dom) := { tag := OSMO_GSUP_CN_DOMAIN_IE, len := 0, /* overwritten */ val := { @@ -1217,13 +1223,85 @@ template (value) GSUP_IE ts_GSUP_IE_CURRENT_RAT_TYPE(GSUP_RatType ratt) := { } } +private function f_gen_ts_ies(hexstring imsi, + template hexstring imei := omit, + template GSUP_CnDomain dom := omit, + template octetstring source_name := omit, + template octetstring destination_name := omit + ) return GSUP_IEs { + var GSUP_IEs ies := { + valueof(ts_GSUP_IE_IMSI(imsi)) + }; + + if (isvalue(dom)) { + ies := ies & { valueof(ts_GSUP_IE_CnDomain(dom)) }; + } + + if (isvalue(imei)) { + ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) }; + } + + if (isvalue(source_name)) { + ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) }; + } + + if (isvalue(destination_name)) { + ies := ies & { valueof(ts_GSUP_IE_Destination_Name(valueof(destination_name))) }; + } + + return ies; +} + +private function f_gen_tr_ies(template hexstring imsi, + template integer cause := omit, + template hexstring msisdn := omit, + template GSUP_IMEIResult imei_result := omit, + template octetstring source_name := omit, + template octetstring destination_name := omit + ) return template GSUP_IEs { + var template GSUP_IEs ies := { + tr_GSUP_IE_IMSI(imsi) + }; + var integer idx := 1; + + if (isvalue(cause)) { + ies[idx] := tr_GSUP_IE_Cause(cause); + idx := idx + 1; + } + + if (isvalue(msisdn)) { + ies[idx] := tr_GSUP_IE_MSISDN(msisdn); + idx := idx + 1; + } + + if (isvalue(imei_result)) { + ies[idx] := tr_GSUP_IE_IMEI_Result(imei_result); + idx := idx + 1; + } + + if (isvalue(source_name)) { + ies[idx] := tr_GSUP_IE_Source_Name(source_name); + idx := idx + 1; + } + + ies[idx] := *; + idx := idx + 1; + + if (isvalue(destination_name)) { + ies[idx] := tr_GSUP_IE_Destination_Name(destination_name); + idx := idx + 1; + } + + return ies; +} private function f_gen_ts_ss_ies( hexstring imsi, OCT4 sid, GSUP_SessionState state, template (omit) octetstring ss := omit, - template (omit) integer cause := omit + template (omit) integer cause := omit, + template octetstring source_name := omit ) return GSUP_IEs { /* Mandatory IEs */ var GSUP_IEs ies := { @@ -1244,6 +1322,10 @@ private function f_gen_ts_ss_ies( ies := ies & { valueof(ts_GSUP_IE_SSInfo(valueof(ss))) }; } + if (isvalue(source_name)) { + ies := ies & { valueof(ts_GSUP_IE_Source_Name(valueof(source_name))) }; + } + return ies; } private function f_gen_tr_ss_ies( @@ -1251,7 +1333,8 @@ private function f_gen_tr_ss_ies( template OCT4 sid := ?, template GSUP_SessionState state := ?, template octetstring ss := omit, - template integer cause := omit + template integer cause := omit, + template octetstring destination_name := omit ) return template GSUP_IEs { /* Mandatory IEs */ var template GSUP_IEs ies := { @@ -1282,6 +1365,11 @@ private function f_gen_tr_ss_ies( idx := idx + 1; } + if (isvalue(destination_name)) { + ies[idx] := tr_GSUP_IE_Destination_Name(destination_name); + idx := idx + 1; + } + /* the GSUP Message Class IE is optional, as old implementations don't have it yet */ var template GSUP_IEs ies2 := ies; ies2[idx] := tr_GSUP_IE_Message_Class(OSMO_GSUP_MESSAGE_CLASS_USSD); @@ -1294,10 +1382,11 @@ template (value) GSUP_PDU ts_GSUP_PROC_SS_REQ( hexstring imsi, OCT4 sid, GSUP_SessionState state, - template (omit) octetstring ss := omit + template (omit) octetstring ss := omit, + template (omit) octetstring source_name := omit ) := ts_GSUP( OSMO_GSUP_MSGT_PROC_SS_REQUEST, - f_gen_ts_ss_ies(imsi, sid, state, ss) + f_gen_ts_ss_ies(imsi, sid, state, ss, source_name := source_name) ); template GSUP_PDU tr_GSUP_PROC_SS_REQ( template hexstring imsi, @@ -1322,10 +1411,11 @@ template GSUP_PDU tr_GSUP_PROC_SS_RES( template hexstring imsi, template OCT4 sid := ?, template GSUP_SessionState state := ?, - template octetstring ss := * + template octetstring ss := *, + template octetstring destination_name := omit ) := tr_GSUP( OSMO_GSUP_MSGT_PROC_SS_RESULT, - f_gen_tr_ss_ies(imsi, sid, state, ss) + f_gen_tr_ss_ies(imsi, sid, state, ss, destination_name := destination_name) ); template (value) GSUP_PDU ts_GSUP_PROC_SS_ERR( -- cgit v1.2.3