remove gNB structure dependency from do_RRCReestablishment in asn1_msg.c

This commit is contained in:
francescomani
2025-04-24 18:40:49 +02:00
parent 368e74930c
commit bda64a05d9
4 changed files with 9 additions and 30 deletions
+2 -18
View File
@@ -1025,12 +1025,7 @@ int do_RRCReestablishmentRequest(uint8_t *buffer,
}
//------------------------------------------------------------------------------
int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *const buffer,
size_t buffer_size,
const uint8_t Transaction_id,
uint16_t pci,
NR_ARFCN_ValueNR_t absoluteFrequencySSB)
int do_RRCReestablishment(int8_t nh_ncc, uint8_t *const buffer, size_t buffer_size, const uint8_t Transaction_id)
{
asn_enc_rval_t enc_rval;
NR_DL_DCCH_Message_t dl_dcch_msg = {0};
@@ -1047,19 +1042,8 @@ int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP,
rrcReestablishment->criticalExtensions.present = NR_RRCReestablishment__criticalExtensions_PR_rrcReestablishment;
rrcReestablishment->criticalExtensions.choice.rrcReestablishment = CALLOC(1, sizeof(NR_RRCReestablishment_IEs_t));
LOG_I(NR_RRC, "Reestablishment update key pci=%d, earfcn_dl=%lu\n", pci, absoluteFrequencySSB);
// 3GPP TS 33.501 Section 6.11 Security handling for RRC connection re-establishment procedure
if (ue_context_pP->ue_context.nh_ncc >= 0) {
nr_derive_key_ng_ran_star(pci, absoluteFrequencySSB, ue_context_pP->ue_context.nh, ue_context_pP->ue_context.kgnb);
rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount = ue_context_pP->ue_context.nh_ncc;
} else { // first HO
nr_derive_key_ng_ran_star(pci, absoluteFrequencySSB, ue_context_pP->ue_context.kgnb, ue_context_pP->ue_context.kgnb);
// LG: really 1
rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount = 0;
}
ue_context_pP->ue_context.kgnb_ncc = 0;
rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nextHopChainingCount = nh_ncc >= 0 ? nh_ncc : 0;
rrcReestablishment->criticalExtensions.choice.rrcReestablishment->lateNonCriticalExtension = NULL;
rrcReestablishment->criticalExtensions.choice.rrcReestablishment->nonCriticalExtension = NULL;
+1 -6
View File
@@ -147,12 +147,7 @@ int do_RRCReestablishmentRequest(uint8_t *buffer,
uint32_t cell_id,
uint16_t c_rnti);
int do_RRCReestablishment(rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *const buffer,
size_t buffer_size,
const uint8_t Transaction_id,
uint16_t pci,
NR_ARFCN_ValueNR_t absoluteFrequencySSB);
int do_RRCReestablishment(int8_t nh_ncc, uint8_t *const buffer, size_t buffer_size, const uint8_t Transaction_id);
int do_RRCReestablishmentComplete(uint8_t *buffer, size_t buffer_size, int64_t rrc_TransactionIdentifier);
@@ -66,12 +66,9 @@ TEST(nr_asn1, rrc_reestablishment_request)
TEST(nr_asn1, rrc_reestablishment)
{
rrc_gNB_ue_context_t ue_context_pP;
memset(&ue_context_pP, 0, sizeof(ue_context_pP));
unsigned char buf[1000];
const uint32_t physical_cell_id = 177;
NR_ARFCN_ValueNR_t absoluteFrequencySSB = 2700000;
EXPECT_GT(do_RRCReestablishment(&ue_context_pP, buf, 1000, 0, physical_cell_id, absoluteFrequencySSB), 0);
const uint8_t nh_ncc = 0;
EXPECT_GT(do_RRCReestablishment(nh_ncc, buf, 1000, 0), 0);
}
TEST(nr_asn1, paging)
+4 -1
View File
@@ -843,7 +843,10 @@ static void rrc_gNB_generate_RRCReestablishment(rrc_gNB_ue_context_t *ue_context
ue_p->xids[xid] = RRC_REESTABLISH;
const f1ap_served_cell_info_t *cell_info = &du->setup_req->cell[0].info;
uint32_t ssb_arfcn = get_ssb_arfcn(du);
int size = do_RRCReestablishment(ue_context_pP, buffer, NR_RRC_BUF_SIZE, xid, cell_info->nr_pci, ssb_arfcn);
LOG_I(NR_RRC, "Reestablishment update key pci=%d, earfcn_dl=%u\n", cell_info->nr_pci, ssb_arfcn);
nr_derive_key_ng_ran_star(cell_info->nr_pci, ssb_arfcn, ue_p->nh_ncc >= 0 ? ue_p->nh : ue_p->kgnb, ue_p->kgnb);
ue_p->kgnb_ncc = 0;
int size = do_RRCReestablishment(ue_context_pP->ue_context.nh_ncc, buffer, NR_RRC_BUF_SIZE, xid);
LOG_A(NR_RRC, "Send RRCReestablishment [%d bytes] to RNTI %04x\n", size, ue_p->rnti);