?? cbse_reset.c
字號:
#include "..\sys\Include.h"
/* 返回確認給CBC_Proxy */
int Process_Reset_Return(PID_t s_Pid,unsigned char cNumberOfReturnMessage);
/* 檢查參數 */
int Process_RESET_init(RESET_t *s_Reset);
/* 發送消息給BSC */
int Process_Send_Reset_To_BSC(PID_t s_Pid,DIVIDE_CELLLIST_BUF_t *s_DivideCellListBuf);
/* 處理重置請求 */
int Process_RESET(unsigned char *MessageBuf,PID_t s_Pid)
{
int iReturnValue;
RESET_t *LPm_Reset;
RESET_PROCESS_DATA_STRUCT *LPs_ResetProcessDataStruct;
/* 拆分小區緩沖區 */
DIVIDE_CELLLIST_BUF_t s_DivideCellListBuf;
CELLID_t s_CellId;
int i,j;
memset(&s_DivideCellListBuf,0,sizeof(DIVIDE_CELLLIST_BUF_t));
memset(&ProcessData[s_Pid.iProcessId][0],0,LPCB_DATA_SIZE);
LPs_ResetProcessDataStruct=(RESET_PROCESS_DATA_STRUCT *)&ProcessData[s_Pid.iProcessId][0];
/* 數據拷貝到進程數據區 */
memcpy(LPs_ResetProcessDataStruct,MessageBuf,sizeof(CBEMESSAGE_t));
LPm_Reset=(RESET_t *)&LPs_ResetProcessDataStruct->s_CBCMessage.cMessage[0];
#ifdef DEBUG_PRINT
Print_RESET(s_Pid,LPm_Reset);
#endif
/* 檢查參數 */
iReturnValue=Process_RESET_init(LPm_Reset);
if(iReturnValue<0)
{
return iReturnValue;
}
/* 構造響應結果 */
iReturnValue=Process_Divide_CellList_AccordingToResetResponse(&LPm_Reset->p_CellList,
0,&LPs_ResetProcessDataStruct->s_ResponseCellList,&s_CellId);
if (iReturnValue<0)
{
return iReturnValue;
}
/* 從響應列表得到拆分列表 */
for(i=0;i<LPs_ResetProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
{
for(j=0;j<LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength;j++)
{
Process_Add_CellId_To_DivideCellListBuf(
&LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].s_CellReport[j].s_CellId.cCellId[0],
&LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].BSCIdentifier[0],
&s_DivideCellListBuf);
}
}
/* 返回確認給CBC_Proxy */
// Process_Reset_Return(s_Pid,s_DivideCellListBuf.cNumberOfCellList);
/* 發送消息給BSC */
Process_Send_Reset_To_BSC(s_Pid, &s_DivideCellListBuf);
/* 創建回復定時器 */
iReturnValue=create_timer(RESET_RETURN_DELAY_TIME,
RESET_RETURN,(char *)&s_Pid,NULL);
/* 創建定時器失敗 */
//sys
if (iReturnValue<0)
{
printf("Create timer Error!\n");
return iReturnValue;
}
else
{
LPs_ResetProcessDataStruct->iTimerId=iReturnValue;
return CONTINUANCE;
}
}
int Process_RESET_init(RESET_t *s_Reset)
{
if (s_Reset->p_CellList.bFlag!=EXIST)
{
return NO_CELLLIST;
}
//檢查小區數目
if ((s_Reset->p_CellList.iLength<=0)||(s_Reset->p_CellList.iLength>MAXCELLCOUNT))
{
return NUMBEROFCELL_ERROR;
}
return SUCCESS;
}
//返回確認給CBC_Proxy
int Process_Reset_Return(PID_t s_Pid,unsigned char cNumberOfReturnMessage)
{
CBEMESSAGE_t s_CBEMessage;
CBEMESSAGE_t *LPCBEMessage;
MESSAGE_CONFIRM_i s_MessageConfirm;
MESSAGE_HEAD_t *LPMessageHead;
memset(&s_MessageConfirm,0,sizeof(MESSAGE_CONFIRM_i));
memset(&s_CBEMessage,0,sizeof(CBEMESSAGE_t));
LPMessageHead=(MESSAGE_HEAD_t *)&ProcessData[s_Pid.iProcessId][sizeof(short)];
LPCBEMessage=(CBEMESSAGE_t *)&ProcessData[s_Pid.iProcessId][0];
s_MessageConfirm.s_MessageHead.iMessageAreaId=A;
s_MessageConfirm.s_MessageHead.iMessageType=LPMessageHead->iMessageType;
memcpy(&s_MessageConfirm.s_MessageHead.s_ReceiverPid,&LPMessageHead->s_SenderPid,sizeof(PID_t));
memcpy(&s_MessageConfirm.s_MessageHead.s_SenderPid,&s_Pid,sizeof(PID_t));
s_MessageConfirm.s_MessageHead.iMessageLength=sizeof(int);
s_MessageConfirm.NumberOfReturnMessage=cNumberOfReturnMessage;
s_CBEMessage.iLen=s_MessageConfirm.s_MessageHead.iMessageLength+sizeof(MESSAGE_HEAD_t);
memcpy(&s_CBEMessage.s_MessageHead,&s_MessageConfirm.s_MessageHead,sizeof(MESSAGE_HEAD_t));
memcpy(&s_CBEMessage.cMessage[0],&s_MessageConfirm.s_MessageHead,s_MessageConfirm.s_MessageHead.iMessageLength);
AppendCBESendMessage(&s_CBEMessage);
return SUCCESS;
}
/*
* 發送消息給BSC
*/
int Process_Send_Reset_To_BSC(PID_t s_Pid,DIVIDE_CELLLIST_BUF_t *s_DivideCellListBuf)
{
int len;
char *BSCID;
BSCMESSAGE_t s_BSCMessage;
RESET_t s_Reset;
int i;
int Tid;
memset(&s_Reset,0,sizeof(RESET_t));
for(i=0;i<s_DivideCellListBuf->cNumberOfCellList;i++)
{
memset(&s_BSCMessage,0,sizeof(BSCMESSAGE_t));
memcpy(&s_Reset.p_CellList,&s_DivideCellListBuf->s_CellListOfBSC[i].s_CellList,sizeof(CELLLIST_t));
len= Pack_RESET(&s_Reset,&s_BSCMessage.cMessage[0]);
if (len>0)
{
s_BSCMessage.iLen=len;
BSCID=&s_DivideCellListBuf->s_CellListOfBSC[i].BSCIdentifier[0];
Tid=GetTid(BSCID);
if (Tid!=FAILURE)
{
memcpy(&s_BSCMessage.s_Pid,&s_Pid,sizeof(PID_t));
#ifdef OPEN_STATISTIC
s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyResetCnt++;
#endif
/* 發送給BSC */
X25AppendCBESendMessage(&s_BSCMessage, Tid);
}
}
}
return SUCCESS;
}
/* 將列表轉為標準格式,用于Reset
// in: s_CBEMessage Cbcproxy發送來的原始信息
// out: s_ProxyMessage
// 返回:
// 1: 成功,
// -1:失敗
*/
int Convert_Reset(CBEMESSAGE_t *s_CBEMessage,CBEMESSAGE_t *s_ProxyMessage)
{
int posi;
unsigned short iListLen;
RESET_t *LPm_Reset;
LPm_Reset=(RESET_t *)&s_ProxyMessage->cMessage[0];
memcpy(&s_ProxyMessage->s_MessageHead,&s_CBEMessage->s_MessageHead,sizeof(MESSAGE_HEAD_t));
posi=0;
/* 得到CELLLIST的長度 */
memcpy(&iListLen,&s_CBEMessage->cMessage[posi],sizeof(unsigned short));
/* 長度溢出,返回錯誤 */
// if (iListLen>sizeof(CELLLIST_t))
if (iListLen>256)
{
return FAILURE;
}
/* 沒有該參數,返回成功 */
if (iListLen==0)
{
return SUCCESS;
}
posi=posi+sizeof(unsigned short);
LPm_Reset->p_CellList.bFlag=1;
LPm_Reset->p_CellList.cCellIdDisc=1;
LPm_Reset->p_CellList.iLength=iListLen;
/* 復制小區列表 */
memcpy(&LPm_Reset->p_CellList.s_CellList, &s_CBEMessage->cMessage[posi],iListLen*sizeof(CELLID_t));
s_ProxyMessage->iLen=sizeof(RESET_t)+sizeof(MESSAGE_HEAD_t);
return SUCCESS;
}
/* 處理SET_DRX_REPORT回復定時器到時 */
void Process_RESET_timer_Expired(PID_t s_Pid)
{
int iPosi;
char ResponseBuf[3096];
RESET_PROCESS_DATA_STRUCT *LPs_ResetProcessDataStruct;
BSC_RESTART_i *LPs_Restart;
int i,j;
unsigned short iLen;
unsigned short iNumberofFailCell;
memset(&ResponseBuf[0],0,3096);
LPs_ResetProcessDataStruct=(RESET_PROCESS_DATA_STRUCT *)&ProcessData[s_Pid.iProcessId][0];
LPs_Restart=(BSC_RESTART_i *)&ResponseBuf[sizeof(short)];
/* */
memcpy(&LPs_Restart->s_MessageHead.s_ReceiverPid,
&LPs_ResetProcessDataStruct->s_CBCMessage.s_MessageHead.s_SenderPid,sizeof(PID_t));
/* */
memcpy(&LPs_Restart->s_MessageHead.s_SenderPid,&s_Pid,sizeof(PID_t));
LPs_Restart->s_MessageHead.iMessageAreaId=A;
LPs_Restart->s_MessageHead.iMessageType=CBCPROXY_RESET;
iPosi=sizeof(BSC_RESTART_i)+sizeof(short);
// LPs_Restart->bReportListFlag=EXIST;
LPs_Restart->cReportListNumberOfBSC=LPs_ResetProcessDataStruct->s_ResponseCellList.cNumberOfBSC;
LPs_Restart->iReturnValue=SUCCESS;
/* 沒響應置為全失敗 */
for(i=0;i<LPs_ResetProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
{
/* 如果沒響應置為全失敗 */
if(LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].bReceiveRespons==0)
{
for(j=0;j<LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength;j++)
{
LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].s_CellReport[j].cCellStatus=PERMANENT_FAILURE;
}
}
}
/* 壓縮ReportList參數 */
/* for(i=0;i<LPs_ResetProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
{
memcpy(&ResponseBuf[iPosi],&LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i],
LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength*sizeof(CELLREPORT_i )+sizeof(short)+BSC_INDENTIFIER_LEN);
iPosi=iPosi+LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength*sizeof(CELLREPORT_i )+sizeof(short)+BSC_INDENTIFIER_LEN;
}
*/
/* 留出小區個數空間 */
iPosi=iPosi+sizeof(short);
iNumberofFailCell=0;
/* 抽出失敗小區序列返回 */
for(i=0;i<LPs_ResetProcessDataStruct->s_ResponseCellList.cNumberOfBSC;i++)
{
for(j=0;j<LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].ilength;j++)
{
if(LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].s_CellReport[j].cCellStatus==PERMANENT_FAILURE)
{
memcpy(&ResponseBuf[iPosi],
&LPs_ResetProcessDataStruct->s_ResponseCellList.s_BSCCellList[i].s_CellReport[j].s_CellId.cCellId[0],
sizeof(CELLID_t));
iPosi=iPosi+sizeof(CELLID_t);
iNumberofFailCell++;
}
}
}
memcpy(&ResponseBuf[sizeof(BSC_RESTART_i)+sizeof(short)],&iNumberofFailCell,sizeof(short));
iLen=iPosi-sizeof(short);
LPs_Restart->s_MessageHead.iMessageLength=iLen-sizeof(MESSAGE_HEAD_t);
memcpy(&ResponseBuf[0],&iLen,sizeof(short));
#ifdef DEBUG_PRINT
printf("Reset Return To CBCProxy. Pid=%d\n",s_Pid.iProcessId);
#endif
AppendCBESendMessage((CBEMESSAGE_t *)&ResponseBuf[0]);
}
/* 當X25鏈路建立時重啟小區 */
void Reset_When_Connect(int Tid)
{
int len;
BSCMESSAGE_t s_BSCMessage;
RESET_t s_Reset;
int i,j;
memset(&s_Reset,0,sizeof(RESET_t));
memset(&s_BSCMessage,0,sizeof(BSCMESSAGE_t));
for(i=0;i<s_BSCCellInfo[Tid].cNumberOfBTS;i++)
{
for(j=0;j<s_BSCCellInfo[Tid].s_BTSCellInfo[i].cNumberOfCell;j++)
{
memcpy(&s_Reset.p_CellList.s_CellList[s_Reset.p_CellList.iLength].cCellId[0],
&s_BSCCellInfo[Tid].s_BTSCellInfo[i].s_CellId[j].cCellId[0],
sizeof(CELLID_t));
s_Reset.p_CellList.iLength++;
}
}
if (s_Reset.p_CellList.iLength>0)
{
s_Reset.p_CellList.bFlag=EXIST;
s_Reset.p_CellList.cCellIdDisc=LAC_AND_CI;
}
len= Pack_RESET(&s_Reset,&s_BSCMessage.cMessage[0]);
if (len>0)
{
s_BSCMessage.iLen=len;
memset(&s_BSCMessage.s_Pid,0,sizeof(PID_t));
#ifdef OPEN_STATISTIC
s_CBSECount.s_ReqBSCCnt[Tid].iCBCProxyResetCnt++;
#endif
/* 發送給BSC */
X25AppendCBESendMessage(&s_BSCMessage, Tid);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -