diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c index b2a58a77bdcedbab13dfb97b6d16cac67e85e533..fb59a57901396b1c8e969eb4596bccebb80e94eb 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c @@ -32,18 +32,112 @@ #include "f1ap_common.h" #include "f1ap_cu_rrc_message_transfer.h" +// undefine C_RNTI from +// openair1/PHY/LTE_TRANSPORT/transport_common.h which +// replaces in ie->value.choice.C_RNTI, causing +// a compile error +#undef C_RNTI /* Initial UL RRC Message Transfer */ -void CU_handle_UL_INITIAL_RRC_MESSAGE_TRANSFER(void) { +int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(int32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu) { - printf("CU_handle_UL_INITIAL_RRC_MESSAGE_TRANSFER\n"); + printf("CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER\n"); // decode the F1 message // get the rrc message from the contauiner // call func rrc_eNB_decode_ccch: <-- needs some update here + MessageDef *message_p; + F1AP_InitialULRRCMessageTransfer_t *container; + F1AP_InitialULRRCMessageTransferIEs_t *ie; + + SRB_INFO* Srb_info; + protocol_ctxt_t ctxt; + rnti_t rnti; + uint8_t *ccch_sdu; + sdu_size_t ccch_sdu_len; + int CC_id =0; + int instance=0; + uint64_t du_ue_f1ap_id; + + DevAssert(pdu != NULL); + + if (stream != 0) { + LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n", + assoc_id, stream); + return -1; + } + + container = &pdu->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer; + + /* GNB_DU_UE_F1AP_ID */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true); + du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID; + printf("du_ue_f1ap_id %lu \n", du_ue_f1ap_id); + + /* NRCGI */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_NRCGI, true); + instance = 0; ///ie->value.choice. ?? //@Todo + + /* RNTI */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_C_RNTI, true); + BIT_STRING_TO_CELL_IDENTITY(&ie->value.choice.C_RNTI, rnti); + + /* RRC Container */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_RRCContainer, true); + + ccch_sdu = calloc(ie->value.choice.RRCContainer.size + 1, sizeof(char)); + memcpy(ccch_sdu, ie->value.choice.RRCContainer.buf, + ie->value.choice.RRCContainer.size); + /* Convert the mme name to a printable string */ + ccch_sdu[ie->value.choice.RRCContainer.size] = '\0'; + printf ("RRCContainer %s \n", ccch_sdu); + + ccch_sdu_len = ie->value.choice.RRCContainer.size; + + // create an ITTI message + message_p = itti_alloc_new_message (TASK_CU_F1, RRC_MAC_CCCH_DATA_IND); + memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); + memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, ccch_sdu, ccch_sdu_len); + RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; + RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; + RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; + RRC_MAC_CCCH_DATA_IND (message_p).enb_index = instance; // CU instance + RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; + RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; + itti_send_msg_to_task (TASK_RRC_ENB, instance, message_p); + + + // OR creat the ctxt and srb_info struct required by rrc_eNB_decode_ccch +/* + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + instance, // to fix + ENB_FLAG_YES, + rnti, + 0, // frame + 0); // slot + + CC_id = RRC_MAC_CCCH_DATA_IND(msg_p).CC_id; + srb_info_p = &RC.rrc[instance]->carrier[CC_id].Srb0; + + if (ccch_sdu_len >= RRC_BUFFER_SIZE_MAX) { + LOG_E(RRC, "CCCH message has size %d > %d\n",ccch_sdu_len,RRC_BUFFER_SIZE_MAX); + break; + } + memcpy(srb_info_p->Rx_buffer.Payload, + ccch_sdu, + ccch_sdu_len); + srb_info->Rx_buffer.payload_size = ccch_sdu_len; + rrc_eNB_decode_ccch(&ctxt, srb_info, CC_id); + */ // if size > 0 // CU_send_DL_RRC_MESSAGE_TRANSFER(C.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size) } diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.h b/openair2/F1AP/f1ap_cu_rrc_message_transfer.h index 24d5a7528ae9040f3ae2294d5254517ffa3445e9..77fd25da297b24f83321051f1ba5c371223adb0a 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.h +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.h @@ -33,4 +33,7 @@ #ifndef F1AP_CU_RRC_MESSAGE_TRANSFER_H_ #define F1AP_CU_RRC_MESSAGE_TRANSFER_H_ +int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(int32_t assoc_id, + uint32_t stream, + F1AP_F1AP_PDU_t *pdu); #endif /* F1AP_CU_RRC_MESSAGE_TRANSFER_H_ */ \ No newline at end of file diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index 2efd22fb23ff40c35355f652b572640c37e67ab9..2675944eab1251a9cad73e21481e8152a76f4aed 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -310,7 +310,6 @@ int DU_handle_F1_SETUP_RESPONSE(uint32_t assoc_id, F1AP_F1AP_PDU_t *pdu) { printf("DU_handle_F1_SETUP_RESPONSE\n"); - return 0; } @@ -382,7 +381,7 @@ void DU_send_gNB_DU_CONFIGURATION_UPDATE(module_id_t enb_mod_idP, module_id_t du /* - nRCGI */ F1AP_NRCGI_t nRCGI; MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[i], &nRCGI.nRCellIdentity); served_cell_information.nRCGI = nRCGI; /* - nRPCI */ @@ -536,7 +535,7 @@ void DU_send_gNB_DU_CONFIGURATION_UPDATE(module_id_t enb_mod_idP, module_id_t du F1AP_NRCGI_t oldNRCGI; MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &oldNRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &oldNRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[i], &oldNRCGI.nRCellIdentity); served_cells_to_modify_item.oldNRCGI = oldNRCGI; @@ -548,7 +547,7 @@ void DU_send_gNB_DU_CONFIGURATION_UPDATE(module_id_t enb_mod_idP, module_id_t du F1AP_NRCGI_t nRCGI; MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[i], &nRCGI.nRCellIdentity); served_cell_information.nRCGI = nRCGI; /* - nRPCI */ diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index 7e2a113329c1d4e716c68d512a8d24291d9563df..f8606e0eef3cb9474a03fc8505061a17fe49cd45 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -163,7 +163,7 @@ void DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER( F1AP_NRCGI_t nRCGI; MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[0], f1ap_du_data->mnc[0], f1ap_du_data->mnc_digit_length[0], &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity); ie->value.choice.NRCGI = nRCGI; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); @@ -206,7 +206,7 @@ void DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER( printf("\n"); - //du_f1ap_itti_send_sctp_data_req(instance, f1ap_setup_req->assoc_id, buffer, len, 0); + du_f1ap_itti_send_sctp_data_req(0, f1ap_du_data->assoc_id, buffer, len, 0); /* decode */ // if (f1ap_decode_pdu(&pdu, buffer, len) > 0) { // printf("Failed to decode F1 setup request\n"); diff --git a/openair2/F1AP/f1ap_handlers.c b/openair2/F1AP/f1ap_handlers.c index e4178e358c9683b5611294c1b3b587ae5f4b06f1..25b2234d6c0592f950dbfd42e3ef121234f36e02 100644 --- a/openair2/F1AP/f1ap_handlers.c +++ b/openair2/F1AP/f1ap_handlers.c @@ -34,6 +34,7 @@ #include "f1ap_handlers.h" #include "f1ap_cu_interface_management.h" #include "f1ap_du_interface_management.h" +#include "f1ap_cu_rrc_message_transfer.h" extern f1ap_setup_req_t *f1ap_du_data_from_du; @@ -52,7 +53,7 @@ f1ap_message_decoded_callback f1ap_messages_callback[][3] = { { 0, 0, 0 }, /* UEContextModificationRequired */ { 0, 0, 0 }, /* UEMobilityCommand */ { 0, 0, 0 }, /* UEContextReleaseRequest */ - { CU_handle_F1_SETUP_REQUEST, 0, 0 }, /* InitialULRRCMessageTransfer */ + { CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER, 0, 0 }, /* InitialULRRCMessageTransfer */ { CU_handle_F1_SETUP_REQUEST, 0, 0 }, /* DLRRCMessageTransfer */ { CU_handle_F1_SETUP_REQUEST, 0, 0 }, /* ULRRCMessageTransfer */ { 0, 0, 0 }, /* privateMessage */ diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index b8cf85a0a303e68bdba56f69139bc4a55a193f73..f55f22b8d43e9371dec292533e2055a1c3e1b319 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -367,7 +367,7 @@ rx_sdu(const module_id_t enb_mod_idP, ra = &mac->common_channels[CC_idP].ra[ii]; if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { //int RC.cudu.du_flag = 1; - int du_flag = 1; + //int du_flag = 1; mac_rrc_data_ind( enb_mod_idP, CC_idP, @@ -377,7 +377,7 @@ rx_sdu(const module_id_t enb_mod_idP, (uint8_t *) payload_ptr, rx_lengths[i], 0, - du_flag + RC.rrc[enb_mod_idP]->node_type ); // prepare transmission of Msg4(RRCConnectionReconfiguration) ra->state = MSGCRNTI; @@ -619,7 +619,7 @@ rx_sdu(const module_id_t enb_mod_idP, } //int RC.cudu.du_flag = 1; - int du_flag = 1; + //int du_flag = 1; mac_rrc_data_ind( enb_mod_idP, CC_idP, @@ -629,7 +629,7 @@ rx_sdu(const module_id_t enb_mod_idP, (uint8_t *) payload_ptr, rx_lengths[i], 0, - du_flag + RC.rrc[enb_mod_idP]->node_type ); diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c index e848ac47a9b4be383f9b6422103413dc7aee1d82..02335aa99a64f8ef74a2b93a27d7bb18fb213b41 100644 --- a/openair2/RRC/LTE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -226,31 +226,31 @@ mac_rrc_data_req( } //-------------------------------------------------------------------------- -int8_t -mac_du_data_ind( - const module_id_t module_idP, - const int CC_idP, - const int UE_id, - const rnti_t rntiP, - const uint8_t *sduP, - const sdu_size_t sdu_lenP -) -//-------------------------------------------------------------------------- -{ - printf( - "[F1 %d][RAPROC] CC_id %d current_rnti %x Received Msg3 from already registered UE %d: length %d, offset %ld\n", - module_idP, CC_idP, rntiP, - UE_id, sdu_lenP, sduP); - - DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER( - module_idP, - CC_idP, - UE_id, - rntiP, - sduP, - sdu_lenP - ); -} +// int8_t +// mac_du_data_ind( +// const module_id_t module_idP, +// const int CC_idP, +// const int UE_id, +// const rnti_t rntiP, +// const uint8_t *sduP, +// const sdu_size_t sdu_lenP +// ) +// //-------------------------------------------------------------------------- +// { +// printf( +// "[F1 %d][RAPROC] CC_id %d current_rnti %x Received Msg3 from already registered UE %d: length %d, offset %ld\n", +// module_idP, CC_idP, rntiP, +// UE_id, sdu_lenP, sduP); + +// DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER( +// module_idP, +// CC_idP, +// UE_id, +// rntiP, +// sduP, +// sdu_lenP +// ); +// } //------------------------------------------------------------------------------ int8_t @@ -265,21 +265,25 @@ mac_rrc_data_ind( const uint8_t* sduP, const sdu_size_t sdu_lenP, const uint8_t mbsfn_sync_areaP, - const int du_flag + const int node_type ) //-------------------------------------------------------------------------- { - - // navid update / Bing-Kai modify - if (du_flag) { - mac_du_data_ind( - module_idP, - CC_id, - UE_id, - rntiP, - sduP, - sdu_lenP); - } + LOG_E(RRC, "node_type == %d \n" , node_type); + if (node_type == ngran_eNB_DU) { + LOG_W(RRC,"[DU %d][RAPROC] Received SDU for CCCH on SRB %d length %d for UE id %d RNTI %x \n", + module_idP, srb_idP, sdu_lenP, UE_id, rntiP); + + DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER( + module_idP, + CC_id, + UE_id, + rntiP, + sduP, + sdu_lenP + ); + return(0); + } SRB_INFO *Srb_info; protocol_ctxt_t ctxt; diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h index 0c87d18094bf2b85ef4e157ca94e75ae1e06b985..68c8655714e14f0579744d658feca18452ebd88f 100644 --- a/openair2/RRC/LTE/rrc_proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -428,7 +428,7 @@ mac_rrc_data_ind( const uint8_t* sduP, const sdu_size_t sdu_lenP, const uint8_t mbsfn_sync_areaP, - const int du_flag + const int node_type ); int8_t