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 "odu_common_codec.h"
22 #include "cu_stub_sctp.h"
23 #include "cu_f1ap_msg_hdl.h"
25 /*******************************************************************
27 * @brief Sends F1 msg over SCTP
31 * Function : SendF1APMsg
33 * Functionality: Sends F1 msg over SCTP
35 * @params[in] Region region
37 * @return ROK - success
40 * ****************************************************************/
41 S16 SendF1APMsg(Region region, Pool pool)
45 if(SGetMsg(region, pool, &mBuf) == ROK)
47 if(SAddPstMsgMult((Data *)encBuf, encBufSize, mBuf) == ROK)
51 if(sctpSend(mBuf) != ROK)
53 DU_LOG("\nF1AP : SCTP Send failed");
60 DU_LOG("\nF1AP : SAddPstMsgMult failed");
68 DU_LOG("\nF1AP : Failed to allocate memory");
75 /*******************************************************************
77 * @brief Builds NRCell ID
81 * Function : BuildNrCellId
83 * Functionality: Building the NR Cell ID
85 * @params[in] BIT_STRING_t *nrcell
86 * @return ROK - success
89 * ****************************************************************/
91 S16 BuildNrCellId(BIT_STRING_t *nrcell)
94 for (tmp = 0 ; tmp < nrcell->size-1; tmp++)
99 nrcell->bits_unused = 4;
100 nrcell->size = 5 * sizeof(uint8_t);
104 /********************************************************************
106 * @brief Builds and sends the F1SetupResponse
110 * Function : BuildAndSendF1SetupRsp
112 * Functionality: Constructs the F1SetupResponse message and sends
113 * it back to the DU through SCTP.
115 * @params[in] void **buf,Buffer to which encoded pattern is written into
116 * @params[in] int *size,size of buffer
118 * @return ROK - success
121 * ****************************************************************/
122 S16 BuildAndSendF1SetupRsp()
125 U8 elementCnt,cellCnt;
126 F1AP_PDU_t *f1apMsg = NULL;
127 F1SetupResponse_t *f1SetupRsp;
128 GNB_CU_Name_t *cuName;
129 Cells_to_be_Activated_List_t *cellToActivate;
130 RRC_Version_t *rrcVer;
131 asn_enc_rval_t encRetVal;
132 DU_LOG("\nF1AP : Building F1 Setup Response\n");
134 /* Allocate the memory for F1SetupRequest_t */
135 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
138 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
141 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
143 CU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
144 if(f1apMsg->choice.successfulOutcome == NULLP)
146 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
147 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
151 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_F1Setup;
152 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
153 f1apMsg->choice.successfulOutcome->value.present = \
154 SuccessfulOutcome__value_PR_F1SetupResponse;
155 f1SetupRsp = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
158 f1SetupRsp->protocolIEs.list.count = elementCnt;
159 f1SetupRsp->protocolIEs.list.size = elementCnt*sizeof(F1SetupResponseIEs_t *);
161 CU_ALLOC(f1SetupRsp->protocolIEs.list.array, \
162 elementCnt * sizeof(F1SetupResponseIEs_t *));
163 if(f1SetupRsp->protocolIEs.list.array == NULLP)
165 DU_LOG("\nF1AP : Memory allocation for F1ResponseIEs failed");
166 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
167 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
171 for(idx=0; idx<elementCnt; idx++)
173 CU_ALLOC(f1SetupRsp->protocolIEs.list.array[idx], \
174 sizeof(F1SetupResponseIEs_t));
175 if(f1SetupRsp->protocolIEs.list.array[idx] == NULLP)
177 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
178 elementCnt * sizeof(F1SetupResponseIEs_t *));
179 CU_FREE(f1apMsg->choice.successfulOutcome, \
180 sizeof(SuccessfulOutcome_t));
181 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
188 f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
189 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
190 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
191 F1SetupResponseIEs__value_PR_TransactionID;
192 f1SetupRsp->protocolIEs.list.array[idx]->value.choice.TransactionID =\
197 f1SetupRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_Name;
198 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
199 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
200 F1SetupResponseIEs__value_PR_GNB_CU_Name;
201 cuName = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_Name;
202 cuName->size = sizeof(cuCfgParams.cuName);
204 CU_ALLOC(cuName->buf, sizeof(cuName->size));
205 if(cuName->buf == NULLP)
207 for(idy=0; idy<elementCnt; idy++)
209 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy],\
210 sizeof(F1SetupResponseIEs_t));
212 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
213 elementCnt * sizeof(F1SetupResponseIEs_t *));
214 CU_FREE(f1apMsg->choice.successfulOutcome,\
215 sizeof(SuccessfulOutcome_t));
216 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
219 strcpy((char*)cuName->buf, (char*)cuCfgParams.cuName);
221 /*Cells to be activated list*/
223 f1SetupRsp->protocolIEs.list.array[idx]->id = \
224 ProtocolIE_ID_id_Cells_to_be_Activated_List ;
225 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
226 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
227 F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List;
228 cellToActivate = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.\
229 Cells_to_be_Activated_List;
231 cellToActivate->list.count = cellCnt;
232 cellToActivate->list.size = \
233 cellCnt*sizeof(struct Cells_to_be_Activated_List_ItemIEs *);
234 CU_ALLOC(cellToActivate->list.array,\
235 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
236 if(cellToActivate->list.array == NULLP)
238 CU_FREE(cuName->buf, sizeof(cuName->size));
239 for(idy=0; idy<elementCnt; idy++)
241 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy],\
242 sizeof(F1SetupResponseIEs_t));
244 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
245 elementCnt * sizeof(F1SetupResponseIEs_t *));
246 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
247 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
250 for(idy=0; idy<cellCnt; idy++)
252 CU_ALLOC(cellToActivate->list.array[idy],\
253 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
254 if(cellToActivate->list.array[idy] == NULLP)
256 CU_FREE(cellToActivate->list.array,\
257 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
258 CU_FREE(cuName->buf, sizeof(cuName->size));
259 for(idy=0; idy<elementCnt; idy++)
261 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
262 sizeof(F1SetupResponseIEs_t));
264 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
265 elementCnt * sizeof(F1SetupResponseIEs_t *));
266 CU_FREE(f1apMsg->choice.successfulOutcome, \
267 sizeof(SuccessfulOutcome_t));
268 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
272 cellToActivate->list.array[0]->id = \
273 ProtocolIE_ID_id_Cells_to_be_Activated_List_Item;
274 cellToActivate->list.array[0]->criticality = Criticality_ignore;
275 cellToActivate->list.array[0]->value.present = \
276 Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item;
277 cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
278 nRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
279 CU_ALLOC(cellToActivate->list.array[0]->\
280 value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\
282 if(cellToActivate->list.array[0]->value.choice.\
283 Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf == NULLP)
286 for(idy=0; idy<cellCnt; idy++)
288 CU_FREE(cellToActivate->list.array[idy],\
289 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
292 CU_FREE(cellToActivate->list.array,\
293 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
294 CU_FREE(cuName->buf, sizeof(cuName->size));
295 for(idy=0; idy<elementCnt; idy++)
297 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
298 sizeof(F1SetupResponseIEs_t));
300 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
301 elementCnt * sizeof(F1SetupResponseIEs_t *));
302 CU_FREE(f1apMsg->choice.successfulOutcome, \
303 sizeof(SuccessfulOutcome_t));
304 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
307 buildPlmnId(cuCfgParams.plmn , &cellToActivate->list.array[0]->value.choice.\
308 Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity);
309 cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
310 nRCGI.nRCellIdentity.size = 5;
311 CU_ALLOC(cellToActivate->list.array[0]->value.choice.\
312 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf,\
314 if(cellToActivate->list.array[0]->value.choice.\
315 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf == NULLP)
317 CU_FREE(cellToActivate->list.array[0]->\
318 value.choice.Cells_to_be_Activated_List_Item.nRCGI.pLMN_Identity.buf,\
320 for(idy=0; idy<cellCnt; idy++)
322 CU_FREE(cellToActivate->list.array[idy],\
323 sizeof(struct Cells_to_be_Activated_List_ItemIEs ));
326 CU_FREE(cellToActivate->list.array,\
327 sizeof(struct Cells_to_be_Activated_List_ItemIEs *));
328 CU_FREE(cuName->buf, sizeof(cuName->size));
329 for(idy=0; idy<elementCnt; idy++)
331 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
332 sizeof(F1SetupResponseIEs_t));
334 CU_FREE(f1SetupRsp->protocolIEs.list.array, \
335 elementCnt * sizeof(F1SetupResponseIEs_t *));
336 CU_FREE(f1apMsg->choice.successfulOutcome, \
337 sizeof(SuccessfulOutcome_t));
338 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
341 BuildNrCellId(&(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity));
344 f1SetupRsp->protocolIEs.list.array[idx]->id = \
345 ProtocolIE_ID_id_GNB_CU_RRC_Version;
346 f1SetupRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
347 f1SetupRsp->protocolIEs.list.array[idx]->value.present = \
348 F1SetupResponseIEs__value_PR_RRC_Version;
349 rrcVer = &f1SetupRsp->protocolIEs.list.array[idx]->value.choice.RRC_Version;
350 rrcVer->latest_RRC_Version.size = RRC_SIZE;
352 CU_ALLOC(rrcVer->latest_RRC_Version.buf, sizeof(U8));
353 if(rrcVer->latest_RRC_Version.buf == NULLP)
355 CU_FREE(cuName->buf, sizeof(cuName->size));
356 for(idy=0; idy<elementCnt; idx++)
358 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
359 sizeof(F1SetupResponseIEs_t));
361 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
362 elementCnt * sizeof(F1SetupResponseIEs_t *));
363 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
364 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
368 /* Need to check RRC Version */
369 rrcVer->latest_RRC_Version.buf[0] = cuCfgParams.rrcVersion.rrcVer;
370 rrcVer->latest_RRC_Version.bits_unused = 5; //TODO: pick from cuCfgParam. If not present, add it
371 CU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
372 if(rrcVer->iE_Extensions == NULLP)
374 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
375 CU_FREE(cuName->buf, sizeof(cuName->size));
376 for(idy=0; idy<elementCnt; idy++)
378 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
379 sizeof(F1SetupResponseIEs_t));
381 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
382 elementCnt * sizeof(F1SetupResponseIEs_t *));
383 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
384 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
387 rrcVer->iE_Extensions->list.count = 1;
388 rrcVer->iE_Extensions->list.size = sizeof(struct RRC_Version_ExtIEs *);
389 CU_ALLOC(rrcVer->iE_Extensions->list.array,\
390 sizeof(struct RRC_Version_ExtIEs *));
391 if(rrcVer->iE_Extensions->list.array == NULLP)
393 CU_FREE(rrcVer->iE_Extensions,\
394 sizeof(ProtocolExtensionContainer_4624P81_t));
395 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
396 CU_FREE(cuName->buf, sizeof(cuName->size));
397 for(idy=0; idy<elementCnt; idy++)
399 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
400 sizeof(F1SetupResponseIEs_t));
402 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
403 elementCnt * sizeof(F1SetupResponseIEs_t *));
404 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
405 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
408 CU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
409 sizeof(struct RRC_Version_ExtIEs));
410 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
412 CU_FREE(rrcVer->iE_Extensions->list.array,\
413 sizeof(struct RRC_Version_ExtIEs *));
414 CU_FREE(rrcVer->iE_Extensions,\
415 sizeof(ProtocolExtensionContainer_4624P81_t));
416 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
417 CU_FREE(cuName->buf, sizeof(cuName->size));
418 for(idy=0; idy<elementCnt; idy++)
420 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
421 sizeof(F1SetupResponseIEs_t));
423 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
424 elementCnt * sizeof(F1SetupResponseIEs_t *));
425 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
426 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
429 rrcVer->iE_Extensions->list.array[0]->id = \
430 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
431 rrcVer->iE_Extensions->list.array[0]->criticality = Criticality_reject;
432 rrcVer->iE_Extensions->list.array[0]->extensionValue.present = \
433 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
434 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
435 Latest_RRC_Version_Enhanced.size = 3*sizeof(U8);
436 CU_ALLOC(rrcVer->iE_Extensions->list.\
437 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf,\
439 if(rrcVer->iE_Extensions->list.\
440 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf == NULLP)
442 CU_FREE(rrcVer->iE_Extensions->list.array[0],\
443 sizeof(struct RRC_Version_ExtIEs));
444 CU_FREE(rrcVer->iE_Extensions->list.array,\
445 sizeof(struct RRC_Version_ExtIEs *));
446 CU_FREE(rrcVer->iE_Extensions,\
447 sizeof(ProtocolExtensionContainer_4624P81_t));
448 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
449 CU_FREE(cuName->buf, sizeof(cuName->size));
450 for(idy=0; idy<elementCnt; idy++)
452 CU_FREE(f1SetupRsp->protocolIEs.list.array[idy], \
453 sizeof(F1SetupResponseIEs_t));
455 CU_FREE(f1SetupRsp->protocolIEs.list.array,\
456 elementCnt * sizeof(F1SetupResponseIEs_t *));
457 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
458 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
461 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
462 Latest_RRC_Version_Enhanced.buf[0] = 0;
463 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
464 Latest_RRC_Version_Enhanced.buf[1] = 5;
465 rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.\
466 Latest_RRC_Version_Enhanced.buf[2] = 15;
468 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
470 /* Encode the F1SetupRequest type as UPER */
471 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
473 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
476 CU_FREE(rrcVer->latest_RRC_Version.buf, sizeof(U8));
477 CU_FREE(cuName->buf, sizeof(cuName->size));
478 for(idx=0; idx<elementCnt; idx++)
480 CU_FREE(f1SetupRsp->protocolIEs.list.array[idx], sizeof(F1SetupResponseIEs_t));
482 CU_FREE(f1SetupRsp->protocolIEs.list.array, elementCnt * sizeof(F1SetupResponseIEs_t *));
483 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
484 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
486 /* Check encode results */
487 if(encRetVal.encoded == ENCODE_FAIL)
489 DU_LOG("\nF1AP : Could not encode F1SetupResponse structure (at %s)\n",\
490 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
495 DU_LOG("\nF1AP : Created APER encoded buffer for F1SetupResponse\n");
496 for(int i=0; i< encBufSize; i++)
498 printf("%x",encBuf[i]);
503 if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
505 DU_LOG("\nF1AP : Sending F1 Setup Response failed");
510 }/* End of BuildAndSendF1SetupRsp */
512 /*******************************************************************
514 * @brief Builds and sends the DUUpdateAcknowledge
518 * Function : BuildAndSendDUUpdateAck
520 * Functionality: Constructs the DU Update Acknowledge message and sends
521 * it to the DU through SCTP.
523 * @params[in] void **buf,Buffer to which encoded pattern is written into
524 * @params[in] int *size,size of buffer
526 * @return ROK - success
529 * ****************************************************************/
531 S16 BuildAndSendDUUpdateAck()
535 F1AP_PDU_t *f1apMsg = NULL;
536 GNBDUConfigurationUpdateAcknowledge_t *gNBDuCfgAck;
537 asn_enc_rval_t enRetVal; /* Encoder return value */
539 DU_LOG("\nF1AP : Building GNB-DU Config Update Ack\n");
541 /* Allocate the memory for F1SetupRequest_t */
542 CU_ALLOC(f1apMsg, (Size)sizeof(F1AP_PDU_t));
545 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
549 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
551 CU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
552 if(f1apMsg->choice.successfulOutcome == NULLP)
554 DU_LOG("\nF1AP : Memory allocation for F1AP-PDU failed");
555 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
559 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_gNBDUConfigurationUpdate;
560 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
561 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge;
562 gNBDuCfgAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
565 gNBDuCfgAck->protocolIEs.list.count = elementCnt;
566 gNBDuCfgAck->protocolIEs.list.size = elementCnt*sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t);
568 /* Initialize the F1Setup members */
569 CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
570 if(gNBDuCfgAck->protocolIEs.list.array == NULLP)
572 DU_LOG("\nF1AP : Memory allocation for DuUpdateAcknowledgeIEs failed");
573 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
574 CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
578 for(idx=0; idx<elementCnt; idx++)
580 CU_ALLOC(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t));
581 if(gNBDuCfgAck->protocolIEs.list.array[idx] == NULLP)
583 CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
584 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
585 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
592 gNBDuCfgAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID ;
593 gNBDuCfgAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
594 gNBDuCfgAck->protocolIEs.list.array[idx]->value.present = GNBDUConfigurationUpdateAcknowledgeIEs__value_PR_TransactionID;
595 gNBDuCfgAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
597 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
599 /* Encode the F1SetupRequest type as UPER */
600 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
602 enRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
605 for(idx=0; idx<elementCnt; idx++)
607 CU_FREE(gNBDuCfgAck->protocolIEs.list.array[idx], sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t));
609 CU_FREE(gNBDuCfgAck->protocolIEs.list.array, elementCnt * sizeof(GNBDUConfigurationUpdateAcknowledgeIEs_t *));
610 CU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
611 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
613 /* Checking encode results */
614 if(enRetVal.encoded == ENCODE_FAIL)
616 DU_LOG("\nF1AP : Could not encode DUConfigUpdateAcknowledge structure (at %s)",enRetVal.failed_type ? enRetVal.failed_type->name : "unknown");
621 DU_LOG("\nF1AP : Created APER encoded buffer for DuConfigUpdateAcknowledge\n");
622 for(int i=0; i< encBufSize; i++)
624 printf("%x",encBuf[i]);
629 if(SendF1APMsg(CU_APP_MEM_REG, CU_POOL) != ROK)
631 DU_LOG("\nF1AP : Sending GNB-DU Config Update Ack failed");
637 }/* End of BuildAndSendDUUpdateAck*/
639 /*******************************************************************
641 * @brief Fills Radio Bearer Config
645 * Function : fillRadioBearerConfig
647 * Functionality: Fills Radio Bearer Config
649 * @params[in] SRB_ToAddModList *
651 * @return ROK - success
654 * ****************************************************************/
655 uint8_t fillRadioBearerConfig(SRB_ToAddModList_t *bearerCfg)
660 if(bearerCfg != NULLP)
663 bearerCfg->list.count = elementCnt;
664 bearerCfg->list.size =\
665 elementCnt * sizeof(SRB_ToAddMod_t *);
666 CU_ALLOC(bearerCfg->list.array, bearerCfg->list.size);
667 if(bearerCfg->list.array != NULLP)
669 for(idx = 0; idx < elementCnt; idx++)
671 CU_ALLOC(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
672 if(bearerCfg->list.array[idx] == NULLP)
674 for(ied = 0; ied < idx; ied++)
676 CU_FREE(bearerCfg->list.array[idx], sizeof(SRB_ToAddMod_t));
678 CU_FREE(bearerCfg->list.array, bearerCfg->list.size);
688 bearerCfg->list.array[idx]->srb_Identity = SRB1;
693 /*******************************************************************
695 * @brief Fills Master CellGroup Info
699 * Function : fillMasterCellGroup
701 * Functionality: Fills Master Cell Group IE
703 * @params[in] RRCSetup_IEs_t *
705 * @return ROK - success
708 * ****************************************************************/
710 uint8_t fillMasterCellGroup(OCTET_STRING_t *masterCellGroup)
713 masterCellGroup->buf = NULLP;
714 if(f1apMsgDb.duToCuContainer.buf)
716 masterCellGroup->size = f1apMsgDb.duToCuContainer.size;
717 CU_ALLOC(masterCellGroup->buf, masterCellGroup->size);
718 if(masterCellGroup->buf != NULLP)
720 memcpy(masterCellGroup->buf, f1apMsgDb.duToCuContainer.buf,\
721 masterCellGroup->size);
735 /*******************************************************************
737 * @brief Fills RRC setup IE
741 * Function : fillRRCSetupIE
743 * Functionality: Fills RRC Setup IE
745 * @params[in] RRCSetup_IEs_t *
747 * @return ROK - success
750 * ****************************************************************/
752 uint8_t fillRRCSetupIE(RRCSetup_IEs_t *rrcSetupIE)
757 CU_ALLOC(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
758 if(rrcSetupIE->radioBearerConfig.srb_ToAddModList != NULLP)
760 ret = fillRadioBearerConfig(rrcSetupIE->radioBearerConfig.srb_ToAddModList);
764 ret = fillMasterCellGroup(&rrcSetupIE->masterCellGroup);
768 CU_FREE(rrcSetupIE->radioBearerConfig.srb_ToAddModList, sizeof(SRB_ToAddModList_t));
774 /*******************************************************************
776 * @brief Builds RRC Container IE required for DLRRCMessageTransfer
780 * Function : BuildDLRRCContainer
782 * Functionality: Builds RRC Container IE required for
783 * DLRRCMessageTransfer
787 * @return ROK - success
790 * ****************************************************************/
792 uint8_t BuildDLRRCContainer(RRCContainer_t *rrcContainer)
796 DL_CCCH_Message_t dl_CCCH_Msg;
797 asn_enc_rval_t encRetVal;
799 if(rrcContainer != NULLP)
801 dl_CCCH_Msg.message.present = DL_CCCH_MessageType_PR_c1;
803 CU_ALLOC(dl_CCCH_Msg.message.choice.c1 , sizeof(DL_CCCH_MessageType_t));
804 if(dl_CCCH_Msg.message.choice.c1 != NULLP)
806 dl_CCCH_Msg.message.choice.c1->present = DL_CCCH_MessageType__c1_PR_rrcSetup;
807 CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup, sizeof(RRCSetup_t));
808 if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup != NULLP)
810 dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->rrc_TransactionIdentifier = 0;
811 dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->criticalExtensions.\
812 present = RRCSetup__criticalExtensions_PR_rrcSetup;
813 /* Fill RRC Setup IE */
814 CU_ALLOC(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
815 criticalExtensions.choice.rrcSetup, sizeof(RRCSetup_IEs_t));
816 if(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
817 criticalExtensions.choice.rrcSetup != NULLP)
819 ret = fillRRCSetupIE(dl_CCCH_Msg.message.choice.c1->choice.rrcSetup->\
820 criticalExtensions.choice.rrcSetup);
824 /* encode DL-CCCH message into RRC Container */
825 xer_fprint(stdout, &asn_DEF_DL_CCCH_MessageType, &dl_CCCH_Msg);
826 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
828 encRetVal = aper_encode(&asn_DEF_DL_CCCH_MessageType, 0, &dl_CCCH_Msg, PrepFinalEncBuf, encBuf);
830 if(encRetVal.encoded == ENCODE_FAIL)
832 DU_LOG( "\n F1AP : Could not encode RRCContainer (at %s)\n",\
833 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
838 DU_LOG("\n F1AP : Created APER encoded buffer for RRCContainer\n");
839 for(int i = 0; i< encBufSize; i++)
841 printf("%x",encBuf[i]);
843 rrcContainer->size = encBufSize;
844 CU_ALLOC(rrcContainer->buf, rrcContainer->size);
845 if(rrcContainer->buf != NULLP)
847 memset(rrcContainer->buf, 0, encBufSize);
848 for(idx2 = 0; idx2 < encBufSize; idx2++)
850 rrcContainer->buf[idx2] = encBuf[idx2];
862 DU_LOG("\nF1AP: Memory Alloc failed for RRC Setup Msg");
868 DU_LOG("\nF1AP: Memory Alloc failed for RRC Msg");
874 DU_LOG("\nF1AP: Memory Alloc failed for DL Ccch Msg choice");
880 DU_LOG("\nF1AP: Memory Alloc failed for DlCcch Msg");
886 /*******************************************************************
888 * @brief Builds and sends the DLRRCMessageTransfer
892 * Function : BuildAndSendDLRRCMessageTransfer
894 * Functionality: Constructs the DL RRC Message Transfer and sends
895 * it to the CU through SCTP.
899 * @return ROK - success
902 * ****************************************************************/
903 S16 BuildAndSendDLRRCMessageTransfer()
906 uint8_t elementCnt = 0;
910 F1AP_PDU_t *f1apMsg = NULLP;
911 DLRRCMessageTransfer_t *dlRRCMsg = NULLP;
912 asn_enc_rval_t encRetVal; /* Encoder return value */
914 DU_LOG("\n F1AP : Building DL RRC Message Transfer Message\n");
916 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
919 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
923 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
924 CU_ALLOC(f1apMsg->choice.initiatingMessage,
925 sizeof(InitiatingMessage_t));
926 if(f1apMsg->choice.initiatingMessage == NULLP)
928 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
929 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
933 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_DLRRCMessageTransfer;
934 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
935 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_DLRRCMessageTransfer;
936 dlRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
939 dlRRCMsg->protocolIEs.list.count = elementCnt;
940 dlRRCMsg->protocolIEs.list.size = elementCnt * sizeof(DLRRCMessageTransferIEs_t *);
942 /* Initialize the F1Setup members */
943 CU_ALLOC(dlRRCMsg->protocolIEs.list.array, dlRRCMsg->protocolIEs.list.size);
944 if(dlRRCMsg->protocolIEs.list.array == NULLP)
946 DU_LOG(" F1AP : Memory allocation for DL RRC MessageTransferIEs failed");
947 CU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
948 CU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
952 for(idx=0; idx<elementCnt; idx++)
954 CU_ALLOC(dlRRCMsg->protocolIEs.list.array[idx], sizeof(DLRRCMessageTransferIEs_t));
955 if(dlRRCMsg->protocolIEs.list.array[idx] == NULLP)
957 for(ieId=0; ieId<idx; ieId++)
959 CU_FREE(dlRRCMsg->protocolIEs.list.array[ieId],\
960 sizeof(DLRRCMessageTransferIEs_t));
962 CU_FREE(dlRRCMsg->protocolIEs.list.array,\
963 dlRRCMsg->protocolIEs.list.size);
964 CU_FREE(f1apMsg->choice.initiatingMessage,\
965 sizeof(InitiatingMessage_t));
966 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
971 /* GNB CU UE F1AP ID */
973 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
974 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
975 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
976 DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
977 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
979 /* GNB DU UE F1AP ID */
981 dlRRCMsg->protocolIEs.list.array[idx]->id = \
982 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
983 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
984 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
985 DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
986 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
990 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_SRBID;
991 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
992 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
993 DLRRCMessageTransferIEs__value_PR_SRBID;
994 dlRRCMsg->protocolIEs.list.array[idx]->value.choice.SRBID = SRB1;
998 dlRRCMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_RRCContainer;
999 dlRRCMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1000 dlRRCMsg->protocolIEs.list.array[idx]->value.present = \
1001 DLRRCMessageTransferIEs__value_PR_RRCContainer;
1002 BuildDLRRCContainer(&dlRRCMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer);
1004 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1006 /* Encode the F1SetupRequest type as APER */
1007 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
1009 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1011 /* Encode results */
1012 if(encRetVal.encoded == ENCODE_FAIL)
1014 DU_LOG( "\n F1AP : Could not encode DL RRC Message Transfer structure (at %s)\n",\
1015 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1020 DU_LOG("\n F1AP : Created APER encoded buffer for DL RRC Message transfer\n");
1021 for(int i=0; i< encBufSize; i++)
1023 printf("%x",encBuf[i]);
1028 if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
1030 DU_LOG("\n F1AP : Sending DL RRC Message Transfer Failed");
1035 }/* End of BuildAndSendDLRRCMessageTransfer */
1038 /*******************************************************************
1040 * @brief Builds and sends the UE Setup Response
1044 * Function : BuildAndSendUESetRsp
1046 * Functionality: Constructs the UE Setup Response and sends
1047 * it to the DU through SCTP.
1051 * @return ROK - success
1054 * ****************************************************************/
1055 S16 BuildAndSendUESetRsp()
1064 F1AP_PDU_t *f1apMsg = NULL;
1065 UEContextSetupResponse_t *ueSetRsp;
1066 asn_enc_rval_t encRetVal; /* Encoder return value */
1068 DU_LOG("\n F1AP : Building UE Context Setup Response\n");
1070 CU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1071 if(f1apMsg == NULLP)
1073 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
1077 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
1078 CU_ALLOC(f1apMsg->choice.successfulOutcome,
1079 sizeof(SuccessfulOutcome_t));
1080 if(f1apMsg->choice.successfulOutcome == NULLP)
1082 DU_LOG(" F1AP : Memory allocation for F1AP-PDU failed");
1083 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
1087 f1apMsg->choice.successfulOutcome->procedureCode = \
1088 ProcedureCode_id_UEContextSetup;
1089 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
1090 f1apMsg->choice.successfulOutcome->value.present = \
1091 SuccessfulOutcome__value_PR_UEContextSetupResponse;
1093 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
1095 ueSetRsp->protocolIEs.list.count = elementCnt;
1096 ueSetRsp->protocolIEs.list.size = \
1097 elementCnt * sizeof(UEContextSetupResponse_t *);
1099 /* Initialize the UESetup members */
1100 CU_ALLOC(ueSetRsp->protocolIEs.list.array, \
1101 ueSetRsp->protocolIEs.list.size);
1102 if(ueSetRsp->protocolIEs.list.array == NULLP)
1104 DU_LOG(" F1AP : Memory allocation for UE Setup Response failed");
1105 CU_FREE(f1apMsg->choice.successfulOutcome,
1106 sizeof(SuccessfulOutcome_t));
1107 CU_FREE(f1apMsg,(Size)sizeof(F1AP_PDU_t));
1111 for(idx=0; idx<elementCnt; idx++)
1113 CU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
1114 sizeof(UEContextSetupResponseIEs_t));
1115 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
1117 for(ieId=0; ieId<idx; ieId++)
1119 CU_FREE(ueSetRsp->protocolIEs.list.array[ieId],\
1120 sizeof(UEContextSetupResponseIEs_t));
1122 CU_FREE(ueSetRsp->protocolIEs.list.array,\
1123 ueSetRsp->protocolIEs.list.size);
1124 CU_FREE(f1apMsg->choice.successfulOutcome,\
1125 sizeof(SuccessfulOutcome_t));
1126 CU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
1133 /*GNB CU UE F1AP ID*/
1134 ueSetRsp->protocolIEs.list.array[idx]->id = \
1135 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
1136 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1137 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
1138 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
1139 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = CU_ID;
1141 /*GNB DU UE F1AP ID*/
1143 ueSetRsp->protocolIEs.list.array[idx]->id = \
1144 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
1145 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
1146 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
1147 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
1148 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = DU_ID;
1151 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1153 /* Encode the F1SetupRequest type as APER */
1154 cmMemset((U8 *)encBuf, 0, ENC_BUF_MAX_LEN);
1156 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1158 /* Encode results */
1159 if(encRetVal.encoded == ENCODE_FAIL)
1161 DU_LOG( "\n F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
1162 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1167 DU_LOG("\n F1AP : Created APER encoded buffer for UE Context Setup Request\n");
1168 for(int i=0; i< encBufSize; i++)
1170 printf("%x",encBuf[i]);
1175 if(SendF1APMsg(CU_APP_MEM_REG,CU_POOL) != ROK)
1177 DU_LOG("\n F1AP : Sending UE Context Setup Request Failed");
1182 }/* End of BuildAndSendUESetRsp */
1185 uint8_t procInitULRRCMsg(F1AP_PDU_t *f1apMsg)
1189 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
1190 DU_LOG("\n filling the required values in DB in procInitULRRCMsg");
1192 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
1194 for(idx=0; idx < initULRRCMsg->protocolIEs.list.count; idx++)
1196 switch(initULRRCMsg->protocolIEs.list.array[idx]->id)
1198 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
1200 case ProtocolIE_ID_id_NRCGI:
1202 case ProtocolIE_ID_id_C_RNTI:
1204 case ProtocolIE_ID_id_RRCContainer:
1206 case ProtocolIE_ID_id_DUtoCURRCContainer:
1208 if((initULRRCMsg->protocolIEs.list.array[idx]->value.choice\
1209 .DUtoCURRCContainer.size > 0) && (initULRRCMsg->protocolIEs\
1210 .list.array[idx]->value.choice.DUtoCURRCContainer.buf != NULLP))
1212 DU_LOG("\n Received Du to Cu RRC Container ");
1213 f1apMsgDb.duToCuContainer.size = initULRRCMsg->protocolIEs\
1214 .list.array[idx]->value.choice.DUtoCURRCContainer.size;
1215 CU_ALLOC(f1apMsgDb.duToCuContainer.buf, \
1216 f1apMsgDb.duToCuContainer.size);
1217 if(f1apMsgDb.duToCuContainer.buf != NULLP)
1219 memcpy(f1apMsgDb.duToCuContainer.buf, initULRRCMsg->protocolIEs\
1220 .list.array[idx]->value.choice.DUtoCURRCContainer.buf, f1apMsgDb\
1221 .duToCuContainer.size);
1226 DU_LOG("\n Failed to receive Du to Cu RRC Container ");
1232 DU_LOG("\n Invalid Event %ld", initULRRCMsg->protocolIEs.list.array[idx]->id);
1237 ret = BuildAndSendDLRRCMessageTransfer();
1240 /*******************************************************************
1242 * @brief Handles received F1AP message and sends back response
1246 * Function : F1APMsgHdlr
1249 * - Decodes received F1AP control message
1250 * - Prepares response message, encodes and sends to SCTP
1253 * @return ROK - success
1256 * ****************************************************************/
1257 void F1APMsgHdlr(Buffer *mBuf)
1263 F1AP_PDU_t *f1apMsg = NULLP;
1264 asn_dec_rval_t rval; /* Decoder return value */
1265 F1AP_PDU_t f1apasnmsg ;
1267 DU_LOG("\nF1AP : Received F1AP message buffer");
1268 SPrntMsg(mBuf, 0,0);
1270 /* Copy mBuf into char array to decode it */
1271 SFndLenMsg(mBuf, &recvBufLen);
1272 if(SGetSBuf(DFLT_REGION, DFLT_POOL, (Data **)&recvBuf, (Size)recvBufLen) != ROK)
1274 DU_LOG("\nF1AP : Memory allocation failed");
1277 if(SCpyMsgFix(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
1279 DU_LOG("\nF1AP : Failed while copying %d", copyCnt);
1283 printf("\nF1AP : Received flat buffer to be decoded : ");
1284 for(i=0; i< recvBufLen; i++)
1286 printf("%x",recvBuf[i]);
1289 /* Decoding flat buffer into F1AP messsage */
1290 f1apMsg = &f1apasnmsg;
1291 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
1293 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
1294 SPutSBuf(DFLT_REGION, DFLT_POOL, (Data *)recvBuf, (Size)recvBufLen);
1295 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
1297 DU_LOG("\nF1AP : ASN decode failed");
1301 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1303 switch(f1apMsg->present)
1305 case F1AP_PDU_PR_initiatingMessage:
1307 switch(f1apMsg->choice.initiatingMessage->value.present)
1309 case InitiatingMessage__value_PR_F1SetupRequest:
1311 DU_LOG("\nF1AP : F1 setup request received");
1312 BuildAndSendF1SetupRsp();
1316 case InitiatingMessage__value_PR_GNBDUConfigurationUpdate:
1318 DU_LOG("\nF1AP : GNB-DU config update received");
1319 BuildAndSendDUUpdateAck();
1322 case InitiatingMessage__value_PR_InitialULRRCMessageTransfer:
1324 DU_LOG("\nF1AP : Received InitialULRRCMessageTransfer");
1325 procInitULRRCMsg(f1apMsg);
1330 DU_LOG("\nF1AP : Invalid type of intiating message [%d]",f1apMsg->choice.initiatingMessage->value.present);
1333 }/* End of switch(initiatingMessage) */
1337 }/* End of switch(f1apMsg->present) */
1339 } /* End of F1APMsgHdlr */
1341 /**********************************************************************
1343 **********************************************************************/