+ if (buildRanName(message.peerInfo->enodbName, ie) < 0) {
+ mdclog_write(MDCLOG_ERR, "Bad param in E2setupRequestIEs GlobalE2node_ID.\n");
+ // no mesage will be sent
+ break;
+ }
+ memcpy(message.message.enodbName, message.peerInfo->enodbName, strlen(message.peerInfo->enodbName));
+ sctpMap->setkey(message.message.enodbName, message.peerInfo);
+ }
+ }
+ // reformat RANFUNCTION Definition to XML
+ if (ie->id == ProtocolIE_ID_id_RANfunctionsAdded) {
+ if (ie->value.present == E2setupRequestIEs__value_PR_RANfunctions_List) {
+ for (auto j = 0; i < ie->value.choice.RANfunctions_List.list.count; i++) {
+ auto *raNfunctionItemIEs = (RANfunction_ItemIEs_t *)ie->value.choice.RANfunctions_List.list.array[j];
+ if (raNfunctionItemIEs->id == ProtocolIE_ID_id_RANfunction_Item) {
+ auto buffer_size = RECEIVE_SCTP_BUFFER_SIZE * 2;
+ unsigned char buffer[RECEIVE_SCTP_BUFFER_SIZE * 2];
+ // encode to xml
+ E2SM_gNB_NRT_RANfunction_Definition_t *ranFunDef = nullptr;
+ auto rval = asn_decode(nullptr, ATS_ALIGNED_BASIC_PER,
+ &asn_DEF_E2SM_gNB_NRT_RANfunction_Definition,
+ (void **)&ranFunDef,
+ buffer,
+ buffer_size);
+ if (rval.code != RC_OK) {
+ mdclog_write(MDCLOG_ERR, "Error %d Decoding (unpack) E2AP PDU from E2MGR : %s",
+ rval.code,
+ asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name);
+ failed = true;
+ break;
+ }
+
+ if (mdclog_level_get() >= MDCLOG_DEBUG) {
+ char *printBuffer;
+ size_t size;
+ FILE *stream = open_memstream(&printBuffer, &size);
+ asn_fprint(stream, &asn_DEF_E2AP_PDU, pdu);
+ mdclog_write(MDCLOG_DEBUG, "Encoding E2AP PDU past : %s", printBuffer);
+ }
+ auto xml_buffer_size = RECEIVE_SCTP_BUFFER_SIZE * 2;
+ unsigned char xml_buffer[RECEIVE_SCTP_BUFFER_SIZE * 2];
+ // encode to xml
+ er = asn_encode_to_buffer(nullptr,
+ ATS_BASIC_XER,
+ &asn_DEF_E2SM_gNB_NRT_RANfunction_Definition,
+ ranFunDef,
+ xml_buffer,
+ xml_buffer_size);
+ if (er.encoded == -1) {
+ mdclog_write(MDCLOG_ERR, "encoding of %s failed, %s",
+ asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name,
+ strerror(errno));
+ } else if (er.encoded > (ssize_t) buffer_size) {
+ mdclog_write(MDCLOG_ERR, "Buffer of size %d is to small for %s",
+ (int) xml_buffer_size,
+ asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name);
+ } else {
+ // we have the xml
+ }
+
+ }
+ }
+ if (failed) {
+ break;
+ }