📄 cngpdef.h
字号:
/******************************************************************
ModuleName: SMGW Client API
FileName: cngpdef.h
DESCRIPTION: CNGP Protocol Message Definition
History:
Date Version Modifier Activies
2003/08/18 1.0 Li Jianfu Create
********************************************************************/
#ifndef _CNGP_DEFINE_H_
#define _CNGP_DEFINE_H_
#ifdef _WIN32
#pragma pack(push,1)
#elif defined _AIX
#pragma options align=packed
#elif defined _HPUX
#pragma pack 1
#else
#pragma pack (1)
#endif
/********************************************************************
The Macro Definition
********************************************************************/
/* The SMGW Client Version */
#define CNGP_CLIENT_VERSION 0x10
/*#define CNGP_CLIENT_VERSION10_OK*/
/* The Maximal Length Of Short Message */
#define MAX_SM_LEN 254
#define MAX_SM_CUT_NUM 100
/*The Maximal number of DestTermID*/
#define MAX_DEST_TERM_NUM 100
#define CNGP_CONFIG_ICP_LEN 10
#define CNGP_CONFIG_PASSWORD_LEN 16
#define CNGP_CONFIG_WITHPREVPAGE_LEN 20
#define CNGP_CONFIG_WITHNEXTPAGE_LEN 20
#define CNGP_CONFIG_IPADDRESS_LEN 25
/* The Short Message Request ID */
#define REQUEST_ID_LOGIN 0x00000001
#define REQUEST_ID_LOGIN_RESP 0x80000001
#define REQUEST_ID_SUBMIT 0x00000002
#define REQUEST_ID_SUBMIT_RESP 0x80000002
#define REQUEST_ID_DELIVER 0x00000003
#define REQUEST_ID_DELIVER_RESP 0x80000003
#define REQUEST_ID_ACTIVE_TEST 0x00000004
#define REQUEST_ID_ACTIVE_TEST_RESP 0x80000004
#define REQUEST_ID_EXIT 0x00000006
#define REQUEST_ID_EXIT_RESP 0x80000006
//#define REQUEST_ID_QUERY 0x00000007
//#define REQUEST_ID_QUERY_RESP 0x80000007
/* Need Reply Yes Or No */
#define NEED_REPLY_YES 1
#define NEED_REPLY_NO 0
#define NEED_REPLY_MAX 128
#define NEED_REPLY_MIN 0
/* Need Report Yes Or No */
#define NEED_REPORT_YES 1
#define NEED_REPORT_NO 0
/* nMsgFormat Macro */
#define MSG_FORMAT_ASCII 0
#define MSG_FORMAT_WRITE_CARD 3
#define MSG_FORMAT_BINARY 4
#define MSG_FORMAT_UCS2 8
#define MSG_FORMAT_GB 15
#define MSG_FORMAT_PASSWORD 100
/* Fee Type Macro */
#define FEE_FREE "0"
#define FEE_BY_ITEM "1"
#define FEE_BY_MONTH "2"
#define FEE_BY_MAXINUM "3"
/* Login Mode */
#define LOGIN_SEND_MODE 0
#define LOGIN_RECV_MODE 1
#define LOGIN_TRANSMIT_MODE 2
/* Submit Priority */
#define SUBMIT_PRIORITY_LOWEST 0
#define SUBMIT_PRIORITY_NORMAL 1
#define SUBMIT_PRIORITY_ABOVE_NORMAL 2
#define SUBMIT_PRIORITY_HIGHEST 9
/* Message Status */
#define MESSAGE_STATUS_DELIVERED 0
#define MESSAGE_STATUS_EXPIRED 1
#define MESSAGE_STATUS_DELITED 2
#define MESSAGE_STATUS_UNDELIVERABLE 3
#define MESSAGE_STATUS_ACCEPTED 4
#define MESSAGE_STATUS_UNKNOW 5
/* CNGP Error Code */
#define CNGP_ERROR_CODE_OK 0
#define CNGP_ERROR_CODE_INVALIDE_PACKET 1
#define CNGP_ERROR_CODE_LOGIN_FAIL 2
#define CNGP_ERROR_CODE_INVALID_PRIORITY 3
#define CNGP_ERROR_CODE_INVALID_FEETYPE 4
#define CNGP_ERROR_CODE_INVALID_FEECODE 5
#define CNGP_ERROR_CODE_INVALID_MSGFORMAT 6
#define CNGP_ERROR_CODE_INVALID_VALIDTIME 7
#define CNGP_ERROR_CODE_INVALID_ATTIME 8
#define CNGP_ERROR_CODE_INVALID_SRCTERMID 9
#define CNGP_ERROR_CODE_INVALID_DESTTERMID 10
#define CNGP_ERROR_CODE_INVALID_LEN 11
#define CNGP_ERROR_CODE_INVALID_DESTSMGW 12
#define CNGP_ERROR_CODE_INVALID_DESTSRCSMGW 13
#define CNGP_ERROR_CODE_INVALID_FWDDESTTERMID 14
#define CNGP_ERROR_CODE_CHANGEPASSWORD_FAIL 15
#define CNGP_ERROR_CODE_RESERVERD 16
/* API Error Code */
#define CNGP_API_OK 0
#define CNGP_API_ERROR_MSG_FORMAT 3
#define CNGP_API_ERROR_MSG_LENGTH 4
#define CNGP_API_ERROR_MSG_FEECODE 5
#define CNGP_API_ERROR_SERVICE_ID 7
#define CNGP_API_ERROR_SYSTEM_BUSY 8
#define CNGP_API_ERROR_CP_NUMBER 10
#define CNGP_API_ERROR_CONTENT_FORMAT 11
#define CNGP_API_ERROR_FEE_TYPE 12
#define CNGP_API_ERROR_VALID_TIME 13
#define CNGP_API_ERROR_AT_TIME 14
#define CNGP_API_ERROR_CHARGE_TERM_ID 15
#define CNGP_API_ERROR_DEST_TERM_ID 16
#define CNGP_API_ERROR_DEST_TERM_ID_FILE 17
#define CNGP_API_ERROR_MSG_FILE 18
#define CNGP_API_ERROR_CONNECT_GW 20
#define CNGP_API_ERROR_AUTHID 21
#define CNGP_API_ERROR_SEND_QUEUE_OVER 23
#define CNGP_API_ERROR_COMMAND_ID 25
#define CNGP_API_ERROR_SEQUENSE_ID 26
#define CNGP_API_ERROR_VERSION 29
#define CNGP_API_ERROR_MSG_TYPE 30
#define CNGP_API_ERROR_PRIORITY 31
#define CNGP_API_ERROR_TIME_TYPE 35
#define CNGP_API_ERROR_QUERY_TYPE 38
#define CNGP_API_ERROR_ROUTE 39
#define CNGP_API_ERROR_FIXED_FEE 40
#define CNGP_API_ERROR_SRC_TERM_ID 46
#define CNGP_API_ERROR_SYSTEM 99
/* CNGP Length */
#define CNGP_MSG_HEAD_LENGTH (UINT32)(sizeof(CNGP_Head))
#define CNGP_LOGIN_MSG_LENGTH (UINT32)(sizeof(CNGP_Login))
#define CNGP_SUBMIT_MSG_LENGTH (UINT32)(sizeof(CNGP_Submit))
#define CNGP_SUBMIT_BATCH_MSG_LENGTH (UINT32)(sizeof(CNGP_Submit_Batch))
#define CNGP_EXIT_MSG_LENGTH (UINT32)(sizeof(CNGP_Head))
#define CNGP_DELIVER_RSP_MSG_LENGTH (UINT32)(sizeof(CNGP_DeliverResp))
/* CNGP Submit Message Type */
#define CNGP_SUBMIT_CANCEL_SUBSCRIBE 1
#define CNGP_SUBMIT_SUBSCRIBE_REQUEST 2
#define CNGP_SUBMIT_REQUEST 3
#define CNGP_SUBMIT_SUBSCRIBE 4
#define CNGP_SUBMIT_EXCHANGE 5
#define CNGP_SUBMIT_QUERY 6
/********************************************************************
The Struct Definition
********************************************************************/
/* CNGP Message Head */
typedef struct
{
unsigned int nPacketLength; /* 4 bytes */
unsigned int nRequestId; /* 4 bytes */
unsigned int nStatus; /* 4 bytes*/
unsigned int nSequenceId; /* 4 bytes */
}CNGP_Head;
/* CNGP Message Login */
typedef struct
{
CNGP_Head msgHead; /* 16 bytes */
char sUser[10]; /* 10 bytes */
char sAuthenMD5[16]; /* 16 bytes */
unsigned char nLoginMode; /* 1 bytes */
unsigned int nTimeStamp; /* 4 bytes */
unsigned char nVersion; /* 1 bytes */
}CNGP_Login;
/* CNGP Message Login Resp*/
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sAuthenMD5[16]; /* 16 bytes */
unsigned char nVersion; /* 1 bytes */
}CNGP_LoginResp;
/* CNGP Message Submit*/
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sUser[10]; /* 10 bytes */
unsigned char nMsgType; /* 1 bytes */
unsigned char nNeedReport; /* 1 bytes */
unsigned char nPriority; /* 1 bytes */
char sServerId[10]; /* 10 bytes */
char sFeeType[2]; /* 2 bytes */
unsigned char nFeeUserType; /* 1 bytes */
char sFeeCode[6]; /* 6 bytes */
//char sFixedFee[6]; /* 6 bytes */
unsigned char nMsgFormat; /* 1 bytes */
char sValidTime[17]; /* 17 bytes */
char sAtTime[17]; /* 17 bytes */
char sSrcTermId[21]; /* 21 bytes */
char sChargeTermId[21]; /* 21 bytes */
unsigned char nDestTermIdCount; /* 1 bytes */
char sDestTermId[21]; /* 21 bytes */
unsigned char nMsgLength; /* 1 bytes */
char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */
}CNGP_Submit;
/* CNGP Message Submit*/
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sUser[10]; /* 10 bytes */
unsigned char nMsgType; /* 1 bytes */
unsigned char nNeedReport; /* 1 bytes */
unsigned char nPriority; /* 1 bytes */
char sServerId[10]; /* 10 bytes */
char sFeeType[2]; /* 2 bytes */
unsigned char nFeeUserType; /* 1 bytes */
char sFeeCode[6]; /* 6 bytes */
//char sFixedFee[6]; /* 6 bytes */
unsigned char nMsgFormat; /* 1 bytes */
char sValidTime[17]; /* 17 bytes */
char sAtTime[17]; /* 17 bytes */
char sSrcTermId[21]; /* 21 bytes */
char sChargeTermId[21]; /* 21 bytes */
unsigned char nDestTermIdCount; /* 1 bytes */
char sDestTermId[21*MAX_DEST_TERM_NUM]; /* 21 * 100 bytes */
unsigned char nMsgLength; /* 1 bytes */
char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */
}CNGP_Submit_Batch;
/* CNGP Message Submit Resp*/
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//unsigned int nResult; /* 4 bytes */
}CNGP_SubmitResp;
/* CNGP Message Deliver*/
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
unsigned char nIsReport; /* 1 bytes */
unsigned char nMsgFormat; /* 1 bytes */
char sRecvTime[14]; /* 14 bytes */
char sSrcTermId[21]; /* 21 bytes */
char sDestTermId[21]; /* 21 bytes */
unsigned char nMsgLength; /* 1 bytes */
char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */
}CNGP_Deliver;
/* CNGP Message Deliver Resp*/
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//unsigned int nResult; /* 4 bytes */
}CNGP_DeliverResp;
/* CNGP Message Active Test*/
/* Empty Body */
/* CNGP Message Active Test Resp */
/* Empty Body */
/* CNGP Message Exit*/
/* Empty Body */
/* CNGP Message Exit Resp*/
/* Empty Body */
/* CNGP Message Status Report */
typedef struct
{
CNGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
char sSubmitDate[14]; /* 14 bytes */
char sDoneDate[14]; /* 14 bytes */
char sStatus[7]; /* 7 bytes */
char sErr[3]; /* 3 bytes */
}CNGP_StatusReport;
/* CNGP Message Change Passward */
typedef struct
{
char sOldPassward[15]; /* 15 bytes */
char sNewPassward[15]; /* 15 bytes */
}CNGP_ChangePassward;
/*CNGP MSGID*/
typedef struct
{
char sGwCode[30];
char sTime[30];
char sSequenceNo[30];
}CNGP_MsgID;
/********************************************************************
The Function Definition
********************************************************************/
int CNGPPackHeadMsg(unsigned int nPacketLength,
unsigned int nRequestId,
CNGP_Head *pCNGPHead);
int CNGPPackLoginMsg(char nLoginMode,CNGP_Login *pLoginMsg);
int CNGPPackSubmitMsg( const int nMsgType, const int nNeedReply,
const int nMsgLevel, const char *sServiceID,
const int nMsgFormat, const char *sFeeType,
const int nFeeUserType, const char *sFeeCode,
const char *sValidTime, const char *sAtTime,
const char *sSrcTermID, const char *sChargeTermID,
const char *sDestTermID, const int nMsgLen,
const char *sMsgContent,
CNGP_Submit *pSubmit);
int CNGPPackSubmitBatchMsg( const int nMsgType, const int nNeedReply,
const int nMsgLevel, const char *sServiceID,
const int nMsgFormat, const char *sFeeType,
const int nFeeUserType, const char *sFeeCode,
const char *sValidTime, const char *sAtTime,
const char *sSrcTermID, const char *sChargeTermID,
const int nDestTermIDCount, const char *sDestTermID,
const int nMsgLen, const char *sMsgContent,
CNGP_Submit_Batch *pSubmit);
int CNGPPackExitMsg(CNGP_Head *pCNGPExit);
int CNGPPackDeliverRspMsg( CNGP_DeliverResp *pDeliverRsp,
unsigned int nSequense,
char *sMsgId,
unsigned int nResult);
int CNGPPackActiveTestMsg(CNGP_Head *pActiveTest);
#ifdef _WIN32
#pragma pack(pop)
#elif defined _AIX
#pragma options align=reset
#elif defined _HPUX
#pragma pack 4
#else
#pragma pack ()
#endif
#endif /* #define _CNGP_DEFINE_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -