+/**
+ * @brief Fill and send statistics response to DU APP
+ *
+ * @details
+ *
+ * Function : MacSendStatsRspToDuApp
+ *
+ * Fill and send statistics response to DU APP
+ *
+ * @param[in] Response
+ * @param[in] Cause of response
+ * @return int
+ * -# ROK
+ **/
+uint8_t MacSendStatsRspToDuApp(MacStatsRsp *statsRsp)
+{
+ uint8_t ret = ROK;
+ Pst pst;
+ MacStatsRsp *macStatsRsp = NULLP;
+
+ DU_LOG("\nINFO --> MAC : MacSendStatsRspToDuApp: Sending Statistics Response to DU APP");
+
+ /* Workaround : To skip corrupted memory, allocating a pointer that will
+ * remain unused */
+ uint8_t *dummyPtr = NULLP;
+ MAC_ALLOC_SHRABL_BUF(dummyPtr, sizeof(uint8_t));
+
+ MAC_ALLOC_SHRABL_BUF(macStatsRsp, sizeof(MacStatsRsp));
+ if(macStatsRsp == NULLP)
+ {
+ DU_LOG("\nERROR --> MAC : Failed to allocate memory in MacProcSchStatsRsp");
+ ret = RFAILED;
+ }
+ else
+ {
+ memcpy(macStatsRsp, statsRsp, sizeof(MacStatsRsp));
+ memset(statsRsp, 0, sizeof(MacStatsRsp));
+
+ memset(&pst, 0, sizeof(Pst));
+ FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_STATISTICS_RSP);
+ if(((*macDuStatsRspOpts[pst.selector])(&pst, macStatsRsp))!= ROK)
+ {
+ DU_LOG("\nERROR --> MAC : Failed to send statistics response to DU APP");
+ MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, macStatsRsp, sizeof(MacStatsRsp));
+ ret = RFAILED;
+ }
+ }
+
+ /* Workaround : Freeing the dummy pointer */
+ MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, dummyPtr, sizeof(uint8_t));
+ return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief Rejects all statistics group requested by DU APP
+ *
+ * @details
+ *
+ * Function : MacRejectAllStats
+ *
+ * Functionality: Add all statistics group received in statistics
+ * request from DU APP, to Reject-Stats-Group-List in statistics
+ * response to DU APP
+ *
+ * @params[in] Statistics request from DU APP
+ * Cause of rejection
+ * @return ROK - success
+ * RFAILED - failure
+ *
+ * ****************************************************************/
+uint8_t MacRejectAllStats(MacStatsReq *macStatsReq, CauseOfResult cause)
+{
+ uint8_t grpIdx = 0;
+ MacStatsRsp macStatsRsp;
+
+ memset(&macStatsRsp, 0, sizeof(MacStatsRsp));
+
+ /* Copying all stats group from stats request to stats response */
+ macStatsRsp.subscriptionId = macStatsReq->subscriptionId;
+ for(grpIdx = 0; grpIdx < macStatsReq->numStatsGroup; grpIdx++)
+ {
+ macStatsRsp.statsGrpRejectedList[grpIdx].groupId = macStatsReq->statsGrpList[grpIdx].groupId;
+ macStatsRsp.statsGrpRejectedList[grpIdx].cause = cause;
+ }
+ macStatsRsp.numGrpRejected = macStatsReq->numStatsGroup;
+
+ return MacSendStatsRspToDuApp(&macStatsRsp);
+}
+