📄 smgp_proto.h
字号:
/**********************************************************************
FileName : smgp_proto.h
Description : SMGP协议头文件
Version : 1.0
Date : 2003年8月11日
Author : 刘荣辉
Other :
***********************************************************************/
#ifndef _SMGP_PROTO_H_
#define _SMGP_PROTO_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
#define SMGP_CLIENT_VERSION 0x13
/*#define SMGP_CLIENT_VERSION10_OK*/
/* The Maximal Length Of Short Message */
#define MAX_SM_LEN 252
#define MAX_SM_CUT_NUM 100
/*The Maximal number of DestTermID*/
#define MAX_DEST_TERM_NUM 100
/* 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
/* SMGP Error Code */
#define SMGP_ERROR_CODE_OK 0
#define SMGP_ERROR_CODE_INVALIDE_PACKET 1
#define SMGP_ERROR_CODE_LOGIN_FAIL 2
#define SMGP_ERROR_CODE_INVALID_PRIORITY 3
#define SMGP_ERROR_CODE_INVALID_FEETYPE 4
#define SMGP_ERROR_CODE_INVALID_FEECODE 5
#define SMGP_ERROR_CODE_INVALID_MSGFORMAT 6
#define SMGP_ERROR_CODE_INVALID_VALIDTIME 7
#define SMGP_ERROR_CODE_INVALID_ATTIME 8
#define SMGP_ERROR_CODE_INVALID_SRCTERMID 9
#define SMGP_ERROR_CODE_INVALID_DESTTERMID 10
#define SMGP_ERROR_CODE_INVALID_LEN 11
#define SMGP_ERROR_CODE_INVALID_DESTSMGW 12
#define SMGP_ERROR_CODE_INVALID_DESTSRCSMGW 13
#define SMGP_ERROR_CODE_INVALID_FWDDESTTERMID 14
#define SMGP_ERROR_CODE_CHANGEPASSWORD_FAIL 15
#define SMGP_ERROR_CODE_RESERVERD 16
/* API Error Code */
#define SMGP_API_OK 0
#define SMGP_API_ERROR_MSG_FORMAT 3
#define SMGP_API_ERROR_MSG_LENGTH 4
#define SMGP_API_ERROR_MSG_FEECODE 5
#define SMGP_API_ERROR_SERVICE_ID 7
#define SMGP_API_ERROR_SYSTEM_BUSY 8
#define SMGP_API_ERROR_CP_NUMBER 10
#define SMGP_API_ERROR_CONTENT_FORMAT 11
#define SMGP_API_ERROR_FEE_TYPE 12
#define SMGP_API_ERROR_VALID_TIME 13
#define SMGP_API_ERROR_AT_TIME 14
#define SMGP_API_ERROR_CHARGE_TERM_ID 15
#define SMGP_API_ERROR_DEST_TERM_ID 16
#define SMGP_API_ERROR_DEST_TERM_ID_FILE 17
#define SMGP_API_ERROR_MSG_FILE 18
#define SMGP_API_ERROR_CONNECT_GW 20
#define SMGP_API_ERROR_AUTHID 21
#define SMGP_API_ERROR_SEND_QUEUE_OVER 23
#define SMGP_API_ERROR_COMMAND_ID 25
#define SMGP_API_ERROR_SEQUENSE_ID 26
#define SMGP_API_ERROR_VERSION 29
#define SMGP_API_ERROR_MSG_TYPE 30
#define SMGP_API_ERROR_PRIORITY 31
#define SMGP_API_ERROR_TIME_TYPE 35
#define SMGP_API_ERROR_QUERY_TYPE 38
#define SMGP_API_ERROR_ROUTE 39
#define SMGP_API_ERROR_FIXED_FEE 40
#define SMGP_API_ERROR_SRC_TERM_ID 46
#define SMGP_API_ERROR_SYSTEM 99
/* SMGP Length */
#define SMGP_MSG_HEAD_LENGTH (UINT32)(sizeof(SMGP_Head))
#define SMGP_LOGIN_MSG_LENGTH (UINT32)(sizeof(SMGP_Login))
#define SMGP_SUBMIT_MSG_LENGTH (UINT32)(sizeof(SMGP_Submit))
#define SMGP_SUBMIT_BATCH_MSG_LENGTH (UINT32)(sizeof(SMGP_Submit_Batch))
#define SMGP_EXIT_MSG_LENGTH (UINT32)(sizeof(SMGP_Head))
#define SMGP_DELIVER_RSP_MSG_LENGTH (UINT32)(sizeof(SMGP_DeliverResp))
/* SMGP Submit Message Type */
#define SMGP_SUBMIT_CANCEL_SUBSCRIBE 1
#define SMGP_SUBMIT_SUBSCRIBE_REQUEST 2
#define SMGP_SUBMIT_REQUEST 3
#define SMGP_SUBMIT_SUBSCRIBE 4
#define SMGP_SUBMIT_EXCHANGE 5
#define SMGP_SUBMIT_QUERY 6
typedef struct{
char sAreaId[9];
char sAreaCode[5];
char sAreaHeader[10];
int nTotalLen;
char sAtTime [20];
char sMsgContent[252];
int nStatus;
}SSendBatch;
/********************************************************************
The Struct Definition
********************************************************************/
/* SMGP Message Head */
typedef struct
{
unsigned int nPacketLength; /* 4 bytes */
unsigned int nRequestId; /* 4 bytes */
unsigned int nSequenceId; /* 4 bytes */
}SMGP_Head;
/* SMGP Message Login */
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sUser[8]; /* 8 bytes */
char sAuthenMD5[16]; /* 16 bytes */
unsigned char nLoginMode; /* 1 bytes */
unsigned int nTimeStamp; /* 4 bytes */
unsigned char nVersion; /* 1 bytes */
}SMGP_Login;
/* SMGP Message Login Resp*/
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
unsigned int nResult; /* 4 bytes */
}SMGP_LoginResp;
/* SMGP Message Submit*/
typedef struct
{
SMGP_Head msgHead; /* 12 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 */
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 sReplyPath[21]; /* 21 bytes */
char sChargeTermId[21]; /* 21 bytes */
unsigned char nDestTermIdCount; /* 1 bytes */
char sDestTermId[21]; /* 21 * 100 bytes */
unsigned char nMsgLength; /* 1 bytes */
char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */
}SMGP_Submit;
/* SMGP Message Submit*/
typedef struct
{
SMGP_Head msgHead; /* 12 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 */
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 sReplyPath[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 */
}SMGP_Submit_Batch;
/* SMGP Message Submit Resp*/
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//short sMsgId_1;
//long long sMsgId_2;
unsigned int nResult; /* 4 bytes */
}SMGP_SubmitResp;
typedef struct
{
char tag_id[3]; // 恒定为"id:"
char MsgId[10]; //Submit_Rsp中的Msg_ID, 10 bytes
//short MsgId_1;
//long long MsgId_2;
unsigned char space_1; // 恒定为0x20
char tag_sub[3]; // 恒定为"sub:"
char sub[3]; // 缺省为"001"
unsigned char space_2; // 恒定为0x20
char tag_dlvrd[6]; // 恒定为"dlvrd:"
char dlvrd[3]; // 缺省为"001"
unsigned char space_3; // 恒定为0x20
char tag_SubmitDate[12]; // 恒定为"submit date:"
char Submit_date[10]; // 提交时间
unsigned char space_4; // 恒定为0x20
char tag_DoneDate[10]; // 恒定为"done date:"
char done_date[10]; //下发时间
unsigned char space_5; // 恒定为0x20
char tag_Stat[5]; // 恒定为"stat:"
char Stat[7]; // 消息状态
unsigned char space_6; // 恒定为0x20
char tag_Err[4]; // 恒定为"err:"
char Err[3]; // 错误代码
unsigned char space_7; // 恒定为0x20
char tag_Txt[5]; // 恒定为"text:"
char Msg_Len[3]; // 消息长度
char Txt[17]; // 消息内容
}SMGP_Report;
/* SMGP Message Deliver*/
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//short sMsgId_1;
//long long sMsgId_2;
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 */
union {
char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */
SMGP_Report Report;
} Deliver_Msg;
}SMGP_Deliver;
/* SMGP Message Status Report */
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//short sMsgId_1;
//long long sMsgId_2;
char sSubmitDate[14]; /* 14 bytes */
char sDoneDate[14]; /* 14 bytes */
char sStatus[7]; /* 7 bytes */
char sErr[3]; /* 3 bytes */
}SMGP_StatusReport;
/* SMGP Message Deliver Resp*/
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//short sMsgId_1;
//long long sMsgId_2;
unsigned int nResult; /* 4 bytes */
}SMGP_DeliverResp;
/* SMGP Message Change Passward */
typedef struct
{
char sOldPassward[15]; /* 15 bytes */
char sNewPassward[15]; /* 15 bytes */
}SMGP_ChangePassward;
/*SMGP MSGID*/
typedef struct
{
char sGwCode[30];
char sTime[30];
char sSequenceNo[30];
}SMGP_MsgID;
/* SMGP Message Active Test*/
/* Empty Body */
/* SMGP Message Active Test Resp */
/* Empty Body */
/* SMGP Message Forward*/
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sDestSMGWNo[6]; /* 6 bytes */
char sSrcSMGWNo[6]; /* 6 bytes */
unsigned char nSMType; /* 1 bytes */
unsigned char nNeedReport; /* 1 bytes */
unsigned char nPriority; /* 1 bytes */
char sMsgSrc[6]; /* 6 bytes */
char sServerId[10]; /* 10 bytes */
char sFeeType[2]; /* 2 bytes */
char sFeeCode[6]; /* 6 bytes */
unsigned char nMsgFormat; /* 1 bytes */
char sValidTime[17]; /* 17 bytes */
char sAtTime[17]; /* 17 bytes */
char sReplyPath[21]; /* 21 bytes */
char sDestTermId[21]; /* 21 bytes */
unsigned char nMsgLength; /* 1 bytes */
char sMsgContent[MAX_SM_LEN]; /* MAX_SM_LEN bytes */
}SMGP_Forward;
/* SMGP Message Forward Resp*/
typedef struct
{
SMGP_Head msgHead; /* 12 bytes */
char sMsgId[10]; /* 10 bytes */
//short sMsgId_1;
//long long sMsgId_2;
unsigned int nResult; /* 4 bytes */
}SMGP_ForwardResp;
/* SMGP Message Exit*/
/* Empty Body */
/* SMGP Message Exit Resp*/
/* Empty Body */
#ifdef _WIN32
#pragma pack(pop)
#elif defined _AIX
#pragma options align=reset
#elif defined _HPUX
#pragma pack 4
#else
#pragma pack ()
#endif
#endif //#define _SMGP_PROTO_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -