f1ap_cu_rrc_message_transfer.c 17.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_cu_rrc_message_transfer.c
 * \brief f1ap rrc message transfer for CU
 * \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 36
#include "f1ap_encoder.h"
#include "f1ap_decoder.h"
#include "f1ap_itti_messaging.h"
37
#include "f1ap_cu_rrc_message_transfer.h"
38 39 40
#include "common/ran_context.h"
#include "openair3/UTILS/conversions.h"

41 42 43 44 45
// undefine C_RNTI from
// openair1/PHY/LTE_TRANSPORT/transport_common.h which
// replaces in ie->value.choice.C_RNTI, causing
// a compile error
#undef C_RNTI 
46

47

48 49 50 51
// Bing Kai: create CU and DU context, and put all the information there.
uint64_t        du_ue_f1ap_id = 0;
uint32_t        f1ap_assoc_id = 0;
uint32_t        f1ap_stream = 0;
52 53


Robert Schmidt's avatar
Robert Schmidt committed
54
extern f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB];
55

56 57 58 59
/*
    Initial UL RRC Message Transfer
*/

60 61
extern RAN_CONTEXT_t RC;

62 63
int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t             instance,
                                              uint32_t               assoc_id,
64 65
                                              uint32_t               stream,
                                              F1AP_F1AP_PDU_t       *pdu) {
66

67
  LOG_D(F1AP, "CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER\n");
68 69 70
  // decode the F1 message
  // get the rrc message from the contauiner 
  // call func rrc_eNB_decode_ccch: <-- needs some update here
71 72 73 74 75 76 77
  MessageDef                            *message_p;
  F1AP_InitialULRRCMessageTransfer_t    *container;
  F1AP_InitialULRRCMessageTransferIEs_t *ie;
  
  rnti_t          rnti;
  sdu_size_t      ccch_sdu_len;
  int             CC_id =0;
78
  
79

80 81 82
  DevAssert(pdu != NULL);
  
  if (stream != 0) {
83 84
    LOG_E(F1AP, "[SCTP %d] Received F1 on stream != 0 (%d)\n",
          assoc_id, stream);
85 86
    return -1;
  }
87 88 89
  // TODO: use context 
  f1ap_stream    = stream;
  f1ap_assoc_id = assoc_id;
90 91 92 93 94 95 96

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

  /* GNB_DU_UE_F1AP_ID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_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;
97
  LOG_D(F1AP, "du_ue_f1ap_id %lu \n", du_ue_f1ap_id);
98

99 100 101
  /* NRCGI 
  * TODO: process NRCGI
  */
102 103 104
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_NRCGI, true);

105

106 107 108
  uint64_t nr_cellid;
  BIT_STRING_TO_NR_CELL_IDENTITY(&ie->value.choice.NRCGI.nRCellIdentity,nr_cellid);
					       
109 110 111
  /* RNTI */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_C_RNTI, true);
Xue Song's avatar
Xue Song committed
112
  rnti = ie->value.choice.C_RNTI;
113 114 115 116

  /* RRC Container */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_RRCContainer, true);
117
  AssertFatal(ie!=NULL,"RRCContainer is missing\n");
118
  // create an ITTI message and copy SDU
Xue Song's avatar
Xue Song committed
119
  if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
120
    message_p = itti_alloc_new_message (TASK_CU_F1, 0, NR_RRC_MAC_CCCH_DATA_IND);
Xue Song's avatar
Xue Song committed
121 122 123 124 125
    memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
    ccch_sdu_len = ie->value.choice.RRCContainer.size;
    memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf,
           ccch_sdu_len);
  } else {
126
    message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_MAC_CCCH_DATA_IND);
Xue Song's avatar
Xue Song committed
127 128 129 130 131
    memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
    ccch_sdu_len = ie->value.choice.RRCContainer.size;
    memcpy(RRC_MAC_CCCH_DATA_IND (message_p).sdu, ie->value.choice.RRCContainer.buf,
           ccch_sdu_len);
  }
132

133 134 135 136 137
  LOG_I(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__,
        ie->value.choice.RRCContainer.size);
  for (int i = 0; i < ie->value.choice.RRCContainer.size; i++)
    printf("%02x ", RRC_MAC_CCCH_DATA_IND (message_p).sdu[i]);
  printf("\n");
138

139 140 141 142 143 144 145 146 147 148 149 150
  /* DUtoCURRCContainer */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_DUtoCURRCContainer, true);
  if (ie) {
    NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t));
    NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = ie->value.choice.DUtoCURRCContainer.size;
    NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc(ie->value.choice.DUtoCURRCContainer.size);
    memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf,
	   ie->value.choice.DUtoCURRCContainer.buf,
	   ie->value.choice.DUtoCURRCContainer.size);

  }
151 152
  // Find instance from nr_cellid
  int rrc_inst = -1;
Xue Song's avatar
Xue Song committed
153 154 155 156 157
  if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
    for (int i=0;i<RC.nb_nr_inst;i++) {
      // first get RRC instance (note, no the ITTI instance)
      gNB_RRC_INST *rrc = RC.nrrrc[i];
      if (rrc->nr_cellid == nr_cellid) {
158
        rrc_inst = i;
Xue Song's avatar
Xue Song committed
159 160 161 162 163
        break;
      }
    }
  } else {
    for (int i=0;i<RC.nb_inst;i++) {
164
          // first get RRC instance (note, no the ITTI instance)
Xue Song's avatar
Xue Song committed
165 166
      eNB_RRC_INST *rrc = RC.rrc[i];
      if (rrc->nr_cellid == nr_cellid) {
167
        rrc_inst = i;
Xue Song's avatar
Xue Song committed
168 169
        break;
      }
170 171
    }
  }
Raymond Knopp's avatar
Raymond Knopp committed
172
  AssertFatal(rrc_inst>=0,"couldn't find an RRC instance for nr_cell %llu\n",(unsigned long long int)nr_cellid);
173

Robert Schmidt's avatar
Robert Schmidt committed
174
  int f1ap_uid = f1ap_add_ue(&f1ap_cu_inst[rrc_inst], rrc_inst, CC_id, 0, rnti);
175
  if (f1ap_uid  < 0 ) {
176
    LOG_E(F1AP, "Failed to add UE \n");
177
    itti_free(ITTI_MSG_ORIGIN_ID(message_p), message_p);
178 179
    return -1;
  }
Robert Schmidt's avatar
Robert Schmidt committed
180
  f1ap_cu_inst[rrc_inst].f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id;
181

Xue Song's avatar
Xue Song committed
182
  if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
183
    NR_RRC_MAC_CCCH_DATA_IND (message_p).frame     = 0;
184 185
    NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
    NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size  = ccch_sdu_len;
186
    NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance
187
    NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti      = rnti;
188
    NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id     = CC_id;
189
    itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p);
Xue Song's avatar
Xue Song committed
190
  } else {
191
    RRC_MAC_CCCH_DATA_IND (message_p).frame      = 0;
192 193
    RRC_MAC_CCCH_DATA_IND (message_p).sub_frame  = 0;
    RRC_MAC_CCCH_DATA_IND (message_p).sdu_size   = ccch_sdu_len;
194
    RRC_MAC_CCCH_DATA_IND (message_p).enb_index  = rrc_inst; // CU instance
195
    RRC_MAC_CCCH_DATA_IND (message_p).rnti       = rnti;
196
    RRC_MAC_CCCH_DATA_IND (message_p).CC_id      = CC_id;
Xue Song's avatar
Xue Song committed
197 198
    itti_send_msg_to_task (TASK_RRC_ENB, instance, message_p);
  }
199

200
  return 0;
201 202 203 204 205 206 207 208
}


/*
    DL RRC Message Transfer.
*/

//void CU_send_DL_RRC_MESSAGE_TRANSFER(F1AP_DLRRCMessageTransfer_t *DLRRCMessageTransfer) {
209 210 211 212
int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t                instance,
                                    f1ap_dl_rrc_message_t    *f1ap_dl_rrc)
                                    {

Xue Song's avatar
Xue Song committed
213
  LOG_D(F1AP, "CU send DL_RRC_MESSAGE_TRANSFER \n");
214
  F1AP_F1AP_PDU_t                 pdu;
215 216 217 218 219 220 221
  F1AP_DLRRCMessageTransfer_t    *out;
  F1AP_DLRRCMessageTransferIEs_t *ie;

  uint8_t  *buffer;
  uint32_t  len;

  /* Create */
222
  /* 0. Message Type */ 
223 224 225 226 227 228 229 230 231 232
  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_DLRRCMessageTransfer;
  pdu.choice.initiatingMessage->criticality   = F1AP_Criticality_ignore;
  pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_DLRRCMessageTransfer;
  out = &pdu.choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
  
  /* mandatory */
  /* c1. GNB_CU_UE_F1AP_ID */
233

234 235 236 237
  ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
Robert Schmidt's avatar
Robert Schmidt committed
238
  ie->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_cu_inst[instance], f1ap_dl_rrc->rnti);
239
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
240
  LOG_I(F1AP, "Setting GNB_CU_UE_F1AP_ID %llu associated with UE RNTI %x (instance %ld)\n",
241
        (unsigned long long int)ie->value.choice.GNB_CU_UE_F1AP_ID, f1ap_dl_rrc->rnti, instance);
242

243 244 245 246 247 248 249

  /* mandatory */
  /* c2. GNB_DU_UE_F1AP_ID */
  ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
  ie->id                             = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
  ie->criticality                    = F1AP_Criticality_reject;
  ie->value.present                  = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
Robert Schmidt's avatar
Robert Schmidt committed
250
  ie->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_cu_inst[instance], f1ap_dl_rrc->rnti);
251
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
252
  LOG_I(F1AP, "GNB_DU_UE_F1AP_ID %llu associated with UE RNTI %x \n", (unsigned long long int)ie->value.choice.GNB_DU_UE_F1AP_ID, f1ap_dl_rrc->rnti);
253 254 255

  /* optional */
  /* c3. oldgNB_DU_UE_F1AP_ID */
256
 /* if (f1ap_dl_rrc->old_gNB_DU_ue_id != 0xFFFFFFFF) {
257
    ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
258 259 260 261
    ie->id                                = F1AP_ProtocolIE_ID_id_oldgNB_DU_UE_F1AP_ID;
    ie->criticality                       = F1AP_Criticality_reject;
    ie->value.present                     = F1AP_DLRRCMessageTransferIEs__value_PR_NOTHING;
    ie->value.choice.oldgNB_DU_UE_F1AP_ID = f1ap_dl_rrc->old_gNB_DU_ue_id;
262
    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
263
  }*/ 
264 265 266 267 268 269 270

  /* mandatory */
  /* c4. SRBID */
  ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
  ie->id                            = F1AP_ProtocolIE_ID_id_SRBID;
  ie->criticality                   = F1AP_Criticality_reject;
  ie->value.present                 = F1AP_DLRRCMessageTransferIEs__value_PR_SRBID;
271
  ie->value.choice.SRBID            = f1ap_dl_rrc->srb_id;
272 273 274 275
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

  /* optional */
  /* c5. ExecuteDuplication */
276
  if (f1ap_dl_rrc->execute_duplication) {
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
    ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
    ie->id                            = F1AP_ProtocolIE_ID_id_ExecuteDuplication;
    ie->criticality                   = F1AP_Criticality_ignore;
    ie->value.present                 = F1AP_DLRRCMessageTransferIEs__value_PR_ExecuteDuplication;
    ie->value.choice.ExecuteDuplication = F1AP_ExecuteDuplication_true;
    ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
  }

  // issue in here
  /* mandatory */
  /* c6. RRCContainer */
  ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
  ie->id                            = F1AP_ProtocolIE_ID_id_RRCContainer;
  ie->criticality                   = F1AP_Criticality_reject;
  ie->value.present                 = F1AP_DLRRCMessageTransferIEs__value_PR_RRCContainer;
Raymond Knopp's avatar
Raymond Knopp committed
292
  OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char*)f1ap_dl_rrc->rrc_container, f1ap_dl_rrc->rrc_container_length);
293 294
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);

Xue Song's avatar
Xue Song committed
295 296 297 298
  LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, f1ap_dl_rrc->rrc_container_length);
  for (int i = 0; i < ie->value.choice.RRCContainer.size; i++)
   printf("%02x ", f1ap_dl_rrc->rrc_container[i]);
  printf("\n");
299

300 301
  /* optional */
  /* c7. RAT_FrequencyPriorityInformation */
302
  /* TODO */ 
303 304 305 306 307 308 309 310
  int endc=1;
  ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t));
  ie->id                            = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation;
  ie->criticality                   = F1AP_Criticality_reject;
  ie->value.present                 = F1AP_DLRRCMessageTransferIEs__value_PR_RAT_FrequencyPriorityInformation;
  if (endc==1) {
    ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC;
    ie->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 123L;
311
  }
312 313 314 315
  else {
    ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN;
    ie->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L;
  }
316 317
    //ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_rAT_FrequencySelectionPriority;
    //ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority = 123L;
318
  ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie);
319
 
320 321
  /* encode */
  if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
Xue Song's avatar
Xue Song committed
322
    LOG_E(F1AP, "Failed to encode F1 DL RRC MESSAGE TRANSFER \n");
323
    return -1;
324 325
  }

326
  cu_f1ap_itti_send_sctp_data_req(instance, f1ap_assoc_id /* BK: fix me*/ , buffer, len, 0 /* BK: fix me*/);
327

328
  return 0;
329 330 331 332 333 334
}

/*
    UL RRC Message Transfer
*/

335 336 337 338
int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t       instance,
                                      uint32_t         assoc_id,
                                      uint32_t         stream,
                                      F1AP_F1AP_PDU_t *pdu) {
339

340
  LOG_D(F1AP, "CU_handle_UL_RRC_MESSAGE_TRANSFER \n");
341 342 343
  
  F1AP_ULRRCMessageTransfer_t    *container;
  F1AP_ULRRCMessageTransferIEs_t *ie;
344

345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
  uint64_t        cu_ue_f1ap_id;
  uint64_t        du_ue_f1ap_id;
  uint64_t        srb_id;

  DevAssert(pdu != NULL);
  
  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.ULRRCMessageTransfer;


  /* GNB_CU_UE_F1AP_ID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_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;
364
  LOG_D(F1AP, "cu_ue_f1ap_id %lu associated with RNTI %x\n", cu_ue_f1ap_id, f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id));
365 366 367 368 369 370


  /* GNB_DU_UE_F1AP_ID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_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;
371
  LOG_D(F1AP, "du_ue_f1ap_id %lu associated with RNTI %x\n", du_ue_f1ap_id, f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], du_ue_f1ap_id));
372 373 374 375 376 377 378


  /* mandatory */
  /* SRBID */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_SRBID, true);
  srb_id = ie->value.choice.SRBID;
379
  if (srb_id < 1 ) 
380
    LOG_E(F1AP, "Unexpected UL RRC MESSAGE for srb_id %lu \n", srb_id);
381
  else  
382
    LOG_D(F1AP, "UL RRC MESSAGE for srb_id %lu in DCCH \n", srb_id);
383 384 385 386 387 388 389


  // issue in here
  /* mandatory */
  /* RRC Container */
  F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
                             F1AP_ProtocolIE_ID_id_RRCContainer, true);
390
  // print message in debug mode 
391

392
  // create an ITTI message and copy SDU
393

394
  /*
395
  
396
  message_p = itti_alloc_new_message (TASK_CU_F1, 0, RRC_DCCH_DATA_IND);
397 398

  RRC_DCCH_DATA_IND (message_p).sdu_p = malloc(ie->value.choice.RRCContainer.size);
399 400 401 402 403 404

  RRC_DCCH_DATA_IND (message_p).sdu_size = ie->value.choice.RRCContainer.size;
  memcpy(RRC_DCCH_DATA_IND (message_p).sdu_p, ie->value.choice.RRCContainer.buf,
         ie->value.choice.RRCContainer.size);

  RRC_DCCH_DATA_IND (message_p).dcch_index = srb_id;
Robert Schmidt's avatar
Robert Schmidt committed
405
  RRC_DCCH_DATA_IND (message_p).rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id);
406 407 408 409
  RRC_DCCH_DATA_IND (message_p).module_id = instance;
  RRC_DCCH_DATA_IND (message_p).eNB_index = instance; // not needed for CU

  itti_send_msg_to_task(TASK_RRC_ENB, instance, message_p);
410 411 412
  */
  protocol_ctxt_t ctxt;
  ctxt.module_id = instance;
413
  ctxt.instance = instance;
Robert Schmidt's avatar
Robert Schmidt committed
414
  ctxt.rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id);
415
  ctxt.enb_flag = 1;
Xue Song's avatar
Xue Song committed
416 417
  ctxt.eNB_index = 0;
  ctxt.configured = 1;
418 419
  mem_block_t *mb = get_free_mem_block(ie->value.choice.RRCContainer.size,__func__);
  memcpy((void*)mb->data,(void*)ie->value.choice.RRCContainer.buf,ie->value.choice.RRCContainer.size);
420
  LOG_I(F1AP, "Calling pdcp_data_ind for UE RNTI %x srb_id %lu with size %ld (DCCH) \n", ctxt.rnti, srb_id, ie->value.choice.RRCContainer.size);
421 422 423 424 425 426

  //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 ", mb->data[i]);
  //printf("\n");

427
  pdcp_data_ind (&ctxt,
428 429 430 431 432
     1, // srb_flag
     0, // embms_flag
     srb_id,
     ie->value.choice.RRCContainer.size,
     mb);
433
  return 0;
434
}