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

📄 smpp_message.h

📁 SMAL是short message abstract library的缩写,是由风起水流软件工作室(www.zealware.com)开发的一个支持短信网关系统开发的C++底层抽象接口库
💻 H
📖 第 1 页 / 共 3 页
字号:
	unsigned char source_address_ton;
	unsigned char source_address_npi;

	/**
	Specifies the address of SME which originated this message. An ESME which is implemented
	as a single SME address, may set this field to NULL to allow the SMSC to default the source
	address of the submitted message.
	Notes
	An IP address is specified in “aaa.bbb.ccc.ddd” notation. IP version 6.0 is not supported in V3.4
	of the SMPP protocol.
	*/
	char source_address[21];
	unsigned char dest_address_ton;
	unsigned char dest_address_npi;

	/**
	Specifies the destination SME address. For mobile terminated messages, this is the directory
	number of the recipient MS.
	Notes
	An IP address is specified in “aaa.bbb.ccc.ddd” notation. IP version 6.0 is not supported in V3.4
	of the SMPP protocol
	*/
	char destination_address[21];

	/**
	The esm_class parameter is used to indicate special message attributes associated with the short
	message.
	The esm_class parameter is encoded as follows in the submit_sm, submit_multi and data_sm
	(ESME -> SMSC) PDUs:
	Bits 7 6 5 4 3 2 1 0 Meaning
	Messaging Mode (bits 1-0)
	x x x x x x 0 0 Default SMSC Mode (e.g. Store and Forward)
	x x x x x x 0 1 Datagram mode
	x x x x x x 1 0 Forward (i.e. Transaction) mode
	x x x x x x 1 1 Store and Forward mode
	(use to select Store and Forward mode if Default SMSC Mode
	is non Store and Forward)
	Message Type (bits 5-2)
	x x 0 0 0 0 x x Default message Type (i.e. normal message)
	x x 0 0 1 0 x x Short Message contains ESME Delivery Acknowledgement
	x x 0 1 0 0 x x Short Message contains ESME Manual/User
	Acknowledgement
	GSM Network Specific Features (bits 7-6)
	0 0 x x x x x x No specific features selected
	0 1 x x x x x x UDHI Indicator (only relevant for MT short messages)
	1 0 x x x x x x Set Reply Path (only relevant for GSM network)
	1 1 x x x x x x Set UDHI and Reply Path (only relevant for GSM network)
	The esm_class parameter is encoded as follows in a deliver_sm and data_sm (SMSC -> ESME)
	PDUs:
	Bits 7 6 5 4 3 2 1 0 Meaning
	Message Mode (bits 1-0)
	x x x x x x x x not applicable - ignore bits 0 and 1
	Message Type (bits 5-2)
	x x 0 0 0 0 x x Default message Type (i.e. normal message)
	x x 0 0 0 1 x x Short Message contains SMSC Delivery Receipt
	x x 0 0 1 0 x x Short Message contains SME Delivery Acknowledgement
	x x 0 0 1 1 x x reserved
	x x 0 1 0 0 x x Short Message contains SME Manual/User Acknowledgment
	x x 0 1 0 1 x x reserved
	x x 0 1 1 0 x x Short Message contains Conversation Abort (Korean CDMA)
	x x 0 1 1 1 x x reserved
	x x 1 0 0 0 x x Short Message contains Intermediate Delivery Notification
	all other values reserved
	Page 122 of 169 ?SMPP Developers Forum Issue 1.2
	SMPP Parameter Definition SMPP Protocol Specification v3.4
	GSM Network Specific Features (bits 7-6)
	0 0 x x x x x x No specific features selected
	0 1 x x x x x x UDHI Indicator set
	1 0 x x x x x x Reply Path
	1 1 x x x x x x UDHI and Reply Path
	all other values reserved
	The default setting of the esm_class parameter is 0x00.
	Notes
	- If an ESME encodes GSM User Data Header information in the short message user data, it
	must set the UDHI flag in the esm_class field.
	- If the SMSC delivers a short message that contains GSM User Data Header information
	encoded in the short_message or message_payload parameter, it must set the UDHI flag in
	the esm_class field.
	- For GSM networks, the concatenation related optional parameters (sar_msg_ref_num,
	sar_total_segments, sar_segment_seqnum) or port addressing related optional parameters
	(source_port, destination_port) cannot be used in conjunction with encoded User Data
	Header in the short_message (user data) field. This means that the above listed optional
	parameters cannot be used if the User Data Header Indicator flag is set.
	*/
	unsigned char esm_class;

	/**
	GSM
	Set according to GSM 03.40 [GSM 03.40]
	ANSI-136 (TDMA)
	For mobile terminated messages, this field is not used and is therefore ignored by the SMSC.
	For ANSI-136 mobile originated messages, the SMSC should set this value to NULL.
	IS-95 (CDMA)
	For mobile terminated messages, this field is not used and is therefore ignored by the SMSC.
	For IS-95 mobile originated messages, the SMSC should set this value to NULL.
	*/
	unsigned char protocol_id;

	/**
	The priority_flag parameter allows the originating SME to assign a priority level to the short
	message.
	Four Priority Levels are supported:
	0 = Level 0 (lowest) priority
	1 = Level 1 priority
	2 = Level 2 priority
	3 = Level 3 (highest) priority
	>3=Reserved
	These are applied in different networks as follows:-
	Priority Level GSMa
	a. For GSM mobile terminated, messages with priority greater
	than Level 0 are treated as priority when making a delivery
	attempt (i.e. a delivery attempt is made even when MWD is
	set in the HLR)
	*/
	unsigned char priority_flag;

	/**
	This parameter specifies the scheduled time at which the message delivery should be first
	attempted.
	It defines either the absolute date and time or relative time from the current SMSC time at which
	delivery of this message will be attempted by the SMSC.
	It can be specified in either absolute time format or relative time format. The encoding of a time
	format is specified in Section 7.1.1.
	*/
	char schedule_delivery_time[17];

	/**
	The validity_period parameter indicates the SMSC expiration time, after which the message
	should be discarded if not delivered to the destination. It can be defined in absolute time format
	or relative time format. The encoding of absolute and relative time format is specified in Section
	7.1.1.
	*/
	char validity_peroid[17];

	/**
	The registered_delivery parameter is used to request an SMSC delivery receipt and/or SME
	originated acknowledgements. The following values are defined:
	Bits 7 6 5 4 3 2 1 0 Meaning
	SMSC Delivery Receipt (bits 1 and 0)
	x x x x x x 0 0 No SMSC Delivery Receipt requested (default)
	x x x x x x 0 1 SMSC Delivery Receipt requested where final delivery
	outcome is delivery success or failure
	x x x x x x 1 0 SMSC Delivery Receipt requested where the final
	delivery outcome is delivery failure
	x x x x x x 1 1 reserved
	SME originated Acknowledgement (bits 3 and 2)
	x x x x 0 0 x x No recipient SME acknowledgment requested (default)
	x x x x 0 1 x x SME Delivery Acknowledgement requested
	x x x x 1 0 x x SME Manual/User Acknowledgment requested
	x x x x 1 1 x x Both Delivery and Manual/User Acknowledgment requested
	Intermediate Notification (bit 5)
	x x x 0 x x x x No Intermediate notification requested (default)
	x x x 1 x x x x Intermediate notification requested **
	all other values reserved
	The default setting of the registered_delivery parameter is 0x00.
	Note: * A delivery receipt is returned only when the message has reached a non-delivered
	final state such as cancelled or undeliverable, etc.
	** Support for Intermediate Notification Functionality is specific to the SMSC
	implementation and is beyond the scope of the SMPP Protocol Specification. 
	*/
	unsigned char registered_delivery_flag;

	/**
	The replace_if_present_flag parameter is used to request the SMSC to replace a previously
	submitted message, that is still pending delivery. The SMSC will replace an existing message
	provided that the source address, destination address and service_type match the same fields in
	the new message.
	0 Don’t replace (default)
	1 Replace
	2 - 255 reserved
	ESME applications that use this SMSC messaging function should use the same service_type
	and set the replace_if_present_flag parameter consistently to “1” for all messages, including the
	first message. This ensures that the SMSC has at most one message pending per destination
	SME for a particular application (e.g. voice mail notification).
	*/
	unsigned char replace_if_present_flag;

	/**
	Bits 7 6 5 4 3 2 1 0 Meaning Notes
	0 0 0 0 0 0 0 0 SMSC Default Alphabet
	0 0 0 0 0 0 0 1 IA5 (CCITT T.50)/ASCII (ANSI X3.4) b
	0 0 0 0 0 0 1 0 Octet unspecified (8-bit binary) b
	0 0 0 0 0 0 1 1 Latin 1 (ISO-8859-1) b
	0 0 0 0 0 1 0 0 Octet unspecified (8-bit binary) a
	0 0 0 0 0 1 0 1 JIS (X 0208-1990) b
	0 0 0 0 0 1 1 0 Cyrllic (ISO-8859-5) b
	0 0 0 0 0 1 1 1 Latin/Hebrew (ISO-8859-8) b
	0 0 0 0 1 0 0 0 UCS2 (ISO/IEC-10646) a
	0 0 0 0 1 0 0 1 Pictogram Encoding b
	0 0 0 0 1 0 1 0 ISO-2022-JP (Music Codes) b
	0 0 0 0 1 0 1 1 reserved
	0 0 0 0 1 1 0 0 reserved
	0 0 0 0 1 1 0 1 Extended Kanji JIS(X 0212-1990) b
	0 0 0 0 1 1 1 0 KS C 5601 b
	0 0 0 0 1 1 1 1 reserved
	:
	1 0 1 1 1 1 1 1 reserved
	1 1 0 0 x x x x GSM MWI control - see [GSM 03.38] d
	1 1 0 1 x x x x GSM MWI control - see [GSM 03.38] d
	1 1 1 0 x x x x reserved
	1 1 1 1 x x x x GSM message class control - see [GSM 03.38] e
	Notes:
	a. These coding schemes are common to GSM, TDMA and CDMA. The SMPP protocol
	allows ESME applications to use the same DCS value (i.e. the GSM 03.38 value) for all
	three technologies.
	b. In cases where a Data Coding Scheme is defined for TDMA and/ or CDMA but not
	defined for GSM, SMPP uses GSM 03.38 reserved values.
	c. There is no default setting for the data_coding parameter.
	d. The data_coding parameter will evolve to specify Character code settings only. Thus the
	recommended way to specify GSM MWI control is by specifying the relevant settings in
	the optional parameters _ms_msg_wait_facilities and ms_validity.
	e. The data_coding parameter will evolve to specify Character code settings only. Thus the
	recommended way to specify GSM message class control is by specifying the relevant
	setting in the optional parameter dest_addr_subunit.
	*/
	unsigned char data_coding;

	/**
	The sm_default_msg_id parameter specifies the SMSC index of a pre-defined (‘canned’)
	message.
	0 reserved
	1 - 254 Allowed values
	255 Reserved
	*/
	unsigned char sm_default_msg_id;
	
	/**
	The sm_length parameter specifies the length of the short_message parameter in octets. The
	sm_length should be set to 0 in the submit_sm, submit_multi, and deliver_sm PDUs if the
	message_payload parameter is being used to send user data larger than 254 octets.
	0 no user data in short message field
	1-254 allowed
	255 not allowed
	*/
	unsigned char sm_length;

	/**
	The short_message parameter contains the user data. A maximum of 254 octets can be sent.
	ESME’s should use the optional message_payload parameter in submit_sm, submit_multi, and
	deliver_sm to send larger user data sizes.
	*/
	unsigned char short_message_text[161];

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

	//pdu_smpp_submit_deliver_sm() {
	//	memset(service_type, 0, 6);
	//	source_address_ton = 0;
	//	source_address_npi = 0;
	//	memset(source_address, 0, 21);
	//	dest_address_ton = 0;
	//	dest_address_npi = 0;
	//	memset(destination_address, 0, 21);
	//	esm_class = 0;
	//	protocol_id = 0;
	//	priority_flag = 0;
	//	memset(schedule_delivery_time, 0, 17);
	//	memset(validity_peroid, 0, 17);
	//	registered_delivery_flag = 0;
	//	replace_if_present_flag = 0;
	//	data_coding = 0;
	//	sm_default_msg_id = 0;
	//	sm_length = 0;
	//	memset(short_message_text, 0, 161);
	//}

} PDU_SMPP_SUBMIT_DELIVER_SM, PDU_SMPP_SUBMIT_SM, PDU_SMPP_DELIVER_SM;

//class SMPP_SUBMIT_SM : public SMPP_PDU
//{
//public:
//	string service_type;
//	unsigned char source_address_ton;
//	unsigned char source_address_npi;
//	string source_address;
//	unsigned char dest_address_ton;
//	unsigned char dest_address_npi;
//	string destination_address;
//	unsigned char esm_class;
//	unsigned char protocol_ID;
//	unsigned char priority_flag;
//	string schedule_delivery_time;
//	string validity_period;
//	unsigned char registered_delivery_flag;
//	unsigned char replace_if_present_flag;
//	unsigned char data_coding;
//	unsigned char sm_default_msg_id;
//	unsigned char sm_length;
//	string short_message_text;
//
//public:
//	SMPP_SUBMIT_SM()
//		: nCommandID( e_ESME_SUB_SM )
//	{
//	}
//};

//##ModelId=46B5D42E0232
typedef struct pdu_smpp_submit_deliver_sm_resp {
	/**
	The unique message identifier reference assigned by the SMSC to each submitted short
	message. It is an opaque value and is set according to SMSC implementation. It is returned by
	the SMSC in the submit_sm_resp, submit_multi_resp, deliver_sm_resp and data_sm_resp
	PDUs and may be used by the ESME in subsequent SMPP operations relating to the short
	message, e.g. the ESME can use the query_sm operation to query a previously submitted
	message using the SMSC message_id as the message handle.
	*/
	char message_id[9];

	/**接口库自定义的字段,消息流水号
	(和CMPP_HEAD里面的流水号相同,这里重复赋值是为了不必返回整个CMPP_HEAD)
	*/
	unsigned long command_status;
	unsigned long sequence_id;
} PDU_SMPP_SUBMIT_DELIVER_SM_RESP, PDU_SMPP_SUBMIT_SM_RESP, PDU_SMPP_DELIVER_SM_RESP;

//class SMPP_SUBMIT_SM_RESP : public SMPP_PDU
//{
//public:
//	string message_id;
//
//public:
//	SMPP_SUBMIT_SM_RESP()
//		: nCommandID( e_ESME_SUB_SM_RESP )
//	{
//	}
//};

/**
6.5.2.5 DELIVER_SM命令
此命令由SMSC产生,SMSC通过此命令发送短消息到目的ESME,它也可用于发送转发状态报告(DELIVERY RECEIPT)消息。
DELIVER_SM语法
它的语法和SUBMIT_SM的语法消息体是相同的,只是在消息头中的Command_ID是“deliver_sm"。
DELIVER_SM_RESP语法
它的语法和SUBMIT_SM_RESP的语法消息体是一样的,只是在消息头中的Command_ID是“deliver_sm_resp"。
*/
//typedef struct PDU_SMPP_SUBMIT_SM PDU_SMPP_DELIVER_SM;
//
//typedef struct PDU_SMPP_SUBMIT_SM_RESP PDU_SMPP_DELIVER_SM_RESP;

//class SMPP_DELIVERY_SM : public SMPP_SUBMIT_SM
//{
//public:
//	SMPP_DELIVERY_SM()
//		: nCommandID( e_ESME_DELIVER_SM )
//	{
//	}
//};
//
//class SMPP_DELIVERY_SM_RESP : public SMPP_SUBMIT_SM_RESP
//{
//public:
//	SMPP_DELIVERY_SM_RESP()
//		: nCommandID( e_ESME_DELIVER_SM_RESP)
//	{
//	}
//};

/**
6.5.2.6 QUERY_SM命令
此命令用于ESME向SMSC查询以前所提交的短消息的状态。
QUERY_SM语法
消息头中的Command_ID是"query_sm"
表9:QUERY_SM语法
字段		长度(字节)		类型		描述
Message_id	最大9	C_HexString	短消息ID
Ton	1	Integer	地址编码类型
Npi	1	Integer	地址编码方案
Address	最大21	C_DecString	地址
QUERY_SM_RESP语法
消息头中的Command_ID是"query_sm_resp"
表10:QUERY_SM_RESP语法
字段	长度(字节)	类型	描述
Message_id	最大9	C_HexString	短消息ID
final_date	最大17	C_StringTime	短消息生命周期终止时间
Message_status	1	Integer	短消息当前的状态

GSM_code	1	Integer	GSM错误码

状态取值范围:
E_SUCCESS
E_OTHERERR
E_CMDLENERR
E_NORIGHT

E_ADDRERR
E_INVLDMSGID
E_DATABASEFAILURE

E_INVLDORGTON
E_INVLDORGNPI
E_ORGADDRERR
*/
//class SMPP_QUERY_SM : public SMPP_PDU
//{
//public:
//	string message_id;
//	unsigned char ton;
//	unsigned char npi;
//	string address;
//
//public:
//	SMPP_QUERY_SM()
//		: nCommandID( e_ESME_QUERY_SM )
//	{
//	}
//};
//
//class SMPP_QUERY_SM_RESP : public SMPP_PDU
//{
//public:
//	string message_id;
//	string final_date;
//	unsigned char message_status;
//	unsigned char gsm_code;
//
//public:
//	SMPP_QUERY_SM_RESP() 
//		: nCommandID( e_ESME_QUERY_SM_RESP )
//	{
//	}
//};

/**
6.5.2.7 CANCEL_SM命令
此命令用于取消ESME以前所提交的短消息。此命令能取消指定短消息ID的短消息,也可取消等待下发的由CANCEL_SM所确定的源地址和目的址的所有短消息(此时,message_id为NULL)。
CANCEL_SM语法
消息头中的Command_ID是"cancel_sm"
表11:CANCEL_SM语法
字段		长度(字节)		类型		描述
service_type	最大6	C_OctetString 	保留,必须设为NULL
message_id	最大9	C_HexString	短消息ID,设置为NULL时表示取消所有源编码地址和目标编码地址与下述地址相同的短消息
source_address_ton	1	Integer	源地址编码类型
source_address_npi	1	Integer	源地址编码方案
source_address	最大21	C_DecString	源地址

⌨️ 快捷键说明

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