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

📄 smpp_message.h

📁 SMAL是short message abstract library的缩写,是由风起水流软件工作室(www.zealware.com)开发的一个支持短信网关系统开发的C++底层抽象接口库
💻 H
📖 第 1 页 / 共 3 页
字号:
/**
 *	smpp_message.h
 *	
 *	Short Message Abstractive Library.(SMAL)
 *
 *	Copyright 2003-2006	北京风起水流软件工作室
 *	
 *	http://www.zealware.com
 *	
 *	princetoad@gmail.com
 *
 */

#ifndef _SMPP3_MESSAGE_H
#define _SMPP3_MESSAGE_H

#include <common/const.h>

#pragma pack(1)

using namespace std;
//##ModelId=46B5D42E0097
#include <string>

/**@name SMPP3.4协议消息结构定义 */
//@{

/**消息头定义
字段	长度(字节)	类型	描述
Command_Length	4	integer	消息包的长度,包括此字段
Command_ID	4	integer	这个字段表明此条短消息的类型,例如ESME_SUB_SM表示此消息为ESME向SMSC提交短消息。具体数值定义见附录A。
Command_status	4	integer	此字段表示一个命令的成功与失败,如失败,指示引起失败的错误类型等信息,它在请求中必须设为0。
Sequence_No	4	integer	此字段表示消息的序列号,它由ESME产生,它是消息和它的应答之间的对应标志,它的数值在0到0XFFFFFFFF间必须保证严格单调的递增,当达到0XFFFFFFFF时,从0开始下一循环。
Optional Message Body	可变	混合	此字段表示短消息的消息体部分,具体定义见6.5.2
*/
//##ModelId=46B5D42E0156
typedef struct pdu_smpp_head {
	/**
	The command_length parameter indicates the length in octets of the SMPP message. The SMPP
	message header (including the command_length field itself), the mandatory parameters and the
	optional parameters are all considered.
	*/
	//##ModelId=46B5D42E00B6
	unsigned long nCommandLength;

	/**
	The command_id field identifies the type of message the SMPP PDU represents, for example,
	submit_sm, query_sm etc.
	A command identifier is allocated to each SMPP request primitive. For reserved range value
	settings refer to Table 5-1:.
	A response command identifier is allocated to each response primitive. For reserved range
	value settings refer to Table 5-1: (In general a response command identifier is identical to the
	corresponding request command identifier, but with bit 31 set).
	The complete set of SMPP Command IDs and their associated values are defined in the
	following table.
	*/
	//##ModelId=46B5D42E00D3
	unsigned long nCommandID;

	/**
	The command_status field of an SMPP message response indicates the success or failure of an
	SMPP request. It is relevant only in the SMPP response message and should be set to NULL in
	SMPP request messages.
	The SMPP Error status codes are returned by the SMSC in the command_status field of the
	SMPP message header and in the error_status_code field of a submit_multi_resp message.
	*/
	//##ModelId=46B5D42E00FB
	unsigned long nCommandStatus;

	/**
	A sequence number allows a response PDU to be correlated with a request PDU.
	The associated SMPP response PDU must preserve this field.
	The allowed sequence_number range is from 0x00000001 to 0x7FFFFFFF.
	*/
	//##ModelId=46B5D42E0119
	unsigned long nSequenceNo;

	//##ModelId=46B5D42E0138
	pdu_smpp_head() {
		nCommandLength = 0;
		nCommandID = 0;
		nCommandStatus = 0;
		nSequenceNo = 0;
	}
} PDU_SMPP_HEAD, PDU_SMPP_UNBIND, PDU_SMPP_UNBIND_RESP;

//class SMPP_PDU {
//public:
//	unsigned long nCommandLength;
//	unsigned long nCommandID;
//	unsigned long nCommandStatus;
//	unsigned long nSequenceNo;
//
//public:
//	SMPP_PDU() 
//		: nCommandLength(0), 
//		nCommandID(0), 
//		nCommandStatus(0), 
//		nSequenceNo(0)
//	{
//	}
//
//	SMPP_PDU(
//		unsigned long _commandID, 
//		unsigned long _commandLength = 0, 
//		unsigned long _commandStatus = 0, 
//		unsigned long _sequenceNO = 0
//		)
//	{
//		nCommandLength = _commandLength;
//		nCommandID = _commandID;
//		nCommandStatus = _commandStatus;
//		nSequenceNo = _sequenceNO;
//	}
//
//	~SMPP_PDU()
//	{
//	}
//};

/**
字段	长度(字节)	类型	描述
system_id	最大 16	C_String	接口ID
password	最大 9	C_String	密码
system_type	最大 13	C_String	接口类型
interface_version	1	integer	接口版本号
ton	1	integer	保留,应设置为0
npi	1	integer	保留,应设置为0
address_range	最大 41	C_DecString	保留,应设置为NULL
*/
//##ModelId=46B5D42E0192
typedef struct pdu_smpp_bind {
	/**
	The system_id parameter is used to identify an ESME or an SMSC at bind time. An ESME
	system_id identifies the ESME or ESME agent to the SMSC. The SMSC system_id provides an
	identification of the SMSC to the ESME.
	*/
	char system_id[16];

	/**
	The password parameter is used by the SMSC to authenticate the identity of the binding ESME.
	The Service Provider may require ESME’s to provide a password when binding to the SMSC.
	This password is normally issued by the SMSC system administrator.
	The password parameter may also be used by the ESME to authenticate the identity of the
	binding SMSC (e.g. in the case of the outbind operation).
	*/
	char password[9];

	/**
	The system_type parameter is used to categorize the type of ESME that is binding to the SMSC.
	Examples include “VMS” (voice mail system) and “OTA” (over-the-air activation system).
	Specification of the system_type is optional - some SMSC’s may not require ESME’s to provide
	this detail. In this case, the ESME can set the system_type to NULL.
	*/
	char system_type[13];

	/**
	This parameter is used to indicate the version of the SMPP protocol. The following interface
	version values are defined:
	Interface Version Value
	Indicates that the EMSE supports
	version 3.3 or earlier of the SMPP
	protocol.
	0x00-0x33
	Indicates that the ESME is supporting
	SMPP version 3.4
	0x34
	All other values reserved
	*/
	unsigned char interface_version;

	/**
	5.2.5 addr_ton, source_addr_ton, dest_addr_ton, esme_addr_ton
	These fields define the Type of Number (TON) to be used in the SME address parameters. The
	following TON values are defined:
	TON Value
	Unknown 00000000
	International 00000001
	National 00000010
	Network Specific 00000011
	Subscriber Number 00000100
	Alphanumeric 00000101
	Abbreviated 00000110
	All other values reserved
	Table 5-3: TON values
	*/
	unsigned char ton;

	/**
	addr_npi, source_addr_npi, dest_addr_npi, esme_addr_npi
	These fields define the Numeric Plan Indicator (NPI) to be used in the SME address parameters.
	The following NPI values are defined:
	NPI Value
	Unknown 00000000
	ISDN (E163/E164) 00000001
	Data (X.121) 00000011
	Telex (F.69) 00000100
	Land Mobile (E.212) 00000110
	National 00001000
	Private 00001001
	ERMES 00001010
	Internet (IP) 00001110
	WAP Client Id (to be
	defined by WAP Forum)
	00010010
	All other values reserved
	Table 5-4: NPI values
	*/
	unsigned char npi;

	/**
	5.2.7 address_range
	The address_range parameter is used in the bind_receiver and bind_transceiver command to
	specify a set of SME addresses serviced by the ESME client. A single SME address may also
	be specified in the address_range parameter. UNIX Regular Expression notation should be used
	to specify a range of addresses (Refer to Appendix A.)
	Messages addressed to any destination in this range shall be routed to the ESME.
	Notes
	For IP addresses, it is only possible to specify a single IP address. A range of IP addresses is
	not allowed. IP version 6.0 is not currently supported in this version of the protocol.
	*/
	char address_range[41];

	pdu_smpp_bind() {
		memset(system_id, 0, 16);
		memset(password, 0, 9);
		memset(system_type, 0, 13);
		interface_version = 0;
		ton = 0;
		npi = 0;
		memset(address_range, 0, 41);
	}
} PDU_SMPP_BIND, PDU_SMPP_BIND_TRANSMITTER, PDU_SMPP_BIND_RECEIVER;

//class SMPP_BIND_RECEIVER : public SMPP_PDU
//{
//public:
//	string system_id;
//	string password;
//	string system_type;
//	unsigned char interface_version;
//	unsigned char ton;
//	unsigned char npi;
//	string address_range;
//public:
//	SMPP_BIND_RECEIVER()
//		: nCommandID( e_ESME_BNDRCV )
//	{
//	}
//};

/**
字段	大小(字节)	类型	描述
System_id	最大 16	C_String	接口ID
状态取值范围:
E_SUCCESS
E_OTHERERR
E_CMDLENERR
E_NORIGHT
E_INVLDSYSTEMID
E_INVLDPASSWORD
E_INVLDSYSTEMTYPE
E_INVLDIFVER
*/
//##ModelId=46B5D42E01C5
typedef struct pdu_smpp_bind_resp {
	char system_id[16];

	unsigned long command_status;
} PDU_SMPP_BIND_RESP, PDU_SMPP_BIND_TRANSMITTER_RESP, PDU_SMPP_BIND_RECEIVER_RESP;

//class SMPP_BIND_RECEIVER_RESP : public SMPP_PDU
//{
//public:
//	string system_id;
//public:
//	SMPP_BIND_RECEIVER_RESP()
//		: nCommandID( e_ESME_BNDRCV_RESP )
//	{
//	}
//};

/**
6.5.2.2 BIND_TRANSMITTER命令
它在扩展短消息实体和短消息中心之间产生虚连接,该连接支持除下发短消息(deliver_sm,deliver_sm_resp)以外的所有协议命令。
BIND_TRANSMITTER语法
此命令和BIND_RECEIVER的语法一样,只是在消息头里的Command_ID为"bind_transmitter"。
BIND_TRANSMITTER_RESP语法
此命令和BIND_RECEIVER_RESP的语法一样,只是在消息头里的Command_ID为"bind_transmitter_resp"。
状态取值范围:
同BIND_RECEIVER_RESP
*/
//typedef struct PDU_SMPP_BIND PDU_SMPP_BIND_TRANSMITTER;
//typedef struct PDU_SMPP_BIND PDU_SMPP_BIND_RECEIVER;

//typedef struct PDU_SMPP_BIND_RESP PDU_SMPP_BIND_TRANSMITTER_RESP;
//typedef struct PDU_SMPP_BIND_RESP PDU_SMPP_BIND_RECEIVER_RESP;

//class SMPP_BIND_TRANSMITTER : public SMPP_BIND_RECEIVER
//{
//public:
//	SMPP_BIND_TRANSMITTER()
//		: nCommandID( e_ESME_BNDTRN)
//	{
//	}
//};
//
//class SMPP_BIND_TRANSMITTER_RESP : public SMPP_BIND_RECEIVER_RESP
//{
//public:
//	SMPP_BIND_TRANSMITTER_RESP()
//		: nCommandID( e_ESME_BNDTRN_RESP )
//	{
//	}
//};

/**
6.5.2.3 UNBIND命令
此命令用于断开ESME和SMSC之间的连接。
UNBIND语法
此消息只有消息头,没有消息体,消息头中的Command_ID是“unbind"。
UNBIND_RESP语法
此消息只有消息头,没有消息体,消息头中的Command_ID是“unbind_resp"。
状态取值范围:
E_SUCCESS
E_OTHERERR
E_CMDLENERR
E_NORIGHT
*/
//typedef struct PDU_SMPP_HEAD PDU_SMPP_UNBIND;
//
//typedef struct PDU_SMPP_HEAD PDU_SMPP_UNBIND_RESP;

//class SMPP_UNBIND : public SMPP_PDU
//{
//public:
//	SMPP_UNBIND()
//		: nCommandID( e_ESME_UBD )
//	{
//	}
//};
//
//class SMPP_UNBIND_RESP : public SMPP_PDU
//{
//public:
//	SMPP_UNBIND_RESP()
//		: nCommandID( e_ESME_UBD_RESP )
//	{
//	}
//};

/**
6.5.2.4 SUBMIT_SM命令
此命令用于ESME提交短消息到SMSC,以便SMSC把此短消息发给特定的移动台。
SUBMIT_SM语法
消息头中的Command_ID是"submit_sm"
表7:SUBMIT_SM语法
字段	长度(字节)	类型	描述
service_type	最大6	C_OctetString	保留,必须设为0
source_address_ton	1	integer	源地址编码类型
source_address_npi	1	integer	源地址编码方案
source_address	最大21	C_DecString	源地址
dest_address_ton	1	integer	目的地址编码类型
dest_address_npi	1	integer	目的地址编码方案
destination_address	最大21	C_DecString	目的地址
esm_class	1	integer	短消息类型
protocol_ID	1	integer	GSM协议类型
priority_flag	1	integer	优先级
schedule_delivery_time	最大17	C_StringTime	计划下发短消息的时间
validity_peroid	最大17	C_StringTime	短消息的最后有效期限
registered_delivery_flag	1	integer	注册短消息标志

replace_if_present_flag	1	integer	替换短消息标志。

data_coding	1	integer	数据编码方案
sm_default_msg_id	1	integer	预定义短消息ID
sm_length	1	integer	短消息的长度
short_message_text	最大161	可变	短消息数据内容


SUBMIT_SM_RESP语法
消息头中的Command_ID是"submit_sm_resp"
表8:SUBMIT_SM_RESP语法
字段	长度(字节)	类型	描述
Message_id	最大9	C_HexString	短消息ID
状态取值范围:
E_SUCCESS
E_OTHERERR
E_CMDLENERR
E_NORIGHT

E_ADDRERR
E_MOEXCEED
E_MTEXCEED
E_INVLDUSER
E_INVLDDATAFMT
E_CREATEMSGFAILURE
E_INVLDORGTON
E_INVLDORGNPI
E_ORGADDRERR
E_INVLDDESTTON
E_INVLDDESTNPI
E_DESTADDRERR
E_INVLDSCHEDULE
E_INVLDEXPIRE
E_INVLDESM
E_INVLDUDLEN
E_INVLDPRI
E_INVLDRDF
E_INVLDRPF
*/
//##ModelId=46B5D42E01F7
typedef struct pdu_smpp_submit_deliver_sm {
	/**
	The service_type parameter can be used to indicate the SMS Application service associated
	with the message. Specifying the service_type allows the ESME to:-
	? Avail of enhanced messaging services such as message ‘replace_if_present’ by service type
	(generic).
	? Control the teleservice used on the air interface (e.g. ANSI-136/TDMA, IS-95/CDMA).
	SMSC’s may implicitly associate a “replace if present” function from the indicated
	service_type in a message submission operation, i.e., the SMSC will always replace an
	existing message pending delivery, that has the same originating and destination address as the
	submitted message. For example, an SMSC can ensure that a Voice Mail System using a
	service_type of “VMA” has at most one outstanding notification per destination MS by
	automatically invoking the “replace if present” function.
	The following generic service_types are defined:
	““ (NULL) Default
	“CMT” Cellular Messaging
	“CPT” Cellular Paging
	“VMN” Voice Mail Notification
	“VMA” Voice Mail Alerting
	“WAP” Wireless Application Protocol
	“USSD” Unstructured Supplementary Services Data
	All other values are carrier specific and are defined by mutual agreement between the SMSC
	Service Provider and the ESME application.
	*/
	char service_type[6];

⌨️ 快捷键说明

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