⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svdisp.cpp

📁 七号信令解码器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*******************************************************
Update History:
2000.06.14:适应NT和Unix版本
2000.09.29:clearBUFRECDATA()
********************************************************/
#include "stdafx.h"

////////////////////////
#define BYTEOFACUIN 0
#define BYTEOFAPIN 0
#define BYTEOFCHGIN 0
#define initreclen 0
#define initrecoff initreclen+4
#define maxmsglen 290  //max message length of BUFRECDATA
#define minmsglen 12   //min message length of BUFRECDATA
#define PASS 0xff
#define maxreclen 7900
#define debug 1
#define bc 0
#define SS7MODE 0

#define MAXHISDISPBUFFER 10  //消息显示最大BUFFER数
#define MAXDISPLAYPAGE 80 //消息显示最大页数
#define MAX_NUM_OF_STATION			9		//9节点机
#define MAX_NUM_LINK_IN_NODE		256		//
///////////////////////////////
unsigned char recno=0;
extern WORD Version;
extern BYTE BUFDISPLAY[0xffff];
BYTE BUFRECDATA[0x9ffff];
BYTE BUFDISPDATA[0x9ffff];
BYTE bufrealmsg[400*1024];
WORD dispmsgno=0;
WORD displen;
BYTE *recbuf,*dispbuf;
WORD scrollreclength=initreclen;
//////////////////////////
int msgType = 0;
int msgKind  = 0;
int subMsg = 0;
int CurSel;
///////////////////
extern BYTE MESSCRI2(BYTE *msg,BYTE *crit);
BYTE		LinkSel[MAX_NUM_OF_STATION][MAX_NUM_LINK_IN_NODE];  //the real links number
extern BYTE BUFMESSCRITERIA1[];
extern BYTE BUFMESSCRITERIA2[];
extern unsigned char TELCAPTURE,realnostep;
extern BOOL			byShowControl;		//used to indicate ss7 thread that scorll or hold

extern void procSCCPdisp(WORD slen);
extern void procISUPdisp(WORD slen);


void procaddr(BYTE ab,BYTE noa,BYTE fldno)
{
  BYTE c,temp;

  *dispbuf++ = fldno;
  temp = (noa+1)/2;
  *dispbuf++ = temp;
  displen += temp;
  for (c=0;c<temp;c++)
	 *dispbuf++ = *(recbuf+c);
  if (ab)  noa--;    //if AADDR NOA dec 1
  *dispbuf++ = noa<<2;      //disp bit len
  temp = noa/2;
  if (temp !=0)//if NOA>=2
	 {c=temp;
	  displen += temp;
	  while (c!=0)
		{*dispbuf++ =((*recbuf&0x0f)<<4)|((*recbuf&0xf0)>>4);
		 recbuf++;
		 c--;
		}//while
	 }//if NOA>=2
  temp = noa%2;
  if (temp !=0)
//NOA is odd
	 { temp = *recbuf&0x0f;
       recbuf++;
	  *dispbuf++ = temp<<4;
	  displen++;
	 }//if
  else if(ab) recbuf++;
  *dispbuf++ =0xcc;
  displen +=4;
}


void procauliddisp(BYTE fldno)
{
  BYTE temp1,temp2;

//AIN:D3-D0
  *dispbuf++ = fldno;
  *dispbuf++ =1;
  temp1 = temp2 = *recbuf++;
  *dispbuf++ =temp2;
  *dispbuf++ =4;
  *dispbuf++ =temp1<<4;
  *dispbuf++ =0xcc;
//NOA:D7-D4
  fldno++;
  *dispbuf++ = fldno;
  *dispbuf++ =0;
  *dispbuf++ =4;
  temp2 &= 0xf0;
  *dispbuf++ = temp2;
  *dispbuf++ =0xcc;
  displen +=11;
//AADDR
  fldno++;
  if (temp2 !=0)//NOA !=0
	{temp2= temp2>>4;
	 procaddr(1,temp2,fldno);
	}
}


void procobuliddisp(BYTE fldno)
{
  BYTE temp1;

//AIN:D3-D0
  *dispbuf++ = fldno;
  *dispbuf++ =1;
  *dispbuf++ =temp1 = *recbuf++;
  *dispbuf++ =4;
  *dispbuf++ =temp1<<4;
  *dispbuf++ =0xcc;
//NOA:D7-D4
  fldno++;
  *dispbuf++ = fldno;
  *dispbuf++ =0;
  *dispbuf++ =4;
  *dispbuf++ = temp1&0xf0;
  *dispbuf++ =0xcc;
  displen +=11;
//ADDR
  fldno++;
  if ((temp1&0xf0) !=0)//NOA !=0
	{temp1=temp1 >>4;
	 procaddr(0,temp1,fldno);
	}
}

void procmoredatadisp(WORD mlen)
{
  WORD	i;

  if(mlen>272) return;

  *dispbuf++ = 0xfe;     //illegal data field No
  *(WORD *)dispbuf = mlen;//illegal data len:2byte
  dispbuf += 2;
  for (i=0;i<mlen;i++)
	*dispbuf++ = *recbuf++;
  *dispbuf++ = 0xcc;

  displen+=mlen+4;
}

void procDPCOPCSLC14disp()
{ WORD temp16;
  BYTE temp1;
 //process DPC
	 *dispbuf++ = 7;
	 *dispbuf++ = 2;
	 *dispbuf++ = *recbuf;
	 *dispbuf++ = *(recbuf+1);
	 *dispbuf++ =16;
	 *dispbuf++ = *(recbuf+1) & 0x3f;
	 *dispbuf++ = *recbuf;
	 *dispbuf++ = 0xcc;
//process OPC
	 *dispbuf++ = 8;
	 *dispbuf++ =2;
	 *dispbuf++ = *(recbuf+2);
	 *dispbuf++ = *(recbuf+3);
	 temp16 = (*(recbuf+1)>>6) + *(recbuf+2)*4 + (*(recbuf+3)&0x0f)*1024;  //get opc(14bits)
	 *dispbuf++ = 16;
	 *dispbuf++=HIBYTE(temp16);
	 *dispbuf++=LOBYTE(temp16);
	 *dispbuf++ = 0xcc;
//process SLC:D3-D0
	 *dispbuf++ = 9;
	 *dispbuf++ = 0;
	 *dispbuf++ = 4;
	 temp1 = *(recbuf+3);
	 *dispbuf++ = temp1<<4;
	 *dispbuf++ = 0xcc;
	 recbuf+=4;
	 displen+=21;
}



void proc24bitsdisp(BYTE dfieldno)
{
	*dispbuf++ = dfieldno;
	*dispbuf++ = 3; 				//source data byte 
	*dispbuf++ = *recbuf;       //source data
	*dispbuf++ = *(recbuf+1);
	*dispbuf++ = *(recbuf+2);
	*dispbuf++ =24;				//display bit len:24
	*dispbuf++ = *(recbuf+2);
	*dispbuf++ = *(recbuf+1);
	*dispbuf++ = *recbuf;
	*dispbuf++ = 0xcc;			//end flag
    recbuf+=3;
	displen+=10;
}
void proc8bitsdisp(BYTE dfieldno)
{
	*dispbuf++ = dfieldno;
	*dispbuf++ = 1; 			//source data byte 
	*dispbuf++ = *recbuf;      //source data
	*dispbuf++ =8;				//display bit len:8
	*dispbuf++ = *recbuf++;
	*dispbuf++ = 0xcc;			//end flag
    displen+=6;
}

void procdisplay(char * msg)
{
	if(msg == NULL)
		return ;
  WORD slen,i,temp16,time,olen;
  BYTE temp1,temp2,dfieldno,is24bits,c,noa,*bufbak;

  recbuf =  (unsigned char*)msg;
  dispbuf = BUFDISPLAY;
  slen = (*recbuf + *(recbuf+1)*256)&0xfff;  //get message length(low 12bits)
  recbuf+=2;     //recbuf-->message source

  Version=0xff;
   displen = 1;

  dispbuf += displen+3;

  WORD msgchannel =256*((*(recbuf+1))&0x7f)+(*recbuf);
	bool b2M=(((*(recbuf+1))&0x80)>0);

  *dispbuf++ = msgchannel%256;     //display message channel No.(L)
  *dispbuf++ = msgchannel/256;     //display message channel No.(H,high 4bits is Node No)
  recbuf+=2;

  bufbak=dispbuf;  //single message len
  dispbuf += 2;	   //reserved for single len:2bytes

  dispmsgno++;
  *dispbuf++ = LOBYTE(dispmsgno); //display message No(L)
  *dispbuf++ = HIBYTE(dispmsgno); //display message No(H)

  *(WORD *)dispbuf = 0;  		 //reserved for display:2byte
  dispbuf +=2;


//msg time:display area:5bytes,rec area:4byte
  time=*recbuf+*(recbuf+1)*256;  //get num of minute
  recbuf+=2;
  *dispbuf++ = time/60;  //hour
  *dispbuf++ = time%60;  //minute
  time=*recbuf+*(recbuf+1)*256;  //get num of ms
  recbuf+=2;
  *dispbuf++ = time/1000;  //second
  time %= 1000;
  *dispbuf++ = LOBYTE(time);  //ms(L)
  *dispbuf++ = HIBYTE(time);  //ms(H)

  displen = 9;             //display length is 9
  slen -=6;               //5byte of time + source

  dfieldno=0;					/*display field No init to 0*/
  if(b2M)
  {
  for (c=0;c<2;c++)
	{
/*process BIB+BSN/FIB+FSN*/
	 dfieldno++;
	 *dispbuf++ = dfieldno;
	 *dispbuf++ = 1;           /*source data byte*/
	 *dispbuf++ = 0;		 /*get BIB(1)+BSN(7)*/
	 *dispbuf++ = 7;           /*display bit length*/
	 temp1=0;           /*get BIB(1)+BSN(7)*/
	 *dispbuf++ = temp1<<1;        /*display data(7)*/
	 *dispbuf++ =0xcc;         /*sub field end*/

	 dfieldno++;
	 *dispbuf++ = dfieldno;
	 *dispbuf++ = 0;           /*source length:0*/
	 *dispbuf++ = 1;           /*display bit length:1*/
	 temp1=0;         /*get BIB(1)+BSN(7)*/
	 *dispbuf++ =0;   /*display data(1)*/
	 *dispbuf++ =0xcc;         /*sub field end*/

	 displen += 11;
	 recbuf+=2;
	}/*for*/

  }
  else
  {
  for (c=0;c<2;c++)
	{
/*process BIB+BSN/FIB+FSN*/
	 dfieldno++;
	 *dispbuf++ = dfieldno;
	 *dispbuf++ = 1;           /*source data byte*/
	 *dispbuf++ = *recbuf;		 /*get BIB(1)+BSN(7)*/
	 *dispbuf++ = 7;           /*display bit length*/
	 temp1=*recbuf;           /*get BIB(1)+BSN(7)*/
	 *dispbuf++ = temp1<<1;        /*display data(7)*/
	 *dispbuf++ =0xcc;         /*sub field end*/

	 dfieldno++;
	 *dispbuf++ = dfieldno;
	 *dispbuf++ = 0;           /*source length:0*/
	 *dispbuf++ = 1;           /*display bit length:1*/
	 temp1=*recbuf++;         /*get BIB(1)+BSN(7)*/
	 *dispbuf++ = temp1&0x80;   /*display data(1)*/
	 *dispbuf++ =0xcc;         /*sub field end*/

	 displen += 11;
	}/*for*/

  }
  slen -= 2;					/*dec 2bytes:bsn+fsn*/

  if(b2M)
  {
	  temp1 = 0x3f;         /*LI to temp*/
	  recbuf+=2;
  }
  else
  {
	  temp1 = *recbuf++;         /*LI to temp*/
  }

  slen--;

  msgType = temp1;
  if(temp1<=0x3f)
	{
/*process LI*/
	 dfieldno++;
	 *dispbuf++ = dfieldno;
	 *dispbuf++ = 1;           /*source data byte*/
	 *dispbuf++ = temp1;		    /*LI*/
	 *dispbuf++ = 6;           /*display bit length:6*/
	 *dispbuf++ = temp1<<2;        /*display data(6)*/
	 *dispbuf++ =0xcc;         /*sub field end*/
	 displen += 6;          /*add 6 byte*/

	 if (temp1==0)/*FISU*/
	  {
		 *dispbuf++ = *(recbuf+1);  /*get con Fisu Counter*/
		 *dispbuf++ = *recbuf;
		 *dispbuf++ = 0xcc;
		 displen +=3;
	  }
	 else if (temp1 <=2)/*LSSU*/
	  {
		 temp1 = *recbuf;					/*get SF*/
		 if (temp1<=5)
		  {
/*process SF*/
			dfieldno++;
			proc8bitsdisp(dfieldno);

		   *dispbuf++ = *(recbuf+1);  /*get con Fisu Counter*/
		   *dispbuf++ = *recbuf;
		   *dispbuf++ = 0xcc;
		   displen +=3;

		  }
		 else if(slen!=0)
			procmoredatadisp(slen);

	  }/*LSSU*/
	 else if (slen!=0)/*MSU*/
	  {

/*process SIO*/
		dfieldno++;
		temp1=temp2= *recbuf; 		/*get SIO*/

		temp1 &= 0x0f;         /*get SI*/
		subMsg = temp1;
		switch (temp1)
		 {
		  case 0:/*SNM*/
/*process DPC/OPC/SLC*/
		    proc8bitsdisp(dfieldno);
			slen--;
			temp1 = temp2&0xf0;       /*get SSF*/
			if (temp1==0xc0 && slen>5)     /*DPC/OPC is 14bits*/
			  {procDPCOPCSLC14disp();
				dfieldno +=3;
				slen -= 4;
				is24bits=0;
			  }/*DPC/OPC is 14bits*/
			else if (temp1!=0xc0 && slen>8) /*DPC/OPC is 24bits*/
			  {
/*process dpc:24bits*/
				proc24bitsdisp(7);  /*display fld:7*/
/*process opc:24bits*/
				proc24bitsdisp(8);  /*display fld:8*/
/*process slc:D3-D0,4bits*/
				*dispbuf++ = 9;           /*display fld:9*/
				*dispbuf++ = 1; 				/*source data byte */
				temp1 = *recbuf++;
				*dispbuf++ = temp1;       /*source data*/
				*dispbuf++ =4;				/*display bit len:24*/
				*dispbuf++ = temp1<<4;
				*dispbuf++ = 0xcc;			/*end flag*/
				displen += 6;

				slen -= 7;
				is24bits=1;
			  }/*DPC/OPC is 14bits*/
			else /*illegal data*/
			  {procmoredatadisp(slen);
			   break;
			  }

/*proc H1H0*/
			  dfieldno=10;
			  temp1 = *recbuf;  //get H1H0
			  proc8bitsdisp(10);  /*display fld:10*/

			  slen--;

			  if(slen!=0)
				{
				 switch(temp1)
				  {
					case 0x11:/*COO*/
					case 0x21:/*COA*/
/*COOFSN:7BITS*/
					 *dispbuf++ = 11;     /*display fld:11*/
					 *dispbuf++ =1;
					 temp1=*recbuf;
					 *dispbuf++ = temp1;
					 *dispbuf++ =7;
					 *dispbuf++ = temp1<<1;
					 *dispbuf++ = 0xcc;
					 displen +=6;
					 break;

					case 0x51:/*CBD*/
					case 0x61:/*CBA*/
/*CHANGE BACK CODE(8bits)*/
					 proc8bitsdisp(11);  /*display fld:11*/
					 break;

					case 0x14:/*TFP*/
					case 0x54:/*TFA*/
					case 0x34:/*TFR*/
					case 0x15:/*RSM*/
					 if(is24bits==1)/*destination:24bits*/
					    proc24bitsdisp(11);  /*display fld:11*/
					 else  /*destination:14bits*/
					  {*dispbuf++ = 11;
						*dispbuf++ =2;
						*dispbuf++ = *recbuf;
						*dispbuf++ = *(recbuf+1);
						*dispbuf++ =14;
						*dispbuf++ = *recbuf;
						*dispbuf++ = *(recbuf+1);
						*dispbuf++ =0xcc;
						displen +=8;
					  }
					 break;

					case 0x18:/*DLC*/
/*Signal Data Link IDentity-12bits)*/
					 *dispbuf++ = 11;    /*display fld:11*/
					 *dispbuf++ =2;
					 temp16 = *(WORD *)recbuf;
					 *(WORD *)dispbuf = temp16;
					 dispbuf +=2;
					 *dispbuf++ =12;
					 *(WORD *)dispbuf = temp16*16;
					 dispbuf +=2;
					 *dispbuf++ =0xcc;
					 displen +=8;

					 break;

					case 0x23:/*TFC*/
					 if(is24bits==1)/*destination:24bits*/
					    proc24bitsdisp(11);  /*display fld:11*/
					 else /*destination:14bits*/
					  {*dispbuf++ = 11;
						*dispbuf++ =2;
						*dispbuf++ = *recbuf;
						*dispbuf++ = *(recbuf+1);
						*dispbuf++ =14;
						*dispbuf++ = *recbuf;
						*dispbuf++ = *(recbuf+1);
						*dispbuf++ =0xcc;
						displen +=8;
					  }
/*status:2bits*/
					 *dispbuf++ = 12;              /*display fld:12*/
					 *dispbuf++ =1;
					 *dispbuf++ = *recbuf;
					 *dispbuf++ =2;
					 *dispbuf++ = (*recbuf)<<6;
					 *dispbuf++ =0xcc;
					 displen +=6;
					 break;

					case 0x1a:/*UPU*/
					 if(is24bits==1)/*destination:24bits*/
					    proc24bitsdisp(11); /*display fld:11*/
					 else /*destination:14bits*/
					  {*dispbuf++ = 11;   /*display fld:11*/
						*dispbuf++ =2;
						*dispbuf++ = *recbuf;
						*dispbuf++ = *(recbuf+1);
						*dispbuf++ =14;
						*dispbuf++ = *recbuf;
						*dispbuf++ = *(recbuf+1);
						*dispbuf++ =0xcc;
						displen +=8;
					  }
/*user part id:4bits*/
					 *dispbuf++ = 12;
					 *dispbuf++ =1;
					 *dispbuf++ = *recbuf;
					 *dispbuf++ =4;
					 *dispbuf++ = (*recbuf)<<4;
					 *dispbuf++ =0xcc;
					 displen +=6;

					 break;
					default:
					 break;
				  }/*switch:h1h0*/
				 }/*if slen!=0*/

			  break;

		  case 1:/*SNT*/
/*process DPC/OPC/SLC*/
		    proc8bitsdisp(dfieldno);
			slen--;
			temp1 = temp2&0xf0;       /*get SSF*/
			if (temp1==0xc0 && slen>5)     /*DPC/OPC is 14bits*/
			  {procDPCOPCSLC14disp();
				dfieldno +=3;
				slen -= 4;
				is24bits=0;
			  }/*DPC/OPC is 14bits*/
			else if (temp1!=0xc0 && slen>8) /*DPC/OPC is 24bits*/
			  {
/*process dpc:24bits*/
				proc24bitsdisp(7);  /*display fld:7*/
/*process opc:24bits*/
				proc24bitsdisp(8);  /*display fld:8*/
/*process slc:D3-D0,4bits*/
				*dispbuf++ = 9;           /*display fld:9*/
				*dispbuf++ = 1; 				/*source data byte */
				temp1 = *recbuf++;
				*dispbuf++ = temp1;       /*source data*/
				*dispbuf++ =4;				/*display bit len:24*/
				*dispbuf++ = temp1<<4;
				*dispbuf++ = 0xcc;			/*end flag*/
				displen += 6;

				slen -= 7;
				is24bits=1;
			  }/*DPC/OPC is 14bits*/
			else /*illegal data*/
			  {procmoredatadisp(slen);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -