anthill_smpp_ruby 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,51 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd" xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
3
|
+
<smpp_submit_multi>
|
|
4
|
+
<command_status>0</command_status>
|
|
5
|
+
<sequence_number>12</sequence_number>
|
|
6
|
+
<service_type>srvtp</service_type>
|
|
7
|
+
<source_addr_ton>1</source_addr_ton>
|
|
8
|
+
<source_addr_npi>2</source_addr_npi>
|
|
9
|
+
<source_addr>123</source_addr>
|
|
10
|
+
<number_of_dest>6</number_of_dest>
|
|
11
|
+
<dest_addresses>
|
|
12
|
+
<dest_address>
|
|
13
|
+
<distr_list_name>distr_list1</distr_list_name>
|
|
14
|
+
</dest_address>
|
|
15
|
+
<dest_address>
|
|
16
|
+
<distr_list_name>distr_list2</distr_list_name>
|
|
17
|
+
</dest_address>
|
|
18
|
+
<dest_address>
|
|
19
|
+
<sme_address>
|
|
20
|
+
<ton>1</ton>
|
|
21
|
+
<npi>1</npi>
|
|
22
|
+
<address>123</address>
|
|
23
|
+
</sme_address>
|
|
24
|
+
</dest_address>
|
|
25
|
+
<dest_address>
|
|
26
|
+
<sme_address>
|
|
27
|
+
<ton>2</ton>
|
|
28
|
+
<npi>2</npi>
|
|
29
|
+
<address>223</address>
|
|
30
|
+
</sme_address>
|
|
31
|
+
</dest_address>
|
|
32
|
+
<dest_address>
|
|
33
|
+
<distr_list_name>distr_list1</distr_list_name>
|
|
34
|
+
</dest_address>
|
|
35
|
+
<dest_address>
|
|
36
|
+
<distr_list_name>distr_list2</distr_list_name>
|
|
37
|
+
</dest_address>
|
|
38
|
+
</dest_addresses>
|
|
39
|
+
<esm_class>1</esm_class>
|
|
40
|
+
<protocol_id>2</protocol_id>
|
|
41
|
+
<priority_flag>3</priority_flag>
|
|
42
|
+
<schedule_delivery_time/>
|
|
43
|
+
<validity_period/>
|
|
44
|
+
<registered_delivery>4</registered_delivery>
|
|
45
|
+
<replace_if_present_flag>5</replace_if_present_flag>
|
|
46
|
+
<data_coding>6</data_coding>
|
|
47
|
+
<sm_default_msg_id>7</sm_default_msg_id>
|
|
48
|
+
<sm_length>0</sm_length>
|
|
49
|
+
<short_message></short_message>
|
|
50
|
+
</smpp_submit_multi>
|
|
51
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd" xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
3
|
+
<smpp_submit_multi_resp>
|
|
4
|
+
<command_status>0</command_status>
|
|
5
|
+
<sequence_number>12</sequence_number>
|
|
6
|
+
<message_id>123</message_id>
|
|
7
|
+
<no_unsuccess>3</no_unsuccess>
|
|
8
|
+
<unsuccess_smes>
|
|
9
|
+
<unsuccess_sme>
|
|
10
|
+
<sme_address>
|
|
11
|
+
<ton>1</ton>
|
|
12
|
+
<npi>2</npi>
|
|
13
|
+
<address>123</address>
|
|
14
|
+
</sme_address>
|
|
15
|
+
<error_status_code>1</error_status_code>
|
|
16
|
+
</unsuccess_sme>
|
|
17
|
+
<unsuccess_sme>
|
|
18
|
+
<sme_address>
|
|
19
|
+
<ton>3</ton>
|
|
20
|
+
<npi>4</npi>
|
|
21
|
+
<address>321</address>
|
|
22
|
+
</sme_address>
|
|
23
|
+
<error_status_code>3</error_status_code>
|
|
24
|
+
</unsuccess_sme>
|
|
25
|
+
<unsuccess_sme>
|
|
26
|
+
<sme_address>
|
|
27
|
+
<ton>5</ton>
|
|
28
|
+
<npi>6</npi>
|
|
29
|
+
<address>213</address>
|
|
30
|
+
</sme_address>
|
|
31
|
+
<error_status_code>3</error_status_code>
|
|
32
|
+
</unsuccess_sme>
|
|
33
|
+
</unsuccess_smes>
|
|
34
|
+
</smpp_submit_multi_resp>
|
|
35
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands
|
|
3
|
+
xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd"
|
|
4
|
+
xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd"
|
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
6
|
+
<smpp_submit_sm>
|
|
7
|
+
<command_status>0</command_status>
|
|
8
|
+
<sequence_number>12</sequence_number>
|
|
9
|
+
<service_type>SMS</service_type>
|
|
10
|
+
<source_addr_ton>1</source_addr_ton>
|
|
11
|
+
<source_addr_npi>2</source_addr_npi>
|
|
12
|
+
<source_addr>123</source_addr>
|
|
13
|
+
<dest_addr_ton>4</dest_addr_ton>
|
|
14
|
+
<dest_addr_npi>5</dest_addr_npi>
|
|
15
|
+
<dest_addr>321</dest_addr>
|
|
16
|
+
<esm_class>6</esm_class>
|
|
17
|
+
<protocol_id>7</protocol_id>
|
|
18
|
+
<priority_flag>8</priority_flag>
|
|
19
|
+
<schedule_delivery_time></schedule_delivery_time>
|
|
20
|
+
<validity_period></validity_period>
|
|
21
|
+
<registered_delivery>9</registered_delivery>
|
|
22
|
+
<replace_if_present_flag>10</replace_if_present_flag>
|
|
23
|
+
<data_coding>11</data_coding>
|
|
24
|
+
<sm_default_msg_id>12</sm_default_msg_id>
|
|
25
|
+
<sm_length>0</sm_length>
|
|
26
|
+
<short_message></short_message>
|
|
27
|
+
|
|
28
|
+
<user_message_reference>1</user_message_reference>
|
|
29
|
+
<source_port>2</source_port>
|
|
30
|
+
<source_addr_subunit>3</source_addr_subunit>
|
|
31
|
+
<destination_port>4</destination_port>
|
|
32
|
+
<dest_addr_subunit>5</dest_addr_subunit>
|
|
33
|
+
<sar_msg_ref_num>6</sar_msg_ref_num>
|
|
34
|
+
<sar_total_segments>7</sar_total_segments>
|
|
35
|
+
<sar_segment_seqnum>8</sar_segment_seqnum>
|
|
36
|
+
<more_messages_to_send>9</more_messages_to_send>
|
|
37
|
+
<payload_type>10</payload_type>
|
|
38
|
+
<message_payload>01 02 AA FF</message_payload>
|
|
39
|
+
<privacy_indicator>11</privacy_indicator>
|
|
40
|
+
<callback_num>01 02 AA FF</callback_num>
|
|
41
|
+
<callback_num_pres_ind>12</callback_num_pres_ind>
|
|
42
|
+
<callback_num_atag>01 02 AA FF</callback_num_atag>
|
|
43
|
+
<source_subaddress>01 02 AA FF</source_subaddress>
|
|
44
|
+
<dest_subaddress>01 02 AA FF</dest_subaddress>
|
|
45
|
+
<user_response_code>13</user_response_code>
|
|
46
|
+
<display_time>14</display_time>
|
|
47
|
+
<sms_signal>15</sms_signal>
|
|
48
|
+
<ms_validity>16</ms_validity>
|
|
49
|
+
<ms_msg_wait_facilities>17</ms_msg_wait_facilities>
|
|
50
|
+
<number_of_messages>18</number_of_messages>
|
|
51
|
+
<alert_on_msg_delivery>19</alert_on_msg_delivery>
|
|
52
|
+
<language_indicator>20</language_indicator>
|
|
53
|
+
<its_reply_type>21</its_reply_type>
|
|
54
|
+
<its_session_info>22</its_session_info>
|
|
55
|
+
<ussd_service_op>23</ussd_service_op>
|
|
56
|
+
</smpp_submit_sm>
|
|
57
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands
|
|
3
|
+
xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd"
|
|
4
|
+
xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd"
|
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
6
|
+
<smpp_submit_sm>
|
|
7
|
+
<command_status>0</command_status>
|
|
8
|
+
<sequence_number>12</sequence_number>
|
|
9
|
+
<service_type>SMS</service_type>
|
|
10
|
+
<source_addr_ton>1</source_addr_ton>
|
|
11
|
+
<source_addr_npi>2</source_addr_npi>
|
|
12
|
+
<source_addr>123</source_addr>
|
|
13
|
+
<dest_addr_ton>4</dest_addr_ton>
|
|
14
|
+
<dest_addr_npi>5</dest_addr_npi>
|
|
15
|
+
<dest_addr>321</dest_addr>
|
|
16
|
+
<esm_class>6</esm_class>
|
|
17
|
+
<protocol_id>7</protocol_id>
|
|
18
|
+
<priority_flag>8</priority_flag>
|
|
19
|
+
<schedule_delivery_time></schedule_delivery_time>
|
|
20
|
+
<validity_period></validity_period>
|
|
21
|
+
<registered_delivery>9</registered_delivery>
|
|
22
|
+
<replace_if_present_flag>10</replace_if_present_flag>
|
|
23
|
+
<data_coding>11</data_coding>
|
|
24
|
+
<sm_default_msg_id>12</sm_default_msg_id>
|
|
25
|
+
<sm_length>0</sm_length>
|
|
26
|
+
<short_message></short_message>
|
|
27
|
+
</smpp_submit_sm>
|
|
28
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd" xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
3
|
+
<smpp_submit_sm_resp>
|
|
4
|
+
<command_status>0</command_status>
|
|
5
|
+
<sequence_number>12</sequence_number>
|
|
6
|
+
<message_id>123</message_id>
|
|
7
|
+
</smpp_submit_sm_resp>
|
|
8
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands
|
|
3
|
+
xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd"
|
|
4
|
+
xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd"
|
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
6
|
+
<smpp_unbind>
|
|
7
|
+
<command_status>0</command_status>
|
|
8
|
+
<sequence_number>12</sequence_number>
|
|
9
|
+
</smpp_unbind>
|
|
10
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<smpp_commands:smpp_commands
|
|
3
|
+
xsi:schemaLocation="http://www.example.net/smpp_commands.xsd smpp_commands.xsd"
|
|
4
|
+
xmlns:smpp_commands="http://www.example.net/smpp_commands.xsd"
|
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
6
|
+
<smpp_unbind_resp>
|
|
7
|
+
<command_status>0</command_status>
|
|
8
|
+
<sequence_number>12</sequence_number>
|
|
9
|
+
</smpp_unbind_resp>
|
|
10
|
+
</smpp_commands:smpp_commands>
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
# == Synopsis
|
|
3
|
+
# SMPP decoder.
|
|
4
|
+
#
|
|
5
|
+
# == Examples
|
|
6
|
+
# This command decode SMPP package and output it.
|
|
7
|
+
# dump_viewer --dumpfile dump.smpp
|
|
8
|
+
#
|
|
9
|
+
# Other examples:
|
|
10
|
+
# dump_viewer -q --dumpfile _dump.smpp --showdump 1 --outputter txt
|
|
11
|
+
# dump_viewer --verbose --dumpfile _dump.smpp --showdump 0 --outputter csv
|
|
12
|
+
#
|
|
13
|
+
# == Usage
|
|
14
|
+
# dump_viewer [options]
|
|
15
|
+
#
|
|
16
|
+
# For help use: dump_viewer -h
|
|
17
|
+
#
|
|
18
|
+
# == Options
|
|
19
|
+
# -h, --help Displays help message
|
|
20
|
+
# -v, --version Display the version, then exit
|
|
21
|
+
# -q, --quiet Output as little as possible, overrides verbose
|
|
22
|
+
# -V, --verbose Verbose output
|
|
23
|
+
# -f, --dumpfile Path to file with SMPP dump
|
|
24
|
+
# -x, --[no-]showhex Show hex fields representation
|
|
25
|
+
# -d, --[no-]showdump Show buffer dump after reading it from file
|
|
26
|
+
# -e, --[no-]showesm Show detailed information from esm class
|
|
27
|
+
# -f, --[no-]showfmt Show detailed information about area format
|
|
28
|
+
# -o, --outputter Outputter for printing(txt, csv, hex or xml)
|
|
29
|
+
#
|
|
30
|
+
# == Author
|
|
31
|
+
# Majoron
|
|
32
|
+
#
|
|
33
|
+
# == Copyright
|
|
34
|
+
# Copyright 2007 Majoron.com (developers@majoron.com)
|
|
35
|
+
# Original sources are available at www.majoron.com
|
|
36
|
+
#
|
|
37
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
38
|
+
# you may not use this file except in compliance with the License.
|
|
39
|
+
# You may obtain a copy of the License at
|
|
40
|
+
#
|
|
41
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
+
#
|
|
43
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
44
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
45
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
46
|
+
# See the License for the specific language governing permissions and
|
|
47
|
+
# limitations under the License.
|
|
48
|
+
#
|
|
49
|
+
|
|
50
|
+
$:.unshift File.dirname(__FILE__) + '/../lib/'
|
|
51
|
+
$:.unshift File.dirname(__FILE__) + '/../lib/' + '/../../../AntHill/0.5/lib/'
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Include necessary libraries
|
|
55
|
+
require "optparse"
|
|
56
|
+
require "rdoc/usage"
|
|
57
|
+
require "ostruct"
|
|
58
|
+
require "date"
|
|
59
|
+
|
|
60
|
+
# Include anthill library
|
|
61
|
+
require "anthill"
|
|
62
|
+
require "anthill_smpp"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
#
|
|
66
|
+
class DumpViewer
|
|
67
|
+
# Module contains supportable outputters
|
|
68
|
+
module Outputter
|
|
69
|
+
TXT = "TXT"
|
|
70
|
+
CSV = "CSV"
|
|
71
|
+
HEX = "HEX"
|
|
72
|
+
XML = "XML"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Module contains error messages
|
|
76
|
+
module Errors
|
|
77
|
+
UNABLE_TO_OPEN_FILE = "Unable to open file."
|
|
78
|
+
INVALID_COMMAND_ID = "Unknown PDU command id."
|
|
79
|
+
MORE_THAN_ONE_PACKAGE = "Dump contains a valid SMPP package and extra dump information."
|
|
80
|
+
UNSUPPORTABLE_OUTPUTTER = "Unsupportable outputter. Supportable are: txt, csv, hex and xml."
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Constructor
|
|
84
|
+
def initialize(arguments, stdin)
|
|
85
|
+
@arguments = arguments
|
|
86
|
+
@stdin = stdin
|
|
87
|
+
|
|
88
|
+
# Set defaults
|
|
89
|
+
@options = OpenStruct.new
|
|
90
|
+
@options.verbose = false
|
|
91
|
+
@options.quiet = false
|
|
92
|
+
@options.showhex = true
|
|
93
|
+
@options.showdump = true
|
|
94
|
+
@options.showesm = true
|
|
95
|
+
@options.showfmt = true
|
|
96
|
+
@options.dumpfile = "dump.smpp"
|
|
97
|
+
@options.outputter = "txt"
|
|
98
|
+
|
|
99
|
+
# Set accessors
|
|
100
|
+
@outputter = ""
|
|
101
|
+
@package = nil
|
|
102
|
+
@buffer = ""
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Entry point to run application
|
|
106
|
+
def run_application
|
|
107
|
+
if parsed_options? && arguments_valid?
|
|
108
|
+
output_options if @options.verbose # [Optional]
|
|
109
|
+
process_arguments
|
|
110
|
+
process_application
|
|
111
|
+
else
|
|
112
|
+
output_usage
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Public accessors
|
|
117
|
+
attr_reader :options
|
|
118
|
+
|
|
119
|
+
protected
|
|
120
|
+
def parsed_options?
|
|
121
|
+
# Specify options
|
|
122
|
+
opts = OptionParser.new
|
|
123
|
+
opts.on('-v', '--version') { output_version ; exit 0 }
|
|
124
|
+
opts.on('-h', '--help') { output_help }
|
|
125
|
+
opts.on('-V', '--verbose') { @options.verbose = true }
|
|
126
|
+
opts.on('-q', '--quiet') { @options.quiet = true }
|
|
127
|
+
|
|
128
|
+
# Get a show dump option
|
|
129
|
+
opts.on("-x", "--[no-]showhex", "Show hex fields representation") do |val|
|
|
130
|
+
options.showhex = val
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Get a show dump option
|
|
134
|
+
opts.on("-d", "--[no-]showdump", "Show buffer dump after reading it from file") do |val|
|
|
135
|
+
options.showdump = val
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Get a show esm class options option
|
|
139
|
+
opts.on("-e", "--[no-]showesm", "Show detailed information from esm class") do |val|
|
|
140
|
+
options.showesm = val
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Get a show format option
|
|
144
|
+
opts.on("-e", "--[no-]showfmt", "Show detailed information about area format") do |val|
|
|
145
|
+
options.showfmt = val
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Get a dumpfile
|
|
149
|
+
opts.on("-f", "--dumpfile DUMPFILE", "Path to file with SMPP dump") do |dump|
|
|
150
|
+
@options.dumpfile = dump
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Get a outputter
|
|
154
|
+
opts.on("-o", "--outputter OUTPUTTER",
|
|
155
|
+
"Outputter for printing(txt, csv, hex or xml)") do |out|
|
|
156
|
+
@options.outputter = out
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
opts.parse!(@arguments) rescue return false
|
|
160
|
+
process_options
|
|
161
|
+
true
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Performs post-parse processing on options
|
|
166
|
+
def process_options
|
|
167
|
+
@options.verbose = false if @options.quiet
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def output_options
|
|
171
|
+
puts "Options:\n"
|
|
172
|
+
@options.marshal_dump.each do |name, val|
|
|
173
|
+
puts " #{name} = #{val}"
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# True if required arguments were provided
|
|
178
|
+
def arguments_valid?
|
|
179
|
+
return false if @options.dumpfile.nil?
|
|
180
|
+
true
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Setup the arguments
|
|
184
|
+
def process_arguments
|
|
185
|
+
# Place in local vars, etc
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def output_help
|
|
189
|
+
output_version
|
|
190
|
+
RDoc::usage() #exits app
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def output_usage
|
|
194
|
+
RDoc::usage('usage') # gets usage from comments above
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def output_version
|
|
198
|
+
puts "#{File.basename(__FILE__)} version #{VERSION}"
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# At the begining read data from file, then decode a byte buffer
|
|
202
|
+
# that was read and then output information about SMPP package
|
|
203
|
+
def process_application
|
|
204
|
+
begin
|
|
205
|
+
create_smpp_outputter()
|
|
206
|
+
|
|
207
|
+
create_byte_buffer()
|
|
208
|
+
|
|
209
|
+
decode_byte_buffer()
|
|
210
|
+
|
|
211
|
+
output_byte_buffer()
|
|
212
|
+
|
|
213
|
+
output_smpp_package()
|
|
214
|
+
rescue Exception => e
|
|
215
|
+
puts e
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Create appropriate outputter based on command line
|
|
220
|
+
def create_smpp_outputter
|
|
221
|
+
case @options.outputter.upcase
|
|
222
|
+
when Outputter::TXT
|
|
223
|
+
@outputter = AntHill::SMPP::SMPPTxtOutputter.new(STDOUT,
|
|
224
|
+
options.showhex, options.showesm, options.showfmt)
|
|
225
|
+
when Outputter::CSV
|
|
226
|
+
@outputter = AntHill::SMPP::SMPPCSVOutputter.new(STDOUT,
|
|
227
|
+
options.showesm, options.showfmt)
|
|
228
|
+
when Outputter::HEX
|
|
229
|
+
@outputter = AntHill::SMPP::SMPPHexOutputter.new(STDOUT)
|
|
230
|
+
when Outputter::XML
|
|
231
|
+
@outputter = AntHill::SMPP::SMPPXMLOutputter.new(STDOUT)
|
|
232
|
+
else
|
|
233
|
+
raise Errors::UNSUPPORTABLE_OUTPUTTER
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Open file with smpp dump and create a byte buffer based on a file
|
|
238
|
+
def create_byte_buffer
|
|
239
|
+
file = File.new(@options.dumpfile, "r")
|
|
240
|
+
raise Errors::UNABLE_TO_OPEN_FILE if file.nil?
|
|
241
|
+
begin
|
|
242
|
+
buf = AntHill::ByteBuffer.new(@buffer)
|
|
243
|
+
buf.read_dump(file)
|
|
244
|
+
file.close()
|
|
245
|
+
rescue RuntimeError => e
|
|
246
|
+
file.close()
|
|
247
|
+
raise
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def decode_byte_buffer
|
|
252
|
+
begin
|
|
253
|
+
decoder = AntHill::SMPP::SMPPDecoder.new()
|
|
254
|
+
validator = AntHill::SMPP::SMPPValidator.new()
|
|
255
|
+
|
|
256
|
+
decoder.append_buffer(@buffer)
|
|
257
|
+
@package = decoder.get_packet()
|
|
258
|
+
if !@package.nil?
|
|
259
|
+
@package.decode_packet(decoder)
|
|
260
|
+
decoder.validate_offset(@package.command_length)
|
|
261
|
+
@package.validate_packet(validator)
|
|
262
|
+
if @package.command_length != @buffer.size()
|
|
263
|
+
puts Errors::MORE_THAN_ONE_PACKAGE
|
|
264
|
+
end
|
|
265
|
+
else
|
|
266
|
+
raise Errors::INVALID_COMMAND_ID
|
|
267
|
+
end
|
|
268
|
+
rescue RuntimeError => e
|
|
269
|
+
puts e
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Output byte buffer if showdump option is true
|
|
275
|
+
def output_byte_buffer
|
|
276
|
+
return if !@options.showdump
|
|
277
|
+
puts AntHill::ByteBuffer.encode_hex(@buffer)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def output_smpp_package
|
|
281
|
+
return if package.nil?
|
|
282
|
+
package.output_packet(@outputter)
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
#
|
|
286
|
+
VERSION = '0.5.1'
|
|
287
|
+
|
|
288
|
+
# Private accessors
|
|
289
|
+
attr_accessor :outputter
|
|
290
|
+
attr_accessor :package
|
|
291
|
+
attr_accessor :buffer
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Create a application and process
|
|
297
|
+
dump_viewer = DumpViewer.new(ARGV, STDIN)
|
|
298
|
+
dump_viewer.run_application()
|