anthill_smpp_ruby 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -0
- data/README +30 -0
- data/anthill_smpp_ruby.gemspec +18 -0
- data/changelog +43 -0
- data/data/dumps/random_command.dump +1 -0
- data/data/dumps/smpp_alert_notification.dump +1 -0
- data/data/dumps/smpp_bind_receiver.dump +1 -0
- data/data/dumps/smpp_bind_receiver_resp.dump +1 -0
- data/data/dumps/smpp_bind_transceiver.dump +1 -0
- data/data/dumps/smpp_bind_transceiver_1.dump +2 -0
- data/data/dumps/smpp_bind_transceiver_resp.dump +1 -0
- data/data/dumps/smpp_bind_transmitter.dump +1 -0
- data/data/dumps/smpp_bind_transmitter_resp.dump +1 -0
- data/data/dumps/smpp_broadcast_sm.dump +1 -0
- data/data/dumps/smpp_broadcast_sm_resp.dump +1 -0
- data/data/dumps/smpp_cancel_broadcast_sm.dump +1 -0
- data/data/dumps/smpp_cancel_broadcast_sm_resp.dump +1 -0
- data/data/dumps/smpp_cancel_sm.dump +1 -0
- data/data/dumps/smpp_cancel_sm_resp.dump +1 -0
- data/data/dumps/smpp_data_sm.dump +1 -0
- data/data/dumps/smpp_data_sm_resp.dump +1 -0
- data/data/dumps/smpp_deliver_sm.dump +1 -0
- data/data/dumps/smpp_deliver_sm_resp.dump +1 -0
- data/data/dumps/smpp_enquire_link.dump +1 -0
- data/data/dumps/smpp_enquire_link_resp.dump +1 -0
- data/data/dumps/smpp_generic_nack.dump +1 -0
- data/data/dumps/smpp_outbind.dump +1 -0
- data/data/dumps/smpp_query_broadcast_sm.dump +1 -0
- data/data/dumps/smpp_query_broadcast_sm_resp.dump +1 -0
- data/data/dumps/smpp_query_broadcast_sm_resp_1.dump +1 -0
- data/data/dumps/smpp_query_sm.dump +1 -0
- data/data/dumps/smpp_query_sm_resp.dump +1 -0
- data/data/dumps/smpp_replace_sm.dump +1 -0
- data/data/dumps/smpp_replace_sm_resp.dump +1 -0
- data/data/dumps/smpp_submit_multi.dump +1 -0
- data/data/dumps/smpp_submit_multi_resp.dump +1 -0
- data/data/dumps/smpp_submit_sm.dump +1 -0
- data/data/dumps/smpp_submit_sm_resp.dump +1 -0
- data/data/dumps/smpp_unbind.dump +1 -0
- data/data/dumps/smpp_unbind_resp.dump +1 -0
- data/data/pdus/random_command.xml +35 -0
- data/data/pdus/smpp_alert_notification.xml +14 -0
- data/data/pdus/smpp_alert_notification_no_optional.xml +13 -0
- data/data/pdus/smpp_bind_receiver.xml +17 -0
- data/data/pdus/smpp_bind_receiver_resp.xml +12 -0
- data/data/pdus/smpp_bind_receiver_resp_no_optional.xml +11 -0
- data/data/pdus/smpp_bind_transceiver.xml +17 -0
- data/data/pdus/smpp_bind_transceiver_resp.xml +12 -0
- data/data/pdus/smpp_bind_transceiver_resp_no_optional.xml +11 -0
- data/data/pdus/smpp_bind_transmitter.xml +17 -0
- data/data/pdus/smpp_bind_transmitter_resp.xml +12 -0
- data/data/pdus/smpp_bind_transmitter_resp_no_optional.xml +11 -0
- data/data/pdus/smpp_broadcast_sm.xml +47 -0
- data/data/pdus/smpp_broadcast_sm_no_optional.xml +26 -0
- data/data/pdus/smpp_broadcast_sm_resp.xml +14 -0
- data/data/pdus/smpp_broadcast_sm_resp_no_optional.xml +8 -0
- data/data/pdus/smpp_cancel_broadcast_sm.xml +17 -0
- data/data/pdus/smpp_cancel_broadcast_sm_no_optional.xml +15 -0
- data/data/pdus/smpp_cancel_broadcast_sm_resp.xml +7 -0
- data/data/pdus/smpp_cancel_sm.xml +18 -0
- data/data/pdus/smpp_cancel_sm_resp.xml +10 -0
- data/data/pdus/smpp_commands.xsd +914 -0
- data/data/pdus/smpp_data_sm.xml +58 -0
- data/data/pdus/smpp_data_sm_no_optional.xml +17 -0
- data/data/pdus/smpp_data_sm_resp.xml +15 -0
- data/data/pdus/smpp_data_sm_resp_no_optional.xml +8 -0
- data/data/pdus/smpp_deliver_sm.xml +46 -0
- data/data/pdus/smpp_deliver_sm_no_optional.xml +25 -0
- data/data/pdus/smpp_deliver_sm_resp.xml +14 -0
- data/data/pdus/smpp_deliver_sm_resp_no_optional.xml +8 -0
- data/data/pdus/smpp_enquire_link.xml +10 -0
- data/data/pdus/smpp_enquire_link_resp.xml +10 -0
- data/data/pdus/smpp_generic_nack.xml +10 -0
- data/data/pdus/smpp_outbind.xml +12 -0
- data/data/pdus/smpp_query_broadcast_sm.xml +12 -0
- data/data/pdus/smpp_query_broadcast_sm_no_optional.xml +11 -0
- data/data/pdus/smpp_query_broadcast_sm_resp.xml +17 -0
- data/data/pdus/smpp_query_broadcast_sm_resp_no_optional.xml +15 -0
- data/data/pdus/smpp_query_sm.xml +11 -0
- data/data/pdus/smpp_query_sm_resp.xml +11 -0
- data/data/pdus/smpp_replace_sm.xml +18 -0
- data/data/pdus/smpp_replace_sm_no_optional.xml +17 -0
- data/data/pdus/smpp_replace_sm_resp.xml +7 -0
- data/data/pdus/smpp_submit_multi.xml +73 -0
- data/data/pdus/smpp_submit_multi_no_optional.xml +51 -0
- data/data/pdus/smpp_submit_multi_resp.xml +35 -0
- data/data/pdus/smpp_submit_sm.xml +57 -0
- data/data/pdus/smpp_submit_sm_no_optional.xml +28 -0
- data/data/pdus/smpp_submit_sm_resp.xml +8 -0
- data/data/pdus/smpp_unbind.xml +10 -0
- data/data/pdus/smpp_unbind_resp.xml +10 -0
- data/examples/dump_viewer.rb +298 -0
- data/examples/pdu_composer.rb +1331 -0
- data/knownbugs +24 -0
- data/lib/anthill_smpp_ruby.rb +83 -0
- data/lib/i_smpp_outputter.rb +425 -0
- data/lib/pdu/smpp_alert_notification.rb +132 -0
- data/lib/pdu/smpp_bind.rb +102 -0
- data/lib/pdu/smpp_bind_receiver.rb +29 -0
- data/lib/pdu/smpp_bind_receiver_resp.rb +30 -0
- data/lib/pdu/smpp_bind_resp.rb +100 -0
- data/lib/pdu/smpp_bind_transceiver.rb +29 -0
- data/lib/pdu/smpp_bind_transceiver_resp.rb +31 -0
- data/lib/pdu/smpp_bind_transmitter.rb +29 -0
- data/lib/pdu/smpp_bind_transmitter_resp.rb +30 -0
- data/lib/pdu/smpp_broadcast_sm.rb +566 -0
- data/lib/pdu/smpp_broadcast_sm_resp.rb +130 -0
- data/lib/pdu/smpp_cancel_broadcast_sm.rb +143 -0
- data/lib/pdu/smpp_cancel_broadcast_sm_resp.rb +60 -0
- data/lib/pdu/smpp_cancel_sm.rb +110 -0
- data/lib/pdu/smpp_cancel_sm_resp.rb +60 -0
- data/lib/pdu/smpp_data_sm.rb +679 -0
- data/lib/pdu/smpp_data_sm_resp.rb +148 -0
- data/lib/pdu/smpp_deliver_sm.rb +458 -0
- data/lib/pdu/smpp_deliver_sm_resp.rb +137 -0
- data/lib/pdu/smpp_enquire_link.rb +59 -0
- data/lib/pdu/smpp_enquire_link_resp.rb +61 -0
- data/lib/pdu/smpp_generic_nack.rb +61 -0
- data/lib/pdu/smpp_outbind.rb +71 -0
- data/lib/pdu/smpp_pdu.rb +90 -0
- data/lib/pdu/smpp_query_broadcast_sm.rb +120 -0
- data/lib/pdu/smpp_query_broadcast_sm_resp.rb +192 -0
- data/lib/pdu/smpp_query_sm.rb +92 -0
- data/lib/pdu/smpp_query_sm_resp.rb +92 -0
- data/lib/pdu/smpp_replace_sm.rb +172 -0
- data/lib/pdu/smpp_replace_sm_resp.rb +61 -0
- data/lib/pdu/smpp_resp.rb +40 -0
- data/lib/pdu/smpp_submit_multi.rb +517 -0
- data/lib/pdu/smpp_submit_multi_resp.rb +90 -0
- data/lib/pdu/smpp_submit_sm.rb +591 -0
- data/lib/pdu/smpp_submit_sm_resp.rb +72 -0
- data/lib/pdu/smpp_unbind.rb +60 -0
- data/lib/pdu/smpp_unbind_resp.rb +61 -0
- data/lib/smpp_constants.rb +917 -0
- data/lib/smpp_csv_outputter.rb +1601 -0
- data/lib/smpp_datatypes.rb +89 -0
- data/lib/smpp_decoder.rb +627 -0
- data/lib/smpp_encoder.rb +495 -0
- data/lib/smpp_hex_outputter.rb +36 -0
- data/lib/smpp_outputter_base.rb +315 -0
- data/lib/smpp_structures.rb +98 -0
- data/lib/smpp_txt_outputter.rb +1895 -0
- data/lib/smpp_validator.rb +373 -0
- data/lib/smpp_xml_outputter.rb +34 -0
- data/roadmap +18 -0
- data/setup.rb +1585 -0
- data/test/anthill_smpp_test.rb +29 -0
- data/test/smpp_codec_test.rb +30 -0
- data/test/smpp_datatypes_test.rb +69 -0
- data/test/smpp_outputter_test.rb +1261 -0
- data/test/smpp_parsing_test.rb +1758 -0
- data/test/smpp_rawdump_test.rb +2095 -0
- data/test/smpp_validator_test.rb +441 -0
- metadata +206 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2007 Majoron.com (developers@majoron.com)
|
3
|
+
# Original sources are available at www.majoron.com
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
|
19
|
+
module Majoron
|
20
|
+
module AntHill
|
21
|
+
module SMPP
|
22
|
+
class SMPPDataSMResp < SMPPResp
|
23
|
+
# Constructor.
|
24
|
+
def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
|
25
|
+
super(CommandId::CM_DATA_SM_RESP, command_status, sequence_number)
|
26
|
+
|
27
|
+
# Mandatory fields
|
28
|
+
@message_id = ""
|
29
|
+
|
30
|
+
# Optional fields
|
31
|
+
@delivery_failure_reason = nil
|
32
|
+
@network_error_code = nil
|
33
|
+
@additional_status_info_text = nil
|
34
|
+
@dpf_result = nil
|
35
|
+
|
36
|
+
# Optional fields length
|
37
|
+
@delivery_failure_reason_len = SMPPTLVLen::BYTE_LEN
|
38
|
+
@network_error_code_len = SMPPTLVLen::BYTE_LEN + SMPPTLVLen::WORD_LEN
|
39
|
+
@additional_status_info_text_len = SMPPTLVLen::ZERO_LEN
|
40
|
+
@dpf_result_len = SMPPTLVLen::BYTE_LEN
|
41
|
+
end
|
42
|
+
# Interface to encode SMPP packet
|
43
|
+
def encode_packet(encoder)
|
44
|
+
# Encode header and mandatory fields
|
45
|
+
encoder.encode_header(@header)
|
46
|
+
encoder.encode_message_id(@message_id)
|
47
|
+
|
48
|
+
# Encode optional fields
|
49
|
+
encoder.encode_delivery_failure_reason(@delivery_failure_reason,
|
50
|
+
@delivery_failure_reason_len) if !@delivery_failure_reason.nil?
|
51
|
+
encoder.encode_network_error_code(@network_error_code,
|
52
|
+
@network_error_code_len) if !@network_error_code.nil?
|
53
|
+
encoder.encode_additional_status_info_text(@additional_status_info_text,
|
54
|
+
@additional_status_info_text_len) if !@additional_status_info_text.nil?
|
55
|
+
encoder.encode_dpf_result(@dpf_result,
|
56
|
+
@dpf_result_len) if !@dpf_result.nil?
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# Interface to decode SMPP packet
|
61
|
+
def decode_packet(decoder)
|
62
|
+
# Decode header and mandatory fields
|
63
|
+
@header = decoder.decode_header()
|
64
|
+
@message_id = decoder.decode_message_id(command_length())
|
65
|
+
|
66
|
+
# Decode optional fields
|
67
|
+
while decoder.has_tlvs()
|
68
|
+
case decoder.get_tlv_code()
|
69
|
+
when OptTags::TAG_DELIVERY_FAILURE_REASON
|
70
|
+
@delivery_failure_reason, @delivery_failure_reason_len =
|
71
|
+
decoder.decode_delivery_failure_reason(command_length())
|
72
|
+
when OptTags::TAG_NETWORK_ERROR_CODE
|
73
|
+
@network_error_code, @network_error_code_len =
|
74
|
+
decoder.decode_network_error_code(command_length())
|
75
|
+
when OptTags::TAG_ADDITIONAL_STATUS_INFO_TEXT
|
76
|
+
@additional_status_info_text, @additional_status_info_text_len =
|
77
|
+
decoder.decode_additional_status_info_text(command_length())
|
78
|
+
when OptTags::TAG_DPF_RESULT
|
79
|
+
@dpf_result, @dpf_result_len =
|
80
|
+
decoder.decode_dpf_result(command_length())
|
81
|
+
else
|
82
|
+
# Report about error
|
83
|
+
raise Errors::UNKNOWN_TAG_MSG + decoder.get_tlv_error()
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Interface to validate SMPP packet
|
89
|
+
def validate_packet(validator)
|
90
|
+
# Validate header and mandatory fields
|
91
|
+
validator.validate_header(@header)
|
92
|
+
validator.validate_message_id(@message_id)
|
93
|
+
|
94
|
+
# Validate optional fields
|
95
|
+
validator.validate_delivery_failure_reason(@delivery_failure_reason,
|
96
|
+
@delivery_failure_reason_len) if !@delivery_failure_reason.nil?
|
97
|
+
validator.validate_network_error_code(@network_error_code,
|
98
|
+
@network_error_code_len) if !@network_error_code.nil?
|
99
|
+
validator.validate_additional_status_info_text(@additional_status_info_text,
|
100
|
+
@additional_status_info_text_len) if !@additional_status_info_text.nil?
|
101
|
+
validator.validate_dpf_result(@dpf_result,
|
102
|
+
@dpf_result_len) if !@dpf_result.nil?
|
103
|
+
end
|
104
|
+
|
105
|
+
# Interface to output SMPP packet
|
106
|
+
def output_packet(outputter)
|
107
|
+
# Output header and mandatory fields
|
108
|
+
outputter.output_header(@header)
|
109
|
+
outputter.output_message_id(@message_id)
|
110
|
+
|
111
|
+
# Output optional fields
|
112
|
+
outputter.output_delivery_failure_reason(@delivery_failure_reason,
|
113
|
+
@delivery_failure_reason_len) if !@delivery_failure_reason.nil?
|
114
|
+
outputter.output_network_error_code(@network_error_code,
|
115
|
+
@network_error_code_len) if !@network_error_code.nil?
|
116
|
+
outputter.output_additional_status_info_text(@additional_status_info_text,
|
117
|
+
@additional_status_info_text_len) if !@additional_status_info_text.nil?
|
118
|
+
outputter.output_dpf_result(@dpf_result,
|
119
|
+
@dpf_result_len) if !@dpf_result.nil?
|
120
|
+
end
|
121
|
+
|
122
|
+
public
|
123
|
+
def additional_status_info_text=(additional_status_info_text)
|
124
|
+
@additional_status_info_text = additional_status_info_text
|
125
|
+
@additional_status_info_text_len = additional_status_info_text.size()
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
public
|
130
|
+
# Mandatory fields
|
131
|
+
attr_accessor :message_id
|
132
|
+
|
133
|
+
# Optional fields
|
134
|
+
attr_accessor :delivery_failure_reason
|
135
|
+
attr_accessor :network_error_code
|
136
|
+
attr_reader :additional_status_info_text
|
137
|
+
attr_accessor :dpf_result
|
138
|
+
|
139
|
+
# Optional fields length
|
140
|
+
attr_accessor :delivery_failure_reason_len
|
141
|
+
attr_accessor :network_error_code_len
|
142
|
+
attr_accessor :additional_status_info_text_len
|
143
|
+
attr_accessor :dpf_result_len
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,458 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2007 Majoron.com (developers@majoron.com)
|
3
|
+
# Original sources are available at www.majoron.com
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
|
19
|
+
module Majoron
|
20
|
+
module AntHill
|
21
|
+
module SMPP
|
22
|
+
class SMPPDeliverSM < SMPPPDU
|
23
|
+
def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
|
24
|
+
super(CommandId::CM_DELIVER_SM, command_status, sequence_number)
|
25
|
+
|
26
|
+
# Mandatory fields
|
27
|
+
@service_type = ""
|
28
|
+
@source_addr_ton = 0
|
29
|
+
@source_addr_npi = 0
|
30
|
+
@source_addr = ""
|
31
|
+
@dest_addr_ton = 0
|
32
|
+
@dest_addr_npi = 0
|
33
|
+
@dest_addr = ""
|
34
|
+
@esm_class = 0
|
35
|
+
@protocol_id = 0
|
36
|
+
@priority_flag = 0
|
37
|
+
@schedule_delivery_time = ""
|
38
|
+
@validity_period = ""
|
39
|
+
@registered_delivery = 0
|
40
|
+
@replace_if_present_flag = 0
|
41
|
+
@data_coding = ""
|
42
|
+
@sm_default_msg_id = 0
|
43
|
+
@sm_length = 0
|
44
|
+
@short_message = ""
|
45
|
+
|
46
|
+
|
47
|
+
# Optional fields
|
48
|
+
@user_message_reference = nil
|
49
|
+
@source_port = nil
|
50
|
+
@destination_port = nil
|
51
|
+
@sar_msg_ref_num = nil
|
52
|
+
@sar_total_segments = nil
|
53
|
+
@sar_segment_seqnum = nil
|
54
|
+
@user_response_code = nil
|
55
|
+
@privacy_indicator = nil
|
56
|
+
@payload_type = nil
|
57
|
+
@message_payload = nil
|
58
|
+
@callback_num = nil
|
59
|
+
@source_subaddress = nil
|
60
|
+
@dest_subaddress = nil
|
61
|
+
@language_indicator = nil
|
62
|
+
@its_session_info = nil
|
63
|
+
@network_error_code = nil
|
64
|
+
@message_state = nil
|
65
|
+
@receipted_message_id = nil
|
66
|
+
|
67
|
+
# Optional fields len
|
68
|
+
@user_message_reference_len = SMPPTLVLen::WORD_LEN
|
69
|
+
@source_port_len = SMPPTLVLen::WORD_LEN
|
70
|
+
@destination_port_len = SMPPTLVLen::WORD_LEN
|
71
|
+
@sar_msg_ref_num_len = SMPPTLVLen::WORD_LEN
|
72
|
+
@sar_total_segments_len = SMPPTLVLen::BYTE_LEN
|
73
|
+
@sar_segment_seqnum_len = SMPPTLVLen::BYTE_LEN
|
74
|
+
@user_response_code_len = SMPPTLVLen::BYTE_LEN
|
75
|
+
@privacy_indicator_len = SMPPTLVLen::BYTE_LEN
|
76
|
+
@payload_type_len = SMPPTLVLen::BYTE_LEN
|
77
|
+
@message_payload_len = SMPPTLVLen::ZERO_LEN
|
78
|
+
@callback_num_len = SMPPTLVLen::ZERO_LEN
|
79
|
+
@source_subaddress_len = SMPPTLVLen::ZERO_LEN
|
80
|
+
@dest_subaddress_len = SMPPTLVLen::ZERO_LEN
|
81
|
+
@language_indicator_len = SMPPTLVLen::BYTE_LEN
|
82
|
+
@its_session_info_len = SMPPTLVLen::WORD_LEN
|
83
|
+
@network_error_code_len = SMPPTLVLen::BYTE_LEN + SMPPTLVLen::WORD_LEN
|
84
|
+
@message_state_len = SMPPTLVLen::BYTE_LEN
|
85
|
+
@receipted_message_id_len = SMPPTLVLen::ZERO_LEN
|
86
|
+
end
|
87
|
+
# Interface to encode SMPP packet
|
88
|
+
def encode_packet(encoder)
|
89
|
+
# Encode header and mandatory fields
|
90
|
+
encoder.encode_header(@header)
|
91
|
+
encoder.encode_service_type(@service_type)
|
92
|
+
encoder.encode_source_addr_ton(@source_addr_ton)
|
93
|
+
encoder.encode_source_addr_npi(@source_addr_npi)
|
94
|
+
encoder.encode_source_addr21(@source_addr)
|
95
|
+
encoder.encode_dest_addr_ton(@dest_addr_ton)
|
96
|
+
encoder.encode_dest_addr_npi(@dest_addr_npi)
|
97
|
+
encoder.encode_dest_addr21(@dest_addr)
|
98
|
+
encoder.encode_esm_class(@esm_class)
|
99
|
+
encoder.encode_protocol_id(@protocol_id)
|
100
|
+
encoder.encode_priority_flag(@priority_flag)
|
101
|
+
encoder.encode_schedule_delivery_time(@schedule_delivery_time)
|
102
|
+
encoder.encode_validity_period(@validity_period)
|
103
|
+
encoder.encode_registered_delivery(@registered_delivery)
|
104
|
+
encoder.encode_replace_if_present_flag(@replace_if_present_flag)
|
105
|
+
encoder.encode_data_coding(@data_coding)
|
106
|
+
encoder.encode_sm_default_msg_id(@sm_default_msg_id)
|
107
|
+
encoder.encode_sm_length(@sm_length)
|
108
|
+
encoder.encode_short_message(@short_message)
|
109
|
+
|
110
|
+
|
111
|
+
# Encode optional fields
|
112
|
+
encoder.encode_user_message_reference(@user_message_reference,
|
113
|
+
@user_message_reference_len) if !@user_message_reference.nil?
|
114
|
+
encoder.encode_source_port(@source_port,
|
115
|
+
@source_port_len) if !@source_port.nil?
|
116
|
+
encoder.encode_destination_port(@destination_port,
|
117
|
+
@destination_port_len) if !@destination_port.nil?
|
118
|
+
encoder.encode_sar_msg_ref_num(@sar_msg_ref_num,
|
119
|
+
@sar_msg_ref_num_len) if !@sar_msg_ref_num.nil?
|
120
|
+
encoder.encode_sar_total_segments(@sar_total_segments,
|
121
|
+
@sar_total_segments_len) if !@sar_total_segments.nil?
|
122
|
+
encoder.encode_sar_segment_seqnum(@sar_segment_seqnum,
|
123
|
+
@sar_segment_seqnum_len) if !@sar_segment_seqnum.nil?
|
124
|
+
encoder.encode_user_response_code(@user_response_code,
|
125
|
+
@user_response_code_len) if !@user_response_code.nil?
|
126
|
+
encoder.encode_privacy_indicator(@privacy_indicator,
|
127
|
+
@privacy_indicator_len) if !@privacy_indicator.nil?
|
128
|
+
encoder.encode_payload_type(@payload_type,
|
129
|
+
@payload_type_len) if !@payload_type.nil?
|
130
|
+
encoder.encode_message_payload(@message_payload,
|
131
|
+
@message_payload_len) if !@message_payload.nil?
|
132
|
+
encoder.encode_callback_num(@callback_num,
|
133
|
+
@callback_num_len) if !@callback_num.nil?
|
134
|
+
encoder.encode_source_subaddress(@source_subaddress,
|
135
|
+
@source_subaddress_len) if !@source_subaddress.nil?
|
136
|
+
encoder.encode_dest_subaddress(@dest_subaddress,
|
137
|
+
@dest_subaddress_len) if !@dest_subaddress.nil?
|
138
|
+
encoder.encode_language_indicator(@language_indicator,
|
139
|
+
@language_indicator_len) if !@language_indicator.nil?
|
140
|
+
encoder.encode_its_session_info(@its_session_info,
|
141
|
+
@its_session_info_len) if !@its_session_info.nil?
|
142
|
+
encoder.encode_network_error_code(@network_error_code,
|
143
|
+
@network_error_code_len) if !@network_error_code.nil?
|
144
|
+
encoder.encode_message_state_tlv(@message_state,
|
145
|
+
@message_state_len) if !@message_state.nil?
|
146
|
+
encoder.encode_receipted_message_id(@receipted_message_id,
|
147
|
+
@receipted_message_id_len) if !@receipted_message_id.nil?
|
148
|
+
end
|
149
|
+
|
150
|
+
# Interface to decode SMPP packet
|
151
|
+
def decode_packet(decoder)
|
152
|
+
# Decode header and mandatory fields
|
153
|
+
@header = decoder.decode_header()
|
154
|
+
@service_type = decoder.decode_service_type(command_length())
|
155
|
+
@source_addr_ton = decoder.decode_source_addr_ton(command_length())
|
156
|
+
@source_addr_npi = decoder.decode_source_addr_npi(command_length())
|
157
|
+
@source_addr = decoder.decode_source_addr21(command_length())
|
158
|
+
@dest_addr_ton = decoder.decode_dest_addr_ton(command_length())
|
159
|
+
@dest_addr_npi = decoder.decode_dest_addr_npi(command_length())
|
160
|
+
@dest_addr = decoder.decode_dest_addr21(command_length())
|
161
|
+
@esm_class = decoder.decode_esm_class(command_length())
|
162
|
+
@protocol_id = decoder.decode_protocol_id(command_length())
|
163
|
+
@priority_flag = decoder.decode_priority_flag(command_length())
|
164
|
+
@schedule_delivery_time = decoder.decode_schedule_delivery_time(command_length())
|
165
|
+
@validity_period = decoder.decode_validity_period(command_length())
|
166
|
+
@registered_delivery = decoder.decode_registered_delivery(command_length())
|
167
|
+
@replace_if_present_flag = decoder.decode_replace_if_present_flag(command_length())
|
168
|
+
@data_coding = decoder.decode_data_coding(command_length())
|
169
|
+
@sm_default_msg_id = decoder.decode_sm_default_msg_id(command_length())
|
170
|
+
@sm_length = decoder.decode_sm_length(command_length())
|
171
|
+
@short_message = decoder.decode_short_message(@sm_length, command_length())
|
172
|
+
|
173
|
+
# Decode optional fields
|
174
|
+
while decoder.has_tlvs()
|
175
|
+
case decoder.get_tlv_code()
|
176
|
+
when OptTags::TAG_USER_MESSAGE_REFERENCE
|
177
|
+
@user_message_reference, @user_message_reference_len =
|
178
|
+
decoder.decode_user_message_reference(command_length())
|
179
|
+
when OptTags::TAG_SOURCE_PORT
|
180
|
+
@source_port, @source_port_len =
|
181
|
+
decoder.decode_source_port(command_length())
|
182
|
+
when OptTags::TAG_DESTINATION_PORT
|
183
|
+
@destination_port, @destination_port_len =
|
184
|
+
decoder.decode_destination_port(command_length())
|
185
|
+
when OptTags::TAG_SAR_MSG_REF_NUM
|
186
|
+
@sar_msg_ref_num, @sar_msg_ref_num_len =
|
187
|
+
decoder.decode_sar_msg_ref_num(command_length())
|
188
|
+
when OptTags::TAG_SAR_TOTAL_SEGMENTS
|
189
|
+
@sar_total_segments, @sar_total_segments_len =
|
190
|
+
decoder.decode_sar_total_segments(command_length())
|
191
|
+
when OptTags::TAG_SAR_SEGMENT_SEQNUM
|
192
|
+
@sar_segment_seqnum, @sar_segment_seqnum_len =
|
193
|
+
decoder.decode_sar_segment_seqnum(command_length())
|
194
|
+
when OptTags::TAG_USER_RESPONSE_CODE
|
195
|
+
@user_response_code, @user_response_code_len =
|
196
|
+
decoder.decode_user_response_code(command_length())
|
197
|
+
when OptTags::TAG_PRIVACY_INDICATOR
|
198
|
+
@privacy_indicator, @privacy_indicator_len =
|
199
|
+
decoder.decode_privacy_indicator(command_length())
|
200
|
+
when OptTags::TAG_PAYLOAD_TYPE
|
201
|
+
@payload_type, @payload_type_len =
|
202
|
+
decoder.decode_payload_type(command_length())
|
203
|
+
when OptTags::TAG_MESSAGE_PAYLOAD
|
204
|
+
@message_payload, @message_payload_len =
|
205
|
+
decoder.decode_message_payload(command_length())
|
206
|
+
when OptTags::TAG_CALLBACK_NUM
|
207
|
+
@callback_num, @callback_num_len =
|
208
|
+
decoder.decode_callback_num(command_length())
|
209
|
+
when OptTags::TAG_SOURCE_SUBADDRESS
|
210
|
+
@source_subaddress, @source_subaddress_len =
|
211
|
+
decoder.decode_source_subaddress(command_length())
|
212
|
+
when OptTags::TAG_DEST_SUBADDRESS
|
213
|
+
@dest_subaddress, @dest_subaddress_len =
|
214
|
+
decoder.decode_dest_subaddress(command_length())
|
215
|
+
when OptTags::TAG_LANGUAGE_INDICATOR
|
216
|
+
@language_indicator, @language_indicator_len =
|
217
|
+
decoder.decode_language_indicator(command_length())
|
218
|
+
when OptTags::TAG_ITS_SESSION_INFO
|
219
|
+
@its_session_info, @its_session_info_len =
|
220
|
+
decoder.decode_its_session_info(command_length())
|
221
|
+
when OptTags::TAG_NETWORK_ERROR_CODE
|
222
|
+
@network_error_code, @network_error_code_len =
|
223
|
+
decoder.decode_network_error_code(command_length())
|
224
|
+
when OptTags::TAG_MESSAGE_STATE
|
225
|
+
@message_state, @message_state_len =
|
226
|
+
decoder.decode_message_state_tlv(command_length())
|
227
|
+
when OptTags::TAG_RECEIPTED_MESSAGE_ID
|
228
|
+
@receipted_message_id, @receipted_message_id_len =
|
229
|
+
decoder.decode_receipted_message_id(command_length())
|
230
|
+
else
|
231
|
+
# Report about error
|
232
|
+
raise Errors::UNKNOWN_TAG_MSG + decoder.get_tlv_error()
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Interface to validate SMPP packet
|
238
|
+
def validate_packet(validator)
|
239
|
+
# Validate header and mandatory fields
|
240
|
+
validator.validate_header(@header)
|
241
|
+
validator.validate_service_type(@service_type)
|
242
|
+
validator.validate_source_addr_ton(@source_addr_ton)
|
243
|
+
validator.validate_source_addr_npi(@source_addr_npi)
|
244
|
+
validator.validate_source_addr21(@source_addr)
|
245
|
+
validator.validate_dest_addr_ton(@dest_addr_ton)
|
246
|
+
validator.validate_dest_addr_npi(@dest_addr_npi)
|
247
|
+
validator.validate_dest_addr21(@dest_addr)
|
248
|
+
validator.validate_esm_class(@esm_class)
|
249
|
+
validator.validate_protocol_id(@protocol_id)
|
250
|
+
validator.validate_priority_flag(@priority_flag)
|
251
|
+
validator.validate_schedule_delivery_time(@schedule_delivery_time)
|
252
|
+
validator.validate_validity_period(@validity_period)
|
253
|
+
validator.validate_registered_delivery(@registered_delivery)
|
254
|
+
validator.validate_replace_if_present_flag(@replace_if_present_flag)
|
255
|
+
validator.validate_data_coding(@data_coding)
|
256
|
+
validator.validate_sm_default_msg_id(@sm_default_msg_id)
|
257
|
+
validator.validate_sm_length(@sm_length)
|
258
|
+
validator.validate_short_message(@short_message)
|
259
|
+
|
260
|
+
|
261
|
+
# Validate optional fields
|
262
|
+
validator.validate_user_message_reference(@user_message_reference,
|
263
|
+
@user_message_reference_len) if !@user_message_reference.nil?
|
264
|
+
validator.validate_source_port(@source_port,
|
265
|
+
@source_port_len) if !@source_port.nil?
|
266
|
+
validator.validate_destination_port(@destination_port,
|
267
|
+
@destination_port_len) if !@destination_port.nil?
|
268
|
+
validator.validate_sar_msg_ref_num(@sar_msg_ref_num,
|
269
|
+
@sar_msg_ref_num_len) if !@sar_msg_ref_num.nil?
|
270
|
+
validator.validate_sar_total_segments(@sar_total_segments,
|
271
|
+
@sar_total_segments_len) if !@sar_total_segments.nil?
|
272
|
+
validator.validate_sar_segment_seqnum(@sar_segment_seqnum,
|
273
|
+
@sar_segment_seqnum_len) if !@sar_segment_seqnum.nil?
|
274
|
+
validator.validate_user_response_code(@user_response_code,
|
275
|
+
@user_response_code_len) if !@user_response_code.nil?
|
276
|
+
validator.validate_privacy_indicator(@privacy_indicator,
|
277
|
+
@privacy_indicator_len) if !@privacy_indicator.nil?
|
278
|
+
validator.validate_payload_type(@payload_type,
|
279
|
+
@payload_type_len) if !@payload_type.nil?
|
280
|
+
validator.validate_message_payload(@message_payload,
|
281
|
+
@message_payload_len) if !@message_payload.nil?
|
282
|
+
validator.validate_callback_num(@callback_num,
|
283
|
+
@callback_num_len) if !@callback_num.nil?
|
284
|
+
validator.validate_source_subaddress(@source_subaddress,
|
285
|
+
@source_subaddress_len) if !@source_subaddress.nil?
|
286
|
+
validator.validate_dest_subaddress(@dest_subaddress,
|
287
|
+
@dest_subaddress_len) if !@dest_subaddress.nil?
|
288
|
+
validator.validate_language_indicator(@language_indicator,
|
289
|
+
@language_indicator_len) if !@language_indicator.nil?
|
290
|
+
validator.validate_its_session_info(@its_session_info,
|
291
|
+
@its_session_info_len) if !@its_session_info.nil?
|
292
|
+
validator.validate_network_error_code(@network_error_code,
|
293
|
+
@network_error_code_len) if !@network_error_code.nil?
|
294
|
+
validator.validate_message_state_tlv(@message_state,
|
295
|
+
@message_state_len) if !@message_state.nil?
|
296
|
+
validator.validate_receipted_message_id(@receipted_message_id,
|
297
|
+
@receipted_message_id_len) if !@receipted_message_id.nil?
|
298
|
+
|
299
|
+
# Validate complex rules
|
300
|
+
validator.validate_short_message_payload(@short_message,
|
301
|
+
@message_payload) if !@message_payload.nil?
|
302
|
+
end
|
303
|
+
|
304
|
+
# Interface to output SMPP packet
|
305
|
+
def output_packet(outputter)
|
306
|
+
# Output header and mandatory fields
|
307
|
+
outputter.output_header(@header)
|
308
|
+
outputter.output_service_type(@service_type)
|
309
|
+
outputter.output_source_addr_ton(@source_addr_ton)
|
310
|
+
outputter.output_source_addr_npi(@source_addr_npi)
|
311
|
+
outputter.output_source_addr21(@source_addr)
|
312
|
+
outputter.output_dest_addr_ton(@dest_addr_ton)
|
313
|
+
outputter.output_dest_addr_npi(@dest_addr_npi)
|
314
|
+
outputter.output_dest_addr21(@dest_addr)
|
315
|
+
outputter.output_esm_class(@esm_class)
|
316
|
+
outputter.output_protocol_id(@protocol_id)
|
317
|
+
outputter.output_priority_flag(@priority_flag)
|
318
|
+
outputter.output_schedule_delivery_time(@schedule_delivery_time)
|
319
|
+
outputter.output_validity_period(@validity_period)
|
320
|
+
outputter.output_registered_delivery(@registered_delivery)
|
321
|
+
outputter.output_replace_if_present_flag(@replace_if_present_flag)
|
322
|
+
outputter.output_data_coding(@data_coding)
|
323
|
+
outputter.output_sm_default_msg_id(@sm_default_msg_id)
|
324
|
+
outputter.output_sm_length(@sm_length)
|
325
|
+
outputter.output_short_message(@short_message)
|
326
|
+
|
327
|
+
# Output optional fields
|
328
|
+
outputter.output_user_message_reference(@user_message_reference,
|
329
|
+
@user_message_reference_len) if !@user_message_reference.nil?
|
330
|
+
outputter.output_source_port(@source_port,
|
331
|
+
@source_port_len) if !@source_port.nil?
|
332
|
+
outputter.output_destination_port(@destination_port,
|
333
|
+
@destination_port_len) if !@destination_port.nil?
|
334
|
+
outputter.output_sar_msg_ref_num(@sar_msg_ref_num,
|
335
|
+
@sar_msg_ref_num_len) if !@sar_msg_ref_num.nil?
|
336
|
+
outputter.output_sar_total_segments(@sar_total_segments,
|
337
|
+
@sar_total_segments_len) if !@sar_total_segments.nil?
|
338
|
+
outputter.output_sar_segment_seqnum(@sar_segment_seqnum,
|
339
|
+
@sar_segment_seqnum_len) if !@sar_segment_seqnum.nil?
|
340
|
+
outputter.output_user_response_code(@user_response_code,
|
341
|
+
@user_response_code_len) if !@user_response_code.nil?
|
342
|
+
outputter.output_privacy_indicator(@privacy_indicator,
|
343
|
+
@privacy_indicator_len) if !@privacy_indicator.nil?
|
344
|
+
outputter.output_payload_type(@payload_type,
|
345
|
+
@payload_type_len) if !@payload_type.nil?
|
346
|
+
outputter.output_message_payload(@message_payload,
|
347
|
+
@message_payload_len) if !@message_payload.nil?
|
348
|
+
outputter.output_callback_num(@callback_num,
|
349
|
+
@callback_num_len) if !@callback_num.nil?
|
350
|
+
outputter.output_source_subaddress(@source_subaddress,
|
351
|
+
@source_subaddress_len) if !@source_subaddress.nil?
|
352
|
+
outputter.output_dest_subaddress(@dest_subaddress,
|
353
|
+
@dest_subaddress_len) if !@dest_subaddress.nil?
|
354
|
+
outputter.output_language_indicator(@language_indicator,
|
355
|
+
@language_indicator_len) if !@language_indicator.nil?
|
356
|
+
outputter.output_its_session_info(@its_session_info,
|
357
|
+
@its_session_info_len) if !@its_session_info.nil?
|
358
|
+
outputter.output_network_error_code(@network_error_code,
|
359
|
+
@network_error_code_len) if !@network_error_code.nil?
|
360
|
+
outputter.output_message_state_tlv_opt(@message_state,
|
361
|
+
@message_state_len) if !@message_state.nil?
|
362
|
+
outputter.output_receipted_message_id(@receipted_message_id,
|
363
|
+
@receipted_message_id_len) if !@receipted_message_id.nil?
|
364
|
+
end
|
365
|
+
|
366
|
+
public
|
367
|
+
def message_payload=(message_payload)
|
368
|
+
@message_payload = message_payload
|
369
|
+
@message_payload_len = message_payload.size()
|
370
|
+
end
|
371
|
+
|
372
|
+
def callback_num=(callback_num)
|
373
|
+
@callback_num = callback_num
|
374
|
+
@callback_num_len = callback_num.size()
|
375
|
+
end
|
376
|
+
|
377
|
+
def source_subaddress=(source_subaddress)
|
378
|
+
@source_subaddress = source_subaddress
|
379
|
+
@source_subaddress_len = source_subaddress.size()
|
380
|
+
end
|
381
|
+
|
382
|
+
def dest_subaddress=(dest_subaddress)
|
383
|
+
@dest_subaddress = dest_subaddress
|
384
|
+
@dest_subaddress_len = dest_subaddress.size()
|
385
|
+
end
|
386
|
+
|
387
|
+
def receipted_message_id=(receipted_message_id)
|
388
|
+
@receipted_message_id = receipted_message_id
|
389
|
+
@receipted_message_id_len = receipted_message_id.size() + 1 # 1 = NULL terminator
|
390
|
+
end
|
391
|
+
|
392
|
+
public
|
393
|
+
# Mandatory fields
|
394
|
+
attr_accessor :service_type
|
395
|
+
attr_accessor :source_addr_ton
|
396
|
+
attr_accessor :source_addr_npi
|
397
|
+
attr_accessor :source_addr
|
398
|
+
attr_accessor :dest_addr_ton
|
399
|
+
attr_accessor :dest_addr_npi
|
400
|
+
attr_accessor :dest_addr
|
401
|
+
attr_accessor :esm_class
|
402
|
+
attr_accessor :protocol_id
|
403
|
+
attr_accessor :priority_flag
|
404
|
+
attr_accessor :schedule_delivery_time
|
405
|
+
attr_accessor :validity_period
|
406
|
+
attr_accessor :registered_delivery
|
407
|
+
attr_accessor :replace_if_present_flag
|
408
|
+
attr_accessor :data_coding
|
409
|
+
attr_accessor :sm_default_msg_id
|
410
|
+
attr_accessor :sm_length
|
411
|
+
attr_accessor :short_message
|
412
|
+
|
413
|
+
|
414
|
+
# Optional fields
|
415
|
+
attr_accessor :user_message_reference
|
416
|
+
attr_accessor :source_port
|
417
|
+
attr_accessor :destination_port
|
418
|
+
attr_accessor :sar_msg_ref_num
|
419
|
+
attr_accessor :sar_total_segments
|
420
|
+
attr_accessor :sar_segment_seqnum
|
421
|
+
attr_accessor :user_response_code
|
422
|
+
attr_accessor :privacy_indicator
|
423
|
+
attr_accessor :payload_type
|
424
|
+
attr_reader :message_payload
|
425
|
+
attr_reader :callback_num
|
426
|
+
attr_reader :source_subaddress
|
427
|
+
attr_reader :dest_subaddress
|
428
|
+
attr_accessor :language_indicator
|
429
|
+
attr_accessor :its_session_info
|
430
|
+
attr_accessor :network_error_code
|
431
|
+
attr_accessor :message_state
|
432
|
+
attr_reader :receipted_message_id
|
433
|
+
|
434
|
+
|
435
|
+
# Optional fields length
|
436
|
+
attr_accessor :user_message_reference_len
|
437
|
+
attr_accessor :source_port_len
|
438
|
+
attr_accessor :destination_port_len
|
439
|
+
attr_accessor :sar_msg_ref_num_len
|
440
|
+
attr_accessor :sar_total_segments_len
|
441
|
+
attr_accessor :sar_segment_seqnum_len
|
442
|
+
attr_accessor :user_response_code_len
|
443
|
+
attr_accessor :privacy_indicator_len
|
444
|
+
attr_accessor :payload_type_len
|
445
|
+
attr_accessor :message_payload_len
|
446
|
+
attr_accessor :callback_num_len
|
447
|
+
attr_accessor :source_subaddress_len
|
448
|
+
attr_accessor :dest_subaddress_len
|
449
|
+
attr_accessor :language_indicator_len
|
450
|
+
attr_accessor :its_session_info_len
|
451
|
+
attr_accessor :network_error_code_len
|
452
|
+
attr_accessor :message_state_len
|
453
|
+
attr_accessor :receipted_message_id_len
|
454
|
+
|
455
|
+
end
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|