
/******************************************************/
/*Title:   sccp.h                                     */
/*Descr:   Definition of SCCP                         */
/*Author:  Liang Hanxi                                */
/*Create:  2002-2-19                                  */
/******************************************************/

#ifndef _SCCP_HEAD_FILE
#define _SCCP_HEAD_FILE

#include "../../../public/src/include/pub_wnet.h"
#include "../../../snmp/src/include/heartbeat.h"
#include "../../../snmp/src/include/snmp.h"
#include "../../../debug/src/include/debug.h"
#include "../../../mtp3/src/include/mtp3.h"
#include "sccpconst.h"

#ifdef _WXC_FSM_TEST
#define spLogFsm printf
#define spWxcBackTrace() WxcBackTrace()
#else 
#define spLogFsm
#define spWxcBackTrace() 
#endif 

#define	MAX_SCLC_BUF	4

#define SCCP_VERSION	    { 9,1,5}

//////////////////////////////////////////////////////////////////
#define SEG_RS_LEN 3

typedef struct SCCP_Segmnt
{
    unsigned RSBits:4;
    unsigned SpaceBits:2;
    unsigned CBit:1;
    unsigned FBit:1;
    u8 SegLR[SEG_RS_LEN];
}
SCCP_Segmnt;

typedef struct SCCP_SegUnID
{
    int OPC;
    int DPC;
    u8 SLS;
    SCCP_ADDR CGA;
    u8 SegLR[SEG_RS_LEN];
}
SCCP_SegUnID;

#define MAX_SEGBLOCK_LEN   256

typedef struct SCCP_SegStream
{
    u8 SegDataLen;
    u8 SegDataBlock[MAX_SEGBLOCK_LEN];
}
SCCP_SegStream;

#define MAX_SEGSTREAM_SIZE 10
#define MAX_SEGMSG_TIMER   2000
#define SEGSTREAM_IDLE     0x00
#define SEGSTREAM_BUSY     0x01

typedef struct SCCP_SegMsgBuf
{
    u8 MsgState;
    u8 MsgClass;
    u8 MsgTotal;
    DWORD SegMsgTimer;
    u8 RSE;

    SCCP_SegUnID SegID;
    SCCP_SegStream SegStream[MAX_SEGSTREAM_SIZE];

}
SCCP_SegMsgBuf;

#define MAX_SEGMSG_BUF 256
/* by simon at 23/9/26 */
//SCCP_SegMsgBuf sccp_segmsgbuf[MAX_SEGMSG_BUF];

typedef struct Intra_Message
{
    u8 msgsource;             //FROM_MTP:0,FROM_SCLC:1,FROM_SCOC:2,FROM_SCMG:3
    u8 msgtype;
    u8 msgclass;

    u8 msgMNP;                /* mnp flag , added by pierre , 11-07 */
    int OPC;
    int DPC;
    u8 SLS;
    u8 link;
    u8 NetID;
    SCCP_ADDR CGA;
    SCCP_ADDR CDA;
    BOOL EOD;
    u8 aSLR[SP_REF_LEN];
    u8 aDLR[SP_REF_LEN];
    u_short msglen;
    u8 data[SCCP_MSG_MAXLEN];
    u8 PS;
    u8 PR;
    u8 RO;
    u8 cause;
    u8 Hop;
    SCCP_Segmnt Segmnt;         //
    u8 SegPresent;
	u8 redirectFlag;
	u8 sequenceFlag;
}
Intra_Msg;

//Intra_Msg             CurMsg;

typedef struct SCCP_OPT
{
    DWORD ip;
    long spc[4];
    u8 spclen[4];
    u8 version[3];
    u8 status;
    u8 RegSSN[32];
    u8 RegNum;
    u8 CO_SSN;
    long T_reset;
    DWORD OMCIP[2];
}
SCCP_OPT;

/* by simon at 23/9/26 */
// SCCP_OPT SCCP_Param;

typedef struct _SCOC_BUF
{
    short rcvsub[2];
    short sndsub[2];
    up_message msgin[SS_MSG_NUM];
    up_message msgout[SS_MSG_NUM];
}
SCOC_BUF;

/* by simon at 23/9/26 */
// SCOC_BUF ScocBuf;

#define MAX_SCLCMSG_LEN 256

typedef struct SCLC_MSG
{
	u8 primitive;
    u8 msg[MAX_SCLCMSG_LEN];
    u_short msglen;
    u8 sls;
	u8 sequence_control;	//Class 0:	The basic connectionless class without guaranteed in-sequence delivery
							//Class 1:	The in-sequence delivery connectionless class with guaranteed in-sequence delivery
	u8 ret_reason;
    SCCP_ADDR src_addr;
    SCCP_ADDR dst_addr;
}
SCLC_MSG;

typedef struct _SCLC_BUF
{
    short readsub;
    short writesub;
    SCLC_MSG msglist[SS_MSG_NUM];
}
SCLC_BUF;

typedef struct LOCAL_SSN
{
    u8 msisdn[MAX_DIGITS];
    u8 status[2];             //0:no 1:equipped(disable)  2:congest 3:enable 4:local&equipped(disable)  5:local&congest 6:local&enable
    u8 nbuf;
    u8 local;
    u8 NetID;
    u8 RegFlag;
    DWORD ip[2];
    short timeout[2];
    u8 msisdn_len;
}
LOCAL_SSN;

/* by simon at 23/9/26 */
// LOCAL_SSN LocalSSN[256];
// u8 ExistSSN[64];
// u8 ExistSSNNum;

// u8 MNP_Flag[2];

/* by simon at 23/9/26 */
// struct _dpc2sls
// {
// 	int dpc;
// 	u8	sls;
// }dpc2sls[256];	//used for sequence control, add by Roy Jiang, 2007-09-17

/* u80:0/1/2=not support MNP/IN_based/MNP_SRF */
/* u81:0-1/2=direct/indirect routing */
/* added by Pierre, 2005-11-07 for MNP */

/*===================================*/
//MIB===================>

/*===================================*/

typedef struct SCCP_ROUTE
{
    u8 avail;
    u8 NP;
    u8 TT;
    u8 StartDigits[MAX_DIGITS];
    u8 EndDigits[MAX_DIGITS];
    u8 NetID;
    u8 DPC[3];
    u8 SSN;
    u8 RI;
    u8 AI;                    //Address indicator,indicate the Address include GT,DPC,SSN or not,BIT0:point code, bit1:ssn, bit2:GT
    u8 ReplaceStart;
    u8 ReplaceEnd;
    u8 OutNP;
    u8 ReplaceDigits[MAX_DIGITS];
    u8 acn_ver[48];
    u8 convert;
    u8 len;
    u8 replace_len;
}
SCCP_ROUTE;

/* by simon at 23/9/26 */
// SCCP_ROUTE RouteList[SCCP_ROUTE_NUM];

typedef struct SCCP_ROUTE_NODE
{
    u_short nItem;
    struct SCCP_ROUTE_NODE *psub[10];
}
SCCP_ROUTE_NODE;

typedef struct RL_SSN
{
    BOOL status;                //0 NULL
    u8 SST;
    u8 NetID;
    u8 SSN;
    int DPC;
    int timeout;
}
RL_SSN;

/* by simon at 23/09/26 */
// int RelatedSSNNum;
// RL_SSN RelatedSSN[SCCP_RLSSN_NUM];

typedef struct RL_SPC
{
    int DPC;
    u8 NetID;
    BOOL status;                //0 NULL 
}
RL_SPC;

/* by simon at 23/09/26 */
// int RelatedSPCNum;
// RL_SPC RelatedSPC[SCCP_RLSPC_NUM];

#define SCCP_MAX_GTT_ATTRIBUTE		16
typedef struct GTTATT_OMC
{
    u8 attribute[SCCP_MAX_GTT_ATTRIBUTE];
}
GTTATT_OMC;
/* by simon at 23/9/26 */
// GTTATT_OMC GTTAttribute[SCCP_ROUTE_NUM];

typedef struct SCCP_FILTER
{
    u8 flag;
    u8 src_ssn;
    u8 dst_ssn;
    int opc;
    int dpc;
}
SCCP_FILTER;

typedef struct SCCP_CSTA
{
    DWORD timestamp;
    DWORD error[21];            //.1.1.?
    DWORD avail[12];            //.1.2.?
    DWORD utilization[12];      //.1.3.?
    DWORD quality[20];          //.1.4.?
}
SCCP_CSTA;

/* by simon at 23/9/26 */
// SCCP_CSTA SccpCsta[96];
// DWORD SccpCstaInd;

/* by simon at 23/9/26 */
// struct sccp_msg_statistic
// {
//     DWORD msg_mtp_scoc;
//     DWORD msg_scoc_up;
//     DWORD mnp_send;
//     DWORD mnp_route;
// }
// sccpmsg_st;

typedef struct SCCP_Capture_Buf
{
    u8 Pointer;
    u8 Buffer[2560];
    u8 watch_dog[256];
}
SCCP_Capture_Buf;
/* by simon at 23/9/26 */
// SCCP_Capture_Buf SCCPCapBuf;


#endif
