Commit 143e765c authored by Daniel0326's avatar Daniel0326

msg5 decoding in RRC

parent 9c7a5b22
......@@ -276,14 +276,23 @@ hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key
*dataP = NULL;
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
//printf("Hash table size : %d\n", hashtblP->size);
//printf("hashfunc(keyP) : %d\n", hashtblP->hashfunc(keyP));
hash=hashtblP->hashfunc(keyP)%hashtblP->size;
/* fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
//printf("keyP %d\n", keyP);
/*fprintf(stderr, "hashtable_get() key=%s, hash=%d\n", key, hash);*/
//printf("hash %d\n", hash);
node=hashtblP->nodes[hash];
//printf("nodes_value %d \n", hashtblP->nodes[hash]);
while(node) {
//printf("node_key %d \n",node->key);
if(node->key == keyP) {
//printf("node_key %d \n",node->key);
*dataP = node->data;
//printf("data : %p \n",node->data);
return HASH_TABLE_OK;
}
node=node->next;
......
......@@ -30,6 +30,9 @@
#include "defs_NB_IoT.h"
#include "proto_NB_IoT.h"
#include "extern_NB_IoT.h"
#include "RRC/LITE/proto.h"
#include "RRC/LITE/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
unsigned char str20[] = "DCI_uss";
unsigned char str21[] = "DATA_uss";
......@@ -246,16 +249,40 @@ void rx_sdu_NB_IoT(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t
printf("%02x ",payload_ptr[a]);
printf("\n");*/
rx_lengths[i]-=1;
mac_rrc_data_ind(
module_id,
CC_id,
frame,subframe,
rnti,
CCCH,
(uint8_t*)payload_ptr,
rx_lengths[i],
1,
module_id,
0);
LOG_D(MAC,"rx_lengths : %d\n", rx_lengths[i]);
msg4_rrc_pdu = mac_rrc_msg3_ind_NB_IoT(payload_ptr,rnti,rx_lengths[i]);
receive_msg3_NB_IoT(mac_inst,rnti,PHR,ul_total_buffer,first_6,msg4_rrc_pdu);
LOG_D(MAC,"Contention resolution ID = %02x %02x %02x %02x %02x %02x\n",first_6[0],first_6[1],first_6[2],first_6[3],first_6[4],first_6[5]);
LOG_I(MAC,"Contention resolution ID = %02x %02x %02x %02x %02x %02x\n",first_6[0],first_6[1],first_6[2],first_6[3],first_6[4],first_6[5]);
//NB_IoT_mac_rrc_data_ind(payload_ptr,mac_inst,rnti);
//NB_IoT_receive_msg3(mac_inst,rnti,PHR,ul_total_buffer);
break;
case DCCH0_NB_IoT:
case DCCH1_NB_IoT:
LOG_I(MAC,"DCCH PDU Here\n");
mac_rlc_data_ind(
module_id,
rnti,
module_id,
frame,
1,
0,
rx_lcids[i],
//1,/* change channel_id equals 1 (SRB) */
(char *)payload_ptr,
rx_lengths[i],
1,
NULL);//(unsigned int*)crc_status);
// UE specific here
//NB_IoT_mac_rlc_data_ind(payload_ptr,mac_inst,rnti);
......
......@@ -514,6 +514,7 @@ pdcp_data_ind(
ctxt_pP->module_id,
ctxt_pP->rnti);
key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_id, srb_flagP);
h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
if (h_rc != HASH_TABLE_OK) {
......@@ -652,6 +653,7 @@ pdcp_data_ind(
PROTOCOL_PDCP_CTXT_FMT" DATA-IND len %u",
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p),
sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len);
rrc_data_ind(ctxt_pP,
rb_id,
sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len,
......
......@@ -211,6 +211,11 @@ config_req_rlc_am (
hashtable_rc_t h_rc;
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
/***************************************/
printf("hashtable_get in comfig_req_rlc_am\n");
/***************************************/
if (h_rc == HASH_TABLE_OK) {
l_rlc_p = &rlc_union_p->rlc.am;
......@@ -265,6 +270,10 @@ void config_req_rlc_am_asn1 (
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
/***************************************/
printf("hashtable_get in config_req_rlc_am_asn1\n");
/***************************************/
if (h_rc == HASH_TABLE_OK) {
l_rlc_p = &rlc_union_p->rlc.am;
......
......@@ -36,6 +36,7 @@
#include "assertions.h"
extern boolean_t pdcp_data_ind(
const protocol_ctxt_t* const ctxt_pP,
const srb_flag_t srb_flagP,
......@@ -581,7 +582,17 @@ void rlc_data_ind (
T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP));
#endif
/*************************For SRB1bis (RLC->RRC)*****************************/
rrc_data_ind(
ctxt_pP,
rb_idP,
51,
(uint8_t*)&sdu_pP->data[0]);
/***************************************************************************/
/*
pdcp_data_ind (
ctxt_pP,
srb_flagP,
......@@ -589,7 +600,9 @@ void rlc_data_ind (
rb_idP,
sdu_sizeP,
sdu_pP);
*/
}
//-----------------------------------------------------------------------------
void rlc_data_conf (const protocol_ctxt_t* const ctxt_pP,
const srb_flag_t srb_flagP,
......
......@@ -177,6 +177,7 @@ tbs_size_t mac_rlc_data_req(
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
if (h_rc == HASH_TABLE_OK) {
rlc_mode = rlc_union_p->mode;
} else {
......@@ -238,8 +239,9 @@ void mac_rlc_data_ind (
rlc_union_t *rlc_union_p = NULL;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc;
srb_flag_t srb_flag = (channel_idP <= 2) ? SRB_FLAG_YES : SRB_FLAG_NO;
srb_flag_t srb_flag = (channel_idP <= 3) ? SRB_FLAG_YES : SRB_FLAG_NO;
protocol_ctxt_t ctxt;
LOG_I(RLC,"NB-IoT: RLC PDU receive\n");
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, enb_flagP, rntiP, frameP, 0, eNB_index);
......@@ -282,7 +284,19 @@ void mac_rlc_data_ind (
return;
}
} else {
key = RLC_COLL_KEY_LCID_VALUE(module_idP, rntiP, enb_flagP, channel_idP, srb_flag);
/*
printf("*******RLC_COLL_KEY_LCID_VALUE*********\n");
printf("module_id : %d\n",module_idP);
printf("rnti : %d\n",rntiP);
printf("enb_flag : %d\n",enb_flagP );
printf("channel_id : %d\n",channel_idP );
printf("srb_flag : %d\n",srb_flag);
printf("***************************************\n");
*/
}
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
......@@ -298,18 +312,24 @@ void mac_rlc_data_ind (
switch (rlc_mode) {
case RLC_MODE_NONE:
LOG_I(RLC,"NB-IoT: No Radio bearer configure for\n");
//handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP);
break;
case RLC_MODE_AM:
LOG_I(RLC,"NB-IoT: AM\n");
rlc_am_mac_data_indication(&ctxt, &rlc_union_p->rlc.am, data_ind);
break;
case RLC_MODE_UM:
LOG_I(RLC,"NB-IoT: UM\n");
rlc_um_mac_data_indication(&ctxt, &rlc_union_p->rlc.um, data_ind);
break;
case RLC_MODE_TM:
LOG_I(RLC,"NB-IoT: TM\n");
rlc_tm_mac_data_indication(&ctxt, &rlc_union_p->rlc.tm, data_ind);
break;
}
......@@ -386,6 +406,7 @@ mac_rlc_status_resp_t mac_rlc_status_ind(
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
if (h_rc == HASH_TABLE_OK) {
rlc_mode = rlc_union_p->mode;
} else {
......@@ -469,6 +490,7 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind(
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
if (h_rc == HASH_TABLE_OK) {
rlc_mode = rlc_union_p->mode;
} else {
......
......@@ -113,6 +113,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP
break;
case RLC_Config_PR_am:
/****************************************config srb1********************************************/
if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM) != NULL) {
config_req_rlc_am_asn1 (
ctxt_pP,
......@@ -124,6 +125,21 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP
PROTOCOL_CTXT_ARGS(ctxt_pP),
rb_id);
}
/***********************************************************************************************/
/****************************************config srb1bis********************************************/
if (rrc_rlc_add_rlc (ctxt_pP, SRB_FLAG_YES, MBMS_FLAG_NO, 3, 3, RLC_MODE_AM) != NULL) {
config_req_rlc_am_asn1 (
ctxt_pP,
SRB_FLAG_YES,
&srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am,
3, 3);
} else {
LOG_E(RLC, PROTOCOL_CTXT_FMT" ERROR IN ALLOCATING SRB %d \n",
PROTOCOL_CTXT_ARGS(ctxt_pP),
rb_id);
}
/***************************************************************************************************/
break;
......@@ -374,6 +390,7 @@ rlc_op_status_t rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) {
rlc_union_p = rrc_rlc_add_rlc (
ctxt_pP,
......@@ -489,7 +506,7 @@ rlc_op_status_t rrc_rlc_remove_rlc (
rlc_union_t *rlc_union_p = NULL;
#if defined(Rel10) || defined(Rel14)
rlc_mbms_id_t *mbms_id_p = NULL;
#endif
#endif rrc_rlc_remove_rlc
#ifdef OAI_EMU
CHECK_CTXT_ARGS(ctxt_pP)
......@@ -548,6 +565,7 @@ rlc_op_status_t rrc_rlc_remove_rlc (
}
key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, lcid, srb_flagP);
h_lcid_rc = hashtable_get(rlc_coll_p, key_lcid, (void**)&rlc_union_p);
} else {
h_lcid_rc = HASH_TABLE_KEY_NOT_EXISTS;
}
......@@ -632,8 +650,20 @@ rlc_union_t* rrc_rlc_add_rlc (
{
key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
key_lcid = RLC_COLL_KEY_LCID_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, chan_idP, srb_flagP);
/*
printf("*******RLC_COLL_KEY_LCID_VALUE*********\n");
printf("module_id : %d\n",ctxt_pP->module_id);
printf("rnti : %d\n",ctxt_pP->rnti);
printf("enb_flag : %d\n",ctxt_pP->enb_flag );
printf("channel_id : %d\n",chan_idP );
printf("srb_flag : %d\n",srb_flagP);
printf("***************************************\n");
printf("key_lcid %d\n",key_lcid);
*/
}
h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
if (h_rc == HASH_TABLE_OK) {
......
......@@ -604,6 +604,16 @@ rrc_data_ind(
sdu_sizeP,
ctxt_pP->rnti);
}
/*
printf("....in rrc_data_ind....\n");
printf("module_id : %d\n",ctxt_pP->module_id);
printf("frame : %d\n",ctxt_pP->frame);
printf("DCCH_index : %d\n",DCCH_index);
printf("Srb_id : %d\n",Srb_id);
printf("sdu_sizeP : %d\n",sdu_sizeP);
printf("rnti : %d\n",ctxt_pP->rnti);
*/
#if defined(ENABLE_ITTI)
{
......
......@@ -944,7 +944,6 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT, //for both SRB1bis and SRB1
struct PhysicalConfigDedicated_NB_r13** physicalConfigDedicated_NB_IoT)
{
asn_enc_rval_t enc_rval;
uint8_t ecause=0;
......
......@@ -35,7 +35,6 @@
#include "rlc.h"
#include "extern_NB_IoT.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
/*NOTE: no static function should be declared in this header file (e.g. init_SI_NB)*/
uint8_t* generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier);
......
......@@ -41,6 +41,14 @@
#include "RRC/LITE/MESSAGES/asn1_msg_NB_IoT.h"
#include "RRCConnectionRequest-NB.h"
#include "UL-CCCH-Message-NB.h"
/***************************/
//#include "DL-CCCH-Message-NB.h"
#include "UL-DCCH-Message-NB.h"
//#include "DL-DCCH-Message-NB.h"
//#include "SRB-ToAddMod-NB-r13.h"
/***************************/
// NB-IoT end
#include "assertions.h"
#include "asn1_conversions.h"
......@@ -121,6 +129,7 @@ extern uint16_t two_tier_hexagonal_cellIds[7];
mui_t rrc_eNB_mui = 0;
uint8_t* generate_msg4_NB_IoT(rrc_eNB_carrier_data_NB_IoT_t *carrier)
{
LOG_D(RRC,"start the RRC connection setup PDU\n");
......@@ -1130,6 +1139,50 @@ rrc_eNB_process_RRCConnectionSetupComplete(
}
}
/**************************************************************************************/
//-----------------------------------------------------------------------------
void rrc_eNB_process_RRCConnectionSetupComplete_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
rrc_eNB_ue_context_NB_IoT_t* ue_context_pP,
RRCConnectionSetupComplete_NB_r13_IEs_t * rrcConnectionSetupComplete_NB
)
//-----------------------------------------------------------------------------
{
LOG_I(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing RRCConnectionSetupComplete_NB from UE (SRB1bis/SRB1 Active)\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
ue_context_pP->ue_context.Srb1bis.Active=1; //SRB1bis active for UE, from eNB point of view
ue_context_pP->ue_context.Srb1.Active=1 //SRB1 active for UE (implicitly activated)
T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
#if defined(ENABLE_USE_MME)
if (EPC_MODE_ENABLED == 1) {
// Forward message to S1AP layer we don't have S1AP functions for the moment
//printf("*********************Get into S1AP*********************\n");
//rrc_eNB_send_S1AP_NAS_FIRST_REQ(
// ctxt_pP,
// ue_context_pP,
// rrcConnectionSetupComplete_NB);
} else
#endif
{
/*
// RRC loop back (no S1AP), send SecurityModeCommand to UE
rrc_eNB_generate_SecurityModeCommand(
ctxt_pP,
ue_context_pP);
*/
}
}
/**************************************************************************************/
//-----------------------------------------------------------------------------
void
rrc_eNB_generate_SecurityModeCommand(
......@@ -4268,6 +4321,282 @@ while ( eNB_rrc_inst == NULL ) {
}
/*------------------------------------------------------------------------------*/
int
rrc_eNB_decode_ccch_NB_IoT(
protocol_ctxt_t* const ctxt_pP,
const SRB_INFO_NB_IoT* const Srb_info,
const int CC_id
)
//-----------------------------------------------------------------------------
{
LOG_D(RRC,"recieve MSG3 CCCH SDU from MAC\n");
asn_dec_rval_t dec_rval;
LOG_D(RRC,"Decoding UL CCCH %x.%x.%x.%x.%x.%x.%x.%x.%x (%p)\n",
((uint8_t *) Srb_info->Rx_buffer.Payload)[0],
((uint8_t *) Srb_info->Rx_buffer.Payload)[1],
((uint8_t *) Srb_info->Rx_buffer.Payload)[2],
((uint8_t *) Srb_info->Rx_buffer.Payload)[3],
((uint8_t *) Srb_info->Rx_buffer.Payload)[4],
((uint8_t *) Srb_info->Rx_buffer.Payload)[5],
((uint8_t *) Srb_info->Rx_buffer.Payload)[6],
((uint8_t *) Srb_info->Rx_buffer.Payload)[7],
((uint8_t *) Srb_info->Rx_buffer.Payload)[8],
(uint8_t *) Srb_info->Rx_buffer.Payload);
RRCConnectionRequest_NB_r13_IEs_t* rrcConnectionRequest_NB = NULL;
UL_CCCH_Message_NB_t* ul_ccch_msg_NB = NULL;
dec_rval = uper_decode(
NULL,
&asn_DEF_UL_CCCH_Message_NB,
(void**)&ul_ccch_msg_NB,
(uint8_t*) Srb_info->Rx_buffer.Payload,
100,
0,
0);
module_id_t Idx;
int i, rval;
struct rrc_eNB_ue_context_s* ue_context_p = NULL;
uint64_t random_value = 0;
int stmsi_received = 0;
if (ul_ccch_msg_NB->message.present == UL_CCCH_MessageType_PR_c1)
{
switch (ul_ccch_msg_NB->message.choice.c1.present)
{
case UL_CCCH_MessageType_NB__c1_PR_rrcConnectionRequest_r13:
T(T_ENB_RRC_CONNECTION_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
#ifdef RRC_MSG_PRINT
LOG_F(RRC,"[MSG] RRC Connection Request\n");
for (i = 0; i < Srb_info->Rx_buffer.payload_size; i++) {
LOG_F(RRC,"%02x ", ((uint8_t*)Srb_info->Rx_buffer.Payload)[i]);
}
LOG_F(RRC,"\n");
#endif
LOG_D(RRC,
PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND (rrcConnectionRequest on SRB0) --> RRC_eNB\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[ctxt_pP->module_id],
ctxt_pP->rnti);
if (ue_context_p != NULL) {
// erase content
rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_p);
MSC_LOG_RX_DISCARDED_MESSAGE(
MSC_RRC_ENB,
MSC_RRC_UE,
Srb_info->Rx_buffer.Payload,
dec_rval.consumed,
MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (UE already in context)",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_p->ue_context.rnti,
dec_rval.consumed);
} else {
rrcConnectionRequest_NB = &ul_ccch_msg_NB->message.choice.c1.choice.rrcConnectionRequest_r13.criticalExtensions.choice.rrcConnectionRequest_r13;
{
if (InitialUE_Identity_PR_randomValue == rrcConnectionRequest_NB->ue_Identity_r13.present) {
AssertFatal(rrcConnectionRequest_NB->ue_Identity_r13.choice.randomValue.size == 5,
"wrong InitialUE-Identity randomValue size, expected 5, provided %d",
rrcConnectionRequest_NB->ue_Identity_r13.choice.randomValue.size);
memcpy(((uint8_t*) & random_value) + 3,
rrcConnectionRequest_NB->ue_Identity_r13.choice.randomValue.buf,
rrcConnectionRequest_NB->ue_Identity_r13.choice.randomValue.size);
/* if there is already a registered UE (with another RNTI) with this random_value,
* the current one must be removed from MAC/PHY (zombie UE)
*/
if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) {
LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n",
ctxt_pP->rnti, ue_context_p->ue_context.rnti, ctxt_pP->rnti);
rrc_mac_remove_ue(ctxt_pP->module_id, ctxt_pP->rnti);
ue_context_p = NULL;
return 0;
} else {
ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value);
}
} else if (InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest_NB->ue_Identity_r13.present) {
/* Save s-TMSI */
S_TMSI_t s_TMSI = rrcConnectionRequest_NB->ue_Identity_r13.choice.s_TMSI;
mme_code_t mme_code = BIT_STRING_to_uint8(&s_TMSI.mmec);
m_tmsi_t m_tmsi = BIT_STRING_to_uint32(&s_TMSI.m_TMSI);
random_value = (((uint64_t)mme_code) << 32) | m_tmsi;
if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) {
LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti);
rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti);
stmsi_received=1;
/* replace rnti in the context */
/* for that, remove the context from the RB tree */
RB_REMOVE(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
/* and insert again, after changing rnti everywhere it has to be changed */
ue_context_p->ue_id_rnti = ctxt_pP->rnti;
ue_context_p->ue_context.rnti = ctxt_pP->rnti;
RB_INSERT(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
/* reset timers */
ue_context_p->ue_context.ul_failure_timer = 0;
ue_context_p->ue_context.ue_release_timer = 0;
} else {
LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi);
ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY);
if (ue_context_p == NULL)
LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__);
if (ue_context_p != NULL) {
ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE;
ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code;
ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi;
} else {
/* TODO: do we have to break here? */
//break;
}
}
MSC_LOG_RX_MESSAGE(
MSC_RRC_ENB,
MSC_RRC_UE,
Srb_info->Rx_buffer.Payload,
dec_rval.consumed,
MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (s-TMSI mmec %u m_TMSI %u random UE id (0x%" PRIx64 ")",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_p->ue_context.rnti,
dec_rval.consumed,
ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
ue_context_p->ue_context.random_ue_identity);
} else {
LOG_E(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionRequest without random UE identity or S-TMSI not supported, let's reject the UE\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
rrc_eNB_generate_RRCConnectionReject(ctxt_pP,
rrc_eNB_get_ue_context(&eNB_rrc_inst[ctxt_pP->module_id], ctxt_pP->rnti),
CC_id);
break;
}
}
LOG_D(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p);
if (ue_context_p != NULL) {
#if defined(ENABLE_ITTI)
ue_context_p->ue_context.establishment_cause = rrcConnectionRequest_NB->establishmentCause_r13;
if (stmsi_received==0)
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %ld\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p->ue_context.random_ue_identity,
ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
ue_context_p->ue_context.establishment_cause);
else
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE MME code %u TMSI %u cause %ld\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code,
ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi,
ue_context_p->ue_context.establishment_cause);
#else
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
ue_context_p->ue_context.random_ue_identity);
#endif
if (stmsi_received == 0)
eNB_rrc_inst[ctxt_pP->module_id].Nb_ue++;
} else {
// no context available
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
random_value);
rrc_mac_remove_ue(ctxt_pP->module_id,ctxt_pP->rnti);
return -1;
}
}
#ifndef NO_RRM
send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id));
#else
ue_context_p->ue_context.primaryCC_id = CC_id;
//LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH;
Idx = DCCH;
// SRB1
ue_context_p->ue_context.Srb1.Active = 1;
ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; //module_id
memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
// SRB2: set it to go through SRB1 with id 1 (DCCH) ????
ue_context_p->ue_context.Srb2.Active = 1;
ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx;
memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1],
&DCCH_LCHAN_DESC,
LCHAN_DESC_SIZE);
rrc_eNB_generate_RRCConnectionSetup(ctxt_pP, ue_context_p, CC_id);
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
Idx);
MSC_LOG_TX_MESSAGE(
MSC_RRC_ENB,
MSC_PDCP_ENB,
NULL,
0,
MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_p->ue_context.rnti);
rrc_pdcp_config_asn1_req(ctxt_pP,
ue_context_p->ue_context.SRB_configList,
(DRB_ToAddModList_t *) NULL,
(DRB_ToReleaseList_t*) NULL,
0xff,
NULL,
NULL,
NULL
# if defined(Rel10) || defined(Rel14)
, (PMCH_InfoList_r9_t *) NULL
# endif
,NULL);
rrc_rlc_config_asn1_req(ctxt_pP,
ue_context_p->ue_context.SRB_configList,
(DRB_ToAddModList_t*) NULL,
(DRB_ToReleaseList_t*) NULL
# if defined(Rel10) || defined(Rel14)
, (PMCH_InfoList_r9_t *) NULL
# endif
);
#endif //NO_RRM
break;
}
rval = 0;
} else {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown error \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
rval = -1;
}
return rval;
}
/*------------------------------------------------------------------------------*/
int
rrc_eNB_decode_ccch(
......@@ -4292,7 +4621,7 @@ rrc_eNB_decode_ccch(
//memset(ul_ccch_msg,0,sizeof(UL_CCCH_Message_t));
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n",
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
((uint8_t*) Srb_info->Rx_buffer.Payload)[0],
((uint8_t *) Srb_info->Rx_buffer.Payload)[1],
......@@ -4647,6 +4976,161 @@ rrc_eNB_decode_ccch(
return rval;
}
/************************************Decode DCCH for NB_IoT*****************************************/
//-----------------------------------------------------------------------------
int rrc_eNB_decode_dcch_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
const rb_id_t Srb_id, //Dcch_index
const uint8_t* const Rx_sdu,
const sdu_size_t sdu_sizeP
)
//-----------------------------------------------------------------------------
{
asn_dec_rval_t dec_rval;
UL_DCCH_Message_NB_t *ul_dcch_msg_NB_IoT = NULL;
UE_Capability_NB_r13_t *UE_Capability_NB = NULL;
int i;
struct rrc_eNB_ue_context_s* ue_context_p = NULL;
int dedicated_DRB=0;
T(T_ENB_RRC_UL_DCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
if ((Srb_id != 1) && (Srb_id != 3)) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received message on SRB%d, should not have ...\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
Srb_id);
} else {
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received message on SRB%d\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
Srb_id);
}
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message-NB\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
dec_rval = uper_decode(
NULL,
&asn_DEF_UL_DCCH_Message_NB,
(void**)&ul_dcch_msg_NB_IoT,
Rx_sdu,
sdu_sizeP,
0,
0);
/*
printf("....after uper_decode....\n");
printf("Rx_sdu : %d\n",Rx_sdu);
printf("sdu_sizeP : %d\n", sdu_sizeP);
*/
//#if defined(ENABLE_ITTI)
//# if defined(DISABLE_ITTI_XER_PRINT)
for (i = 0; i < sdu_sizeP; i++) {
printf("%02x ", Rx_sdu[i]);
}
printf("\n");
if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UL-DCCH (%zu bytes)\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
dec_rval.consumed);
return -1;
}
ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[ctxt_pP->module_id],
ctxt_pP->rnti);
if (ul_dcch_msg_NB_IoT->message.present == UL_DCCH_MessageType_NB_PR_c1) {
switch (ul_dcch_msg_NB_IoT->message.choice.c1.present) {
case UL_DCCH_MessageType_NB__c1_PR_rrcConnectionSetupComplete_r13:
//MP: Ts 36.331 V14.2.1 RRCConnectionSetupComplete is transmitted over SRB1bis (pag 585)
#ifdef RRC_MSG_PRINT
LOG_F(RRC,"[MSG] RRCConnectionSetupComplete-NB\n");
for (i = 0; i < sdu_sizeP; i++) {
LOG_F(RRC,"%02x ", ((uint8_t*)Rx_sdu)[i]);
}
LOG_F(RRC,"\n");
#endif
MSC_LOG_RX_MESSAGE(
MSC_RRC_ENB,
MSC_RRC_UE,
Rx_sdu,
sdu_sizeP,
MSC_AS_TIME_FMT" RRCConnectionSetupComplete-NB UE %x size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
ue_context_p->ue_context.rnti,
sdu_sizeP);
LOG_D(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes "
"(RRCConnectionSetupComplete-NB) ---> RRC_eNB\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
DCCH0_NB_IoT,//SRB1bis
sdu_sizeP);
if (ul_dcch_msg_NB_IoT->message.choice.c1.choice.rrcConnectionSetupComplete_r13.criticalExtensions.present ==
RRCConnectionSetupComplete_NB__criticalExtensions_PR_rrcConnectionSetupComplete_r13) {
LOG_I(RRC,"selectedPLMN_Identity_r13 : %ld\n",ul_dcch_msg_NB_IoT->message.choice.c1.choice.rrcConnectionSetupComplete_r13.criticalExtensions.choice.rrcConnectionSetupComplete_r13.selectedPLMN_Identity_r13);
LOG_I(RRC,"dedicatedInfoNAS_r13 : %02x\n",ul_dcch_msg_NB_IoT->message.choice.c1.choice.rrcConnectionSetupComplete_r13.criticalExtensions.choice.rrcConnectionSetupComplete_r13.dedicatedInfoNAS_r13);
rrc_eNB_process_RRCConnectionSetupComplete_NB_IoT(
ctxt_pP,
ue_context_p,
&ul_dcch_msg_NB_IoT->message.choice.c1.choice.rrcConnectionSetupComplete_r13.criticalExtensions.choice.rrcConnectionSetupComplete_r13);
//set Ue status CONNECTED
ue_context_p->ue_context.Status = RRC_CONNECTED_NB_IoT;
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED_NB_IoT \n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
}
ue_context_p->ue_context.ue_release_timer=0;
break;
default:
T(T_ENB_RRC_UNKNOW_MESSAGE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message %s:%u\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
__FILE__, __LINE__);
return -1;
}
return 0;
} else {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown error %s:%u\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
__FILE__, __LINE__);
return -1;
}
}
/*******************************************************************************************/
//-----------------------------------------------------------------------------
int
rrc_eNB_decode_dcch(
......@@ -4670,11 +5154,19 @@ rrc_eNB_decode_dcch(
T(T_ENB_RRC_UL_DCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
if ((Srb_id != 1) && (Srb_id != 2)) {
if (Srb_id == 3) {
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received message on SRB1bis\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
}
else if ((Srb_id != 1) && (Srb_id != 2)) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received message on SRB%d, should not have ...\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
Srb_id);
} else {
}
else {
LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received message on SRB%d\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),
Srb_id);
......@@ -4692,6 +5184,7 @@ rrc_eNB_decode_dcch(
0,
0);
#if defined(ENABLE_ITTI)
# if defined(DISABLE_ITTI_XER_PRINT)
{
......@@ -5277,7 +5770,8 @@ rrc_enb_task(
RRC_MAC_CCCH_DATA_IND(msg_p).sdu,
RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size);
srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size;
rrc_eNB_decode_ccch(&ctxt, srb_info_p, CC_id);
LOG_I(RRC,"NB-IoT Test function !!!\n");
rrc_eNB_decode_ccch_NB_IoT(&ctxt, srb_info_p, CC_id);
break;
/* Messages from PDCP */
......@@ -5292,7 +5786,7 @@ rrc_enb_task(
PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt),
RRC_DCCH_DATA_IND(msg_p).dcch_index,
msg_name_p);
rrc_eNB_decode_dcch(&ctxt,
rrc_eNB_decode_dcch_NB_IoT(&ctxt,
RRC_DCCH_DATA_IND(msg_p).dcch_index,
RRC_DCCH_DATA_IND(msg_p).sdu_p,
RRC_DCCH_DATA_IND(msg_p).sdu_size);
......
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