+
+
+
+
+int collectSetupRequestData(E2AP_PDU_t *pdu,
+ Sctp_Map_t *sctpMap,
+ ReportingMessages_t &message,
+ vector <string> &runFunDEFXML_v) {
+ auto index = 0;
+ memset(message.peerInfo->enodbName, 0 , MAX_ENODB_NAME_SIZE);
+ for (auto i = 0; i < pdu->choice.initiatingMessage->value.choice.E2setupRequest.protocolIEs.list.count; i++) {
+ auto *ie = pdu->choice.initiatingMessage->value.choice.E2setupRequest.protocolIEs.list.array[i];
+ if (ie->id == ProtocolIE_ID_id_GlobalE2node_ID) {
+ // get the ran name for meid
+ if (ie->value.present == E2setupRequestIEs__value_PR_GlobalE2node_ID) {
+ if (buildRanName(message.peerInfo->enodbName, ie) < 0) {
+ mdclog_write(MDCLOG_ERR, "Bad param in E2setupRequestIEs GlobalE2node_ID.\n");
+ // no mesage will be sent
+ return -1;
+ }
+ 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) {
+ if (mdclog_level_get() >= MDCLOG_DEBUG) {
+ mdclog_write(MDCLOG_DEBUG, "Run function list have %d entries and size %d",
+ ie->value.choice.RANfunctions_List.list.count,
+ ie->value.choice.RANfunctions_List.list.size);
+ }
+ for (auto j = 0; j < ie->value.choice.RANfunctions_List.list.count; j++) {
+ auto *raNfunctionItemIEs = (RANfunction_ItemIEs_t *)ie->value.choice.RANfunctions_List.list.array[j];
+ if (raNfunctionItemIEs->id == ProtocolIE_ID_id_RANfunction_Item &&
+ (raNfunctionItemIEs->value.present == RANfunction_ItemIEs__value_PR_RANfunction_Item)) {
+ // 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,
+ raNfunctionItemIEs->value.choice.RANfunction_Item.ranFunctionDefinition.buf,
+ raNfunctionItemIEs->value.choice.RANfunction_Item.ranFunctionDefinition.size);
+ if (rval.code != RC_OK) {
+ mdclog_write(MDCLOG_ERR, "Error %d Decoding (unpack) E2SM message from : %s",
+ rval.code,
+ asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name);
+ return -1;
+ }
+
+// if (mdclog_level_get() >= MDCLOG_DEBUG) {
+// char *printBuffer;
+// size_t size;
+// FILE *stream = open_memstream(&printBuffer, &size);
+// asn_fprint(stream, &asn_DEF_E2SM_gNB_NRT_RANfunction_Definition, ranFunDef);
+// mdclog_write(MDCLOG_DEBUG, "Encoding E2SM %s PDU past : %s",
+// asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name,
+// printBuffer);
+// }
+ auto xml_buffer_size = RECEIVE_SCTP_BUFFER_SIZE * 2;
+ unsigned char xml_buffer[RECEIVE_SCTP_BUFFER_SIZE * 2];
+ // encode to xml
+ auto 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)xml_buffer_size) {
+ mdclog_write(MDCLOG_ERR, "Buffer of size %d is to small for %s, at %s line %d",
+ (int) xml_buffer_size,
+ asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name, __func__, __LINE__);
+ } else {
+ if (mdclog_level_get() >= MDCLOG_DEBUG) {
+ mdclog_write(MDCLOG_DEBUG, "Encoding E2SM %s PDU number %d : %s",
+ asn_DEF_E2SM_gNB_NRT_RANfunction_Definition.name,
+ index++,
+ xml_buffer);
+ }
+ string runFuncs = (char *)(xml_buffer);
+ runFunDEFXML_v.emplace_back(runFuncs);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ if (mdclog_level_get() >= MDCLOG_DEBUG) {
+ mdclog_write(MDCLOG_DEBUG, "Run function vector have %ld entries",
+ runFunDEFXML_v.size());
+ }
+ return 0;
+}