1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains F1AP message handler functions */
20 #include "common_def.h"
21 #include "OCTET_STRING.h"
22 #include "BIT_STRING.h"
23 #include "odu_common_codec.h"
24 #include "cu_stub_sctp.h"
25 #include "cu_f1ap_msg_hdl.h"
27 /*******************************************************************
29 * @brief Sends F1 msg over SCTP
33 * Function : SendF1APMsg
35 * Functionality: Sends F1 msg over SCTP
37 * @params[in] Region region
39 * @return ROK - success
42 * ****************************************************************/
43 S16 SendF1APMsg(Region region, Pool pool)
47 if(SGetMsg(region, pool, &mBuf) == ROK)
49 if(SAddPstMsgMult((Data *)encBuf, encBufSize, mBuf) == ROK)
53 if(sctpSend(mBuf) != ROK)
55 DU_LOG("\nF1AP : SCTP Send failed");
62 DU_LOG("\nF1AP : SAddPstMsgMult failed");
70 DU_LOG("\nF1AP : Failed to allocate memory");
77 /*******************************************************************
79 * @brief Builds NRCell ID
83 * Function : BuildNrCellId
85 * Functionality: Building the NR Cell ID
87 * @params[in] BIT_STRING_t *nrcell
88 * @return ROK - success
91 * ****************************************************************/
93 S16 BuildNrCellId(BIT_STRING_t *nrcell)
96 for (tmp = 0 ; tmp < nrcell->size-1; tmp++)
101 nrcell->bits_unused = 4;
102 nrcell->size = 5 * sizeof(uint8_t);
106 /********************************************************************
108 * @brief Builds and sends the F1SetupResponse
112 * Function : BuildAndSendF1SetupRsp
114 * Functionality: Constructs the F1SetupResponse message and sends
115 * it back to the DU through SCTP.
117 * @params[in] void **buf,Buffer to which encoded pattern is written into
118 * @params[in] int *size,size of buffer
120 * @return ROK - success
123 * ****************************************************************/
124 S16 BuildAndSendF1SetupRsp()
127 U8 elementCnt,cellCnt;
128 F1AP_PDU_t *f1apMsg = NULL;
129 F1SetupResponse_t *f1SetupRsp;
130 GNB_CU_Name_t *cuName;
131 Cells_to_be_Activated_List_t *cellToActivate;
132 RRC_Version_t *rrcVer;
133 asn_enc_rval_t encRetVal;
134 DU_LOG("\nF1AP : Building F1 Setup Response\n");
136 /* Allocate the memory for F1SetupRequest_t */
137 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
140 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
143 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
145 CU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
146 if(f1apMsg->choice.successfulOutcome == NULLP)
148 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
149 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
153 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_F1Setup;
154 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
155 f1apMsg->choice.successfulOutcome->value.present = \
156 SuccessfulOutcome__value_PR_F1SetupResponse;
157 f1SetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
160 f1SetupRsp->protocolIEs.list.count = elementCnt;
161 f1SetupRsp->protocolIEs.list.size = elementCnt*sizeof(F1SetupResponseIEs_t *);
163 CU_ALLOC(f1SetupRsp->protocolIEs.list.array, \
164 elementCnt * sizeof(F1SetupResponseIEs_t *));
165 if(f1SetupRsp->protocolIEs.list.array == NULLP)
167 DU_LOG("\nF1AP : Memory allocation for F1ResponseIEs failed");
168 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
169 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
173 for(idx=0; idx<elementCnt; idx++)
175 CU_ALLOC(f1SetupRsp->protocolIEs.list.array[idx], \
176 sizeof(F1SetupResponseIEs_t));
177 if(f1SetupRsp->protocolIEs.list.array[idx] == NULLP)
179 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
180 elementCnt * sizeof(F1SetupResponseIEs_t *));
181 CU_FREE(f1apMsg->choice.successfulOutcome, \
182 sizeof(SuccessfulOutcome_t));
183 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
190 f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
191 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
192 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
193 F1SetupResponseIEs__value_PR_TransactionID;
194 f1SetupRsp->protocolIEs.list.array[idx]->value.choice.TransactionID =\
199 f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_Name;
200 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
201 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
202 F1SetupResponseIEs__value_PR_GNB_CU_Name;
203 cuName = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_Name;
204 cuName->size = sizeof(cuCfgParams.cuName);
206 CU_ALLOC(cuName->buf, sizeof(cuName->size));
207 if(cuName->buf == NULLP)
209 for(idy=0; idy<elementCnt; idy++)
211 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy],\
212 sizeof(F1SetupResponseIEs_t));
214 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
215 elementCnt * sizeof(F1SetupResponseIEs_t *));
216 CU_FREE(f1apMsg->choice.successfulOutcome,\
217 sizeof(SuccessfulOutcome_t));
218 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
221 strcpy((char*)cuName->buf, (char*)cuCfgParams.cuName);
223 /*Cells to be activated list*/
225 f1SetupRsp->protocolIEs.list.array[idx]->id = \
226 ProtocolIE_ID_id_Cells_to_be_Activated_List ;
227 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
228 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
229 F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List;
230 cellToActivate = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.\
231 Cells_to_be_Activated_List;
233 cellToActivate->list.count = cellCnt;
234 cellToActivate->list.size = \
235 cellCnt*sizeof(struct Cells_to_be_Activated_List_ItemIEs *);
236 CU_ALLOC(cellToActivate->list.array,\
237 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
238 if(cellToActivate->list.array == NULLP)
240 CU_FREE(cuName->buf, sizeof(cuName->size));
241 for(idy=0; idy<elementCnt; idy++)
243 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy],\
244 sizeof(F1SetupResponseIEs_t));
246 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
247 elementCnt * sizeof(F1SetupResponseIEs_t *));
248 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
249 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
252 for(idy=0; idy<cellCnt; idy++)
254 CU_ALLOC(cellToActivate->list.array[idy],\
255 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
256 if(cellToActivate->list.array[idy] == NULLP)
258 CU_FREE(cellToActivate->list.array,\
259 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
260 CU_FREE(cuName->buf, sizeof(cuName->size));
261 for(idy=0; idy<elementCnt; idy++)
263 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
264 sizeof(F1SetupResponseIEs_t));
266 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
267 elementCnt * sizeof(F1SetupResponseIEs_t *));
268 CU_FREE(f1apMsg->choice.successfulOutcome, \
269 sizeof(SuccessfulOutcome_t));
270 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
274 cellToActivate->list.array[0]->id = \
275 ProtocolIE_ID_id_Cells_to_be_Activated_List_Item;
276 cellToActivate->list.array[0]->criticality = Criticality_ignore;
277 cellToActivate->list.array[0]->value.present = \
278 Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item;
279 cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
280 nRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
281 CU_ALLOC(cellToActivate->list.array[0]->\
282 value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\
284 if(cellToActivate->list.array[0]->value.choice.\
285 Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf == NULLP)
288 for(idy=0; idy<cellCnt; idy++)
290 CU_FREE(cellToActivate->list.array[idy],\
291 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
294 CU_FREE(cellToActivate->list.array,\
295 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
296 CU_FREE(cuName->buf, sizeof(cuName->size));
297 for(idy=0; idy<elementCnt; idy++)
299 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
300 sizeof(F1SetupResponseIEs_t));
302 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
303 elementCnt * sizeof(F1SetupResponseIEs_t *));
304 CU_FREE(f1apMsg->choice.successfulOutcome, \
305 sizeof(SuccessfulOutcome_t));
306 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
309 buildPlmnId(cuCfgParams.plmn , &cellToActivate->list.array[0]->value.choice.\
310 Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity);
311 cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
312 nRCGI.nRCellIdentity.size = 5;
313 CU_ALLOC(cellToActivate->list.array[0]->value.choice.\
314 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf,\
316 if(cellToActivate->list.array[0]->value.choice.\
317 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf == NULLP)
319 CU_FREE(cellToActivate->list.array[0]->\
320 value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\
322 for(idy=0; idy<cellCnt; idy++)
324 CU_FREE(cellToActivate->list.array[idy],\
325 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
328 CU_FREE(cellToActivate->list.array,\
329 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
330 CU_FREE(cuName->buf, sizeof(cuName->size));
331 for(idy=0; idy<elementCnt; idy++)
333 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
334 sizeof(F1SetupResponseIEs_t));
336 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
337 elementCnt * sizeof(F1SetupResponseIEs_t *));
338 CU_FREE(f1apMsg->choice.successfulOutcome, \
339 sizeof(SuccessfulOutcome_t));
340 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
343 BuildNrCellId(&(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity));
346 f1SetupRsp->protocolIEs.list.array[idx]->id = \
347 ProtocolIE_ID_id_GNB_CU_RRC_Version;
348 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
349 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
350 F1SetupResponseIEs__value_PR_RRC_Version;
351 rrcVer = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.RRC_Version;
352 rrcVer->latest_RRC_Version.size = RRC_SIZE;
354 CU_ALLOC(rrcVer->latest_RRC_Version.buf, sizeof(U8));
355 if(rrcVer->latest_RRC_Version.buf == NULLP)
357 CU_FREE(cuName->buf, sizeof(cuName->size));
358 for(idy=0; idy<elementCnt; idx++)
360 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
361 sizeof(F1SetupResponseIEs_t));
363 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
364 elementCnt * sizeof(F1SetupResponseIEs_t *));
365 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
366 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
370 /* Need to check RRC Version */
371 rrcVer->latest_RRC_Version.buf[0] = cuCfgParams.rrcVersion.rrcVer;
372 rrcVer->latest_RRC_Version.bits_unused = 5; //TODO: pick from cuCfgParam. If not present, add it
373 CU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
374 if(rrcVer->iE_Extensions == NULLP)
376 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
377 CU_FREE(cuName->buf, sizeof(cuName->size));
378 for(idy=0; idy<elementCnt; idy++)
380 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
381 sizeof(F1SetupResponseIEs_t));
383 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
384 elementCnt * sizeof(F1SetupResponseIEs_t *));
385 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
386 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
389 rrcVer->iE_Extensions->list.count = 1;
390 rrcVer->iE_Extensions->list.size = sizeof(struct RRC_Version_ExtIEs *);
391 CU_ALLOC(rrcVer->iE_Extensions->list.array,\
392 sizeof(struct RRC_Version_ExtIEs *));
393 if(rrcVer->iE_Extensions->list.array == NULLP)
395 CU_FREE(rrcVer->iE_Extensions,\
396 sizeof(ProtocolExtensionContainer_4624P81_t));
397 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
398 CU_FREE(cuName->buf, sizeof(cuName->size));
399 for(idy=0; idy<elementCnt; idy++)
401 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
402 sizeof(F1SetupResponseIEs_t));
404 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
405 elementCnt * sizeof(F1SetupResponseIEs_t *));
406 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
407 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
410 CU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
411 sizeof(struct RRC_Version_ExtIEs));
412 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
414 CU_FREE(rrcVer->iE_Extensions->list.array,\
415 sizeof(struct RRC_Version_ExtIEs *));
416 CU_FREE(rrcVer->iE_Extensions,\
417 sizeof(ProtocolExtensionContainer_4624P81_t));
418 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
419 CU_FREE(cuName->buf, sizeof(cuName->size));
420 for(idy=0; idy<elementCnt; idy++)
422 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
423 sizeof(F1SetupResponseIEs_t));
425 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
426 elementCnt * sizeof(F1SetupResponseIEs_t *));
427 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
428 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
431 rrcVer->iE_Extensions->list.array[0]->id = \
432 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
433 rrcVer->iE_Extensions->list.array[0]->criticality = Criticality_reject;
434 rrcVer->iE_Extensions->list.array[0]->extensionValue.present = \
435 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
436 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
437 Latest_RRC_Version_Enhanced.size = 3*sizeof(U8);
438 CU_ALLOC(rrcVer->iE_Extensions->list.\
439 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf,\
441 if(rrcVer->iE_Extensions->list.\
442 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf == NULLP)
444 CU_FREE(rrcVer->iE_Extensions->list.array[0],\
445 sizeof(struct RRC_Version_ExtIEs));
446 CU_FREE(rrcVer->iE_Extensions->list.array,\
447 sizeof(struct RRC_Version_ExtIEs *));
448 CU_FREE(rrcVer->iE_Extensions,\
449 sizeof(ProtocolExtensionContainer_4624P81_t));
450 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
451 CU_FREE(cuName->buf, sizeof(cuName->size));
452 for(idy=0; idy<elementCnt; idy++)
454 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
455 sizeof(F1SetupResponseIEs_t));
457 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
458 elementCnt * sizeof(F1SetupResponseIEs_t *));
459 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
460 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
463 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
464 Latest_RRC_Version_Enhanced.buf[0] = 0;
465 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
466 Latest_RRC_Version_Enhanced.buf[1] = 5;
467 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
468 Latest_RRC_Version_Enhanced.buf[2] = 15;
470 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
472 /* Encode the F1SetupRequest type as UPER */
473 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
475 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
478 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
479 CU_FREE(cuName->buf, sizeof(cuName->size));
480 for(idx=0; idx<elementCnt; idx++)
482 CU_FREE(f1SetupRsp->protocolIEs.list.array[idx], sizeof(F1SetupResponseIEs_t));
484 CU_FREE(f1SetupRsp->protocolIEs.list.array, elementCnt * sizeof(F1SetupResponseIEs_t *));
485 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
486 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
488 /* Check encode results */
489 if(encRetVal.encoded == ENCODE_FAIL)
491 DU_LOG("\nF1AP : Could not encode F1SetupResponse structure (at %s)\n",\
492 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
497 DU_LOG("\nF1AP : Created APER encoded buffer for F1SetupResponse\n");
498 for(int i=0; i< encBufSize; i++)
500 printf("%x",encBuf[i]);
505 if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
507 DU_LOG("\nF1AP : Sending F1 Setup Response failed");
512 }/* End of BuildAndSendF1SetupRsp */
514 /*******************************************************************
516 * @brief Builds and sends the DUUpdateAcknowledge
520 * Function : BuildAndSendDUUpdateAck
522 * Functionality: Constructs the DU Update Acknowledge message and sends
523 * it to the DU through SCTP.
525 * @params[in] void **buf,Buffer to which encoded pattern is written into
526 * @params[in] int *size,size of buffer
528 * @return ROK - success
531 * ****************************************************************/
533 S16 BuildAndSendDUUpdateAck()
537 F1AP_PDU_t *f1apMsg = NULL;
538 GNBDUConfigurationUpdateAcknowledge_t *gNBDuCfgAck;
539 asn_enc_rval_t enRetVal; /* Encoder return value */
541 DU_LOG("\nF1AP : Building GNB-DU Config Update Ack\n");
543 /* Allocate the memory for F1SetupRequest_t */
544 CU_ALLOC(f1apMsg, (Size)sizeof(F1AP_PDU_t));
547 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
551 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
553 CU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
554 if(f1apMsg->choice.successfulOutcome == NULLP)
556 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
557 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
561 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_gNBDUConfigurationUpdate;
562 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
563 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge;
564 gNBDuCfgAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
567 gNBDuCfgAck->protocolIEs.list.count = elementCnt;
568 gNBDuCfgAck->protocolIEs.list.size = elementCnt*sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t);
570 /* Initialize the F1Setup members */
571 CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
572 if(gNBDuCfgAck->protocolIEs.list.array == NULLP)
574 DU_LOG("\nF1AP : Memory allocation for DuUpdateAcknowledgeIEs failed");
575 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
576 CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
580 for(idx=0; idx<elementCnt; idx++)
582 CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t));
583 if(gNBDuCfgAck->protocolIEs.list.array[idx] == NULLP)
585 CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
586 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
587 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
594 gNBDuCfgAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID ;
595 gNBDuCfgAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
596 gNBDuCfgAck->protocolIEs.list.array[idx]->value.present = GNBDUConfigurationUpdateAcknowledgeIEs__value_PR_TransactionID;
597 gNBDuCfgAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
599 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
601 /* Encode the F1SetupRequest type as UPER */
602 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
604 enRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
607 for(idx=0; idx<elementCnt; idx++)
609 CU_FREE(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t));
611 CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
612 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
613 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
615 /* Checking encode results */
616 if(enRetVal.encoded == ENCODE_FAIL)
618 DU_LOG("\nF1AP : Could not encode DUConfigUpdateAcknowledge structure (at %s)",enRetVal.failed_type ? enRetVal.failed_type->name : "unknown");
623 DU_LOG("\nF1AP : Created APER encoded buffer for DuConfigUpdateAcknowledge\n");
624 for(int i=0; i< encBufSize; i++)
626 printf("%x",encBuf[i]);
631 if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
633 DU_LOG("\nF1AP : Sending GNB-DU Config Update Ack failed");
639 }/* End of BuildAndSendDUUpdateAck*/
641 /*******************************************************************
643 * @brief Fills Radio Bearer Config
647 * Function : fillRadioBearerConfig
649 * Functionality: Fills Radio Bearer Config
651 * @params[in] SRB_ToAddModList *
653 * @return ROK - success
656 * ****************************************************************/
657 uint8_t fillRadioBearerConfig(SRB_ToAddModList_t *bearerCfg)
662 if(bearerCfg != NULLP)
665 bearerCfg->list.count = elementCnt;
666 bearerCfg->list.size =\
667 elementCnt * sizeof(SRB_ToAddMod_t *);
668 CU_ALLOC(bearerCfg->list.array, bearerCfg->list.size);
669 if(bearerCfg->list.array != NULLP)
671 for(idx = 0; idx < elementCnt; idx++)
673 CU_ALLOC(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
674 if(bearerCfg->list.array[idx] == NULLP)
676 for(ied = 0; ied < idx; ied++)
678 CU_FREE(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
680 CU_FREE(bearerCfg->list.array, bearerCfg->list.size);
690 bearerCfg->list.array[idx]->srb_Identity = SRB1;
695 /*******************************************************************
697 * @brief Fills Master CellGroup Info
701 * Function : fillMasterCellGroup
703 * Functionality: Fills Master Cell Group IE
705 * @params[in] RRCSetup_IEs_t *
707 * @return ROK - success
710 * ****************************************************************/
712 uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup)
715 masterCellGroup->buf = NULLP;
716 if(f1apMsgDb.duToCuContainer.buf)
718 masterCellGroup->size = f1apMsgDb.duToCuContainer.size;
719 CU_ALLOC(masterCellGroup->buf, masterCellGroup->size);
720 if(masterCellGroup->buf != NULLP)
722 memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\
723 masterCellGroup->size);
737 /*******************************************************************
739 * @brief Fills RRC setup IE
743 * Function : fillRRCSetupIE
745 * Functionality: Fills RRC Setup IE
747 * @params[in] RRCSetup_IEs_t *
749 * @return ROK - success
752 * ****************************************************************/
754 uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE)
759 CU_ALLOC(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
760 if(rrcSetupIE->radioBearerConfig.srb_ToAddModList != NULLP)
762 ret = fillRadioBearerConfig(rrcSetupIE->radioBearerConfig.srb_ToAddModList);
766 ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup);
770 CU_FREE(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
776 /*******************************************************************
778 * @brief Builds RRC Container IE required for DLRRCMessageTransfer
782 * Function : BuildDLRRCContainer
784 * Functionality: Builds RRC Container IE required for
785 * DLRRCMessageTransfer
789 * @return ROK - success
792 * ****************************************************************/
794 uint8_t BuildDLRRCContainer(RRCContainer_t *rrcContainer)
798 DL_CCCH_Message_t dl_CCCH_Msg;
799 asn_enc_rval_t encRetVal;
801 if(rrcContainer != NULLP)
803 dl_CCCH_Msg.message.present = DL_CCCH_MessageType_PR_c1;
805 CU_ALLOC(dl_CCCH_Msg.message.choice.c1 , sizeof(DL_CCCH_MessageType_t));
806 if(dl_CCCH_Msg.message.choice.c1 != NULLP)
808 dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup;
809 CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t));
810 if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP)
812 dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0;
813 dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\
814 present = RRCSetup__criticalExtensions_PR_rrcSetup;
815 /* Fill RRC Setup IE */
816 CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
817 criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t));
818 if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
819 criticalExtensions.choice.rrcSetup != NULLP)
821 ret = fillRRCSetupIE(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
822 criticalExtensions.choice.rrcSetup);
826 /* encode DL-CCCH message into RRC Container */
827 xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg);
828 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
830 encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf);
832 if(encRetVal.encoded == ENCODE_FAIL)
834 DU_LOG( "\n F1AP : Could not encode RRCContainer (at %s)\n",\
835 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
840 DU_LOG("\n F1AP : Created APER encoded buffer for RRCContainer\n");
841 for(int i = 0; i< encBufSize; i++)
843 printf("%x",encBuf[i]);
845 rrcContainer->size = encBufSize;
846 CU_ALLOC(rrcContainer->buf, rrcContainer->size);
847 if(rrcContainer->buf != NULLP)
849 memset(rrcContainer->buf, 0, encBufSize);
850 for(idx2 = 0; idx2 < encBufSize; idx2++)
852 rrcContainer->buf[idx2] = encBuf[idx2];
864 DU_LOG("\nF1AP: Memory Alloc failed for RRC Setup Msg");
870 DU_LOG("\nF1AP: Memory Alloc failed for RRC Msg");
876 DU_LOG("\nF1AP: Memory Alloc failed for DL Ccch Msg choice");
882 DU_LOG("\nF1AP: Memory Alloc failed for DlCcch Msg");
888 /*******************************************************************
890 * @brief Builds and sends the DLRRCMessageTransfer
894 * Function : BuildAndSendDLRRCMessageTransfer
896 * Functionality: Constructs the DL RRC Message Transfer and sends
897 * it to the CU through SCTP.
901 * @return ROK - success
904 * ****************************************************************/
905 S16 BuildAndSendDLRRCMessageTransfer()
908 uint8_t elementCnt = 0;
912 F1AP_PDU_t *f1apMsg = NULLP;
913 DLRRCMessageTransfer_t *dlRRCMsg = NULLP;
914 asn_enc_rval_t encRetVal; /* Encoder return value */
916 DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n");
918 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
921 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
925 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
926 CU_ALLOC(f1apMsg->choice.initiatingMessage,
927 sizeof(InitiatingMessage_t));
928 if(f1apMsg->choice.initiatingMessage == NULLP)
930 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
931 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
935 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_DLRRCMessageTransfer;
936 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
937 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_DLRRCMessageTransfer;
938 dlRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
941 dlRRCMsg->protocolIEs.list.count = elementCnt;
942 dlRRCMsg->protocolIEs.list.size = elementCnt * sizeof(DLRRCMessageTransferIEs_t *);
944 /* Initialize the F1Setup members */
945 CU_ALLOC(dlRRCMsg->protocolIEs.list.array, dlRRCMsg->protocolIEs.list.size);
946 if(dlRRCMsg->protocolIEs.list.array == NULLP)
948 DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed");
949 CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
950 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
954 for(idx=0; idx<elementCnt; idx++)
956 CU_ALLOC(dlRRCMsg->protocolIEs.list.array[idx], sizeof(DLRRCMessageTransferIEs_t));
957 if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP)
959 for(ieId=0; ieId<idx; ieId++)
961 CU_FREE(dlRRCMsg->protocolIEs.list.array[ieId],\
962 sizeof(DLRRCMessageTransferIEs_t));
964 CU_FREE(dlRRCMsg->protocolIEs.list.array,\
965 dlRRCMsg->protocolIEs.list.size);
966 CU_FREE(f1apMsg->choice.initiatingMessage,\
967 sizeof(InitiatingMessage_t));
968 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
973 /* GNB CU UE F1AP ID */
975 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
976 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
977 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
978 DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
979 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
981 /* GNB DU UE F1AP ID */
983 dlRRCMsg->protocolIEs.list.array[idx]->id = \
984 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
985 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
986 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
987 DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
988 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
992 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_SRBID;
993 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
994 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
995 DLRRCMessageTransferIEs__value_PR_SRBID;
996 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = SRB1;
1000 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer;
1001 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1002 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
1003 DLRRCMessageTransferIEs__value_PR_RRCContainer;
1004 BuildDLRRCContainer(&dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer);
1006 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1008 /* Encode the F1SetupRequest type as APER */
1009 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
1011 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1013 /* Encode results */
1014 if(encRetVal.encoded == ENCODE_FAIL)
1016 DU_LOG( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\
1017 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1022 DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n");
1023 for(int i=0; i< encBufSize; i++)
1025 printf("%x",encBuf[i]);
1030 if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
1032 DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed");
1037 }/* End of BuildAndSendDLRRCMessageTransfer */
1040 /*******************************************************************
1042 * @brief Builds and sends the UE Setup Response
1046 * Function : BuildAndSendUESetRsp
1048 * Functionality: Constructs the UE Setup Response and sends
1049 * it to the DU through SCTP.
1053 * @return ROK - success
1056 * ****************************************************************/
1057 S16 BuildAndSendUESetRsp()
1066 F1AP_PDU_t *f1apMsg = NULL;
1067 UEContextSetupResponse_t *ueSetRsp;
1068 asn_enc_rval_t encRetVal; /* Encoder return value */
1070 DU_LOG("\n F1AP : Building UE Context Setup Response\n");
1072 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1073 if(f1apMsg == NULLP)
1075 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
1079 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
1080 CU_ALLOC(f1apMsg->choice.successfulOutcome,
1081 sizeof(SuccessfulOutcome_t));
1082 if(f1apMsg->choice.successfulOutcome == NULLP)
1084 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
1085 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
1089 f1apMsg->choice.successfulOutcome->procedureCode = \
1090 ProcedureCode_id_UEContextSetup;
1091 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
1092 f1apMsg->choice.successfulOutcome->value.present = \
1093 SuccessfulOutcome__value_PR_UEContextSetupResponse;
1095 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
1097 ueSetRsp->protocolIEs.list.count = elementCnt;
1098 ueSetRsp->protocolIEs.list.size = \
1099 elementCnt * sizeof(UEContextSetupResponse_t *);
1101 /* Initialize the UESetup members */
1102 CU_ALLOC(ueSetRsp->protocolIEs.list.array, \
1103 ueSetRsp->protocolIEs.list.size);
1104 if(ueSetRsp->protocolIEs.list.array == NULLP)
1106 DU_LOG(" F1AP : Memory allocation for UE Setup Response failed");
1107 CU_FREE(f1apMsg->choice.successfulOutcome,
1108 sizeof(SuccessfulOutcome_t));
1109 CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
1113 for(idx=0; idx<elementCnt; idx++)
1115 CU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
1116 sizeof(UEContextSetupResponseIEs_t));
1117 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
1119 for(ieId=0; ieId<idx; ieId++)
1121 CU_FREE(ueSetRsp->protocolIEs.list.array[ieId],\
1122 sizeof(UEContextSetupResponseIEs_t));
1124 CU_FREE(ueSetRsp->protocolIEs.list.array,\
1125 ueSetRsp->protocolIEs.list.size);
1126 CU_FREE(f1apMsg->choice.successfulOutcome,\
1127 sizeof(SuccessfulOutcome_t));
1128 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
1135 /*GNB CU UE F1AP ID*/
1136 ueSetRsp->protocolIEs.list.array[idx]->id = \
1137 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
1138 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1139 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
1140 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
1141 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
1143 /*GNB DU UE F1AP ID*/
1145 ueSetRsp->protocolIEs.list.array[idx]->id = \
1146 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
1147 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1148 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
1149 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
1150 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
1153 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1155 /* Encode the F1SetupRequest type as APER */
1156 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
1158 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1160 /* Encode results */
1161 if(encRetVal.encoded == ENCODE_FAIL)
1163 DU_LOG( "\n F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
1164 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1169 DU_LOG("\n F1AP : Created APER encoded buffer for UE Context Setup Request\n");
1170 for(int i=0; i< encBufSize; i++)
1172 printf("%x",encBuf[i]);
1177 if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
1179 DU_LOG("\n F1AP : Sending UE Context Setup Request Failed");
1184 }/* End of BuildAndSendUESetRsp */
1187 uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg)
1191 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
1192 DU_LOG("\n filling the required values in DB in procInitULRRCMsg");
1194 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
1196 for(idx=0; idx < initULRRCMsg->protocolIEs.list.count; idx++)
1198 switch(initULRRCMsg->protocolIEs.list.array[idx]->id)
1200 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
1202 case ProtocolIE_ID_id_NRCGI:
1204 case ProtocolIE_ID_id_C_RNTI:
1206 case ProtocolIE_ID_id_RRCContainer:
1208 case ProtocolIE_ID_id_DUtoCURRCContainer:
1210 if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\
1211 .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\
1212 .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP))
1214 DU_LOG("\n Received Du to Cu RRC Container ");
1215 f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\
1216 .list.array[idx]->value.choice.DUtoCURRCContainer.size;
1217 CU_ALLOC(f1apMsgDb.duToCuContainer.buf, \
1218 f1apMsgDb.duToCuContainer.size);
1219 if(f1apMsgDb.duToCuContainer.buf != NULLP)
1221 memcpy(f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\
1222 .list.array[idx]->value.choice.DUtoCURRCContainer.buf, f1apMsgDb\
1223 .duToCuContainer.size);
1228 DU_LOG("\n Failed to receive Du to Cu RRC Container ");
1234 DU_LOG("\n Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id);
1239 ret = BuildAndSendDLRRCMessageTransfer();
1242 /*******************************************************************
1244 * @brief Handles received F1AP message and sends back response
1248 * Function : F1APMsgHdlr
1251 * - Decodes received F1AP control message
1252 * - Prepares response message, encodes and sends to SCTP
1255 * @return ROK - success
1258 * ****************************************************************/
1259 void F1APMsgHdlr(Buffer *mBuf)
1265 F1AP_PDU_t *f1apMsg = NULLP;
1266 asn_dec_rval_t rval; /* Decoder return value */
1267 F1AP_PDU_t f1apasnmsg ;
1269 DU_LOG("\nF1AP : Received F1AP message buffer");
1270 SPrntMsg(mBuf, 0,0);
1272 /* Copy mBuf into char array to decode it */
1273 SFndLenMsg(mBuf, &recvBufLen);
1274 if(SGetSBuf(DFLT_REGION, DFLT_POOL, (Data **)&recvBuf, (Size)recvBufLen) != ROK)
1276 DU_LOG("\nF1AP : Memory allocation failed");
1279 if(SCpyMsgFix(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
1281 DU_LOG("\nF1AP : Failed while copying %d", copyCnt);
1285 printf("\nF1AP : Received flat buffer to be decoded : ");
1286 for(i=0; i< recvBufLen; i++)
1288 printf("%x",recvBuf[i]);
1291 /* Decoding flat buffer into F1AP messsage */
1292 f1apMsg = &f1apasnmsg;
1293 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
1295 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
1296 SPutSBuf(DFLT_REGION, DFLT_POOL, (Data *)recvBuf, (Size)recvBufLen);
1297 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
1299 DU_LOG("\nF1AP : ASN decode failed");
1303 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1305 switch(f1apMsg->present)
1307 case F1AP_PDU_PR_initiatingMessage:
1309 switch(f1apMsg->choice.initiatingMessage->value.present)
1311 case InitiatingMessage__value_PR_F1SetupRequest:
1313 DU_LOG("\nF1AP : F1 setup request received");
1314 BuildAndSendF1SetupRsp();
1318 case InitiatingMessage__value_PR_GNBDUConfigurationUpdate:
1320 DU_LOG("\nF1AP : GNB-DU config update received");
1321 BuildAndSendDUUpdateAck();
1324 case InitiatingMessage__value_PR_InitialULRRCMessageTransfer:
1326 DU_LOG("\nF1AP : Received InitialULRRCMessageTransfer");
1327 procInitULRRCMsg(f1apMsg);
1332 DU_LOG("\nF1AP : Invalid type of intiating message [%d]",f1apMsg->choice.initiatingMessage->value.present);
1335 }/* End of switch(initiatingMessage) */
1339 }/* End of switch(f1apMsg->present) */
1341 } /* End of F1APMsgHdlr */
1343 /**********************************************************************
1345 **********************************************************************/