From 46bbb6a9435935e2b6deb94aecd4487d99752acb Mon Sep 17 00:00:00 2001 From: Qiu DeZhi Date: Thu, 15 Oct 2020 10:34:19 +0000 Subject: [PATCH 01/16] Modify RRCSetupComplete --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 70029ed54c..eccb74b05a 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1188,6 +1188,14 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Trans NR_UL_DCCH_Message_t ul_dcch_msg; NR_RRCSetupComplete_t *RrcSetupComplete; memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); + + uint8_t buf[6]; + uint8_t rv[6]; + int i; + for (i=0; i<6; i++) { + rv[i]=taus()&0xff; + } + ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1 = CALLOC(1,sizeof(struct NR_DL_DCCH_MessageType__c1)); ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_rrcSetupComplete; @@ -1198,6 +1206,16 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Trans sizeof(*RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension)); RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->selectedPLMN_Identity = sel_plmn_id; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->registeredAMF = NULL; + + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size = 6; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf = buf; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[0] = rv[0]; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[1] = rv[1]; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[2] = rv[2]; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[3] = rv[3]; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[4] = rv[4]; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[5] = rv[5]; + memset(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,0,sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,dedicatedInfoNAS,dedicatedInfoNASLength); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { From 43ef53cbcf359dd77ed6b655c3c289029fce83e6 Mon Sep 17 00:00:00 2001 From: Xue Song Date: Fri, 16 Oct 2020 01:46:15 +0000 Subject: [PATCH 02/16] Add pucchresset->maxPayloadMinus1 to be compatible with Rel15 --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index d9cf1ac13d..00f86b8e5e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -624,7 +624,11 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, AssertFatal(1==0,"Couldn't fine pucch resource indicator %d in PUCCH resource set %d for %d UCI bits",pucch_resource,i,O_uci); } else { +#if (NR_RRC_VERSION >= MAKE_VERSION(16, 0, 0)) N3 = pucchresset->maxPayloadSize!= NULL ? *pucchresset->maxPayloadSize : 1706; +#else + N3 = pucchresset->maxPayloadMinus1!= NULL ? *pucchresset->maxPayloadMinus1 : 1706; +#endif if (N2O_uci) { if (pucch_resource < n_list) resource_id = pucchresset->resourceList.list.array[pucch_resource]; From 5697057f0bff91b29bf1dda6e2f766fff479a3f9 Mon Sep 17 00:00:00 2001 From: Xue Song Date: Fri, 16 Oct 2020 05:06:19 +0000 Subject: [PATCH 03/16] Unblock ITTI SIM process --- openair2/COMMON/itti_sim_messages_types.h | 2 +- openair2/RRC/NR/MESSAGES/asn1_msg.c | 50 ++--- openair2/RRC/NR/rrc_gNB.c | 82 ++++---- openair2/RRC/NR_UE/rrc_UE.c | 231 ++++++++++++---------- openair2/RRC/NR_UE/rrc_proto.h | 6 + openair2/SIMULATION/NR_RRC/itti_sim.c | 48 +++-- 6 files changed, 240 insertions(+), 179 deletions(-) diff --git a/openair2/COMMON/itti_sim_messages_types.h b/openair2/COMMON/itti_sim_messages_types.h index 4b06cc9dc8..247c474542 100644 --- a/openair2/COMMON/itti_sim_messages_types.h +++ b/openair2/COMMON/itti_sim_messages_types.h @@ -24,7 +24,7 @@ typedef struct itti_sim_rrc_ch_s { - const rb_id_t rbid; + rb_id_t rbid; uint8_t *sdu; int size; } itti_sim_rrc_ch_t; diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index eccb74b05a..6cf1b01752 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -631,12 +631,12 @@ uint8_t do_RRCReject(uint8_t Mod_id, 100); if(enc_rval.encoded == -1) { - LOG_E(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + LOG_E(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } - LOG_D(RRC,"RRCReject Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"RRCReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } @@ -762,13 +762,13 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP, 100); if(enc_rval.encoded == -1) { - LOG_E(RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", + LOG_E(NR_RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } if (OCTET_STRING_fromBuf(&ie->masterCellGroup, masterCellGroup_buf, (enc_rval.encoded+7)/8) == -1) { - LOG_E(RRC, "fatal: OCTET_STRING_fromBuf failed\n"); + LOG_E(NR_RRC, "fatal: OCTET_STRING_fromBuf failed\n"); return -1; } @@ -783,12 +783,12 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP, 100); if(enc_rval.encoded == -1) { - LOG_E(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + LOG_E(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } - LOG_D(RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } @@ -890,19 +890,19 @@ uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, 100); if(enc_rval.encoded == -1) { - LOG_I(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + LOG_I(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } - LOG_D(RRC,"[gNB %d] NR UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"[gNB %d] NR UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rnti, enc_rval.encoded, (enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { - LOG_E(RRC,"[eNB %d] ASN1 : NR UECapabilityRequest encoding failed for UE %x\n", + LOG_E(NR_RRC,"[gNB %d] ASN1 : NR UECapabilityRequest encoding failed for UE %x\n", ctxt_pP->module_id, ctxt_pP->rnti); return(-1); @@ -1106,14 +1106,16 @@ uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { ul_ccch_msg.message.present = NR_UL_CCCH_MessageType_PR_c1; ul_ccch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_UL_CCCH_MessageType__c1)); ul_ccch_msg.message.choice.c1->present = NR_UL_CCCH_MessageType__c1_PR_rrcSetupRequest; + ul_ccch_msg.message.choice.c1->choice.rrcSetupRequest = CALLOC(1, sizeof(NR_RRCSetupRequest_t)); rrcSetupRequest = ul_ccch_msg.message.choice.c1->choice.rrcSetupRequest; if (1) { rrcSetupRequest->rrcSetupRequest.ue_Identity.present = NR_InitialUE_Identity_PR_randomValue; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.size = 5; - rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.bits_unused = 0; + rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.bits_unused = 1; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf = buf; + rv[0] = rv[0] & 0x7F; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[0] = rv[0]; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[1] = rv[1]; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[2] = rv[2]; @@ -1132,9 +1134,9 @@ uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { rrcSetupRequest->rrcSetupRequest.spare.size=1; rrcSetupRequest->rrcSetupRequest.spare.bits_unused = 7; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_CCCH_Message, (void *)&ul_ccch_msg); - } + // } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_CCCH_Message, NULL, @@ -1142,7 +1144,7 @@ uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - LOG_D(RRC,"[UE] RRCSetupRequest Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); + LOG_D(NR_RRC,"[UE] RRCSetupRequest Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } //------------------------------------------------------------------------------ @@ -1178,7 +1180,7 @@ do_NR_RRCReconfigurationComplete( 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - LOG_D(RRC,"rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_D(NR_RRC,"rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } @@ -1197,16 +1199,20 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Trans } ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1; - ul_dcch_msg.message.choice.c1 = CALLOC(1,sizeof(struct NR_DL_DCCH_MessageType__c1)); + ul_dcch_msg.message.choice.c1 = CALLOC(1,sizeof(struct NR_UL_DCCH_MessageType__c1)); ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_rrcSetupComplete; + ul_dcch_msg.message.choice.c1->choice.rrcSetupComplete = CALLOC(1, sizeof(NR_RRCSetupComplete_t)); RrcSetupComplete = ul_dcch_msg.message.choice.c1->choice.rrcSetupComplete; RrcSetupComplete->rrc_TransactionIdentifier = Transaction_id; RrcSetupComplete->criticalExtensions.present = NR_RRCSetupComplete__criticalExtensions_PR_rrcSetupComplete; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension = CALLOC(1, - sizeof(*RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension)); + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete = CALLOC(1, sizeof(NR_RRCSetupComplete_IEs_t)); + // RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension = CALLOC(1, + // sizeof(*RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->nonCriticalExtension)); RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->selectedPLMN_Identity = sel_plmn_id; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->registeredAMF = NULL; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value = CALLOC(1, sizeof(struct NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value)); + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->present = NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size = 6; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf = buf; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[0] = rv[0]; @@ -1218,11 +1224,11 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Trans memset(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,0,sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,dedicatedInfoNAS,dedicatedInfoNASLength); -if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&ul_dcch_msg); -} +//if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); +//} -enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, +enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, (void *)&ul_dcch_msg, buffer, @@ -1230,7 +1236,7 @@ enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, AssertFatal(enc_rval.encoded > 0,"ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name,enc_rval.encoded); - LOG_D(RRC,"RRCConnectionSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_D(NR_RRC,"RRCSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index f472eb77f4..d61471ad42 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -422,7 +422,7 @@ rrc_gNB_generate_RRCSetup( // ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; #ifdef ITTI_SIM MessageDef *message_p; - message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, GNB_RRC_CCCH_DATA_IND); + message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_CCCH_DATA_IND); GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)ue_p->Srb0.Tx_buffer.Payload; GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); @@ -481,7 +481,11 @@ rrc_gNB_process_RRCSetupComplete( // T_INT(ctxt_pP->subframe), // T_INT(ctxt_pP->rnti)); - rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); + // if (AMF_MODE_ENABLED) { + // rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); + // } else { + rrc_gNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP); + // } } //----------------------------------------------------------------------------- @@ -890,6 +894,7 @@ rrc_gNB_decode_dcch( sdu_sizeP, 0, 0); + xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); { for (i = 0; i < sdu_sizeP; i++) { @@ -981,43 +986,50 @@ rrc_gNB_decode_dcch( if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.present == NR_RRCSetupComplete__criticalExtensions_PR_rrcSetupComplete) { if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI_Part2) { - // ng-5G-S-TMSI-Part2 BIT STRING (SIZE (9)) + rrcSetupComplete->ng_5G_S_TMSI_Value != NULL) { if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size != 2) { - LOG_E(NR_RRC, "wrong ng_5G_S_TMSI_Part2 size, expected 2, provided %lu", - (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete-> - ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size); - return -1; - } + rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI_Part2) { + // ng-5G-S-TMSI-Part2 BIT STRING (SIZE (9)) + if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. + rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size != 2) { + LOG_E(NR_RRC, "wrong ng_5G_S_TMSI_Part2 size, expected 2, provided %lu", + (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete-> + ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size); + return -1; + } - if (ue_context_p->ue_context.ng_5G_S_TMSI_Part1 != 0) { - ue_context_p->ue_context.ng_5G_S_TMSI_Part2 = - BIT_STRING_to_uint16(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete-> - ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2); - } + if (ue_context_p->ue_context.ng_5G_S_TMSI_Part1 != 0) { + ue_context_p->ue_context.ng_5G_S_TMSI_Part2 = + BIT_STRING_to_uint16(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete-> + ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2); + } - /* TODO */ - } else if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI) { - // NG-5G-S-TMSI ::= BIT STRING (SIZE (48)) - if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size != 6) { - LOG_E(NR_RRC, "wrong ng_5G_S_TMSI size, expected 6, provided %lu", - (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete-> - ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size); - return -1; - } + /* TODO */ + } else if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. + rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI) { + // NG-5G-S-TMSI ::= BIT STRING (SIZE (48)) + if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. + rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size != 6) { + LOG_E(NR_RRC, "wrong ng_5G_S_TMSI size, expected 6, provided %lu", + (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete-> + ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size); + return -1; + } - uint64_t fiveg_s_TMSI = BIT_STRING_to_uint16(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI); - if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_set_id = fiveg_s_TMSI >> 38; - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_pointer = (fiveg_s_TMSI >> 32) & 0x3F; - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.fiveg_tmsi = (uint32_t)fiveg_s_TMSI; + uint64_t fiveg_s_TMSI = BIT_STRING_to_uint64(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI); + LOG_I(NR_RRC, "Received rrcSetupComplete, 5g_s_TMSI: 0x%lX, amf_set_id: 0x%lX(%d), amf_pointer: 0x%lX(%d), 5g TMSI: 0x%lX \n", + fiveg_s_TMSI, fiveg_s_TMSI >> 38, fiveg_s_TMSI >> 38, + (fiveg_s_TMSI >> 32) & 0x3F, (fiveg_s_TMSI >> 32) & 0x3F, + (uint32_t)fiveg_s_TMSI); + if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_set_id = fiveg_s_TMSI >> 38; + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_pointer = (fiveg_s_TMSI >> 32) & 0x3F; + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.fiveg_tmsi = (uint32_t)fiveg_s_TMSI; + } } } diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index ddf9b4493c..e73455621e 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -350,7 +350,7 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){ memset(NR_UE_rrc_inst, 0, NB_NR_UE_INST * sizeof(NR_UE_RRC_INST_t)); // fill UE-NR-Capability @ UE-CapabilityRAT-Container here. - + NR_UE_rrc_inst[0].selected_plmn_identity = 1; // init RRC lists RRC_LIST_INIT(NR_UE_rrc_inst->RLC_Bearer_Config_list, NR_maxLC_ID); RRC_LIST_INIT(NR_UE_rrc_inst->SchedulingRequest_list, NR_maxNrofSR_ConfigPerCellGroup); @@ -470,42 +470,6 @@ int8_t nr_ue_process_spcell_config(NR_SpCellConfig_t *spcell_config){ return 0; } -//----------------------------------------------------------------------------- -void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) { - uint8_t i=0,rv[6]; - - if(NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size ==0) { - // Get RRCConnectionRequest, fill random for now - // Generate random byte stream for contention resolution - for (i=0; i<6; i++) { -#ifdef SMBV - // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed - rv[i]=i; -#else - rv[i]=taus()&0xff; -#endif - LOG_T(RRC,"%x.",rv[i]); - } - - LOG_T(RRC,"\n"); - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size = - do_RRCSetupRequest( - ctxt_pP->module_id, - (uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, - rv); - LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, gNB %d)\n", - ctxt_pP->module_id, ctxt_pP->frame, NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index); - - for (i=0; imodule_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) { - LOG_T(RRC,"%x.",NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]); - } - - LOG_T(RRC,"\n"); - /*UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff; - UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; */ - } -} - /*brief decode BCCH-BCH (MIB) message*/ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( const module_id_t module_id, @@ -1343,7 +1307,7 @@ static void rrc_ue_generate_RRCSetupComplete( } */ size = do_RRCSetupComplete(ctxt_pP->module_id,buffer,Transaction_id,sel_plmn_id,nas_msg_length,nas_msg); - LOG_I(RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionSetupComplete (bytes%d, gNB %d)\n", + LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCSetupComplete (bytes%d, gNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, size, gNB_index); LOG_D(RLC, "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to gNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", @@ -1357,6 +1321,17 @@ static void rrc_ue_generate_RRCSetupComplete( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +#ifdef ITTI_SIM + MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_UE_SIM, TASK_RRC_GNB_SIM, size); + memcpy (message_buffer, buffer, size); + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_DCCH_DATA_IND); + UE_RRC_DCCH_DATA_IND (message_p).rbid = 1; + UE_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; + UE_RRC_DCCH_DATA_IND (message_p).size = size; + itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); +#endif } int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *const Srb_info, const uint8_t gNB_index ){ @@ -1386,14 +1361,14 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_IN if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State == RRC_SI_RECEIVED) { switch (dl_ccch_msg->message.choice.c1->present) { case NR_DL_CCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", + LOG_I(NR_RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", ctxt_pP->module_id, ctxt_pP->frame); rval = 0; break; case NR_DL_CCCH_MessageType__c1_PR_rrcReject: - LOG_I(RRC, + LOG_I(NR_RRC, "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n", ctxt_pP->module_id, ctxt_pP->frame); @@ -1401,7 +1376,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_IN break; case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: - LOG_I(RRC, + LOG_I(NR_RRC, "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received NR_RRCSetup RNTI %x\n", ctxt_pP->module_id, ctxt_pP->frame, @@ -1430,7 +1405,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_IN break; default: - LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n", + LOG_E(NR_RRC, "[UE%d] Frame %d : Unknown message\n", ctxt_pP->module_id, ctxt_pP->frame); rval = -1; @@ -1534,51 +1509,51 @@ nr_rrc_ue_process_securityModeCommand( NR_UL_DCCH_Message_t ul_dcch_msg; uint8_t buffer[200]; int i, securityMode; - LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (gNB %d)\n", + LOG_I(NR_RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index); switch (securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm) { case NR_CipheringAlgorithm_nea0: - LOG_I(RRC,"[UE %d] Security algorithm is set to nea0\n", + LOG_I(NR_RRC,"[UE %d] Security algorithm is set to nea0\n", ctxt_pP->module_id); securityMode= NR_CipheringAlgorithm_nea0; break; case NR_CipheringAlgorithm_nea1: - LOG_I(RRC,"[UE %d] Security algorithm is set to nea1\n",ctxt_pP->module_id); + LOG_I(NR_RRC,"[UE %d] Security algorithm is set to nea1\n",ctxt_pP->module_id); securityMode= NR_CipheringAlgorithm_nea1; break; case NR_CipheringAlgorithm_nea2: - LOG_I(RRC,"[UE %d] Security algorithm is set to nea2\n", + LOG_I(NR_RRC,"[UE %d] Security algorithm is set to nea2\n", ctxt_pP->module_id); securityMode = NR_CipheringAlgorithm_nea2; break; default: - LOG_I(RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id); + LOG_I(NR_RRC,"[UE %d] Security algorithm is set to none\n",ctxt_pP->module_id); securityMode = NR_CipheringAlgorithm_spare1; break; } switch (*securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm) { case NR_IntegrityProtAlgorithm_nia1: - LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to nia1\n",ctxt_pP->module_id); + LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to nia1\n",ctxt_pP->module_id); securityMode |= 1 << 5; break; case NR_IntegrityProtAlgorithm_nia2: - LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to nia2\n",ctxt_pP->module_id); + LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to nia2\n",ctxt_pP->module_id); securityMode |= 1 << 6; break; default: - LOG_I(RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id); + LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id); securityMode |= 0x70 ; break; } - LOG_D(RRC,"[UE %d] security mode is %x \n",ctxt_pP->module_id, securityMode); + LOG_D(NR_RRC,"[UE %d] security mode is %x \n",ctxt_pP->module_id, securityMode); NR_UE_rrc_inst->cipheringAlgorithm = securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm; NR_UE_rrc_inst->integrityProtAlgorithm = @@ -1589,10 +1564,10 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); ul_dcch_msg.message.choice.c1 = calloc(1, sizeof(*ul_dcch_msg.message.choice.c1)); if (securityMode >= NO_SECURITY_MODE) { - LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode complete case \n"); + LOG_I(NR_RRC, "rrc_ue_process_securityModeCommand, security mode complete case \n"); ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeComplete; } else { - LOG_I(RRC, "rrc_ue_process_securityModeCommand, security mode failure case \n"); + LOG_I(NR_RRC, "rrc_ue_process_securityModeCommand, security mode failure case \n"); ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_securityModeFailure; } @@ -1607,8 +1582,8 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); h_rc = hashtable_get(pdcp_coll_p, key, (void **) &pdcp_p); if (h_rc == HASH_TABLE_OK) { - LOG_D(RRC, "PDCP_COLL_KEY_VALUE() returns valid key = %ld\n", key); - LOG_D(RRC, "driving kRRCenc, kRRCint and kUPenc from KgNB=" + LOG_D(NR_RRC, "PDCP_COLL_KEY_VALUE() returns valid key = %ld\n", key); + LOG_D(NR_RRC, "driving kRRCenc, kRRCint and kUPenc from KgNB=" "%02x%02x%02x%02x" "%02x%02x%02x%02x" "%02x%02x%02x%02x" @@ -1635,11 +1610,11 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); | (NR_UE_rrc_inst->integrityProtAlgorithm << 4), kRRCenc, kRRCint, kUPenc); } else { - LOG_I(RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", + LOG_I(NR_RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", securityMode); } } else { - LOG_I(RRC, "Could not get PDCP instance where key=0x%ld\n", key); + LOG_I(NR_RRC, "Could not get PDCP instance where key=0x%ld\n", key); } if (securityModeCommand->criticalExtensions.present == NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand) { @@ -1647,7 +1622,7 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); ul_dcch_msg.message.choice.c1->choice.securityModeComplete->rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.present = NR_SecurityModeComplete__criticalExtensions_PR_securityModeComplete; ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete->nonCriticalExtension =NULL; - LOG_I(RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (gNB %d), rrc_TransactionIdentifier: %ld\n", + LOG_I(NR_RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d), rrc_TransactionIdentifier: %ld\n", ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index, securityModeCommand->rrc_TransactionIdentifier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, @@ -1661,13 +1636,13 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); } - LOG_D(RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); + LOG_D(NR_RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) { - LOG_T(RRC, "%02x.", buffer[i]); + LOG_T(NR_RRC, "%02x.", buffer[i]); } - LOG_T(RRC, "\n"); + LOG_T(NR_RRC, "\n"); rrc_data_req ( ctxt_pP, DCCH, @@ -1676,10 +1651,54 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); (enc_rval.encoded + 7) / 8, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - } else LOG_W(RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", + } else LOG_W(NR_RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", securityModeCommand->criticalExtensions.present); } +//----------------------------------------------------------------------------- +void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ) { + uint8_t i=0,rv[6]; + + if(NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size ==0) { + // Get RRCConnectionRequest, fill random for now + // Generate random byte stream for contention resolution + for (i=0; i<6; i++) { +#ifdef SMBV + // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed + rv[i]=i; +#else + rv[i]=taus()&0xff; +#endif + LOG_T(NR_RRC,"%x.",rv[i]); + } + + LOG_T(NR_RRC,"\n"); + NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size = + do_RRCSetupRequest( + ctxt_pP->module_id, + (uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, + rv); + LOG_I(NR_RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCSetupRequest (bytes %d, eNB %d)\n", + ctxt_pP->module_id, ctxt_pP->frame, NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index); + + for (i=0; imodule_id].Srb0[gNB_index].Tx_buffer.payload_size; i++) { + LOG_T(NR_RRC,"%x.",NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload[i]); + } + + LOG_T(NR_RRC,"\n"); + /*UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff; + UE_rrc_inst[ue_mod_idP].Srb0[Idx].Tx_buffer.payload_size =i; */ + +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_CCCH_DATA_IND); + GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload; + GNB_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size; + itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); +#endif + } +} + //----------------------------------------------------------------------------- int32_t nr_rrc_ue_establish_srb1( @@ -1924,26 +1943,26 @@ nr_sa_rrc_ue_process_radioBearerConfig( derive_key_rrc_int(NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm, NR_UE_rrc_inst[ctxt_pP->module_id].kgnb, &kRRCint); // Refresh SRBs - nr_rrc_pdcp_config_asn1_req(ctxt_pP, - radioBearerConfig->srb_ToAddModList, - NULL, - NULL, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | - (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), - kRRCenc, - kRRCint, - NULL, - NULL, - NULL, - NULL); + // nr_rrc_pdcp_config_asn1_req(ctxt_pP, + // radioBearerConfig->srb_ToAddModList, + // NULL, + // NULL, + // NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | + // (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), + // kRRCenc, + // kRRCint, + // NULL, + // NULL, + // NULL, + // NULL); // Refresh SRBs - nr_rrc_rlc_config_asn1_req(ctxt_pP, - radioBearerConfig->srb_ToAddModList, - NULL, - NULL, - NULL, - NULL - ); + // nr_rrc_rlc_config_asn1_req(ctxt_pP, + // radioBearerConfig->srb_ToAddModList, + // NULL, + // NULL, + // NULL, + // NULL + // ); for (cnt = 0; cnt < radioBearerConfig->srb_ToAddModList->list.count; cnt++) { SRB_id = radioBearerConfig->srb_ToAddModList->list.array[cnt]->srb_Identity; @@ -2016,26 +2035,26 @@ nr_sa_rrc_ue_process_radioBearerConfig( (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4)); // Refresh DRBs - nr_rrc_pdcp_config_asn1_req(ctxt_pP, - NULL, - radioBearerConfig->drb_ToAddModList, - NULL, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | - (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), - NULL, - NULL, - kUPenc, - NULL, - NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB, - NULL); + // nr_rrc_pdcp_config_asn1_req(ctxt_pP, + // NULL, + // radioBearerConfig->drb_ToAddModList, + // NULL, + // NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | + // (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), + // NULL, + // NULL, + // kUPenc, + // NULL, + // NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB, + // NULL); // Refresh DRBs - nr_rrc_rlc_config_asn1_req(ctxt_pP, - NULL, - radioBearerConfig->drb_ToAddModList, - NULL, - NULL, - NULL - ); + // nr_rrc_rlc_config_asn1_req(ctxt_pP, + // NULL, + // radioBearerConfig->drb_ToAddModList, + // NULL, + // NULL, + // NULL + // ); } // drb_ToAddModList if (radioBearerConfig->drb_ToReleaseList != NULL) { @@ -2102,7 +2121,7 @@ rrc_ue_process_rrcReconfiguration( void nr_rrc_ue_generate_RRCReconfigurationComplete( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index, const uint8_t Transaction_id ) { uint8_t buffer[32], size; size = do_NR_RRCReconfigurationComplete(ctxt_pP, buffer, Transaction_id); - LOG_I(RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCReconfigurationComplete (bytes %d, gNB_index %d)\n", + LOG_I(NR_RRC,PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel UL-DCCH (SRB1), Generating RRCReconfigurationComplete (bytes %d, gNB_index %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, gNB_index); LOG_D(RLC, "[FRAME %05d][RRC_UE][INST %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCReconfigurationComplete to gNB %d MUI %d) --->][PDCP][INST %02d][RB %02d]\n", @@ -2230,16 +2249,16 @@ void *rrc_nrue_task( void *args_p ) { switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: - LOG_W(RRC, " *** Exiting RRC thread\n"); + LOG_W(NR_RRC, " *** Exiting RRC thread\n"); itti_exit_task (); break; case MESSAGE_TEST: - LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; case NR_RRC_MAC_BCCH_DATA_IND: - LOG_D(RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), + LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); // PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_NO, NOT_A_RNTI, RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0); PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); @@ -2251,7 +2270,7 @@ void *rrc_nrue_task( void *args_p ) { NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); case NR_RRC_MAC_CCCH_DATA_IND: - LOG_D(RRC, "[UE %d] RNTI %x Received %s: frameP %d, gNB %d\n", + LOG_D(NR_RRC, "[UE %d] RNTI %x Received %s: frameP %d, gNB %d\n", ue_mod_id, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, ITTI_MSG_NAME (msg_p), @@ -2293,7 +2312,7 @@ void *rrc_nrue_task( void *args_p ) { break; default: - LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + LOG_E(NR_RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; } diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 5ec6c3f8e2..207ba02f81 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -118,6 +118,12 @@ int8_t mac_rrc_nr_data_req_ue(const module_id_t Mod_idP, /**\brief RRC UE task. \param void *args_p Pointer on arguments to start the task. */ void *rrc_nrue_task(void *args_p); + +/**\brief RRC UE generate RRCSetupRequest message. + \param ctxt_pP protocol context + \param gNB_index gNB index */ +void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_index ); + /** @}*/ #endif diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c index 19bc9c154a..db3da25e21 100644 --- a/openair2/SIMULATION/NR_RRC/itti_sim.c +++ b/openair2/SIMULATION/NR_RRC/itti_sim.c @@ -59,6 +59,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "x2ap_eNB.h" #include "ngap_gNB.h" #include "RRC/NR_UE/rrc_proto.h" +#include "RRC/NR_UE/rrc_vars.h" #include "openair3/NAS/UE/nas_ue_task.h" pthread_cond_t nfapi_sync_cond; @@ -380,7 +381,7 @@ int create_tasks_nrue(uint32_t ue_nb) { if (ue_nb > 0) { printf("create TASK_RRC_NRUE\n"); if (itti_create_task (TASK_RRC_NRUE, rrc_nrue_task, NULL) < 0) { - LOG_E(RRC, "Create task for RRC UE failed\n"); + LOG_E(NR_RRC, "Create task for RRC UE failed\n"); return -1; } } @@ -406,12 +407,12 @@ void *itti_sim_ue_rrc_task( void *args_p) { switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: - LOG_W(RRC, " *** Exiting RRC thread\n"); + LOG_W(NR_RRC, " *** Exiting RRC thread\n"); itti_exit_task (); break; case MESSAGE_TEST: - LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; case GNB_RRC_BCCH_DATA_IND: message_p = itti_alloc_new_message (TASK_RRC_NRUE, NR_RRC_MAC_BCCH_DATA_IND); @@ -433,12 +434,11 @@ void *itti_sim_ue_rrc_task( void *args_p) { message_p = itti_alloc_new_message (TASK_RRC_NRUE, NR_RRC_DCCH_DATA_IND); NR_RRC_DCCH_DATA_IND (message_p).dcch_index = GNB_RRC_DCCH_DATA_IND(msg_p).rbid; NR_RRC_DCCH_DATA_IND (message_p).sdu_size = GNB_RRC_DCCH_DATA_IND(msg_p).size; - memset(NR_RRC_DCCH_DATA_IND (message_p).sdu_p, 0, GNB_RRC_DCCH_DATA_IND(msg_p).size); - memcpy(NR_RRC_DCCH_DATA_IND (message_p).sdu_p, GNB_RRC_DCCH_DATA_IND(msg_p).sdu, GNB_RRC_DCCH_DATA_IND(msg_p).size); + NR_RRC_DCCH_DATA_IND (message_p).sdu_p = GNB_RRC_DCCH_DATA_IND(msg_p).sdu; itti_send_msg_to_task (TASK_RRC_NRUE, instance, message_p); break; default: - LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + LOG_E(NR_RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; } @@ -464,30 +464,30 @@ void *itti_sim_gnb_rrc_task( void *args_p) { switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: - LOG_W(RRC, " *** Exiting RRC thread\n"); + LOG_W(NR_RRC, " *** Exiting RRC thread\n"); itti_exit_task (); break; case MESSAGE_TEST: - LOG_D(RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; case UE_RRC_CCCH_DATA_IND: message_p = itti_alloc_new_message (TASK_RRC_GNB, NR_RRC_MAC_CCCH_DATA_IND); - RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = UE_RRC_CCCH_DATA_IND(msg_p).size; - memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); - memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).size); + NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = UE_RRC_CCCH_DATA_IND(msg_p).size; + memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); + memcpy (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).sdu, UE_RRC_CCCH_DATA_IND(msg_p).size); itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p); break; case UE_RRC_DCCH_DATA_IND: message_p = itti_alloc_new_message (TASK_RRC_GNB, NR_RRC_DCCH_DATA_IND); - RRC_DCCH_DATA_IND (message_p).sdu_size = UE_RRC_DCCH_DATA_IND(msg_p).size; - memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, UE_RRC_DCCH_DATA_IND(msg_p).size); - memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, UE_RRC_DCCH_DATA_IND(msg_p).sdu, UE_RRC_DCCH_DATA_IND(msg_p).size); + NR_RRC_DCCH_DATA_IND (message_p).sdu_size = UE_RRC_DCCH_DATA_IND(msg_p).size; + NR_RRC_DCCH_DATA_IND (message_p).dcch_index = UE_RRC_DCCH_DATA_IND(msg_p).rbid; + NR_RRC_DCCH_DATA_IND (message_p).sdu_p = UE_RRC_DCCH_DATA_IND(msg_p).sdu; itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p); break; default: - LOG_E(RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + LOG_E(NR_RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; } @@ -584,8 +584,26 @@ int main( int argc, char **argv ) // wait for end of program printf("TYPE TO TERMINATE\n"); + usleep(10000); + protocol_ctxt_t ctxt; + struct rrc_gNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[0]); + + if(ue_context_p == NULL){ + printf("ue_context_p == NULL"); + } + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, + 0, + ENB_FLAG_YES, + 0, + 0, + 0); + NR_UE_rrc_inst[ctxt.module_id].Info[0].State = RRC_SI_RECEIVED; + + rrc_ue_generate_RRCSetupRequest(&ctxt, 0); + #if 0 // test itti sim usleep(10000); From dfa50d975b2d125b7513b7a1281b4842f558da5a Mon Sep 17 00:00:00 2001 From: Xue Song Date: Fri, 16 Oct 2020 08:42:28 +0000 Subject: [PATCH 04/16] Modify RRCSetupComplete --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 3 +-- openair2/RRC/NR/rrc_gNB.c | 36 +++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 6cf1b01752..dff37614a8 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1115,12 +1115,11 @@ uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.size = 5; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.bits_unused = 1; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf = buf; - rv[0] = rv[0] & 0x7F; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[0] = rv[0]; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[1] = rv[1]; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[2] = rv[2]; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[3] = rv[3]; - rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[4] = rv[4]; + rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.randomValue.buf[4] = rv[4]&0xfe; } else { rrcSetupRequest->rrcSetupRequest.ue_Identity.present = NR_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1; rrcSetupRequest->rrcSetupRequest.ue_Identity.choice.ng_5G_S_TMSI_Part1.size = 1; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index d61471ad42..ff6431b1a5 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -86,6 +86,9 @@ #include "executables/softmodem-common.h" #include +#include "BIT_STRING.h" +#include "assertions.h" + //#define XER_PRINT extern RAN_CONTEXT_t RC; @@ -112,6 +115,8 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); +static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn); + mui_t rrc_gNB_mui = 0; ///---------------------------------------------------------------------------------------------------------------/// @@ -773,7 +778,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, return -1; } - uint64_t s_tmsi_part1 = BIT_STRING_to_uint64(&rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1); + uint64_t s_tmsi_part1 = bitStr_to_uint64(&rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1); // memcpy(((uint8_t *) & random_value) + 3, // rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf, @@ -857,6 +862,29 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, return 0; } +/*! \fn uint64_t bitStr_to_uint64(BIT_STRING_t *) + *\brief This function extract at most a 64 bits value from a BIT_STRING_t object, the exact bits number depend on the BIT_STRING_t contents. + *\param[in] pointer to the BIT_STRING_t object. + *\return the extracted value. + */ +static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn) { + uint64_t result = 0; + int index; + int shift; + + DevCheck ((asn->size > 0) && (asn->size <= 8), asn->size, 0, 0); + + shift = ((asn->size - 1) * 8) - asn->bits_unused; + for (index = 0; index < (asn->size - 1); index++) { + result |= (uint64_t)asn->buf[index] << shift; + shift -= 8; + } + + result |= asn->buf[index] >> asn->bits_unused; + + return result; +} + //----------------------------------------------------------------------------- int rrc_gNB_decode_dcch( @@ -894,7 +922,7 @@ rrc_gNB_decode_dcch( sdu_sizeP, 0, 0); - xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); + // xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); { for (i = 0; i < sdu_sizeP; i++) { @@ -1019,9 +1047,9 @@ rrc_gNB_decode_dcch( return -1; } - uint64_t fiveg_s_TMSI = BIT_STRING_to_uint64(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + uint64_t fiveg_s_TMSI = bitStr_to_uint64(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI); - LOG_I(NR_RRC, "Received rrcSetupComplete, 5g_s_TMSI: 0x%lX, amf_set_id: 0x%lX(%d), amf_pointer: 0x%lX(%d), 5g TMSI: 0x%lX \n", + LOG_I(NR_RRC, "Received rrcSetupComplete, 5g_s_TMSI: 0x%lX, amf_set_id: 0x%lX(%d), amf_pointer: 0x%lX(%d), 5g TMSI: 0x%X \n", fiveg_s_TMSI, fiveg_s_TMSI >> 38, fiveg_s_TMSI >> 38, (fiveg_s_TMSI >> 32) & 0x3F, (fiveg_s_TMSI >> 32) & 0x3F, (uint32_t)fiveg_s_TMSI); From 6030a75a65fbaedc1e0c16a7cb392debbbd3a14a Mon Sep 17 00:00:00 2001 From: yaojie Date: Fri, 16 Oct 2020 09:15:53 +0000 Subject: [PATCH 05/16] fix securityModeCommand/securityModeComplete --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 4 ++-- openair2/RRC/NR/rrc_gNB.c | 14 ++++++++++++-- openair2/RRC/NR_UE/rrc_UE.c | 30 +++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index dff37614a8..e3faab6edb 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -820,9 +820,9 @@ uint8_t do_NR_SecurityModeCommand( dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm = integrityProtAlgorithm; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); - } + //} enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index ff6431b1a5..fb637495ad 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1089,9 +1089,9 @@ rrc_gNB_decode_dcch( DCCH, sdu_sizeP); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { +// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); - } +// } break; case NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: @@ -1420,6 +1420,14 @@ rrc_gNB_generate_SecurityModeCommand( size); LOG_I(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); + GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).size = size; + itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); +#else rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, @@ -1427,6 +1435,8 @@ rrc_gNB_generate_SecurityModeCommand( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +#endif + } void diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index e73455621e..09a42ff865 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1618,10 +1618,11 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); } if (securityModeCommand->criticalExtensions.present == NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand) { - + ul_dcch_msg.message.choice.c1->choice.securityModeComplete = CALLOC(1, sizeof(NR_SecurityModeComplete_t)); ul_dcch_msg.message.choice.c1->choice.securityModeComplete->rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.present = NR_SecurityModeComplete__criticalExtensions_PR_securityModeComplete; - ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete->nonCriticalExtension =NULL; + ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete = CALLOC(1, sizeof(NR_SecurityModeComplete_IEs_t)); + ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete->nonCriticalExtension =NULL; LOG_I(NR_RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d), rrc_TransactionIdentifier: %ld\n", ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index, securityModeCommand->rrc_TransactionIdentifier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, @@ -1632,9 +1633,9 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { +// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - } +// } LOG_D(NR_RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); @@ -1643,6 +1644,19 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); } LOG_T(NR_RRC, "\n"); +#ifdef ITTI_SIM + MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_UE_SIM,TASK_RRC_GNB_SIM, + (enc_rval.encoded + 7) / 8); + memcpy (message_buffer, buffer, (enc_rval.encoded + 7) / 8); + + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_CCCH_DATA_IND); + GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = buffer; + GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; + itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); +#else rrc_data_req ( ctxt_pP, DCCH, @@ -1651,6 +1665,7 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); (enc_rval.encoded + 7) / 8, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +#endif } else LOG_W(NR_RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", securityModeCommand->criticalExtensions.present); } @@ -2225,6 +2240,13 @@ nr_rrc_ue_decode_dcch( case NR_DL_DCCH_MessageType__c1_PR_spare1: break; case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: + LOG_I(RRC, "[UE %d] Received securityModeCommand (gNB %d)\n", + ctxt_pP->module_id, gNB_indexP); + nr_rrc_ue_process_securityModeCommand( + ctxt_pP, + dl_dcch_msg->message.choice.c1->choice.securityModeCommand, + gNB_indexP); + break; } } From 160526644052c2ba1122212e802cd3bb30b1a5d2 Mon Sep 17 00:00:00 2001 From: Qiu DeZhi Date: Mon, 19 Oct 2020 04:59:29 +0000 Subject: [PATCH 06/16] Add RRCrelease --- openair2/RRC/NR_UE/rrc_UE.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 09a42ff865..1c07f1e25a 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1430,6 +1430,7 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( int32_t i; NR_DL_DCCH_Message_t *nr_dl_dcch_msg = NULL; + MessageDef *msg_p; asn_dec_rval_t dec_rval = uper_decode( NULL, &asn_DEF_NR_DL_DCCH_Message, @@ -1460,6 +1461,16 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( case NR_DL_DCCH_MessageType__c1_PR_NOTHING: case NR_DL_DCCH_MessageType__c1_PR_rrcResume: case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: + msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND); + + if((nr_dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.present == NR_RRCRelease__criticalExtensions_PR_rrcRelease) && + (nr_dl_dcch_msg->message.choice.c1->present == NR_DL_DCCH_MessageType__c1_PR_rrcRelease)){ + nr_dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationTimer = + NR_RRCRelease_IEs__deprioritisationReq__deprioritisationTimer_min5; + nr_dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationType = + NR_RRCRelease_IEs__deprioritisationReq__deprioritisationType_frequency; + } + break; case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: From 4421bc56654f6c7c94f745e90cf46b283fe13d06 Mon Sep 17 00:00:00 2001 From: Qiu DeZhi Date: Mon, 19 Oct 2020 06:55:53 +0000 Subject: [PATCH 07/16] modify rrcRelease --- openair2/RRC/NR_UE/rrc_UE.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 1c07f1e25a..bc388bdc3d 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1461,7 +1461,7 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( case NR_DL_DCCH_MessageType__c1_PR_NOTHING: case NR_DL_DCCH_MessageType__c1_PR_rrcResume: case NR_DL_DCCH_MessageType__c1_PR_rrcRelease: - msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND); + msg_p = itti_alloc_new_message(TASK_RRC_NRUE, NAS_CONN_RELEASE_IND); if((nr_dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.present == NR_RRCRelease__criticalExtensions_PR_rrcRelease) && (nr_dl_dcch_msg->message.choice.c1->present == NR_DL_DCCH_MessageType__c1_PR_rrcRelease)){ @@ -1470,6 +1470,7 @@ int8_t nr_rrc_ue_decode_NR_DL_DCCH_Message( nr_dl_dcch_msg->message.choice.c1->choice.rrcRelease->criticalExtensions.choice.rrcRelease->deprioritisationReq->deprioritisationType = NR_RRCRelease_IEs__deprioritisationReq__deprioritisationType_frequency; } + itti_send_msg_to_task(TASK_RRC_NRUE,module_id,msg_p); break; case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: From 4766f3a629bf74493fc4d125c55a116d051b43ce Mon Sep 17 00:00:00 2001 From: Xue Song Date: Mon, 19 Oct 2020 07:58:10 +0000 Subject: [PATCH 08/16] fix RRCReconfiguration/RRCReconfigurationComplete --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 22 ++++++++++ openair2/RRC/NR/rrc_gNB.c | 65 +++++++++++++++-------------- openair2/RRC/NR_UE/rrc_UE.c | 34 +++++++++++++-- 3 files changed, 86 insertions(+), 35 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e3faab6edb..e3687e26f5 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -65,6 +65,9 @@ #include "NR_SecurityConfig.h" #include "NR_RRCReconfiguration-v1530-IEs.h" #include "NR_UL-DCCH-Message.h" +#include "NR_SDAP-Config.h" +#include "NR_RRCReconfigurationComplete.h" +#include "NR_RRCReconfigurationComplete-IEs.h" #if defined(NR_Rel16) #include "NR_SCS-SpecificCarrier.h" #include "NR_TDD-UL-DL-ConfigCommon.h" @@ -952,6 +955,7 @@ uint16_t do_RRCReconfiguration( NR_DRB_ToAddModList_t *DRB_configList = NULL; NR_DRB_ToAddModList_t *DRB_configList2 = NULL; NR_DRB_ToAddMod_t *DRB_config = NULL; + NR_SDAP_Config_t *sdap_config = NULL; NR_SecurityConfig_t *security_config = NULL; NR_DedicatedNAS_Message_t *dedicatedNAS_Message = NULL; @@ -1003,6 +1007,9 @@ uint16_t do_RRCReconfiguration( DRB_config->cnAssociation = CALLOC(1, sizeof(*DRB_config->cnAssociation)); DRB_config->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config; // TODO sdap_Config + sdap_config = CALLOC(1, sizeof(NR_SDAP_Config_t)); + memset(sdap_config, 0, sizeof(NR_SDAP_Config_t)); + DRB_config->cnAssociation->choice.sdap_Config = sdap_config; // TODO pdcp_Config DRB_config->reestablishPDCP = NULL; DRB_config->recoverPDCP = NULL; @@ -1068,6 +1075,10 @@ uint16_t do_RRCReconfiguration( dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie; + // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); + // } + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, (void *)&dl_dcch_msg, @@ -1093,6 +1104,15 @@ uint16_t do_RRCReconfiguration( return(-1); } +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); + GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded+7)/8; + itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); +#endif + return((enc_rval.encoded+7)/8); } @@ -1162,8 +1182,10 @@ do_NR_RRCReconfigurationComplete( ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_UL_DCCH_MessageType__c1)); ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_rrcReconfigurationComplete; + ul_dcch_msg.message.choice.c1->choice.rrcReconfigurationComplete = CALLOC(1, sizeof(NR_RRCReconfigurationComplete_t)); rrcReconfigurationComplete = ul_dcch_msg.message.choice.c1->choice.rrcReconfigurationComplete; rrcReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id; + rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete = CALLOC(1, sizeof(NR_RRCReconfigurationComplete_IEs_t)); rrcReconfigurationComplete->criticalExtensions.present = NR_RRCReconfigurationComplete__criticalExtensions_PR_rrcReconfigurationComplete; rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->nonCriticalExtension = NULL; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index fb637495ad..403e2509e8 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -535,6 +535,14 @@ rrc_gNB_generate_defaultRRCReconfiguration( ue_context_pP->ue_context.rnti, rrc_gNB_mui, size); +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); + GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).size = size; + itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); +#else rrc_data_req(ctxt_pP, DCCH, rrc_gNB_mui++, @@ -542,7 +550,7 @@ rrc_gNB_generate_defaultRRCReconfiguration( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - +#endif // rrc_pdcp_config_asn1_req // rrc_rlc_config_asn1_req } @@ -571,12 +579,12 @@ rrc_gNB_process_RRCReconfigurationComplete( rnti_t rnti = ue_context_pP->ue_id_rnti; module_id_t module_id = ctxt_pP->module_id; - int UE_id_mac = find_UE_id(module_id, rnti); + // int UE_id_mac = find_UE_id(module_id, rnti); - if (UE_id_mac == -1) { - LOG_E(RRC, "Can't find UE_id(MAC) of UE rnti %x\n", rnti); - return; - } + // if (UE_id_mac == -1) { + // LOG_E(RRC, "Can't find UE_id(MAC) of UE rnti %x\n", rnti); + // return; + // } /* Derive the keys from kgnb */ if (DRB_configList != NULL) { @@ -597,24 +605,24 @@ rrc_gNB_process_RRCReconfigurationComplete( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti); - nr_rrc_pdcp_config_asn1_req(ctxt_pP, - SRB_configList, // NULL, - DRB_configList, - DRB_Release_configList2, - 0xff, // already configured during the securitymodecommand - kRRCenc, - kRRCint, - kUPenc, - NULL, - NULL, - NULL); - /* Refresh SRBs/DRBs */ - nr_rrc_rlc_config_asn1_req(ctxt_pP, - SRB_configList, // NULL, - DRB_configList, - DRB_Release_configList2, - NULL, - NULL); + // nr_rrc_pdcp_config_asn1_req(ctxt_pP, + // SRB_configList, // NULL, + // DRB_configList, + // DRB_Release_configList2, + // 0xff, // already configured during the securitymodecommand + // kRRCenc, + // kRRCint, + // kUPenc, + // NULL, + // NULL, + // NULL); + // /* Refresh SRBs/DRBs */ + // nr_rrc_rlc_config_asn1_req(ctxt_pP, + // SRB_configList, // NULL, + // DRB_configList, + // DRB_Release_configList2, + // NULL, + // NULL); /* Loop through DRBs and establish if necessary */ if (DRB_configList != NULL) { @@ -1092,6 +1100,8 @@ rrc_gNB_decode_dcch( // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); // } + + rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); break; case NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: @@ -1281,13 +1291,6 @@ void *rrc_gnb_task(void *args_p) { NR_RRC_DCCH_DATA_IND(msg_p).dcch_index, NR_RRC_DCCH_DATA_IND(msg_p).sdu_p, NR_RRC_DCCH_DATA_IND(msg_p).sdu_size); - // Message buffer has been processed, free it now. - result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), NR_RRC_DCCH_DATA_IND(msg_p).sdu_p); - - if (result != EXIT_SUCCESS) { - LOG_I(NR_RRC, "Failed to free memory (%d)!\n", result); - break; - } break; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index bc388bdc3d..513f304b23 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1663,11 +1663,30 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); (enc_rval.encoded + 7) / 8); memcpy (message_buffer, buffer, (enc_rval.encoded + 7) / 8); - message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_CCCH_DATA_IND); + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_DCCH_DATA_IND); GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; GNB_RRC_DCCH_DATA_IND (message_p).sdu = buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); + + asn_dec_rval_t dec_rval; + NR_UL_DCCH_Message_t *ul_dcch_msg = NULL; + + dec_rval = uper_decode( + NULL, + &asn_DEF_NR_UL_DCCH_Message, + (void **)&ul_dcch_msg, + buffer, + (enc_rval.encoded + 7) / 8, + 0, + 0); + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + LOG_E(NR_RRC, " Failed to decode UL-DCCH (%zu bytes)\n", + dec_rval.consumed); + return -1; + } else { + LOG_I(NR_RRC, "decode securityModeComplete success\n"); + } #else rrc_data_req ( ctxt_pP, @@ -2159,6 +2178,14 @@ void nr_rrc_ue_generate_RRCReconfigurationComplete( const protocol_ctxt_t *const nr_rrc_mui, UE_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), DCCH); +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_DCCH_DATA_IND); + UE_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + UE_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + UE_RRC_DCCH_DATA_IND (message_p).size = size; + itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); +#else rrc_data_req_ue ( ctxt_pP, DCCH, @@ -2167,6 +2194,8 @@ void nr_rrc_ue_generate_RRCReconfigurationComplete( const protocol_ctxt_t *const size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +#endif + } // from NR SRB1 @@ -2340,9 +2369,6 @@ void *rrc_nrue_task( void *args_p ) { NR_RRC_DCCH_DATA_IND (msg_p).dcch_index, NR_RRC_DCCH_DATA_IND (msg_p).sdu_p, NR_RRC_DCCH_DATA_IND (msg_p).gNB_index); - // Message buffer has been processed, free it now. - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), NR_RRC_DCCH_DATA_IND (msg_p).sdu_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); break; default: From 49487217bf731292a739311a83f4e1335aa3b3ed Mon Sep 17 00:00:00 2001 From: zhanghuiqin Date: Mon, 19 Oct 2020 08:22:15 +0000 Subject: [PATCH 09/16] add UECapabitlityEnquiry(ue) --- openair2/RRC/NR_UE/rrc_UE.c | 73 +++++++++++++++++++++++++++++++++++ openair2/RRC/NR_UE/rrc_defs.h | 2 + 2 files changed, 75 insertions(+) diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 513f304b23..550be9d45a 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -2271,6 +2271,13 @@ nr_rrc_ue_decode_dcch( case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: + LOG_I(RRC, "[UE %d] Received Capability Enquiry (gNB %d)\n", + ctxt_pP->module_id,gNB_indexP); + nr_rrc_ue_process_ueCapabilityEnquiry( + ctxt_pP, + &dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, + gNB_indexP); + break; case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: @@ -2402,3 +2409,69 @@ void *nr_rrc_ue_process_sidelink_radioResourceConfig( } } } + +//----------------------------------------------------------------------------- +void +nr_rrc_ue_process_ueCapabilityEnquiry( + const protocol_ctxt_t *const ctxt_pP, + NR_UECapabilityEnquiry_t *UECapabilityEnquiry, + uint8_t gNB_index +) +//----------------------------------------------------------------------------- +{ + asn_enc_rval_t enc_rval; + NR_UL_DCCH_Message_t ul_dcch_msg; + NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container; + uint8_t buffer[200]; + int i; + LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing UECapabilityEnquiry (gNB %d)\n", + ctxt_pP->module_id, + ctxt_pP->frame, + gNB_index); + memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); + memset((void *)&ue_CapabilityRAT_Container,0,sizeof(NR_UE_CapabilityRAT_Container_t)); + ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1; + ul_dcch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_UL_DCCH_MessageType__c1)); + ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation; + ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation)); + ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier; + ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_eutra; + OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, + (const char *)NR_UE_rrc_inst[ctxt_pP->module_id].UECapability, + NR_UE_rrc_inst[ctxt_pP->module_id].UECapability_size); + // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf = UE_rrc_inst[ue_mod_idP].UECapability; + // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[ue_mod_idP].UECapability_size; + AssertFatal(UECapabilityEnquiry->criticalExtensions.present == NR_UECapabilityEnquiry__criticalExtensions_PR_ueCapabilityEnquiry, + "UECapabilityEnquiry->criticalExtensions.present (%d) != UECapabilityEnquiry__criticalExtensions_PR_c1 (%d)\n", + UECapabilityEnquiry->criticalExtensions.present,NR_UECapabilityEnquiry__criticalExtensions_PR_ueCapabilityEnquiry); + + ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.present = NR_UECapabilityInformation__criticalExtensions_PR_ueCapabilityInformation; + ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation_IEs)); + ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.count = 0; + + for (i=0; icriticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list.count; i++) { + if (UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list.array[i] + == NR_RAT_Type_eutra) { + ASN_SEQUENCE_ADD( + &ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list, + &ue_CapabilityRAT_Container); + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + + LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + rrc_data_req_ue ( + ctxt_pP, + DCCH, + nr_rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + } + } +} diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 92728eee98..26863944fd 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -92,6 +92,8 @@ typedef struct NR_UE_RRC_INST_s { NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE]; uint8_t MBMS_flag; + uint8_t *UECapability; + uint8_t UECapability_size; NR_SystemInformation_t *si[NB_CNX_UE]; NR_SIB1_t *sib1[NB_CNX_UE]; From fad30fff8a5619878f6d2a33cea19b49d56d9e4d Mon Sep 17 00:00:00 2001 From: zhanghuiqin Date: Tue, 20 Oct 2020 08:41:41 +0000 Subject: [PATCH 10/16] fix UECapabilityEnquiry & UECapabilityInformation --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 14 ++--- openair2/RRC/NR/rrc_gNB.c | 30 +++++++---- openair2/RRC/NR_UE/rrc_UE.c | 79 +++++++++++++++++++---------- openair2/RRC/NR_UE/rrc_defs.h | 8 +++ 4 files changed, 88 insertions(+), 43 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e3687e26f5..9e9299e956 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -865,7 +865,7 @@ uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, //------------------------------------------------------------------------------ { NR_DL_DCCH_Message_t dl_dcch_msg; - NR_UE_CapabilityRAT_Request_t ue_capabilityrat_request; + NR_UE_CapabilityRAT_Request_t *ue_capabilityrat_request; asn_enc_rval_t enc_rval; memset(&dl_dcch_msg,0,sizeof(NR_DL_DCCH_Message_t)); @@ -875,16 +875,18 @@ uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry = CALLOC(1,sizeof(struct NR_UECapabilityEnquiry)); dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->rrc_TransactionIdentifier = Transaction_id; dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->criticalExtensions.present = NR_UECapabilityEnquiry__criticalExtensions_PR_ueCapabilityEnquiry; - ue_capabilityrat_request.rat_Type = NR_RAT_Type_nr; - + dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry = CALLOC(1,sizeof(struct NR_UECapabilityEnquiry_IEs)); + ue_capabilityrat_request = CALLOC(1,sizeof(NR_UE_CapabilityRAT_Request_t)); + memset(ue_capabilityrat_request,0,sizeof(NR_UE_CapabilityRAT_Request_t)); + ue_capabilityrat_request->rat_Type = NR_RAT_Type_nr; ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list, - &ue_capabilityrat_request); + ue_capabilityrat_request); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); - } + //} enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 403e2509e8..64c134073d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1101,7 +1101,7 @@ rrc_gNB_decode_dcch( xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); // } - rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); + rrc_gNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); break; case NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: @@ -1131,9 +1131,9 @@ rrc_gNB_decode_dcch( PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), DCCH, sdu_sizeP); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); - } + //} LOG_I(NR_RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); int eutra_index = -1; @@ -1153,9 +1153,9 @@ rrc_gNB_decode_dcch( ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.buf, ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size, 0,0); - if(LOG_DEBUGFLAG(DEBUG_ASN1)){ + //if(LOG_DEBUGFLAG(DEBUG_ASN1)){ xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); - } + //} if((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)){ LOG_E(NR_RRC,PROTOCOL_NR_RRC_CTXT_UE_FMT" Failed to decode nr UE capabilities (%zu bytes)\n", @@ -1166,6 +1166,11 @@ rrc_gNB_decode_dcch( ue_context_p->ue_context.UE_Capability_size = ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size; + if(eutra_index != -1){ + LOG_E(NR_RRC,"fatal: more than 1 eutra capability\n"); + exit(1); + } + eutra_index = i; } if(ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == @@ -1197,11 +1202,7 @@ rrc_gNB_decode_dcch( if(ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == NR_RAT_Type_eutra){ - if(eutra_index == -1){ - LOG_E(NR_RRC,"fatal: more than 1 eutra capability\n"); - exit(1); - } - eutra_index = i; + //TODO } } @@ -1477,6 +1478,14 @@ rrc_gNB_generate_UECapabilityEnquiry( ue_context_pP->ue_context.rnti, rrc_gNB_mui, size); +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); + GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).size = size; + itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); +#else rrc_data_req( ctxt_pP, DCCH, @@ -1485,6 +1494,7 @@ rrc_gNB_generate_UECapabilityEnquiry( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +#endif } //----------------------------------------------------------------------------- diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 550be9d45a..aa1dd20d13 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1668,25 +1668,6 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); GNB_RRC_DCCH_DATA_IND (message_p).sdu = buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); - - asn_dec_rval_t dec_rval; - NR_UL_DCCH_Message_t *ul_dcch_msg = NULL; - - dec_rval = uper_decode( - NULL, - &asn_DEF_NR_UL_DCCH_Message, - (void **)&ul_dcch_msg, - buffer, - (enc_rval.encoded + 7) / 8, - 0, - 0); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(NR_RRC, " Failed to decode UL-DCCH (%zu bytes)\n", - dec_rval.consumed); - return -1; - } else { - LOG_I(NR_RRC, "decode securityModeComplete success\n"); - } #else rrc_data_req ( ctxt_pP, @@ -2268,16 +2249,16 @@ nr_rrc_ue_decode_dcch( itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); break; - case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: - case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: LOG_I(RRC, "[UE %d] Received Capability Enquiry (gNB %d)\n", ctxt_pP->module_id,gNB_indexP); nr_rrc_ue_process_ueCapabilityEnquiry( ctxt_pP, - &dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, + dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, gNB_indexP); break; + case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: + case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand: case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16: case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16: @@ -2435,7 +2416,36 @@ nr_rrc_ue_process_ueCapabilityEnquiry( ul_dcch_msg.message.choice.c1->present = NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation; ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation)); ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier; - ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_eutra; + ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr; + NR_UE_NR_Capability_t* UE_Capability_nr; + UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t)); + NR_BandNR_t *nr_bandnr; + nr_bandnr = CALLOC(1,sizeof(NR_BandNR_t)); + nr_bandnr->bandNR = 1; + ASN_SEQUENCE_ADD( + &UE_Capability_nr->rf_Parameters.supportedBandListNR.list, + nr_bandnr); + OAI_NR_UECapability_t *UECap; + UECap = CALLOC(1,sizeof(OAI_NR_UECapability_t)); + UECap->UE_NR_Capability = UE_Capability_nr; + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr); + //} + + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_NR_Capability, + NULL, + (void *)UE_Capability_nr, + &UECap->sdu[0], + MAX_UE_NR_CAPABILITY_SIZE); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + UECap->sdu_size = (enc_rval.encoded + 7) / 8; + LOG_I(PHY, "[RRC]UE NR Capability encoded, %d bytes (%zd bits)\n", + UECap->sdu_size, enc_rval.encoded + 7); + + NR_UE_rrc_inst[ctxt_pP->module_id].UECap = UECap; + NR_UE_rrc_inst[ctxt_pP->module_id].UECapability = UECap->sdu; + NR_UE_rrc_inst[ctxt_pP->module_id].UECapability_size = UECap->sdu_size; OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, (const char *)NR_UE_rrc_inst[ctxt_pP->module_id].UECapability, NR_UE_rrc_inst[ctxt_pP->module_id].UECapability_size); @@ -2447,11 +2457,12 @@ nr_rrc_ue_process_ueCapabilityEnquiry( ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.present = NR_UECapabilityInformation__criticalExtensions_PR_ueCapabilityInformation; ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation_IEs)); + ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList = CALLOC(1, sizeof(struct NR_UE_CapabilityRAT_ContainerList)); ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.count = 0; for (i=0; icriticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list.count; i++) { - if (UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list.array[i] - == NR_RAT_Type_eutra) { + if (UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list.array[i]->rat_Type + == NR_RAT_Type_nr) { ASN_SEQUENCE_ADD( &ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list, &ue_CapabilityRAT_Container); @@ -2459,11 +2470,24 @@ nr_rrc_ue_process_ueCapabilityEnquiry( AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - } + //} LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); +#ifdef ITTI_SIM + MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_UE_SIM,TASK_RRC_GNB_SIM, + (enc_rval.encoded + 7) / 8); + memcpy (message_buffer, buffer, (enc_rval.encoded + 7) / 8); + + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_DCCH_DATA_IND); + GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; + GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; + itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); +#else rrc_data_req_ue ( ctxt_pP, DCCH, @@ -2472,6 +2496,7 @@ nr_rrc_ue_process_ueCapabilityEnquiry( (enc_rval.encoded + 7) / 8, buffer, PDCP_TRANSMISSION_MODE_CONTROL); +#endif } } } diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 26863944fd..336c663857 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -70,6 +70,13 @@ typedef enum { nr_RadioBearerConfigX_r15=1 } nsa_message_t; +#define MAX_UE_NR_CAPABILITY_SIZE 255 +typedef struct OAI_NR_UECapability_s { + uint8_t sdu[MAX_UE_NR_CAPABILITY_SIZE]; + uint8_t sdu_size; + NR_UE_NR_Capability_t *UE_NR_Capability; +} OAI_NR_UECapability_t; + typedef struct NR_UE_RRC_INST_s { NR_MeasConfig_t *meas_config; @@ -92,6 +99,7 @@ typedef struct NR_UE_RRC_INST_s { NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE]; uint8_t MBMS_flag; + OAI_NR_UECapability_t *UECap; uint8_t *UECapability; uint8_t UECapability_size; From e15f0b2813dadced08d91e4ffb7a0711af092358 Mon Sep 17 00:00:00 2001 From: He Shanyun Date: Tue, 20 Oct 2020 11:30:06 +0000 Subject: [PATCH 11/16] add struct for registration request message --- .../NAS/COMMON/EMM/MSG/RegistrationRequest.c | 71 ++++++++ .../NAS/COMMON/EMM/MSG/RegistrationRequest.h | 99 +++++++++++ .../IES/ExtendedProtocolDiscriminator.c | 28 ++++ .../IES/ExtendedProtocolDiscriminator.h | 26 +++ openair3/NAS/COMMON/IES/FGSMobileIdentity.c | 156 ++++++++++++++++++ openair3/NAS/COMMON/IES/FGSMobileIdentity.h | 113 +++++++++++++ openair3/NAS/COMMON/IES/FGSRegistrationType.c | 43 +++++ openair3/NAS/COMMON/IES/FGSRegistrationType.h | 35 ++++ openair3/NAS/COMMON/IES/SpareHalfOctet.c | 28 ++++ openair3/NAS/COMMON/IES/SpareHalfOctet.h | 29 ++++ 10 files changed, 628 insertions(+) create mode 100644 openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c create mode 100644 openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h create mode 100644 openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.c create mode 100644 openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.h create mode 100644 openair3/NAS/COMMON/IES/FGSMobileIdentity.c create mode 100644 openair3/NAS/COMMON/IES/FGSMobileIdentity.h create mode 100644 openair3/NAS/COMMON/IES/FGSRegistrationType.c create mode 100644 openair3/NAS/COMMON/IES/FGSRegistrationType.h create mode 100644 openair3/NAS/COMMON/IES/SpareHalfOctet.c create mode 100644 openair3/NAS/COMMON/IES/SpareHalfOctet.h diff --git a/openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c b/openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c new file mode 100644 index 0000000000..4d449168d5 --- /dev/null +++ b/openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.c @@ -0,0 +1,71 @@ +/*! \file RegistrationRequest.c + +\brief registration request procedures for gNB +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include +#include + +#include "nas_log.h" + +#include "RegistrationRequest.h" + +int decode_registration_request(registration_request_msg *registration_request, uint8_t *buffer, uint32_t len) +{ + uint32_t decoded = 0; + int decoded_result = 0; + + LOG_FUNC_IN; + LOG_TRACE(INFO, "EMM - registration_request len = %d", + len); + + /* Decoding mandatory fields */ + if ((decoded_result = decode_5gs_registration_type(®istration_request->fgsregistrationtype, 0, *(buffer + decoded) & 0x0f, len - decoded)) < 0) { + // return decoded_result; + LOG_FUNC_RETURN(decoded_result); + } + + if ((decoded_result = decode_u8_nas_key_set_identifier(®istration_request->naskeysetidentifier, 0, *(buffer + decoded) >> 4, len - decoded)) < 0) { + // return decoded_result; + LOG_FUNC_RETURN(decoded_result); + } + + decoded++; + + if ((decoded_result = decode_5gs_mobile_identity(®istration_request->fgsmobileidentity, 0, buffer + decoded, len - decoded)) < 0) { + // return decoded_result; + LOG_FUNC_RETURN(decoded_result); + } else + decoded += decoded_result; + + + // TODO, Decoding optional fields + + return decoded; +} + +int encode_registration_request(registration_request_msg *registration_request, uint8_t *buffer, uint32_t len) +{ + int encoded = 0; + int encode_result = 0; + + *(buffer + encoded) = ((encode_u8_nas_key_set_identifier(®istration_request->naskeysetidentifier) & 0x0f) << 4) | (encode_5gs_registration_type(®istration_request->fgsregistrationtype) & 0x0f); + encoded++; + + if ((encode_result = + encode_5gs_mobile_identity(®istration_request->fgsmobileidentity, 0, buffer + + encoded, len - encoded)) < 0) //Return in case of error + return encode_result; + else + encoded += encode_result; + + // TODO, Eecoding optional fields + return encoded; +} + diff --git a/openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h b/openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h new file mode 100644 index 0000000000..4d023e05e9 --- /dev/null +++ b/openair3/NAS/COMMON/EMM/MSG/RegistrationRequest.h @@ -0,0 +1,99 @@ +/*! \file RegistrationRequest.h + +\brief registration request procedures for gNB +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + +#include "ExtendedProtocolDiscriminator.h" +#include "SecurityHeaderType.h" +#include "SpareHalfOctet.h" +#include "FGSMobileIdentity.h" +#include "NasKeySetIdentifier.h" +#include "FGSRegistrationType.h" +#include "MessageType.h" + +#ifndef REGISTRATION_REQUEST_H_ +#define REGISTRATION_REQUEST_H_ + + +# define REGISTRATION_REQUEST_NON_CURRENT_NATIVE_NAS_KEYSET_PRESENT (1<<0) +# define REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT (1<<1) +# define REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_PRESENT (1<<2) +# define REGISTRATION_REQUEST_REQUESTED_NSSAI_PRESENT (1<<3) +# define REGISTRATION_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT (1<<4) +# define REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_PRESENT (1<<5) +# define REGISTRATION_REQUEST_UPLINK_DATA_STATUS_PRESENT (1<<6) +# define REGISTRATION_REQUEST_PDU_SESSION_STATUS_PRESENT (1<<7) +# define REGISTRATION_REQUEST_MICO_INDICATION_PRESENT (1<<8) +# define REGISTRATION_REQUEST_UE_STATUS_PRESENT (1<<9) +# define REGISTRATION_REQUEST_ADDITIONAL_GUTI_PRESENT (1<<10) +# define REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_PRESENT (1<<11) +# define REGISTRATION_REQUEST_UE_USAGE_SETTING_PRESENT (1<<12) +# define REGISTRATION_REQUEST_REQUESTED_DRX_PARAMETERS_PRESENT (1<<13) +# define REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_PRESENT (1<<14) +# define REGISTRATION_REQUEST_LADN_INDICATION_PRESENT (1<<15) +# define REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_PRESENT (1<<16) +# define REGISTRATION_REQUEST_PAYLOAD_CONTAINER_PRESENT (1<<17) +# define REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_PRESENT (1<<18) +# define REGISTRATION_REQUEST_5GS_UPDATE_TYPE_PRESENT (1<<19) +# define REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_PRESENT (1<<20) +# define REGISTRATION_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT (1<<21) + +typedef enum registration_request_iei_tag { + REGISTRATION_REQUEST_NON_CURRENT_NATIVE_NAS_KEYSET_IEI = 0xC0, /* 0xC- = 192- */ + REGISTRATION_REQUEST_5GMM_CAPABILITY_IEI = 0x10, /* 0x10 = 16 */ + REGISTRATION_REQUEST_UE_SECURITY_CAPABILITY_IEI = 0x2E, /* 0x2E = 46 */ + REGISTRATION_REQUEST_REQUESTED_NSSAI_IEI = 0x2F, /* 0x2F = 47 */ + REGISTRATION_REQUEST_LAST_VISITED_REGISTERED_TAI_IEI = 0x52, /* 0x52 = 82 */ + REGISTRATION_REQUEST_S1_UE_NETWORK_CAPABILITY_IEI = 0x17, /* 0x17 = 23 */ + REGISTRATION_REQUEST_UPLINK_DATA_STATUS_IEI = 0x40, /* 0x40 = 64 */ + REGISTRATION_REQUEST_PDU_SESSION_STATUS_IEI = 0x50, /* 0x50 = 80 */ + REGISTRATION_REQUEST_MICO_INDICATION_IEI = 0xB0, /* 0xB- = 176- */ + REGISTRATION_REQUEST_UE_STATUS_IEI = 0x2B, /* 0x2B = 43 */ + REGISTRATION_REQUEST_ADDITIONAL_GUTI_IEI = 0x77, /* 0x77 = 119 */ + REGISTRATION_REQUEST_ALLOWED_PDU_SESSION_STATUS_IEI = 0x25, /* 0x25 = 37 */ + REGISTRATION_REQUEST_UE_USAGE_SETTING_IEI = 0x18, /* 0x18 = 24 */ + REGISTRATION_REQUEST_REQUESTED_DRX_PARAMETERS_IEI = 0x51, /* 0x51 = 81 */ + REGISTRATION_REQUEST_EPS_NAS_MESSAGE_CONTAINER_IEI = 0x70, /* 0x70 = 112 */ + REGISTRATION_REQUEST_LADN_INDICATION_IEI = 0x74, /* 0x74 = 116 */ + REGISTRATION_REQUEST_PAYLOAD_CONTAINER_TYPE_IEI = 0x80, /* 0x80 = 128 */ + REGISTRATION_REQUEST_PAYLOAD_CONTAINER_IEI = 0x7B, /* 0x7B = 123 */ + REGISTRATION_REQUEST_NETWORK_SLICING_INDICATION_IEI = 0x90, /* 0x90 = 144 */ + REGISTRATION_REQUEST_5GS_UPDATE_TYPE_IEI = 0x53, /* 0x53 = 83 */ + REGISTRATION_REQUEST_NAS_MESSAGE_CONTAINER_IEI = 0x71, /* 0x71 = 113 */ + REGISTRATION_REQUEST_EPS_BEARER_CONTEXT_STATUS_IEI = 0x60 /* 0x60 = 96 */ +} registration_request_iei; + +/* + * Message name: Registration request + * Description: This message is sent by the UE to the AMF. See TS24.501 table 8.2.6.1.1. + * Significance: dual + * Direction: UE to network + */ + +typedef struct registration_request_msg_tag { + /* Mandatory fields */ + ExtendedProtocolDiscriminator protocoldiscriminator; + SecurityHeaderType securityheadertype:4; + SpareHalfOctet sparehalfoctet:4; + MessageType messagetype; + FGSRegistrationType fgsregistrationtype; + NasKeySetIdentifier naskeysetidentifier; + FGSMobileIdentity fgsmobileidentity; + + /* Optional fields */ +} registration_request_msg; + +int decode_registration_request(registration_request_msg *registrationrequest, uint8_t *buffer, uint32_t len); + +int encode_registration_request(registration_request_msg *registrationrequest, uint8_t *buffer, uint32_t len); + +#endif /* ! defined(REGISTRATION_REQUEST_H_) */ + diff --git a/openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.c b/openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.c new file mode 100644 index 0000000000..c0203f9882 --- /dev/null +++ b/openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.c @@ -0,0 +1,28 @@ +/*! \file ExtendedProtocolDiscriminator.c + +\brief Extended protocol discriminator for registration request procedures +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + + +#include "TLVEncoder.h" +#include "TLVDecoder.h" +#include "ExtendedProtocolDiscriminator.h" + +int encode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + return 0; +} + +int decode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + return 0; +} + diff --git a/openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.h b/openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.h new file mode 100644 index 0000000000..1fb3e085c7 --- /dev/null +++ b/openair3/NAS/COMMON/IES/ExtendedProtocolDiscriminator.h @@ -0,0 +1,26 @@ +/*! \file ExtendedProtocolDiscriminator.h + +\brief Extended protocol discriminator for registration request procedures +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + +#include "OctetString.h" + +#ifndef EXTENDED_PROTOCOL_DISCRIMINATOR_H_ +#define EXTENDED_PROTOCOL_DISCRIMINATOR_H_ + +typedef uint8_t ExtendedProtocolDiscriminator; + +int encode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len); + +int decode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len); + +#endif /* EXTENDED PROTOCOL DISCRIMINATOR_H_ */ + diff --git a/openair3/NAS/COMMON/IES/FGSMobileIdentity.c b/openair3/NAS/COMMON/IES/FGSMobileIdentity.c new file mode 100644 index 0000000000..77551c3eed --- /dev/null +++ b/openair3/NAS/COMMON/IES/FGSMobileIdentity.c @@ -0,0 +1,156 @@ +/*! \file FGSMobileIdentity.c + +\brief 5GS Mobile Identity for registration request procedures +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + + +#include "TLVEncoder.h" +#include "TLVDecoder.h" +#include "FGSMobileIdentity.h" + +static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer); + +static int encode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer); + +int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + int decoded_rc = TLV_DECODE_VALUE_DOESNT_MATCH; + int decoded = 0; + uint8_t ielen = 0; + + if (iei > 0) { + CHECK_IEI_DECODER(iei, *buffer); + decoded++; + } + + ielen = *(buffer + decoded); + decoded++; + CHECK_LENGTH_DECODER(len - decoded, ielen); + + uint8_t typeofidentity = *(buffer + decoded) & 0x7; + + if (typeofidentity == FGS_MOBILE_IDENTITY_5G_GUTI) { + decoded_rc = decode_guti_5gs_mobile_identity(&fgsmobileidentity->guti, + buffer + decoded); + } + + if (decoded_rc < 0) { + return decoded_rc; + } + + return (decoded + decoded_rc); +} + +int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + uint8_t *lenPtr; + int encoded_rc = TLV_ENCODE_VALUE_DOESNT_MATCH; + uint32_t encoded = 0; + + if (iei > 0) { + *buffer = iei; + encoded++; + } + + lenPtr = (buffer + encoded); + encoded ++; + + if (fgsmobileidentity->guti.typeofidentity == FGS_MOBILE_IDENTITY_5G_GUTI) { + encoded_rc = encode_guti_5gs_mobile_identity(&fgsmobileidentity->guti, + buffer + encoded); + } + + if (encoded_rc < 0) { + return encoded_rc; + } + + *lenPtr = encoded + encoded_rc - 1 - ((iei > 0) ? 1 : 0); + return (encoded + encoded_rc); +} + +static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer) +{ + int decoded = 0; + uint16_t temp; + guti->spare = (*(buffer + decoded) >> 4) & 0xf; + + /* + * For the 5G-GUTI, bits 5 to 8 of octet 3 are coded as "1111" + */ + if (guti->spare != 0xf) { + return (TLV_ENCODE_VALUE_DOESNT_MATCH); + } + + + guti->oddeven = (*(buffer + decoded) >> 3) & 0x1; + + /* + * For the 5G-GUTI, bits 4 of octet 3 are coded as "0" + */ + if (guti->oddeven != 0) { + return (TLV_ENCODE_VALUE_DOESNT_MATCH); + } + guti->typeofidentity = *(buffer + decoded) & 0x7; + + if (guti->typeofidentity != FGS_MOBILE_IDENTITY_5G_GUTI) { + return (TLV_ENCODE_VALUE_DOESNT_MATCH); + } + + decoded++; + guti->mccdigit2 = (*(buffer + decoded) >> 4) & 0xf; + guti->mccdigit1 = *(buffer + decoded) & 0xf; + decoded++; + guti->mncdigit3 = (*(buffer + decoded) >> 4) & 0xf; + guti->mccdigit3 = *(buffer + decoded) & 0xf; + decoded++; + guti->mncdigit2 = (*(buffer + decoded) >> 4) & 0xf; + guti->mncdigit1 = *(buffer + decoded) & 0xf; + decoded++; + + + guti->amfregionid = *(buffer+decoded); + decoded++; + IES_DECODE_U16(buffer, decoded, temp); + guti->amfsetid = temp>>3; + guti->amfpointer = temp&0x3f; + + IES_DECODE_U32(buffer, decoded, guti->tmsi); + return decoded; +} + + +static int encode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer) +{ + uint32_t encoded = 0; + uint16_t temp; + *(buffer + encoded) = 0xf0 | ((guti->oddeven & 0x1) << 3) | + (guti->typeofidentity & 0x7); + encoded++; + *(buffer + encoded) = 0x00 | ((guti->mccdigit2 & 0xf) << 4) | + (guti->mccdigit1 & 0xf); + encoded++; + *(buffer + encoded) = 0x00 | ((guti->mncdigit3 & 0xf) << 4) | + (guti->mccdigit3 & 0xf); + encoded++; + *(buffer + encoded) = 0x00 | ((guti->mncdigit2 & 0xf) << 4) | + (guti->mncdigit1 & 0xf); + encoded++; + + *(buffer + encoded) = guti->amfregionid; + encoded++; + + temp = 0x00 | ((guti->amfsetid & 0x3f) << 6) | (guti->amfpointer & 0x3f); + + IES_ENCODE_U16(buffer, encoded, temp); + IES_ENCODE_U32(buffer, encoded, guti->tmsi); + return encoded; +} + diff --git a/openair3/NAS/COMMON/IES/FGSMobileIdentity.h b/openair3/NAS/COMMON/IES/FGSMobileIdentity.h new file mode 100644 index 0000000000..56e41767d7 --- /dev/null +++ b/openair3/NAS/COMMON/IES/FGSMobileIdentity.h @@ -0,0 +1,113 @@ +/*! \file FGSMobileIdentity.h + +\brief 5GS Mobile Identity for registration request procedures +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + +#include "OctetString.h" + +#ifndef FGS_MOBILE_IDENTITY_H_ +#define FGS_MOBILE_IDENTITY_H_ + + +typedef struct { + uint8_t spare:5; + uint8_t typeofidentity:3; +} NoIdentity5GSMobileIdentity_t; + +typedef struct { + uint8_t spare1:1; + uint8_t supiformat:3; + uint8_t spare2:1; + uint8_t typeofidentity:3; + uint8_t mccdigit2:4; + uint8_t mccdigit1:4; + uint8_t mncdigit3:4; + uint8_t mccdigit3:4; + uint8_t mncdigit2:4; + uint8_t mncdigit1:4; + uint8_t routingindicatordigit2:4; + uint8_t routingindicatordigit1:4; + uint8_t routingindicatordigit4:4; + uint8_t routingindicatordigit3:4; + uint8_t spare3:1; + uint8_t spare4:1; + uint8_t spare5:1; + uint8_t spare6:1; + uint8_t protectionschemeId:4; + uint8_t homenetworkpki; +} Suci5GSMobileIdentity_t; + +typedef struct { + uint8_t spare:4; + uint8_t oddeven:1; + uint8_t typeofidentity:3; + uint8_t mccdigit2:4; + uint8_t mccdigit1:4; + uint8_t mncdigit3:4; + uint8_t mccdigit3:4; + uint8_t mncdigit2:4; + uint8_t mncdigit1:4; + uint8_t amfregionid; + uint16_t amfsetid:10; + uint16_t amfpointer:6; + uint32_t tmsi; +} Guti5GSMobileIdentity_t; + + +typedef struct { + uint8_t digit1:4; + uint8_t oddeven:1; + uint8_t typeofidentity:3; + uint8_t digitp1:4; + uint8_t digitp:4; +} Imei5GSMobileIdentity_t; + +typedef Imei5GSMobileIdentity_t Imeisv5GSMobileIdentity_t; + + +typedef struct { + uint8_t digit1:4; + uint8_t spare:1; + uint8_t typeofidentity:3; + uint16_t amfsetid:10; + uint16_t amfpointer:6; + uint32_t tmsi; +} Stmsi5GSMobileIdentity_t; + +typedef struct { + uint8_t spare:5; + uint8_t typeofidentity:3; + uint8_t macaddr; +} Macaddr5GSMobileIdentity_t; + +typedef union FGSMobileIdentity_tag { +#define FGS_MOBILE_IDENTITY_NOIDENTITY 0b000 +#define FGS_MOBILE_IDENTITY_SUCI 0b001 +#define FGS_MOBILE_IDENTITY_5G_GUTI 0b010 +#define FGS_MOBILE_IDENTITY_IMEI 0b011 +#define FGS_MOBILE_IDENTITY_5GS_TMSI 0b100 +#define FGS_MOBILE_IDENTITY_IMEISV 0b101 +#define FGS_MOBILE_IDENTITY_MAC_ADDR 0b110 + NoIdentity5GSMobileIdentity_t noidentity; + Suci5GSMobileIdentity_t suci; + Guti5GSMobileIdentity_t guti; + Imei5GSMobileIdentity_t imei; + Stmsi5GSMobileIdentity_t stmsi; + Imeisv5GSMobileIdentity_t imeisv; + Macaddr5GSMobileIdentity_t macaddress; +} FGSMobileIdentity; + +int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len); + +int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len); + +#endif /* FGS MOBILE IDENTITY_H_ */ + diff --git a/openair3/NAS/COMMON/IES/FGSRegistrationType.c b/openair3/NAS/COMMON/IES/FGSRegistrationType.c new file mode 100644 index 0000000000..4202e9c65f --- /dev/null +++ b/openair3/NAS/COMMON/IES/FGSRegistrationType.c @@ -0,0 +1,43 @@ +/*! \file FGSRegistrationType.c + +\brief 5GS Registration Type for registration request procedures +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ +#include +#include +#include + + +#include "TLVEncoder.h" +#include "TLVDecoder.h" +#include "FGSRegistrationType.h" + +int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + int decoded = 0; + if (iei > 0) { + CHECK_IEI_DECODER((*buffer & 0xf0), iei); + } + + *fgsregistrationtype = *buffer & 0x7; + decoded++; + + return decoded; +} + +int encode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype) +{ + uint8_t bufferReturn; + uint8_t *buffer = &bufferReturn; + uint8_t encoded = 0; + uint8_t iei = 0; + *(buffer + encoded) = 0x00 | (iei & 0xf0) | + (*fgsregistrationtype & 0x7); + encoded++; + + return bufferReturn; +} + diff --git a/openair3/NAS/COMMON/IES/FGSRegistrationType.h b/openair3/NAS/COMMON/IES/FGSRegistrationType.h new file mode 100644 index 0000000000..b9fee868fb --- /dev/null +++ b/openair3/NAS/COMMON/IES/FGSRegistrationType.h @@ -0,0 +1,35 @@ +/*! \file FGSRegistrationType.h + +\brief 5GS Registration Type for registration request procedures +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ +#include +#include +#include + +#include "OctetString.h" + +#ifndef FGS_REGISTRATION_TYPE_H_ +#define FGS_REGISTRATION_TYPE_H_ + +#define FGS_REGISTRATION_TYPE_MINIMUM_LENGTH 1 +#define FGS_REGISTRATION_TYPE_MAXIMUM_LENGTH 1 + +typedef uint8_t FGSRegistrationType; + + +#define INITIAL_REGISTRATION 0b001 +#define MOBILITY_REGISTRATION_UPDATING 0b010 +#define PERIODIC_REGISTRATION_UPDATING 0b011 +#define EMERGENCY_REGISTRATION 0b100 + +int encode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype); + +int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8_t iei, uint8_t *buffer, uint32_t len); + + +#endif /* FGS_REGISTRATION_TYPE_H_*/ + diff --git a/openair3/NAS/COMMON/IES/SpareHalfOctet.c b/openair3/NAS/COMMON/IES/SpareHalfOctet.c new file mode 100644 index 0000000000..afbb9f4f12 --- /dev/null +++ b/openair3/NAS/COMMON/IES/SpareHalfOctet.c @@ -0,0 +1,28 @@ +/*! \file SpareHalfOctet.c + +\brief registration request procedures for gNB +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + + +#include "TLVEncoder.h" +#include "TLVDecoder.h" +#include "SpareHalfOctet.h" + +int decode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + return 0; +} + +int encode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len) +{ + return 0; +} + diff --git a/openair3/NAS/COMMON/IES/SpareHalfOctet.h b/openair3/NAS/COMMON/IES/SpareHalfOctet.h new file mode 100644 index 0000000000..f0f0b8047f --- /dev/null +++ b/openair3/NAS/COMMON/IES/SpareHalfOctet.h @@ -0,0 +1,29 @@ +/*! \file SpareHalfOctet.h + +\brief registration request procedures for gNB +\author Yoshio INOUE, Masayuki HARADA +\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com +\date 2020 +\version 0.1 +*/ + +#include +#include +#include + +#include "OctetString.h" + +#ifndef SPARE_HALF_OCTET_H_ +#define SPARE_HALF_OCTET_H_ + +#define SPARE_HALF_OCTET_MINIMUM_LENGTH 1 +#define SPARE_HALF_OCTET_MAXIMUM_LENGTH 1 + +typedef uint8_t SpareHalfOctet; + +int encode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len); + +int decode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len); + +#endif /* SPARE HALF OCTET_H_ */ + From 592642cb28c26f76f98b8f980f9663eee21aee20 Mon Sep 17 00:00:00 2001 From: Xue Song Date: Wed, 21 Oct 2020 02:46:40 +0000 Subject: [PATCH 12/16] modify RRC messages --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 65 +++++---- openair2/RRC/NR/MESSAGES/asn1_msg.h | 2 +- openair2/RRC/NR/rrc_gNB.c | 204 ++++++++++++++++++---------- 3 files changed, 170 insertions(+), 101 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index f1682d0674..4c05f60cc6 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -41,6 +41,7 @@ #include #include "asn1_msg.h" +#include "../nr_rrc_proto.h" #include "RRC/NR/nr_rrc_extern.h" #include "NR_DL-CCCH-Message.h" #include "NR_DL-DCCH-Message.h" @@ -627,12 +628,12 @@ uint8_t do_RRCReject(uint8_t Mod_id, 100); if(enc_rval.encoded == -1) { - LOG_E(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + LOG_E(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } - LOG_D(RRC,"RRCReject Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"RRCReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } @@ -758,13 +759,13 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP, 100); if(enc_rval.encoded == -1) { - LOG_E(RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", + LOG_E(NR_RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } if (OCTET_STRING_fromBuf(&ie->masterCellGroup, masterCellGroup_buf, (enc_rval.encoded+7)/8) == -1) { - LOG_E(RRC, "fatal: OCTET_STRING_fromBuf failed\n"); + LOG_E(NR_RRC, "fatal: OCTET_STRING_fromBuf failed\n"); return -1; } @@ -779,12 +780,12 @@ uint8_t do_RRCSetup(const protocol_ctxt_t *const ctxt_pP, 100); if(enc_rval.encoded == -1) { - LOG_E(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + LOG_E(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } - LOG_D(RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } @@ -852,13 +853,13 @@ uint8_t do_NR_SecurityModeCommand( /*TODO*/ //------------------------------------------------------------------------------ -uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, +uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, const uint8_t Transaction_id) //------------------------------------------------------------------------------ { NR_DL_DCCH_Message_t dl_dcch_msg; - NR_UE_CapabilityRAT_Request_t ue_capabilityrat_request; + NR_UE_CapabilityRAT_Request_t *ue_capabilityrat_request; asn_enc_rval_t enc_rval; memset(&dl_dcch_msg,0,sizeof(NR_DL_DCCH_Message_t)); @@ -868,11 +869,13 @@ uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry = CALLOC(1,sizeof(struct NR_UECapabilityEnquiry)); dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->rrc_TransactionIdentifier = Transaction_id; dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->criticalExtensions.present = NR_UECapabilityEnquiry__criticalExtensions_PR_ueCapabilityEnquiry; - ue_capabilityrat_request.rat_Type = NR_RAT_Type_nr; - + dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry = CALLOC(1,sizeof(struct NR_UECapabilityEnquiry_IEs)); + ue_capabilityrat_request = CALLOC(1,sizeof(NR_UE_CapabilityRAT_Request_t)); + memset(ue_capabilityrat_request,0,sizeof(NR_UE_CapabilityRAT_Request_t)); + ue_capabilityrat_request->rat_Type = NR_RAT_Type_nr; ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1->choice.ueCapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list, - &ue_capabilityrat_request); + ue_capabilityrat_request); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { @@ -886,19 +889,19 @@ uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, 100); if(enc_rval.encoded == -1) { - LOG_I(RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + LOG_I(NR_RRC, "[gNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); return -1; } - LOG_D(RRC,"[gNB %d] NR UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", + LOG_D(NR_RRC,"[gNB %d] NR UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, ctxt_pP->rnti, enc_rval.encoded, (enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { - LOG_E(RRC,"[eNB %d] ASN1 : NR UECapabilityRequest encoding failed for UE %x\n", + LOG_E(NR_RRC,"[gNB %d] ASN1 : NR UECapabilityRequest encoding failed for UE %x\n", ctxt_pP->module_id, ctxt_pP->rnti); return(-1); @@ -948,6 +951,7 @@ uint16_t do_RRCReconfiguration( NR_DRB_ToAddModList_t *DRB_configList = NULL; NR_DRB_ToAddModList_t *DRB_configList2 = NULL; NR_DRB_ToAddMod_t *DRB_config = NULL; + NR_SDAP_Config_t *sdap_config = NULL; NR_SecurityConfig_t *security_config = NULL; NR_DedicatedNAS_Message_t *dedicatedNAS_Message = NULL; @@ -999,6 +1003,9 @@ uint16_t do_RRCReconfiguration( DRB_config->cnAssociation = CALLOC(1, sizeof(*DRB_config->cnAssociation)); DRB_config->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_sdap_Config; // TODO sdap_Config + sdap_config = CALLOC(1, sizeof(NR_SDAP_Config_t)); + memset(sdap_config, 0, sizeof(NR_SDAP_Config_t)); + DRB_config->cnAssociation->choice.sdap_Config = sdap_config; // TODO pdcp_Config DRB_config->reestablishPDCP = NULL; DRB_config->recoverPDCP = NULL; @@ -1026,12 +1033,12 @@ uint16_t do_RRCReconfiguration( ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config); /* Configure Security */ - security_config = CALLOC(1, sizeof(NR_SecurityConfig_t)); - security_config->securityAlgorithmConfig = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->securityAlgorithmConfig)); - security_config->securityAlgorithmConfig->cipheringAlgorithm = NR_CipheringAlgorithm_nea0; - security_config->securityAlgorithmConfig->integrityProtAlgorithm = NULL; - security_config->keyToUse = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->keyToUse)); - *security_config->keyToUse = NR_SecurityConfig__keyToUse_master; + // security_config = CALLOC(1, sizeof(NR_SecurityConfig_t)); + // security_config->securityAlgorithmConfig = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->securityAlgorithmConfig)); + // security_config->securityAlgorithmConfig->cipheringAlgorithm = NR_CipheringAlgorithm_nea0; + // security_config->securityAlgorithmConfig->integrityProtAlgorithm = NULL; + // security_config->keyToUse = CALLOC(1, sizeof(*ie->radioBearerConfig->securityConfig->keyToUse)); + // *security_config->keyToUse = NR_SecurityConfig__keyToUse_master; ie = calloc(1, sizeof(NR_RRCReconfiguration_IEs_t)); ie->radioBearerConfig = calloc(1, sizeof(NR_RadioBearerConfig_t)); @@ -1042,13 +1049,13 @@ uint16_t do_RRCReconfiguration( ie->radioBearerConfig->drb_ToReleaseList = NULL; /******************** Secondary Cell Group ********************/ - rrc_gNB_carrier_data_t *carrier = &(gnb_rrc_inst->carrier); - fill_default_secondaryCellGroup( carrier->servingcellconfigcommon, - ue_context_pP->ue_context.secondaryCellGroup, - 1, - 1, - carrier->pdsch_AntennaPorts, - carrier->initial_csi_index[gnb_rrc_inst->Nb_ue]); + // rrc_gNB_carrier_data_t *carrier = &(gnb_rrc_inst->carrier); + // fill_default_secondaryCellGroup( carrier->servingcellconfigcommon, + // ue_context_pP->ue_context.secondaryCellGroup, + // 1, + // 1, + // carrier->pdsch_AntennaPorts, + // carrier->initial_csi_index[gnb_rrc_inst->Nb_ue]); /******************** Meas Config ********************/ // measConfig @@ -1065,6 +1072,10 @@ uint16_t do_RRCReconfiguration( dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie; + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); + } + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, (void *)&dl_dcch_msg, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index fa424fb7a4..44fee4c52f 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -99,7 +99,7 @@ uint8_t do_NR_SecurityModeCommand( const uint8_t cipheringAlgorithm, NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm); -uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, +uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, const uint8_t Transaction_id); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index aa814bdb5c..091c3c312f 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -86,6 +86,9 @@ #include "executables/softmodem-common.h" #include +#include "BIT_STRING.h" +#include "assertions.h" + //#define XER_PRINT extern RAN_CONTEXT_t RC; @@ -112,6 +115,8 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); +static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn); + mui_t rrc_gNB_mui = 0; ///---------------------------------------------------------------------------------------------------------------/// @@ -474,7 +479,11 @@ rrc_gNB_process_RRCSetupComplete( // T_INT(ctxt_pP->subframe), // T_INT(ctxt_pP->rnti)); - rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); + // if (AMF_MODE_ENABLED) { + // rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); + // } else { + rrc_gNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP); + // } } //----------------------------------------------------------------------------- @@ -552,15 +561,15 @@ rrc_gNB_process_RRCReconfigurationComplete( NR_DRB_Identity_t *drb_id_p = NULL; ue_context_pP->ue_context.ue_reestablishment_timer = 0; - rnti_t rnti = ue_context_pP->ue_id_rnti; - module_id_t module_id = ctxt_pP->module_id; + // rnti_t rnti = ue_context_pP->ue_id_rnti; + // module_id_t module_id = ctxt_pP->module_id; - int UE_id_mac = find_UE_id(module_id, rnti); + // int UE_id_mac = find_UE_id(module_id, rnti); - if (UE_id_mac == -1) { - LOG_E(RRC, "Can't find UE_id(MAC) of UE rnti %x\n", rnti); - return; - } + // if (UE_id_mac == -1) { + // LOG_E(RRC, "Can't find UE_id(MAC) of UE rnti %x\n", rnti); + // return; + // } /* Derive the keys from kgnb */ if (DRB_configList != NULL) { @@ -581,24 +590,49 @@ rrc_gNB_process_RRCReconfigurationComplete( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti); - nr_rrc_pdcp_config_asn1_req(ctxt_pP, - SRB_configList, // NULL, - DRB_configList, - DRB_Release_configList2, - 0xff, // already configured during the securitymodecommand - kRRCenc, - kRRCint, - kUPenc, - NULL, - NULL, - NULL); - /* Refresh SRBs/DRBs */ - nr_rrc_rlc_config_asn1_req(ctxt_pP, - SRB_configList, // NULL, - DRB_configList, - DRB_Release_configList2, - NULL, - NULL); + // nr_rrc_pdcp_config_asn1_req(ctxt_pP, + // SRB_configList, // NULL, + // DRB_configList, + // DRB_Release_configList2, + // 0xff, // already configured during the securitymodecommand + // kRRCenc, + // kRRCint, + // kUPenc, + // NULL, + // NULL, + // NULL); + // /* Refresh SRBs/DRBs */ + // nr_rrc_rlc_config_asn1_req(ctxt_pP, + // SRB_configList, // NULL, + // DRB_configList, + // DRB_Release_configList2, + // NULL, + // NULL); + + /* Set the SRB active in UE context */ + if (SRB_configList != NULL) { + for (int i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { + if (SRB_configList->list.array[i]->srb_Identity == 1) { + ue_context_pP->ue_context.Srb1.Active = 1; + } else if (SRB_configList->list.array[i]->srb_Identity == 2) { + ue_context_pP->ue_context.Srb2.Active = 1; + ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; + LOG_I(NR_RRC,"[gNB %d] Frame %d CC %d : SRB2 is now active\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ue_context_pP->ue_context.primaryCC_id); + } else { + LOG_W(NR_RRC,"[gNB %d] Frame %d CC %d : invalide SRB identity %ld\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ue_context_pP->ue_context.primaryCC_id, + SRB_configList->list.array[i]->srb_Identity); + } + } + + free(SRB_configList); + ue_context_pP->ue_context.SRB_configList2[xid] = NULL; + } /* Loop through DRBs and establish if necessary */ if (DRB_configList != NULL) { @@ -762,7 +796,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, return -1; } - uint64_t s_tmsi_part1 = BIT_STRING_to_uint64(&rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1); + uint64_t s_tmsi_part1 = bitStr_to_uint64(&rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1); // memcpy(((uint8_t *) & random_value) + 3, // rrcSetupRequest->ue_Identity.choice.ng_5G_S_TMSI_Part1.buf, @@ -846,6 +880,29 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, return 0; } +/*! \fn uint64_t bitStr_to_uint64(BIT_STRING_t *) + *\brief This function extract at most a 64 bits value from a BIT_STRING_t object, the exact bits number depend on the BIT_STRING_t contents. + *\param[in] pointer to the BIT_STRING_t object. + *\return the extracted value. + */ +static inline uint64_t bitStr_to_uint64(BIT_STRING_t *asn) { + uint64_t result = 0; + int index; + int shift; + + DevCheck ((asn->size > 0) && (asn->size <= 8), asn->size, 0, 0); + + shift = ((asn->size - 1) * 8) - asn->bits_unused; + for (index = 0; index < (asn->size - 1); index++) { + result |= (uint64_t)asn->buf[index] << shift; + shift -= 8; + } + + result |= asn->buf[index] >> asn->bits_unused; + + return result; +} + //----------------------------------------------------------------------------- int rrc_gNB_decode_dcch( @@ -974,43 +1031,50 @@ rrc_gNB_decode_dcch( if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.present == NR_RRCSetupComplete__criticalExtensions_PR_rrcSetupComplete) { if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI_Part2) { - // ng-5G-S-TMSI-Part2 BIT STRING (SIZE (9)) + rrcSetupComplete->ng_5G_S_TMSI_Value != NULL) { if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size != 2) { - LOG_E(NR_RRC, "wrong ng_5G_S_TMSI_Part2 size, expected 2, provided %lu", - (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete-> - ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size); - return -1; - } + rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI_Part2) { + // ng-5G-S-TMSI-Part2 BIT STRING (SIZE (9)) + if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. + rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size != 2) { + LOG_E(NR_RRC, "wrong ng_5G_S_TMSI_Part2 size, expected 2, provided %lu", + (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete-> + ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2.size); + return -1; + } - if (ue_context_p->ue_context.ng_5G_S_TMSI_Part1 != 0) { - ue_context_p->ue_context.ng_5G_S_TMSI_Part2 = - BIT_STRING_to_uint16(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete-> - ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2); - } + if (ue_context_p->ue_context.ng_5G_S_TMSI_Part1 != 0) { + ue_context_p->ue_context.ng_5G_S_TMSI_Part2 = + BIT_STRING_to_uint16(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete-> + ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2); + } - /* TODO */ - } else if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI) { - // NG-5G-S-TMSI ::= BIT STRING (SIZE (48)) - if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. - rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size != 6) { - LOG_E(NR_RRC, "wrong ng_5G_S_TMSI size, expected 6, provided %lu", - (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete-> - ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size); - return -1; - } + /* TODO */ + } else if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. + rrcSetupComplete->ng_5G_S_TMSI_Value->present == NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI) { + // NG-5G-S-TMSI ::= BIT STRING (SIZE (48)) + if (ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete->criticalExtensions.choice. + rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size != 6) { + LOG_E(NR_RRC, "wrong ng_5G_S_TMSI size, expected 6, provided %lu", + (long unsigned int)ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete-> + ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size); + return -1; + } - uint64_t fiveg_s_TMSI = BIT_STRING_to_uint16(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> - criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI); - if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_set_id = fiveg_s_TMSI >> 38; - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_pointer = (fiveg_s_TMSI >> 32) & 0x3F; - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.fiveg_tmsi = (uint32_t)fiveg_s_TMSI; + uint64_t fiveg_s_TMSI = bitStr_to_uint64(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> + criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI); + LOG_I(NR_RRC, "Received rrcSetupComplete, 5g_s_TMSI: 0x%lX, amf_set_id: 0x%lX(%ld), amf_pointer: 0x%lX(%ld), 5g TMSI: 0x%X \n", + fiveg_s_TMSI, fiveg_s_TMSI >> 38, fiveg_s_TMSI >> 38, + (fiveg_s_TMSI >> 32) & 0x3F, (fiveg_s_TMSI >> 32) & 0x3F, + (uint32_t)fiveg_s_TMSI); + if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_set_id = fiveg_s_TMSI >> 38; + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.amf_pointer = (fiveg_s_TMSI >> 32) & 0x3F; + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.fiveg_tmsi = (uint32_t)fiveg_s_TMSI; + } } } @@ -1109,6 +1173,11 @@ rrc_gNB_decode_dcch( ue_context_p->ue_context.UE_Capability_size = ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size; + if(eutra_index != -1){ + LOG_E(NR_RRC,"fatal: more than 1 eutra capability\n"); + exit(1); + } + eutra_index = i; } if(ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == @@ -1140,11 +1209,7 @@ rrc_gNB_decode_dcch( if(ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->rat_Type == NR_RAT_Type_eutra){ - if(eutra_index == -1){ - LOG_E(NR_RRC,"fatal: more than 1 eutra capability\n"); - exit(1); - } - eutra_index = i; + //TODO } } @@ -1234,13 +1299,6 @@ void *rrc_gnb_task(void *args_p) { NR_RRC_DCCH_DATA_IND(msg_p).dcch_index, NR_RRC_DCCH_DATA_IND(msg_p).sdu_p, NR_RRC_DCCH_DATA_IND(msg_p).sdu_size); - // Message buffer has been processed, free it now. - result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), NR_RRC_DCCH_DATA_IND(msg_p).sdu_p); - - if (result != EXIT_SUCCESS) { - LOG_I(NR_RRC, "Failed to free memory (%d)!\n", result); - break; - } break; @@ -1393,7 +1451,7 @@ rrc_gNB_generate_UECapabilityEnquiry( uint8_t size; T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - size = do_NR_UECapabilityEnquiry_nr( + size = do_NR_SA_UECapabilityEnquiry( ctxt_pP, buffer, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id)); From bfd2c35c350c6ac271b59039f6a9077aab47a0fb Mon Sep 17 00:00:00 2001 From: yaojie Date: Wed, 21 Oct 2020 07:30:20 +0000 Subject: [PATCH 13/16] fix warning/error --- cmake_targets/CMakeLists.txt | 8 -- .../NR_MAC_UE/nr_ue_dci_configuration.c | 6 +- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 26 ++--- openair2/RRC/NR/MESSAGES/asn1_msg.c | 16 +-- openair2/RRC/NR/MESSAGES/asn1_msg.h | 4 +- openair2/RRC/NR/nr_rrc_defs.h | 2 +- openair2/RRC/NR/rrc_gNB.c | 32 +++++- openair2/RRC/NR_UE/rrc_UE.c | 105 +++++++++++++----- openair2/RRC/NR_UE/rrc_defs.h | 1 + 9 files changed, 132 insertions(+), 68 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 933b1c59df..e62b13462b 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -3329,14 +3329,6 @@ add_executable(nr-ittisim ${SHLIB_LOADER_SOURCES} ) -#target_link_libraries (nr-ittisim -# -Wl,--start-group -# UTIL HASHTABLE SCTP_CLIENT UDP LFDS NR_GTPV1U SECU_CN SECU_OSA -# ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB -# NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB -# X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} -# -Wl,--end-group z dl) - target_link_libraries (nr-ittisim -Wl,--start-group UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS NR_GTPV1U SECU_CN SECU_OSA diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 2285fc5999..8020cfd79b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -66,9 +66,9 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id, uint8_t dci_format){ - uint16_t monitoringSymbolsWithinSlot; + uint16_t monitoringSymbolsWithinSlot = 0; uint8_t bwp_id = 1, coreset_id = 1; - int sps; + int sps = 0; def_dci_pdu_rel15 = calloc(1,sizeof(dci_pdu_rel15_t)); AssertFatal(mac->scc != NULL, "scc is null\n"); NR_ServingCellConfigCommon_t *scc = mac->scc; @@ -184,7 +184,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl int ss_id; uint8_t bwp_id = 1, coreset_id = 1; - NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; + //NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated; NR_BWP_Downlink_t *bwp = mac->DLbwp[bwp_id - 1]; #ifdef DEBUG_DCI diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ab533af941..911742ae1b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1275,7 +1275,7 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, (dynamic_prb_BundlingType2==dy_2_n4)||(dynamic_prb_BundlingType2==dy_2_wideband)) prb_BundlingType_size=1; // 15 RATE_MATCHING_IND FIXME!!! - // according to TS 38.212: Rate matching indicator – 0, 1, or 2 bits according to higher layer parameter rateMatchPattern + // according to TS 38.212: Rate matching indicator  E0, 1, or 2 bits according to higher layer parameter rateMatchPattern uint8_t rateMatching_bits = pdsch_config.n_rateMatchPatterns; // 16 ZP_CSI_RS_TRIGGER FIXME!!! // 0, 1, or 2 bits as defined in Subclause 5.1.4.2 of [6, TS 38.214]. @@ -1418,7 +1418,7 @@ uint16_t nr_dci_format_size (PHY_VARS_NR_UE *ue, // 2 bits otherwise uint8_t ptrs_dmrs_bits=0; //FIXME!!! // 46 BETA_OFFSET_IND - // at IE PUSCH-Config, beta_offset indicator – 0 if the higher layer parameter betaOffsets = semiStatic; otherwise 2 bits + // at IE PUSCH-Config, beta_offset indicator  E0 if the higher layer parameter betaOffsets = semiStatic; otherwise 2 bits // uci-OnPUSCH // Selection between and configuration of dynamic and semi-static beta-offset. If the field is absent or released, the UE applies the value 'semiStatic' and the BetaOffsets uint8_t betaOffsets = 0; @@ -3289,10 +3289,10 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, case NR_RNTI_P: /* - // Short Messages Indicator – 2 bits + // Short Messages Indicator  E2 bits for (int i=0; i<2; i++) dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages_indicator>>(1-i))&1)<<(dci_size-pos++); - // Short Messages – 8 bits + // Short Messages  E8 bits for (int i=0; i<8; i++) *dci_pdu |= (((uint64_t)dci_pdu_rel15->short_messages>>(7-i))&1)<<(dci_size-pos++); // Freq domain assignment 0-16 bit @@ -3359,13 +3359,13 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // HARQ process number 4bit pos+=4; dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; - // Downlink assignment index – 2 bits + // Downlink assignment index  E2 bits pos+=2; dci_pdu_rel15->dai[0].val = (*dci_pdu>>(dci_size-pos))&3; - // TPC command for scheduled PUCCH – 2 bits + // TPC command for scheduled PUCCH  E2 bits pos+=2; dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; - // PDSCH-to-HARQ_feedback timing indicator – 3 bits + // PDSCH-to-HARQ_feedback timing indicator  E3 bits pos+=3; dci_pdu_rel15->pdsch_to_harq_feedback_timing_indicator.val = (*dci_pdu>>(dci_size-pos))&7; @@ -3386,7 +3386,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // Time domain assignment 4bit pos+=4; dci_pdu_rel15->time_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&0xf; - // Frequency hopping flag – 1 bit + // Frequency hopping flag  E1 bit pos++; dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1; // MCS 5 bit @@ -3401,10 +3401,10 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // HARQ process number 4bit pos+=4; dci_pdu_rel15->harq_pid = (*dci_pdu>>(dci_size-pos))&0xf; - // TPC command for scheduled PUSCH – 2 bits + // TPC command for scheduled PUSCH  E2 bits pos+=2; dci_pdu_rel15->tpc = (*dci_pdu>>(dci_size-pos))&3; - // UL/SUL indicator – 1 bit + // UL/SUL indicator  E1 bit /* commented for now (RK): need to get this from BWP descriptor if (cfg->pucch_config.pucch_GroupHopping.value) dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)ul_sul_indicator&1)<<(dci_size-pos++); @@ -3422,7 +3422,7 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // Time domain assignment 4bit for (int i=0; i<4; i++) dci_pdu->= (((uint64_t)*dci_pdu>>(dci_size-pos)time_domain_assignment>>(3-i))&1)<<(dci_size-pos++); - // Frequency hopping flag – 1 bit + // Frequency hopping flag  E1 bit dci_pdu->= ((uint64_t)*dci_pdu>>(dci_size-pos)frequency_hopping_flag&1)<<(dci_size-pos++); // MCS 5 bit for (int i=0; i<5; i++) @@ -3436,11 +3436,11 @@ void nr_extract_dci_info(NR_UE_MAC_INST_t *mac, for (int i=0; i<4; i++) *dci_pdu |= (((uint64_t)*dci_pdu>>(dci_size-pos)harq_pid>>(3-i))&1)<<(dci_size-pos++); - // TPC command for scheduled PUSCH – 2 bits + // TPC command for scheduled PUSCH  E2 bits for (int i=0; i<2; i++) dci_pdu->= (((uint64_t)*dci_pdu>>(dci_size-pos)tpc>>(1-i))&1)<<(dci_size-pos++); */ - // UL/SUL indicator – 1 bit + // UL/SUL indicator  E1 bit /* commented for now (RK): need to get this information from BWP descriptor if (cfg->pucch_config.pucch_GroupHopping.value) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 9e9299e956..e6be4365d6 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1073,6 +1073,7 @@ uint16_t do_RRCReconfiguration( dedicatedNAS_Message = calloc(1, sizeof(NR_DedicatedNAS_Message_t)); dedicatedNAS_Message->buf = ue_context_pP->ue_context.nas_pdu.buffer; dedicatedNAS_Message->size = ue_context_pP->ue_context.nas_pdu.length; + ie->nonCriticalExtension->dedicatedNAS_MessageList = calloc(1, sizeof(struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList)); ASN_SEQUENCE_ADD(&ie->nonCriticalExtension->dedicatedNAS_MessageList->list, dedicatedNAS_Message); dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie; @@ -1106,15 +1107,6 @@ uint16_t do_RRCReconfiguration( return(-1); } -#ifdef ITTI_SIM - MessageDef *message_p; - message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); - GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; - GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded+7)/8; - itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); -#endif - return((enc_rval.encoded+7)/8); } @@ -1192,9 +1184,9 @@ do_NR_RRCReconfigurationComplete( NR_RRCReconfigurationComplete__criticalExtensions_PR_rrcReconfigurationComplete; rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->nonCriticalExtension = NULL; rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->lateNonCriticalExtension = NULL; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - } + //} enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, @@ -1203,7 +1195,7 @@ do_NR_RRCReconfigurationComplete( 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - LOG_D(NR_RRC,"rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_I(NR_RRC,"rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index c55b8dd1ec..35d726ed89 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -117,4 +117,6 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, const uint8_t Transaction_id, uint8_t sel_plmn_id, const int dedicatedInfoNASLength, - const char *dedicatedInfoNAS); \ No newline at end of file + const char *dedicatedInfoNAS); + +uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); \ No newline at end of file diff --git a/openair2/RRC/NR/nr_rrc_defs.h b/openair2/RRC/NR/nr_rrc_defs.h index a9a8c80ed1..596180e793 100644 --- a/openair2/RRC/NR/nr_rrc_defs.h +++ b/openair2/RRC/NR/nr_rrc_defs.h @@ -150,7 +150,7 @@ typedef struct UE_RRC_INFO_NR_s { uint32_t SIStatus; uint32_t SIcnt; uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA - uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40 + uint16_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40 uint8_t handoverTarget; //HO_STATE_t ho_state; uint16_t diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 64c134073d..37a5d7420d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -576,8 +576,8 @@ rrc_gNB_process_RRCReconfigurationComplete( NR_DRB_Identity_t *drb_id_p = NULL; ue_context_pP->ue_context.ue_reestablishment_timer = 0; - rnti_t rnti = ue_context_pP->ue_id_rnti; - module_id_t module_id = ctxt_pP->module_id; + //rnti_t rnti = ue_context_pP->ue_id_rnti; + //module_id_t module_id = ctxt_pP->module_id; // int UE_id_mac = find_UE_id(module_id, rnti); @@ -625,6 +625,31 @@ rrc_gNB_process_RRCReconfigurationComplete( // NULL); /* Loop through DRBs and establish if necessary */ + /* Set the SRB active in UE context */ + if (SRB_configList != NULL) { + for (int i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { + if (SRB_configList->list.array[i]->srb_Identity == 1) { + ue_context_pP->ue_context.Srb1.Active = 1; + } else if (SRB_configList->list.array[i]->srb_Identity == 2) { + ue_context_pP->ue_context.Srb2.Active = 1; + ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; + LOG_I(NR_RRC,"[gNB %d] Frame %d CC %d : SRB2 is now active\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ue_context_pP->ue_context.primaryCC_id); + } else { + LOG_W(NR_RRC,"[gNB %d] Frame %d CC %d : invalide SRB identity %ld\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ue_context_pP->ue_context.primaryCC_id, + SRB_configList->list.array[i]->srb_Identity); + } + } + + free(SRB_configList); + ue_context_pP->ue_context.SRB_configList2[xid] = NULL; + } + if (DRB_configList != NULL) { for (int i = 0; i < DRB_configList->list.count; i++) { if (DRB_configList->list.array[i]) { @@ -1057,7 +1082,7 @@ rrc_gNB_decode_dcch( uint64_t fiveg_s_TMSI = bitStr_to_uint64(&ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete-> criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI); - LOG_I(NR_RRC, "Received rrcSetupComplete, 5g_s_TMSI: 0x%lX, amf_set_id: 0x%lX(%d), amf_pointer: 0x%lX(%d), 5g TMSI: 0x%X \n", + LOG_I(NR_RRC, "Received rrcSetupComplete, 5g_s_TMSI: 0x%lX, amf_set_id: 0x%lX(%ld), amf_pointer: 0x%lX(%ld), 5g TMSI: 0x%X \n", fiveg_s_TMSI, fiveg_s_TMSI >> 38, fiveg_s_TMSI >> 38, (fiveg_s_TMSI >> 32) & 0x3F, (fiveg_s_TMSI >> 32) & 0x3F, (uint32_t)fiveg_s_TMSI); @@ -1102,6 +1127,7 @@ rrc_gNB_decode_dcch( // } rrc_gNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); + //rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); break; case NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index aa1dd20d13..78591d46f1 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -60,19 +60,67 @@ #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#ifndef CELLULAR + #include "RRC/NR/MESSAGES/asn1_msg.h" +#endif + +#include "RRC/NAS/nas_config.h" +#include "RRC/NAS/rb_config.h" +#include "SIMULATION/TOOLS/sim.h" // for taus + +/* NAS Attach request with IMSI */ +static const char nr_nas_attach_req_imsi[] = { + 0x07, 0x41, + /* EPS Mobile identity = IMSI */ + 0x71, 0x08, 0x29, 0x80, 0x43, 0x21, 0x43, 0x65, 0x87, + 0xF9, + /* End of EPS Mobile Identity */ + 0x02, 0xE0, 0xE0, 0x00, 0x20, 0x02, 0x03, + 0xD0, 0x11, 0x27, 0x1A, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00, + 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2, + 0x01, 0x27, 0x11, +}; + +extern void pdcp_config_set_security( + const protocol_ctxt_t *const ctxt_pP, + pdcp_t *const pdcp_pP, + const rb_id_t rb_idP, + const uint16_t lc_idP, + const uint8_t security_modeP, + uint8_t *const kRRCenc, + uint8_t *const kRRCint, + uint8_t *const kUPenc +); + +void +nr_rrc_ue_process_ueCapabilityEnquiry( + const protocol_ctxt_t *const ctxt_pP, + NR_UECapabilityEnquiry_t *UECapabilityEnquiry, + uint8_t gNB_index +); + +void +nr_sa_rrc_ue_process_radioBearerConfig( + const protocol_ctxt_t *const ctxt_pP, + const uint8_t gNB_index, + NR_RadioBearerConfig_t *const radioBearerConfig +); + + mui_t nr_rrc_mui=0; -static Rrc_State_t nr_rrc_get_state (module_id_t ue_mod_idP) { +static Rrc_State_NR_t nr_rrc_get_state (module_id_t ue_mod_idP) { return NR_UE_rrc_inst[ue_mod_idP].nrRrcState; } -static Rrc_Sub_State_t nr_rrc_get_sub_state (module_id_t ue_mod_idP) { +static Rrc_Sub_State_NR_t nr_rrc_get_sub_state (module_id_t ue_mod_idP) { return NR_UE_rrc_inst[ue_mod_idP].nrRrcSubState; } -static int nr_rrc_set_state (module_id_t ue_mod_idP, Rrc_State_t state) { - AssertFatal ((RRC_STATE_FIRST <= state) && (state <= RRC_STATE_LAST), +static int nr_rrc_set_state (module_id_t ue_mod_idP, Rrc_State_NR_t state) { + AssertFatal ((RRC_STATE_FIRST_NR <= state) && (state <= RRC_STATE_LAST_NR), "Invalid state %d!\n", state); if (NR_UE_rrc_inst[ue_mod_idP].nrRrcState != state) { @@ -518,12 +566,12 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( return 0; } -static const char siWindowLength[10][5] = {"5s", "10s", "20s", "40s", "80s", "160s", "320s", "640s", "1280s","ERR"};// {"1ms","2ms","5ms","10ms","15ms","20ms","40ms","80ms","ERR"}; -static const char siWindowLength_int[9] = {5,10,20,40,80,160,320,640,1280};//{1,2,5,10,15,20,40,80}; +const char siWindowLength[10][5] = {"5s", "10s", "20s", "40s", "80s", "160s", "320s", "640s", "1280s","ERR"};// {"1ms","2ms","5ms","10ms","15ms","20ms","40ms","80ms","ERR"}; +const short siWindowLength_int[9] = {5,10,20,40,80,160,320,640,1280};//{1,2,5,10,15,20,40,80}; -static const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","SIB10","SIB11","SIB12","SIB13","Spare"}; -static const char SIBPeriod[8][6]= {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"}; -static int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; +const char SIBType[12][6] = {"SIB3","SIB4","SIB5","SIB6","SIB7","SIB8","SIB9","SIB10","SIB11","SIB12","SIB13","Spare"}; +const char SIBPeriod[8][6] = {"rf8","rf16","rf32","rf64","rf128","rf256","rf512","ERR"}; +int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; const char *nr_SIBreserved( long value ) { if (value < 0 || value > 1) @@ -971,7 +1019,7 @@ int nr_decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_inde LOG_I( RRC, "[UE %d] : Dumping SIB 1\n", ctxt_pP->module_id ); const int n = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.count; for (int i = 0; i < n; ++i) { - NR_PLMN_Identity_t *PLMN_identity = &sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[i]->plmn_IdentityList.list.array[0]; + NR_PLMN_Identity_t *PLMN_identity = sib1->cellAccessRelatedInfo.plmn_IdentityList.list.array[i]->plmn_IdentityList.list.array[0]; int mccdigits = PLMN_identity->mcc->list.count; int mncdigits = PLMN_identity->mnc.list.count; @@ -1131,7 +1179,7 @@ int nr_decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t gNB_inde itti_send_msg_to_task(TASK_PHY_UE, ctxt_pP->instance, msg_p); LOG_E(RRC, "Synched with a cell, but PLMN doesn't match our SIM " - "(selected_plmn_identity %d), the message PHY_FIND_NEXT_CELL_REQ " + "(selected_plmn_identity %ld), the message PHY_FIND_NEXT_CELL_REQ " "is sent but lost in current UE implementation!\n", NR_UE_rrc_inst[ctxt_pP->module_id].selected_plmn_identity); } @@ -1297,15 +1345,13 @@ static void rrc_ue_generate_RRCSetupComplete( uint8_t size; const char *nas_msg; int nas_msg_length; - /* - if (EPC_MODE_ENABLED) { - nas_msg = (char *) UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; - nas_msg_length = UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; - } else { - nas_msg = nas_attach_req_imsi; - nas_msg_length = sizeof(nas_attach_req_imsi); - } - */ + if (AMF_MODE_ENABLED) { + nas_msg = (char *) NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; + nas_msg_length = NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; + } else { + nas_msg = nr_nas_attach_req_imsi; + nas_msg_length = sizeof(nr_nas_attach_req_imsi); + } size = do_RRCSetupComplete(ctxt_pP->module_id,buffer,Transaction_id,sel_plmn_id,nas_msg_length,nas_msg); LOG_I(NR_RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCSetupComplete (bytes%d, gNB %d)\n", ctxt_pP->module_id,ctxt_pP->frame, size, gNB_index); @@ -1334,7 +1380,7 @@ static void rrc_ue_generate_RRCSetupComplete( #endif } -int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *const Srb_info, const uint8_t gNB_index ){ +int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB_INFO *const Srb_info, const uint8_t gNB_index ){ NR_DL_CCCH_Message_t *dl_ccch_msg=NULL; asn_dec_rval_t dec_rval; int rval=0; @@ -1358,7 +1404,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_IN } if (dl_ccch_msg->message.present == NR_DL_CCCH_MessageType_PR_c1) { - if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State == RRC_SI_RECEIVED) { + if (NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State == NR_RRC_SI_RECEIVED) { switch (dl_ccch_msg->message.choice.c1->present) { case NR_DL_CCCH_MessageType__c1_PR_NOTHING: LOG_I(NR_RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", @@ -1635,7 +1681,7 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.present = NR_SecurityModeComplete__criticalExtensions_PR_securityModeComplete; ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete = CALLOC(1, sizeof(NR_SecurityModeComplete_IEs_t)); ul_dcch_msg.message.choice.c1->choice.securityModeComplete->criticalExtensions.choice.securityModeComplete->nonCriticalExtension =NULL; - LOG_I(NR_RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d), rrc_TransactionIdentifier: %ld\n", + LOG_I(NR_RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (gNB %d), rrc_TransactionIdentifier: %ld\n", ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index, securityModeCommand->rrc_TransactionIdentifier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, @@ -1665,7 +1711,7 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_DCCH_DATA_IND); GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = buffer; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #else @@ -2161,9 +2207,13 @@ void nr_rrc_ue_generate_RRCReconfigurationComplete( const protocol_ctxt_t *const DCCH); #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_UE_SIM,TASK_RRC_GNB_SIM,size); + memcpy (message_buffer, buffer, size); + message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_DCCH_DATA_IND); UE_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - UE_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + UE_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; UE_RRC_DCCH_DATA_IND (message_p).size = size; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #else @@ -2267,6 +2317,7 @@ nr_rrc_ue_decode_dcch( case NR_DL_DCCH_MessageType__c1_PR_spare3: case NR_DL_DCCH_MessageType__c1_PR_spare2: case NR_DL_DCCH_MessageType__c1_PR_spare1: + case NR_DL_DCCH_MessageType__c1_PR_counterCheck: break; case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: LOG_I(RRC, "[UE %d] Received securityModeCommand (gNB %d)\n", @@ -2363,13 +2414,13 @@ void *rrc_nrue_task( void *args_p ) { LOG_E(NR_RRC, "[UE %d] Received unexpected message %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); break; } - + LOG_I(NR_RRC, "[UE %d] RRC Status %d\n", ue_mod_id, nr_rrc_get_state(ue_mod_id)); result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); msg_p = NULL; } } -void *nr_rrc_ue_process_sidelink_radioResourceConfig( +void nr_rrc_ue_process_sidelink_radioResourceConfig( module_id_t Mod_idP, uint8_t gNB_index, NR_SetupRelease_SL_ConfigDedicatedNR_r16_t *sl_ConfigDedicatedNR diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index 336c663857..35f815ca8f 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -183,6 +183,7 @@ typedef struct NR_UE_RRC_INST_s { long selected_plmn_identity; Rrc_State_NR_t nrRrcState; Rrc_Sub_State_NR_t nrRrcSubState; + as_nas_info_t initialNasMsg; } NR_UE_RRC_INST_t; #endif From f3c922b1c1752f7fb09983365200853fef247fd7 Mon Sep 17 00:00:00 2001 From: zhanghuiqin Date: Thu, 22 Oct 2020 09:19:27 +0000 Subject: [PATCH 14/16] fix RRCReject --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 5 +++++ openair2/RRC/NR/rrc_gNB.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index e6be4365d6..c96819f6c2 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -619,7 +619,12 @@ uint8_t do_RRCReject(uint8_t Mod_id, dl_ccch_msg.message.choice.c1 = CALLOC(1, sizeof(struct NR_DL_CCCH_MessageType__c1)); dl_ccch_msg.message.choice.c1->present = NR_RRCReject__criticalExtensions_PR_rrcReject; + dl_ccch_msg.message.choice.c1->choice.rrcReject = CALLOC(1,sizeof(NR_RRCReject_t)); rrcReject = dl_ccch_msg.message.choice.c1->choice.rrcReject; + + rrcReject->criticalExtensions.choice.rrcReject = CALLOC(1, sizeof(struct NR_RRCReject_IEs)); + rrcReject->criticalExtensions.choice.rrcReject->waitTime = CALLOC(1, sizeof(NR_RejectWaitTime_t)); + rrcReject->criticalExtensions.present = NR_RRCReject__criticalExtensions_PR_rrcReject; rrcReject->criticalExtensions.choice.rrcReject->waitTime = &waitTime; diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 37a5d7420d..99711d0e98 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -850,7 +850,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ue_context_p->ue_context.ng_5G_S_TMSI_Part1 = s_tmsi_part1; } } - } else { + } //else { /* TODO */ LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", @@ -859,7 +859,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti), CC_id); break; - } + //} } if (ue_context_p != NULL) { From ce8567776254b952a44490c7e324071ce6c0153a Mon Sep 17 00:00:00 2001 From: Xue Song Date: Fri, 23 Oct 2020 03:42:06 +0000 Subject: [PATCH 15/16] modify some issues --- openair2/RRC/NR/rrc_gNB.c | 98 +++++++++++-------------- openair2/SIMULATION/NR_RRC/itti_sim.c | 27 +------ openair3/NGAP/ngap_gNB_nas_procedures.c | 3 + 3 files changed, 45 insertions(+), 83 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 99711d0e98..be6230e36d 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -378,33 +378,7 @@ rrc_gNB_generate_RRCSetup( PROTOCOL_NR_RRC_CTXT_UE_FMT" RRC_gNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_gNB\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - // rrc_mac_config_req_eNB( ctxt_pP->module_id, - // ue_context_pP->ue_context.primaryCC_id, - // 0,0,0,0,0, 0, - // ue_context_pP->ue_context.rnti, - // NULL, - // NULL, - // NULL, - // ue_context_pP->ue_context.physicalConfigDedicated, - // NULL, - // NULL, - // ue_context_pP->ue_context.mac_MainConfig, - // 1, - // SRB1_logicalChannelConfig, - // ue_context_pP->ue_context.measGapConfig, - // NULL, - // NULL, - // NULL, - // 0, NULL, NULL, NULL, - // 0, NULL, NULL, - // NULL, - // 0, - // NULL, - // NULL, - // NULL, - // NULL, - // NULL, - // NULL); + // rrc_mac_config_req_eNB MSC_LOG_TX_MESSAGE( MSC_RRC_GNB, @@ -462,6 +436,14 @@ rrc_gNB_generate_RRCReject( PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating NR_RRCReject (bytes %d)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), ue_p->Srb0.Tx_buffer.payload_size); + +#ifdef ITTI_SIM + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_CCCH_DATA_IND); + GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)ue_p->Srb0.Tx_buffer.Payload; + GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; + itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); +#endif } //----------------------------------------------------------------------------- @@ -479,18 +461,13 @@ rrc_gNB_process_RRCSetupComplete( LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing NR_RRCSetupComplete from UE (SRB1 Active)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); ue_context_pP->ue_context.Srb1.Active = 1; - ue_context_pP->ue_context.Status = RRC_CONNECTED; - // T(T_GNB_RRC_SETUP_COMPLETE, - // T_INT(ctxt_pP->module_id), - // T_INT(ctxt_pP->frame), - // T_INT(ctxt_pP->subframe), - // T_INT(ctxt_pP->rnti)); + ue_context_pP->ue_context.Status = NR_RRC_CONNECTED; - // if (AMF_MODE_ENABLED) { - // rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); - // } else { + if (AMF_MODE_ENABLED) { + rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); + } else { rrc_gNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP); - // } + } } //----------------------------------------------------------------------------- @@ -605,24 +582,26 @@ rrc_gNB_process_RRCReconfigurationComplete( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti); - // nr_rrc_pdcp_config_asn1_req(ctxt_pP, - // SRB_configList, // NULL, - // DRB_configList, - // DRB_Release_configList2, - // 0xff, // already configured during the securitymodecommand - // kRRCenc, - // kRRCint, - // kUPenc, - // NULL, - // NULL, - // NULL); - // /* Refresh SRBs/DRBs */ - // nr_rrc_rlc_config_asn1_req(ctxt_pP, - // SRB_configList, // NULL, - // DRB_configList, - // DRB_Release_configList2, - // NULL, - // NULL); +#ifndef ITTI_SIM + nr_rrc_pdcp_config_asn1_req(ctxt_pP, + SRB_configList, // NULL, + DRB_configList, + DRB_Release_configList2, + 0xff, // already configured during the securitymodecommand + kRRCenc, + kRRCint, + kUPenc, + NULL, + NULL, + NULL); + /* Refresh SRBs/DRBs */ + nr_rrc_rlc_config_asn1_req(ctxt_pP, + SRB_configList, // NULL, + DRB_configList, + DRB_Release_configList2, + NULL, + NULL); +#endif /* Loop through DRBs and establish if necessary */ /* Set the SRB active in UE context */ @@ -850,8 +829,13 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ue_context_p->ue_context.ng_5G_S_TMSI_Part1 = s_tmsi_part1; } } - } //else { + } else { /* TODO */ + memcpy(((uint8_t *) & random_value) + 3, + rrcSetupRequest->ue_Identity.choice.randomValue.buf, + rrcSetupRequest->ue_Identity.choice.randomValue.size); + + rrc_gNB_get_next_free_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], random_value); LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" RRCSetupRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); @@ -859,7 +843,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti), CC_id); break; - //} + } } if (ue_context_p != NULL) { diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c index db3da25e21..6d0ae5f7fc 100644 --- a/openair2/SIMULATION/NR_RRC/itti_sim.c +++ b/openair2/SIMULATION/NR_RRC/itti_sim.c @@ -584,7 +584,7 @@ int main( int argc, char **argv ) // wait for end of program printf("TYPE TO TERMINATE\n"); - usleep(10000); + usleep(100000); protocol_ctxt_t ctxt; struct rrc_gNB_ue_context_s *ue_context_p = NULL; @@ -604,31 +604,6 @@ int main( int argc, char **argv ) rrc_ue_generate_RRCSetupRequest(&ctxt, 0); -#if 0 - // test itti sim - usleep(10000); - - protocol_ctxt_t ctxt; - struct rrc_gNB_ue_context_s *ue_context_p = NULL; - - - ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[0]); - - if(ue_context_p == NULL){ - printf("ue_context_p == NULL"); - } - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, - 0, - ENB_FLAG_YES, - 0, - 0, - 0); - rrc_gNB_generate_RRCSetup(&ctxt, - ue_context_p, - 0); - // end test itti sim -#endif - printf("Entering ITTI signals handler\n"); itti_wait_tasks_end(); printf("Returned from ITTI signal handler\n"); diff --git a/openair3/NGAP/ngap_gNB_nas_procedures.c b/openair3/NGAP/ngap_gNB_nas_procedures.c index d49f6951ac..9e99051e55 100644 --- a/openair3/NGAP/ngap_gNB_nas_procedures.c +++ b/openair3/NGAP/ngap_gNB_nas_procedures.c @@ -70,6 +70,7 @@ int ngap_gNB_handle_nas_first_req( DevAssert(instance_p != NULL); memset(&pdu, 0, sizeof(pdu)); pdu.present = NGAP_NGAP_PDU_PR_initiatingMessage; + pdu.choice.initiatingMessage = (NGAP_InitiatingMessage_t *)calloc(1,sizeof(NGAP_InitiatingMessage_t)); pdu.choice.initiatingMessage->procedureCode = NGAP_ProcedureCode_id_InitialUEMessage; pdu.choice.initiatingMessage->criticality = NGAP_Criticality_ignore; pdu.choice.initiatingMessage->value.present = NGAP_InitiatingMessage__value_PR_InitialUEMessage; @@ -220,6 +221,8 @@ int ngap_gNB_handle_nas_first_req( ie->value.choice.UserLocationInformation.present = NGAP_UserLocationInformation_PR_userLocationInformationNR; + ie->value.choice.UserLocationInformation.choice.userLocationInformationNR = + CALLOC(1, sizeof(*ie->value.choice.UserLocationInformation.choice.userLocationInformationNR)); userinfo_nr_p = ie->value.choice.UserLocationInformation.choice.userLocationInformationNR; /* Set nRCellIdentity. default userLocationInformationNR */ From d5f95c6c79e83b0ebd01f77c60025711ccd6cc6f Mon Sep 17 00:00:00 2001 From: Xue Song Date: Fri, 23 Oct 2020 08:00:21 +0000 Subject: [PATCH 16/16] fix some error --- openair2/RRC/NR/MESSAGES/asn1_msg.c | 45 ++++++++++++--------------- openair2/RRC/NR/MESSAGES/asn1_msg.h | 10 ++++-- openair2/RRC/NR/rrc_gNB.c | 41 +++++++++++++++++------- openair2/RRC/NR_UE/rrc_UE.c | 32 ++++++++++++------- openair2/SIMULATION/NR_RRC/itti_sim.c | 3 +- 5 files changed, 80 insertions(+), 51 deletions(-) diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index c96819f6c2..826be63056 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -828,9 +828,9 @@ uint8_t do_NR_SecurityModeCommand( dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm = integrityProtAlgorithm; - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); - //} + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, @@ -864,7 +864,7 @@ uint8_t do_NR_SecurityModeCommand( /*TODO*/ //------------------------------------------------------------------------------ -uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, +uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, const uint8_t Transaction_id) //------------------------------------------------------------------------------ @@ -889,9 +889,9 @@ uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, ue_capabilityrat_request); - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); - //} + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, @@ -1083,9 +1083,9 @@ uint16_t do_RRCReconfiguration( dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie; - // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); - // } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, @@ -1152,9 +1152,9 @@ uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { rrcSetupRequest->rrcSetupRequest.spare.size=1; rrcSetupRequest->rrcSetupRequest.spare.bits_unused = 7; - // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_CCCH_Message, (void *)&ul_ccch_msg); - // } + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_CCCH_Message, NULL, @@ -1189,9 +1189,9 @@ do_NR_RRCReconfigurationComplete( NR_RRCReconfigurationComplete__criticalExtensions_PR_rrcReconfigurationComplete; rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->nonCriticalExtension = NULL; rrcReconfigurationComplete->criticalExtensions.choice.rrcReconfigurationComplete->lateNonCriticalExtension = NULL; - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - //} + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, @@ -1212,11 +1212,6 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Trans memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); uint8_t buf[6]; - uint8_t rv[6]; - int i; - for (i=0; i<6; i++) { - rv[i]=taus()&0xff; - } ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1 = CALLOC(1,sizeof(struct NR_UL_DCCH_MessageType__c1)); @@ -1235,18 +1230,18 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Trans RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->present = NR_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.size = 6; RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf = buf; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[0] = rv[0]; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[1] = rv[1]; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[2] = rv[2]; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[3] = rv[3]; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[4] = rv[4]; - RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[5] = rv[5]; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[0] = 0x12; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[1] = 0x34; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[2] = 0x56; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[3] = 0x78; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[4] = 0x9A; + RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI.buf[5] = 0xBC; memset(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,0,sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(&RrcSetupComplete->criticalExtensions.choice.rrcSetupComplete->dedicatedNAS_Message,dedicatedInfoNAS,dedicatedInfoNASLength); -//if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { +if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); -//} +} enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, NULL, diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.h b/openair2/RRC/NR/MESSAGES/asn1_msg.h index 35d726ed89..78deda904d 100644 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.h +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.h @@ -99,7 +99,7 @@ uint8_t do_NR_SecurityModeCommand( const uint8_t cipheringAlgorithm, NR_IntegrityProtAlgorithm_t *integrityProtAlgorithm); -uint8_t do_NR_UECapabilityEnquiry_nr( const protocol_ctxt_t *const ctxt_pP, +uint8_t do_NR_SA_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, uint8_t *const buffer, const uint8_t Transaction_id); @@ -119,4 +119,10 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS); -uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); \ No newline at end of file +uint8_t do_RRCSetupRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv); + +uint8_t do_NR_RRCReconfigurationComplete( + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, + const uint8_t Transaction_id + ); diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index be6230e36d..0aaede865e 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -401,8 +401,12 @@ rrc_gNB_generate_RRCSetup( // ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM, + ue_p->Srb0.Tx_buffer.payload_size); + memcpy (message_buffer, (uint8_t*)ue_p->Srb0.Tx_buffer.Payload, ue_p->Srb0.Tx_buffer.payload_size); message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)ue_p->Srb0.Tx_buffer.Payload; + GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #endif @@ -439,8 +443,12 @@ rrc_gNB_generate_RRCReject( #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM, + ue_p->Srb0.Tx_buffer.payload_size); + memcpy (message_buffer, (uint8_t*)ue_p->Srb0.Tx_buffer.Payload, ue_p->Srb0.Tx_buffer.payload_size); message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)ue_p->Srb0.Tx_buffer.Payload; + GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_CCCH_DATA_IND (message_p).size = ue_p->Srb0.Tx_buffer.payload_size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #endif @@ -514,9 +522,12 @@ rrc_gNB_generate_defaultRRCReconfiguration( size); #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM, size); + memcpy (message_buffer, buffer, size); message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #else @@ -1106,9 +1117,9 @@ rrc_gNB_decode_dcch( DCCH, sdu_sizeP); -// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); -// } + } rrc_gNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); //rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p); @@ -1141,9 +1152,9 @@ rrc_gNB_decode_dcch( PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), DCCH, sdu_sizeP); - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)ul_dcch_msg); - //} + } LOG_I(NR_RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); int eutra_index = -1; @@ -1163,9 +1174,9 @@ rrc_gNB_decode_dcch( ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.buf, ul_dcch_msg->message.choice.c1->choice.ueCapabilityInformation->criticalExtensions.choice.ueCapabilityInformation->ue_CapabilityRAT_ContainerList->list.array[i]->ue_CapabilityRAT_Container.size, 0,0); - //if(LOG_DEBUGFLAG(DEBUG_ASN1)){ + if(LOG_DEBUGFLAG(DEBUG_ASN1)){ xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); - //} + } if((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)){ LOG_E(NR_RRC,PROTOCOL_NR_RRC_CTXT_UE_FMT" Failed to decode nr UE capabilities (%zu bytes)\n", @@ -1436,9 +1447,12 @@ rrc_gNB_generate_SecurityModeCommand( LOG_I(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM,size); + memcpy (message_buffer, buffer, size); message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #else @@ -1464,7 +1478,7 @@ rrc_gNB_generate_UECapabilityEnquiry( uint8_t size; T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - size = do_NR_UECapabilityEnquiry_nr( + size = do_NR_SA_UECapabilityEnquiry( ctxt_pP, buffer, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id)); @@ -1490,9 +1504,12 @@ rrc_gNB_generate_UECapabilityEnquiry( size); #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_GNB_SIM, TASK_RRC_UE_SIM, size); + memcpy (message_buffer, buffer, size); message_p = itti_alloc_new_message (TASK_RRC_GNB_SIM, GNB_RRC_DCCH_DATA_IND); GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; - GNB_RRC_DCCH_DATA_IND (message_p).sdu = (uint8_t*)buffer; + GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #else diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 78591d46f1..949cf5bf08 100755 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -107,6 +107,11 @@ nr_sa_rrc_ue_process_radioBearerConfig( NR_RadioBearerConfig_t *const radioBearerConfig ); +uint8_t do_NR_RRCReconfigurationComplete( + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, + const uint8_t Transaction_id + ); mui_t nr_rrc_mui=0; @@ -1393,9 +1398,9 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB (uint8_t *)Srb_info->Rx_buffer.Payload, 100,0,0); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout,&asn_DEF_NR_DL_CCCH_Message,(void *)dl_ccch_msg); - } + // } if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%zu bytes)\n",ctxt_pP->module_id,ctxt_pP->frame,dec_rval.consumed); @@ -1691,9 +1696,9 @@ memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t)); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); -// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); -// } + } LOG_D(NR_RRC, "securityModeComplete Encoded %zd bits (%zd bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); @@ -1764,8 +1769,13 @@ void rrc_ue_generate_RRCSetupRequest( const protocol_ctxt_t *const ctxt_pP, cons #ifdef ITTI_SIM MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_UE_SIM,TASK_RRC_GNB_SIM, + NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size); + memcpy (message_buffer, (uint8_t*)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, + NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size); message_p = itti_alloc_new_message (TASK_RRC_UE_SIM, UE_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload; + GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #endif @@ -2266,9 +2276,9 @@ nr_rrc_ue_decode_dcch( return -1; } - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + // if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message,(void *)dl_dcch_msg); - } + // } if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) { switch (dl_dcch_msg->message.choice.c1->present) { @@ -2479,9 +2489,9 @@ nr_rrc_ue_process_ueCapabilityEnquiry( OAI_NR_UECapability_t *UECap; UECap = CALLOC(1,sizeof(OAI_NR_UECapability_t)); UECap->UE_NR_Capability = UE_Capability_nr; - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr); - //} + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_NR_Capability, NULL, @@ -2521,9 +2531,9 @@ nr_rrc_ue_process_ueCapabilityEnquiry( AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_UL_DCCH_Message, (void *)&ul_dcch_msg); - //} + } LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #ifdef ITTI_SIM diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c index 6d0ae5f7fc..a09c6207af 100644 --- a/openair2/SIMULATION/NR_RRC/itti_sim.c +++ b/openair2/SIMULATION/NR_RRC/itti_sim.c @@ -522,7 +522,8 @@ int main( int argc, char **argv ) exit(-1); } - AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1; + // AMF_MODE_ENABLED = !IS_SOFTMODEM_NOS1; + AMF_MODE_ENABLED = 0; #if T_TRACER T_Config_Init();