Use F1AP lib for UL RRC Message Trasfer in stack
This commit is contained in:
@@ -96,76 +96,67 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(sctp_assoc_t assoc_id, f1ap_dl_rrc_message_t
|
|||||||
*/
|
*/
|
||||||
int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, sctp_assoc_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu)
|
int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, sctp_assoc_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu)
|
||||||
{
|
{
|
||||||
LOG_D(F1AP, "CU_handle_UL_RRC_MESSAGE_TRANSFER \n");
|
|
||||||
F1AP_ULRRCMessageTransfer_t *container;
|
|
||||||
F1AP_ULRRCMessageTransferIEs_t *ie;
|
|
||||||
uint64_t cu_ue_f1ap_id;
|
|
||||||
uint64_t du_ue_f1ap_id;
|
|
||||||
uint64_t srb_id;
|
|
||||||
DevAssert(pdu != NULL);
|
|
||||||
|
|
||||||
if (stream != 0) {
|
if (stream != 0) {
|
||||||
LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n",
|
LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n",
|
||||||
assoc_id, stream);
|
assoc_id, stream);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
container = &pdu->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
|
f1ap_ul_rrc_message_t msg = {0};
|
||||||
/* GNB_CU_UE_F1AP_ID */
|
|
||||||
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
|
|
||||||
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
|
|
||||||
cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
|
|
||||||
/* GNB_DU_UE_F1AP_ID */
|
|
||||||
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_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;
|
|
||||||
|
|
||||||
if (!cu_exists_f1_ue_data(cu_ue_f1ap_id)) {
|
LOG_D(F1AP, "CU_handle_UL_RRC_MESSAGE_TRANSFER \n");
|
||||||
LOG_E(F1AP, "unknown CU UE ID %ld\n", cu_ue_f1ap_id);
|
if (!decode_ul_rrc_message_transfer(pdu, &msg)) {
|
||||||
return 1;
|
LOG_E(F1AP, "cannot decode F1 UL RRC message Transfer\n");
|
||||||
|
free_ul_rrc_message_transfer(&msg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cu_exists_f1_ue_data(msg.gNB_CU_ue_id)) {
|
||||||
|
LOG_E(F1AP, "unknown CU UE ID %d\n", msg.gNB_CU_ue_id);
|
||||||
|
free_ul_rrc_message_transfer(&msg);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the RLC-PDCP does not transport the DU UE ID (yet), so we drop it here.
|
/* the RLC-PDCP does not transport the DU UE ID (yet), so we drop it here.
|
||||||
* For the moment, let's hope this won't become relevant; to sleep in peace,
|
* For the moment, let's hope this won't become relevant; to sleep in peace,
|
||||||
* let's put an assert to check that it is the expected DU UE ID. */
|
* let's put an assert to check that it is the expected DU UE ID. */
|
||||||
f1_ue_data_t ue_data = cu_get_f1_ue_data(cu_ue_f1ap_id);
|
f1_ue_data_t ue_data = cu_get_f1_ue_data(msg.gNB_CU_ue_id);
|
||||||
if (ue_data.secondary_ue != du_ue_f1ap_id) {
|
if (ue_data.secondary_ue != msg.gNB_DU_ue_id) {
|
||||||
LOG_E(F1AP, "unexpected DU UE ID %u received, expected it to be %lu\n", ue_data.secondary_ue, du_ue_f1ap_id);
|
LOG_E(F1AP, "unexpected DU UE ID %u received, expected it to be %u\n", ue_data.secondary_ue, msg.gNB_DU_ue_id);
|
||||||
return 1;
|
free_ul_rrc_message_transfer(&msg);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mandatory */
|
if (msg.srb_id < 1)
|
||||||
/* SRBID */
|
LOG_E(F1AP, "Unexpected UL RRC MESSAGE for SRB %d \n", msg.srb_id);
|
||||||
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
|
|
||||||
F1AP_ProtocolIE_ID_id_SRBID, true);
|
|
||||||
srb_id = ie->value.choice.SRBID;
|
|
||||||
|
|
||||||
if (srb_id < 1 )
|
|
||||||
LOG_E(F1AP, "Unexpected UL RRC MESSAGE for srb_id %lu \n", srb_id);
|
|
||||||
else
|
else
|
||||||
LOG_D(F1AP, "UL RRC MESSAGE for srb_id %lu in DCCH \n", srb_id);
|
LOG_D(F1AP, "UL RRC MESSAGE for SRB %d in DCCH \n", msg.srb_id);
|
||||||
|
|
||||||
|
protocol_ctxt_t ctxt = {
|
||||||
|
.instance = instance,
|
||||||
|
.module_id = instance,
|
||||||
|
.enb_flag = 1,
|
||||||
|
.eNB_index = 0,
|
||||||
|
.rntiMaybeUEid = msg.gNB_CU_ue_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
LOG_D(F1AP,
|
||||||
|
"[UE %lx] calling pdcp_data_ind for SRB %d with size %d (DCCH) \n",
|
||||||
|
ctxt.rntiMaybeUEid,
|
||||||
|
msg.srb_id,
|
||||||
|
msg.rrc_container_length);
|
||||||
|
uint8_t *mb = malloc16(msg.rrc_container_length);
|
||||||
|
memcpy(mb, msg.rrc_container, msg.rrc_container_length);
|
||||||
|
|
||||||
// issue in here
|
|
||||||
/* mandatory */
|
|
||||||
/* RRC Container */
|
|
||||||
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
|
|
||||||
F1AP_ProtocolIE_ID_id_RRCContainer, true);
|
|
||||||
protocol_ctxt_t ctxt={0};
|
|
||||||
ctxt.instance = instance;
|
|
||||||
ctxt.module_id = instance;
|
|
||||||
ctxt.rntiMaybeUEid = cu_ue_f1ap_id;
|
|
||||||
ctxt.enb_flag = 1;
|
|
||||||
ctxt.eNB_index = 0;
|
|
||||||
uint8_t *mb = malloc16(ie->value.choice.RRCContainer.size);
|
|
||||||
memcpy(mb, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size);
|
|
||||||
LOG_D(F1AP, "Calling pdcp_data_ind for UE RNTI %lx srb_id %lu with size %ld (DCCH) \n", ctxt.rntiMaybeUEid, srb_id, ie->value.choice.RRCContainer.size);
|
|
||||||
nr_pdcp_data_ind(&ctxt,
|
nr_pdcp_data_ind(&ctxt,
|
||||||
1, // srb_flag
|
1, // srb_flag
|
||||||
0, // embms_flag
|
0, // embms_flag
|
||||||
srb_id,
|
msg.srb_id,
|
||||||
ie->value.choice.RRCContainer.size,
|
msg.rrc_container_length,
|
||||||
mb,
|
mb,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
/* Free UL RRC Message Transfer */
|
||||||
|
free_ul_rrc_message_transfer(&msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,64 +100,29 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(sctp_assoc_t assoc_id, const f1ap_in
|
|||||||
|
|
||||||
int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(sctp_assoc_t assoc_id, const f1ap_ul_rrc_message_t *msg)
|
int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(sctp_assoc_t assoc_id, const f1ap_ul_rrc_message_t *msg)
|
||||||
{
|
{
|
||||||
F1AP_F1AP_PDU_t pdu= {0};
|
|
||||||
F1AP_ULRRCMessageTransfer_t *out;
|
|
||||||
uint8_t *buffer = NULL;
|
|
||||||
uint32_t len;
|
|
||||||
LOG_D(F1AP,
|
LOG_D(F1AP,
|
||||||
"size %d UE RNTI %x in SRB %d\n",
|
"size %d UE RNTI %x in SRB %d\n",
|
||||||
msg->rrc_container_length,
|
msg->rrc_container_length,
|
||||||
msg->gNB_DU_ue_id,
|
msg->gNB_DU_ue_id,
|
||||||
msg->srb_id);
|
msg->srb_id);
|
||||||
//for (int i = 0;i < msg->rrc_container_length; i++)
|
/* encode UL RRC Message Transfer */
|
||||||
// printf("%02x ", msg->rrc_container[i]);
|
F1AP_F1AP_PDU_t *pdu = encode_ul_rrc_message_transfer(msg);
|
||||||
//printf("\n");
|
if (pdu == NULL) {
|
||||||
/* Create */
|
LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER: cannot send message\n");
|
||||||
/* 0. Message Type */
|
ASN_STRUCT_FREE(asn_DEF_F1AP_F1AP_PDU, pdu);
|
||||||
pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
|
|
||||||
asn1cCalloc(pdu.choice.initiatingMessage, tmp);
|
|
||||||
tmp->procedureCode = F1AP_ProcedureCode_id_ULRRCMessageTransfer;
|
|
||||||
tmp->criticality = F1AP_Criticality_ignore;
|
|
||||||
tmp->value.present = F1AP_InitiatingMessage__value_PR_ULRRCMessageTransfer;
|
|
||||||
out = &tmp->value.choice.ULRRCMessageTransfer;
|
|
||||||
/* mandatory */
|
|
||||||
/* c1. GNB_CU_UE_F1AP_ID */
|
|
||||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie1);
|
|
||||||
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
|
|
||||||
ie1->criticality = F1AP_Criticality_reject;
|
|
||||||
ie1->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
|
|
||||||
ie1->value.choice.GNB_CU_UE_F1AP_ID = msg->gNB_CU_ue_id;
|
|
||||||
/* mandatory */
|
|
||||||
/* c2. GNB_DU_UE_F1AP_ID */
|
|
||||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie2);
|
|
||||||
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
|
|
||||||
ie2->criticality = F1AP_Criticality_reject;
|
|
||||||
ie2->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
|
|
||||||
ie2->value.choice.GNB_DU_UE_F1AP_ID = msg->gNB_DU_ue_id;
|
|
||||||
/* mandatory */
|
|
||||||
/* c3. SRBID */
|
|
||||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie3);
|
|
||||||
ie3->id = F1AP_ProtocolIE_ID_id_SRBID;
|
|
||||||
ie3->criticality = F1AP_Criticality_reject;
|
|
||||||
ie3->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_SRBID;
|
|
||||||
ie3->value.choice.SRBID = msg->srb_id;
|
|
||||||
// issue in here
|
|
||||||
/* mandatory */
|
|
||||||
/* c4. RRCContainer */
|
|
||||||
asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie4);
|
|
||||||
ie4->id = F1AP_ProtocolIE_ID_id_RRCContainer;
|
|
||||||
ie4->criticality = F1AP_Criticality_reject;
|
|
||||||
ie4->value.present = F1AP_ULRRCMessageTransferIEs__value_PR_RRCContainer;
|
|
||||||
OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer,
|
|
||||||
(const char *) msg->rrc_container,
|
|
||||||
msg->rrc_container_length);
|
|
||||||
|
|
||||||
/* encode */
|
|
||||||
if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
|
|
||||||
LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER \n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
/* encode F1AP PDU */
|
||||||
|
uint8_t *buffer = NULL;
|
||||||
|
uint32_t len;
|
||||||
|
if (f1ap_encode_pdu(pdu, &buffer, &len) < 0) {
|
||||||
|
LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER \n");
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_F1AP_F1AP_PDU, pdu);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* Free F1AP PDU */
|
||||||
|
ASN_STRUCT_FREE(asn_DEF_F1AP_F1AP_PDU, pdu);
|
||||||
|
/* Send to ITTI */
|
||||||
f1ap_itti_send_sctp_data_req(assoc_id, buffer, len);
|
f1ap_itti_send_sctp_data_req(assoc_id, buffer, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user