f1ap_du_rrc_message_transfer.c 55.4 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
#include "NR_DL-CCCH-Message.h"
#include "NR_UL-CCCH-Message.h"
#include "NR_DL-DCCH-Message.h"
#include "NR_UL-DCCH-Message.h"
49 50 51 52
// for SRB1_logicalChannelConfig_defaultValue
#include "rrc_extern.h"
#include "common/ran_context.h"

53
#include "rrc_eNB_UE_context.h"
54
#include "openair2/RRC/NR/rrc_gNB_UE_context.h"
55
#include "asn1_msg.h"
56
#include "intertask_interface.h"
57
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
58

Xue Song's avatar
Xue Song committed
59
int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t       instance,
60 61 62
    uint32_t         assoc_id,
    uint32_t         stream,
    F1AP_F1AP_PDU_t *pdu);
63

64
/*  DL RRC Message Transfer */
65 66 67 68
int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t       instance,
                                      uint32_t         assoc_id,
                                      uint32_t         stream,
                                      F1AP_F1AP_PDU_t *pdu) {
Xue Song's avatar
Xue Song committed
69 70 71 72 73 74
  if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) {
    LOG_I(F1AP, "node is gNB DU, call DU_handle_DL_NR_RRC_MESSAGE_TRANSFER \n");
    DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance, assoc_id, stream, pdu);
    return 0;
  }

75
  LOG_D(F1AP, "DU_handle_DL_RRC_MESSAGE_TRANSFER \n");
76 77 78 79 80 81
  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;
82
  sdu_size_t      rrc_dl_sdu_len;
83 84
  //uint64_t        subscriberProfileIDforRFP;
  //uint64_t        rAT_FrequencySelectionPriority;
85
  DevAssert(pdu != NULL);
86

87 88
  if (stream != 0) {
    LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n",
89
          assoc_id, stream);
90 91 92 93 94 95 96 97
    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;
98
  LOG_D(F1AP, "cu_ue_f1ap_id %lu \n", cu_ue_f1ap_id);
99 100 101 102
  /* 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;
103 104
  LOG_D(F1AP, "du_ue_f1ap_id %lu associated with UE RNTI %x \n",
        du_ue_f1ap_id,
105
        f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer
106

107
  if (f1ap_du_add_cu_ue_id(false, instance,du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) {
108
    LOG_E(F1AP, "Failed to find the F1AP UID \n");
109 110
    //return -1;
  }
111

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

  /* mandatory */
  /* SRBID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_SRBID, true);
  srb_id = ie->value.choice.SRBID;
124
  LOG_D(F1AP, "srb_id %lu \n", srb_id);
125 126 127 128 129

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

  // 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
142
  //  message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_MAC_CCCH_DATA_IND);
143 144 145 146
  //  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);
147 148 149 150 151

  //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");
152 153 154 155 156

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

    switch(ie->value.choice.RAT_FrequencyPriorityInformation.present) {
Xue Song's avatar
Xue Song committed
160
      case F1AP_RAT_FrequencyPriorityInformation_PR_eNDC:
161
        //subscriberProfileIDforRFP = ie->value.choice.RAT_FrequencyPriorityInformation.choice.subscriberProfileIDforRFP;
162
        break;
163

Xue Song's avatar
Xue Song committed
164
      case F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN:
165
        //rAT_FrequencySelectionPriority = ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority;
166
        break;
167

168
      default:
169
        LOG_W(F1AP, "unhandled IE RAT_FrequencyPriorityInformation.present\n");
170
        break;
171 172 173
    }
  }

174 175
  // decode RRC Container and act on the message type
  AssertFatal(srb_id<3,"illegal srb_id\n");
176
  protocol_ctxt_t ctxt;
177
  ctxt.rnti      = f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id);
178 179 180
  ctxt.module_id = instance;
  ctxt.instance  = instance;
  ctxt.enb_flag  = 1;
181 182 183
  struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(
        RC.rrc[ctxt.module_id],
        ctxt.rnti);
184

185
  if (srb_id == 0) {
186
    LTE_DL_CCCH_Message_t *dl_ccch_msg=NULL;
187 188
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
189 190 191 192
                           &asn_DEF_LTE_DL_CCCH_Message,
                           (void **)&dl_ccch_msg,
                           ie->value.choice.RRCContainer.buf,
                           rrc_dl_sdu_len,0,0);
193
    AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n");
194

195
    switch (dl_ccch_msg->message.choice.c1.present) {
196
      case LTE_DL_CCCH_MessageType__c1_PR_NOTHING:
197
        LOG_I(F1AP, "Received PR_NOTHING on DL-CCCH-Message\n");
198 199
        break;

200
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment:
201 202
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n");
203 204
        break;

205
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject:
206 207
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n");
208 209
        break;

210
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReject:
211 212
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n");
213 214
        break;

215
      case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: {
216 217 218
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup DU_ID %lx/RNTI %x\n",
              du_ue_f1ap_id,
219
              f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id));
220 221
        // Get configuration
        LTE_RRCConnectionSetup_t *rrcConnectionSetup = &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup;
222
        AssertFatal(rrcConnectionSetup!=NULL,"rrcConnectionSetup is null\n");
223
        LTE_RadioResourceConfigDedicated_t *radioResourceConfigDedicated = &rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated;
224
        // get SRB logical channel information
225 226
        LTE_SRB_ToAddModList_t *SRB_configList;
        LTE_SRB_ToAddMod_t *SRB1_config;
Robert Schmidt's avatar
Robert Schmidt committed
227
        LTE_LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL;
228 229
        SRB_configList                 = radioResourceConfigDedicated->srb_ToAddModList;
        AssertFatal(SRB_configList!=NULL,"SRB_configList is null\n");
230

231 232 233 234 235 236
        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 ==
237
                  LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) {
238 239 240 241 242 243 244 245 246 247
                SRB1_logicalChannelConfig = &SRB1_config->logicalChannelConfig->choice.explicitValue;
              } else {
                SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
              }
            } else {
              SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue;
            }
          }
        } // for

248 249 250 251 252 253 254 255 256 257
        rrc_rlc_config_asn1_req(&ctxt,
                                SRB_configList,
                                (LTE_DRB_ToAddModList_t *) NULL,
                                (LTE_DRB_ToReleaseList_t *) NULL
                                , (LTE_PMCH_InfoList_r9_t *) NULL,
                                0,0
                               );
        // This should be somewhere in the f1ap_cudu_ue_inst_t
        /*int macrlc_instance = 0;

258
        rnti_t rnti = f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id);
259 260 261 262 263 264 265 266 267
        struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[macrlc_instance],rnti);
        */
        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,
               rrc_dl_sdu_len); // ie->value.choice.RRCContainer.size
        ue_p->Srb0.Tx_buffer.payload_size = rrc_dl_sdu_len;
        LTE_MAC_MainConfig_t    *mac_MainConfig  = NULL;
268

269 270
        if (radioResourceConfigDedicated->mac_MainConfig)
          mac_MainConfig = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue;
Robert Schmidt's avatar
Robert Schmidt committed
271

272
        rrc_mac_config_req_eNB(
273
          ctxt.module_id,
274
          0, //primaryCC_id,
275
          0,0,0,0,0,0,
276
          ctxt.rnti,
277 278 279
          (LTE_BCCH_BCH_Message_t *) NULL,
          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
280
          radioResourceConfigDedicated->physicalConfigDedicated,
281
          (LTE_SCellToAddMod_r10_t *)NULL,
282
          //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
283
          (LTE_MeasObjectToAddMod_t **) NULL,
Robert Schmidt's avatar
Robert Schmidt committed
284
          mac_MainConfig,
285 286 287
          1,
          SRB1_logicalChannelConfig,
          NULL, // measGapConfig,
288
          (LTE_TDD_Config_t *) NULL,
289
          NULL,
290 291
          (LTE_SchedulingInfoList_t *) NULL,
          0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL
292
          , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL,
293
          (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL
294 295 296 297 298 299 300 301 302 303
          ,
          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,
          (LTE_MBSFN_AreaInfoList_r9_t *) NULL,
          (LTE_MBSFNAreaConfiguration_r9_t *) NULL
        );
        break;
304
      } // case
305

306 307
      default:
        AssertFatal(1==0,
308
                    "Unknown message\n");
309 310 311
        break;
    }// switch case

312 313 314
    return(0);
  } else if (srb_id == 1) {
    LTE_DL_DCCH_Message_t *dl_dcch_msg=NULL;
315 316
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
317 318 319 320 321 322
                           &asn_DEF_LTE_DL_DCCH_Message,
                           (void **)&dl_dcch_msg,
                           &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header
                           rrc_dl_sdu_len,0,0);

    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0))
323
      LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed);
324
    else
325 326
      LOG_D(F1AP, "Received message: present %d and c1 present %d\n",
            dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1.present);
327

328
    if (dl_dcch_msg->message.present == LTE_DL_DCCH_MessageType_PR_c1) {
329
      switch (dl_dcch_msg->message.choice.c1.present) {
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
        case LTE_DL_DCCH_MessageType__c1_PR_NOTHING:
          LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n");
          return 0;

        case LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer:
          LOG_I(F1AP,"Received NAS DL Information Transfer\n");
          break;

        case LTE_DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000:
          LOG_I(F1AP,"Received NAS sfbParametersResponseCDMA2000\n");
          break;

        case LTE_DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest:
          LOG_I(F1AP,"Received NAS andoverFromEUTRAPreparationRequest\n");
          break;

        case LTE_DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand:
          LOG_I(F1AP,"Received NAS mobilityFromEUTRACommand\n");
          break;

        case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration:
          // handle RRCConnectionReconfiguration
          LOG_I(F1AP,
                "Logical Channel DL-DCCH (SRB1), Received RRCConnectionReconfiguration DU_ID %lx/RNTI %x\n",
                du_ue_f1ap_id,
355
                f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id));
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
          LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration = &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration;

          if (rrcConnectionReconfiguration->criticalExtensions.present == LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1) {
            if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present ==
                LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) {
              LTE_RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 =
                &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8;

              if (rrcConnectionReconfiguration_r8->mobilityControlInfo) {
                LOG_I(F1AP, "Mobility Control Information is present\n");
                AssertFatal(1==0,"Can't handle this yet in DU\n");
              }

              if (rrcConnectionReconfiguration_r8->measConfig != NULL) {
                LOG_I(F1AP, "Measurement Configuration is present\n");
371
              }
372

373 374 375 376 377 378 379 380 381
              if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) {
                LOG_I(F1AP, "Radio Resource Configuration is present\n");
                uint8_t DRB2LCHAN[8];
                long drb_id;
                int i;
                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;
                LTE_MAC_MainConfig_t    *mac_MainConfig  = NULL;
382

383 384 385
                for (i = 0; i< 8; i++) {
                  DRB2LCHAN[i] = 0;
                }
386

387 388 389
                if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig) {
                  LOG_D(F1AP, "MAC Main Configuration is present\n");
                  mac_MainConfig = &rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue;
390

391 392 393 394 395 396 397 398 399 400 401 402 403 404
                  /* CDRX Configuration */
                  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 {
                    MessageDef *message_p = NULL;
                    /* Send DRX configuration to MAC task to configure timers of local UE context */
                    message_p = itti_alloc_new_message(TASK_DU_F1, 0, 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);
                    LOG_D(F1AP, "DRX configured in MAC Main Configuration for RRC Connection Reconfiguration\n");
                  }

                  /* End of CDRX configuration */
405 406
                }

407 408 409 410 411 412 413
                LTE_MeasGapConfig_t     *measGapConfig   = NULL;
                struct LTE_PhysicalConfigDedicated *physicalConfigDedicated = rrcConnectionReconfiguration_r8->radioResourceConfigDedicated->physicalConfigDedicated;
                rrc_rlc_config_asn1_req(
                  &ctxt,
                  SRB_configList, // NULL,  //LG-RK 14/05/2014 SRB_configList,
                  DRB_configList,
                  DRB_ReleaseList, (LTE_PMCH_InfoList_r9_t *) NULL, 0, 0
414 415
                );

416 417 418 419 420 421 422 423 424 425 426 427
                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;
                      LOG_I(F1AP, "[DU %d] SRB2 is now active\n",ctxt.module_id);
                    } else {
                      LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n",ctxt.module_id,
                            SRB_configList->list.array[i]->srb_Identity);
                    }
428
                  }
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
                }

                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;
                      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);

                      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,
                          (LTE_BCCH_BCH_Message_t *) NULL,
                          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
                          (LTE_RadioResourceConfigCommonSIB_t *) NULL,
                          physicalConfigDedicated,
                          (LTE_SCellToAddMod_r10_t *)NULL,
                          //(struct PhysicalConfigDedicatedSCell_r10 *)NULL,
                          (LTE_MeasObjectToAddMod_t **) NULL,
                          mac_MainConfig,
                          DRB2LCHAN[i],
                          DRB_configList->list.array[i]->logicalChannelConfig,
                          measGapConfig,
                          (LTE_TDD_Config_t *) NULL,
                          NULL,
                          (LTE_SchedulingInfoList_t *) NULL,
                          0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL
                          , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL,
                          (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL,
                          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,
                          (LTE_MBSFN_AreaInfoList_r9_t *) NULL,
                          (LTE_MBSFNAreaConfiguration_r9_t *) NULL
                        );
                      }
                    } else {        // remove LCHAN from MAC/PHY
                      AssertFatal(1==0,"Can't handle this yet in DU\n");
                    }
483 484 485
                  }
                }
              }
486 487
            }
          }
488

489
          break;
490

491 492 493 494
        case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease:
          // handle RRCConnectionRelease
          LOG_I(F1AP, "Received RRCConnectionRelease\n");
          break;
495

496 497 498
        case LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand:
          LOG_I(F1AP, "Received securityModeCommand\n");
          break;
499

500 501 502
        case LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
          LOG_I(F1AP, "Received ueCapabilityEnquiry\n");
          break;
503

504 505 506 507 508 509
        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:
510
          break;
511 512 513 514 515 516 517 518 519 520

        case LTE_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9:
          LOG_I(F1AP, "Received ueInformationRequest_r9\n");
          break;

        case LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionResume_r13:
          LOG_I(F1AP, "Received rrcConnectionResume_r13\n");
      }
    }
  } else if (srb_id == 2) {
521 522
  }

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

529 530 531 532 533 534 535 536
  //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");

537 538 539
  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);
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
    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:
        //LOG_I(F1AP, "Data sending request over RLC succeeded!\n");
        ret=TRUE;
        break;
557

558 559 560 561
      case RLC_OP_STATUS_BAD_PARAMETER:
        LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
        ret= FALSE;
        break;
562

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

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

573 574 575 576 577 578 579 580
      default:
        LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
        ret= FALSE;
        break;
    } // switch case

    return ret;
  } // if pdcp_pdu_p
581

582
  return 0;
583 584
}

585
int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
586
                                    const f1ap_ul_rrc_message_t *msg) {
587
  const rnti_t rnti = msg->rnti;
588 589 590
  F1AP_F1AP_PDU_t                pdu;
  F1AP_ULRRCMessageTransfer_t    *out;
  F1AP_ULRRCMessageTransferIEs_t *ie;
591 592
  uint8_t *buffer = NULL;
  uint32_t len;
593
  LOG_I(F1AP, "[DU %ld] %s: size %d UE RNTI %x in SRB %d\n",
594
        instance, __func__, msg->rrc_container_length, rnti, msg->srb_id);
595 596 597 598
  //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");
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
  /* 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;
614
  ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(false, instance, rnti);
615 616 617 618 619 620 621
  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;
622
  ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(false, instance, rnti);
623 624 625 626 627 628 629
  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;
630
  ie->value.choice.SRBID            = msg->srb_id;
631 632 633 634 635 636 637 638
  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;
639 640 641
  OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer,
                       (const char *) msg->rrc_container,
                       msg->rrc_container_length);
642 643
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

644
  if (msg->srb_id == 1 || msg->srb_id == 2) {
645 646
    struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[instance], rnti);
    LTE_UL_DCCH_Message_t *ul_dcch_msg=NULL;
647 648
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
649 650 651 652 653 654
                           &asn_DEF_LTE_UL_DCCH_Message,
                           (void **)&ul_dcch_msg,
                           &ie->value.choice.RRCContainer.buf[1], // buf[0] includes the pdcp header
                           msg->rrc_container_length, 0, 0);

    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0))
655
      LOG_E(F1AP, " Failed to decode UL-DCCH (%zu bytes)\n",dec_rval.consumed);
656
    else
657 658
      LOG_I(F1AP, "Received message: present %d and c1 present %d\n",
            ul_dcch_msg->message.present, ul_dcch_msg->message.choice.c1.present);
659

660
    if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_c1) {
661
      switch (ul_dcch_msg->message.choice.c1.present) {
662 663
        case LTE_UL_DCCH_MessageType__c1_PR_NOTHING:   /* No components present */
          break;
664

665 666
        case LTE_UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000:
          break;
667

668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687
        case LTE_UL_DCCH_MessageType__c1_PR_measurementReport:
          break;

        case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete:
          LOG_I(F1AP, "[MSG] RRC UL rrcConnectionReconfigurationComplete\n");
          /* CDRX: activated when RRC Connection Reconfiguration Complete is received */
          int UE_id_mac = find_UE_id(instance, rnti);

          if (UE_id_mac == -1) {
            LOG_E(F1AP, "Can't find UE_id(MAC) of UE rnti %x\n", rnti);
            break;
          }

          UE_sched_ctrl_t *UE_scheduling_control = &(RC.mac[instance]->UE_info.UE_sched_ctrl[UE_id_mac]);

          if (UE_scheduling_control->cdrx_waiting_ack == TRUE) {
            UE_scheduling_control->cdrx_waiting_ack = FALSE;
            UE_scheduling_control->cdrx_configured = TRUE; // Set to TRUE when RRC Connection Reconfiguration Complete is received
            LOG_I(F1AP, "CDRX configuration activated after RRC Connection Reconfiguration Complete reception\n");
          }
688

689
          /* End of CDRX processing */
690
          break;
691

692 693
        case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete:
          break;
694

695 696
        case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete:
          LOG_I(F1AP, "[MSG] RRC UL rrcConnectionSetupComplete \n");
697

698 699 700 701 702 703
          if(!ue_context_p) {
            LOG_E(F1AP, "Did not find the UE context associated with UE RNTOI %x, ue_context_p is NULL\n", rnti);
          } else {
            LOG_I(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti);
            ue_context_p->ue_context.Status = RRC_CONNECTED;
          }
704

705
          break;
706

707 708 709
        case LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete:
          LOG_I(F1AP, "[MSG] RRC securityModeComplete \n");
          break;
710

711 712
        case LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure:
          break;
713

714 715 716
        case LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation:
          LOG_I(F1AP, "[MSG] RRC ueCapabilityInformation \n");
          break;
717

718 719
        case LTE_UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer:
          break;
720

721 722 723
        case LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer:
          LOG_I(F1AP,"[MSG] RRC UL Information Transfer \n");
          break;
724

725 726
        case LTE_UL_DCCH_MessageType__c1_PR_counterCheckResponse:
          break;
727

728 729
        case LTE_UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9:
          break;
730

731 732 733 734 735
        case LTE_UL_DCCH_MessageType__c1_PR_proximityIndication_r9:
          break;

        case LTE_UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10:
          break;
736

737 738
        case LTE_UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10:
          break;
739

740 741
        case LTE_UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10:
          break;
742 743 744
      }
    }
  }
745 746

  /* encode */
747
  if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
Xue Song's avatar
Xue Song committed
748
    LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER\n");
749
    return -1;
750 751
  }

752 753
  ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu);
  f1ap_itti_send_sctp_data_req(false, instance, buffer, len, getCxt(false, instance)->default_sctp_stream_id);
754
  return 0;
755 756
}

757

758
/*  UL RRC Message Transfer */
759
int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t     module_idP,
760 761 762 763 764 765 766 767
    int             CC_idP,
    int             UE_id,
    rnti_t          rntiP,
    const uint8_t   *sduP,
    sdu_size_t      sdu_lenP,
    const char   *sdu2P,
    sdu_size_t      sdu2_lenP) {
  F1AP_F1AP_PDU_t                       pdu= {0};
768
  F1AP_InitialULRRCMessageTransfer_t    *out;
769 770
  uint8_t  *buffer=NULL;
  uint32_t  len=0;
771
  int f1ap_uid = f1ap_add_ue (false, module_idP, CC_idP,UE_id, rntiP);
772 773

  if (f1ap_uid  < 0 ) {
774
    LOG_E(F1AP, "Failed to add UE \n");
775 776
    return -1;
  }
777 778 779 780

  /* Create */
  /* 0. Message Type */
  pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
781 782 783 784 785
  asn1cCalloc(pdu.choice.initiatingMessage, F1AP_InitiatingMessage_t, tmp);
  tmp->procedureCode = F1AP_ProcedureCode_id_InitialULRRCMessageTransfer;
  tmp->criticality   = F1AP_Criticality_ignore;
  tmp->value.present = F1AP_InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
  out = &tmp->value.choice.InitialULRRCMessageTransfer;
786 787
  /* mandatory */
  /* c1. GNB_DU_UE_F1AP_ID */
788 789 790 791
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie1);
  ie1->id                             = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
  ie1->criticality                    = F1AP_Criticality_reject;
  ie1->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
792
  ie1->value.choice.GNB_DU_UE_F1AP_ID = getCxt(false, module_idP)->f1ap_ue[f1ap_uid].du_ue_f1ap_id;
793 794
  /* mandatory */
  /* c2. NRCGI */
795 796 797 798
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie2);
  ie2->id                             = F1AP_ProtocolIE_ID_id_NRCGI;
  ie2->criticality                    = F1AP_Criticality_reject;
  ie2->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_NRCGI;
799 800
  //Fixme: takes always the first cell
  addnRCGI(ie2->value.choice.NRCGI, getCxt(false, module_idP)->setupReq.cell);
801 802
  /* mandatory */
  /* c3. C_RNTI */  // 16
803 804 805 806 807
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie3);
  ie3->id                             = F1AP_ProtocolIE_ID_id_C_RNTI;
  ie3->criticality                    = F1AP_Criticality_reject;
  ie3->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
  ie3->value.choice.C_RNTI=rntiP;
808 809
  /* mandatory */
  /* c4. RRCContainer */
810 811 812 813 814
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie4);
  ie4->id                            = F1AP_ProtocolIE_ID_id_RRCContainer;
  ie4->criticality                   = F1AP_Criticality_reject;
  ie4->value.present                 = F1AP_InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
  OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer, (const char *)sduP, sdu_lenP);
815 816 817

  /* optional */
  /* c5. DUtoCURRCContainer */
818
  if (sdu2P) {
819 820 821 822 823 824 825 826 827 828
    asn1cSequenceAdd(out->protocolIEs.list, F1AP_InitialULRRCMessageTransferIEs_t, ie5);
    ie5->id                             = F1AP_ProtocolIE_ID_id_DUtoCURRCContainer;
    ie5->criticality                    = F1AP_Criticality_reject;
    ie5->value.present                  = F1AP_InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
    OCTET_STRING_fromBuf(&ie5->value.choice.DUtoCURRCContainer,
                         sdu2P,
                         sdu2_lenP);
  }

  /* encode */
829
  if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
Xue Song's avatar
Xue Song committed
830
    LOG_E(F1AP, "Failed to encode F1 INITIAL UL RRC MESSAGE TRANSFER\n");
831
    return -1;
832 833
  }

Xue Song's avatar
Xue Song committed
834
  if (RC.nrrrc[module_idP]->node_type == ngran_gNB_DU) {
835 836
    struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]);
    ue_context_p->ue_id_rnti                    = rntiP;
Xue Song's avatar
Xue Song committed
837 838 839 840 841
    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_nr_ue_tree_s, &RC.nrrrc[module_idP]->rrc_ue_head, ue_context_p);
  } else {
842 843
    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;
Xue Song's avatar
Xue Song committed
844 845 846 847 848
    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);
  }
849

850
  f1ap_itti_send_sctp_data_req(false, module_idP, buffer, len, getCxt(false, module_idP)->default_sctp_stream_id);
851
  return 0;
852
}
853 854


855 856
int DU_send_UL_NR_RRC_MESSAGE_TRANSFER(instance_t instance,
                                       const f1ap_ul_rrc_message_t *msg) {
857
  const rnti_t rnti = msg->rnti;
858
  F1AP_F1AP_PDU_t                pdu= {0};
859 860 861
  F1AP_ULRRCMessageTransfer_t    *out;
  uint8_t *buffer = NULL;
  uint32_t len;
862
  LOG_I(F1AP, "[DU %ld] %s: size %d UE RNTI %x in SRB %d\n",
863 864 865 866 867 868 869 870
        instance, __func__, msg->rrc_container_length, rnti, msg->srb_id);
  //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");
  /* Create */
  /* 0. Message Type */
  pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
871 872 873 874 875
  asn1cCalloc(pdu.choice.initiatingMessage, F1AP_InitiatingMessage_t, tmp);
  tmp->procedureCode = F1AP_ProcedureCode_id_ULRRCMessageTransfer;
  tmp->criticality   = F1AP_Criticality_ignore;
  tmp->value.present = F1AP_InitiatingMessage__value_PR_ULRRCMessageTransfer;
  out = &tmp->value.choice.ULRRCMessageTransfer;
876 877
  /* mandatory */
  /* c1. GNB_CU_UE_F1AP_ID */
878 879 880 881
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie1);
  ie1->id                             = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
  ie1->criticality                    = F1AP_Criticality_reject;
  ie1->value.present                  = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
882
  ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(false, instance, rnti);
883 884
  /* mandatory */
  /* c2. GNB_DU_UE_F1AP_ID */
885 886 887 888
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie2);
  ie2->id                             = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
  ie2->criticality                    = F1AP_Criticality_reject;
  ie2->value.present                  = F1AP_ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
889
  ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(false, instance, rnti);
890 891
  /* mandatory */
  /* c3. SRBID */
892 893 894 895 896
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie3);
  ie3->id                            = F1AP_ProtocolIE_ID_id_SRBID;
  ie3->criticality                   = F1AP_Criticality_reject;
  ie3->value.present                 = F1AP_ULRRCMessageTransferIEs__value_PR_SRBID;
  ie3->value.choice.SRBID            = msg->srb_id;
897 898 899
  // issue in here
  /* mandatory */
  /* c4. RRCContainer */
900 901 902 903 904
  asn1cSequenceAdd(out->protocolIEs.list, F1AP_ULRRCMessageTransferIEs_t, ie4);
  ie4->id                            = F1AP_ProtocolIE_ID_id_RRCContainer;
  ie4->criticality                   = F1AP_Criticality_reject;
  ie4->value.present                 = F1AP_ULRRCMessageTransferIEs__value_PR_RRCContainer;
  OCTET_STRING_fromBuf(&ie4->value.choice.RRCContainer,
905 906 907
                       (const char *) msg->rrc_container,
                       msg->rrc_container_length);

908
  /* encode */
909 910 911 912 913
  if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
    LOG_E(F1AP, "Failed to encode F1 UL RRC MESSAGE TRANSFER \n");
    return -1;
  }

914
  f1ap_itti_send_sctp_data_req(false, instance, buffer, len, getCxt(false, instance)->default_sctp_stream_id);
915 916
  return 0;
}
917

918 919
/*  DL NR RRC Message Transfer */
int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t       instance,
920 921 922
    uint32_t         assoc_id,
    uint32_t         stream,
    F1AP_F1AP_PDU_t *pdu) {
923 924 925 926 927 928 929 930 931 932 933 934 935 936
  LOG_D(F1AP, "DU_handle_DL_NR_RRC_MESSAGE_TRANSFER \n");
  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;
  sdu_size_t      rrc_dl_sdu_len;
  //uint64_t        subscriberProfileIDforRFP;
  //uint64_t        rAT_FrequencySelectionPriority;
  DevAssert(pdu != NULL);

  if (stream != 0) {
    LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n",
937
          assoc_id, stream);
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
    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;
  LOG_D(F1AP, "cu_ue_f1ap_id %lu \n", cu_ue_f1ap_id);
  /* 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;
  LOG_D(F1AP, "du_ue_f1ap_id %lu associated with UE RNTI %x \n",
        du_ue_f1ap_id,
953
        f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id)); // this should be the one transmitted via initial ul rrc message transfer
954

955
  if (f1ap_du_add_cu_ue_id(false, instance,du_ue_f1ap_id, cu_ue_f1ap_id) < 0 ) {
956 957 958 959 960 961 962 963
    LOG_E(F1AP, "Failed to find the F1AP UID \n");
    //return -1;
  }

  /* optional */
  /* oldgNB_DU_UE_F1AP_ID */
  if (0) {
    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
964
                               F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID, true);
965 966 967 968 969 970 971 972 973 974 975 976 977
  }

  /* mandatory */
  /* SRBID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_SRBID, true);
  srb_id = ie->value.choice.SRBID;
  LOG_D(F1AP, "srb_id %lu \n", srb_id);

  /* optional */
  /* ExecuteDuplication */
  if (0) {
    F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_DLRRCMessageTransferIEs_t, ie, container,
978
                               F1AP_ProtocolIE_ID_id_ExecuteDuplication, true);
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
    executeDuplication = ie->value.choice.ExecuteDuplication;
    LOG_D(F1AP, "ExecuteDuplication %d \n", executeDuplication);
  }

  // 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
  //  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);

  //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");

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

    switch(ie->value.choice.RAT_FrequencyPriorityInformation.present) {
Xue Song's avatar
Xue Song committed
1008
      case F1AP_RAT_FrequencyPriorityInformation_PR_eNDC:
1009 1010
        //subscriberProfileIDforRFP = ie->value.choice.RAT_FrequencyPriorityInformation.choice.subscriberProfileIDforRFP;
        break;
1011

Xue Song's avatar
Xue Song committed
1012
      case F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN:
1013 1014
        //rAT_FrequencySelectionPriority = ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority;
        break;
1015

1016 1017 1018 1019 1020 1021 1022 1023 1024
      default:
        LOG_W(F1AP, "unhandled IE RAT_FrequencyPriorityInformation.present\n");
        break;
    }
  }

  // decode RRC Container and act on the message type
  AssertFatal(srb_id<3,"illegal srb_id\n");
  protocol_ctxt_t ctxt;
1025
  ctxt.rnti      = f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id);
1026 1027 1028
  ctxt.module_id = instance;
  ctxt.instance  = instance;
  ctxt.enb_flag  = 1;
1029 1030 1031
  struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_get_ue_context(
        RC.nrrrc[ctxt.module_id],
        ctxt.rnti);
1032
  gNB_RRC_INST *rrc = RC.nrrrc[ctxt.module_id];
1033

Xue Song's avatar
Xue Song committed
1034
  if (srb_id == 0) {
1035
    NR_DL_CCCH_Message_t *dl_ccch_msg=NULL;
1036 1037 1038
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
                           &asn_DEF_NR_DL_CCCH_Message,
1039 1040 1041
                           (void **)&dl_ccch_msg,
                           ie->value.choice.RRCContainer.buf,
                           rrc_dl_sdu_len,0,0);
1042 1043
    AssertFatal(dec_rval.code == RC_OK, "could not decode F1AP message\n");

1044
    switch (dl_ccch_msg->message.choice.c1->present) {
1045 1046 1047 1048 1049 1050 1051 1052 1053
      case NR_DL_CCCH_MessageType__c1_PR_NOTHING:
        LOG_I(F1AP, "Received PR_NOTHING on DL-CCCH-Message\n");
        break;

      case NR_DL_CCCH_MessageType__c1_PR_rrcReject:
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCReject\n");
        break;

1054
      case NR_DL_CCCH_MessageType__c1_PR_rrcSetup: {
1055 1056 1057
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received RRCSetup DU_ID %lx/RNTI %x\n",
              du_ue_f1ap_id,
1058
              f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id));
1059 1060
        // Get configuration
        NR_RRCSetup_t *rrcSetup = dl_ccch_msg->message.choice.c1->choice.rrcSetup;
1061 1062
        AssertFatal(rrcSetup!=NULL, "rrcSetup is null\n");
        NR_RRCSetup_IEs_t *rrcSetup_ies = rrcSetup->criticalExtensions.choice.rrcSetup;
1063
        ue_context_p->ue_context.SRB_configList = rrcSetup_ies->radioBearerConfig.srb_ToAddModList;
1064
        AssertFatal(rrcSetup_ies->masterCellGroup.buf!=NULL,"masterCellGroup is null\n");
1065 1066 1067 1068 1069 1070 1071
        asn_dec_rval_t dec_rval;
        dec_rval = uper_decode(NULL,
                               &asn_DEF_NR_CellGroupConfig,
                               (void **)&ue_context_p->ue_context.masterCellGroup,
                               rrcSetup_ies->masterCellGroup.buf,
                               rrcSetup_ies->masterCellGroup.size,0,0);
        AssertFatal(dec_rval.code == RC_OK, "could not decode masterCellGroup\n");
1072
        apply_macrlc_config(rrc,ue_context_p,&ctxt);
1073
        gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context;
1074
        AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n");
1075 1076
        memcpy((void *)ue_p->Srb0.Tx_buffer.Payload,
               (void *)ie->value.choice.RRCContainer.buf,
1077 1078
               rrc_dl_sdu_len); // ie->value.choice.RRCContainer.size
        ue_p->Srb0.Tx_buffer.payload_size = rrc_dl_sdu_len;
1079
        break;
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
      } // case

      case NR_DL_CCCH_MessageType__c1_PR_spare2:
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received spare2\n");
        break;

      case NR_DL_CCCH_MessageType__c1_PR_spare1:
        LOG_I(F1AP,
              "Logical Channel DL-CCCH (SRB0), Received spare1\n");
        break;

      default:
        AssertFatal(1==0,
1094
                    "Unknown message\n");
1095 1096 1097
        break;
    }// switch case

1098 1099 1100
    return(0);
  } else if (srb_id == 1) {
    NR_DL_DCCH_Message_t *dl_dcch_msg=NULL;
1101 1102
    asn_dec_rval_t dec_rval;
    dec_rval = uper_decode(NULL,
1103 1104 1105 1106
                           &asn_DEF_NR_DL_DCCH_Message,
                           (void **)&dl_dcch_msg,
                           &ie->value.choice.RRCContainer.buf[2], // buf[0] includes the pdcp header
                           rrc_dl_sdu_len-6,0,0);
1107

1108
    if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0))
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
      LOG_E(F1AP," Failed to decode DL-DCCH (%zu bytes)\n",dec_rval.consumed);
    else
      LOG_D(F1AP, "Received message: present %d and c1 present %d\n",
            dl_dcch_msg->message.present, dl_dcch_msg->message.choice.c1->present);

    if (dl_dcch_msg->message.present == NR_DL_DCCH_MessageType_PR_c1) {
      switch (dl_dcch_msg->message.choice.c1->present) {
        case NR_DL_DCCH_MessageType__c1_PR_NOTHING:
          LOG_I(F1AP, "Received PR_NOTHING on DL-DCCH-Message\n");
          return 0;

        case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration:
1121
          // handle RRCReconfiguration
1122 1123 1124
          LOG_I(F1AP,
                "Logical Channel DL-DCCH (SRB1), Received RRCReconfiguration DU_ID %lx/RNTI %x\n",
                du_ue_f1ap_id,
1125
                f1ap_get_rnti_by_du_id(false, instance, du_ue_f1ap_id));
1126
          NR_RRCReconfiguration_t *rrcReconfiguration = dl_dcch_msg->message.choice.c1->choice.rrcReconfiguration;
1127 1128

          if (rrcReconfiguration->criticalExtensions.present == NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration) {
1129
            NR_RRCReconfiguration_IEs_t *rrcReconfiguration_ies =
1130 1131 1132 1133 1134 1135
              rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration;

            if (rrcReconfiguration_ies->measConfig != NULL) {
              LOG_I(F1AP, "Measurement Configuration is present\n");
            }

1136 1137 1138 1139 1140 1141
            if (rrcReconfiguration_ies->radioBearerConfig) {
              LOG_I(F1AP, "Radio Resource Configuration is present\n");
              long drb_id;
              int i;
              NR_DRB_ToAddModList_t  *DRB_configList  = rrcReconfiguration_ies->radioBearerConfig->drb_ToAddModList;
              NR_SRB_ToAddModList_t  *SRB_configList  = rrcReconfiguration_ies->radioBearerConfig->srb_ToAddModList;
1142

1143
              // NR_DRB_ToReleaseList_t *DRB_ReleaseList = rrcReconfiguration_ies->radioBearerConfig->drb_ToReleaseList;
1144

1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
              // rrc_rlc_config_asn1_req

              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;
                    LOG_I(F1AP, "[DU %d] SRB2 is now active\n",ctxt.module_id);
                  } else {
                    LOG_W(F1AP, "[DU %d] invalide SRB identity %ld\n",ctxt.module_id,
                          SRB_configList->list.array[i]->srb_Identity);
1158 1159
                  }
                }
1160
              }
1161

1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172
              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;
                    LOG_I(F1AP,
                          "[DU %d] Logical Channel UL-DCCH, Received RRCConnectionReconfiguration for UE rnti %x, reconfiguring DRB %d\n",
                          ctxt.module_id,
                          ctxt.rnti,
                          (int)DRB_configList->list.array[i]->drb_Identity);

                    // (int)*DRB_configList->list.array[i]->logicalChannelIdentity);
1173 1174 1175 1176 1177 1178 1179

                    if (ue_context_p->ue_context.DRB_active[drb_id] == 0) {
                      ue_context_p->ue_context.DRB_active[drb_id] = 1;
                      // logicalChannelIdentity
                      // rrc_mac_config_req_eNB
                    }
                  } else {        // remove LCHAN from MAC/PHY
1180 1181
                    AssertFatal(1==0,"Can't handle this yet in DU\n");
                  }
1182 1183 1184
                }
              }
            }
1185 1186
          }

1187
          break;
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226

        case NR_DL_DCCH_MessageType__c1_PR_rrcResume:
          LOG_I(F1AP,"Received rrcResume\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_rrcRelease:
          LOG_I(F1AP,"Received rrcRelease\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment:
          LOG_I(F1AP,"Received rrcReestablishment\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand:
          LOG_I(F1AP,"Received securityModeCommand\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer:
          LOG_I(F1AP, "Received dlInformationTransfer\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry:
          LOG_I(F1AP, "Received ueCapabilityEnquiry\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_counterCheck:
          LOG_I(F1AP, "Received counterCheck\n");
          break;

        case NR_DL_DCCH_MessageType__c1_PR_mobilityFromNRCommand:
        case NR_DL_DCCH_MessageType__c1_PR_dlDedicatedMessageSegment_r16:
        case NR_DL_DCCH_MessageType__c1_PR_ueInformationRequest_r16:
        case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransferMRDC_r16:
        case NR_DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r16:
        case NR_DL_DCCH_MessageType__c1_PR_spare3:
        case NR_DL_DCCH_MessageType__c1_PR_spare2:
        case NR_DL_DCCH_MessageType__c1_PR_spare1:
          break;
      }
1227
    }
1228
  } else if (srb_id == 2) {
1229 1230 1231 1232
    // TODO
  }

  LOG_I(F1AP, "Received DL RRC Transfer on srb_id %ld\n", srb_id);
1233 1234 1235
  //   rlc_op_status_t    rlc_status;
  //   boolean_t          ret             = TRUE;
  mem_block_t       *pdcp_pdu_p      = NULL;
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
  pdcp_pdu_p = get_free_mem_block(rrc_dl_sdu_len, __func__);

  //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");

  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);
Xue Song's avatar
Xue Song committed
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
    /* for rfsim */
    du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, rrc_dl_sdu_len, pdcp_pdu_p);
    //   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:
    //       //LOG_I(F1AP, "Data sending request over RLC succeeded!\n");
    //       ret=TRUE;
    //       break;
    //     case RLC_OP_STATUS_BAD_PARAMETER:
    //       LOG_W(F1AP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
    //       ret= FALSE;
    //       break;
    //     case RLC_OP_STATUS_INTERNAL_ERROR:
    //       LOG_W(F1AP, "Data sending request over RLC failed with 'Internal Error' reason!\n");
    //       ret= FALSE;
    //       break;
    //     case RLC_OP_STATUS_OUT_OF_RESSOURCES:
    //       LOG_W(F1AP, "Data sending request over RLC failed with 'Out of Resources' reason!\n");
    //       ret= FALSE;
    //       break;
    //     default:
    //       LOG_W(F1AP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
    //       ret= FALSE;
    //       break;
    //   } // switch case
1284 1285
    //   return ret;
  } // if pdcp_pdu_p
Xue Song's avatar
Xue Song committed
1286

1287 1288
  return 0;
}