📄 ylffiltemsg.cpp
字号:
// ylfFilteMsg.cpp: implementation of the ylfFilteMsg class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ylfFilteMsg.h"
bool ylfFilteMsg::bFilter=false;
CString ylfFilteMsg::addr="";
CString ylfFilteMsg::baddr="";
bool ylfFilteMsg::haveIAM=false;
UINT ylfFilteMsg::dpc=0;
UINT ylfFilteMsg::opc=0;
WORD ylfFilteMsg::cic=0;
bool ylfFilteMsg::haveIAM2=false;
UINT ylfFilteMsg::dpc2=0;
UINT ylfFilteMsg::opc2=0;
WORD ylfFilteMsg::cic2=0;
int ylfFilteMsg::count=0;
defIsupFiltItem ylfFilteMsg::isupFiltItem;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ylfFilteMsg::ylfFilteMsg()
{
}
ylfFilteMsg::~ylfFilteMsg()
{
}
bool ylfFilteMsg::ReadConfig()
{
CString app_path=CString(AfxGetApp()->m_pszHelpFilePath);
int index=-1;
if((index=app_path.ReverseFind('\\'))!=-1)
{
app_path=app_path.Left(index);
}
app_path+="\\MsgDetail.ini";
ylfProfile pf(app_path);
haveIAM=false;
bFilter=(pf.GetProfileInt("cdr","bFilter",0)==1);
addr=pf.GetProfileString("cdr","addr","");
baddr=pf.GetProfileString("cdr","baddr","");
return bFilter;
}
bool ylfFilteMsg::FiltIAM(UINT dpc,UINT opc,WORD cic,CString addr,CString baddr)
{
/* if(addr==""||addr=="0")return true;
return false;
UINT pcs[]={0x0E3097,0x0E2FBE,0x0E31B4};//,0x0E30BE
for(int i=0;i<sizeof(pcs)/4;i++)
{
if(dpc==pcs[i]||opc==pcs[i])return true;
}
return false;*/
if(ylfFilteMsg::addr==""&&ylfFilteMsg::baddr=="")return true;
if(baddr.GetLength()<3)return false;
#if 1
if(((ylfFilteMsg::addr!=""&&ylfFilteMsg::addr.Find(addr)==0)
||(ylfFilteMsg::baddr!=""&&ylfFilteMsg::baddr.Find(baddr)==0))
||((ylfFilteMsg::addr!=""&&addr.Find(ylfFilteMsg::addr)==0)
||(ylfFilteMsg::baddr!=""&&baddr.Find(ylfFilteMsg::baddr)==0))
)
#else
if(((ylfFilteMsg::addr!=""&&ylfFilteMsg::addr.Find(addr)==0)
&&(ylfFilteMsg::baddr!=""&&ylfFilteMsg::baddr.Find(baddr)==0))
||((ylfFilteMsg::addr!=""&&addr.Find(ylfFilteMsg::addr)==0)
&&(ylfFilteMsg::baddr!=""&&baddr.Find(ylfFilteMsg::baddr)==0))
)
#endif
{
if(!haveIAM)
{
haveIAM=true;
ylfFilteMsg::dpc=dpc;
ylfFilteMsg::opc=opc;
ylfFilteMsg::cic=cic;
return true;
}
else if(!haveIAM2)
{
haveIAM2=true;
ylfFilteMsg::dpc2=dpc;
ylfFilteMsg::opc2=opc;
ylfFilteMsg::cic2=cic;
return true;
}
}
return false;
}
bool ylfFilteMsg::Filt(UINT dpc,UINT opc,WORD cic,BYTE h1h2)
{
bool suc=false;
if(haveIAM&&((ylfFilteMsg::dpc==dpc&&ylfFilteMsg::opc==opc)
||(ylfFilteMsg::dpc==opc&&ylfFilteMsg::opc==dpc))&&ylfFilteMsg::cic==cic)
{
suc=true;
if(h1h2==0x10)
{
haveIAM=false;
}
}
else if(haveIAM2&&((ylfFilteMsg::dpc2==dpc&&ylfFilteMsg::opc2==opc)
||(ylfFilteMsg::dpc2==opc&&ylfFilteMsg::opc2==dpc))&&ylfFilteMsg::cic2==cic)
{
suc=true;
if(h1h2==0x10)
{
haveIAM2=false;
}
}
return suc;
}
bool ylfFilteMsg::IsFiltMsg(BYTE* msgBuf,int len)
{
bool suc=false;
unsigned char topc[3];
unsigned char tdpc[3];
int p=0;
int startPos=p;
int endPos=p+len;
int pos=p;
int msgLen=256*msgBuf[pos+1]+msgBuf[pos];
BYTE ss7sio=0;
BYTE mode=0;
int li;
if(msgBuf[pos+1]>0)
{
mode=1;
}
mode=msgLen>>12;//
msgLen&=0x0fff;
pos+=2;
BOOL b2M=((msgBuf[pos+1]&0x80)>0);
BOOL pc24bit=FALSE;
BYTE dataleggel;
BYTE b;
char taddr[20];
if(mode==0)//ss7
{
pos+=6;
msgLen+=2;
if(msgLen!=len)
{
TRACE("\r\n消息长度%d不等于实际长度%d",msgLen,len);
return false;
}
if(b2M) //适应2M
{
pos=startPos+12;//sbuf-->LI
li=255*(msgBuf[pos+1]&0x01)+msgBuf[pos];
ss7sio=(msgBuf[pos+2]);
pos+=2; //->SIO
}
else
{
pos=startPos+10;//sbuf-->LI
li=msgBuf[pos];
ss7sio=(msgBuf[pos+1]);
pos++; //->SIO
}
if(li<=2)
{
return false;
}
else
{
pos++;
pc24bit=((ss7sio&0xc0)!=0xc0);
if(pc24bit) // 是24比特编码
{
tdpc[0] =msgBuf[pos++];
tdpc[1] =msgBuf[pos++];
tdpc[2] =msgBuf[pos++];
topc[0] =msgBuf[pos++];
topc[1] =msgBuf[pos++];
topc[2] =msgBuf[pos++];
pos++;
}
else // 是14比特编码
{
tdpc[0]=msgBuf[pos++];
tdpc[1]=msgBuf[pos]&0x3f;
tdpc[2]=0;
topc[0]=(msgBuf[pos]>>6) | ((msgBuf[pos+1])<<2);
pos++;
topc [1]=((msgBuf[pos]>>6) | ((msgBuf[pos+1])<<2))&0x3f;
pos++;
topc [2]=0;
pos++;
}
if((ss7sio&0x0f)==4) //根据业务表示语调用相应的函数
{
ss7sio=4;
}
if((ss7sio&0x0f)==5) //根据业务表示语调用相应的函数
{
isupFiltItem.dpc=isupFiltItem.opc=0;
memcpy(&isupFiltItem.dpc,tdpc,3);
memcpy(&isupFiltItem.opc,topc,3);
isupFiltItem.cic=256*msgBuf[pos+1]+msgBuf[pos];
pos += 2;
isupFiltItem.msgtype=msgBuf[pos]; //get H1H0 ->MT后第一个字节
if(isupFiltItem.msgtype==1)
{
pos+=8; //->CALNOLI:
if(!ylfCommon::GetMsgBAddr(msgBuf+pos,isupFiltItem.baddr,sizeof(isupFiltItem.baddr)))
{//地址有错,长度不合法
return false;
}
li=msgBuf[pos++];
pos+=li;
dataleggel=0xff;
while(endPos-pos>2 && dataleggel==0xff && msgBuf[pos]!=0)
{
dataleggel=0;
b=msgBuf[pos];
if(b==0x0a||b==0x0b||b==0x28) // 主叫,改发,原被叫,
{
pos++; //buf-->LI of CLGNO
if(msgBuf[pos]>2&&msgBuf[pos]<20)//include Calling Addr Sig.
{
if(ylfCommon::GetMsgBAddr(msgBuf+pos,taddr,sizeof(taddr)))
{
if(b==0x0a)//主叫
{
strcpy(isupFiltItem.addr,taddr);
}
}
}
li=msgBuf[pos++]; //buf-->地址性质表示语
pos+=li; //sbuf->Next field
dataleggel=0xff;
}//// exist Calling No.
else //not Calling No.
{
if(endPos-pos>=(msgBuf[pos+1]+2))//存在任选项
{
dataleggel=0xff;pos++;li=msgBuf[pos++];pos+=li;
}
else //长度错误,退出while
break;
}
}//while(endPos-pos>2)
suc=FiltIAM(isupFiltItem.dpc,isupFiltItem.opc,isupFiltItem.cic,isupFiltItem.addr,isupFiltItem.baddr);
}
else if(haveIAM||haveIAM2)
{
suc=Filt(isupFiltItem.dpc,isupFiltItem.opc,isupFiltItem.cic,isupFiltItem.msgtype);
}
//isup.Decode();
}
}
}
if(suc)
{
FillMsg(msgBuf,len);
}
return suc;
}
BYTE* ylfFilteMsg::GetMsgBuf(int pos)
{
return NULL;
}
void ylfFilteMsg::FillMsg(BYTE *msgBuf, int len)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -