f1ap_du_rrc_message_transfer.c 36.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

/*! \file f1ap_du_rrc_message_transfer.c
 * \brief f1ap rrc message transfer for DU
 * \author EURECOM/NTUST
 * \date 2018
 * \version 0.1
 * \company Eurecom
 * \email: navid.nikaein@eurecom.fr, bing-kai.hong@eurecom.fr
 * \note
 * \warning
 */

#include "f1ap_common.h"
34 35
#include "f1ap_encoder.h"
#include "f1ap_decoder.h"
36
#include "f1ap_itti_messaging.h"
37

38
#include "f1ap_du_rrc_message_transfer.h"
39

40

41 42 43
#include "LTE_DL-CCCH-Message.h"
#include "LTE_DL-DCCH-Message.h"
#include "LTE_UL-DCCH-Message.h"
44

45 46 47 48
// for SRB1_logicalChannelConfig_defaultValue
#include "rrc_extern.h"
#include "common/ran_context.h"

49
#include "rrc_eNB_UE_context.h"
50
#include "asn1_msg.h"
51
#include "intertask_interface.h"
52

53 54 55 56
// undefine C_RNTI from
// openair1/PHY/LTE_TRANSPORT/transport_common.h which
// replaces in ie->value.choice.C_RNTI, causing
// a compile error
57

58 59 60
#undef C_RNTI 

extern f1ap_setup_req_t *f1ap_du_data;
61
extern RAN_CONTEXT_t RC;
Robert Schmidt's avatar
Robert Schmidt committed
62
extern f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB];
63 64 65



66
/*  DL RRC Message Transfer */
67 68 69 70
int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t       instance,
                                      uint32_t         assoc_id,
                                      uint32_t         stream,
                                      F1AP_F1AP_PDU_t *pdu) {
71
  LOG_D(F1AP, "DU_handle_DL_RRC_MESSAGE_TRANSFER \n");
72 73 74 75 76 77 78 79
  
  F1AP_DLRRCMessageTransfer_t    *container;
  F1AP_DLRRCMessageTransferIEs_t *ie;

  uint64_t        cu_ue_f1ap_id;
  uint64_t        du_ue_f1ap_id;
  uint64_t        srb_id;
  int             executeDuplication;
80
  sdu_size_t      rrc_dl_sdu_len;
81 82
  //uint64_t        subscriberProfileIDforRFP;
  //uint64_t        rAT_FrequencySelectionPriority;
83 84

  DevAssert(pdu != NULL);
85

86 87 88 89 90 91 92 93 94 95 96 97 98
  if (stream != 0) {
    LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n",
               assoc_id, stream);
    return -1;
  }

  container = &pdu->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;


  /* GNB_CU_UE_F1AP_ID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
  cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
99
  LOG_D(F1AP, "cu_ue_f1ap_id %lu \n", cu_ue_f1ap_id);
100 101 102 103 104 105


  /* GNB_DU_UE_F1AP_ID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
  du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
106 107 108
  LOG_D(F1AP, "du_ue_f1ap_id %lu associated with UE RNTI %x \n",
        du_ue_f1ap_id,
        f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer
109

Robert Schmidt's avatar
Robert Schmidt committed
110
  if (f1ap_du_add_cu_ue_id(&f1ap_du_inst[instance],du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) {
111
    LOG_E(F1AP, "Failed to find the F1AP UID \n");
112 113
    //return -1;
  }
114

115 116 117 118 119 120 121 122 123 124 125 126
  /* optional */
  /* oldgNB_DU_UE_F1AP_ID */
  if (0) {
    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID, true);
  }

  /* mandatory */
  /* SRBID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_SRBID, true);
  srb_id = ie->value.choice.SRBID;
127
  LOG_D(F1AP, "srb_id %lu \n", srb_id);
128 129 130 131 132 133 134

  /* optional */
  /* ExecuteDuplication */
  if (0) {
    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_ExecuteDuplication, true);
    executeDuplication = ie->value.choice.ExecuteDuplication;
135
    LOG_D(F1AP, "ExecuteDuplication %d \n", executeDuplication);
136 137 138 139 140 141 142 143 144
  }

  // issue in here
  /* mandatory */
  /* RRC Container */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_RRCContainer, true);
  // BK: need check
  // create an ITTI message and copy SDU
145

146 147 148 149 150
  //  message_p = itti_alloc_new_message (TASK_CU_F1, RRC_MAC_CCCH_DATA_IND);
  //  memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
  rrc_dl_sdu_len = ie->value.choice.RRCContainer.size;
  //  memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf,
  //         ccch_sdu_len);
151 152 153 154 155

  //LOG_I(F1AP, "%s() RRCContainer size %lu: ", __func__, ie->value.choice.RRCContainer.size);
  //for (int i = 0;i < ie->value.choice.RRCContainer.size; i++)
  //  printf("%02x ", ie->value.choice.RRCContainer.buf[i]);
  //printf("\n");
156 157 158 159 160 161 162 163 164

  /* optional */
  /* RAT_FrequencyPriorityInformation */
  if (0) {
    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation, true);

    switch(ie->value.choice.RAT_FrequencyPriorityInformation.present) {
      case F1AP_RAT_FrequencyPriorityInformation_PR_subscriberProfileIDforRFP:
165
        //subscriberProfileIDforRFP = ie->value.choice.RAT_FrequencyPriorityInformation.choice.subscriberProfileIDforRFP;
166 167
        break;
      case F1AP_RAT_FrequencyPriorityInformation_PR_rAT_FrequencySelectionPriority:
168
        //rAT_FrequencySelectionPriority = ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority;
169
        break;
170
      default:
171
        LOG_W(F1AP, "unhandled IE RAT_FrequencyPriorityInformation.present\n");
172
        break;
173 174 175
    }
  }

176 177 178
  // decode RRC Container and act on the message type
  AssertFatal(srb_id<3,"illegal srb_id\n");

179
  protocol_ctxt_t ctxt;
Robert Schmidt's avatar
Robert Schmidt committed
180
  ctxt.rnti      = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id);
181 182 183 184
  ctxt.module_id = instance;
  ctxt.instance  = instance;
  ctxt.enb_flag  = 1;

185 186 187 188
 struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(
                                                RC.rrc[ctxt.module_id],
                                                ctxt.rnti);

189
  if (srb_id == 0) {
190
    LTE_DL_CCCH_Message_t* dl_ccch_msg=NULL;
191 192
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
193
         &asn_DEF_LTE_DL_CCCH_Message,
194 195 196
         (void**)&dl_ccch_msg,
         ie->value.choice.RRCContainer.buf,
         rrc_dl_sdu_len,0,0);
197
    AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n");
198
    switch (dl_ccch_msg->message.choice.c1.present) {
199

200
      case LTE_DL_CCCH_MessageType__c1_PR_NOTHING:
201
        LOG_I(F1AP, "Received PR_NOTHING on DL-CCCH-Message\n");
202 203
        break;

204
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment:
205 206
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n");
207 208
        break;

209
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject:
210 211
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n");
212 213
        break;

214
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReject:
215 216
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n");
217 218
        break;

219
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup:
220
      {
221 222 223 224
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup DU_ID %lx/RNTI %x\n",
              du_ue_f1ap_id,
              f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id));
225 226
          // Get configuration

227
        LTE_RRCConnectionSetup_t* rrcConnectionSetup = &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup;
228
        AssertFatal(rrcConnectionSetup!=NULL,"rrcConnectionSetup is null\n");
229
        LTE_RadioResourceConfigDedicated_t* radioResourceConfigDedicated = &rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated;
230 231

        // get SRB logical channel information
232 233
        LTE_SRB_ToAddModList_t *SRB_configList;
        LTE_SRB_ToAddMod_t *SRB1_config;
Robert Schmidt's avatar
Robert Schmidt committed
234
        LTE_LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL;
235
        SRB_configList                 = radioResourceConfigDedicated->srb_ToAddModList;
236

237 238 239 240 241 242 243
        AssertFatal(SRB_configList!=NULL,"SRB_configList is null\n");
        for (int cnt = 0; cnt < (SRB_configList)->list.count; cnt++) {
          if ((SRB_configList)->list.array[cnt]->srb_Identity == 1) {
            SRB1_config = (SRB_configList)->list.array[cnt];

            if (SRB1_config->logicalChannelConfig) {
              if (SRB1_config->logicalChannelConfig->present ==
244
                LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
245 246 247 248 249 250 251 252 253 254 255
                SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue;
              } else {
                SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
              }
            } else {
              SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
            }
          }
        } // for
        rrc_rlc_config_asn1_req(&ctxt,
          SRB_configList,
256 257 258
          (LTE_DRB_ToAddModList_t*) NULL,
          (LTE_DRB_ToReleaseList_t*) NULL
          , (LTE_PMCH_InfoList_r9_t *) NULL,
259 260 261 262
          0,0
          );

      // This should be somewhere in the f1ap_cudu_ue_inst_t
263
      /*int macrlc_instance = 0; 
264

Robert Schmidt's avatar
Robert Schmidt committed
265
      rnti_t rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[0], du_ue_f1ap_id);
266
      struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[macrlc_instance],rnti);
267
      */  
268 269 270 271 272
      eNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; 
      AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n");

      memcpy((void*)ue_p->Srb0.Tx_buffer.Payload,
             (void*)ie->value.choice.RRCContainer.buf,
273
             rrc_dl_sdu_len); // ie->value.choice.RRCContainer.size
274 275 276

      ue_p->Srb0.Tx_buffer.payload_size = rrc_dl_sdu_len;

Robert Schmidt's avatar
Robert Schmidt committed
277 278 279 280
      LTE_MAC_MainConfig_t    *mac_MainConfig  = NULL;
      if (radioResourceConfigDedicated->mac_MainConfig)
        mac_MainConfig = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue;

281
      rrc_mac_config_req_eNB(
282
          ctxt.module_id,
283
          0, //primaryCC_id,
284
          0,0,0,0,0,0,
285
          ctxt.rnti,
286 287 288
          (LTE_BCCH_BCH_Message_t *) NULL,
          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
289
          radioResourceConfigDedicated->physicalConfigDedicated,
290
          (LTE_SCellToAddMod_r10_t *)NULL,
291
          //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
292
          (LTE_MeasObjectToAddMod_t **) NULL,
Robert Schmidt's avatar
Robert Schmidt committed
293
          mac_MainConfig,
294 295 296
          1,
          SRB1_logicalChannelConfig,
          NULL, // measGapConfig,
297
          (LTE_TDD_Config_t *) NULL,
298
          NULL,
299 300
          (LTE_SchedulingInfoList_t *) NULL,
          0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL
301
          , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL,
302
          (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL
303 304 305 306 307 308
                        ,
                        0,
                        (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL,
                        (LTE_SchedulingInfo_MBMS_r14_t *) NULL,
                        (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL,
                        (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL,
309 310
                        (LTE_MBSFN_AreaInfoList_r9_t *) NULL,
                        (LTE_MBSFNAreaConfiguration_r9_t*) NULL
311 312 313
          );
          break;
      } // case
314

315 316 317 318 319
      default:
        AssertFatal(1==0,
        "Unknown message\n");
        break;
    }// switch case
320
    return(0);
321 322
  } else if (srb_id == 1) { 

323
    LTE_DL_DCCH_Message_t* dl_dcch_msg=NULL;
324 325
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
326
         &asn_DEF_LTE_DL_DCCH_Message,
327
         (void**)&dl_dcch_msg,
328
         &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header
329
         rrc_dl_sdu_len,0,0);
330 331
    
    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) 
332
      LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed);
333
    else
334 335
      LOG_D(F1AP, "Received message: present %d and c1 present %d\n",
            dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1.present);
336

337
    if (dl_dcch_msg->message.present == LTE_DL_DCCH_MessageType_PR_c1) {
338 339 340
     
      switch (dl_dcch_msg->message.choice.c1.present) {
	
341
      case LTE_DL_DCCH_MessageType__c1_PR_NOTHING:
342
        LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n");
343
        return 0;
344
      case LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer:
345
        LOG_I(F1AP,"Received NAS DL Information Transfer\n");
346
        break;	
347
      case LTE_DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000:
348
        LOG_I(F1AP,"Received NAS sfbParametersResponseCDMA2000\n");
349
        break;  
350
      case LTE_DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest:
351
        LOG_I(F1AP,"Received NAS andoverFromEUTRAPreparationRequest\n");
352
        break;  
353
      case LTE_DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand:
354
        LOG_I(F1AP,"Received NAS mobilityFromEUTRACommand\n");
355
        break;
356
      case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration:
357
	     // handle RRCConnectionReconfiguration
358 359 360 361
        LOG_I(F1AP,
              "Logical Channel DL-DCCH (SRB1), Received RRCConnectionReconfiguration DU_ID %lx/RNTI %x\n",
              du_ue_f1ap_id,
              f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], du_ue_f1ap_id));
362
	
363
        LTE_RRCConnectionReconfiguration_t* rrcConnectionReconfiguration = &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration;
364

365
        if (rrcConnectionReconfiguration->criticalExtensions.present == LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) {
366
	        if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present ==
367 368
	         LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) {
	          LTE_RRCConnectionReconfiguration_r8_IEs_t* rrcConnectionReconfiguration_r8 =
369
	          &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8;
370
	    
371
            if (rrcConnectionReconfiguration_r8->mobilityControlInfo) {
372
	            LOG_I(F1AP, "Mobility Control Information is present\n");
373 374 375
	            AssertFatal(1==0,"Can't handle this yet in DU\n");
	          }
	          if (rrcConnectionReconfiguration_r8->measConfig != NULL) {
376
	            LOG_I(F1AP, "Measurement Configuration is present\n");
377
	          } 
378
	    
379
      	    if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) {
380
              LOG_I(F1AP, "Radio Resource Configuration is present\n");
381
      	      uint8_t DRB2LCHAN[8];
382 383
              long drb_id;
              int i;
384 385 386
              LTE_DRB_ToAddModList_t  *DRB_configList  = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->drb_ToAddModList;
              LTE_SRB_ToAddModList_t  *SRB_configList  = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->srb_ToAddModList;
              LTE_DRB_ToReleaseList_t *DRB_ReleaseList = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->drb_ToReleaseList;
Robert Schmidt's avatar
Robert Schmidt committed
387
              LTE_MAC_MainConfig_t    *mac_MainConfig  = NULL;
388
              
389 390 391
              for (i = 0; i< 8; i++){
                DRB2LCHAN[i] = 0;
              }
392

393
              if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig) {
LouisAdrien's avatar
LouisAdrien committed
394
                LOG_D(F1AP, "MAC Main Configuration is present\n");
395

Robert Schmidt's avatar
Robert Schmidt committed
396
                mac_MainConfig = &rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue;
397

398
                /* CDRX Configuration */
399 400 401
                if (mac_MainConfig->drx_Config == NULL) {
                  LOG_W(F1AP, "drx_Configuration parameter is NULL, cannot configure local UE parameters or CDRX is deactivated\n");
                } else {
402
                  MessageDef *message_p = NULL;
403

404 405 406 407 408
                  /* Send DRX configuration to MAC task to configure timers of local UE context */
                  message_p = itti_alloc_new_message(TASK_DU_F1, RRC_MAC_DRX_CONFIG_REQ);
                  RRC_MAC_DRX_CONFIG_REQ(message_p).rnti = ctxt.rnti;
                  RRC_MAC_DRX_CONFIG_REQ(message_p).drx_Configuration = mac_MainConfig->drx_Config;
                  itti_send_msg_to_task(TASK_MAC_ENB, ctxt.module_id, message_p);
LouisAdrien's avatar
LouisAdrien committed
409
                  LOG_D(F1AP, "DRX configured in MAC Main Configuration for RRC Connection Reconfiguration\n");
410
                }
411
                /* End of CDRX configuration */
412
              }
413

414
              LTE_MeasGapConfig_t     *measGapConfig   = NULL;
Robert Schmidt's avatar
Robert Schmidt committed
415
              struct LTE_PhysicalConfigDedicated* physicalConfigDedicated = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->physicalConfigDedicated;
416 417 418 419
              rrc_rlc_config_asn1_req(
                &ctxt,
                SRB_configList, // NULL,  //LG-RK 14/05/2014 SRB_configList,
                DRB_configList,
420
                DRB_ReleaseList, (LTE_PMCH_InfoList_r9_t *) NULL, 0, 0
421 422 423 424 425 426 427 428 429 430
                );

              if (SRB_configList != NULL) {
                for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) {
                  if (SRB_configList->list.array[i]->srb_Identity == 1 ){
                    ue_context_p->ue_context.Srb1.Active=1;
                  }
                  else if (SRB_configList->list.array[i]->srb_Identity == 2 )  {
                    ue_context_p->ue_context.Srb2.Active=1;
                    ue_context_p->ue_context.Srb2.Srb_info.Srb_id=2;
431
                    LOG_I(F1AP, "[DU %d] SRB2 is now active\n",ctxt.module_id);
432
                  } else {
433
                    LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n",ctxt.module_id,
434 435 436 437 438 439 440 441 442
                   SRB_configList->list.array[i]->srb_Identity);
                  }
                }
              }

              if (DRB_configList != NULL) {
                for (i = 0; i < DRB_configList->list.count; i++) {  // num max DRB (11-3-8)
                  if (DRB_configList->list.array[i]) {
                    drb_id = (int)DRB_configList->list.array[i]->drb_Identity;
443 444 445 446 447 448
                    LOG_I(F1AP,
                          "[DU %d] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %x, reconfiguring DRB %d/LCID %d\n",
                          ctxt.module_id,
                          ctxt.rnti,
                          (int)DRB_configList->list.array[i]->drb_Identity,
                          (int)*DRB_configList->list.array[i]->logicalChannelIdentity);
449 450 451 452 453 454 455 456 457 458 459 460 461

                  if (ue_context_p->ue_context.DRB_active[drb_id] == 0) {
                    ue_context_p->ue_context.DRB_active[drb_id] = 1;

                    if (DRB_configList->list.array[i]->logicalChannelIdentity) {
                      DRB2LCHAN[i] = (uint8_t) * DRB_configList->list.array[i]->logicalChannelIdentity;
                    }

                    rrc_mac_config_req_eNB(
                      ctxt.module_id,
                      0,0,0,0,0,0,
                   0,
                   ue_context_p->ue_context.rnti,
462 463 464
                   (LTE_BCCH_BCH_Message_t *) NULL,
                   (LTE_RadioResourceConfigCommonSIB_t *) NULL,
                   (LTE_RadioResourceConfigCommonSIB_t *) NULL,
465
                   physicalConfigDedicated,
466
                   (LTE_SCellToAddMod_r10_t *)NULL,
467
                   //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
468
                   (LTE_MeasObjectToAddMod_t **) NULL,
469 470 471 472
                   mac_MainConfig,
                   DRB2LCHAN[i],
                   DRB_configList->list.array[i]->logicalChannelConfig,
                   measGapConfig,
473
                   (LTE_TDD_Config_t *) NULL,
474
                   NULL,
475 476
                   (LTE_SchedulingInfoList_t *) NULL,
                   0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL
477 478
                   , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL,
                   (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL,
479 480 481 482 483
                         0,
                         (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL,
                         (LTE_SchedulingInfo_MBMS_r14_t *) NULL,
                         (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL,
                         (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL,
484 485
                         (LTE_MBSFN_AreaInfoList_r9_t *) NULL,
                         (LTE_MBSFNAreaConfiguration_r9_t*) NULL
486 487
                   );
                  }
488

489 490 491 492 493 494 495 496
                } else {        // remove LCHAN from MAC/PHY
                  AssertFatal(1==0,"Can't handle this yet in DU\n");  
                } 
        	     }
        	   }
           }
         }
       }
497
	    break;
498
      case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease:
499
  	    // handle RRCConnectionRelease
500
        LOG_I(F1AP, "Received RRCConnectionRelease\n");
501
  	    break;
502
      case LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand:
503
        LOG_I(F1AP, "Received securityModeCommand\n");
504
          break; 
505
      case LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
506
        LOG_I(F1AP, "Received ueCapabilityEnquiry\n");
507
          break;
508 509 510 511 512 513
      case LTE_DL_DCCH_MessageType__c1_PR_counterCheck:
      case LTE_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10:
      case LTE_DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10:
      case LTE_DL_DCCH_MessageType__c1_PR_spare1:
      case LTE_DL_DCCH_MessageType__c1_PR_spare2:
      case LTE_DL_DCCH_MessageType__c1_PR_spare3:
514
  	    break;
515
      case LTE_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9:
516
        LOG_I(F1AP, "Received ueInformationRequest_r9\n");
517
        break;
518
      case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionResume_r13:
519
        LOG_I(F1AP, "Received rrcConnectionResume_r13\n");
520 521
	   } 
	 }	
522 523 524 525 526
  }
  else if (srb_id == 2) {
    
  }

527
  LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", srb_id);
528 529 530 531
  rlc_op_status_t    rlc_status;
  boolean_t          ret             = TRUE;
  mem_block_t       *pdcp_pdu_p      = NULL; 
  pdcp_pdu_p = get_free_mem_block(rrc_dl_sdu_len, __func__);
532

533 534 535 536 537 538 539 540
  //LOG_I(F1AP, "PRRCContainer size %lu:", ie->value.choice.RRCContainer.size);
  //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++)
  //  printf("%02x ", ie->value.choice.RRCContainer.buf[i]);

  //printf (", PDCP PDU size %d:", rrc_dl_sdu_len);
  //for (int i=0;i<rrc_dl_sdu_len;i++) printf("%2x ",pdcp_pdu_p->data[i]);
  //printf("\n");

541

542 543 544
  if (pdcp_pdu_p != NULL) {
    memset(pdcp_pdu_p->data, 0, rrc_dl_sdu_len);
    memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, rrc_dl_sdu_len);
545

546 547 548 549 550 551 552 553 554 555 556 557 558
      rlc_status = rlc_data_req(&ctxt
                                , 1
                                , MBMS_FLAG_NO
                                , srb_id
                                , 0
                                , 0
                                , rrc_dl_sdu_len
                                , pdcp_pdu_p
                                ,NULL
                                ,NULL
                                );
      switch (rlc_status) {
        case RLC_OP_STATUS_OK:
559
          //LOG_I(F1AP, "Data sending request over RLC succeeded!\n");
560 561 562 563
          ret=TRUE;
          break;

        case RLC_OP_STATUS_BAD_PARAMETER:
564
          LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
565 566
          ret= FALSE;
          break;
567

568
        case RLC_OP_STATUS_INTERNAL_ERROR:
569
          LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n");
570 571
          ret= FALSE;
          break;
572

573
        case RLC_OP_STATUS_OUT_OF_RESSOURCES:
574
          LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n");
575 576 577 578
          ret= FALSE;
          break;

        default:
579
          LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
580 581 582 583 584 585
          ret= FALSE;
          break;
      } // switch case
      return ret; 
    } // if pdcp_pdu_p
  
586 587
  return 0;
  
588 589
}

590
int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, 
591
                                    const f1ap_ul_rrc_message_t *msg) {
592
  const rnti_t rnti = msg->rnti;
593

594 595 596 597
  F1AP_F1AP_PDU_t                pdu;
  F1AP_ULRRCMessageTransfer_t    *out;
  F1AP_ULRRCMessageTransferIEs_t *ie;

598 599
  uint8_t *buffer = NULL;
  uint32_t len;
600

601

602
  LOG_I(F1AP, "[DU %d] %s: size %d UE RNTI %x in SRB %d\n",
603
        instance, __func__, msg->rrc_container_length, rnti, msg->srb_id);
604

605 606 607 608 609
  //LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, msg->rrc_container_length);
  //for (int i = 0;i < msg->rrc_container_length; i++)
  //  printf("%02x ", msg->rrc_container[i]);
  //printf("\n");

610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
  /* Create */
  /* 0. Message Type */
  memset(&pdu, 0, sizeof(pdu));
  pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
  pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t));
  pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_ULRRCMessageTransfer;
  pdu.choice.initiatingMessage->criticality   = F1AP_Criticality_ignore;
  pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_ULRRCMessageTransfer;
  out = &pdu.choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
  
  /* mandatory */
  /* c1. GNB_CU_UE_F1AP_ID */
  ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
626

Robert Schmidt's avatar
Robert Schmidt committed
627
  ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_du_inst[instance], rnti);
628

629 630 631 632 633 634 635 636
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* mandatory */
  /* c2. GNB_DU_UE_F1AP_ID */
  ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
Robert Schmidt's avatar
Robert Schmidt committed
637
  ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_du_inst[instance], rnti);
638 639 640 641 642 643 644 645
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* mandatory */
  /* c3. SRBID */
  ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t));
  ie->id                            = F1AP_ProtocolIE_ID_id_SRBID;
  ie->criticality                   = F1AP_Criticality_reject;
  ie->value.present                 = F1AP_ULRRCMessageTransferIEs__value_PR_SRBID;
646
  ie->value.choice.SRBID            = msg->srb_id;
647 648 649 650 651 652 653 654 655
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  // issue in here
  /* mandatory */
  /* c4. RRCContainer */
  ie = (F1AP_ULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_ULRRCMessageTransferIEs_t));
  ie->id                            = F1AP_ProtocolIE_ID_id_RRCContainer;
  ie->criticality                   = F1AP_Criticality_reject;
  ie->value.present                 = F1AP_ULRRCMessageTransferIEs__value_PR_RRCContainer;
656 657 658
  OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer,
                       (const char *) msg->rrc_container,
                       msg->rrc_container_length);
659 660
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

661 662
  if (msg->srb_id == 1 || msg->srb_id == 2) {
    struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_get_ue_context(RC.rrc[instance], rnti);
663 664

   
665
    LTE_UL_DCCH_Message_t* ul_dcch_msg=NULL;
666 667
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
668
         &asn_DEF_LTE_UL_DCCH_Message,
669 670
         (void**)&ul_dcch_msg,
         &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header
671
         msg->rrc_container_length, 0, 0);
672 673
    
    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) 
674
      LOG_E(F1AP, " Failed to decode UL-DCCH (%zu bytes)\n",dec_rval.consumed);
675
    else
676 677
      LOG_I(F1AP, "Received message: present %d and c1 present %d\n",
            ul_dcch_msg->message.present, ul_dcch_msg->message.choice.c1.present);
678

679
    if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_c1) {
680 681

      switch (ul_dcch_msg->message.choice.c1.present) {
682
      case LTE_UL_DCCH_MessageType__c1_PR_NOTHING:   /* No components present */
683 684
        break;

685
      case LTE_UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000:
686 687
        break;

688
      case LTE_UL_DCCH_MessageType__c1_PR_measurementReport:
689 690
        break;

691
      case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete:
692
        LOG_I(F1AP, "[MSG] RRC UL rrcConnectionReconfigurationComplete\n");
693
        
694
        /* CDRX: activated when RRC Connection Reconfiguration Complete is received */
695 696 697
        int UE_id_mac = find_UE_id(instance, rnti);
        
        if (UE_id_mac == -1) {
698
          LOG_E(F1AP, "Can't find UE_id(MAC) of UE rnti %x\n", rnti);
699
          break;
700 701
        }
        
702
        UE_sched_ctrl_t *UE_scheduling_control = &(RC.mac[instance]->UE_info.UE_sched_ctrl[UE_id_mac]);
703
        
704
        if (UE_scheduling_control->cdrx_waiting_ack == TRUE) {
705
          UE_scheduling_control->cdrx_waiting_ack = FALSE;
706
          UE_scheduling_control->cdrx_configured = TRUE; // Set to TRUE when RRC Connection Reconfiguration Complete is received
LouisAdrien's avatar
LouisAdrien committed
707
          LOG_I(F1AP, "CDRX configuration activated after RRC Connection Reconfiguration Complete reception\n");
708
        }
709 710
        /* End of CDRX processing */
        
711 712
        break;

713
      case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete:
714 715
        break;

716
      case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete:
717
        LOG_I(F1AP, "[MSG] RRC UL rrcConnectionSetupComplete \n");
718 719
        
        if(!ue_context_p){
720
          LOG_E(F1AP, "Did not find the UE context associated with UE RNTOI %x, ue_context_p is NULL\n", rnti);
721

722
        } else {
723
          LOG_I(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti);
724
          ue_context_p->ue_context.Status = RRC_CONNECTED;
725
        }
726 727
        break;

728
      case LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete:
729
        LOG_I(F1AP, "[MSG] RRC securityModeComplete \n");
730 731
        break;

732
      case LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure:
733 734
        break;

735
      case LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation:
736
        LOG_I(F1AP, "[MSG] RRC ueCapabilityInformation \n");
737 738
        break;

739
      case LTE_UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer:
740 741
        break;

742
      case LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer:
743
        LOG_I(F1AP,"[MSG] RRC UL Information Transfer \n");
744 745
        break;

746
      case LTE_UL_DCCH_MessageType__c1_PR_counterCheckResponse:
747 748
        break;

749
      case LTE_UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9:
750 751
        break;

752
      case LTE_UL_DCCH_MessageType__c1_PR_proximityIndication_r9:
753 754
       break;

755
      case LTE_UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10:
756 757
        break;

758
      case LTE_UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10:
759
       break;
760

761
      case LTE_UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10:
762 763 764 765
       break;
      }
    }
  }
766 767
    /* encode */
  if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
768
    LOG_E(F1AP, "Failed to encode F1 setup request\n");
769
    return -1;
770 771
  }

772
  du_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data->assoc_id, buffer, len, f1ap_du_data->default_sctp_stream_id);
773
  return 0;
774 775
}

776

777
/*  UL RRC Message Transfer */
778 779 780 781
int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t     module_idP,
                                            int             CC_idP,
                                            int             UE_id,
                                            rnti_t          rntiP,
782
                                            const uint8_t   *sduP,
783
                                            sdu_size_t      sdu_lenP) {
784 785 786 787 788 789
  F1AP_F1AP_PDU_t                       pdu;
  F1AP_InitialULRRCMessageTransfer_t    *out;
  F1AP_InitialULRRCMessageTransferIEs_t *ie;

  uint8_t  *buffer;
  uint32_t  len;
Robert Schmidt's avatar
Robert Schmidt committed
790
  int f1ap_uid = f1ap_add_ue (&f1ap_du_inst[module_idP], module_idP, CC_idP,UE_id, rntiP);
791 792

  if (f1ap_uid  < 0 ) {
793
    LOG_E(F1AP, "Failed to add UE \n");
794 795
    return -1;
  }
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813

  /* Create */
  /* 0. Message Type */
  memset(&pdu, 0, sizeof(pdu));
  pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
  pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t));
  pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_InitialULRRCMessageTransfer;
  pdu.choice.initiatingMessage->criticality   = F1AP_Criticality_ignore;
  pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
  out = &pdu.choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
  

  /* mandatory */
  /* c1. GNB_DU_UE_F1AP_ID */
  ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
Robert Schmidt's avatar
Robert Schmidt committed
814
  ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_du_inst[module_idP].f1ap_ue[f1ap_uid].du_ue_f1ap_id;
815 816 817 818 819 820 821 822 823 824
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* mandatory */
  /* c2. NRCGI */
  ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_NRCGI;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_NRCGI;

  F1AP_NRCGI_t nRCGI;
825
  memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t));
826 827
  MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[0], f1ap_du_data->mnc[0], f1ap_du_data->mnc_digit_length[0],
                                         &nRCGI.pLMN_Identity);
828
  NR_CELL_ID_TO_BIT_STRING(f1ap_du_data->nr_cellid[0], &nRCGI.nRCellIdentity);
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
  ie->value.choice.NRCGI = nRCGI;

  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* mandatory */
  /* c3. C_RNTI */  // 16
  ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_C_RNTI;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
  C_RNTI_TO_BIT_STRING(rntiP, &ie->value.choice.C_RNTI);
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* mandatory */
  /* c4. RRCContainer */
  ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t));
  ie->id                            = F1AP_ProtocolIE_ID_id_RRCContainer;
  ie->criticality                   = F1AP_Criticality_reject;
  ie->value.present                 = F1AP_InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
Robert Schmidt's avatar
Robert Schmidt committed
848
  OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char *)sduP, sdu_lenP);
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* optional */
  /* c5. DUtoCURRCContainer */
  if (0) {
    ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t));
    ie->id                             = F1AP_ProtocolIE_ID_id_DUtoCURRCContainer;
    ie->criticality                    = F1AP_Criticality_reject;
    ie->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
    OCTET_STRING_fromBuf(&ie->value.choice.DUtoCURRCContainer, "dummy_val",
                       strlen("dummy_val"));
    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
  }

    /* encode */
  if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
865
    LOG_E(F1AP, "Failed to encode F1 setup request\n");
866
    return -1;
867 868
  }

869

870 871 872 873 874 875
  struct rrc_eNB_ue_context_s* ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[module_idP]);
  ue_context_p->ue_id_rnti                    = rntiP; 
  ue_context_p->ue_context.rnti               = rntiP;
  ue_context_p->ue_context.random_ue_identity = rntiP;
  ue_context_p->ue_context.Srb0.Active        = 1;
  RB_INSERT(rrc_ue_tree_s, &RC.rrc[module_idP]->rrc_ue_head, ue_context_p);
876 877
  du_f1ap_itti_send_sctp_data_req(module_idP, f1ap_du_data->assoc_id, buffer, len,  f1ap_du_data->default_sctp_stream_id);

878
  return 0;
879
}
880
    
881

882
void init_f1ap_du_ue_inst (void) {
883

Robert Schmidt's avatar
Robert Schmidt committed
884
   memset(f1ap_du_inst, 0, sizeof(f1ap_du_inst));
885 886 887
}