/*lint -e438 -e429*/ BST_UINT32 BST_SRV_CEvent::RcvTimerExpired ( BST_OS_TIMERID_T ulTimerId ) { BST_TIMER_EVT_STRU *pstSendTimerEvent; if( BST_NULL_PTR == m_pstEventMbx ) { return BST_ERR_INVALID_PTR; } pstSendTimerEvent = ( BST_TIMER_EVT_STRU *)BST_OS_MALLOC ( BST_OS_SIZEOF(BST_TIMER_EVT_STRU) ); BST_ASSERT_NULL_RTN( pstSendTimerEvent, BST_ERR_NO_MEMORY ); pstSendTimerEvent->pucData = ( BST_UINT8 *)BST_OS_MALLOC ( BST_OS_SIZEOF(ulTimerId) ); if ( BST_NULL_PTR == pstSendTimerEvent->pucData ) { BST_OS_FREE( pstSendTimerEvent ); return BST_ERR_NO_MEMORY; } pstSendTimerEvent->ulLength = BST_OS_SIZEOF( ulTimerId ); BST_OS_MEMCPY( pstSendTimerEvent->pucData, &ulTimerId, pstSendTimerEvent->ulLength ); pstSendTimerEvent->enId = BST_SRV_TIMER_EVENT; return BST_OS_SendMail( m_pstEventMbx, pstSendTimerEvent ); }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ConfigedPriodic( BST_UINT16 usLen, const BST_VOID *const pData, BST_UINT8 **pucNewAddr ) { BST_UINT32 ulTimerTicks; BST_ERR_ENUM_UINT8 ucRtnVal; if ( usLen < BST_OS_SIZEOF ( BST_UINT32 ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::ConfigedPriodic usLen=%u", usLen ); return BST_ERR_PAR_LEN; } BST_OS_MEMCPY( &ulTimerTicks, pData, BST_OS_SIZEOF(BST_UINT32) ); ucRtnVal = ConfigCycleTicks ( ulTimerTicks ); if ( ucRtnVal == BST_NO_ERROR_MSG ) { *pucNewAddr = ( BST_UINT8 * )&m_ulCycle; BST_SetConfigFlag ( BST_CFGFLG_CYCL ); } else { *pucNewAddr = BST_NULL_PTR; } return ucRtnVal; }
/*lint -e438 -e429*/ BST_ERR_ENUM_UINT8 BST_SRV_CEvent::RcvTcpIpEvent ( BST_IP_EVENT_STRU *pstEvent ) { BST_NET_EVENT_STRU *pstNetEvent; BST_IP_EVENT_STRU *pstLwipEvent; if ( BST_NULL_PTR == m_pstEventMbx ) { return BST_ERR_INVALID_PTR; } if ( BST_NULL_PTR == pstEvent ) { return BST_ERR_INVALID_PTR; } pstLwipEvent = ( BST_IP_EVENT_STRU *)BST_OS_MALLOC ( BST_OS_SIZEOF ( BST_IP_EVENT_STRU ) ); BST_ASSERT_NULL_RTN( pstLwipEvent, BST_ERR_NO_MEMORY ); pstNetEvent = ( BST_NET_EVENT_STRU *)BST_OS_MALLOC ( BST_OS_SIZEOF ( BST_NET_EVENT_STRU ) ); if ( BST_NULL_PTR == pstNetEvent ) { BST_OS_FREE( pstLwipEvent ); return BST_ERR_INVALID_PTR; } BST_OS_MEMCPY ( pstLwipEvent, pstEvent, BST_OS_SIZEOF ( BST_IP_EVENT_STRU ) ); pstNetEvent->enId = BST_SRV_TCPIP_EVENT; pstNetEvent->pucData = ( BST_UINT8 * )pstLwipEvent; pstNetEvent->ulLength = BST_OS_SIZEOF ( BST_IP_EVENT_STRU ); return BST_OS_SendMail( m_pstEventMbx, pstNetEvent ); }
BST_IP_ERR_T BST_IP_BsdTcpClone( BST_FD_T fd, BST_IP_SOCKET_ADD_T *pAddr ) { struct sockaddr_in stRemoteAddr; if( !BST_IP_IsBsdFdValid(fd) ) { return BST_IP_ERR_MEM; } if( BST_NULL_PTR == pAddr ) { return BST_IP_ERR_MEM; } stRemoteAddr.sin_len = BST_OS_SIZEOF(stRemoteAddr); stRemoteAddr.sin_family = AF_INET; stRemoteAddr.sin_port = pAddr->usRemotePort; BST_IP_GetU32Addr( stRemoteAddr.sin_addr.s_addr, pAddr->aucRemoteIp[3], pAddr->aucRemoteIp[2], pAddr->aucRemoteIp[1], pAddr->aucRemoteIp[0] ); return (BST_IP_ERR_T)lwip_cloneconnect( fd.lFd, (struct sockaddr*)&stRemoteAddr, BST_OS_SIZEOF(stRemoteAddr) ); }
BST_CORE_CNPTask::BST_CORE_CNPTask( BST_PROCID_T in_usProcId, BST_TASKID_T in_usTaskId ) :BST_CORE_CPTask ( in_usProcId, in_usTaskId ) { BST_CORE_CRegedit *pcRegedit; BST_APP_CMainTask *pcMainTask; pcRegedit = BST_CORE_CRegedit::GetInstance(); pcMainTask = BST_APP_CMainTask::GetInstance(); BST_ASSERT_NULL( pcRegedit ); m_CfgedFlag = BST_CFGFLG_NONE; m_pExptReport = new BST_DSPP_CReport ( in_usProcId, in_usTaskId ); #if( BST_VER_TYPE == BST_DBG_VER ) m_pSocket = new BST_IP_CSocket ( in_usProcId, in_usTaskId ); #else m_pSocket = new BST_IP_CSocket(); #endif m_ProtolType = BST_PRTC_TYPE_INVALID; pcRegedit->Regist ( this, this, BST_PID_PERIODIC, BST_OS_SIZEOF ( BST_TICK_T ), BST_NULL_PTR); pcRegedit->Regist ( this, this, BST_PID_PROTOCOL_TYPE, BST_OS_SIZEOF ( BST_SCKT_TYPE_ENUM_UINT32 ), BST_NULL_PTR ); pcRegedit->Regist ( this, this, BST_PID_SOCKET_INFO, BST_OS_SIZEOF ( BST_IP_SOCKET_ADD_T ), BST_NULL_PTR ); pcRegedit->Regist ( this, this, BST_PID_SOCKET_PROPERTY, BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU), BST_NULL_PTR ) ; pcRegedit->Regist ( this, this, BST_PID_TRAFFIC_FLOW, BST_OS_SIZEOF ( BST_IP_TRAFFIC_FLOW_STRU), BST_NULL_PTR );/*注册EMAIL流量查询*/ if ( BST_NULL_PTR != pcMainTask ) { pcMainTask->Attach( this ); } }
BST_UINT16 BST_CORE_CNPTask::InquiredSocketProperty( BST_UINT16 usDataSize, BST_VOID *const pData ) { BST_IP_ERR_T enIpErr; BST_DBG_LOG ( " BST_CORE_CNPTask::InquiredSocketProperty Enter."); if ( usDataSize < BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU ) ) { BST_RLS_LOG1 ( "BST_CORE_CNPTask::InquiredSocketProperty usDataSize=%d", usDataSize ); return BST_CORE_INVALID_INQUIRED_LEN; } Stop(); enIpErr = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_PROPERTY, pData ); BST_ResetPrptyFlag(); ( BST_VOID )PidInquired ( BST_PID_SOCKET_PROPERTY, usDataSize, pData ); if ( BST_IP_ERR_OK == enIpErr ) { return ( BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU ) ); } else { return BST_CORE_INVALID_INQUIRED_LEN; } }
BST_VOID BST_SYS_MntnTrigReport( BST_VOID ) { OM_BST_MSG_STRU *pstBstOmIndMsg; OM_BST_AGENT_APP_NUM_STRU *pstBstAppNum; BST_UINT32 ulRslt; BST_UINT32 ulLength; BST_UINT16 usAppNum; OM_BST_APP_INFO_STRU *pstAppInfo; ulRslt = BST_TRUE; /* 申请的大小等于消息头BST_OM_MSG_STRU -4个字节的指针占位 + 实际代理信息大小 */ usAppNum = (BST_UINT16)BST_SYS_MNTN_GetAppNumber(); ulLength = (BST_OS_SIZEOF(OM_BST_MSG_STRU) - 4) + (BST_OS_SIZEOF(OM_BST_AGENT_APP_NUM_STRU)); pstBstOmIndMsg = (OM_BST_MSG_STRU *)BST_SYS_MntnGetSendExternalMsgBuffAddr(UEPS_PID_BASTET, ulLength); if (BST_NULL_PTR == pstBstOmIndMsg) { BST_DBG_LOG1("BST_SYS_MntnTrigReport, Agent Info Msg Alloc Mem Fail", 0); return; } /* 填写消息头 */ BST_SYS_MntnFillBstOmMsgHead( pstBstOmIndMsg, ulLength, ID_BST_OM_AGENT_INFO_IND, 0 ); pstBstAppNum = (OM_BST_AGENT_APP_NUM_STRU *)(pstBstOmIndMsg->aucData); pstBstAppNum->usAgentAppNum = usAppNum; pstAppInfo = ( (OM_BST_APP_INFO_STRU *)(pstBstAppNum->stBstAppList ) ); ulRslt = BST_SYS_MntnBuildAgentInfoInd( pstAppInfo, usAppNum ); if (BST_TRUE != ulRslt) { BST_DBG_LOG1("BST_SYS_MntnTrigReport, Get Bst Agent Info Error: ulRslt", ulRslt); return; } /* 发送IND消息 */ ulRslt = OM_SendData( (OM_RSP_PACKET_STRU *)pstBstOmIndMsg, (BST_UINT16)ulLength ); /* 释放传入的消息包 */ BST_FREE_MSG( UEPS_PID_BASTET, pstBstOmIndMsg ); if (VOS_OK != ulRslt) { BST_RLS_LOG1( "[Mntn] Send Maintain Message Fail:", ulRslt ); return; } BST_RLS_LOG( "[Mntn] Send Maintain Message Success" ); return; }
BST_VOID BST_CTaskSchdler::AsEventCallback( BST_AS_EVT_ENUM_UINT32 enEvent, BST_UINT32 ulLength, BST_VOID *pvData ) { BST_UINT32 ulPara; switch( enEvent ) { /* * 仅处理RRC状态信息,当RRC连接成功时,查看当前剩余时间是否靠近 */ case BST_AS_EVT_L3_RRC_STATE: if ( BST_OS_SIZEOF(ulPara) != ulLength ) { break; } if ( BST_NULL_PTR == pvData ) { break; } BST_OS_MEMCPY( &ulPara, pvData, ulLength ); if( BST_AS_RRC_CONNECTED == ulPara ) { ulPara = BST_OS_TimerIsStop( m_ulTimerId ); if ( BST_TRUE == ulPara ) { break; } ulPara = BST_OS_TimeGetRemain( m_ulTimerId ); if ( 0 == ulPara ) { break; } ulPara = NearRrcTrig ( ulPara ); BST_OS_TimerStart( m_ulTimerId, ulPara ); } break; case BST_AS_EVT_L3_BLOCK_INFO: if ( BST_OS_SIZEOF(BST_UINT32) != ulLength ) { BST_RLS_LOG1("BST_CTaskSchdler::AsEventCallback Error blockinfo Length = %u:", ulLength ); break; } UtranBlockInfoChgProc( (BST_UINT32 *)pvData ); break; default: break; } }
BST_UINT32 BST_PAL_NetApiPacketRcved( const BST_UINT8 *pData, const BST_UINT32 ulLen ) { BST_OS_LOCKCNT_T tThreadLockCnt; BST_PAL_NET_ENTITY_STRU *pstBstNetEntity; pstBstNetEntity = BST_PAL_NetGetEntity(); /*入参判断*/ if ( ulLen != BST_OS_SIZEOF(TTF_MEM_ST) ) { BST_RLS_LOG( "BST_EnQueueOtaData: Wrong Size" ); return 0; } if ( BST_NULL_PTR == pData ) { BST_RLS_LOG( "BST_EnQueueOtaData: NULL pData" ); return 0; } /*入队*/ tThreadLockCnt = BST_OS_ThreadLock(); if ( PS_SUCC != LUP_EnQue( pstBstNetEntity->pstDlDataQue, (BST_VOID *)pData ) ) { BST_PAL_NetApiPacketFree( (BST_VOID *)pData ); BST_OS_ThreadUnLock( tThreadLockCnt ); BST_RLS_LOG( "BST_EnQueueOtaData: EnQueue Fail" ); return 0; } BST_OS_ThreadUnLock( tThreadLockCnt ); /*wakeup cds*/ BST_SYS_ApiSndEvtToBastet( BST_CDS_EVENT_RCV_DL_PROC ); return ulLen; }
/*lint -e438 -e429*/ BST_ERR_ENUM_UINT8 BST_SRV_CEvent::RcvAcomData( BST_UINT32 ulLength, BST_UINT8 *pucData ) { BST_ACOM_EVT_STRU *pstAcpuEvent; if( BST_NULL_PTR == m_pstEventMbx ) { return BST_ERR_INVALID_PTR; } if( BST_NULL_PTR == pucData ) { return BST_ERR_INVALID_PTR; } if( 0 == ulLength ) { return BST_ERR_PAR_LEN; } pstAcpuEvent = (BST_ACOM_EVT_STRU *)BST_OS_MALLOC( BST_OS_SIZEOF(BST_ACOM_EVT_STRU) ); BST_ASSERT_NULL_RTN( pstAcpuEvent, BST_ERR_NO_MEMORY ); pstAcpuEvent->pucData = (BST_UINT8 *)BST_OS_MALLOC( ulLength ); if ( BST_NULL_PTR == pstAcpuEvent->pucData ) { BST_OS_FREE( pstAcpuEvent ); return BST_ERR_NO_MEMORY; } pstAcpuEvent->enId = BST_SRV_ACOM_EVENT; pstAcpuEvent->ulLength = ulLength; BST_OS_MEMCPY( pstAcpuEvent->pucData, pucData, ulLength ); return BST_OS_SendMail( m_pstEventMbx, pstAcpuEvent ); }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ReportTrafficFlow( BST_VOID ) { BST_ERR_ENUM_UINT8 enRtnVal; BST_IP_ERR_T enIpErr; BST_IP_TRAFFIC_FLOW_STRU stSktTrFlow; enRtnVal = BST_ERR_UNREACHABLE; stSktTrFlow.ulRxByte = 0; stSktTrFlow.ulTxByte = 0; enIpErr = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_TRAFFIC_FLOW, &stSktTrFlow ); if ( BST_IP_ERR_OK == enIpErr ) { if( ( 0 != stSktTrFlow.ulRxByte ) || ( 0 != stSktTrFlow.ulTxByte ) ) { enRtnVal = m_pExptReport->Report ( BST_PID_TRAFFIC_FLOW, BST_OS_SIZEOF ( BST_IP_TRAFFIC_FLOW_STRU ), &stSktTrFlow ); } if ( BST_NO_ERROR_MSG == enRtnVal ) { return enRtnVal; } } BST_RLS_LOG2( "BST_CORE_CNPTask::Report Traffic Flow, Ip_Err =%u, Rpt_Err=%u",\ enIpErr, enRtnVal ); return BST_ERR_UNREACHABLE; }
BST_IP_ERR_T BST_IP_BsdSocket( BST_FD_T *pfd, BST_ARG_T *Arg, BST_UINT16 usProtocol ) { BST_UINT32 ulTimeout; ulTimeout = BST_IP_RX_TIME_OUT; if( BST_NULL_PTR == pfd ) { return BST_IP_ERR_ARG; } switch( usProtocol ) { case BST_IP_PROTOCOL_UDP: pfd->lFd = lwip_socket( AF_INET, SOCK_DGRAM, 0 ); break; case BST_IP_PROTOCOL_TCP: pfd->lFd = lwip_socket( AF_INET, SOCK_STREAM, 0 ); //TCP对应SOCK_STREAM break; default : pfd->lFd = BST_IP_ERR_MEM; return BST_IP_ERR_ARG; } if( BST_IP_IsBsdFdValid( (*pfd) ) ) { if ( 0 == lwip_setsockopt( pfd->lFd, SOL_SOCKET, SO_RCVTIMEO, &ulTimeout, BST_OS_SIZEOF( ulTimeout ) ) ) { return BST_IP_ERR_OK; } return BST_IP_ERR_VAL; } else { return BST_IP_ERR_MEM; } }
BST_OS_SEM_STRU *BST_OS_CreateSem( BST_VOID *pvArg, BST_UINT32 ulInitCnt ) { BST_OS_SEM_STRU *pstOsSem; BST_OS_LOCKCNT_T tThreadLockCnt; pstOsSem = (BST_OS_SEM_STRU *)BST_OS_MALLOC( BST_OS_SIZEOF( BST_OS_SEM_STRU ) ); if( BST_NULL_PTR == pstOsSem ) { return BST_NULL_PTR; } tThreadLockCnt = BST_OS_ThreadLock(); pstOsSem->pvArg = BST_OS_GetCurrentThreadId(); pstOsSem->stHandle = BST_OS_PalCreateSem( ulInitCnt ); if ( BST_OS_SYS_IsSemValid(pstOsSem->stHandle) ) { BST_OS_FREE( pstOsSem ); BST_OS_ThreadUnLock( tThreadLockCnt ); /*lint -e438*/ return BST_NULL_PTR; /*lint +e438*/ } #ifdef BST_OS_SIGNAL_COUNTER pstOsSem->ulCounter = ulInitCnt; if ( 0U != pstOsSem->ulCounter ) { BST_OS_PalSendSem( pstOsSem->stHandle, pstOsSem->pvArg ); } #endif BST_OS_ThreadUnLock( tThreadLockCnt ); return pstOsSem; }
BST_IP_ERR_T BST_IP_BsdBind( BST_FD_T fd, BST_UINT16 usPort ) { struct sockaddr_in stLocalAddr; if( !BST_IP_IsBsdFdValid(fd) ) { return BST_IP_ERR_MEM; } stLocalAddr.sin_len = BST_OS_SIZEOF(stLocalAddr); stLocalAddr.sin_family = AF_INET; stLocalAddr.sin_port = PP_HTONS( usPort ); stLocalAddr.sin_addr.s_addr = BST_IP_ADDRESS_ANY; return (BST_IP_ERR_T)lwip_bind( fd.lFd, ( struct sockaddr *)&stLocalAddr, BST_OS_SIZEOF(stLocalAddr) ); }
BST_VOID BST_PAL_NetMsgEntry( MsgBlock *pstMsg ) { BST_UINT32 ulTrsFlg; if ( BST_NULL_PTR == pstMsg ) { BST_RLS_LOG( "BST_PAL_NetMsgEntry : Input NULL PTR." ); return; } BST_RLS_LOG1( "BST_PAL_NetMsgEntry : MsgId", TTF_GET_MSG_NAME(pstMsg) ); switch( TTF_GET_MSG_NAME(pstMsg) ) { /* CDS发给BASTET的消息原语: 有其他IP包在运行中 */ case ID_BST_CDS_TX_RX_IND: ulTrsFlg = BST_TRUE; BST_PalAsEventRcvCb( BST_AS_EVT_L3_AP_TRS_RCV_IND, ( BST_UINT16 )BST_OS_SIZEOF(ulTrsFlg), &ulTrsFlg ); break; /* CDS发给BASTET的消息原语: 当前MODEM数据业务使用的MODEM ID*/ case ID_BST_CDS_CHANNEL_INFO_IND: BST_PAL_NetMsgCfgCallBack( (const BST_CDS_SEND_CB_INFO_STRU *)pstMsg ); break; default: BST_RLS_LOG( "BST_PAL_NetMsgEntry : Unknown Message." ); break; } return; }
BST_VOID BST_SYS_MntnAddTask( BST_UINT16 usType, BST_UINT16 usTaskId ) { BST_SYS_MNTN_APP_NODE_STRU *pstAppInfoNode; BST_OS_LOCKCNT_T tThreadLockCnt; if ( !BST_SYS_MNTN_IsMntnInited() ) { return; } if ( (BST_UINT32)BST_SYS_MNTN_GetAppNumber() >= BST_SYS_MNTN_MAX_APP_NUMBER ) { return; } tThreadLockCnt = BST_OS_ThreadLock(); if ( BST_NULL_PTR != BST_SYS_MntnSrchAppByTask( usType, usTaskId ) ) { BST_OS_ThreadUnLock( tThreadLockCnt ); return; } pstAppInfoNode = ( BST_SYS_MNTN_APP_NODE_STRU *)BST_OS_MALLOC ( BST_OS_SIZEOF(BST_SYS_MNTN_APP_NODE_STRU) ); if ( BST_NULL_PTR == pstAppInfoNode ) { BST_OS_ThreadUnLock( tThreadLockCnt ); return; } BST_OS_MEMSET( &(pstAppInfoNode->stAppInfo), 0, BST_OS_SIZEOF(OM_BST_APP_INFO_STRU) ); pstAppInfoNode->stAppInfo.usAppType = usType; pstAppInfoNode->stAppInfo.usTaskId = usTaskId; lstAdd( BST_SYS_MNTN_GetAppListHead(), (NODE *)pstAppInfoNode ); BST_RLS_LOG3( "[Mntn] Add Task: TypeId=, TaskId=, Total=", usType, usTaskId, BST_SYS_MNTN_GetAppNumber() ); BST_SYS_MntnChangedInd(); BST_OS_ThreadUnLock( tThreadLockCnt ); /*lint -e429*/ }
BST_INT32 RAND_poll( BST_VOID ) { BST_UINT32 ulRnd; BST_UINT32 i; ulRnd = 0; BST_UINT8 ucBuf[ENTROPY_NEEDED]; for ( i = 0; i < BST_OS_SIZEOF(ucBuf); i++ ) { if ( 0 == (i % 4) ) { ulRnd = VOS_Rand(0xff);/*此处调用rtos平台的随机数生成函数*/ } ucBuf[i] = ulRnd; ulRnd >>= 8; } RAND_add( ucBuf, BST_OS_SIZEOF(ucBuf), (double)ENTROPY_NEEDED ); BST_OS_MEMSET( ucBuf, 0, BST_OS_SIZEOF(ucBuf) ); return 1; }
VOS_VOID BST_SYS_MsgProcEntry( MsgBlock *pstMsg ) { if(BST_FALSE == BST_SYS_ApiGetSupported()) { BST_DBG_LOG("BST_SYS_MsgProcEntry: bastet nv disabled"); return; } switch(pstMsg->ulSenderPid) { case WUEPS_PID_USIM: break; case VOS_PID_TIMER: BST_DBG_LOG("BST_SYS_MsgProcEntry: VOS_PID_TIMER"); BST_OS_PalTimerCallBack(); break; case ACPU_PID_BASTET_COMM: BST_DBG_LOG("BST_SYS_MsgProcEntry: ACPU_PID_BASTET_COMM"); BST_Pal_DrvAcomRecv( ( BST_UINT32 ) BST_OS_SIZEOF( BST_ACOM_MSG_STRU ), ( BST_UINT8 *) pstMsg ); break; case UEPS_PID_CDS: BST_DBG_LOG("BST_SYS_MsgProcEntry: UEPS_PID_CDS"); OM_TraceMsgHook(pstMsg); BST_PAL_NetMsgEntry( pstMsg ); break; case I0_WUEPS_PID_MMA: OM_TraceMsgHook(pstMsg); BST_MSG_ProcMmaRecv(pstMsg,BST_MODEM_ID_1); break; case I1_WUEPS_PID_MMA: OM_TraceMsgHook(pstMsg); BST_MSG_ProcMmaRecv(pstMsg,BST_MODEM_ID_2); break; case WUEPS_PID_WRR: OM_TraceMsgHook(pstMsg); BST_MSG_ProcWrrcRecv(pstMsg); break; case TPS_PID_RRC: OM_TraceMsgHook(pstMsg); BST_MSG_ProcTrrcRecv(pstMsg); break; case PS_PID_ERRC: OM_TraceMsgHook(pstMsg); BST_MSG_ProcLrrcRecv(pstMsg); break; default: break; } }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ConfigedSockeInfo( BST_UINT16 usLen, const BST_VOID *const pData, BST_UINT8 **pucNewAddr ) { BST_IP_ERR_T enIpErrMsg; BST_ERR_ENUM_UINT8 ucRtnVal; if ( usLen < BST_OS_SIZEOF ( BST_IP_SOCKET_ADD_T ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::ConfigedPriodic usLen=%u", usLen ); return BST_ERR_PAR_LEN; } if ( !BST_IP_IsValidIpAddress( ( BST_IP_SOCKET_ADD_T * )pData ) ) { Report( BST_TRAFFIC_FLOW_REPORT ); } enIpErrMsg = m_pSocket->IoCtrl ( BST_SCKT_CMD_SET_ADDRESS, ( BST_VOID *)pData ); BST_DBG_UPDATE_IP_INFO( m_usProcId, m_usTaskId, (( BST_IP_SOCKET_ADD_T * )pData) ); if ( BST_IP_ERR_OK == enIpErrMsg ) { enIpErrMsg = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_ADDRPTR, ( BST_VOID *)pucNewAddr ); if ( BST_IP_ERR_OK == enIpErrMsg ) { if ( BST_IP_IsValidIpAddress( ( BST_IP_SOCKET_ADD_T * )( *pucNewAddr ) ) ) { BST_SetConfigFlag ( BST_CFGFLG_ADDR ); } else { /* 清除Config, 防止Socket进行Clone,并挂起任务 */ BST_UnsetConfigFlag ( BST_CFGFLG_ADDR ); Suspend(); } ucRtnVal = BST_NO_ERROR_MSG; } else { BST_UnsetConfigFlag ( BST_CFGFLG_ADDR ); ucRtnVal = BST_ERR_ILLEGAL_PARAM; } } else { ucRtnVal = BST_ERR_ILLEGAL_PARAM; } return ucRtnVal; }
inline BST_BOOL CheckIfEcryOrDecry ( BST_CORE_PID_ENUM_UINT16 enPid ) { BST_UINT32 i; for ( i = 0; i < BST_OS_SIZEOF ( g_enEncrypterParamTable ); i++ ) { if ( enPid == g_enEncrypterParamTable[i] ) { return BST_TRUE; } } return BST_FALSE; }
/*lint -e429*/ BST_VOID BST_CTaskSchdler::Attach ( BST_CORE_CPTask *pC_PTask ) { BST_CORE_PTASK_NODE_STRU *pstPtaskNode; if ( !BST_OS_IsTimerValid (m_ulTimerId) ) { BST_RLS_LOG1( "BST_CTaskSchdler::Attach m_ulTimerId=%u is invalid", m_ulTimerId ); return; } if ( BST_NULL_PTR == pC_PTask ) { BST_RLS_LOG( "BST_CTaskSchdler::Attach pC_PTask=NULL" ); return; } for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList ); pstPtaskNode!= BST_NULL_PTR; pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) ) { if( pstPtaskNode->pcTask == pC_PTask ) { return; } } /* * 申请链表节点资源,用于存储任务 */ pstPtaskNode = ( BST_CORE_PTASK_NODE_STRU *)BST_OS_MALLOC ( BST_OS_SIZEOF( BST_CORE_PTASK_NODE_STRU ) ); if( BST_NULL_PTR == pstPtaskNode ) { BST_RLS_LOG( "BST_CTaskSchdler::Attach pstPtaskNode=NULL" ); return; } /* * 初始化任务数据,添加如任务列表 */ pC_PTask->m_ulSuspCounter = 0; pstPtaskNode->pcTask = pC_PTask; lstAdd( &g_stPTaskList, (NODE *)pstPtaskNode ); /* * 如果此时系统TICK定时已经关闭,且PS域服务状态正常,那么需要再次启动定时 */ if( BST_TRUE == BST_OS_TimerIsStop( m_ulTimerId ) ) { m_ulSystemTick = 0; BST_OS_TimerStart ( m_ulTimerId, BST_TASK_SYS_BASE_TIMELEN ); BST_DBG_LOG1( "BST_CTaskSchdler::Attach Start Scheduler Timer:%u", BST_TASK_SYS_BASE_TIMELEN ); } }
BST_UINT32 BST_PAL_NetApiPacketPppRcvd( BST_UINT32 ulLength, BST_UINT8 *pucData ) { if( BST_NULL_PTR == pucData ) { return 0x00U; } if( BST_OS_SIZEOF( TTF_MEM_ST )!= ulLength ) { return 0x00U; } BST_PAL_NetApiPacketFree( pucData ); return ulLength; }
BST_UINT16 BST_CORE_CNPTask::InquiredTrafficFlow( BST_UINT16 usDataSize, BST_VOID *const pData ) { BST_IP_ERR_T enIpErr; BST_DBG_LOG( "BST_CORE_CNPTask::InquiredTrafficFlow email traffic flow info"); if ( usDataSize < BST_OS_SIZEOF ( BST_IP_TRAFFIC_FLOW_STRU ) ) { BST_RLS_LOG1( "BST_CORE_CNPTask::InquiredTrafficFlow usDataSize=%u", usDataSize ); return BST_CORE_INVALID_INQUIRED_LEN; } enIpErr = m_pSocket->IoCtrl ( BST_SCKT_CMD_GET_TRAFFIC_FLOW, pData ); ( BST_VOID )PidInquired ( BST_PID_TRAFFIC_FLOW, usDataSize, pData ); if ( BST_IP_ERR_OK == enIpErr ) { return ( BST_OS_SIZEOF ( BST_IP_TRAFFIC_FLOW_STRU ) ); } else { return BST_CORE_INVALID_INQUIRED_LEN; } }
BST_UINT32 BST_SRV_RcvTimerEvent( BST_OS_TIMERID_T ulTimerId ) { BST_SRV_CEvent *pEvtProc; BST_UINT32 ulRtnVal; pEvtProc = BST_SRV_CEvent::GetInstance(); BST_ASSERT_NULL_RTN( pEvtProc, 0 ); ulRtnVal = pEvtProc->RcvTimerExpired( ulTimerId ); if( BST_NO_ERROR_MSG == ulRtnVal ) { return BST_OS_SIZEOF(BST_OS_TIMER_STRU); } BST_RLS_LOG1( "BST_SRV_RcvTimerEvent pEvtProc->RcvTimerExpired Err=%u", ulRtnVal ); return 0; }
//lint -sem(lstAdd,custodial(2)) BST_ERR_ENUM_UINT8 BST_OS_SendMail( BST_OS_MBX_T *pstMbx, BST_VOID *pMsg ) { BST_OS_MAIL_T *pstContent; BST_OS_LOCKCNT_T tThreadLockCnt; BST_ASSERT_NULL_RTN( pstMbx, BST_ERR_INVALID_PTR ); BST_ASSERT_NULL_RTN( pstMbx->hSem, BST_ERR_INVALID_PTR ); pstContent = BST_OS_MALLOC( BST_OS_SIZEOF(BST_OS_MAIL_T) ); BST_ASSERT_NULL_RTN( pstContent, BST_ERR_NO_MEMORY ); tThreadLockCnt = (BST_OS_LOCKCNT_T)BST_OS_SpinLock( &g_MboxLock ); pstContent->ulContent = pMsg; lstAdd( &pstMbx->hList, ( NODE * )pstContent ); BST_OS_SpinUnLock( &g_MboxLock,(BST_UINT32)tThreadLockCnt ); BST_OS_SendSem( pstMbx->hSem ); return( BST_NO_ERROR_MSG ); }
/*lint -e438 -e429*/ BST_ERR_ENUM_UINT8 BST_SRV_CEvent::RcvAsEvent( BST_AS_EVT_ENUM_UINT32 enAsEvent, BST_UINT32 ulLength, BST_VOID *pvData ) { BST_AS_EVT_STRU *pstSendAsEvent; if( BST_NULL_PTR == m_pstEventMbx ) { return BST_ERR_INVALID_PTR; } if( !BST_SRV_IsValidAsEvent( enAsEvent ) ) { return BST_ERR_INVALID_PTR; } pstSendAsEvent = (BST_AS_EVT_STRU *)BST_OS_MALLOC( BST_OS_SIZEOF(BST_AS_EVT_STRU) ); BST_ASSERT_NULL_RTN( pstSendAsEvent, BST_ERR_NO_MEMORY ); if( ( BST_NULL_PTR == pvData ) || ( 0 == ulLength ) ) { pstSendAsEvent->pucData = BST_NULL_PTR; pstSendAsEvent->ulLength = 0; } else { pstSendAsEvent->pucData = (BST_UINT8 *)BST_OS_MALLOC( ulLength ); if ( BST_NULL_PTR == pstSendAsEvent->pucData ) { BST_RLS_LOG( "BST_SRV_CEvent::RcvAsEvent No Memory" ); BST_OS_FREE( pstSendAsEvent ); return BST_ERR_NO_MEMORY; } pstSendAsEvent->ulLength = ulLength; BST_OS_MEMCPY( pstSendAsEvent->pucData, pvData, ulLength ); } pstSendAsEvent->enId = BST_SRV_AS_EVENT; pstSendAsEvent->enAsEvent = enAsEvent; return BST_OS_SendMail( m_pstEventMbx, pstSendAsEvent ); }
BST_OS_MBX_T *BST_OS_CreateMbx( BST_VOID *pvArg, BST_UINT32 ulSize ) { BST_OS_MBX_T *pstMbx; pstMbx = BST_OS_MALLOC( BST_OS_SIZEOF(BST_OS_MBX_T) ); BST_ASSERT_NULL_RTN( pstMbx, BST_NULL_PTR ); pstMbx->hSem = BST_NULL_PTR; lstInit( &pstMbx->hList ); pstMbx->hSem = BST_OS_CreateSem( pvArg, 0U ); if( BST_NULL_PTR == pstMbx->hSem ) { BST_DBG_LOG("Create Mail Box Fail.\n"); lstFree( &pstMbx->hList ); BST_OS_FREE(pstMbx); /*lint -e438*/ return BST_NULL_PTR; /*lint +e438*/ } return( pstMbx ); }
BST_ERR_ENUM_UINT8 BST_CORE_CNPTask::ReportNoneHb( BST_VOID ) { BST_ERR_ENUM_UINT8 enRtnVal; BST_IP_ERR_T enIpErr; BST_IP_SKT_PROPTY_STRU stSktProperty; enRtnVal = BST_ERR_UNREACHABLE; enIpErr = m_pSocket->IoCtrl ( BST_SCKT_CMD_RPT_PROPERTY, &stSktProperty ); if ( BST_IP_ERR_OK == enIpErr ) { enRtnVal = m_pExptReport->Report ( BST_PID_SOCKET_PROPERTY, BST_OS_SIZEOF ( BST_IP_SKT_PROPTY_STRU ), &stSktProperty ); if ( BST_NO_ERROR_MSG == enRtnVal ) { return enRtnVal; } } BST_RLS_LOG2( "BST_CORE_CNPTask::Report Get Propery Error, Ip_Err =%u, Rpt_Err=%u",\ enIpErr, enRtnVal ); return BST_ERR_UNREACHABLE; }
BST_ERR_ENUM_UINT8 BST_PAL_NetApiPacketResume( BST_VOID *pstItem ) { BST_PAL_NET_ENTITY_STRU *pstBstNetEntity; pstBstNetEntity = BST_PAL_NetGetEntity(); if ( BST_NULL_PTR == pstItem ) { BST_RLS_LOG( "BST_PAL_NetApiPacketResume : Mst Pointer Is Null ." ); return BST_ERR_INVALID_PTR; } if ( BST_NULL_PTR == pstBstNetEntity->pfRsmItf ) { BST_RLS_LOG( "BST_PAL_NetApiPacketResume : pfRsmItf Pointer Is Null ." ); return BST_ERR_INVALID_PTR; } if( 0 == pstBstNetEntity->pfRsmItf( (BST_UINT8 *)pstItem, (BST_UINT16)BST_OS_SIZEOF (TTF_MEM_ST ) ) ) { BST_PAL_NetApiPacketFree( pstItem ); return BST_ERR_ILLEGAL_PARAM; } return BST_NO_ERROR_MSG; }
BST_UINT32 BST_SYS_MntnBuildAgentInfoInd( OM_BST_APP_INFO_STRU *pstAgentInfo, const BST_UINT16 usAppNumber ) { BST_SYS_MNTN_APP_NODE_STRU *pstAppNode; BST_UINT16 usAppCounter; BST_OS_LOCKCNT_T tThreadLockCnt; if ( BST_NULL_PTR == pstAgentInfo ) { return BST_FALSE; } tThreadLockCnt = BST_OS_ThreadLock(); usAppCounter = 0; /* 查找链表中是否已经存在该Task信息 */ for ( pstAppNode = ( BST_SYS_MNTN_APP_NODE_STRU *)lstFirst(BST_SYS_MNTN_GetAppListHead()); pstAppNode != BST_NULL_PTR; pstAppNode = ( BST_SYS_MNTN_APP_NODE_STRU *)lstNext( (NODE *)pstAppNode ) ) { if ( ID_BST_OM_TASK_TYPE_MAIN == pstAppNode->stAppInfo.usAppType ) { continue; } BST_OS_MEMCPY( &pstAgentInfo[usAppCounter], &(pstAppNode->stAppInfo), BST_OS_SIZEOF(OM_BST_APP_INFO_STRU) ); usAppCounter++; if ( usAppCounter >= usAppNumber ) { break; } } BST_OS_ThreadUnLock( tThreadLockCnt ); return BST_TRUE; }