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 */
21 #include "cu_stub_sctp.h"
22 #include "cu_f1ap_msg_hdl.h"
24 /*******************************************************************
26 * @brief Sends F1 msg over SCTP
30 * Function : SendF1APMsg
32 * Functionality: Sends F1 msg over SCTP
34 * @params[in] Region region
36 * @return ROK - success
39 * ****************************************************************/
40 S16 SendF1APMsg(Region region, Pool pool)
44 if(SGetMsg(region, pool, &mBuf) == ROK)
46 if(SAddPstMsgMult((Data *)encBuf, encBufSize, mBuf) == ROK)
50 if(sctpSend(mBuf) != ROK)
52 DU_LOG("\nF1AP : SCTP Send failed");
59 DU_LOG("\nF1AP : SAddPstMsgMult failed");
67 DU_LOG("\nF1AP : Failed to allocate memory");
74 /*******************************************************************
76 * @brief Builds NRCell ID
80 * Function : BuildNrCellId
82 * Functionality: Building the NR Cell ID
84 * @params[in] BIT_STRING_t *nrcell
85 * @return ROK - success
88 * ****************************************************************/
90 S16 BuildNrCellId(BIT_STRING_t *nrcell)
93 for (tmp = 0 ; tmp < nrcell->size-1; tmp++)
98 nrcell->bits_unused = 4;
99 nrcell->size = 5 * sizeof(uint8_t);
103 /********************************************************************
105 * @brief Builds and sends the F1SetupResponse
109 * Function : BuildAndSendF1SetupRsp
111 * Functionality: Constructs the F1SetupResponse message and sends
112 * it back to the DU through SCTP.
114 * @params[in] void **buf,Buffer to which encoded pattern is written into
115 * @params[in] int *size,size of buffer
117 * @return ROK - success
120 * ****************************************************************/
121 S16 BuildAndSendF1SetupRsp()
124 U8 elementCnt,cellCnt;
125 F1AP_PDU_t *f1apMsg = NULL;
126 F1SetupResponse_t *f1SetupRsp;
127 GNB_CU_Name_t *cuName;
128 Cells_to_be_Activated_List_t *cellToActivate;
129 RRC_Version_t *rrcVer;
130 asn_enc_rval_t encRetVal;
131 DU_LOG("\nF1AP : Building F1 Setup Response\n");
133 /* Allocate the memory for F1SetupRequest_t */
134 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
137 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
140 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
142 CU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
143 if(f1apMsg->choice.successfulOutcome == NULLP)
145 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
146 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
150 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_F1Setup;
151 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
152 f1apMsg->choice.successfulOutcome->value.present = \
153 SuccessfulOutcome__value_PR_F1SetupResponse;
154 f1SetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
157 f1SetupRsp->protocolIEs.list.count = elementCnt;
158 f1SetupRsp->protocolIEs.list.size = elementCnt*sizeof(F1SetupResponseIEs_t *);
160 CU_ALLOC(f1SetupRsp->protocolIEs.list.array, \
161 elementCnt * sizeof(F1SetupResponseIEs_t *));
162 if(f1SetupRsp->protocolIEs.list.array == NULLP)
164 DU_LOG("\nF1AP : Memory allocation for F1ResponseIEs failed");
165 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
166 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
170 for(idx=0; idx<elementCnt; idx++)
172 CU_ALLOC(f1SetupRsp->protocolIEs.list.array[idx], \
173 sizeof(F1SetupResponseIEs_t));
174 if(f1SetupRsp->protocolIEs.list.array[idx] == NULLP)
176 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
177 elementCnt * sizeof(F1SetupResponseIEs_t *));
178 CU_FREE(f1apMsg->choice.successfulOutcome, \
179 sizeof(SuccessfulOutcome_t));
180 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
187 f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
188 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
189 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
190 F1SetupResponseIEs__value_PR_TransactionID;
191 f1SetupRsp->protocolIEs.list.array[idx]->value.choice.TransactionID =\
196 f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_Name;
197 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
198 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
199 F1SetupResponseIEs__value_PR_GNB_CU_Name;
200 cuName = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_Name;
201 cuName->size = sizeof(cuCfgParams.cuName);
203 CU_ALLOC(cuName->buf, sizeof(cuName->size));
204 if(cuName->buf == NULLP)
206 for(idy=0; idy<elementCnt; idy++)
208 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy],\
209 sizeof(F1SetupResponseIEs_t));
211 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
212 elementCnt * sizeof(F1SetupResponseIEs_t *));
213 CU_FREE(f1apMsg->choice.successfulOutcome,\
214 sizeof(SuccessfulOutcome_t));
215 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
218 strcpy((char*)cuName->buf, (char*)cuCfgParams.cuName);
220 /*Cells to be activated list*/
222 f1SetupRsp->protocolIEs.list.array[idx]->id = \
223 ProtocolIE_ID_id_Cells_to_be_Activated_List ;
224 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
225 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
226 F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List;
227 cellToActivate = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.\
228 Cells_to_be_Activated_List;
230 cellToActivate->list.count = cellCnt;
231 cellToActivate->list.size = \
232 cellCnt*sizeof(struct Cells_to_be_Activated_List_ItemIEs *);
233 CU_ALLOC(cellToActivate->list.array,\
234 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
235 if(cellToActivate->list.array == NULLP)
237 CU_FREE(cuName->buf, sizeof(cuName->size));
238 for(idy=0; idy<elementCnt; idy++)
240 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy],\
241 sizeof(F1SetupResponseIEs_t));
243 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
244 elementCnt * sizeof(F1SetupResponseIEs_t *));
245 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
246 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
249 for(idy=0; idy<cellCnt; idy++)
251 CU_ALLOC(cellToActivate->list.array[idy],\
252 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
253 if(cellToActivate->list.array[idy] == NULLP)
255 CU_FREE(cellToActivate->list.array,\
256 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
257 CU_FREE(cuName->buf, sizeof(cuName->size));
258 for(idy=0; idy<elementCnt; idy++)
260 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
261 sizeof(F1SetupResponseIEs_t));
263 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
264 elementCnt * sizeof(F1SetupResponseIEs_t *));
265 CU_FREE(f1apMsg->choice.successfulOutcome, \
266 sizeof(SuccessfulOutcome_t));
267 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
271 cellToActivate->list.array[0]->id = \
272 ProtocolIE_ID_id_Cells_to_be_Activated_List_Item;
273 cellToActivate->list.array[0]->criticality = Criticality_ignore;
274 cellToActivate->list.array[0]->value.present = \
275 Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item;
276 cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
277 nRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
278 CU_ALLOC(cellToActivate->list.array[0]->\
279 value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\
281 if(cellToActivate->list.array[0]->value.choice.\
282 Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf == NULLP)
285 for(idy=0; idy<cellCnt; idy++)
287 CU_FREE(cellToActivate->list.array[idy],\
288 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
291 CU_FREE(cellToActivate->list.array,\
292 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
293 CU_FREE(cuName->buf, sizeof(cuName->size));
294 for(idy=0; idy<elementCnt; idy++)
296 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
297 sizeof(F1SetupResponseIEs_t));
299 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
300 elementCnt * sizeof(F1SetupResponseIEs_t *));
301 CU_FREE(f1apMsg->choice.successfulOutcome, \
302 sizeof(SuccessfulOutcome_t));
303 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
306 buildPlmnId(cuCfgParams.plmn , &cellToActivate->list.array[0]->value.choice.\
307 Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity);
308 cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
309 nRCGI.nRCellIdentity.size = 5;
310 CU_ALLOC(cellToActivate->list.array[0]->value.choice.\
311 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf,\
313 if(cellToActivate->list.array[0]->value.choice.\
314 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf == NULLP)
316 CU_FREE(cellToActivate->list.array[0]->\
317 value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\
319 for(idy=0; idy<cellCnt; idy++)
321 CU_FREE(cellToActivate->list.array[idy],\
322 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
325 CU_FREE(cellToActivate->list.array,\
326 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
327 CU_FREE(cuName->buf, sizeof(cuName->size));
328 for(idy=0; idy<elementCnt; idy++)
330 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
331 sizeof(F1SetupResponseIEs_t));
333 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
334 elementCnt * sizeof(F1SetupResponseIEs_t *));
335 CU_FREE(f1apMsg->choice.successfulOutcome, \
336 sizeof(SuccessfulOutcome_t));
337 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
340 BuildNrCellId(&(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity));
343 f1SetupRsp->protocolIEs.list.array[idx]->id = \
344 ProtocolIE_ID_id_GNB_CU_RRC_Version;
345 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
346 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
347 F1SetupResponseIEs__value_PR_RRC_Version;
348 rrcVer = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.RRC_Version;
349 rrcVer->latest_RRC_Version.size = RRC_SIZE;
351 CU_ALLOC(rrcVer->latest_RRC_Version.buf, sizeof(U8));
352 if(rrcVer->latest_RRC_Version.buf == NULLP)
354 CU_FREE(cuName->buf, sizeof(cuName->size));
355 for(idy=0; idy<elementCnt; idx++)
357 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
358 sizeof(F1SetupResponseIEs_t));
360 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
361 elementCnt * sizeof(F1SetupResponseIEs_t *));
362 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
363 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
367 /* Need to check RRC Version */
368 rrcVer->latest_RRC_Version.buf[0] = cuCfgParams.rrcVersion.rrcVer;
369 rrcVer->latest_RRC_Version.bits_unused = 5; //TODO: pick from cuCfgParam. If not present, add it
370 CU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
371 if(rrcVer->iE_Extensions == NULLP)
373 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
374 CU_FREE(cuName->buf, sizeof(cuName->size));
375 for(idy=0; idy<elementCnt; idy++)
377 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
378 sizeof(F1SetupResponseIEs_t));
380 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
381 elementCnt * sizeof(F1SetupResponseIEs_t *));
382 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
383 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
386 rrcVer->iE_Extensions->list.count = 1;
387 rrcVer->iE_Extensions->list.size = sizeof(struct RRC_Version_ExtIEs *);
388 CU_ALLOC(rrcVer->iE_Extensions->list.array,\
389 sizeof(struct RRC_Version_ExtIEs *));
390 if(rrcVer->iE_Extensions->list.array == NULLP)
392 CU_FREE(rrcVer->iE_Extensions,\
393 sizeof(ProtocolExtensionContainer_4624P81_t));
394 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
395 CU_FREE(cuName->buf, sizeof(cuName->size));
396 for(idy=0; idy<elementCnt; idy++)
398 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
399 sizeof(F1SetupResponseIEs_t));
401 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
402 elementCnt * sizeof(F1SetupResponseIEs_t *));
403 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
404 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
407 CU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
408 sizeof(struct RRC_Version_ExtIEs));
409 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
411 CU_FREE(rrcVer->iE_Extensions->list.array,\
412 sizeof(struct RRC_Version_ExtIEs *));
413 CU_FREE(rrcVer->iE_Extensions,\
414 sizeof(ProtocolExtensionContainer_4624P81_t));
415 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
416 CU_FREE(cuName->buf, sizeof(cuName->size));
417 for(idy=0; idy<elementCnt; idy++)
419 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
420 sizeof(F1SetupResponseIEs_t));
422 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
423 elementCnt * sizeof(F1SetupResponseIEs_t *));
424 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
425 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
428 rrcVer->iE_Extensions->list.array[0]->id = \
429 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
430 rrcVer->iE_Extensions->list.array[0]->criticality = Criticality_reject;
431 rrcVer->iE_Extensions->list.array[0]->extensionValue.present = \
432 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
433 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
434 Latest_RRC_Version_Enhanced.size = 3*sizeof(U8);
435 CU_ALLOC(rrcVer->iE_Extensions->list.\
436 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf,\
438 if(rrcVer->iE_Extensions->list.\
439 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf == NULLP)
441 CU_FREE(rrcVer->iE_Extensions->list.array[0],\
442 sizeof(struct RRC_Version_ExtIEs));
443 CU_FREE(rrcVer->iE_Extensions->list.array,\
444 sizeof(struct RRC_Version_ExtIEs *));
445 CU_FREE(rrcVer->iE_Extensions,\
446 sizeof(ProtocolExtensionContainer_4624P81_t));
447 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
448 CU_FREE(cuName->buf, sizeof(cuName->size));
449 for(idy=0; idy<elementCnt; idy++)
451 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
452 sizeof(F1SetupResponseIEs_t));
454 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
455 elementCnt * sizeof(F1SetupResponseIEs_t *));
456 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
457 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
460 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
461 Latest_RRC_Version_Enhanced.buf[0] = 0;
462 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
463 Latest_RRC_Version_Enhanced.buf[1] = 5;
464 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
465 Latest_RRC_Version_Enhanced.buf[2] = 15;
467 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
469 /* Encode the F1SetupRequest type as UPER */
470 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
472 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
475 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
476 CU_FREE(cuName->buf, sizeof(cuName->size));
477 for(idx=0; idx<elementCnt; idx++)
479 CU_FREE(f1SetupRsp->protocolIEs.list.array[idx], sizeof(F1SetupResponseIEs_t));
481 CU_FREE(f1SetupRsp->protocolIEs.list.array, elementCnt * sizeof(F1SetupResponseIEs_t *));
482 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
483 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
485 /* Check encode results */
486 if(encRetVal.encoded == ENCODE_FAIL)
488 DU_LOG("\nF1AP : Could not encode F1SetupResponse structure (at %s)\n",\
489 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
494 DU_LOG("\nF1AP : Created APER encoded buffer for F1SetupResponse\n");
495 for(int i=0; i< encBufSize; i++)
497 printf("%x",encBuf[i]);
502 if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
504 DU_LOG("\nF1AP : Sending F1 Setup Response failed");
509 }/* End of BuildAndSendF1SetupRsp */
511 /*******************************************************************
513 * @brief Builds and sends the DUUpdateAcknowledge
517 * Function : BuildAndSendDUUpdateAck
519 * Functionality: Constructs the DU Update Acknowledge message and sends
520 * it to the DU through SCTP.
522 * @params[in] void **buf,Buffer to which encoded pattern is written into
523 * @params[in] int *size,size of buffer
525 * @return ROK - success
528 * ****************************************************************/
530 S16 BuildAndSendDUUpdateAck()
534 F1AP_PDU_t *f1apMsg = NULL;
535 GNBDUConfigurationUpdateAcknowledge_t *gNBDuCfgAck;
536 asn_enc_rval_t enRetVal; /* Encoder return value */
538 DU_LOG("\nF1AP : Building GNB-DU Config Update Ack\n");
540 /* Allocate the memory for F1SetupRequest_t */
541 CU_ALLOC(f1apMsg, (Size)sizeof(F1AP_PDU_t));
544 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
548 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
550 CU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
551 if(f1apMsg->choice.successfulOutcome == NULLP)
553 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
554 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
558 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_gNBDUConfigurationUpdate;
559 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
560 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge;
561 gNBDuCfgAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
564 gNBDuCfgAck->protocolIEs.list.count = elementCnt;
565 gNBDuCfgAck->protocolIEs.list.size = elementCnt*sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t);
567 /* Initialize the F1Setup members */
568 CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
569 if(gNBDuCfgAck->protocolIEs.list.array == NULLP)
571 DU_LOG("\nF1AP : Memory allocation for DuUpdateAcknowledgeIEs failed");
572 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
573 CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
577 for(idx=0; idx<elementCnt; idx++)
579 CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t));
580 if(gNBDuCfgAck->protocolIEs.list.array[idx] == NULLP)
582 CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
583 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
584 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
591 gNBDuCfgAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID ;
592 gNBDuCfgAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
593 gNBDuCfgAck->protocolIEs.list.array[idx]->value.present = GNBDUConfigurationUpdateAcknowledgeIEs__value_PR_TransactionID;
594 gNBDuCfgAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
596 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
598 /* Encode the F1SetupRequest type as UPER */
599 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
601 enRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
604 for(idx=0; idx<elementCnt; idx++)
606 CU_FREE(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t));
608 CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
609 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
610 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
612 /* Checking encode results */
613 if(enRetVal.encoded == ENCODE_FAIL)
615 DU_LOG("\nF1AP : Could not encode DUConfigUpdateAcknowledge structure (at %s)",enRetVal.failed_type ? enRetVal.failed_type->name : "unknown");
620 DU_LOG("\nF1AP : Created APER encoded buffer for DuConfigUpdateAcknowledge\n");
621 for(int i=0; i< encBufSize; i++)
623 printf("%x",encBuf[i]);
628 if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
630 DU_LOG("\nF1AP : Sending GNB-DU Config Update Ack failed");
636 }/* End of BuildAndSendDUUpdateAck*/
638 /*******************************************************************
640 * @brief Fills Radio Bearer Config
644 * Function : fillRadioBearerConfig
646 * Functionality: Fills Radio Bearer Config
648 * @params[in] SRB_ToAddModList *
650 * @return ROK - success
653 * ****************************************************************/
654 uint8_t fillRadioBearerConfig(SRB_ToAddModList_t *bearerCfg)
659 if(bearerCfg != NULLP)
662 bearerCfg->list.count = elementCnt;
663 bearerCfg->list.size =\
664 elementCnt * sizeof(SRB_ToAddMod_t *);
665 CU_ALLOC(bearerCfg->list.array, bearerCfg->list.size);
666 if(bearerCfg->list.array != NULLP)
668 for(idx = 0; idx < elementCnt; idx++)
670 CU_ALLOC(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
671 if(bearerCfg->list.array[idx] == NULLP)
673 for(ied = 0; ied < idx; ied++)
675 CU_FREE(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
677 CU_FREE(bearerCfg->list.array, bearerCfg->list.size);
687 bearerCfg->list.array[idx]->srb_Identity = SRB1;
692 /*******************************************************************
694 * @brief Fills Master CellGroup Info
698 * Function : fillMasterCellGroup
700 * Functionality: Fills Master Cell Group IE
702 * @params[in] RRCSetup_IEs_t *
704 * @return ROK - success
707 * ****************************************************************/
709 uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup)
712 masterCellGroup->buf = NULLP;
713 if(f1apMsgDb.duToCuContainer.buf)
715 masterCellGroup->size = f1apMsgDb.duToCuContainer.size;
716 CU_ALLOC(masterCellGroup->buf, masterCellGroup->size);
717 if(masterCellGroup->buf != NULLP)
719 memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\
720 masterCellGroup->size);
734 /*******************************************************************
736 * @brief Fills RRC setup IE
740 * Function : fillRRCSetupIE
742 * Functionality: Fills RRC Setup IE
744 * @params[in] RRCSetup_IEs_t *
746 * @return ROK - success
749 * ****************************************************************/
751 uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE)
756 CU_ALLOC(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
757 if(rrcSetupIE->radioBearerConfig.srb_ToAddModList != NULLP)
759 ret = fillRadioBearerConfig(rrcSetupIE->radioBearerConfig.srb_ToAddModList);
763 ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup);
767 CU_FREE(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
773 /*******************************************************************
775 * @brief Builds RRC Container IE required for DLRRCMessageTransfer
779 * Function : BuildDLRRCContainer
781 * Functionality: Builds RRC Container IE required for
782 * DLRRCMessageTransfer
786 * @return ROK - success
789 * ****************************************************************/
791 uint8_t BuildDLRRCContainer(RRCContainer_t *rrcContainer)
795 DL_CCCH_Message_t dl_CCCH_Msg;
796 asn_enc_rval_t encRetVal;
798 if(rrcContainer != NULLP)
800 dl_CCCH_Msg.message.present = DL_CCCH_MessageType_PR_c1;
802 CU_ALLOC(dl_CCCH_Msg.message.choice.c1 , sizeof(DL_CCCH_MessageType_t));
803 if(dl_CCCH_Msg.message.choice.c1 != NULLP)
805 dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup;
806 CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t));
807 if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP)
809 dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0;
810 dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\
811 present = RRCSetup__criticalExtensions_PR_rrcSetup;
812 /* Fill RRC Setup IE */
813 CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
814 criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t));
815 if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
816 criticalExtensions.choice.rrcSetup != NULLP)
818 ret = fillRRCSetupIE(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
819 criticalExtensions.choice.rrcSetup);
823 /* encode DL-CCCH message into RRC Container */
824 xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg);
825 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
827 encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf);
829 if(encRetVal.encoded == ENCODE_FAIL)
831 DU_LOG( "\n F1AP : Could not encode RRCContainer (at %s)\n",\
832 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
837 DU_LOG("\n F1AP : Created APER encoded buffer for RRCContainer\n");
838 for(int i = 0; i< encBufSize; i++)
840 printf("%x",encBuf[i]);
842 rrcContainer->size = encBufSize;
843 CU_ALLOC(rrcContainer->buf, rrcContainer->size);
844 if(rrcContainer->buf != NULLP)
846 memset(rrcContainer->buf, 0, encBufSize);
847 for(idx2 = 0; idx2 < encBufSize; idx2++)
849 rrcContainer->buf[idx2] = encBuf[idx2];
861 DU_LOG("\nF1AP: Memory Alloc failed for RRC Setup Msg");
867 DU_LOG("\nF1AP: Memory Alloc failed for RRC Msg");
873 DU_LOG("\nF1AP: Memory Alloc failed for DL Ccch Msg choice");
879 DU_LOG("\nF1AP: Memory Alloc failed for DlCcch Msg");
885 /*******************************************************************
887 * @brief Builds and sends the DLRRCMessageTransfer
891 * Function : BuildAndSendDLRRCMessageTransfer
893 * Functionality: Constructs the DL RRC Message Transfer and sends
894 * it to the CU through SCTP.
898 * @return ROK - success
901 * ****************************************************************/
902 S16 BuildAndSendDLRRCMessageTransfer()
905 uint8_t elementCnt = 0;
909 F1AP_PDU_t *f1apMsg = NULLP;
910 DLRRCMessageTransfer_t *dlRRCMsg = NULLP;
911 asn_enc_rval_t encRetVal; /* Encoder return value */
913 DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n");
915 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
918 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
922 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
923 CU_ALLOC(f1apMsg->choice.initiatingMessage,
924 sizeof(InitiatingMessage_t));
925 if(f1apMsg->choice.initiatingMessage == NULLP)
927 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
928 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
932 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_DLRRCMessageTransfer;
933 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
934 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_DLRRCMessageTransfer;
935 dlRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
938 dlRRCMsg->protocolIEs.list.count = elementCnt;
939 dlRRCMsg->protocolIEs.list.size = elementCnt * sizeof(DLRRCMessageTransferIEs_t *);
941 /* Initialize the F1Setup members */
942 CU_ALLOC(dlRRCMsg->protocolIEs.list.array, dlRRCMsg->protocolIEs.list.size);
943 if(dlRRCMsg->protocolIEs.list.array == NULLP)
945 DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed");
946 CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
947 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
951 for(idx=0; idx<elementCnt; idx++)
953 CU_ALLOC(dlRRCMsg->protocolIEs.list.array[idx], sizeof(DLRRCMessageTransferIEs_t));
954 if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP)
956 for(ieId=0; ieId<idx; ieId++)
958 CU_FREE(dlRRCMsg->protocolIEs.list.array[ieId],\
959 sizeof(DLRRCMessageTransferIEs_t));
961 CU_FREE(dlRRCMsg->protocolIEs.list.array,\
962 dlRRCMsg->protocolIEs.list.size);
963 CU_FREE(f1apMsg->choice.initiatingMessage,\
964 sizeof(InitiatingMessage_t));
965 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
970 /* GNB CU UE F1AP ID */
972 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
973 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
974 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
975 DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
976 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
978 /* GNB DU UE F1AP ID */
980 dlRRCMsg->protocolIEs.list.array[idx]->id = \
981 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
982 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
983 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
984 DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
985 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
989 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_SRBID;
990 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
991 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
992 DLRRCMessageTransferIEs__value_PR_SRBID;
993 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = SRB1;
997 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer;
998 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
999 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
1000 DLRRCMessageTransferIEs__value_PR_RRCContainer;
1001 BuildDLRRCContainer(&dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer);
1003 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1005 /* Encode the F1SetupRequest type as APER */
1006 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
1008 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1010 /* Encode results */
1011 if(encRetVal.encoded == ENCODE_FAIL)
1013 DU_LOG( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\
1014 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1019 DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n");
1020 for(int i=0; i< encBufSize; i++)
1022 printf("%x",encBuf[i]);
1027 if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
1029 DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed");
1034 }/* End of BuildAndSendDLRRCMessageTransfer */
1037 /*******************************************************************
1039 * @brief Builds and sends the UE Setup Response
1043 * Function : BuildAndSendUESetRsp
1045 * Functionality: Constructs the UE Setup Response and sends
1046 * it to the DU through SCTP.
1050 * @return ROK - success
1053 * ****************************************************************/
1054 S16 BuildAndSendUESetRsp()
1063 F1AP_PDU_t *f1apMsg = NULL;
1064 UEContextSetupResponse_t *ueSetRsp;
1065 asn_enc_rval_t encRetVal; /* Encoder return value */
1067 DU_LOG("\n F1AP : Building UE Context Setup Response\n");
1069 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1070 if(f1apMsg == NULLP)
1072 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
1076 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
1077 CU_ALLOC(f1apMsg->choice.successfulOutcome,
1078 sizeof(SuccessfulOutcome_t));
1079 if(f1apMsg->choice.successfulOutcome == NULLP)
1081 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
1082 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
1086 f1apMsg->choice.successfulOutcome->procedureCode = \
1087 ProcedureCode_id_UEContextSetup;
1088 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
1089 f1apMsg->choice.successfulOutcome->value.present = \
1090 SuccessfulOutcome__value_PR_UEContextSetupResponse;
1092 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
1094 ueSetRsp->protocolIEs.list.count = elementCnt;
1095 ueSetRsp->protocolIEs.list.size = \
1096 elementCnt * sizeof(UEContextSetupResponse_t *);
1098 /* Initialize the UESetup members */
1099 CU_ALLOC(ueSetRsp->protocolIEs.list.array, \
1100 ueSetRsp->protocolIEs.list.size);
1101 if(ueSetRsp->protocolIEs.list.array == NULLP)
1103 DU_LOG(" F1AP : Memory allocation for UE Setup Response failed");
1104 CU_FREE(f1apMsg->choice.successfulOutcome,
1105 sizeof(SuccessfulOutcome_t));
1106 CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
1110 for(idx=0; idx<elementCnt; idx++)
1112 CU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
1113 sizeof(UEContextSetupResponseIEs_t));
1114 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
1116 for(ieId=0; ieId<idx; ieId++)
1118 CU_FREE(ueSetRsp->protocolIEs.list.array[ieId],\
1119 sizeof(UEContextSetupResponseIEs_t));
1121 CU_FREE(ueSetRsp->protocolIEs.list.array,\
1122 ueSetRsp->protocolIEs.list.size);
1123 CU_FREE(f1apMsg->choice.successfulOutcome,\
1124 sizeof(SuccessfulOutcome_t));
1125 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
1132 /*GNB CU UE F1AP ID*/
1133 ueSetRsp->protocolIEs.list.array[idx]->id = \
1134 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
1135 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1136 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
1137 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
1138 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
1140 /*GNB DU UE F1AP ID*/
1142 ueSetRsp->protocolIEs.list.array[idx]->id = \
1143 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
1144 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1145 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
1146 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
1147 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
1150 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1152 /* Encode the F1SetupRequest type as APER */
1153 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
1155 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1157 /* Encode results */
1158 if(encRetVal.encoded == ENCODE_FAIL)
1160 DU_LOG( "\n F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
1161 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1166 DU_LOG("\n F1AP : Created APER encoded buffer for UE Context Setup Request\n");
1167 for(int i=0; i< encBufSize; i++)
1169 printf("%x",encBuf[i]);
1174 if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
1176 DU_LOG("\n F1AP : Sending UE Context Setup Request Failed");
1181 }/* End of BuildAndSendUESetRsp */
1184 uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg)
1188 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
1189 DU_LOG("\n filling the required values in DB in procInitULRRCMsg");
1191 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
1193 for(idx=0; idx < initULRRCMsg->protocolIEs.list.count; idx++)
1195 switch(initULRRCMsg->protocolIEs.list.array[idx]->id)
1197 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
1199 case ProtocolIE_ID_id_NRCGI:
1201 case ProtocolIE_ID_id_C_RNTI:
1203 case ProtocolIE_ID_id_RRCContainer:
1205 case ProtocolIE_ID_id_DUtoCURRCContainer:
1207 if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\
1208 .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\
1209 .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP))
1211 DU_LOG("\n Received Du to Cu RRC Container ");
1212 f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\
1213 .list.array[idx]->value.choice.DUtoCURRCContainer.size;
1214 CU_ALLOC(f1apMsgDb.duToCuContainer.buf, \
1215 f1apMsgDb.duToCuContainer.size);
1216 if(f1apMsgDb.duToCuContainer.buf != NULLP)
1218 memcpy(f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\
1219 .list.array[idx]->value.choice.DUtoCURRCContainer.buf, f1apMsgDb\
1220 .duToCuContainer.size);
1225 DU_LOG("\n Failed to receive Du to Cu RRC Container ");
1231 DU_LOG("\n Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id);
1236 ret = BuildAndSendDLRRCMessageTransfer();
1239 /*******************************************************************
1241 * @brief Handles received F1AP message and sends back response
1245 * Function : F1APMsgHdlr
1248 * - Decodes received F1AP control message
1249 * - Prepares response message, encodes and sends to SCTP
1252 * @return ROK - success
1255 * ****************************************************************/
1256 void F1APMsgHdlr(Buffer *mBuf)
1262 F1AP_PDU_t *f1apMsg = NULLP;
1263 asn_dec_rval_t rval; /* Decoder return value */
1264 F1AP_PDU_t f1apasnmsg ;
1266 DU_LOG("\nF1AP : Received F1AP message buffer");
1267 SPrntMsg(mBuf, 0,0);
1269 /* Copy mBuf into char array to decode it */
1270 SFndLenMsg(mBuf, &recvBufLen);
1271 if(SGetSBuf(DFLT_REGION, DFLT_POOL, (Data **)&recvBuf, (Size)recvBufLen) != ROK)
1273 DU_LOG("\nF1AP : Memory allocation failed");
1276 if(SCpyMsgFix(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
1278 DU_LOG("\nF1AP : Failed while copying %d", copyCnt);
1282 printf("\nF1AP : Received flat buffer to be decoded : ");
1283 for(i=0; i< recvBufLen; i++)
1285 printf("%x",recvBuf[i]);
1288 /* Decoding flat buffer into F1AP messsage */
1289 f1apMsg = &f1apasnmsg;
1290 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
1292 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
1293 SPutSBuf(DFLT_REGION, DFLT_POOL, (Data *)recvBuf, (Size)recvBufLen);
1294 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
1296 DU_LOG("\nF1AP : ASN decode failed");
1300 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1302 switch(f1apMsg->present)
1304 case F1AP_PDU_PR_initiatingMessage:
1306 switch(f1apMsg->choice.initiatingMessage->value.present)
1308 case InitiatingMessage__value_PR_F1SetupRequest:
1310 DU_LOG("\nF1AP : F1 setup request received");
1311 BuildAndSendF1SetupRsp();
1315 case InitiatingMessage__value_PR_GNBDUConfigurationUpdate:
1317 DU_LOG("\nF1AP : GNB-DU config update received");
1318 BuildAndSendDUUpdateAck();
1321 case InitiatingMessage__value_PR_InitialULRRCMessageTransfer:
1323 DU_LOG("\nF1AP : Received InitialULRRCMessageTransfer");
1324 procInitULRRCMsg(f1apMsg);
1329 DU_LOG("\nF1AP : Invalid type of intiating message [%d]",f1apMsg->choice.initiatingMessage->value.present);
1332 }/* End of switch(initiatingMessage) */
1336 }/* End of switch(f1apMsg->present) */
1338 } /* End of F1APMsgHdlr */
1340 /**********************************************************************
1342 **********************************************************************/