init ems server code

This commit is contained in:
2024-09-27 15:39:34 +08:00
parent 9d4009aaca
commit 9930e4e58f
1551 changed files with 110216 additions and 102864 deletions

View File

@@ -0,0 +1,324 @@
/******************************************************/
/*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

View File

@@ -0,0 +1,165 @@
//////////////////////////////////////////////////
//Title : sccp_func.h
//Auhtor : Liu Wei
//Desc : SCCP function decl
//Created : 2007-04-22
//Revision :
//
//Revision :
//
//////////////////////////////////////////////////
/* sccp.c */
void sccp_init(void);
void sccp_init_serial_number(BYTE *Serial);
void sccp_timer(void);
void sccp_reset(void);
int AddToIpList(DWORD ip, BYTE ssn);
int CollectLocalInfo(void);
int sccp_mnp_register(BYTE flag, BYTE routing_method, BYTE usertype);
int spSetGttAddr(u8 uGtType, u8 uSSN, u8 *uGtNum, struct SCCP_ADDRESS *pSpAddr);
/* sccp_debug.c */
void spLogDebug_setup(void);
void spLogDebug_timer(void);
int parsecmd(char *cmdstr);
int sccp_filter_msg(SCCP_ADDR *pSrcAddr, SCCP_ADDR *pDstAddr);
void spLogDebug_info(BYTE npage, BYTE nline, BYTE *pt, BYTE len);
void spLogDebug_csta(BYTE npage, int instance);
void spLogDebug_local(BYTE npage, BYTE nline);
void spLogDebug_related(BYTE npage, BYTE nline);
void spLogDebug_buffer(BYTE npage);
void spLogDebug_errorCapture(BYTE npage, BYTE nline);
void spLogDebug_WatchDog(BYTE npage);
void sccp_list_route(void);
void sccp_put_capture_logs(BYTE person, BYTE *pictures, int len);
/* sccp_func.c */
int ParseLine(char *str, char (*row)[128], int maxrow);
int GetEnt(FILE *fp, char *key, char *str);
BOOL isco(Intra_Msg *intramsg);
BOOL iscl(Intra_Msg *intramsg);
BOOL iscr(Intra_Msg *intramsg);
/* sccp_gtt.c */
int BuildRouteIndex(void);
u_short SelectRoute(BYTE *pDigits, BYTE DigitsLen);
int GetACNInfo(SCCP_ADDR *pAddr, BYTE **pAcnInfo);
void TranslateGT(SCCP_ADDR *pAddr, SCCP_ROUTE *pRoute);
int AddRoute(BYTE *pStartDigits, BYTE *pEndDigits, BYTE DigitsLen, u_short index);
int AddLargerNode(SCCP_ROUTE_NODE *pNode, BYTE *pDigits, BYTE DigitsLen, u_short index);
int AddLessNode(SCCP_ROUTE_NODE *pNode, BYTE *pDigits, BYTE DigitsLen, u_short index);
SCCP_ROUTE_NODE *NewNode(void);
int CheckGT(BYTE np, BYTE tt, BYTE *gt, BYTE gt_len);
/* sccp_mib.c */
void sccpmib_init(void);
void sccp_sethb(void);
int sccp_setmib(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen);
int sccp_getmib(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype);
void sccp_OMCIP_detect(DWORD ip);
void sccp_trapcallback(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD len, snmp_addr *addr);
/* sccp_msg.c */
int build_msg(BYTE *buf, Intra_Msg *intramsg, BYTE NetID, BYTE ansi_flag);
int parse_msg(BYTE *buf, Intra_Msg *intramsg, int len, BYTE NetID, BYTE ansi_flag);
int parse_oparam(BYTE *buf, int len, Intra_Msg *intramsg, BYTE NetID, BYTE ansi_flag);
int encode_int(BYTE *buf, unsigned int val, BYTE len);
unsigned int decode_int(BYTE *buf, BYTE len);
int encode_addr(BYTE *buf, SCCP_ADDR *addr, BYTE NetID);
int decode_addr(BYTE *buf, SCCP_ADDR *addr, BYTE NetID);
int encode_addr_Ansi(BYTE *buf, SCCP_ADDR *addr);
int decode_addr_Ansi(BYTE *buf, SCCP_ADDR *addr);
/* sclc.c */
int scrc2sclc(Intra_Msg *pIntraMsg);
int sclc_rf(Intra_Msg *pIntraMsg);
int scmg2sclc(Intra_Msg *pIntraMsg);
int sclc_send(SCLC_MSG *pmsg);
int sclc_receive(SCLC_MSG *pmsg, BYTE usertype);
void sclc_timer(void);
int sclc_mnp_send(SCLC_MSG *pmsg);
int SegmentingMsg(Intra_Msg *pIntraMsg);
int RecvXUDTMsg(Intra_Msg *pIntraMsg, BYTE nbuf);
int CheckSegUnID(Intra_Msg *pIntraMsg);
int RsmRegMsg(SCLC_MSG *pmsg, SCCP_SegMsgBuf *pSegMsgbuf, Intra_Msg *pIntraMsg);
/* sccp_param.c */
int GetMSISDNOfSSN(BYTE ssn, BYTE *msisdn);
int sccp_GetSSNType(BYTE ssn);
int sccp_loadparam(void);
void sccp_saveparam(void);
int sccp_setparam(DWORD *oid, BYTE *pdata, WORD datalen);
int sccp_getparam(DWORD *oid, BYTE *pdata, BYTE *vartype);
int SccpGetLocalIP(void);
int ParseLocalNode(char *str);
void ParseRouteInfo(char *str);
void ParseRLSSN(char *str);
/* scmg.c */
void localssn_timer(void);
int sclc2scmg(Intra_Msg *intramsg);
BOOL CheckAvail(SCCP_ADDR *addr);
BYTE ssn_status(int spc, BYTE ssn, BYTE NetID);
void spac(int spc, BYTE NetID);
void sppc(int spc, BYTE NetID);
void spcc(int spc, BYTE NetID);
int register_ssn(BYTE ssn, BYTE usertype);
void ssac(int spc, BYTE ssn, BYTE NetID, BOOL relay);
void sscc(int spc, BYTE ssn, BYTE NetID);
int stop_ssn(BYTE ssn);
void sspc(int spc, BYTE ssn, BYTE NetID, BOOL relay);
void sst_timer(void);
void lcst(int spc, BYTE ssn, BYTE ntype, BYTE NetID);
void bcst(BYTE ssn, BYTE ntype);
void bcst_relay(int spc, BYTE ssn, BYTE ntype, BYTE NetID);
int build_scmgmsg(BYTE *data, BYTE type, int spc, BYTE ssn, BYTE NetID);
int parse_scmgmsg(BYTE *data, BYTE *type, int *spc, BYTE *ssn, BYTE NetID);
/* scrc.c */
void scrc_timer(void);
int scrc_route(Intra_Msg *pIntraMsg, BOOL ForceAnsi);
int scrc_mnp_route(Intra_Msg *pIntraMsg, BOOL ForceAnsi);
int send_msg(Intra_Msg *pIntraMsg, BYTE ansi_flag);
int scrc_rf(Intra_Msg *pIntraMsg, BYTE AnsiFlag);
DWORD SelectIPOfSSN(BYTE ssn, BYTE sls, BOOL from_mtp);
/* scoc_fsm.c */
void coFsm ( );
/* scoc_func.c */
void coInit ( u32 sysID, u32 localIP, u32 alterIP );
void cr2coFailHandle(Intra_Msg *pIntraMsg, u8 uAnsiFlag, u8 uMsgtype);
int cr2co(Intra_Msg *pIntraMsg, u8 uAnsiFlag);
void co2cr(u16 wConnId, u8 uMsgType);
void co2ul(u16 wConnId, u8 uPri);
void co2scmg(void);
void co2co(u16 wConnId, u8 uPri);
int spCheckAudit(void);
int coNewCS(u16 wConnId, SCCP_ADDR *pAddr);
void coFreeCS(u16 wConnId);
void coFillCS(SP_PriPoolEle *pPri);
int coCheckCS(u16 wConnId, u8 uCState, u8 uSide);
void coTimerOut(u16 wConnId, u8 uPri);
void coTimerMng(void);
int coNewConnId(u8 uPri);
int coGetConnId(u8 *pSLR);
extern inline int coCheckResource ( );
void spWatchDogStatic(u8 uDebugStaticMask);
/* sccp_log.c */
void spLog(char *info);
void spShowAddr(SCCP_ADDR *pAddr, const char *sAddrName);
void spLogDebug(DWORD mask, const char *fmt, ...);
void spShowBCD(DWORD mask, BYTE *buf, int len);
void spLogSeg(SCCP_SegMsgBuf *pSegMsgbuf);
void spShowMsg(DWORD mask, const char *pDesc, Intra_Msg *pIntraMsg);
void spShowPrimitive(SP_UiPriPara *pUiPriParam, u8 uDirection);
void spLogStateError(u16 wConnId, u8 uErrCode);
void spLogTimerOut(u16 wConnId, u8 uTimerID);
void spShowUserData(SP_UiPriPara *pPri);
/* scoc_pool.c */
void spPoolInit(void);
int spPoolGet(SP_PriPoolEle *pPri, CO_Pool *pCoPool);
int spPoolPut(SP_PriPoolEle *pPri, CO_Pool *pCoPool);

View File

@@ -0,0 +1,27 @@
//////////////////////////////////////////////////
//Title : sccp_pub.h
//Auhtor : Liu Wei
//Desc : SCCP public header
//Created : 2007-05-07
//Revision :
//
//Revision :
//
//////////////////////////////////////////////////
#ifndef _SCCP_PUB_H_
#define _SCCP_PUB_H_
#include "../../../public/src/include/includes.h"
#include "../../../public/src/include/public.h"
#include "../../../public/src/include/pub_debug.h"
#include "../../../public/src/include/pub_wnet.h"
#include "../../../public/src/include/pub_fmt.h"
#include "sccp.h"
#include "scoc.h"
#include "sccp_func.h"
#endif

View File

@@ -0,0 +1,510 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/io.h>
#include <netdb.h>
#include "scoc_if.h"
#include "../../../public/src/include/includes.h"
#ifndef _SCCP_CONST_DEF
#define _SCCP_CONST_DEF
#define SCCP_CONF_FILE "./conf/sccp.conf"
#define SINGLE_MODE 1
#define spLogDebug_MASK 0xFFFFFFFF
#define GetValueString(i,p,Maxtrix,IdMax) \
{ \
if( (i) >= (IdMax) ) \
{ \
(p) = Maxtrix[(IdMax)].pStr; \
} \
else \
{ \
(p) = Maxtrix[(i)].pStr; \
} \
}
typedef enum SCCP_WATCH_DOG
{
WDS_RECV_PRI,
}
SP_WatchDog;
#define SCCP_SHM_KEY 0x00116688
#define SCCP_SHM_PERM 0666
//#define SCCP_OID {1,3,6,1,4,1,1373,1,3,2,2,3}
#define SCCP_OID {1,3,6,1,4,1,1373,2,3,2,3}
#define SCCP_OIDLEN 11
#define SCCP_SERNUM_LEN 4
/*Message type-----> */
#define CR_MSG 1
#define CC_MSG 2
#define CREF_MSG 3
#define RLSD_MSG 4
#define RLC_MSG 5
#define DT1_MSG 6
#define DT2_MSG 7
#define AK_MSG 8
#define UDT_MSG 9
#define UDTS_MSG 10
#define ED_MSG 11
#define EA_MSG 12
#define RSR_MSG 13
#define RSC_MSG 14
#define ERR_MSG 15
#define IT_MSG 16
#define XUDT_MSG 17
#define XUDTS_MSG 18
#define LUDT_MSG 19
#define LUDTS_MSG 20
//Intra message type
#define RF_MSG 100
/*SCMG Message */
#define SSA_MSG 1 //subsystem allowed
#define SSP_MSG 2 //subsystem prohibited
#define SST_MSG 3 //subsystem status test
#define SOR_MSG 4 //subsystem out of service request
#define SOG_MSG 5 //subsystem out of service grant
#define SSC_MSG 6 //SCCP/subsystem congested
/*SCCP parameter name codes */
#define P_EOP 0
#define P_DLR 1
#define P_SLR 2
#define P_CDA 3
#define P_CGA 4
#define P_PLC 5
#define P_EOD 6
#define P_PR 7
#define P_SEQ 8
#define P_Credit 9
#define P_RLC 10
#define P_RTC 11
#define P_RSC 12
#define P_ERC 13
#define P_RFC 14
#define P_Data 15
#define P_SEG 16
#define P_HC 17
#define P_Importance 18
#define P_Ldata 19
//////////////////////////////////////////////////
#define SCCP_SSN_NUM 256
#define SCCP_RLSSN_NUM 128
#define SCCP_RLSPC_NUM 64
#define SCCP_ROUTE_NUM 1024
#define SCCP_ROUTE_NODE_NUM 65535
#define LR_NUM 1024
#define LR_MSG_NUM 50
#define SS_MSG_NUM 1024
#define SLS_NUM 16
#define SCCP_MSG_MAXLEN 256
#define MAX_HC 15
#define SCOC_SSN 10
#define Unrestricted 1
#define Restricted 0
#define RI_GT 0 //Route on GT
#define RI_SSN 1 //Route on SSN
#define NP_IMSI 6
#define NP_MSISDN 1
#define NP_GT 7
#define TT_0 0
#define TT_1 1
#define TT_4 4
//message source---->
#define FROM_MTP 1
#define FROM_SCLC 2
#define FROM_SCOC 3
#define FROM_SCMG 4
//subsystem number
#define SSN_NOTUSE 0
#define SSN_SCMG 1
#define SSN_ITU 2 //reserved for ITU-T allocation
#define SSN_ISUP 3
#define SSN_OMC 4
#define SSN_MAP 5
#define SSN_HLR 6
#define SSN_VLR 7
#define SSN_MSC 8
#define SSN_EIC 9 //Equipment Identifier Certer
//scoc state
#define SCOC_IDLE 0
#define SCOC_CPO 1 //connection pending outgoing
#define SCOC_CPI 2 //connection pending incoming
#define SCOC_CPMID 3 //connection pending(intermediate node)
#define SCOC_WCC 4 //Wait connection confirm
#define SCOC_ACTIVE 5 //Active
#define SCOC_MID 6 //Active(intermediate node)
#define SCOC_DP 7 //disconnect pending
#define SCOC_DPMID 8 //disconnect pending(intermediate node)
#define SCOC_Interval 20*1000 //20ms
//Timer (SCMG)
#define T_idle 30 //(s)
#define T_sst 2 //20s interval = 10s
#define T_hbrecv 3 //30s interval = 10s
//#define SST_Start 0
//#define SST_Pend 1
//#define SST_Stop 2
//SP/SCCP/SS status
#define ST_Disable 1
#define ST_Congest 2
#define ST_Enable 3
#define SCCPDB_TCAP 0x01
#define SCCPDB_UDT 0x02
#define SCCPDB_AIF 0x04
#define SCCPDB_ERR 0x08
#define SCCPDB_SCMG 0x10
#define SCCPDB_TIME 0x20
#define SCCPDB_SNMP 0x40
#define SCCPDB_MSG 0x80
#define SCCPDB_ADDR 0x100
#define SCCPDB_STP 0x1000
#define SCCPDB_USER 0x2000
#define SCCPDB_MTP3 0x4000
#define SCCPDB_XUDT 0x8000
/*******************Release cause*******************/
#define RL_EUO 0 //end user originated
#define RL_EUC 1 //end user congestion
#define RL_EUF 2 //end user failure
#define RL_SUO 3 //SCCP user originated
#define RL_RPL 4 //remote procedure error
#define RL_ICD 5 //inconsistent connection data
#define RL_AF 6 //access failure
#define RL_AC 7 //access congestion
#define RL_SF 8 //subsystem failure
#define RL_SC 9 //subsystem congestion
#define RL_MF 10 //MTP failure
#define RL_NC 11 //network congestion
#define RL_EORT 12 //expiration of reset timer
#define RL_EORIT 13 //expriation of receive inactivity timer
#define RL_R 14 //reserved
#define RL_U 15 //unqualified
#define RL_SCCPF 16 //SCCP failure
/*******************return cause*******************/
#define RT_NTFN 0 //no translation for an address of such nature
#define RT_NTFA 1 //no translation for this specific address
#define RT_SC 2 //subsystem congestion
#define RT_SF 3 //subsystem failure
#define RT_UU 4 //unequipped user
#define RT_MF 5 //MTP failure
#define RT_NF 6 //network congestion
#define RT_U 7 //unqulified
#define RT_EIMT 8 //error in message transport
#define RT_EILP 9 //error in local processing
#define RT_DCPR 10 //destination cannot perform reassembly
#define RT_SCCPF 11 //SCCP failure
#define RT_HCV 12 //hop counter violation
#define RT_SNS 13 //segmentation not supported
#define RT_SMTF 14 //segmentation failure
/*******************reset cause*******************/
#define RS_EUO 0 //end user originated
#define RS_SUO 1 //SCCP user originated
#define RS_IPS 2 //incorrect P(S)
#define RS_IPR 3 //incorrect P(R)
#define RS_OFW 4 //remote procedure error-message out of window
#define RS_IPSAI 5 //remote procedure error-incorrect P(S) after initialization
#define RS_G 6 //remote procedure error-general
#define RS_REUO 7 //remote end user operational
#define RS_NO 8 //network operational
#define RS_AO 9 //access operational
#define RS_NC 10 //network congestion
#define RS_R 11 //reserved
#define RS_U 12 //unqualified
#endif
static const StringVal spUlPrimitiveStr[] =
{
{N_UNITDATA_REQ , "N-Unit Data Request "},
{N_UNITDATA_IND , "N-Unit Data Indicate "},
{N_NOTICE_IND , "N-Notice Indicate "},
{N_CONNECT_REQ , "N-Connect Request "},
{N_CONNECT_IND , "N-Connect Indicate "},
{N_CONNECT_RSP , "N-Connect Response "},
{N_CONNECT_CFM , "N-Connect Confirm "},
{N_DISCONNECT_REQ, "N-Disconnect Request "},
{N_DISCONNECT_IND, "N-Disconnect Indicate"},
{N_DATA_REQ , "N-DATA Request "},
{N_DATA_IND , "N-DATA Indicate "},
{N_DATAAK_REQ , "N-DataAk Request "},
{N_DATAAK_IND , "N-DataAk Indicate "},
{N_EDATA_REQ , "N-EData Request "},
{N_EDATA_IND , "N-EData Indicate "},
{N_RESET_REQ , "N-Reset Request "},
{N_RESET_IND , "N-Reset Indicate "},
{N_RESET_RSP , "N-Reset Response "},
{N_RESET_CFM , "N-Reset Confirm "},
{N_INFORM_REQ , "N-Inform Request "},
{N_INFORM_IND , "N-Inform Indicate "},
{SPUI_PRI_MAX , "Unknow SCCP Primitive"},
};
#define spGetUlPrimitiveStr(e,p)\
WxcAssert( (e) < SP_PRI_MAX ,\
"spGetUlPrimitiveStr Primitive id error" );\
GetValueString(e,p,spUlPrimitiveStr,SPUI_PRI_MAX)
typedef enum SCOC_MESSAGE_TYPE
{
SP_MSG0_RESERVED, /* Reserved */
SP_MSG_CR = 1, /* connection request */
SP_MSG_CC = 2, /* connection confirm */
SP_MSG_CREF = 3, /* connection refused */
SP_MSG_RLSD = 4, /* release request */
SP_MSG_RLC = 5, /* release confirm */
SP_MSG_DT1 = 6, /* Data Form 1 */
SP_MSG_DT2 = 7, /* Data Form 2 */
SP_MSG_AK = 8, /* Data acknowledge */
SP_MSG_UDT = 9, /* Unit data */
SP_MSG_UDTS = 10, /* Unit data */
SP_MSG_ED = 11, /* Expedited data */
SP_MSG_EA = 12, /* Expedited data acknowledge */
SP_MSG_RSR = 13, /* Reset request */
SP_MSG_RSC = 14, /* Reset confirm */
SP_MSG_ERR = 15, /* PDU error */
SP_MSG_IT = 16, /* Inactivity test */
SP_MSG_XUDT = 17, /* XUDT */
SP_MSG_XUDTS= 18, /* XUDTS */
SP_MSG_LUDT = 19, /* LUDT */
SP_MSG_LUDTS= 20, /* LUDTS */
SP_MSG_RF = 21, /* Routing Fail */
SP_MSG_MAX , /* MAX message type undefine */
}
CO_MsgType;
static const StringVal sp_messagetype_str[] =
{
{SP_MSG0_RESERVED, " Message Reserved" },
{SP_MSG_CR, " Connection request" },
{SP_MSG_CC, " Connection confirm" },
{SP_MSG_CREF, " Connection refused" },
{SP_MSG_RLSD, " Release request" },
{SP_MSG_RLC, " Release confirm" },
{SP_MSG_DT1, " Data Form 1" },
{SP_MSG_DT2, " Data Form 2" },
{SP_MSG_AK, " Data acknowledge" },
{SP_MSG_UDT, " Unit data" },
{SP_MSG_UDTS, " Unit data service" },
{SP_MSG_ED, " Data acknowledge" },
{SP_MSG_EA, " EData acknowledge" },
{SP_MSG_RSR, " Reset request" },
{SP_MSG_RSC, " Reset confirm" },
{SP_MSG_ERR, " PDU error" },
{SP_MSG_IT, " Inactivity test" },
{SP_MSG_XUDT, " XUDT" },
{SP_MSG_XUDTS, " XUDTS" },
{SP_MSG_LUDT, " LUDT" },
{SP_MSG_LUDTS, " LUDTS" },
{SP_MSG_RF , " Routing Fail" },
{SP_MSG_MAX, " Undefine" },
};
#define spGetMsgStr(MsgId,pStr)\
WxcAssert( (MsgId) >= SP_MSG_CR && (MsgId) < SP_MSG_MAX ,\
"spGetMsgStr MsgId error" );\
GetValueString(MsgId,pStr,sp_messagetype_str,SP_MSG_MAX)
//temp define , define in pub_base.h
#define STR(s) #s
#define FILL_VALSTR(n) {n,#n}
static const StringVal spTimerOutStr[] =
{
FILL_VALSTR(T_CONNEST_OUT),
FILL_VALSTR(T_IAS_OUT),
FILL_VALSTR(T_IAR_OUT),
FILL_VALSTR(T_REPEATE_RLS_OUT),
FILL_VALSTR(T_RLS_OUT),
FILL_VALSTR(T_RESET_OUT),
FILL_VALSTR(T_GUARD_OUT),
FILL_VALSTR(T_INTERNAL_OUT),
FILL_VALSTR(SPTM_PRI_MAX),
};
#define spGetTimerOutStr(MsgId,pStr)\
WxcAssert( (MsgId) >= T_CONNEST_OUT && (MsgId) < SPTM_PRI_MAX ,\
"spGetTimerOutStr MsgId error" );\
GetValueString(((MsgId)-SPCR_PRI_MAX-1),pStr,spTimerOutStr,SPTM_PRI_MAX)
#define T_UNDEFINE 100000
#define T_SP_10ms 1
#define T_SP_1s T_SP_10ms*100
#define T_SP_1MIN T_SP_1s*60
#define T_CONNEST_MAX T_SP_1s*2 //1~2 sec
#define T_IAS_MAX T_SP_1MIN*5 //5~10 mins
#define T_IAR_MAX T_SP_1MIN*11 //11~21 mins
#define T_RLS_MAX T_SP_1s*15 //10~20 sec
#define T_REPEATE_RLS_MAX T_SP_1s*15 //10~20 sec
#define T_RESET_MAX T_SP_1s*15 //10~20 sec
#define T_GUARD_MAX T_SP_1MIN*24 //23~25 mins
#define T_INTERNAL_MAX T_SP_1MIN //1 mins
typedef enum SCOC_TRANSITION_STATUS
{
CO_STATUS_INIT, //Transtion initialed
CO_STATUS_IDLE, //status Idle
CO_STATUS_WTCC, //Wait Connection confirm
CO_STATUS_ACTV, //Active
CO_STATUS_CONP, //Connection pending
CO_STATUS_CPIC, //Connection pending incoming
CO_STATUS_CPOG, //Connection pending outgoing
CO_STATUS_DSCP, //Disconnect pending
CO_STATUS_DPIC, //Disconnect pending incoming
CO_STATUS_DPOG, //Disconnect pending outgoing
CO_STATUS_DPBH, //Disconnect pending both
CO_STATUS_NMOP, //Normal operation
CO_STATUS_WSEA, //Wait for sending EA Message
CO_STATUS_RSIC, //Reset outgoing
CO_STATUS_RSOG, //Reset incoming
CO_STATUS_RSBH, //Reset both
CO_STATUS_MTBK, //Maintenance blocking
CO_STATUS_RSTA, //Restart
CO_STATUS_MAX,
}
CO_Status;
static const StringVal sp_co_state_str[] =
{
{CO_STATUS_INIT, "Transtion initialed" },
{CO_STATUS_IDLE, "status Idle" },
{CO_STATUS_WTCC, "Wait Connection confirm" },
{CO_STATUS_ACTV, "Active" },
{CO_STATUS_CONP, "Connection pending " },
{CO_STATUS_CPIC, "Connection pending incoming"},
{CO_STATUS_CPOG, "Connection pending outgoing"},
{CO_STATUS_DSCP, "Disconnect pending" },
{CO_STATUS_DPIC, "Disconnect pending incoming"},
{CO_STATUS_DPOG, "Disconnect pending outgoing"},
{CO_STATUS_DPBH, "Disconnect pending both" },
{CO_STATUS_NMOP, "Normal operation" },
{CO_STATUS_WSEA, "Wait for sending EA Message"},
{CO_STATUS_RSIC, "Reset outgoing" },
{CO_STATUS_RSOG, "Reset incoming" },
{CO_STATUS_RSBH, "Reset both" },
{CO_STATUS_MTBK, "Maintenance blocking" },
{CO_STATUS_RSTA, "Restart" },
{CO_STATUS_MAX, "Error Transtion state" },
};
#define spGetCoStateStr(s,p)\
WxcAssert( (s) < CO_STATUS_MAX ,\
"spGetCoStateStr co status error" );\
GetValueString(s,p,sp_co_state_str,CO_STATUS_MAX)
typedef enum CO_INSTANCE_SIDE
{
CO_INST_SIDE_ORG,
CO_INST_SIDE_DST,
CO_INST_SIDE_MID,
CO_INST_SIDE_MAX,
}
CO_InstSide;
static const StringVal sp_co_instanceside_str[] =
{
{CO_INST_SIDE_ORG, "Originating node side" },
{CO_INST_SIDE_DST, "Destination node side" },
{CO_INST_SIDE_MID, "intermidediate node side"},
{CO_INST_SIDE_MAX, "Undefine Node Side" },
};
#define spGetCoInstanceSide(s,p)\
WxcAssert( (s) < CO_INST_SIDE_MAX ,\
"spGetCoInstanceSide co sideid error" );\
GetValueString(s,p,sp_co_instanceside_str,CO_INST_SIDE_MAX)
static const StringVal co_reason_str[] = {
//reason : originated network serice provider
{REA_PDISC_ACNN,
"disconnection <20>Cabnormal condition(non-transient nature)" },
{REA_PDISC_ACTN, "disconnection <20>Cabnormal condition of transient nature"},
{REA_PDISC_IS, "disconnection <20>Cinvalid state1" },
{REA_PDISC_RIP, "disconnection <20>Crelease in progress1" },
{REA_PCREF_DAU, "CREF2 <20>Cdestination address unknown " },
{REA_PCREF_DINC,
"CREF2 <20>Cdestination inaccessible/non-transient condition" },
{REA_PCREF_DITCs, "CREF2 <20>Cdestination inaccessible/transient condition" },
{REA_PCREF_QNANC, "CREF2 <20>CQOS not available/non-transient condition" },
{REA_PCREF_QNATC, "CREF2 <20>CQOS not available/transient condition" },
{REA_PCREF_RUNC, "CREF2 <20>Creason unspecified/non-transient condition" },
{REA_PCREF_RUTC, "CREF2 <20>Creason unspecified/transient condition" },
{REA_PCREF_LE, "CREF2 <20>Clocal error1" },
{REA_PCREF_IS, "CREF2 <20>Cinvalid state1" },
{REA_PCREF_NT, "CREF2 <20>Cno translation1" },
{REA_PCREF_IRP, "CREF2 <20>Cin restart phase1" },
{REA_PCREF_HCV, "CREF2 <20>Chop counter violation" },
//reason : originated network serice user
{REA_UDISC_NC, "disconnection <20>Cnormal condition" },
{REA_UDISC_ABC, "disconnection <20>Cabnormal condition" },
{REA_UDISC_EUC, "disconnection <20>Cend user congestion" },
{REA_UDISC_EUF, "disconnection <20>Cend user failure" },
{REA_UDISC_SUO, "disconnection <20>CSCCP user originated" },
{REA_UDISC_ACC, "disconnection <20>Caccess congestion" },
{REA_UDISC_AF, "disconnection <20>Caccess failure" },
{REA_UDISC_SC, "disconnection <20>Csubsystem congestion" },
{REA_UCREF_NTC, "CREF2<EFBFBD>Cnon-transient condition" },
{REA_UCREF_TC, "CREF2<EFBFBD>Ctransient condition" },
{REA_UCREF_IIIN, "CREF2<EFBFBD>Cincompatible information in NSDUs" },
{REA_UCREF_EUO, "CREF2<EFBFBD>Cend user originated" },
{REA_UCREF_EUC, "CREF2<EFBFBD>Cend user congestion" },
{REA_UCREF_EUF, "CREF2<EFBFBD>Cend user failure" },
{REA_UCREF_SUO, "CREF2 <20>CSCCP user originated" },
{REA_UCREF_ACC, "CREF2 <20>Caccess congestion" },
{REA_UCREF_AF, "CREF2 <20>Caccess failure" },
{REA_UCREF_SC, "CREF2 <20>Csubsystem congestion" },
//Notice service reason : N-inform values
{REA_NINFO_FAIL, "work service provider failure" },
{REA_NINFO_CONG, "work service congestion" },
{REA_NINFO_PQC, "work service provider QOS change" },
{REA_UINFO_FAIL, "work service user failure" },
{REA_UINFO_CONG, "work service user congestion" },
{REA_UINFO_PQC, "work service user QOS change" },
{REA_INFO_USPC, "reason unspecified" },
{REA_UNDEFINED, "Undefined" },
};
#define coGetReasonStr(r,p)\
WxcAssert( (r) >= REA_PDISC_ACNN && (r) < REA_UNDEFINED ,\
"coGetReasonStr reason id error" );\
GetValueString(r,p,co_reason_str,REA_UNDEFINED)
typedef enum SCOC_INTERNAL_ERROR
{
CO_FATAL_STATE,
CO_FATAL_SIDE,
}
CO_InterErr;

View File

@@ -0,0 +1,274 @@
//////////////////////////////////////////////////
//Title : scoc.h
//Auhtor : Liu Wei
//Desc : SCCP Connection-Oriented Control
//Created : 2007-04-22
//Revision :
//
//Revision :
//
//////////////////////////////////////////////////
#ifndef _SCOC_H_
#define _SCOC_H_
#include "scoc_if.h"
#include "../../../public/src/include/pub_list.h"
#define spLogDebug_STATIC
typedef struct SCCP_PRIMITIVE_CR_PRIMITIVE
{
u8 uUiPri;
u8 uAnsiFlag;
u16 wConnId;
Intra_Msg tIntraMsg;
}
SP_CrPriPara;
typedef union SCCP_PRIMITVE_POOL_Elemnet
{
SP_UiPriPara tUiPri;
SP_CrPriPara tCrPri;
}
SP_PriPoolEle;
typedef enum SCOC_FSM_ERROR
{
ERR_NONE, //show state string
ERR_FSM_DISCARD,
ERR_FSM_ERROR,
ERR_FSM_FATAL,
ERR_FSM_UNEXPECT_SIDE,
ERR_FSM_RESERVED,
ERR_FSM_UNEXPECT_PRI,
ERR_FSM_UNKOWN_ERROR_CODE,
ERR_TIMER_OUT,
}
CO_FsmErr;
typedef struct SCOC_QOS
{
u8 uInSequence;
u8 uReturnOnErr;
u8 uImportance;
u8 uHopcount;
u8 uMbit;
u8 uRecvSequnce;
u8 uSendSequnce;
}
CO_Qos;
typedef struct SCOC_CAUSE
{
u8 uRelCause;
u8 uReturnCause;
u8 uResetCause;
u8 uErrorCause;
u8 uRejectCause;
}
CO_Cause;
#define MAX_SCCP_MSG 256
typedef struct SCOC_Message
{
u8 uMsgType;
u8 uMsgClass;
u8 uMsgFlag;
u8 aSLR[SP_REF_LEN]; // 0x01 SLR present
u8 aDLR[SP_REF_LEN]; // 0x02 DLR present
SCCP_ADDR tCDA; // 0x04 CDA present
SCCP_ADDR tCGA; // 0x08 CGA present
CO_Qos tQos; // 0x10 QOS present
CO_Cause tCause; // 0x20 CAUSE present
u8 aMsgConent[MAX_SCCP_MSG]; // 0x40 DATA present
}
CO_Msg;
typedef struct CO_TIMER
{
u32 tmConnEst;
u32 tmIas;
u32 tmIar;
u32 tmRepeatRel;
u32 tmRel;
u32 tmReset; //unsupportted now
u32 tmGuard; //unsupportted now
//u32 tmIas;
//u32 tmIar;
//u32 tmIT;
u32 tmInternal;
}
CO_Timer;
typedef struct CO_CONNECTION_Section
{
CO_Status uCState;
SP_Pri uPri;
u8 uAnsiFlag;
CO_InstSide uSide;
u8 uSLS;
u8 uNetId;
int nDPC;
int nOPC;
u8 aSLR[SP_REF_LEN];
u8 aDLR[SP_REF_LEN];
u8 uClass;
u8 uCredit;
u8 eREA;
u8 eOR;
SCCP_ADDR tCDA;
SCCP_ADDR tCGA;
SCCP_ADDR tSPA;
SP_UD tUD;
CO_Timer tmSCOC;
}
CO_ConnSection;
typedef struct SCOC_POOL_PRIMITIVE_IN
{
}
CO_PoolPriIn;
typedef struct SCLC_DATA_BLOCK
{
}
CL_DataBlock;
typedef struct SCRC_DATA_BLOCK
{
}
CR_DataBlock;
typedef struct SCMG_DATA_BLOCK
{
}
CM_DataBlock;
#define CO_CS_MPORT 8192
#ifdef DEBUG
typedef enum SCOC_DEBUG_STATIC_VALUE
{
GET_IN_POOL = 30,
PUT_IN_POOL,
READ_IN_POOL,
WRITE_IN_POOL,
GET_OUT_POOL,
PUT_OUT_POOL,
PUT_ELE_APT,
PUT_ELE_SUC,
UL_POST_CO_APT,
UL_POST_CO,
CO_SUBMIT_UL_APT,
CO_SUBMIT_UL,
CO_TO_CR_APT,
CO_TO_CR,
CR_TO_CO_APT,
CR_TO_CO,
SP_TIMER_OUT,
}
CO_DebugStaticVal;
typedef struct SCOC_DEBUG_STATIC
{
u32 dGetInPool;
u32 dPutInPool;
u32 dReadInPool;
u32 dWriteInPool;
u32 dGetOutPool;
u32 dPutOutPool;
u32 dPutEleApt;
u32 dPutEleSuc;
u32 dCoSubmitUlApt;
u32 dCoSubmitUl;
u32 dUlPostCoApt;
u32 dUlPostCo;
u32 dCo2CrApt;
u32 dCo2Cr;
u32 dCr2CoApt;
u32 dCr2Co;
u32 dTimerOut;
u32 dbusyElem;
}
CO_DebugStatic;
#endif
typedef struct SCOC_DATA_BLOCK
{
u32 wConnIdCount;
CO_ConnSection tCSInst[CO_CS_MPORT];
CO_DebugStatic tCoDebugStatic;
}
CO_DataBlock;
typedef struct SCCP_ENTITY
{
u32 dLocalIP;
u32 dAlterIP;
u32 dSysID;
CL_DataBlock tCl;
CO_DataBlock tCo;
CR_DataBlock tCr;
CM_DataBlock tCm;
}
SP_Entity;
/* by simon at 23/9/26 */
extern SP_Entity tSpEntity;
extern SP_Entity *pSp;
typedef enum SCOC_POOL_OP
{
CO_GET_POOL,
CO_READ_POOL,
CO_PUT_POOL,
CO_WRITE_POOL,
}
CO_PoolOp;
typedef struct SCOC_POOL_ELEMENT
{
POOL_ENTRY ( SCOC_POOL_ELEMENT ) tPointer;
SP_PriPoolEle tPri;
BYTE flag;
}
CO_PoolEle;
typedef struct SCOC_POOL
{
POOL_HEAD ( CO_PriPool, SCOC_POOL_ELEMENT ) tPoolHead;
struct CO_PriPool *pPoolHead;
int uMaxPoolSize;
int uPoolCount;
}
CO_Pool;
#define MAX_IN_POOL 1024
#define MAX_OUT_POOL 512
extern CO_Pool *pInCoPool;
extern CO_Pool *pOutCoPool;
#endif

View File

@@ -0,0 +1,559 @@
//////////////////////////////////////////////////
//Title : SCCP_if.h
//Auhtor : Liu Wei
//Desc : SCOC interface header
//Created : 2007-05-07
//Revision :
//
//Revision :
//
//////////////////////////////////////////////////
#ifndef _SCCP_IF_H_
#define _SCCP_IF_H_
#include "../../../public/src/include/public.h"
#define MAX_DIGITS 10
#define SP_REF_LEN 3
///////////////////////////////////////////////////
typedef struct SCCP_ADDRESS
{
DWORD ip;
int DPC;
BYTE NetID;
BYTE SSN;
BYTE RI;
BYTE GTI;
BYTE TT;
BYTE NP;
BYTE ES;
BYTE NAI;
BYTE len;
BYTE GTAI[MAX_DIGITS];
BYTE AI;
}
SCCP_ADDR;
typedef enum SCCP_LI_MTP_PRIMITIVE
{
MTP_TARNSFER,
MTP_RESUME,
MTP_STATUS,
MTP_UPU,
}
SP_LiMTPPri;
typedef enum SCCP_UI_N_PRIMITIVE
{
N_UNITDATA_REQ,
N_UNITDATA_IND,
N_NOTICE_IND,
N_CONNECT_REQ,
N_CONNECT_IND,
N_CONNECT_RSP,
N_CONNECT_CFM,
N_DISCONNECT_REQ,
N_DISCONNECT_IND,
N_DATA_REQ,
N_DATA_IND,
N_DATAAK_REQ,
N_DATAAK_IND,
N_EDATA_REQ,
N_EDATA_IND,
N_RESET_REQ,
N_RESET_IND,
N_RESET_RSP,
N_RESET_CFM,
N_INFORM_REQ,
N_INFORM_IND,
SPUI_PRI_MAX,
R_CR , /* connection request */
R_CC , /* connection confirm */
R_CREF , /* connection refused */
R_RLSD , /* release request */
R_RLC , /* release confirm */
R_DT1 , /* Data Form 1 */
R_DT2 , /* Data Form 2 */
R_AK , /* Data acknowledge */
R_UDT , /* Unit data */
R_UDTS , /* Unit data */
R_ED , /* Expedited data */
R_EA , /* Expedited data acknowledge */
R_RSR , /* Reset request */
R_RSC , /* Reset confirm */
R_ERR , /* PDU error */
R_IT , /* Inactivity test */
R_XUDT , /* XUDT */
R_XUDTS, /* XUDTS */
R_LUDT , /* LUDT */
R_LUDTS, /* LUDTS */
R_RF , /* Routing Fail */
R_RLS_ERR, /* Release err */
R_CR2 , /* connection request type 2 */
SPCR_PRI_MAX , /* MAX CR2CO Primitive */
T_CONNEST_OUT,
T_IAS_OUT,
T_IAR_OUT,
T_REPEATE_RLS_OUT,
T_RLS_OUT,
T_RESET_OUT,
T_GUARD_OUT,
T_INTERNAL_OUT,
SPTM_PRI_MAX,
N_CONNECT_T1,
RELAY,
TRAFFIC,
NO_TRAFFIC,
I_DISCONNECT,
I_RESET,
I_CONGESTED,
I_UNCONGESTED,
I_RESET_REQ,
SP_PRI_MAX,
}
SP_Pri;
/*
* /SCOC upper layer primitive parameters
*
* /CDA : Called address CGA : Calling address
* /CI : Connection identification
* /CRS : Confirm request slecttion
* /EDS : Expedited data selection
* /QOS : Quality of service parameter set
* /OR : Originator RA : Responding address
* /RCS : Receipt confirmation selection
* /REA : Reason OR : Originator
* /RR : Return Resaon SEQ : Sequence Control
* /UD : User data RO : Return Optinal selection
*
*/
typedef struct SCCP_QUALITY_OF_SERVICE
{
//reserved
u8 uQOS;
}
SP_QOS; //Quality of service parameter set
typedef enum SCCP_ORIGINATOR
{
NSP, //the network service provider
NSU, //the network service user
UNDEFINED, //undefined
}
SP_OR; //Originator
typedef struct SCCP_REQUEST_CONFIRM_SELECTION
{
//reserved
u8 uRCS;
}
SP_RCS; //Confirm request slecttion
/*
* Reason parameter
*
* Note: coGetReasonStr(u8 Reason , char *pReasonStr)
*
*/
typedef enum SCCP_REASON
{
//reason : originated network serice provider
REA_PDISC_ACNN, //Disconn <20>Cabnormal condition of non-transient nature
REA_PDISC_ACTN, //Disconn <20>Cabnormal condition of transient nature
REA_PDISC_IS, //Disconn <20>Cinvalid state1
REA_PDISC_RIP, //Disconn -release in progress1
REA_PCREF_DAU, //CREF <20>Cdestination address unknown(non-transient condition)
REA_PCREF_DINC, //CREF2 <20>Cdestination inaccessible/non-transient condition
REA_PCREF_DITCs, //CREF2 <20>Cdestination inaccessible/transient condition
REA_PCREF_QNANC, //CREF2 <20>CQOS not available/non-transient condition
REA_PCREF_QNATC, //CREF2 <20>CQOS not available/transient condition;
REA_PCREF_RUNC, //CREF2 <20>Creason unspecified/non-transient condition
REA_PCREF_RUTC, //CREF2 <20>Creason unspecified/transient condition;
REA_PCREF_LE, //CREF2 <20>Clocal error1;
REA_PCREF_IS, //CREF2 <20>Cinvalid state1;
REA_PCREF_NT, //CREF2 <20>Cno translation1;
REA_PCREF_IRP, //CREF2 <20>Cin restart phase1;
REA_PCREF_HCV, //CREF2 <20>Chop counter violation.
//reason : originated network serice user
REA_UDISC_NC, //Disconn <20>Cnormal condition;
REA_UDISC_ABC, //Disconn <20>Cabnormal condition;
REA_UDISC_EUC, //Disconn <20>Cend user congestion;
REA_UDISC_EUF, //Disconn <20>Cend user failure;
REA_UDISC_SUO, //Disconn <20>CSCCP user originated;
REA_UDISC_ACC, //Disconn <20>Caccess congestion;
REA_UDISC_AF, //Disconn <20>Caccess failure;
REA_UDISC_SC, //Disconn <20>Csubsystem congestion;
REA_UCREF_NTC, //CREF2 -non-transient condition;
REA_UCREF_TC, //CREF2 -transient condition;
REA_UCREF_IIIN, //CREF2 -incompatible information in NSDUs;
REA_UCREF_EUO, //CREF2 -end user originated;
REA_UCREF_EUC, //CREF2 -end user congestion;
REA_UCREF_EUF, //CREF2 -end user failure;
REA_UCREF_SUO, //CREF2 <20>CSCCP user originated;
REA_UCREF_ACC, //CREF2 <20>Caccess congestion;
REA_UCREF_AF, //CREF2 <20>Caccess failure;
REA_UCREF_SC, //CREF2 <20>Csubsystem congestion.
//Notice service reason : N-inform values
REA_NINFO_FAIL, //N-Inform <20>C network service provider failure;
REA_NINFO_CONG, //N-Inform <20>C network service congestion;
REA_NINFO_PQC, //N-Inform <20>C network service provider QOS change;
REA_UINFO_FAIL, //N-Inform <20>C network service user failure;
REA_UINFO_CONG, //N-Inform <20>C network service user congestion;
REA_UINFO_PQC, //N-Inform <20>C network service user QOS change;
REA_INFO_USPC, //N-Inform <20>C reason unspecified.
REA_UNDEFINED, //undefined
}
SP_REA; //Reason
typedef struct SCCP_RETURN_OPTINAL
{
//reserved
u8 uRO;
}
SP_RO; //return Optinal
typedef struct SCCP_RETURN_REASON
{
//reserved
u8 uRR;
}
SP_RR; //Return Reason
typedef struct SCCP_SEQUENCE
{
//reserved
u8 uSEQ;
}
SP_SEQ; //Sequence control
#define SP_MAX_UD 256
typedef struct SCCP_USER_DATA
{
u8 uDataLen;
u8 aUserData[SP_MAX_UD];
}
SP_UD; //User data
typedef union SCCP_UI_PRIMITIVE_UNION
{
struct PriNUnitDataReq //reserved for sclc ,not used now
{
u8 uSLS;
SP_SEQ tSEQ;
SCCP_ADDR tCDA;
SCCP_ADDR tCGA;
SP_RO tRO;
SP_UD tUD;
}
tPriNUDataReq;
struct PriNUnitDataInd //reserved for sclc ,not used now
{
u8 uSLS;
SP_UD tUD;
SCCP_ADDR tCDA;
SCCP_ADDR tCGA;
}
tPriNUDataInd;
struct PriNNoticeInd //reserved for sclc ,not used now
{
SP_RR tRR;
SP_UD tUD;
SCCP_ADDR tCDA;
SCCP_ADDR tCGA;
}
tPriNNoticeInd;
struct PriNConnectReq
{
//Mandatory
SCCP_ADDR tCDA;
SP_QOS tQOS;
//Optianal
u8 uOptFlag;
u8 tEDS;
u8 uImp;
SCCP_ADDR tCGA;
SP_UD tUD;
}
tPriNConnReq;
struct PriNConnectInd
{
//Mandatory
SCCP_ADDR tCDA;
SP_QOS tQOS;
u8 aSLR[SP_REF_LEN];
u8 uSLS;
u32 OPC;
u8 NetID;
//Optianal
u8 uOptFlag;
u8 uImp;
SCCP_ADDR tCGA;
SP_UD tUD;
}
tPriNConnInd;
struct PriNConnectRsp
{
//Mandatory
SP_QOS tQOS;
//Optianal
u8 uOptFlag;
u8 tEDS;
u8 uImp;
SCCP_ADDR tRA;
SP_UD tUD;
}
tPriNConnRsp;
struct PriNConnectCfm
{
//Mandatory
SP_QOS tQOS;
//Optianal
u8 uOptFlag;
u8 uImp;
SCCP_ADDR tRA;
SP_UD tUD;
}
tPriNConnCfm;
struct PriNDisconnectReq
{
//Mandatory
//SP_OR eOR; //always NSU
SP_REA eREA;
//Optianal
u8 uOptFlag;
u8 uImp;
SCCP_ADDR tRA;
SP_UD tUD;
}
tPriNDisconnReq;
struct PriNDisconnectInd
{
//Mandatory
SP_OR eOR;
SP_REA eREA;
//Optianal
u8 uOptFlag;
u8 uImp;
SCCP_ADDR tRA;
SP_UD tUD;
}
tPriNDisconnInd;
struct PriNDataReq
{
//Mandatory
SP_UD tUD;
//Optianal
u8 uImp;
}
tPriNDataReq;
struct PriNDataInd
{
//Mandatory
SP_UD tUD;
//Optianal
u8 uImp;
}
tPriNDataInd;
struct PriNDataAkReq
{
}
tPriNDataAkReq;
struct PriNDataAkInd
{
}
tPriNDataAkInd;
struct PriNEDataReq
{
SP_UD tUD;
}
tPriNEDataReq;
struct PriNEDataInd
{
SP_UD tUD;
}
tPriNEDataInd;
struct PriNResetReq
{
//SP_OR tOR; //always NSU
SP_REA eREA;
}
tPriNResetReq;
struct PriNResetInd
{
SP_REA eREA;
SP_OR tOR;
}
tPriNResetInd;
struct PriNResetRsp
{
}
tPriNResetRsp;
struct PriNResetCfm
{
}
tPriNResetCfm;
struct PriNInformReq
{
SP_SEQ tQOS;
SP_REA eREA;
}
tPriNInformRsp;
struct PriNInformInd
{
SP_SEQ tQOS;
SP_REA eREA;
}
tPriNInformInd;
}
SP_UiPriUnion;
typedef struct SCCP_UI_PRIMITIVE_PARAMETERS
{
u8 uUiPri;
u8 uAnsiFlag;
u16 wConnId; //return by SCCP while PostSp for N_CONN_REQ
SP_UiPriUnion tPriUnion;
}
SP_UiPriPara;
///////////////////////////////////////////////////////////////////////////
//
// Name : PostSp
// Function : Upper layer post request/response primitive to sccp
// Parameter: pUiPriParam [sccp UL primitive buffer pointer]
// Note : Sccp Connid is implicit returned in "pUiPriParam" buffer
// : while N-Connect requesing
// Return : 0 Post Fail 1 Post Successful
//
///////////////////////////////////////////////////////////////////////////
int PostSp ( SP_UiPriPara * pUiPriParam );
///////////////////////////////////////////////////////////////////////////
//
// Name : SpSubmit
// Function : Upper layer fetch indicate/confirm primitive submited form sccp
// Parameter: pUiPriParam [sccp UL primitive buffer pointer]
// Return : 0 Fetch Fail 1 Fetch Successful
//
///////////////////////////////////////////////////////////////////////////
int SpSubmit ( SP_UiPriPara * pUiPriParam, u8 uUlSapId );
/////////////////////Below is reserved, do not need to read/////////////////////
/*
* \Inter-Layer Communication interface mode
* \
* \Loose coupling mode :
* interface implementation based on message pool engine
* \Tight coupling mode :
* interface implementation based on function call and callback
*
* \Note : In order to be compatible with old user , use Loose coupling mode now
*
*/
#define LOOSE_COUPLING_MODE 0 //Loose coupling mode
//#define TIGHT_COUPING_MODE
#ifdef LOOSE_COUPLING_MODE //Loose coupling mode
#else
#ifdef TIGHT_COUPING_MODE //Tight coupling mode
#error "Do not support Tight coupling mode ,please use \"LOOSE_COUPLING_MODE\" flag \n"
/*
* \CFS(CallBack function Set) for SCCP sumbit primitives to SCCP user
*
* \The following Callback Fucntion set define the mapping of the primitives
* \which is submited to SCCP serivce user(s). It is used in tight coupling mode.
*
* \User A : Reserved for ISUP
* \User B : Q.711 Page 2 user part B not define
* \User C : Other SCCCP user e.g. AIF
*/
typedef struct SCCP_SUBMIT_USERA_CFS
{
//For Isup ,Not supported now
}
SP_UserA_CFS;
typedef struct SCCP_SUBMIT_USERB_CFS
{
//NULL Undefined in Q.711
}
SP_UserB_CFS;
typedef struct SCCP_SUBMIT_USERC_CFS
{
void ( *spCBUi_N_UnitDataInd ) ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_UD * pUD );
void ( *spCBUi_N_NoticeInd ) ( SCCP_ADDR * pCDA, SCCP_ADDR * pCGA, SP_RR * pRR, SP_UD * pUD );
void ( *spCBUi_N_ConnectInd ) ( SP_QOS * pQOS, SP_UD * pUD, u8 uCI );
void ( *spCBUi_N_ConnectCfm ) ( SP_QOS * pQOS, SP_UD * pUD, u8 uCI );
void ( *spCBUi_N_DisconnectInd ) ( SP_OR * pOR, SP_OR * pRA, SP_REA * pREA, SP_UD * pUD, u8 uCI );
void ( *spCBUi_N_DataInd ) ( );
void ( *spCBUi_N_DataAkInd ) ( );
void ( *spCBUi_N_EDataInd ) ( );
void ( *spCBUi_N_ResetInd ) ( SP_OR * pOR, SP_REA * pREA, u8 uCI );
void ( *spCBUi_N_ResetCfm ) ( );
void ( *spCBUi_N_InformInd ) ( );
}
SP_UserC_CFS;
#endif
#endif
/////////////////////Above is reserved, do not need to read/////////////////////
#endif