Commit 08e77555 authored by wujing's avatar wujing

Merge branch 'develop_SA_SIM' into develop_SA_L3

parents 028be9e4 a9b76b53
......@@ -3341,14 +3341,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
......
......@@ -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;
......
......@@ -246,7 +246,6 @@ typedef struct ccparams_nr_x2 {
#define GNB_SLICE_SERIVE_TYPE_IDX 0
#define GNB_SLICE_DIFFERENTIATOR_IDX 1
#define GNBSNSSAIPARAMS_DESC { \
/* optname helpstr paramflags XXXptr def val type numelt */ \
{GNB_CONFIG_STRING_SLICE_SERIVE_TYPE, "slice serive type", 0, uptr:NULL, defuintval:1, TYPE_UINT, 0}, \
......@@ -260,7 +259,6 @@ typedef struct ccparams_nr_x2 {
{ .s5 = { NULL } }, \
}
/* AMF configuration parameters section name */
#define GNB_CONFIG_STRING_AMF_IP_ADDRESS "amf_ip_address"
......
......@@ -183,6 +183,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_BWP_Downlink_t *bwp = mac->DLbwp[bwp_id - 1];
#ifdef DEBUG_DCI
......
......@@ -1408,7 +1408,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].
......@@ -1551,7 +1551,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;
......@@ -3492,10 +3492,10 @@ int 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
......@@ -3562,13 +3562,13 @@ int 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;
......@@ -3586,10 +3586,9 @@ int 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;
// This is not supported yet - Skip for now
// Frequency hopping flag – 1 bit
//pos++;
//dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1;
// Frequency hopping flag  E1 bit
pos++;
dci_pdu_rel15->frequency_hopping_flag.val= (*dci_pdu>>(dci_size-pos))&1;
// MCS 5 bit
pos+=5;
dci_pdu_rel15->mcs= (*dci_pdu>>(dci_size-pos))&0x1f;
......@@ -3602,10 +3601,10 @@ int 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++);
......@@ -3623,7 +3622,7 @@ int 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++)
......@@ -3637,11 +3636,11 @@ int 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)
......
......@@ -811,7 +811,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 (N2<O_uci && N3>O_uci) {
if (pucch_resource < n_list)
resource_id = pucchresset->resourceList.list.array[pucch_resource];
......
......@@ -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"
......@@ -616,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;
......@@ -631,12 +639,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 +770,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 +791,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);
}
......@@ -856,13 +864,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));
......@@ -872,11 +880,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) ) {
......@@ -890,19 +900,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);
......@@ -952,6 +962,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 +1014,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;
......@@ -1064,10 +1078,15 @@ 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;
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,
......@@ -1106,19 +1125,20 @@ 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;
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;
......@@ -1142,7 +1162,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);
}
//------------------------------------------------------------------------------
......@@ -1161,8 +1181,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;
......@@ -1178,7 +1200,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_I(NR_RRC,"rrcReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
return((enc_rval.encoded+7)/8);
}
......@@ -1188,23 +1210,40 @@ 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];
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] = 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) ) {
xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&ul_dcch_msg);
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,
......@@ -1212,7 +1251,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);
}
......
......@@ -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);
......@@ -118,3 +118,11 @@ uint8_t do_RRCSetupComplete(uint8_t Mod_id,
uint8_t sel_plmn_id,
const int dedicatedInfoNASLength,
const char *dedicatedInfoNAS);
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
);
......@@ -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
......
......@@ -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;
///---------------------------------------------------------------------------------------------------------------///
......@@ -393,33 +398,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,
......@@ -442,8 +421,12 @@ 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);
GNB_RRC_CCCH_DATA_IND (message_p).sdu = (uint8_t*)ue_p->Srb0.Tx_buffer.Payload;
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 = 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
......@@ -477,6 +460,18 @@ 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;
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 = 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
}
//-----------------------------------------------------------------------------
......@@ -494,14 +489,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 {
rrc_gNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP);
}
}
//-----------------------------------------------------------------------------
......@@ -546,6 +540,17 @@ rrc_gNB_generate_defaultRRCReconfiguration(
ue_context_pP->ue_context.rnti,
rrc_gNB_mui,
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 = 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
nr_rrc_data_req(ctxt_pP,
DCCH,
rrc_gNB_mui++,
......@@ -553,7 +558,7 @@ rrc_gNB_generate_defaultRRCReconfiguration(
size,
buffer,
PDCP_TRANSMISSION_MODE_CONTROL);
#endif
// rrc_pdcp_config_asn1_req
// rrc_rlc_config_asn1_req
}
......@@ -580,6 +585,15 @@ rrc_gNB_process_RRCReconfigurationComplete(
uint8_t nr_DRB2LCHAN[8];
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;
// 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;
// }
#ifndef PHYSIM
/* Derive the keys from kgnb */
......@@ -601,6 +615,7 @@ rrc_gNB_process_RRCReconfigurationComplete(
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_pP->ue_context.rnti);
#ifndef ITTI_SIM
nr_rrc_pdcp_config_asn1_req(ctxt_pP,
SRB_configList, // NULL,
DRB_configList,
......@@ -619,8 +634,34 @@ rrc_gNB_process_RRCReconfigurationComplete(
DRB_Release_configList2,
NULL,
NULL);
#endif
/* 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]) {
......@@ -782,7 +823,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,
......@@ -823,6 +864,11 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP,
}
} 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));
......@@ -866,6 +912,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(
......@@ -903,6 +972,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++) {
......@@ -993,6 +1063,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))
......@@ -1025,14 +1097,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,
......@@ -1065,6 +1142,9 @@ 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_UECapabilityEnquiry(ctxt_pP, ue_context_p);
//rrc_gNB_generate_defaultRRCReconfiguration(ctxt_pP, ue_context_p);
break;
case NR_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation:
......@@ -1129,6 +1209,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 ==
......@@ -1160,11 +1245,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
}
}
......@@ -1261,13 +1342,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;
......@@ -1422,6 +1496,17 @@ rrc_gNB_generate_SecurityModeCommand(
size);
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 = 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
nr_rrc_data_req(ctxt_pP,
DCCH,
rrc_gNB_mui++,
......@@ -1429,6 +1514,8 @@ rrc_gNB_generate_SecurityModeCommand(
size,
buffer,
PDCP_TRANSMISSION_MODE_CONTROL);
#endif
}
void
......@@ -1442,7 +1529,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));
......@@ -1466,6 +1553,17 @@ rrc_gNB_generate_UECapabilityEnquiry(
ue_context_pP->ue_context.rnti,
rrc_gNB_mui,
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 = 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
nr_rrc_data_req(
ctxt_pP,
DCCH,
......@@ -1474,6 +1572,7 @@ rrc_gNB_generate_UECapabilityEnquiry(
size,
buffer,
PDCP_TRANSMISSION_MODE_CONTROL);
#endif
}
//-----------------------------------------------------------------------------
......
......@@ -60,19 +60,72 @@
#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
);
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;
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) {
......@@ -350,7 +403,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 +523,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; i<NR_UE_rrc_inst[ctxt_pP->module_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,
......@@ -554,12 +571,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)
......@@ -1007,7 +1024,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;
......@@ -1167,7 +1184,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);
}
......@@ -1333,17 +1350,15 @@ 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;
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 = nas_attach_req_imsi;
nas_msg_length = sizeof(nas_attach_req_imsi);
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(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,9 +1372,20 @@ 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 ){
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;
......@@ -1372,9 +1398,9 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_IN
(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);
......@@ -1383,17 +1409,17 @@ 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(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 +1427,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 +1456,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;
......@@ -1455,6 +1481,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,
......@@ -1485,6 +1512,17 @@ 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_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)){
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;
}
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:
case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer:
......@@ -1534,51 +1572,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 +1627,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 +1645,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,19 +1673,20 @@ 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) {
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 = CALLOC(1, sizeof(NR_SecurityModeComplete_IEs_t));
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 (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,
......@@ -1661,13 +1700,26 @@ 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(RRC, "\n");
LOG_T(NR_RRC, "%02x.", buffer[i]);
}
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_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 (
ctxt_pP,
DCCH,
......@@ -1676,10 +1728,60 @@ 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",
#endif
} 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; i<NR_UE_rrc_inst[ctxt_pP->module_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;
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 = 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
}
}
//-----------------------------------------------------------------------------
int32_t
nr_rrc_ue_establish_srb1(
......@@ -1924,26 +2026,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 +2118,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 +2204,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",
......@@ -2113,6 +2215,18 @@ 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;
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 = 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
rrc_data_req_ue (
ctxt_pP,
DCCH,
......@@ -2121,6 +2235,8 @@ void nr_rrc_ue_generate_RRCReconfigurationComplete( const protocol_ctxt_t *const
size,
buffer,
PDCP_TRANSMISSION_MODE_CONTROL);
#endif
}
// from NR SRB1
......@@ -2160,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) {
......@@ -2193,9 +2309,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_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_rrcReestablishment:
case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer:
case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
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:
......@@ -2204,8 +2327,16 @@ 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",
ctxt_pP->module_id, gNB_indexP);
nr_rrc_ue_process_securityModeCommand(
ctxt_pP,
dl_dcch_msg->message.choice.c1->choice.securityModeCommand,
gNB_indexP);
break;
}
}
......@@ -2230,16 +2361,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 +2382,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),
......@@ -2287,22 +2418,19 @@ 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:
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;
}
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
......@@ -2323,3 +2451,113 @@ 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_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);
// 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 = 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; i<UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry->ue_CapabilityRAT_RequestList.list.count; i++) {
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);
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);
#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,
nr_rrc_mui++,
SDU_CONFIRM_NO,
(enc_rval.encoded + 7) / 8,
buffer,
PDCP_TRANSMISSION_MODE_CONTROL);
#endif
}
}
}
......@@ -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,9 @@ 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;
NR_SystemInformation_t *si[NB_CNX_UE];
NR_SIB1_t *sib1[NB_CNX_UE];
......@@ -173,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
......
......@@ -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
......@@ -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;
}
......@@ -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();
......@@ -584,12 +585,7 @@ int main( int argc, char **argv )
// wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n");
#if 0
// test itti sim
usleep(10000);
usleep(100000);
protocol_ctxt_t ctxt;
struct rrc_gNB_ue_context_s *ue_context_p = NULL;
......@@ -605,11 +601,9 @@ int main( int argc, char **argv )
0,
0,
0);
rrc_gNB_generate_RRCSetup(&ctxt,
ue_context_p,
0);
// end test itti sim
#endif
NR_UE_rrc_inst[ctxt.module_id].Info[0].State = RRC_SI_RECEIVED;
rrc_ue_generate_RRCSetupRequest(&ctxt, 0);
printf("Entering ITTI signals handler\n");
itti_wait_tasks_end();
......
/*! \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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#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(&registration_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(&registration_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(&registration_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(&registration_request->naskeysetidentifier) & 0x0f) << 4) | (encode_5gs_registration_type(&registration_request->fgsregistrationtype) & 0x0f);
encoded++;
if ((encode_result =
encode_5gs_mobile_identity(&registration_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;
}
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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_) */
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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;
}
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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_ */
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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;
}
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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_ */
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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;
}
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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_*/
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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;
}
/*! \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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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_ */
......@@ -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;
......@@ -224,6 +225,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 */
......
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