From d5cf363bfebc933f8f0dfcc02c51b9a3867fbe47 Mon Sep 17 00:00:00 2001 From: Rakesh BB Date: Tue, 6 Jan 2026 12:51:39 +0530 Subject: [PATCH] NR NGAP: Fix Time UE Stayed in Cell IE type and calculation According to 3GPP TS 38.413, the 'Time UE Stayed in Cell' IE is an integer ranging from 0 to 4095. This patch updates the data structure to reflect the correct bit width and implements the dynamic calculation based on the UE's residence time. - Change time_in_cell from long to uint16_t in ngap_messages_types.h. - Replace dummy value with real-time calculation in rrc_gNB_NGAP.c. - Implement a ceiling of 4095 to comply with the 12-bit protocol limit. Ref: 3GPP TS 38.413 Section 9.3.1.97 --- openair2/COMMON/ngap_messages_types.h | 2 +- openair2/RRC/NR/rrc_gNB_NGAP.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openair2/COMMON/ngap_messages_types.h b/openair2/COMMON/ngap_messages_types.h index ed93cdaadf..76abc3783d 100644 --- a/openair2/COMMON/ngap_messages_types.h +++ b/openair2/COMMON/ngap_messages_types.h @@ -474,7 +474,7 @@ typedef struct { // Cell type uint8_t type; // Time UE Stayed in Cell - long time_in_cell; + uint16_t time_in_cell; // Cause ngap_cause_t *cause; } last_visited_ngran_cell_info_t; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 5c212438e1..65991f714d 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -1649,7 +1649,7 @@ void rrc_gNB_send_NGAP_HANDOVER_REQUIRED(gNB_RRC_INST *rrc, msg.source2target->ue_history_info.cause->type = NGAP_CAUSE_RADIO_NETWORK; msg.source2target->ue_history_info.cause->value = NGAP_CAUSE_RADIO_NETWORK_HANDOVER_DESIRABLE_FOR_RADIO_REASON; msg.source2target->ue_history_info.type = NGAP_CellSize_small; - msg.source2target->ue_history_info.time_in_cell = 500; // dummy number for now + msg.source2target->ue_history_info.time_in_cell = min(time(NULL) - UE->last_seen, 4095); msg.source2target->ue_history_info.id = target_cell; /* Fill both PDU Session Resource List IE (M) in Handover Required