fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37226?usp=email )
Change subject: s1ap: add {enc,dec}_S1AP_Global_ENB_ID() API ......................................................................
s1ap: add {enc,dec}_S1AP_Global_ENB_ID() API
Change-Id: I856fd426b92046dcae72149f46737da3e1b65219 --- M library/s1ap/S1AP_EncDec.cc M library/s1ap/S1AP_Types.ttcn M mme/MME_Tests.ttcn 3 files changed, 35 insertions(+), 29 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/26/37226/1
diff --git a/library/s1ap/S1AP_EncDec.cc b/library/s1ap/S1AP_EncDec.cc index 6f82b2b..077ec31 100644 --- a/library/s1ap/S1AP_EncDec.cc +++ b/library/s1ap/S1AP_EncDec.cc @@ -30,4 +30,26 @@ return pdu; }
+OCTETSTRING enc__S1AP__Global__ENB__ID(const S1AP__IEs::Global__ENB__ID &ie) +{ + TTCN_Buffer buf; + + buf.clear(); + ie.encode(S1AP__IEs::Global__ENB__ID_descr_, buf, + TTCN_EncDec::CT_PER, PER_ALIGNED); + return OCTETSTRING(buf.get_len(), buf.get_data()); +} + +S1AP__IEs::Global__ENB__ID dec__S1AP__Global__ENB__ID(const OCTETSTRING &stream) +{ + S1AP__IEs::Global__ENB__ID ie; + TTCN_Buffer buf; + + buf.clear(); + buf.put_os(stream); + ie.decode(S1AP__IEs::Global__ENB__ID_descr_, buf, + TTCN_EncDec::CT_PER, PER_ALIGNED); + return ie; +} + } diff --git a/library/s1ap/S1AP_Types.ttcn b/library/s1ap/S1AP_Types.ttcn index 6730ff3..5d0ecbe 100644 --- a/library/s1ap/S1AP_Types.ttcn +++ b/library/s1ap/S1AP_Types.ttcn @@ -1,7 +1,11 @@ module S1AP_Types {
import from S1AP_PDU_Descriptions language "ASN.1:1997" all; + import from S1AP_IEs language "ASN.1:1997" all;
external function enc_S1AP_PDU(in S1AP_PDU pdu) return octetstring; external function dec_S1AP_PDU(in octetstring stream) return S1AP_PDU; + + external function enc_S1AP_Global_ENB_ID(in Global_ENB_ID ie) return octetstring; + external function dec_S1AP_Global_ENB_ID(in octetstring stream) return Global_ENB_ID; } diff --git a/mme/MME_Tests.ttcn b/mme/MME_Tests.ttcn index 3ea17dd..931ad91 100644 --- a/mme/MME_Tests.ttcn +++ b/mme/MME_Tests.ttcn @@ -124,35 +124,6 @@ var UeParams g_ue_pars[NUM_UE]; }
-/* Encode an S1AP Global-ENB-ID into an octetstring */ -private function enc_S1AP_Global_ENB_ID(Global_ENB_ID global_enb_id) return octetstring { - - /* Due to the limitations of libfftranscode, we can not define encoders (or decoders) for individual - * information elements (in S1AP_Types.cc). Unfortuantely Global-ENB-ID also appears in BSSGP in its - * encoded form. (see also: GTP-C 3GPP TS 48.018, section 11.3.70). To encode a given Global-ENB-ID - * we craft a full S1AP PDU and encode it. Then we can cut out the encoded Global-ENB-ID from the - * generated octetstring. */ - - var SupportedTAs supported_tas_dummy := {{ - tAC := '0000'O, - broadcastPLMNs := { '00f000'O }, - iE_Extensions := omit - }}; - var octetstring encoded; - var integer global_enb_id_len; - - if (ispresent(global_enb_id.eNB_ID.macroENB_ID)) { - global_enb_id_len := 8; - } else { - /* All other ENB ID types fit into 8 byte (homeENB_ID, short_macroENB_ID, long_macroENB_ID) */ - global_enb_id_len := 9; - } - - encoded := enc_S1AP_PDU(valueof(ts_S1AP_SetupReq(global_enb_id, supported_tas_dummy, v32))); - - return substr(encoded, 11, global_enb_id_len); -} - type component ConnHdlr extends S1AP_ConnHdlr, SGsAP_ConnHdlr, DIAMETER_ConnHdlr, GTP_ConnHdlr, GTP2_ConnHdlr { var ConnHdlrPars g_pars; timer g_Tguard := 30.0;