Commit 06f8d8a5 authored by Guido Casati's avatar Guido Casati Committed by Guido Casati

Minor fixes for maintainability and readability

RRC:
* simplified function parameter
* replaced hardcoded sizes with defines

Other:
* clang-formatted
* comments
parent 5aba7ac9
......@@ -211,6 +211,10 @@ typedef struct gtpv1u_gnb_create_tunnel_resp_s {
pdusessionid_t pdusession_id;
transport_layer_addr_t gnb_addr;
} gtpv1u_gnb_create_tunnel_resp_t;
/**
* @brief GTP-U Delete Tunnel Request
*/
typedef struct gtpv1u_gnb_delete_tunnel_req_s {
ue_id_t ue_id;
uint8_t num_pdusession;
......
......@@ -170,6 +170,12 @@ static instance_t get_f1_gtp_instance(void)
return inst->gtpInst;
}
/**
* @brief Process the E1 Bearer Context Setup Request
* - Fill the E1 Bearer Context Setup Response
* - Add PDCP entities
* - Create GTP-U tunnels
*/
void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req)
{
bool need_ue_id_mgmt = e1_used();
......@@ -184,7 +190,7 @@ void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req)
instance_t n3inst = get_n3_gtp_instance();
instance_t f1inst = get_f1_gtp_instance();
/* Init E1 Bearer Context Setup Response */
e1ap_bearer_setup_resp_t resp = {
.gNB_cu_cp_ue_id = req->gNB_cu_cp_ue_id,
.gNB_cu_up_ue_id = cu_up_ue_id,
......@@ -203,7 +209,6 @@ void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req)
pdu_session_setup_t *resp_pdu = resp.pduSession + i;
const pdu_session_to_setup_t *req_pdu = req->pduSession + i;
resp_pdu->id = req_pdu->sessionId;
AssertFatal(req_pdu->numDRB2Modify == 0, "DRB modification not implemented\n");
resp_pdu->numDRBSetup = req_pdu->numDRB2Setup;
fill_gtpu_n3_req(&req_n3, req_pdu, i);
......@@ -241,7 +246,6 @@ void e1_bearer_context_setup(const e1ap_bearer_setup_req_t *req)
resp_drb->UpParamList[d].tlAddress);
}
}
// We assume all DRBs to setup have been setup successfully, so we always
// send successful outcome in response and no failed DRBs
resp_pdu->numDRBFailed = 0;
......
......@@ -482,32 +482,32 @@ rb_found:
if (NODE_IS_DU(type)) {
if(is_srb) {
MessageDef *msg;
msg = itti_alloc_new_message(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE);
uint8_t *message_buffer = itti_malloc (TASK_RLC_ENB, TASK_DU_F1, size);
memcpy (message_buffer, buf, size);
MessageDef *msg;
msg = itti_alloc_new_message(TASK_RLC_ENB, 0, F1AP_UL_RRC_MESSAGE);
uint8_t *message_buffer = itti_malloc(TASK_RLC_ENB, TASK_DU_F1, size);
memcpy(message_buffer, buf, size);
F1AP_UL_RRC_MESSAGE(msg).gNB_CU_ue_id = ctx.rntiMaybeUEid;
F1AP_UL_RRC_MESSAGE(msg).gNB_DU_ue_id = ue->ue_id;
F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id;
F1AP_UL_RRC_MESSAGE(msg).rrc_container = message_buffer;
F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size;
itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg);
return;
F1AP_UL_RRC_MESSAGE(msg).gNB_DU_ue_id = ue->ue_id;
F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_id;
F1AP_UL_RRC_MESSAGE(msg).rrc_container = message_buffer;
F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = size;
itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(0 /*ctxt_pP->module_id*/), msg);
return;
} else {
MessageDef *msg = itti_alloc_new_message_sized(TASK_RLC_ENB, 0, GTPV1U_TUNNEL_DATA_REQ,
sizeof(gtpv1u_tunnel_data_req_t) + size);
gtpv1u_tunnel_data_req_t *req=&GTPV1U_TUNNEL_DATA_REQ(msg);
req->buffer=(uint8_t*)(req+1);
memcpy(req->buffer,buf,size);
req->length=size;
req->offset = 0;
req->ue_id = ue->ue_id;
req->bearer_id=rb_id;
req->qfi = -1;
LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
extern instance_t DUuniqInstance;
itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg);
return;
MessageDef *msg =
itti_alloc_new_message_sized(TASK_RLC_ENB, 0, GTPV1U_TUNNEL_DATA_REQ, sizeof(gtpv1u_tunnel_data_req_t) + size);
gtpv1u_tunnel_data_req_t *req = &GTPV1U_TUNNEL_DATA_REQ(msg);
req->buffer = (uint8_t *)(req + 1);
memcpy(req->buffer, buf, size);
req->length = size;
req->offset = 0;
req->ue_id = ue->ue_id;
req->bearer_id = rb_id;
req->qfi = -1;
LOG_D(RLC, "Received uplink user-plane traffic at RLC-DU to be sent to the CU, size %d \n", size);
extern instance_t DUuniqInstance;
itti_send_msg_to_task(TASK_GTPV1_U, DUuniqInstance, msg);
return;
}
}
}
......
......@@ -1976,7 +1976,7 @@ void rrc_gNB_process_e1_bearer_context_setup_resp(e1ap_bearer_setup_resp_t *resp
}
/* Instruction towards the DU for DRB configuration and tunnel creation */
f1ap_drb_to_be_setup_t drbs[32]; // maximum DRB can be 32
f1ap_drb_to_be_setup_t drbs[MAX_DRBS_PER_UE];
int nb_drb = 0;
for (int p = 0; p < resp->numPDUSessions; ++p) {
rrc_pdu_session_param_t *RRC_pduSession = find_pduSession(UE, resp->pduSession[p].id, false);
......
......@@ -365,8 +365,8 @@ static int decodePDUSessionResourceSetup(pdusession_t *session)
void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdusession_t *sessions, uint64_t ueAggMaxBitRateDownlink)
{
e1ap_bearer_setup_req_t bearer_req = {0};
e1ap_nssai_t cuup_nssai = {0};
/* Loop over the PDU sessions to setup */
for (int i = 0; i < n; i++) {
rrc_pdu_session_param_t *pduSession = find_pduSession(UE, sessions[i].pdusession_id, true);
pdusession_t *session = &pduSession->param;
......@@ -422,7 +422,6 @@ void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdusession
fiveQI);
/* DRB to be setup */
DRB_nGRAN_to_setup_t *drb = pdu->DRBnGRanList + j;
drb->id = rrc_drb->drb_id;
/* SDAP */
struct sdap_config_s *sdap_config = &rrc_drb->cnAssociation.sdap_config;
......@@ -431,9 +430,8 @@ void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdusession
drb->sdap_config.sDAP_Header_DL = sdap_config->sdap_HeaderDL;
/* PDCP */
set_bearer_context_pdcp_config(&drb->pdcp_config, rrc_drb, rrc->configuration.um_on_default_drb);
/* Cell groups */
drb->numCellGroups = 1; // assume one cell group associated with a DRB
for (int k=0; k < drb->numCellGroups; k++) {
cell_group_t *cellGroup = drb->cellGroupList + k;
cellGroup->id = 0; // MCG
......@@ -453,7 +451,7 @@ void trigger_bearer_setup(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, int n, pdusession
qos_char->non_dynamic.fiveqi = qos_session->fiveQI;
qos_char->non_dynamic.qos_priority_level = qos_session->qos_priority;
}
/* Retention priority */
ngran_allocation_retention_priority_t *rent_priority = &qos_flow->qos_params.alloc_reten_priority;
ngap_allocation_retention_priority_t *rent_priority_in = &qos_session->allocation_retention_priority;
rent_priority->priority_level = rent_priority_in->priority_level;
......
......@@ -82,7 +82,7 @@ void set_bearer_context_pdcp_config(bearer_context_pdcp_config_t *pdcp_config, d
drb_t *generateDRB(gNB_RRC_UE_t *ue,
uint8_t drb_id,
const rrc_pdu_session_param_t *pduSession,
const int pdusession_id,
bool enable_sdap,
int do_drb_integrity,
int do_drb_ciphering,
......@@ -104,7 +104,7 @@ drb_t *generateDRB(gNB_RRC_UE_t *ue,
/* SDAP Configuration */
est_drb->cnAssociation.present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config;
est_drb->cnAssociation.sdap_config.pdusession_id = pduSession->param.pdusession_id;
est_drb->cnAssociation.sdap_config.pdusession_id = pdusession_id;
if (enable_sdap) {
est_drb->cnAssociation.sdap_config.sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_present;
est_drb->cnAssociation.sdap_config.sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_present;
......
......@@ -53,7 +53,7 @@ drb_t *get_drb(gNB_RRC_UE_t *ue, uint8_t drb_id);
/// @return returns a pointer to the generated DRB structure
drb_t *generateDRB(gNB_RRC_UE_t *ue,
uint8_t drb_id,
const rrc_pdu_session_param_t *pduSession,
const int pdusession_id,
bool enable_sdap,
int do_drb_integrity,
int do_drb_ciphering,
......
This diff is collapsed.
......@@ -34,6 +34,18 @@ static uint16_t getShort(uint8_t *input)
return htons(tmp16);
}
/**
* Handles the PDU Session Establishment Accept message received by the UE
* The PDU Session Establishment Accept message is sent by the SMF
* to the UE in response to the PDU Session Establishment Request message.
* It indicates the successful establishment of a PDU session.
* The direction is from the network to the UE.
*
* @param buffer pointer to PDU Session Establishment Accept message
* @param msg_length length of PDU Session Establishment Accept message
*
* @ref 3GPP TS 24.501 (Release 16)
*/
void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length)
{
security_protected_nas_5gs_msg_t sec_nas_hdr;
......
......@@ -1129,16 +1129,16 @@ void *nas_nrue(void *args_p)
}
case NAS_CONN_ESTABLI_CNF: {
uint8_t *pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data;
int msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
LOG_I(NAS,
"[UE %ld] Received %s: errCode %u, length %u\n",
"[UE %ld] Received %s: %s (errCode %u, length %u)\n",
instance,
ITTI_MSG_NAME(msg_p),
msg_type == REGISTRATION_ACCEPT ? "REGISTRATION_ACCEPT" : "FGS_PDU_SESSION_ESTABLISHMENT_ACC",
NAS_CONN_ESTABLI_CNF(msg_p).errCode,
NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
uint8_t *pdu_buffer = NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data;
int msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
if (msg_type == REGISTRATION_ACCEPT) {
nr_ue_nas_t *nas = get_ue_nas_info(0);
handle_registration_accept(instance, nas, pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
......
......@@ -341,7 +341,6 @@ static void gtpv1uSend(instance_t instance, gtpv1u_tunnel_data_req_t *req, bool
ext.pdusession_cntr.Reflective_QoS_activation = false;
ext.pdusession_cntr.Paging_Policy_Indicator = false;
ext.NextExtHeaderType = NO_MORE_EXT_HDRS;
gtpv1uCreateAndSendMsg(compatInst(instance),
tmp.outgoing_ip_addr,
tmp.outgoing_port,
......
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