📄 sccpdispgsm.cpp
字号:
/**********************************************
History:
2000.04.17:SSN=5,process CAP message
2000.07.21:SSN=0xfe&&PC is 14bits is GSMA,else INAP
2000.09.02:procUDTDATADisp(),by LHG
***********************************************/
#include "stdafx.h"
#include "mpa08.h"
#include "common.h"
#define DATAFIELDNO 0x40 //start field no of DATA content field
#define DIALODPARTFIELDNO 0x50 //start field No of DIALOD part:50h-1
#define COMPONENTPARTFIELDNO 0xd0 //component part tag field No:A2-1
#define COMPONENTTAGFIELDNO 0xd1 //component tag field No:A2-1
#define INVOKEIDFIELDNO 0xd3
#define LINKIDFIELDNO 0xd6
#define OCFIELDNO 0xd9
#define SEQUENCEFIELDNO 0xdd
#define ERRORCODEFIELDNO 0xdf
#define PROBLEMCODEFIELDNO 0xe2
#define PARAFIELDNO 0xe6
#define bytedisp(x) *dispbuf++=x; \
*dispbuf++=1; \
*dispbuf++=*recbuf; \
*dispbuf++=8; \
*dispbuf++=*recbuf++;\
*dispbuf++=0xcc; \
displen+=6;
#define procOPTIONoverDisp(x) *dispbuf++=x; \
*dispbuf++=1; \
*dispbuf++=0; \
*dispbuf++=8; \
*dispbuf++=0; \
*dispbuf++=0xcc;\
displen+=6;
#define proc3byte(x) *dispbuf++=x;\
*dispbuf++=3;\
*dispbuf++=*recbuf;\
*dispbuf++=*(recbuf+1);\
*dispbuf++=*(recbuf+2);\
*dispbuf++=24;\
*dispbuf++=*(recbuf+2);\
*dispbuf++=*(recbuf+1);\
*dispbuf++=*recbuf;\
*dispbuf++=0xcc;\
displen+=10;recbuf+=3;
BYTE SCCPSSN; //save SSN of SCCP
extern WORD Version;
extern void proc8bitsdisp(BYTE dfldno);
extern void proc24bitsdisp(BYTE dfldno);
extern void procmoredatadisp(WORD slen);
extern void procDPCOPCSLC14disp();
extern void procGSMAdisp();
void procPARATAGdisp(BYTE dfldno);
void procDIALOGPARTdisp(BYTE dfldno);
extern BYTE *recbuf,*dispbuf;
extern WORD displen;
BYTE UDTlen;
extern void procMAPdisp(BYTE oc,BYTE compt);
extern void procMAPERRdisp(BYTE ec);
extern void procINAPdisp(BYTE oc,BYTE compt);
extern void procINAPERRdisp(BYTE ec);
extern void procCAPdisp(BYTE oc,BYTE compt);
BYTE procTCLENGTHdisp(BYTE dfldno)
{
if((*recbuf&0x80)==0)//short format:8bits
{bytedisp(dfldno)
UDTlen--;return 0;
}//short format:8bits
else if(*recbuf&0x7f)//long format:16bits
{*dispbuf++=dfldno;
*dispbuf++=2;
*(WORD *)dispbuf=*(WORD *)recbuf; dispbuf+=2;
*dispbuf++=8; *dispbuf++=*(recbuf+1); recbuf+=2;
*dispbuf++=0xcc; displen+=7;
UDTlen-=2;return 0;
}//long format:16bits
else//Indefinite format:8bits
{bytedisp(dfldno)
UDTlen--;return 1;
}//Indefinite format:8bits
}
void procPRIMITIVEIEDdisp(BYTE dfldno)
{ BYTE c,taglen;
//tag code:8bits,M
dfldno++;
bytedisp(dfldno)
//length,M
dfldno++;
if((*recbuf&0x80)==0)//short format
{*dispbuf++=dfldno;
*dispbuf++=1;
taglen=*dispbuf++=*recbuf++;
*dispbuf++=8;
*dispbuf++=taglen;
*dispbuf++=0xcc;
displen+=6;
UDTlen -= 2+taglen;
}//short format
else//long format
{*dispbuf++=dfldno;
*dispbuf++=2;
*(WORD *)dispbuf=*(WORD *)recbuf;
dispbuf+=2;
*dispbuf++=8;
taglen=*dispbuf++=*(recbuf+1);
*dispbuf++=0xcc;
recbuf+=2;
displen+=7;
UDTlen -= 3+taglen;
}//long format
dfldno++;
if (taglen!=0)
{*dispbuf++=dfldno;
*dispbuf++=taglen;
for (c=0;c<taglen;c++) *dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=taglen+3;
}
}
void procOCdisp()
{ BYTE c,taglen;
//tag code:8bits,M
bytedisp(0xda)
//length,M
if(*recbuf<0x80)//short format
{*dispbuf++=0xdb;
*dispbuf++=1;
taglen=*dispbuf++=*recbuf++;
*dispbuf++=8;
*dispbuf++=taglen;
*dispbuf++=0xcc;
displen+=6;
UDTlen -= 2+taglen;
}//short format
else//long format
{*dispbuf++=0xdb;
*dispbuf++=2;
*(WORD *)dispbuf=*(WORD *)recbuf;
dispbuf+=2;
*dispbuf++=8;
taglen=*dispbuf++=*(recbuf+1);
*dispbuf++=0xcc;
recbuf+=2;
displen+=7;
UDTlen -= 3+taglen;
}//long format
if (taglen!=0)
{*dispbuf++=0xdc;
*dispbuf++=taglen;
for (c=0;c<taglen;c++) *dispbuf++=*(recbuf+c);
*dispbuf++=taglen*8;
for (c=0;c<taglen;c++) *dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=taglen*2+4;
}
}
void procSourcePARAdisp(BYTE dfldno)
{ BYTE lenfmt=0;
BYTE paralen,len,c,*bufbak;
//Tag code:8bits
bytedisp(dfldno)
dfldno++;
//length
if(*recbuf==0x80)//indefinite format
{
//process indefinite format length
*dispbuf++=dfldno;
*dispbuf++=1;
*dispbuf++=*recbuf;
*dispbuf++=8;
*dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=6;
lenfmt++;
//process External Tag content
paralen=0;
len=*(recbuf+1);//get sub-len
bufbak=recbuf;
while(*(WORD *)recbuf!=0) //EOC tag
{if(*(recbuf+1)==0x80)//sub len is indefinite format
{lenfmt++; recbuf+=2;paralen+=2;}
else
{if ((*(recbuf+1)&0x80)==0x80) //long format
{recbuf++;paralen++;}
len=*(recbuf+1);
recbuf+=2;
paralen+=2;
recbuf+=len;
paralen+=len;
}//else
}//while
//process parameter content
recbuf=bufbak;
*dispbuf++=dfldno+1;
*dispbuf++=paralen;
for(c=0;c<paralen;c++) *dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=paralen+3;
}//indefinite format
else //short or long format
{if((*recbuf&0x80)==0)//short length
{*dispbuf++=dfldno;
*dispbuf++=1;
paralen=*dispbuf++=*recbuf++;
*dispbuf++=8;
*dispbuf++=paralen;
*dispbuf++=0xcc;
displen+=6;
}//short length
else if((*recbuf&0x7f)!=0)//long format
{*dispbuf++=dfldno;
*dispbuf++=2;
*dispbuf++=*recbuf++;
paralen=*dispbuf++=*recbuf++;
*dispbuf++=8;
*dispbuf++=paralen;
*dispbuf++=0xcc;
displen+=7;
}//long format
//process parameter content
if(paralen!=0)
{*dispbuf++=dfldno+1;
*dispbuf++=paralen;
for(c=0;c<paralen;c++) *dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=paralen+3;
}
}//else:short or long format
recbuf+=lenfmt*2;
}
void procINVOKEdisp(BYTE dfldno,BYTE up)
{ BYTE lenfmt=0; //dh,if indefinit return 1,else 0
BYTE len,oc;
//Invoke component type tag:8bits
dfldno++;
bytedisp(dfldno)
UDTlen--;
//Invoke component length
dfldno++;
lenfmt+=procTCLENGTHdisp(dfldno);
//Invoke ID(M)
procPRIMITIVEIEDdisp(INVOKEIDFIELDNO);
//Link ID(O) or operator code(M) tag
if(*recbuf==0x80) //Link ID tag
procPRIMITIVEIEDdisp(LINKIDFIELDNO);
//operat code,M
oc=*(recbuf+2); //get operate code
procOCdisp();
//parameter tag(O)
lenfmt*=2;
if(UDTlen>lenfmt) //exist parament
{len=UDTlen-lenfmt;
if(up==5)
{
#if MultiTS
procCAPdisp(oc,1);
if( UDTlen>lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
#else
procSourcePARAdisp(PARAFIELDNO);
#endif
}
else if(up==6)
{procMAPdisp(oc,1);
if(UDTlen > lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else if((Version&0x08)!=0 && up==0x0c)
{procINAPdisp(oc,1);
if( UDTlen>lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else //process to source data
procSourcePARAdisp(PARAFIELDNO);
}//exist parament
if(UDTlen > lenfmt) //add by 2000.06.12
{
recbuf+=lenfmt;
UDTlen-=lenfmt;
}
}
void procRETURNRESULTdisp(BYTE dfldno,BYTE up)
{ BYTE lenfmt=0; //dh,if indefinit return 1,else 0
BYTE len,oc;
//Return Result component type tag:8bits
dfldno++;
bytedisp(dfldno)
UDTlen--;
//Return Result component length
dfldno++;
lenfmt+=procTCLENGTHdisp(dfldno);
//Invoke ID(M)
procPRIMITIVEIEDdisp(INVOKEIDFIELDNO);
//Sequence tag(O),Construct
if(*recbuf==0x30) //Sequence tag code
{dfldno=SEQUENCEFIELDNO;
//Sequence tag code:8bits
bytedisp(dfldno)
dfldno++;
UDTlen--;
//Sequence tag length
if(*recbuf==0x80)//Sequence tag length is Indefinite format
{ bytedisp(dfldno)
lenfmt++;
UDTlen--;
}
else if((*recbuf&0x80)==0x80)//long format
{*dispbuf++=dfldno;
*dispbuf++=2;
*(WORD *)dispbuf=*(WORD *)recbuf;
dispbuf+=2;
recbuf++;
*dispbuf++=8;
*dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=7;
UDTlen-=2;
}
else //short format
{bytedisp(dfldno)
UDTlen--;
}
//operate code tag,O,Primitive
if(*recbuf==0x02 || *recbuf==0x06) //Local\Global operate code tag
{oc=*(recbuf+2); //get operate code
procOCdisp();
}
//parameter tag,O,Primitive
lenfmt*=2;
if(UDTlen>lenfmt) //exist parament
{len=UDTlen-lenfmt;
if(up==5)
{
#if MultiTS
procCAPdisp(oc,2);
if( UDTlen>lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
#else
procSourcePARAdisp(PARAFIELDNO);
#endif
}
else if(up==6)
{procMAPdisp(oc,2);
if( UDTlen>lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else if((Version&0x08)!=0 && up==0x0c)
{procINAPdisp(oc,2);
if( UDTlen>lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else //process to source data
procSourcePARAdisp(PARAFIELDNO);
}//exist parament
if(UDTlen > lenfmt) //add by 2000.06.12
{
recbuf+=lenfmt;
UDTlen-=lenfmt;
}
}//Sequence tag code
}
void procRETURNERRdisp(BYTE dfldno,BYTE up)
{ BYTE lenfmt=0; //dh,if indefinit return 1,else 0
BYTE len,errcode;
//Return Error component type tag:8bits
dfldno++;
bytedisp(dfldno)
UDTlen--;
//Return Error component length
dfldno++;
lenfmt+=procTCLENGTHdisp(dfldno);
//Invoke ID(M)
procPRIMITIVEIEDdisp(INVOKEIDFIELDNO);
//Error code(M) tag
errcode=*(recbuf+2); //get error code
bytedisp(ERRORCODEFIELDNO+1)
bytedisp(ERRORCODEFIELDNO+2)
bytedisp(ERRORCODEFIELDNO+3)
UDTlen-=3;
//parameter tag,O,Primitive
lenfmt*=2;
if(UDTlen>lenfmt) //exist parament
{len=UDTlen-lenfmt;
if(up==5)
{/*procCAPERRdisp(errcode);*/
if( UDTlen-=lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else if(up==6)
{procMAPERRdisp(errcode);
if( UDTlen-=lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else if((Version&0x08)!=0 && up==0x0c)
{procINAPERRdisp(errcode);
if( UDTlen-=lenfmt) UDTlen-=lenfmt; //add by 2000.06.12
}
else //process to source data
procSourcePARAdisp(PARAFIELDNO);
}//exist parament
if( UDTlen-=lenfmt) //add by 2000.06.12
{
recbuf+=lenfmt;
UDTlen-=lenfmt;
}
}
void procREJECTdisp(BYTE dfldno)
{ BYTE lenfmt=0; //dh,if indefinit return 1,else 0
//Reject component type tag:8bits
dfldno++;
bytedisp(dfldno)
//Reject component length
dfldno++;
lenfmt+=procTCLENGTHdisp(dfldno);
//Invoke ID(M)
procPRIMITIVEIEDdisp(INVOKEIDFIELDNO);
//problem code(M) tag
procPRIMITIVEIEDdisp(PROBLEMCODEFIELDNO);
recbuf+=lenfmt*2;
UDTlen-=lenfmt*2;
}
void procPARATAGdisp(BYTE dfldno)
{ BYTE lenfmt=0;
BYTE paralen,len,c,*bufbak;
//parameter tag
*dispbuf++=dfldno;
*dispbuf++=1;
*dispbuf++=*recbuf;
*dispbuf++=8;
*dispbuf++=*recbuf++;
*dispbuf++=0xcc;
UDTlen--;
//parameter length
if(*recbuf==0x80)//indefinite format
{
//process indefinite format length
*dispbuf++=dfldno+1;
*dispbuf++=1;
*dispbuf++=*recbuf;
*dispbuf++=8;
*dispbuf++=*recbuf++;
*dispbuf++=0xcc;
displen+=6;
lenfmt++;
UDTlen--;
//process parameter content
paralen=0;
len=*(recbuf+1);//get sub-len
bufbak=recbuf;
while(*(WORD *)recbuf!=0) //EOC tag
{if(*(recbuf+1)==0x80)//sub len
{lenfmt++; recbuf+=2;paralen+=2;}
else
{if ((*(recbuf+1)&0x80)==0x80) //long format
{recbuf++;paralen++;len=*(recbuf+1);}
recbuf+=2;
paralen+=2;
recbuf+=len;
paralen+=len;
}
}//while
recbuf=bufbak;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -