📄 cmppmessage.h
字号:
#ifndef CMPP_MESSAGE_H
#define CMPP_MESSAGE_H
#include <afxsock.h>
// 标准端口号
#define CMPP_PORT 7890
#define CMPP_Connect 0x00000001
#define CMPP_Connect_REP 0x80000001
#define CMPP_Terminate 0x00000002
#define CMPP_Terminate_REP 0x80000002
#define CMPP_Submit 0x00000004
#define CMPP_Submit_REP 0x80000004
#define CMPP_Deliver 0x00000005
#define CMPP_Deliver_REP 0x80000005
#define CMPP_Query 0x00000006
#define CMPP_Query_REP 0x80000006
#define CMPP_Cancel 0x00000007
#define CMPP_Cancel_REP 0x80000007
#define CMPP_Active_Test 0x00000008
#define CMPP_Active_Test_REP 0x80000008
#define CMPP_Fwd 0x00000009
#define CMPP_Fwd_REP 0x80000009
//********************************************************
#define CMPP_MT_ROUTE 0x00000010;
#define CMPP_MT_ROUTE_REP 0x80000010;
#define CMPP_MO_ROUTE 0x00000011;
#define CMPP_MO_ROUTE_REP 0x80000011;
#define CMPP_GET_ROUTE 0x00000012;
#define CMPP_GET_ROUTE_REP 0x80000012;
//网关与汇接节点间的消息类型
#define CMPP_MT_ROUTE_UPDATE 0x00000013;
#define CMPP_MT_ROUTE_UPDATE_REP 0x80000013;
#define CMPP_MO_ROUTE_UPDATE 0x00000014;
#define CMPP_MO_ROUTE_UPDATE_REP 0x80000014;
#define CMPP_PUSH_MT_ROUTE_UPDATE 0x00000015;
#define CMPP_PUSH_MT_ROUTE_UPDATE_REP 0x80000015;
#define CMPP_PUSH_MO_ROUTE_UPDATE 0x00000016;
#define CMPP_PUSH_MO_ROUTE_UPDATE_REP 0x80000016;
//CMPP V1.1中的内容,现已不用了。
#define CMPP_Route 0x00000003
#define CMPP_Route_REP 0x80000003
//**********************************************************
#define CMPP_STATUS_DELIVERED 0
#define CMPP_STATUS_EXPIRED 1
#define CMPP_STATUS_DELETED 2
#define CMPP_STATUS_UNDELIVERABLE 3
#define CMPP_STATUS_ACCEPTED 4
#define CMPP_STATUS_UNKNOWN 5
#define CMPP_STATUS_REJECTED 6
#define MAX_ROUTE_NUM 100
#define VALID_UTCTIMELENG 16
class CCmppMessage
{
public:
bool m_ValidMessage;
int m_nUseUnicode; //是否采用API提供的unicode函数
unsigned long m_nCommandID; // 命令或响应类型
unsigned long m_nSequenceID; // 消息流水号
// 1. CMPP_Connect
char m_sSource_Addr[7];
char m_AuthenticatorICP[17];
BYTE m_nVersion;
unsigned long m_nTimeStamp; //10位长的时间标志
char reserve[9];
// 2. CMPP_Connect_REP
BYTE m_nStatus;
char m_AuthenticatorISMG[17];
// BYTE m_nTLSAVailable; // used in cmpp1.1
// 5. CMPP_Submit
__int64 m_nMsgID;
BYTE m_nPKTotal;
BYTE m_nPKNumber;
BYTE m_nRegisteredDelivery;
BYTE m_nMsgLevel;
char m_sServiceID[11];
BYTE m_nFee_UserType;
char m_sFeeTerminalID[22];
BYTE m_nTP_pid;
BYTE m_nTP_udhi;
BYTE m_nMsgFmt;
char m_sFeeType[3];
char m_sFeeCode[7];
char m_sValidTime[18];
char m_sAtTime[18];
char m_sSrcTerminalID[22];
BYTE m_nDestUsrTl;
char m_sDestTerminalIDs[100][21];
BYTE m_nMsgLength;
char m_sMsgContent[141];
// 6. CMPP_Submit_REP
BYTE m_nResult;
// 7. CMPP_Query
char m_sTime[9];
BYTE m_nQueryType;
char m_sQueryCode[11];
// 8. CMPP_Query_REP
int m_nMT_TLMsg;
int m_nMT_TLUsr;
int m_nMT_Scs;
int m_nMT_WT;
int m_nMT_FL;
int m_nMO_Scs;
int m_nMO_WT;
int m_nMO_FL;
// 9. CMPP_Deliver
// deliver status : if m_nRegisteredDelivery == 1;
__int64 m_nMsgIDForStatus; //4
int m_nMTStatus;
char m_sMTStatus[8]; //7
char m_sSendtime[11]; //10--yymmddhhmm
char m_sDonetime[11]; //10--yymmddhhmm
char m_sDestnation_id[22];
char m_sDest_terminal_id[22];
int m_nSMSC_sequence;
// 12. CMPP_Cancel_REP
BYTE m_nSuccessID;
// 15. CMPP_Fwd
char m_sSourceID[7];
char m_sDestID[7];
BYTE m_nNodesCount;
BYTE m_nMsg_Fwd_Type;
// BYTE m_nFee_terminal_id;
//*****************************************
// 17. CMPP_Route
BYTE m_nNewGate;
short m_nRequestTotal;
char m_sServiceType[11]; // ? Service_ID
int m_nServiceCode; // ?
// 18. CMPP_Route_REP
short m_RequestNumber;
char m_sServiceTypes[MAX_ROUTE_NUM][11]; // ? Service_ID
int m_nServiceCodeStarts[MAX_ROUTE_NUM];
int m_nServiceCodeEnds[MAX_ROUTE_NUM];
char m_sICPIDs[MAX_ROUTE_NUM][7];
char m_sISMGIDs[MAX_ROUTE_NUM][5];
//************************************************
public:
//
CCmppMessage();
bool IsReplyMessage() const;
//
int FillData(char *dst, const char *src, int cnt) const;
// encode and decode message frame
int EncodeMessage(char *out) const;
int DecodeMessage(const char *in);
int EncodeData(char *out, char c) const;
int EncodeData(char *out, short s) const;
int EncodeData(char *out, long l) const;
int EncodeData(char *out, __int64 ll) const;
int EncodeData(char *out, const char *s) const;
int EncodeData(char *out, const char *s, int len) const;
int DecodeData(const char *in, char &c);
int DecodeData(const char *in, short &s);
int DecodeData(const char *in, long &l);
int DecodeData(const char *in, __int64 &ll);
int DecodeData(const char *in, char *s);
int DecodeData(const char *in, char *s, int len);
// manipulate message data
void SetSequenceId(unsigned long seq) { m_nSequenceID = seq; }
unsigned long GetSequenceId() { return m_nSequenceID; }
void Set_Connect(const char *icp_id, const char *AuthenticateICP,bool use_9_byte = true);
void Set_Connect_REP(char status, const char *AuthenticateISMG);
void Set_Terminate();
void Set_Terminate_REP();
void Set_Submit(__int64 msg_id,
int pk_total,
int pk_num,
int msg_level,
const char *service_id,
BYTE Fee_UserType,
const char *Fee_terminal_id,
int TP_pid,
int TP_udhi,
int msg_fmt,
const char *icp_id,
const char *fee_type,
const char *fee_code,
const char *valid_time,
const char *at_time,
const char *src_term_id,
int dest_term_num,
const char **dest_term_id,
int msg_len,
const char *msg,
int regdelivery=0);
void Set_Submit_REP(__int64 msg_id, int result);
void Set_Query(const char *time1, int query_type, const char *query_code);
void Set_Query_REP(const char *time1, int query_type, const char *query_code,
long mt_tlmsg, long mt_tlusr, long mt_scs, long mt_wt, long mt_fl,
long mo_scs, long mo_wt, long mo_fl);
void Set_Deliver(__int64 msg_id, const char *Destnationid, const char *service_id,
int TP_pid, int TP_udhi, int msg_fmt, const char *src_term_id, int msg_len, const char *msg);
void Set_DeliverStatus(__int64 msg_id, const char *Destnationid, const char *service_id,
int TP_pid, int TP_udhi, int msg_fmt, const char *src_term_id, int msg_len, __int64 MsgID,
const char* status , const char* sTimeSend,const char* sTimeDone,const char* sDestterminalid, int nSmscSequence);
void Set_Deliver_REP(__int64 msg_id, int result);
void Set_Cancel(__int64 msg_id);
void Set_Cancel_REP(int success_id);
void Set_Active_Test(); //bool use_tls);
void Set_Active_Test_REP(int success_id); //bool use_tls, int success_id);
void Set_Fwd(const char *src_id, const char *dst_id, int nodes_cnt, int msg_fwd_type,
__int64 msg_id, int pk_total, int pk_num, int reg_delivery, int msg_level, const char *service_id,
int fee_usertype, const char *fee_terminal_id, int TP_pid, int TP_udhi,
int msg_fmt, const char *src_term_id, int dest_term_num, const char **dest_term_id,
const char *msg_src, const char *fee_type, const char *fee_code, const char *valid_time,
const char *at_time, int msg_len, const char *msg);
void Set_Fwd_REP(__int64 msg_id, int pk_total, int pk_num, int result);
//**************************************************************
void Set_Route(bool new_gate, bool request_multi, const char *service_type, int service_code, const char *icp_id);
void Set_Route_REP(int req_num, const char *service_type, int *service_code_start,
int *service_code_end, const char *icp_id, const char *ismg_id);
//*****************************************************************
// MD5 generate and validation
void MakeAuthIcp(const char *secret, bool use_9_byte);
void MakeAuthISMG(const char *secret);
bool ValidAuthIcp(const char *secret, bool use_9_byte) const;
bool ValidAuthISMG(const char *secret) const;
//
void CopySubmit(const CCmppMessage* msg);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -