pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-iuh/+/40974?usp=email )
Change subject: ranap: Introduce ranap_new_msg_error_ind() ......................................................................
ranap: Introduce ranap_new_msg_error_ind()
Change-Id: I58c75b3e0e0f33f48d077385ffac820a6b2be59e --- M TODO-RELEASE M include/osmocom/ranap/ranap_msg_factory.h M src/ranap_msg_factory.c 3 files changed, 62 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified lynxis lazus: Looks good to me, but someone else must approve
diff --git a/TODO-RELEASE b/TODO-RELEASE index f825ac1..7af0fca 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -14,3 +14,4 @@ libosmo-ranap move declaration (backwards compatible): asn_debug, asn1_xer_print: use osmocom/iuh/common.h instead of iu_client.h libosmo-ranap move definition (backwards compatible): enum ranap_nsap_addr_enc: use osmocom/ranap/ranap_common.h instead of iu_client.h libosmo-ranap move declaration (backwards compatible): ranap_iu_vty_init, ranap_iu_vty_config_write: use osmocom/ranap/vty.h instead of iu_client.h +libosmo-ranap add API ranap_new_msg_error_ind() diff --git a/include/osmocom/ranap/ranap_msg_factory.h b/include/osmocom/ranap/ranap_msg_factory.h index 0a4bdf2..b1175b0 100644 --- a/include/osmocom/ranap/ranap_msg_factory.h +++ b/include/osmocom/ranap/ranap_msg_factory.h @@ -7,6 +7,7 @@ #include <osmocom/ranap/RANAP_GlobalRNC-ID.h> #include <osmocom/ranap/RANAP_ChosenIntegrityProtectionAlgorithm.h> #include <osmocom/ranap/RANAP_ChosenEncryptionAlgorithm.h> +#include <osmocom/ranap/RANAP_CriticalityDiagnostics.h> #include <osmocom/ranap/RANAP_KeyStatus.h>
/*! \brief generate RANAP DIRECT TRANSFER message */ @@ -55,6 +56,12 @@ struct msgb *ranap_new_msg_reset_ack(RANAP_CN_DomainIndicator_t domain, const RANAP_GlobalRNC_ID_t *rnc_id);
+/*! \brief generate RANAP ERROR INDICATION message */ +struct msgb *ranap_new_msg_error_ind(const RANAP_Cause_t *cause, + const RANAP_CriticalityDiagnostics_t *criticalityDiagnostics, + const RANAP_CN_DomainIndicator_t *domain, + const RANAP_GlobalRNC_ID_t *rnc_id); +
/*! \brief generate RANAP INITIAL UE message */ struct msgb *ranap_new_msg_initial_ue(uint32_t conn_id, int is_ps, diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 8f6a99a..794d82d 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -129,6 +129,60 @@ return msg; }
+/*! \brief generate RANAP ERROR INDICATION message */ +struct msgb *ranap_new_msg_error_ind(const RANAP_Cause_t *cause, + const RANAP_CriticalityDiagnostics_t *criticalityDiagnostics, + const RANAP_CN_DomainIndicator_t *domain, + const RANAP_GlobalRNC_ID_t *rnc_id) +{ + RANAP_ErrorIndicationIEs_t ies; + RANAP_ErrorIndication_t out; + struct msgb *msg; + int rc; + + memset(&ies, 0, sizeof(ies)); + + if (cause) { + ies.presenceMask |= ERRORINDICATIONIES_RANAP_CAUSE_PRESENT; + memcpy(&ies.cause, cause, sizeof(ies.cause)); + } + + if (criticalityDiagnostics) { + ies.presenceMask |= ERRORINDICATIONIES_RANAP_CRITICALITYDIAGNOSTICS_PRESENT; + memcpy(&ies.criticalityDiagnostics, criticalityDiagnostics, sizeof(ies.criticalityDiagnostics)); + } + + if (domain) { + ies.presenceMask |= ERRORINDICATIONIES_RANAP_CN_DOMAININDICATOR_PRESENT; + ies.cN_DomainIndicator = *domain; + } + + if (rnc_id) { + ies.presenceMask = RESETACKNOWLEDGEIES_RANAP_GLOBALRNC_ID_PRESENT; + OCTET_STRING_noalloc(&ies.globalRNC_ID.pLMNidentity, + rnc_id->pLMNidentity.buf, + rnc_id->pLMNidentity.size); + ies.globalRNC_ID.rNC_ID = rnc_id->rNC_ID; + } + + memset(&out, 0, sizeof(out)); + rc = ranap_encode_errorindicationies(&out, &ies); + if (rc < 0) { + LOGP(DRANAP, LOGL_ERROR, "error encoding ErrorIndication IEs: %d\n", rc); + return NULL; + } + + msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_ErrorIndication, + RANAP_Criticality_ignore, + &asn_DEF_RANAP_ErrorIndication, + &out); + + /* release dynamic allocations attached to dt */ + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_ErrorIndication, &out); + + return msg; +} + /*! \brief generate RANAP INITIAL UE message */ struct msgb *ranap_new_msg_initial_ue(uint32_t conn_id, int is_ps, const RANAP_GlobalRNC_ID_t *rnc_id,