Commit 00a47807 authored by Laurent THOMAS's avatar Laurent THOMAS

some progress in du ue context setup

parent 7e1febce
......@@ -55,78 +55,95 @@ boolean_t DURecvCb( protocol_ctxt_t *ctxt_pP,
return true;
}
int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, rnti_t rntiP);
int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, rnti_t rntiP, int nbTEID, teid_t * teids);
int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
uint32_t assoc_id,
uint32_t stream,
F1AP_F1AP_PDU_t *pdu) {
MessageDef *msg_p; // message to RRC
F1AP_UEContextSetupRequest_t *container;
F1AP_UEContextSetupRequestIEs_t *ie;
int i;
DevAssert(pdu);
msg_p = itti_alloc_new_message(TASK_DU_F1, 0, F1AP_UE_CONTEXT_SETUP_REQ);
f1ap_ue_context_setup_req_t *f1ap_ue_context_setup_req = &F1AP_UE_CONTEXT_SETUP_REQ(msg_p);
container = &pdu->choice.initiatingMessage->value.choice.UEContextSetupRequest;
/* GNB_CU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieCU;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieCU, container,
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
f1ap_ue_context_setup_req->gNB_CU_ue_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
f1ap_ue_context_setup_req->gNB_CU_ue_id = ieCU->value.choice.GNB_CU_UE_F1AP_ID;
/* optional */
/* GNB_DU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieDU_UE;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDU_UE, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, false);
if (ie) {
if (ieDU_UE) {
f1ap_ue_context_setup_req->gNB_DU_ue_id = malloc(sizeof(uint32_t));
if (f1ap_ue_context_setup_req->gNB_DU_ue_id)
*f1ap_ue_context_setup_req->gNB_DU_ue_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
*f1ap_ue_context_setup_req->gNB_DU_ue_id =
ieDU_UE->value.choice.GNB_DU_UE_F1AP_ID;
} else {
f1ap_ue_context_setup_req->gNB_DU_ue_id = NULL;
}
if(f1ap_ue_context_setup_req->gNB_DU_ue_id!=NULL)
f1ap_ue_context_setup_req->rnti = f1ap_get_rnti_by_du_id(false, instance, *f1ap_ue_context_setup_req->gNB_DU_ue_id);
else
f1ap_ue_context_setup_req->rnti = f1ap_get_rnti_by_cu_id(false, instance, f1ap_ue_context_setup_req->gNB_CU_ue_id);
if(f1ap_ue_context_setup_req->rnti<0)
LOG_E(F1AP, "Could not retrieve UE rnti based on the CU/DU UE id \n");
else
LOG_I(F1AP, "Retrieved rnti is: %d \n", f1ap_ue_context_setup_req->rnti);
/* SpCell_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieNet;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieNet, container,
F1AP_ProtocolIE_ID_id_SpCell_ID, true);
PLMNID_TO_MCC_MNC(&ie->value.choice.NRCGI.pLMN_Identity,
PLMNID_TO_MCC_MNC(&ieNet->value.choice.NRCGI.pLMN_Identity,
f1ap_ue_context_setup_req->mcc,
f1ap_ue_context_setup_req->mnc,
f1ap_ue_context_setup_req->mnc_digit_length);
BIT_STRING_TO_NR_CELL_IDENTITY(&ie->value.choice.NRCGI.nRCellIdentity, f1ap_ue_context_setup_req->nr_cellid);
BIT_STRING_TO_NR_CELL_IDENTITY(&ieNet->value.choice.NRCGI.nRCellIdentity, f1ap_ue_context_setup_req->nr_cellid);
/* ServCellIndex */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieCell;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieCell, container,
F1AP_ProtocolIE_ID_id_ServCellIndex, true);
f1ap_ue_context_setup_req->servCellIndex = ie->value.choice.ServCellIndex;
f1ap_ue_context_setup_req->servCellIndex = ieCell->value.choice.ServCellIndex;
/* optional */
/* CellULConfigured */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieULCell;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieULCell, container,
F1AP_ProtocolIE_ID_id_SpCellULConfigured, false); // SpCellULConfigured
if (ie) {
if (ieULCell) {
/* correct here */
f1ap_ue_context_setup_req->cellULConfigured = malloc(sizeof(uint32_t));
if (f1ap_ue_context_setup_req->cellULConfigured)
*f1ap_ue_context_setup_req->cellULConfigured = ie->value.choice.CellULConfigured;
*f1ap_ue_context_setup_req->cellULConfigured = ieULCell->value.choice.CellULConfigured;
} else {
f1ap_ue_context_setup_req->cellULConfigured = NULL;
}
teid_t *teids=NULL;
if (RC.nrrrc) {
/* RRCContainer */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieDrb;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieDrb, container,
F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true);
f1ap_ue_context_setup_req->drbs_to_be_setup_length = ie->value.choice.DRBs_ToBeSetup_List.list.count;
f1ap_ue_context_setup_req->drbs_to_be_setup_length = ieDrb->value.choice.DRBs_ToBeSetup_List.list.count;
f1ap_ue_context_setup_req->drbs_to_be_setup = calloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length,
sizeof(f1ap_drb_to_be_setup_t));
AssertFatal(f1ap_ue_context_setup_req->drbs_to_be_setup,
"could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n");
teids=malloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length*sizeof(*teids));
for (i = 0; i < f1ap_ue_context_setup_req->drbs_to_be_setup_length; ++i) {
f1ap_drb_to_be_setup_t *drb_p = &f1ap_ue_context_setup_req->drbs_to_be_setup[i];
F1AP_DRBs_ToBeSetup_Item_t *drbs_tobesetup_item_p;
drbs_tobesetup_item_p = &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item;
drbs_tobesetup_item_p = &((F1AP_DRBs_ToBeSetup_ItemIEs_t *)ieDrb->value.choice.DRBs_ToBeSetup_List.list.array[i])->value.choice.DRBs_ToBeSetup_Item;
drb_p->drb_id = drbs_tobesetup_item_p->dRBID;
/* TODO in the following, assume only one UP UL TNL is present.
* this matches/assumes OAI CU implementation, can be up to 2! */
......@@ -151,9 +168,9 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
memcpy(addr.buffer, &drb_p->up_ul_tnl[0].tl_address, sizeof(drb_p->up_ul_tnl[0].tl_address));
addr.length=sizeof(drb_p->up_ul_tnl[0].tl_address)*8;
rnti_t ue_rnti = (f1ap_ue_context_setup_req->gNB_DU_ue_id!=NULL) ?
f1ap_get_rnti_by_du_id(false, instance, *f1ap_ue_context_setup_req->gNB_DU_ue_id):
f1ap_get_rnti_by_cu_id(false, instance, f1ap_ue_context_setup_req->gNB_CU_ue_id);
teid_t t=newGtpuCreateTunnel(INSTANCE_DEFAULT,
f1ap_get_rnti_by_du_id(false, instance, *f1ap_ue_context_setup_req->gNB_DU_ue_id):
f1ap_get_rnti_by_cu_id(false, instance, f1ap_ue_context_setup_req->gNB_CU_ue_id);
teid_t x=newGtpuCreateTunnel(INSTANCE_DEFAULT,
ue_rnti,
drb_p->drb_id ,
drb_p->drb_id,
......@@ -161,11 +178,13 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
addr,
2152,
DURecvCb);
teids[i]=x;
}
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieSrb;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieSrb, container,
F1AP_ProtocolIE_ID_id_SRBs_ToBeSetup_List, true);
f1ap_ue_context_setup_req->srbs_to_be_setup_length = ie->value.choice.SRBs_ToBeSetup_List.list.count;
f1ap_ue_context_setup_req->srbs_to_be_setup_length = ieSrb->value.choice.SRBs_ToBeSetup_List.list.count;
f1ap_ue_context_setup_req->srbs_to_be_setup = calloc(f1ap_ue_context_setup_req->srbs_to_be_setup_length,
sizeof(f1ap_srb_to_be_setup_t));
AssertFatal(f1ap_ue_context_setup_req->srbs_to_be_setup,
......@@ -174,68 +193,56 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance,
for (i = 0; i < f1ap_ue_context_setup_req->srbs_to_be_setup_length; ++i) {
f1ap_srb_to_be_setup_t *srb_p = &f1ap_ue_context_setup_req->srbs_to_be_setup[i];
F1AP_SRBs_ToBeSetup_Item_t *srbs_tobesetup_item_p;
srbs_tobesetup_item_p = &((F1AP_SRBs_ToBeSetup_ItemIEs_t *)ie->value.choice.SRBs_ToBeSetup_List.list.array[i])->value.choice.SRBs_ToBeSetup_Item;
srbs_tobesetup_item_p = &((F1AP_SRBs_ToBeSetup_ItemIEs_t *)ieSrb->value.choice.SRBs_ToBeSetup_List.list.array[i])->value.choice.SRBs_ToBeSetup_Item;
srb_p->srb_id = srbs_tobesetup_item_p->sRBID;
}
}
/* RRCContainer */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container,
F1AP_UEContextSetupRequestIEs_t *ieRRC;
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ieRRC, container,
F1AP_ProtocolIE_ID_id_RRCContainer, false);
if(f1ap_ue_context_setup_req->gNB_DU_ue_id!=NULL){
f1ap_ue_context_setup_req->rnti = f1ap_get_rnti_by_du_id(false, instance, *f1ap_ue_context_setup_req->gNB_DU_ue_id);
}
else{
f1ap_ue_context_setup_req->rnti = f1ap_get_rnti_by_cu_id(false, instance, f1ap_ue_context_setup_req->gNB_CU_ue_id);
}
if(f1ap_ue_context_setup_req->rnti<0){
LOG_E(F1AP, "Could not retrieve UE rnti based on the CU/DU UE id \n");
}
else{
LOG_I(F1AP, "Retrieved rnti is: %d \n", f1ap_ue_context_setup_req->rnti);
}
if (ie) {
if (ieRRC) {
/* correct here */
f1ap_ue_context_setup_req->rrc_container = malloc(ie->value.choice.RRCContainer.size);
memcpy(f1ap_ue_context_setup_req->rrc_container, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size);
if ( ieRRC->value.choice.RRCContainer.size ) {
f1ap_ue_context_setup_req->rrc_container = malloc(ieRRC->value.choice.RRCContainer.size);
memcpy(f1ap_ue_context_setup_req->rrc_container,
ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size);
// AssertFatal(0, "check configuration, send to appropriate handler\n");
protocol_ctxt_t ctxt;
// AssertFatal(0, "check configuration, send to appropriate handler\n");
protocol_ctxt_t ctxt;
// decode RRC Container and act on the message type
//FIXME
//rnti_t rnti = f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id);
ctxt.module_id = instance;
ctxt.instance = instance;
ctxt.enb_flag = 1;
if ( ie->value.choice.RRCContainer.size ) {
mem_block_t *pdcp_pdu_p = NULL;
pdcp_pdu_p = get_free_mem_block(ie->value.choice.RRCContainer.size, __func__);
memset(pdcp_pdu_p->data, 0, ie->value.choice.RRCContainer.size);
memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size);
//FIXME
//rnti_t rnti = f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id);
ctxt.module_id = instance;
ctxt.instance = instance;
ctxt.enb_flag = 1;
mem_block_t *pdcp_pdu_p = get_free_mem_block(ieRRC->value.choice.RRCContainer.size, __func__);
memcpy(&pdcp_pdu_p->data[0], ieRRC->value.choice.RRCContainer.buf, ieRRC->value.choice.RRCContainer.size);
/* for rfsim */
du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ie->value.choice.RRCContainer.size, pdcp_pdu_p);
DU_send_UE_CONTEXT_SETUP_RESPONSE(instance, ctxt.rnti);
du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ieRRC->value.choice.RRCContainer.size, pdcp_pdu_p);
} else {
LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n");
LOG_E(F1AP, " RRCContainer in UEContextSetupRequestIEs size id 0\n");
}
} else {
LOG_E(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer);
LOG_W(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer);
}
DU_send_UE_CONTEXT_SETUP_RESPONSE(instance, f1ap_ue_context_setup_req->rnti,
f1ap_ue_context_setup_req->drbs_to_be_setup_length, teids);
if (teids)
free(teids);
itti_send_msg_to_task(TASK_RRC_GNB, instance, msg_p);
return 0;
}
//void DU_send_UE_CONTEXT_SETUP_RESPONSE(F1AP_UEContextSetupResponse_t *UEContextSetupResponse) {
int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, rnti_t rntiP) {
int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, rnti_t rntiP, int nbTEID, teid_t * teids) {
F1AP_F1AP_PDU_t pdu= {0};
F1AP_UEContextSetupResponse_t *out;
uint8_t *buffer=NULL;
......@@ -330,7 +337,7 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, rnti_t rntiP) {
ie7->criticality = F1AP_Criticality_ignore;
ie7->value.present = F1AP_UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
for (int i=0; i<1; i++) {
for (int i=0; i<nbTEID; i++) {
//
asn1cSequenceAdd(ie7->value.choice.DRBs_Setup_List.list,
F1AP_DRBs_Setup_ItemIEs_t, drbs_setup_item_ies);
......@@ -357,10 +364,13 @@ int DU_send_UE_CONTEXT_SETUP_RESPONSE(instance_t instance, rnti_t rntiP) {
asn1cCalloc(dLUPTNLInformation_ToBeSetup_Item->dLUPTNLInformation.choice.gTPTunnel,
F1AP_GTPTunnel_t, gTPTunnel);
/* transportLayerAddress */
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &gTPTunnel->transportLayerAddress);
struct sockaddr_in addr={0};
inet_pton(AF_INET, getCxt(false,instance)->setupReq.DU_f1_ip_address.ipv4_address,
&addr.sin_addr.s_addr);
TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(addr.sin_addr.s_addr,
&gTPTunnel->transportLayerAddress);
/* gTP_TEID */
OCTET_STRING_fromBuf(&gTPTunnel->gTP_TEID, "1204",
strlen("1204"));
INT32_TO_OCTET_STRING(teids[i], &gTPTunnel->gTP_TEID);
} // for j
} // for i
......
......@@ -1663,7 +1663,9 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) {
//strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv6_address, "");
strcpy(F1AP_SETUP_REQ (msg_p).CU_f1_ip_address.ipv4_address, RC.nrmac[k]->eth_params_n.remote_addr);
LOG_I(GNB_APP,"F1AP: DU_ip4_address in DU %s\n",RC.nrmac[k]->eth_params_n.my_addr);
LOG_I(GNB_APP,"FIAP: DU_ip4_address in DU %p, strlen %d\n",F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,(int)strlen(RC.nrmac[k]->eth_params_n.my_addr));
LOG_I(GNB_APP,"FIAP: DU_ip4_address in DU %p, strlen %ld\n",
F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4_address,
strlen(RC.nrmac[k]->eth_params_n.my_addr));
F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6 = 0;
F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv4 = 1;
//strcpy(F1AP_SETUP_REQ (msg_p).DU_f1_ip_address.ipv6_address, "");
......
......@@ -86,7 +86,7 @@ class gtpEndPoints {
gtpEndPoints globGtp;
// note TEid 0 is reserved for specific usage: echo req/resp, error and supported extensions
static uint32_t gtpv1uNewTeid(void) {
static teid_t gtpv1uNewTeid(void) {
#ifdef GTPV1U_LINEAR_TEID_ALLOCATION
g_gtpv1u_teid = g_gtpv1u_teid + 1;
return g_gtpv1u_teid;
......@@ -400,7 +400,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer
inst->ue2te_mapping.erase(it);
}
uint32_t incoming_teid=gtpv1uNewTeid();
teid_t incoming_teid=gtpv1uNewTeid();
while ( inst->te2ue_mapping.find(incoming_teid) != inst->te2ue_mapping.end() ) {
LOG_W(GTPU, "generated a random Teid that exists, re-generating (%x)\n",incoming_teid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment