Commit 592642cb authored by Xue Song's avatar Xue Song

modify RRC messages

parent 43ef53cb
......@@ -41,6 +41,7 @@
#include <per_encoder.h>
#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,
......
......@@ -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);
......
......@@ -86,6 +86,9 @@
#include "executables/softmodem-common.h"
#include <openair2/RRC/NR/rrc_gNB_UE_context.h>
#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(
......@@ -973,6 +1030,8 @@ 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 != NULL) {
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))
......@@ -1005,14 +1064,19 @@ rrc_gNB_decode_dcch(
return -1;
}
uint64_t fiveg_s_TMSI = BIT_STRING_to_uint16(&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(%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;
}
}
}
rrc_gNB_process_RRCSetupComplete(
ctxt_pP,
......@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment