pespin has uploaded this change for review.

View Change

ranap: Add API to encode Reset Resource into msgb

Related: SYS#6602
Change-Id: I5e7b647dee2887d9af7dc22bc9f46f499f676e01
---
M TODO-RELEASE
M include/osmocom/ranap/ranap_msg_factory.h
M src/ranap_msg_factory.c
3 files changed, 80 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/69/38569/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 0ed7189..a6b0779 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
+libosmo-ranap add API ranap_new_msg_reset_resource()
diff --git a/include/osmocom/ranap/ranap_msg_factory.h b/include/osmocom/ranap/ranap_msg_factory.h
index 4b42d05..5ff2d54 100644
--- a/include/osmocom/ranap/ranap_msg_factory.h
+++ b/include/osmocom/ranap/ranap_msg_factory.h
@@ -66,3 +66,10 @@

/*! \brief generate RANAP RAB RELEASE REQUEST message */
struct msgb *ranap_new_msg_rab_rel_req(uint8_t rab_id, const RANAP_Cause_t *cause);
+
+/*! \brief generate RANAP INITIAL UE message */
+struct msgb *ranap_new_msg_reset_resource(int is_ps,
+ const RANAP_Cause_t *cause,
+ const uint32_t *conn_id_list,
+ unsigned int conn_id_list_len,
+ RANAP_GlobalRNC_ID_t *rnc_id);
diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index 44b879f..f464214 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -965,3 +965,75 @@

return msg;
}
+
+/*! \brief generate RANAP RAB RELEASE REQUEST message */
+struct msgb *ranap_new_msg_reset_resource(int is_ps,
+ const RANAP_Cause_t *cause,
+ const uint32_t *conn_id_list,
+ unsigned int conn_id_list_len,
+ RANAP_GlobalRNC_ID_t *rnc_id)
+{
+ RANAP_ResetResourceItemIEs_t item_ies;
+ RANAP_ResetResourceIEs_t ies;
+ RANAP_ResetResource_t out;
+ uint32_t ctxidbuf;
+ struct msgb *msg;
+ int rc;
+
+ OSMO_ASSERT(conn_id_list);
+ OSMO_ASSERT(cause);
+
+ memset(&item_ies, 0, sizeof(item_ies));
+ memset(&ies, 0, sizeof(ies));
+ memset(&out, 0, sizeof(out));
+
+ /* CN Domain Indicator */
+ if (is_ps)
+ ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_ps_domain;
+ else
+ ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_cs_domain;
+
+ /* Cause */
+ memcpy(&ies.cause, cause, sizeof(ies.cause));
+
+ /* Reset Resource Item IEs */
+ if (conn_id_list_len != 1) {
+ LOGP(DRANAP, LOGL_ERROR, "Encoding ResourceReset len %u != 1 not supported!\n", conn_id_list_len);
+ return NULL;
+ }
+ asn1_u24_to_bitstring(&item_ies.iuSigConIdItem.iuSigConId, &ctxidbuf, conn_id_list[0]);
+
+ /* Encode items into the list: */
+ rc = ranap_encode_resetresourceitemies(&ies.iuSigConIdList, &item_ies);
+ if (rc < 0)
+ return NULL;
+
+ /* Global RNC-ID */
+ if (rnc_id) {
+ ies.presenceMask = RESETIES_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;
+ }
+
+ /* encode the list IEs into the output */
+ rc = ranap_encode_resetresourceies(&out, &ies);
+
+ /* 'out' has been generated, we can release the input */
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_ResetResourceList, &ies.iuSigConIdList);
+
+ if (rc < 0) {
+ LOGP(DRANAP, LOGL_ERROR, "error encoding release request IEs: %d\n", rc);
+ return NULL;
+ }
+
+ /* encode the output into the msgb */
+ msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_ResetResource,
+ RANAP_Criticality_reject,
+ &asn_DEF_RANAP_ResetResource, &out);
+
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_ResetResource, &out);
+
+ return msg;
+}

To view, visit change 38569. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I5e7b647dee2887d9af7dc22bc9f46f499f676e01
Gerrit-Change-Number: 38569
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>