⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ~cngp_message.~h

📁 SMAL是short message abstract library的缩写,是由风起水流软件工作室(www.zealware.com)开发的一个支持短信网关系统开发的C++底层抽象接口库
💻 ~H
字号:
/**
 *	cngp_message.h
 *	
 *	Short Message Abstractive Library.(SMAL)
 *
 *	Copyright 2003-2006	北京风起水流软件工作室
 *	
 *	http://www.zealware.com
 *	
 *	princetoad@gmail.com
 *
 * $ Log
 *  Revision 1.1 2007/07/22 2:32 范圣刚
 *  1.修改消息结构定义,为字符串字段增加一个字节长度,方便调用.
 *
 */

#ifndef _CNGP2_MESSAGE_H
#define _CNGP2_MESSAGE_H

#include <common/const.h>

#pragma pack(1)

/**@name cngp2.0协议消息结构定义 */
/** cngp_head */
typedef struct cngp_head {
	///< 消息总长度(含消息头和消息体)	
	unsigned long nTotalLength;
	///< 命令标识
	unsigned long nCommandId;
	///< 命令状态(参见7.4 status错误代码表)
	unsigned long nCommandStatus;
	///< 消息流水号,顺序累加,步长为1,循环使用(一对请求和应答的消息的流水号必须相同)
	unsigned long nSeqId;
} CNGP_HEAD, CNGP_EXIT, CNGP_EXIT_RESP, CNGP_ACTIVETEST, CNGP_ACTIVETEST_RESP;

/** cngp_login */
typedef struct cngp_login {
	///< SMGW设置的SP接入标识.
	char          sClientID[10+1];

	/** 客户端密码
	用于鉴别客户端的接入请求.其值通过单向MD5 hash计算得出,表示如下:
	AuthenticatorClient = MD5(ClientID + 7字节二进制零 + Sharedsecret+Timestamp).
	Shared secret由服务端和客户端事先定好,最长15字节,Timestamp格式为: mmddhhmmss,
	即月日时分秒,10位.
	*/
	char          sAuthClient[16+1];

	/** 登录类型(0=发送短消息, 1=接收短消息, 2=收发短消息,其他保留.) */
	unsigned char uchLoginMode;

	/** 时间辍的明文,由客户端产生,格式为mmddhhmmss,
	即月日时分秒,10位数字的整型,右对齐
	*/
	unsigned long nTimeStamp;

	/** 客户端支持的版本号(高位4bit表示主版本号,低位4bit表示次版本号) */
	unsigned char uchVersion;
} CNGP_LOGIN;

/** cngp_loginresp */
typedef struct cngp_login_resp {
	/** 服务端认证码,当客户端认证出错时,此项为空.
	其值通过单向MD5 hash计算得出,表示如下:
	AuthenticatorServer=MD5(Status + AuthenticatorClient + Shared secret)
	*/
	char            sAuthServer[16+1];

	unsigned char	uchVersion;
} CNGP_LOGIN_RESP;

/** TLV message of ProtocolID and CongestionState */
typedef struct cngp_tlv_221 {
	unsigned short tag;
	unsigned short length;
	unsigned char  value;
} CNGP_TLV_PROTOCOLID, CNGP_TLV_CONGESTIONSTATE;

/**TLV message of SPID*/
typedef struct cngp_tlv_spid {
	unsigned short tag;
	unsigned short length;
	char	value[10];	
} CNGP_TLV_SPID;

/**TLV message of SRCTermID*/
typedef struct cngp_tlv_srctermid {
	unsigned short tag;
	unsigned short length;
	char value[21];
} CNGP_TLV_SRCTERMID;

/**cngp submit message */
typedef struct cngp_submit {
	/** SP的企业代码 */
	char          sSpid[10+1];

	/** 短消息子类型(0=取消订阅,1=订阅或点播请求, 2=点播下发, 3=订阅下发,其他保留) */
	unsigned char uchSubType;

	/** 是否要求返回状态报告(0=不要求,1=要求) */
	unsigned char uchNeedReport;

	/** 发送优先级(0-3),3为最高级 */
	unsigned char uchPriority;

	/** 业务类型 */
	char          sServiceId[10+1];

	/** 资费类型
	00=免费
	01=按条收费
	02=包月
	03=封顶
	04=包月扣费请求
	05=CR话单
	其他保留
	*/
	char          sFeeType[2+1];

	/** 计费用户类型字段
	0: 对目的终端收费
	1: 对源终端收费
	2: 对SP计费
	3: 按照计费用户号码计费
	其他保留
	*/
	unsigned char uchFeeUserType;

	/** 每条短消息的信息费,单位:分 */
	char          sFeeCode[6+1];

	/** 短消息格式
	0 - ASCII编码
	3	-	保留
	4	-	二进制短消息
	8	-	UCS2编码
	15- GB2312编码
	*/
	unsigned char uchMsgFmt;

	/** 有效时间 */
	char          sValidTime[17+1];

	/** 定时发送时间 */
	char          sAtTime[17+1];

	/** 短消息发送用户号码 */
	char          sSrcTermId[21+1];

	/** 计费用户号码 */
	char          sChargeTermId[21+1];

	/** 短消息接收号码总数(<=100) */
	unsigned char uchDstUsrTl;

	/** 短消息接收号码 */
	char          sDstTermId[21*100];

	/** 短消息长度 */
	unsigned char uchMsgLen;

	/** 短消息内容 */
	char          sMsgContent[254];

	/** 协议标识 */
	CNGP_TLV_PROTOCOLID	pid;

	/** 自定义的非标准消息
	*/
	NonStandardInfo	nonStdMessage;

} CNGP_SUBMIT;

/** cngp submitresp and deliverresp*/
typedef struct cngp_submit_deliver_resp {
	/** SMGW产生的短消息流水号,由三部分组成:
	SMGW代码: 3字节(BCD码)
	时间: 4字节(BCD码)
	序列号: 3字节(BCD码)
	*/
	char                     sMsgid[10+1];

	/** 流量控制 */
	CNGP_TLV_CONGESTIONSTATE cstate;

	/**
	非标准字段,用来存储Response的流水号
	(就是消息头里面的流水号)
	*/
	unsigned long            nSeqId;

	unsigned long            nResult;
} CNGP_SUBMIT_RESP, CNGP_DELIVER_RESP;

/** cngp status report message 
totallength = 122
*/
typedef struct cngp_status_report {
	/** 状态报告对应原始消息的MsgID
	id(14,+3)
	id:IIIIIIIIII空格
	69 64 3a 85 10 61 06 18 19 01 06 05 08 20
	
	69 64 3a 
	85 10 61 
	06 18 19 01 
	06 05 08 
	20
	*/
	char						SR_id[14+1];

	/** 取缺省值001
	Sub(8,+4)
	Sub:001空格
	73 75 62 3a 30 30 31 20 
	*/
	char						SR_sub[8+1];

	/** 取缺省值001
	dlvrd(10,+6)
	dlvrd:001空格
	64 6c 76 72 64 3a 30 30 31 20 
	*/
	char						SR_dlvrd[10+1];

	/** 短消息提交格式(格式:yymmddhhmm,例如010331200000)
	submitdate(23,+12)
	submit date:06181932空格
	73 75 62 6d 69 74 20 64 61 74 65 3a 30 36 30 36 31 38 31 39 30 32 20 
	*/
	char						SR_submitdate[23+1];

	/** 短消息下发时间(格式:yymmddhhmm,例如010331200000)
	donedate(21,+10)
	done date:0606181902空格
	64 6f 6e 65 20 64 61 74 65 3a 30 36 30 36 31 38 31 39 30 32 20 
	*/
	char						SR_donedate[21+1];

	/** 短消息状态(参见6.3节短消息状态表)
	state(13,+5)
	stat:DELIVRD空格
	73 74 61 74 3a 44 45 4c 49 56 52 44 20
	*/
	char						SR_state[13+1];

	/** 参见第6.4节错误代码表
	err(8,+4)
	err:000空格
	65 72 72 3a 30 30 30 20 
	*/
	char						SR_err[8+1];

	/** 前三个字节,表示短消息长度(用ASCII码表示),
	后17个字节表示短消息的内容(保证内容不出现乱码)
	txt(24,+4)
	txt:114消息内容(无空格)
	74 65 78 74 3a 31 31 34 c4 fa d6 a7 b3 d6 b5 c4 b2 ce c8 fc d1 a1 ca d6 b8
	*/
	char						SR_text[24+1];
} CNGP_STATUS_REPORT;

/**cngp deliver message */
typedef struct cngp_deliver {
	/** SMGW产生的短消息流水号,由三部分组成:
	SMGW代码: 3字节(BCD码)
	时间: 4字节(BCD码)
	序列号: 3字节(BCD码)
	*/
	char                    sMsgid[10+1];

	/** 是否是状态报告(0 = 不是, 1 = 是) */
	unsigned char           uchRegisteredDelivery;

	/** 短消息格式 */
	unsigned char	        uchMsgfmt;

	/** 短消息接收时间(yyyymmddhhmmss, 例如20010301200000) */
	char			        sRecvTime[14+1];

	/** 短消息发送用户号码 */
	char			        sSrcTermId[21+1];

	/** 短消息接收用户号码 */
	char			        sDstTermId[21+1];

	/** 短消息长度 */
	unsigned char           uchMsgLen;

	/** 短消息内容 */
	union {
		char                sMsgcontent[254];
		cngp_status_report	csr;
	} MO_Msg_Content;

	/**
	协议标识
	*/
	CNGP_TLV_PROTOCOLID     pid;
} CNGP_DELIVER;

/**cngp message from smgw to sp */
typedef struct cngp_smgtosp {
	cngp_head                    pk_head;

	union {
		cngp_login_resp          pk_connectresp;
		cngp_submit_deliver_resp pk_submitresp;
		cngp_deliver             pk_deliver;
	} pk_body;
} CNGP_SMGTOSP;

/**cngp message from sp to smgw */
typedef struct cngp_sptosmg {
	cngp_head                    pk_head;

	union {
		cngp_login               pk_connect;
		cngp_submit              pk_submit;
		cngp_submit_deliver_resp pk_deliverresp;
	} pk_body;
} CNGP_SPTOSMG;

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -