VOS_UINT32 Fc_BufferReportDiscount( VOS_UINT32 ulBufferSize ) { VOS_UINT8 ulTmpCurrPos; if(PS_FALSE == g_ulUlDowngradeFlag) { ulTmpCurrPos = g_stFcLteTemperatureCtrl.ucCurrPos; } else { if (g_stFcLteTemperatureCtrl.ucBsrThresCnt > 0) { ulTmpCurrPos = g_stFcLteTemperatureCtrl.ucBsrThresCnt - 1; } else { ulTmpCurrPos = FC_UL_THROUGHPUT_THRES_CNT; } } if(ulTmpCurrPos < FC_UL_THROUGHPUT_THRES_CNT) { if(ulBufferSize > g_stFcLteTemperatureCtrl.ulTemperSteps[ulTmpCurrPos]) { ulBufferSize = g_stFcLteTemperatureCtrl.ulTemperSteps[ulTmpCurrPos]; } } /* CPU或温控减速 */ /* 0.9999浮点逼近 1 */ if((g_dBsrCpuModu < 0.9999) && (g_stFcLteCpuCtrl.ulUlMinBsr < ulBufferSize)) { ulBufferSize = (VOS_UINT32)(ulBufferSize * g_dBsrCpuModu); if(g_stFcLteCpuCtrl.ulUlMinBsr > ulBufferSize) { FC_CL_BSR_BELOW_MIN_STAT(1); ulBufferSize = g_stFcLteCpuCtrl.ulUlMinBsr; } } if(g_BsrCheck) { if(977 == PS_RAND(3000)) { PS_PRINTF("BSR value: %d\r\n", ulBufferSize); } } return ulBufferSize; }
/***************************************************************************** 函 数 名 : chap_Challenge 功能描述 : 构造Challenge帧并发送 输入参数 : l - PPP链接 输出参数 : 无 返 回 值 : 无 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2008年10月25日 作 者 : liukai 修改内容 : porting from BSD *****************************************************************************/ VOS_VOID chap_Challenge(struct link *l) { struct chap *chap = &(l->chap); VOS_UINT32 len, i; VOS_UINT8 *cp; VOS_UINT32 ulTick; const VOS_CHAR acLocalChallenge[] = "HUAWEI_CHAP_SRVR"; /* we always use "HUAWEI_CHAP_SRVR" as Name of Challenge */ /* Challenge body: */ /* * ------------------------ --------------------- ---------- * | Challenge-Size(1B) | Challenge-Value | Name | * ------------------------ --------------------- ---------- */ len = VOS_StrLen((VOS_CHAR *)acLocalChallenge); if (0x0 == *(chap->challenge.local)) { /* as each time local[0] is 0x0, here is always true */ ulTick = VOS_GetTick(); VOS_SetSeed(ulTick); /* use current tick as seed of random algorithm */ cp = chap->challenge.local; /*AT2D19295 测试组建议challenge中随机字符串长度固定为16,和标杆一致 */ *cp++ = (VOS_UINT8)(MD5DIGESTSIZE); /* *cp++ = (VOS_UINT8)(PS_RAND(CHAPCHALLENGELEN-MD5DIGESTSIZE) + MD5DIGESTSIZE); 随机字串长度本为任意长度, 存放在local的第一个字节,为了防止对端只支持MD5而要求长度为16, 特意保证长度至少16字节 */ for (i = 0; i < *(chap->challenge.local); i++) { *cp++ = (VOS_UINT8)PS_RAND(PS_NULL_UINT8+1); /* 随机字串 */ } /* use memcpy instead of strcpy, as "The Name should not be NUL or CR/LF terminated." in RFC1994 */ PS_MEM_CPY(cp, acLocalChallenge, len); } /* each time send challenge, record its packet */ ChapBufferChallengePacket(chap, chap->auth.id, chap->challenge.local, 1 + *(chap->challenge.local) + len); ChapOutput(l, CHAP_CHALLENGE, chap->auth.id, chap->challenge.local, 1 + *(chap->challenge.local) + len, VOS_NULL_PTR); /* 1: challenge length, *local: 随机字串长度, len: Name length */ return; } /* chap_Challenge */
VOS_BOOL Fc_CdsDlPktDiscard(VOS_UINT8 ucRabId) { VOS_UINT32 ulRandValue; (VOS_VOID)ucRabId; /*lint -e960*/ if((g_stFcCdsDlCtrl.bDlCdsFcEnable) && (g_stFcCdsDlCtrl.ulDiscardThres > TTF_GetDlIpFreeMemCnt())) { /* 丢包 */ ulRandValue = PS_RAND(101); if(ulRandValue > g_stFcCdsDlCtrl.ulDiscardRate) { return VOS_FALSE; } return VOS_TRUE; } return VOS_FALSE; /*lint +e960*/ }
VOS_BOOL QosFc_IsDiscard(VOS_UINT8 ucRabId, MODEM_ID_ENUM_UINT16 enModemId) { static VOS_UINT32 ulPktCntVal = 0; /* 包计数 */ VOS_UINT32 ulRandValue = 0; if(VOS_TRUE != g_stQosFcCtrl.bQosFcEnable) { /* 流控没打开,不进流控状态 */ return VOS_FALSE; } ulPktCntVal++; if(ulPktCntVal >= g_stQosFcCtrl.ulPktCntLimit) { ulPktCntVal = 0; QosFc_FlowCtrl(); } if(QosFc_IsInValidRabId(ucRabId)) { CDS_ERROR_LOG1(UEPS_PID_CDS,"QosFc_IsDiscard : Error RabId: ", ucRabId); /* 非法承载,丢包 */ return VOS_TRUE; } switch( g_enRabState[enModemId][ucRabId - 5] ) { case QOS_FC_RAB_STATE_NORMAL: case QOS_FC_RAB_STATE_NOT_DISCARD: /* 正常数传状态,不丢包 */ return VOS_FALSE; case QOS_FC_RAB_STATE_RANDOM_DISCARD: FC_DBG_RCV_PKT_ONRD_STAT(enModemId, ucRabId, 1); /* 随机丢包 */ ulRandValue = PS_RAND(101); if(ulRandValue > g_stQosFcCtrl.ulRandomDiscardRate) { return VOS_FALSE; } FC_DBG_DISCARD_PKT_ONRD_STAT(enModemId, ucRabId, 1); return VOS_TRUE; case QOS_FC_RAB_STATE_DISCARD: FC_DBG_RCV_PKT_OND_STAT(enModemId, ucRabId, 1); /* 丢包 */ ulRandValue = PS_RAND(101); if(ulRandValue > g_stQosFcCtrl.ulDiscardRate) { return VOS_FALSE; } FC_DBG_DISCARD_PKT_OND_STAT(enModemId, ucRabId, 1); return VOS_TRUE; default: /* 非法状态 */ CDS_ERROR_LOG3(UEPS_PID_CDS, "QosFc_IsDiscard : Rab invalid state::",enModemId, ucRabId, g_enRabState[enModemId][ucRabId - 5]); break; } /* 尽量不丢包 */ return VOS_FALSE; }