VOS_VOID CDS_SaveIpfDlSrcMem(const IPF_CONFIG_DLPARAM_S *pstIpfDlBdBuff, VOS_UINT32 ulSaveNum) { LUP_QUEUE_STRU *pstDlFreeQue; VOS_UINT32 ulCnt; TTF_MEM_ST *pstSrcMem; CDS_ASSERT(VOS_NULL_PTR != pstIpfDlBdBuff); if (ulSaveNum > IPF_DLBD_DESC_SIZE) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_SaveIpfDlMemInfo:Input Bd Num Error.",ulSaveNum); return ; } pstDlFreeQue = CDS_IPF_DL_SRCMEM_FREE_QUE(); CDS_ASSERT(VOS_NULL_PTR != pstDlFreeQue); for (ulCnt = 0; ulCnt < ulSaveNum; ulCnt ++) { pstSrcMem = (TTF_MEM_ST*)pstIpfDlBdBuff[ulCnt].u32Data; if (PS_SUCC != LUP_EnQue(pstDlFreeQue,pstSrcMem)) { CDS_ERROR_LOG2(UEPS_PID_CDS,"CDS_SaveIpfDlMemInfo: Src Mem Leak.",ulCnt,ulSaveNum); vos_printf("CDS_SaveIpfDlMemInfo: Buffer Full!! cnt=%d,ulSaveNum=%d\n",ulCnt,ulSaveNum); TTF_MemFree(UEPS_PID_CDS,pstSrcMem); CDS_DBG_DL_IPF_SAVE_SRCMEM_FAIL_NUM(1); continue; } CDS_DBG_DL_IPF_SAVE_SRCMEM_SUCC_NUM(1); } return ; }
VOS_VOID CDS_DecodeIpv6Pkt(const TTF_MEM_ST *pstIpPkt, CDS_IPV6_FRAGMENT_INFO_STRU *pstIpv6FragInfo) { IPV6_HDR_STRU *pstIpv6Hdr; VOS_UINT8 ucNextHdr; VOS_UINT8 *pstExtHdr; IPV6_FRAGMENT_HDR *pstFragHdr; IPV6_OPTION_HDR *pstOptHdr; VOS_UINT32 ulOptLen; CDS_ASSERT(VOS_NULL_PTR != pstIpPkt); CDS_ASSERT(VOS_NULL_PTR != pstIpv6FragInfo); pstIpv6Hdr = (IPV6_HDR_STRU *)((VOS_UINT32)(pstIpPkt->pData)); PS_MEM_CPY(&(pstIpv6FragInfo->unSrcAddr),&(pstIpv6Hdr->unSrcAddr),IPV6_ADDR_LEN); PS_MEM_CPY(&(pstIpv6FragInfo->unDstAddr),&(pstIpv6Hdr->unDstAddr),IPV6_ADDR_LEN); ucNextHdr = pstIpv6Hdr->ucNextHdr; pstExtHdr = pstIpPkt->pData + sizeof(IPV6_HDR_STRU); while (CDS_Ipv6ExtHdr(ucNextHdr)) { pstOptHdr = (IPV6_OPTION_HDR*)((VOS_UINT32)pstExtHdr); if ((IPV6_NEXTHDR_NONE == ucNextHdr) || (IPV6_NEXTHDR_ESP == ucNextHdr)) { return; } if (IPV6_NEXTHDR_FRAGMENT == ucNextHdr) { pstFragHdr = (IPV6_FRAGMENT_HDR *)((VOS_UINT32)pstExtHdr); pstIpv6FragInfo->ulIdentity = pstFragHdr->ulIdentification; return; } if (IPV6_NEXTHDR_AUTH == ucNextHdr) { ulOptLen = (pstOptHdr->ucHdrLen + 2) << 2; } else { ulOptLen = IPV6_OPTION_LEN(pstOptHdr); } ucNextHdr = pstOptHdr->ucNextHdr; pstExtHdr = pstExtHdr + ulOptLen; } return; }
VOS_VOID CDS_DecodeIpv4Pkt( const TTF_MEM_ST *pstIpPkt, CDS_IPV4_FRAGMENT_INFO_STRU *pstIpv4FragInfo) { IPV4_HDR_STRU *pstIpHdr; CDS_ASSERT(VOS_NULL_PTR != pstIpPkt); CDS_ASSERT(VOS_NULL_PTR != pstIpv4FragInfo); pstIpHdr = (IPV4_HDR_STRU *)((VOS_UINT32)(pstIpPkt->pData)); pstIpv4FragInfo->unDstAddr.ulIpAddr = pstIpHdr->unDestAddr.ulIpAddr; pstIpv4FragInfo->unSrcAddr.ulIpAddr = pstIpHdr->unSrcAddr.ulIpAddr; pstIpv4FragInfo->usIpIdentity = pstIpHdr->usIdentification; return; }
VOS_VOID CDS_SendNdDataIndMsg(TTF_MEM_ST *pstNdPkt, VOS_UINT8 ucRabId, const CDS_ENTITY_STRU *pstCdsEntity) { CDS_NDCLIENT_ND_DATA_IND_STRU *pstDataInd; VOS_UINT32 ulMsgLen; VOS_UINT32 ulPktLen; CDS_ASSERT(VOS_NULL_PTR != pstNdPkt); CDS_ASSERT(VOS_NULL_PTR != pstCdsEntity); CDS_INFO_LOG1(UEPS_PID_CDS,"Enter CDS_SendNdDataIndMsg.ucRabid=",ucRabId); /*申请消息内存*/ ulPktLen = TTF_MemGetLen(UEPS_PID_CDS,pstNdPkt); ulMsgLen = sizeof(CDS_NDCLIENT_ND_DATA_IND_STRU) + ulPktLen; pstDataInd = CDS_ALLOC_MSG_WITH_HDR(ulMsgLen); if (VOS_NULL_PTR == pstDataInd) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_SendNdDataIndMsg : Alloc Msg Fail. Size=",ulMsgLen); return; } /*填写消息内容*/ CDS_CFG_MSG_HDR(pstDataInd,UEPS_PID_NDCLIENT); pstDataInd->enMsgId = ID_CDS_NDCLIENT_ND_DATA_IND; pstDataInd->enModemId = pstCdsEntity->usModemId; pstDataInd->ucRabId = ucRabId; pstDataInd->ulLen = ulPktLen; /*内存拷贝*/ if (PS_SUCC != TTF_MemGetHeadData(UEPS_PID_CDS, pstNdPkt, pstDataInd->aucData, (VOS_UINT16)ulPktLen)) { /*lint -e961*/ PS_FREE_MSG(UEPS_PID_CDS, pstDataInd); /*lint +e961*/ CDS_ERROR_LOG(UEPS_PID_CDS,"CDS_SendNdDataIndMsg : TTF_MemGetHeadData Error."); return ; } /*发送消息*/ CDS_SEND_MSG(pstDataInd); CDS_INFO_LOG(UEPS_PID_CDS,"Leave CDS_SendNdDataIndMsg Succ."); return; }
VOS_VOID CDS_PrintIpv4Addr(const IPV4_ADDR_UN *pstIpv4Addr) { CDS_ASSERT(VOS_NULL_PTR != pstIpv4Addr); vos_printf("%d.%d.%d.%d\r\n", pstIpv4Addr->aucIPAddr[0], pstIpv4Addr->aucIPAddr[1], pstIpv4Addr->aucIPAddr[2], pstIpv4Addr->aucIPAddr[3]); return; }
VOS_VOID CDS_SaveIpv6FragmentInfo(const CDS_IPV6_FRAGMENT_INFO_STRU *pstSrcInfo) { CDS_IPV6_FRAGMENT_BUFF_STRU *pstIpv6FragBuff; CDS_IPV6_FRAGMENT_INFO_STRU *pstDstInfo; CDS_ASSERT(VOS_NULL_PTR != pstSrcInfo); pstIpv6FragBuff = CDS_GET_IPV6_FRAGMENT_BUFF(); pstDstInfo = &(pstIpv6FragBuff->astSegBuff[pstIpv6FragBuff->ulIndex]); pstIpv6FragBuff->ulIndex = TTF_MOD_ADD(pstIpv6FragBuff->ulIndex,1,CDS_IPV6_FRAGMENT_BUFF_SIZE); PS_MEM_CPY(pstDstInfo,pstSrcInfo,sizeof(CDS_IPV6_FRAGMENT_INFO_STRU)); return; }
VOS_VOID CDS_FreeIpfDlSrcMem(VOS_VOID) { LUP_QUEUE_STRU *pstDlFreeQue ; BSP_U32 ulIdleCD; VOS_UINT32 ulIdleBD; VOS_UINT32 ulBusyBD; VOS_UINT32 ulCanFree; VOS_UINT32 ulQueCnt; VOS_UINT32 ulCnt; TTF_MEM_ST *pstSrcTtf; pstDlFreeQue = CDS_IPF_DL_SRCMEM_FREE_QUE(); CDS_ASSERT(VOS_NULL_PTR != pstDlFreeQue); ulQueCnt = LUP_QueCnt(pstDlFreeQue); if (0 == ulQueCnt) { return; } /*get busy bd num*/ ulIdleBD = BSP_IPF_GetDlBDNum(&ulIdleCD); ulBusyBD = IPF_DLBD_DESC_SIZE - ulIdleBD; if (ulQueCnt >= ulBusyBD) { ulCanFree = ulQueCnt - ulBusyBD; } else { CDS_ERROR_LOG3(UEPS_PID_CDS, "CDS_FreeIpfDlSrcMem:Buff Num Less IPF Busy BD Num.quecnt,busybd,idlebd",ulQueCnt,ulBusyBD,ulIdleBD); vos_printf("CDS_FreeIpfDlSrcMem : src free que less than busy bd. quecnt=%d,busybd=%d,idlebd=%d.\n",ulQueCnt,ulBusyBD,ulIdleBD); CDS_DBG_DL_IPF_FREE_SRCMEM_ERROR(1); return; } /*free src mem*/ for (ulCnt = 0; ulCnt < ulCanFree; ulCnt ++) { if (PS_SUCC != LUP_DeQue(pstDlFreeQue,&pstSrcTtf)) { return; } TTF_MemFree(UEPS_PID_CDS,pstSrcTtf); CDS_DBG_DL_IPF_FREE_SRCMEM_NUM(1); } return; }
VOS_VOID CDS_PrintIpv6Addr(const IPV6_ADDR_UN *pstIpv6Addr) { VOS_UINT32 ulCnt; CDS_ASSERT(VOS_NULL_PTR != pstIpv6Addr); for (ulCnt = 0; ulCnt < IPV6_ADDR_LEN - 1; ulCnt ++) { vos_printf("%.2x:",pstIpv6Addr->aucIPAddr[ulCnt]); } vos_printf("%.2x\r\n",pstIpv6Addr->aucIPAddr[ulCnt]); return; }
VOS_VOID CDS_PrintPktData(const VOS_UINT8 *pucPkt, VOS_UINT32 ulLen) { VOS_UINT32 ulCnt; CDS_ASSERT(VOS_NULL_PTR != pucPkt); for (ulCnt = 1; ulCnt <= ulLen; ulCnt ++) { vos_printf("%.2x ",pucPkt[ulCnt - 1]); if (0 == (ulCnt % 16)) { vos_printf("\n"); } } vos_printf("\n"); return; }