anthill_smpp_ruby 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/MIT-LICENSE +21 -0
  2. data/README +30 -0
  3. data/anthill_smpp_ruby.gemspec +18 -0
  4. data/changelog +43 -0
  5. data/data/dumps/random_command.dump +1 -0
  6. data/data/dumps/smpp_alert_notification.dump +1 -0
  7. data/data/dumps/smpp_bind_receiver.dump +1 -0
  8. data/data/dumps/smpp_bind_receiver_resp.dump +1 -0
  9. data/data/dumps/smpp_bind_transceiver.dump +1 -0
  10. data/data/dumps/smpp_bind_transceiver_1.dump +2 -0
  11. data/data/dumps/smpp_bind_transceiver_resp.dump +1 -0
  12. data/data/dumps/smpp_bind_transmitter.dump +1 -0
  13. data/data/dumps/smpp_bind_transmitter_resp.dump +1 -0
  14. data/data/dumps/smpp_broadcast_sm.dump +1 -0
  15. data/data/dumps/smpp_broadcast_sm_resp.dump +1 -0
  16. data/data/dumps/smpp_cancel_broadcast_sm.dump +1 -0
  17. data/data/dumps/smpp_cancel_broadcast_sm_resp.dump +1 -0
  18. data/data/dumps/smpp_cancel_sm.dump +1 -0
  19. data/data/dumps/smpp_cancel_sm_resp.dump +1 -0
  20. data/data/dumps/smpp_data_sm.dump +1 -0
  21. data/data/dumps/smpp_data_sm_resp.dump +1 -0
  22. data/data/dumps/smpp_deliver_sm.dump +1 -0
  23. data/data/dumps/smpp_deliver_sm_resp.dump +1 -0
  24. data/data/dumps/smpp_enquire_link.dump +1 -0
  25. data/data/dumps/smpp_enquire_link_resp.dump +1 -0
  26. data/data/dumps/smpp_generic_nack.dump +1 -0
  27. data/data/dumps/smpp_outbind.dump +1 -0
  28. data/data/dumps/smpp_query_broadcast_sm.dump +1 -0
  29. data/data/dumps/smpp_query_broadcast_sm_resp.dump +1 -0
  30. data/data/dumps/smpp_query_broadcast_sm_resp_1.dump +1 -0
  31. data/data/dumps/smpp_query_sm.dump +1 -0
  32. data/data/dumps/smpp_query_sm_resp.dump +1 -0
  33. data/data/dumps/smpp_replace_sm.dump +1 -0
  34. data/data/dumps/smpp_replace_sm_resp.dump +1 -0
  35. data/data/dumps/smpp_submit_multi.dump +1 -0
  36. data/data/dumps/smpp_submit_multi_resp.dump +1 -0
  37. data/data/dumps/smpp_submit_sm.dump +1 -0
  38. data/data/dumps/smpp_submit_sm_resp.dump +1 -0
  39. data/data/dumps/smpp_unbind.dump +1 -0
  40. data/data/dumps/smpp_unbind_resp.dump +1 -0
  41. data/data/pdus/random_command.xml +35 -0
  42. data/data/pdus/smpp_alert_notification.xml +14 -0
  43. data/data/pdus/smpp_alert_notification_no_optional.xml +13 -0
  44. data/data/pdus/smpp_bind_receiver.xml +17 -0
  45. data/data/pdus/smpp_bind_receiver_resp.xml +12 -0
  46. data/data/pdus/smpp_bind_receiver_resp_no_optional.xml +11 -0
  47. data/data/pdus/smpp_bind_transceiver.xml +17 -0
  48. data/data/pdus/smpp_bind_transceiver_resp.xml +12 -0
  49. data/data/pdus/smpp_bind_transceiver_resp_no_optional.xml +11 -0
  50. data/data/pdus/smpp_bind_transmitter.xml +17 -0
  51. data/data/pdus/smpp_bind_transmitter_resp.xml +12 -0
  52. data/data/pdus/smpp_bind_transmitter_resp_no_optional.xml +11 -0
  53. data/data/pdus/smpp_broadcast_sm.xml +47 -0
  54. data/data/pdus/smpp_broadcast_sm_no_optional.xml +26 -0
  55. data/data/pdus/smpp_broadcast_sm_resp.xml +14 -0
  56. data/data/pdus/smpp_broadcast_sm_resp_no_optional.xml +8 -0
  57. data/data/pdus/smpp_cancel_broadcast_sm.xml +17 -0
  58. data/data/pdus/smpp_cancel_broadcast_sm_no_optional.xml +15 -0
  59. data/data/pdus/smpp_cancel_broadcast_sm_resp.xml +7 -0
  60. data/data/pdus/smpp_cancel_sm.xml +18 -0
  61. data/data/pdus/smpp_cancel_sm_resp.xml +10 -0
  62. data/data/pdus/smpp_commands.xsd +914 -0
  63. data/data/pdus/smpp_data_sm.xml +58 -0
  64. data/data/pdus/smpp_data_sm_no_optional.xml +17 -0
  65. data/data/pdus/smpp_data_sm_resp.xml +15 -0
  66. data/data/pdus/smpp_data_sm_resp_no_optional.xml +8 -0
  67. data/data/pdus/smpp_deliver_sm.xml +46 -0
  68. data/data/pdus/smpp_deliver_sm_no_optional.xml +25 -0
  69. data/data/pdus/smpp_deliver_sm_resp.xml +14 -0
  70. data/data/pdus/smpp_deliver_sm_resp_no_optional.xml +8 -0
  71. data/data/pdus/smpp_enquire_link.xml +10 -0
  72. data/data/pdus/smpp_enquire_link_resp.xml +10 -0
  73. data/data/pdus/smpp_generic_nack.xml +10 -0
  74. data/data/pdus/smpp_outbind.xml +12 -0
  75. data/data/pdus/smpp_query_broadcast_sm.xml +12 -0
  76. data/data/pdus/smpp_query_broadcast_sm_no_optional.xml +11 -0
  77. data/data/pdus/smpp_query_broadcast_sm_resp.xml +17 -0
  78. data/data/pdus/smpp_query_broadcast_sm_resp_no_optional.xml +15 -0
  79. data/data/pdus/smpp_query_sm.xml +11 -0
  80. data/data/pdus/smpp_query_sm_resp.xml +11 -0
  81. data/data/pdus/smpp_replace_sm.xml +18 -0
  82. data/data/pdus/smpp_replace_sm_no_optional.xml +17 -0
  83. data/data/pdus/smpp_replace_sm_resp.xml +7 -0
  84. data/data/pdus/smpp_submit_multi.xml +73 -0
  85. data/data/pdus/smpp_submit_multi_no_optional.xml +51 -0
  86. data/data/pdus/smpp_submit_multi_resp.xml +35 -0
  87. data/data/pdus/smpp_submit_sm.xml +57 -0
  88. data/data/pdus/smpp_submit_sm_no_optional.xml +28 -0
  89. data/data/pdus/smpp_submit_sm_resp.xml +8 -0
  90. data/data/pdus/smpp_unbind.xml +10 -0
  91. data/data/pdus/smpp_unbind_resp.xml +10 -0
  92. data/examples/dump_viewer.rb +298 -0
  93. data/examples/pdu_composer.rb +1331 -0
  94. data/knownbugs +24 -0
  95. data/lib/anthill_smpp_ruby.rb +83 -0
  96. data/lib/i_smpp_outputter.rb +425 -0
  97. data/lib/pdu/smpp_alert_notification.rb +132 -0
  98. data/lib/pdu/smpp_bind.rb +102 -0
  99. data/lib/pdu/smpp_bind_receiver.rb +29 -0
  100. data/lib/pdu/smpp_bind_receiver_resp.rb +30 -0
  101. data/lib/pdu/smpp_bind_resp.rb +100 -0
  102. data/lib/pdu/smpp_bind_transceiver.rb +29 -0
  103. data/lib/pdu/smpp_bind_transceiver_resp.rb +31 -0
  104. data/lib/pdu/smpp_bind_transmitter.rb +29 -0
  105. data/lib/pdu/smpp_bind_transmitter_resp.rb +30 -0
  106. data/lib/pdu/smpp_broadcast_sm.rb +566 -0
  107. data/lib/pdu/smpp_broadcast_sm_resp.rb +130 -0
  108. data/lib/pdu/smpp_cancel_broadcast_sm.rb +143 -0
  109. data/lib/pdu/smpp_cancel_broadcast_sm_resp.rb +60 -0
  110. data/lib/pdu/smpp_cancel_sm.rb +110 -0
  111. data/lib/pdu/smpp_cancel_sm_resp.rb +60 -0
  112. data/lib/pdu/smpp_data_sm.rb +679 -0
  113. data/lib/pdu/smpp_data_sm_resp.rb +148 -0
  114. data/lib/pdu/smpp_deliver_sm.rb +458 -0
  115. data/lib/pdu/smpp_deliver_sm_resp.rb +137 -0
  116. data/lib/pdu/smpp_enquire_link.rb +59 -0
  117. data/lib/pdu/smpp_enquire_link_resp.rb +61 -0
  118. data/lib/pdu/smpp_generic_nack.rb +61 -0
  119. data/lib/pdu/smpp_outbind.rb +71 -0
  120. data/lib/pdu/smpp_pdu.rb +90 -0
  121. data/lib/pdu/smpp_query_broadcast_sm.rb +120 -0
  122. data/lib/pdu/smpp_query_broadcast_sm_resp.rb +192 -0
  123. data/lib/pdu/smpp_query_sm.rb +92 -0
  124. data/lib/pdu/smpp_query_sm_resp.rb +92 -0
  125. data/lib/pdu/smpp_replace_sm.rb +172 -0
  126. data/lib/pdu/smpp_replace_sm_resp.rb +61 -0
  127. data/lib/pdu/smpp_resp.rb +40 -0
  128. data/lib/pdu/smpp_submit_multi.rb +517 -0
  129. data/lib/pdu/smpp_submit_multi_resp.rb +90 -0
  130. data/lib/pdu/smpp_submit_sm.rb +591 -0
  131. data/lib/pdu/smpp_submit_sm_resp.rb +72 -0
  132. data/lib/pdu/smpp_unbind.rb +60 -0
  133. data/lib/pdu/smpp_unbind_resp.rb +61 -0
  134. data/lib/smpp_constants.rb +917 -0
  135. data/lib/smpp_csv_outputter.rb +1601 -0
  136. data/lib/smpp_datatypes.rb +89 -0
  137. data/lib/smpp_decoder.rb +627 -0
  138. data/lib/smpp_encoder.rb +495 -0
  139. data/lib/smpp_hex_outputter.rb +36 -0
  140. data/lib/smpp_outputter_base.rb +315 -0
  141. data/lib/smpp_structures.rb +98 -0
  142. data/lib/smpp_txt_outputter.rb +1895 -0
  143. data/lib/smpp_validator.rb +373 -0
  144. data/lib/smpp_xml_outputter.rb +34 -0
  145. data/roadmap +18 -0
  146. data/setup.rb +1585 -0
  147. data/test/anthill_smpp_test.rb +29 -0
  148. data/test/smpp_codec_test.rb +30 -0
  149. data/test/smpp_datatypes_test.rb +69 -0
  150. data/test/smpp_outputter_test.rb +1261 -0
  151. data/test/smpp_parsing_test.rb +1758 -0
  152. data/test/smpp_rawdump_test.rb +2095 -0
  153. data/test/smpp_validator_test.rb +441 -0
  154. metadata +206 -0
@@ -0,0 +1,137 @@
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 SMPPDeliverSMResp < SMPPResp
23
+ # Constructor.
24
+ def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
25
+ super(CommandId::CM_DELIVER_SM_RESP, command_status, sequence_number)
26
+
27
+ # Mandatory fields
28
+ @message_id = ""
29
+
30
+ # Optional fields
31
+ @additional_status_info_text = nil
32
+ @delivery_failure_reason = nil
33
+ @network_error_code = nil
34
+
35
+ # Optional fields length
36
+ @additional_status_info_text_len = SMPPTLVLen::ZERO_LEN
37
+ @delivery_failure_reason_len = SMPPTLVLen::BYTE_LEN
38
+ @network_error_code_len = SMPPTLVLen::BYTE_LEN + SMPPTLVLen::WORD_LEN
39
+ end
40
+
41
+ # Interface to encode SMPP packet
42
+ def encode_packet(encoder)
43
+ # Encode header and mandatory fields
44
+ encoder.encode_header(@header)
45
+ encoder.encode_message_id(@message_id)
46
+
47
+ # Encode optional fields
48
+ encoder.encode_additional_status_info_text(@additional_status_info_text,
49
+ @additional_status_info_text_len) if !@additional_status_info_text.nil?
50
+ encoder.encode_delivery_failure_reason(@delivery_failure_reason,
51
+ @delivery_failure_reason_len) if !@delivery_failure_reason.nil?
52
+ encoder.encode_network_error_code(@network_error_code,
53
+ @network_error_code_len) if !@network_error_code.nil?
54
+ end
55
+
56
+ # Interface to decode SMPP packet
57
+ def decode_packet(decoder)
58
+ # Decode header and mandatory fields
59
+ @header = decoder.decode_header()
60
+ @message_id = decoder.decode_message_id(command_length())
61
+
62
+ # Decode optional fields
63
+ while decoder.has_tlvs()
64
+ case decoder.get_tlv_code()
65
+ when OptTags::TAG_ADDITIONAL_STATUS_INFO_TEXT
66
+ @additional_status_info_text, @additional_status_info_text_len =
67
+ decoder.decode_additional_status_info_text(command_length())
68
+ when OptTags::TAG_DELIVERY_FAILURE_REASON
69
+ @delivery_failure_reason, @delivery_failure_reason_len =
70
+ decoder.decode_delivery_failure_reason(command_length())
71
+ when OptTags::TAG_NETWORK_ERROR_CODE
72
+ @network_error_code, @network_error_code_len =
73
+ decoder.decode_network_error_code(command_length())
74
+ else
75
+ # Report about error
76
+ raise Errors::UNKNOWN_TAG_MSG + decoder.get_tlv_error()
77
+ end
78
+ end
79
+ end
80
+
81
+ # Interface to validate SMPP packet
82
+ def validate_packet(validator)
83
+ # Validate header and mandatory fields
84
+ validator.validate_header(@header)
85
+ validator.validate_message_id(@message_id)
86
+
87
+ # Validate optional fields
88
+ validator.validate_additional_status_info_text(@additional_status_info_text,
89
+ @additional_status_info_text_len) if !@additional_status_info_text.nil?
90
+ validator.validate_delivery_failure_reason(@delivery_failure_reason,
91
+ @delivery_failure_reason_len) if !@delivery_failure_reason.nil?
92
+ validator.validate_network_error_code(@network_error_code,
93
+ @network_error_code_len) if !@network_error_code.nil?
94
+
95
+ # Validate compex rules
96
+ validator.validate_message_id_null(message_id)
97
+ end
98
+
99
+ # Interface to output SMPP packet
100
+ def output_packet(outputter)
101
+ # Output header and mandatory fields
102
+ outputter.output_header(@header)
103
+ outputter.output_message_id(@message_id)
104
+
105
+ # Output optional fields
106
+ outputter.output_additional_status_info_text(@additional_status_info_text,
107
+ @additional_status_info_text_len) if !@additional_status_info_text.nil?
108
+ outputter.output_delivery_failure_reason(@delivery_failure_reason,
109
+ @delivery_failure_reason_len) if !@delivery_failure_reason.nil?
110
+ outputter.output_network_error_code(@network_error_code,
111
+ @network_error_code_len) if !@network_error_code.nil?
112
+ end
113
+
114
+ public
115
+ def additional_status_info_text=(additional_status_info_text)
116
+ @additional_status_info_text = additional_status_info_text
117
+ @additional_status_info_text_len = additional_status_info_text.size()
118
+ end
119
+
120
+
121
+ public
122
+ # Mandatory fields
123
+ attr_accessor :message_id
124
+
125
+ # Optional fields
126
+ attr_reader :additional_status_info_text
127
+ attr_accessor :delivery_failure_reason
128
+ attr_accessor :network_error_code
129
+
130
+ # Optional fields length
131
+ attr_accessor :additional_status_info_text_len
132
+ attr_accessor :delivery_failure_reason_len
133
+ attr_accessor :network_error_code_len
134
+ end
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,59 @@
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 SMPPEnquireLink < SMPPPDU
23
+ def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
24
+ super(CommandId::CM_ENQUIRE_LINK, command_status, sequence_number)
25
+ end
26
+ # Interface to encode SMPP packet
27
+ def encode_packet(encoder)
28
+ # Encode header and mandatory fields
29
+ encoder.encode_header(@header)
30
+ end
31
+
32
+ # Interface to decode SMPP packet
33
+ def decode_packet(decoder)
34
+ # Decode header and mandatory fields
35
+ @header = decoder.decode_header()
36
+ end
37
+
38
+ # Interface to validate SMPP packet
39
+ def validate_packet(validator)
40
+ # Validate header and mandatory fields
41
+ validator.validate_header(@header)
42
+ end
43
+
44
+ # Interface to output SMPP packet
45
+ def output_packet(outputter)
46
+ # Output header and mandatory fields
47
+ outputter.output_header(@header)
48
+ end
49
+
50
+ public
51
+ # Mandatory fields
52
+
53
+ # Optional fields
54
+
55
+ # Optional fields length
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,61 @@
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 SMPPEnquireLinkResp < SMPPResp
23
+ # Constructor.
24
+ def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
25
+ super(CommandId::CM_ENQUIRE_LINK_RESP, command_status, sequence_number)
26
+ end
27
+
28
+ # Interface to encode SMPP packet
29
+ def encode_packet(encoder)
30
+ # Encode header and mandatory fields
31
+ encoder.encode_header(@header)
32
+ end
33
+
34
+ # Interface to decode SMPP packet
35
+ def decode_packet(decoder)
36
+ # Decode header and mandatory fields
37
+ @header = decoder.decode_header()
38
+ end
39
+
40
+ # Interface to validate SMPP packet
41
+ def validate_packet(validator)
42
+ # Validate header and mandatory fields
43
+ validator.validate_header(@header)
44
+ end
45
+
46
+ # Interface to output SMPP packet
47
+ def output_packet(outputter)
48
+ # Output header and mandatory fields
49
+ outputter.output_header(@header)
50
+ end
51
+
52
+ public
53
+ # Mandatory fields
54
+
55
+ # Optional fields
56
+
57
+ # Optional fields length
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
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 SMPPGenericNack < SMPPPDU
23
+ def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
24
+ super(CommandId::CM_GENERIC_NACK, command_status, sequence_number)
25
+ end
26
+
27
+ # Interface to encode SMPP packet
28
+ def encode_packet(encoder)
29
+ # Encode header and mandatory fields
30
+ encoder.encode_header(@header)
31
+ end
32
+
33
+ # Interface to decode SMPP packet
34
+ def decode_packet(decoder)
35
+ # Decode header and mandatory fields
36
+ @header = decoder.decode_header()
37
+ end
38
+
39
+ # Interface to validate SMPP packet
40
+ def validate_packet(validator)
41
+ # Validate header and mandatory fields
42
+ validator.validate_header(@header)
43
+ end
44
+
45
+ # Interface to output SMPP packet
46
+ def output_packet(outputter)
47
+ # Output header and mandatory fields
48
+ outputter.output_header(@header)
49
+ end
50
+
51
+ public
52
+ # Mandatory fields
53
+
54
+ # Optional fields
55
+
56
+ # Optional fields length
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,71 @@
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 SMPPOutbind < SMPPPDU
23
+ def initialize(command_status = ErrorCode::ESME_ROK, sequence_number = nil)
24
+ super(CommandId::CM_OUTBIND, command_status, sequence_number)
25
+ end
26
+
27
+ # Interface to encode SMPP packet
28
+ def encode_packet(encoder)
29
+ # Encode header and mandatory fields
30
+ encoder.encode_header(@header)
31
+ encoder.encode_system_id(@system_id)
32
+ encoder.encode_password(@password)
33
+ end
34
+
35
+ # Interface to decode SMPP packet
36
+ def decode_packet(decoder)
37
+ # Decode header and mandatory fields
38
+ @header = decoder.decode_header()
39
+ @system_id = decoder.decode_system_id(command_length())
40
+ @password = decoder.decode_password(command_length())
41
+ end
42
+
43
+ # Interface to validate SMPP packet
44
+ def validate_packet(validator)
45
+ # Validate header and mandatory fields
46
+ validator.validate_header(@header)
47
+ validator.validate_system_id(@system_id)
48
+ validator.validate_password(@password)
49
+ end
50
+
51
+ # Interface to output SMPP packet
52
+ def output_packet(outputter)
53
+ # Output header and mandatory fields
54
+ outputter.output_header(@header)
55
+ outputter.output_system_id(@system_id)
56
+ outputter.output_password(@password)
57
+ end
58
+
59
+ public
60
+ # Mandatory fields
61
+ attr_accessor :system_id
62
+ attr_accessor :password
63
+
64
+ # Optional fields
65
+
66
+ # Optional fields length
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,90 @@
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
+ # The base class for all SMPP protocol data units.
23
+ # All SMPP packages inherited from this class.
24
+ class SMPPPDU
25
+
26
+ # Constructor
27
+ def initialize(command_id, command_status, sequence_number)
28
+ @header = Header.new()
29
+ @header.command_id = command_id
30
+ @header.command_status = command_status
31
+ @header.sequence_number = sequence_number
32
+ end
33
+
34
+ # Interface to encode SMPP packet
35
+ def encode_packet(encoder)
36
+ raise Errors::INTERFACE_NOT_IMPLEMENTED
37
+ end
38
+
39
+ # Interface to decode SMPP packet
40
+ def decode_packet(decoder)
41
+ raise Errors::INTERFACE_NOT_IMPLEMENTED
42
+ end
43
+
44
+ # Interface to validate SMPP packet
45
+ def validate_packet(validator)
46
+ raise Errors::INTERFACE_NOT_IMPLEMENTED
47
+ end
48
+
49
+ # Interface to output SMPP packet
50
+ def output_packet(outputter)
51
+ raise Errors::INTERFACE_NOT_IMPLEMENTED
52
+ end
53
+
54
+ def command_length(command_length)
55
+ @header.command_length = command_length
56
+ end
57
+
58
+ def command_length()
59
+ @header.command_length
60
+ end
61
+
62
+ def command_id(command_id)
63
+ @header.command_id = command_id
64
+ end
65
+
66
+ def command_id()
67
+ @header.command_id
68
+ end
69
+
70
+ def command_status=(command_status)
71
+ @header.command_status = command_status
72
+ end
73
+
74
+ def command_status()
75
+ @header.command_status
76
+ end
77
+
78
+ def sequence_number=(sequence_number)
79
+ @header.sequence_number = sequence_number
80
+ end
81
+
82
+ def sequence_number()
83
+ @header.sequence_number
84
+ end
85
+ public
86
+ attr_accessor :header
87
+ end
88
+ end
89
+ end
90
+ end