Sipper 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/sipper/README.rb +26 -0
- data/sipper/b2bua_controller.rb +163 -0
- data/sipper/b2bua_session_mixin.rb +24 -0
- data/sipper/base_controller.rb +425 -0
- data/sipper/bin/common.rb +42 -0
- data/sipper/bin/generate.rb +70 -0
- data/sipper/bin/project.rb +44 -0
- data/sipper/bin/run.rb +85 -0
- data/sipper/bin/run_smoke.rb +8 -0
- data/sipper/config/log4r.xml +71 -0
- data/sipper/controller_class_loader.rb +29 -0
- data/sipper/controller_selector.rb +119 -0
- data/sipper/controllers/invite_controller.rb +30 -0
- data/sipper/controllers/order.yaml +3 -0
- data/sipper/custom_message.rb +4 -0
- data/sipper/detached_session.rb +11 -0
- data/sipper/docs/manual.txt +1621 -0
- data/sipper/generators/README +12 -0
- data/sipper/generators/gen_controller.rb +228 -0
- data/sipper/generators/gen_project.rb +45 -0
- data/sipper/generators/gen_test.rb +72 -0
- data/sipper/generators/project_template_dir/Rakefile +56 -0
- data/sipper/generators/project_template_dir/config/sipper.cfg +31 -0
- data/sipper/generators/project_template_dir/controllers/README.txt +2 -0
- data/sipper/generators/project_template_dir/dot_sipper.proj +2 -0
- data/sipper/generators/project_template_dir/logs/README.txt +2 -0
- data/sipper/generators/project_template_dir/tests/README.txt +2 -0
- data/sipper/lib/smc/statemap.rb +194 -0
- data/sipper/logs/dialog_info_store +0 -0
- data/sipper/logs/r.cmd +6 -0
- data/sipper/logs/r.sh +6 -0
- data/sipper/media/sipper_media_client.rb +268 -0
- data/sipper/media/sipper_media_event.rb +43 -0
- data/sipper/media/sipper_media_manager.rb +145 -0
- data/sipper/media/sipper_media_proxy.rb +60 -0
- data/sipper/media/sipper_offer_answer.rb +285 -0
- data/sipper/message.rb +512 -0
- data/sipper/modified_pattern_formatter.rb +119 -0
- data/sipper/proxy_controller.rb +143 -0
- data/sipper/registration.rb +52 -0
- data/sipper/request.rb +109 -0
- data/sipper/response.rb +123 -0
- data/sipper/ruby_ext/module.rb +27 -0
- data/sipper/ruby_ext/mutable_class.rb +17 -0
- data/sipper/ruby_ext/object.rb +38 -0
- data/sipper/ruby_ext/pqueue.rb +190 -0
- data/sipper/ruby_ext/snapshot.rb +201 -0
- data/sipper/ruby_ext/string.rb +18 -0
- data/sipper/ruby_ext/time.rb +9 -0
- data/sipper/run/run_sipper1.rb +28 -0
- data/sipper/run/run_sipper2.rb +56 -0
- data/sipper/sdp/sdp.rb +257 -0
- data/sipper/sdp/sdp_generator.rb +131 -0
- data/sipper/sdp/sdp_parser.rb +136 -0
- data/sipper/session.rb +1952 -0
- data/sipper/session_manager.rb +170 -0
- data/sipper/session_recorder.rb +190 -0
- data/sipper/session_state/DialogState.sm +54 -0
- data/sipper/session_state/DialogState_sm.rb +337 -0
- data/sipper/session_state/dialog_routes.rb +141 -0
- data/sipper/sip_headers/header.rb +632 -0
- data/sipper/sip_headers/sipuri.rb +352 -0
- data/sipper/sip_logger.rb +65 -0
- data/sipper/sip_message_router.rb +231 -0
- data/sipper/sip_test_driver_controller.rb +10 -0
- data/sipper/sipper.rb +329 -0
- data/sipper/sipper_assertions.rb +21 -0
- data/sipper/sipper_configurator.rb +376 -0
- data/sipper/sipper_http/sipper_http_request_dispatcher.rb +71 -0
- data/sipper/sipper_http/sipper_http_response.rb +25 -0
- data/sipper/stray_message_manager.rb +40 -0
- data/sipper/test_completion_signaling_helper.rb +77 -0
- data/sipper/transaction/Ict.sm +59 -0
- data/sipper/transaction/Ict_sm.rb +430 -0
- data/sipper/transaction/Ist.sm +74 -0
- data/sipper/transaction/Ist_sm.rb +460 -0
- data/sipper/transaction/Nict.sm +51 -0
- data/sipper/transaction/Nict_sm.rb +325 -0
- data/sipper/transaction/Nist.sm +59 -0
- data/sipper/transaction/Nist_sm.rb +356 -0
- data/sipper/transaction/invite_client_transaction.rb +274 -0
- data/sipper/transaction/invite_server_transaction.rb +319 -0
- data/sipper/transaction/non_invite_client_transaction.rb +230 -0
- data/sipper/transaction/non_invite_server_transaction.rb +263 -0
- data/sipper/transaction/state_machine_wrapper.rb +58 -0
- data/sipper/transaction/transaction.rb +212 -0
- data/sipper/transport/base_transport.rb +84 -0
- data/sipper/transport/rel_unrel.rb +19 -0
- data/sipper/transport/transport_and_route_resolver.rb +67 -0
- data/sipper/transport/udp_transport.rb +156 -0
- data/sipper/transport_manager.rb +33 -0
- data/sipper/udp_session.rb +17 -0
- data/sipper/util/command_element.rb +62 -0
- data/sipper/util/compact_converter.rb +50 -0
- data/sipper/util/counter.rb +26 -0
- data/sipper/util/digest/digest_authorizer.rb +204 -0
- data/sipper/util/expectation_parser.rb +164 -0
- data/sipper/util/locator.rb +31 -0
- data/sipper/util/message_fill.rb +58 -0
- data/sipper/util/persistence/ps_sipper_map.rb +63 -0
- data/sipper/util/persistence/sipper_map.rb +41 -0
- data/sipper/util/sipper_util.rb +305 -0
- data/sipper/util/timer/sip_timer_helper.rb +26 -0
- data/sipper/util/timer/timer_manager.rb +80 -0
- data/sipper/util/timer/timer_task.rb +56 -0
- data/sipper/util/validations.rb +44 -0
- data/sipper/version.rb +10 -0
- data/sipper_test/_test_media_uas.rb +79 -0
- data/sipper_test/base_test_case.rb +31 -0
- data/sipper_test/c_134.txt +7 -0
- data/sipper_test/driven_sip_test_case.rb +96 -0
- data/sipper_test/gold.txt +10 -0
- data/sipper_test/gold_res.txt +8 -0
- data/sipper_test/gold_sub.txt +9 -0
- data/sipper_test/hello_sipper.au +0 -0
- data/sipper_test/in_sipper.au +0 -0
- data/sipper_test/nonrr_proxy.rb +17 -0
- data/sipper_test/order_tests.yaml +4 -0
- data/sipper_test/rake_res.txt +399 -0
- data/sipper_test/rr_proxy.rb +17 -0
- data/sipper_test/run_test.cmd +94 -0
- data/sipper_test/sip_test_case.rb +104 -0
- data/sipper_test/test2xx_retransmission.rb +80 -0
- data/sipper_test/test2xx_retransmission_with_limit.rb +81 -0
- data/sipper_test/test2xx_retransmission_with_nist.rb +91 -0
- data/sipper_test/test2xx_retransmission_with_txns.rb +94 -0
- data/sipper_test/test_address_header.rb +66 -0
- data/sipper_test/test_b2bua1.rb +130 -0
- data/sipper_test/test_b2bua2.rb +120 -0
- data/sipper_test/test_b2bua3.rb +160 -0
- data/sipper_test/test_b2bua4.rb +130 -0
- data/sipper_test/test_base_controller.rb +110 -0
- data/sipper_test/test_base_transport.rb +37 -0
- data/sipper_test/test_cancel.rb +21 -0
- data/sipper_test/test_cancel_after2xx.rb +81 -0
- data/sipper_test/test_cancel_retransmission.rb +105 -0
- data/sipper_test/test_cancel_with481.rb +83 -0
- data/sipper_test/test_cancel_with487.rb +70 -0
- data/sipper_test/test_cancel_with_ist_without_nist.rb +99 -0
- data/sipper_test/test_cancel_with_nist.rb +84 -0
- data/sipper_test/test_cancel_without487.rb +77 -0
- data/sipper_test/test_command_element.rb +38 -0
- data/sipper_test/test_compact_converter.rb +33 -0
- data/sipper_test/test_controller_class_loader.rb +37 -0
- data/sipper_test/test_controller_selector.rb +53 -0
- data/sipper_test/test_controller_using_compact_headers.rb +74 -0
- data/sipper_test/test_controller_using_header_order.rb +85 -0
- data/sipper_test/test_controller_using_ict.rb +64 -0
- data/sipper_test/test_controller_using_ict_with_non_success.rb +72 -0
- data/sipper_test/test_controller_using_ict_with_tcbh.rb +24 -0
- data/sipper_test/test_controller_using_ict_with_tcbh_no_action.rb +24 -0
- data/sipper_test/test_controller_using_ist.rb +70 -0
- data/sipper_test/test_controller_using_ist_with_tcbh.rb +24 -0
- data/sipper_test/test_controller_using_nict.rb +115 -0
- data/sipper_test/test_controller_using_nict_with_tcbh.rb +24 -0
- data/sipper_test/test_controller_using_nist.rb +63 -0
- data/sipper_test/test_controller_using_pre_existing_rs0.rb +73 -0
- data/sipper_test/test_controller_using_pre_existing_rs1.rb +75 -0
- data/sipper_test/test_controller_using_pre_existing_rs2.rb +71 -0
- data/sipper_test/test_controller_using_route_set.rb +86 -0
- data/sipper_test/test_controller_with_sdp.rb +80 -0
- data/sipper_test/test_controllers/cancel/order.yaml +2 -0
- data/sipper_test/test_controllers/cancel/uac_cancel_controller.rb +35 -0
- data/sipper_test/test_controllers/cancel/uas_cancel_controller.rb +25 -0
- data/sipper_test/test_controllers/class_loading/ordered/first_ordered_controller.rb +5 -0
- data/sipper_test/test_controllers/class_loading/ordered/order.yaml +3 -0
- data/sipper_test/test_controllers/class_loading/ordered/recond_ordered_controller.rb +6 -0
- data/sipper_test/test_controllers/class_loading/ordered/second_ordered_controller.rb +6 -0
- data/sipper_test/test_controllers/class_loading/unordered/first_unordered_controller.rb +7 -0
- data/sipper_test/test_controllers/class_loading/unordered/second_unordered_controller.rb +6 -0
- data/sipper_test/test_controllers/ctrl_trhandler/lib/transport_filters/my_transport_handler.rb +22 -0
- data/sipper_test/test_controllers/ctrl_trhandler/uac_tr_handler_controller.rb +27 -0
- data/sipper_test/test_controllers/ctrl_trhandler/uas_tr_handler_controller.rb +21 -0
- data/sipper_test/test_controllers/ete/order.yaml +1 -0
- data/sipper_test/test_controllers/ete/uac_controller.rb +39 -0
- data/sipper_test/test_controllers/ete/uas_controller.rb +34 -0
- data/sipper_test/test_controllers/extensions/extension_uac_controller.rb +24 -0
- data/sipper_test/test_controllers/extensions/extension_uas_controller.rb +35 -0
- data/sipper_test/test_controllers/extensions/lib/sipper_extensions/my_from_extension.rb +16 -0
- data/sipper_test/test_controllers/ict_tcbh/lib/transaction_handlers/app_ict_handler.rb +23 -0
- data/sipper_test/test_controllers/ict_tcbh/uac_ict_tcbh_controller.rb +27 -0
- data/sipper_test/test_controllers/ict_tcbh/uac_ict_tcbh_no_action_controller.rb +28 -0
- data/sipper_test/test_controllers/ict_tcbh/uas_ict_tcbh_controller.rb +29 -0
- data/sipper_test/test_controllers/ict_tcbh/uas_ict_tcbh_no_action_controller.rb +31 -0
- data/sipper_test/test_controllers/ist_tcbh/lib/app_ist_handler.rb +13 -0
- data/sipper_test/test_controllers/ist_tcbh/uac_ist_tcbh_controller.rb +22 -0
- data/sipper_test/test_controllers/ist_tcbh/uas_ist_tcbh_controller.rb +31 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/in_order.yaml +2 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/my_transport_handler1.rb +21 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/my_transport_handler2.rb +21 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/out_order.yaml +2 -0
- data/sipper_test/test_controllers/multi_trhandlers/uac_multi_tr_handler_controller.rb +27 -0
- data/sipper_test/test_controllers/multi_trhandlers/uas_multi_tr_handler_controller.rb +29 -0
- data/sipper_test/test_controllers/multiple/lib/blank_test.rb +2 -0
- data/sipper_test/test_controllers/multiple/uac_info_controller.rb +21 -0
- data/sipper_test/test_controllers/multiple/uac_msg_controller.rb +20 -0
- data/sipper_test/test_controllers/multiple/uas_info_controller.rb +15 -0
- data/sipper_test/test_controllers/multiple/uas_msg_controller.rb +14 -0
- data/sipper_test/test_controllers/nict_tcbh/lib/transaction_handlers/app_nict_handler.rb +13 -0
- data/sipper_test/test_controllers/nict_tcbh/uac_nict_tcbh_controller.rb +26 -0
- data/sipper_test/test_controllers/nict_tcbh/uas_nict_tcbh_controller.rb +20 -0
- data/sipper_test/test_controllers/state_machine_based/lib/CreditControl.sm +43 -0
- data/sipper_test/test_controllers/state_machine_based/lib/CreditControl_sm.rb +194 -0
- data/sipper_test/test_controllers/state_machine_based/order.yaml +1 -0
- data/sipper_test/test_controllers/state_machine_based/uac_message_controller.rb +34 -0
- data/sipper_test/test_controllers/state_machine_based/uas_message_controller.rb +44 -0
- data/sipper_test/test_controllers/stray_message/lib/sipper_extensions/my_stray_handler.rb +9 -0
- data/sipper_test/test_controllers/stray_message/stray_uac_controller.rb +24 -0
- data/sipper_test/test_controllers/stray_message/stray_uas_controller.rb +31 -0
- data/sipper_test/test_controllers/string/order.yaml +1 -0
- data/sipper_test/test_controllers/string/uac_controller.rb +29 -0
- data/sipper_test/test_controllers/string/uas_controller.rb +22 -0
- data/sipper_test/test_controllers/test_controller.rb +24 -0
- data/sipper_test/test_detached_session1.rb +78 -0
- data/sipper_test/test_dialog_routes.rb +139 -0
- data/sipper_test/test_digest_challenge1.rb +89 -0
- data/sipper_test/test_digest_challenge2.rb +90 -0
- data/sipper_test/test_dynamic_parse.rb +249 -0
- data/sipper_test/test_empty_sdp.rb +89 -0
- data/sipper_test/test_ete.rb +37 -0
- data/sipper_test/test_expectation_parser.rb +76 -0
- data/sipper_test/test_extensions.rb +28 -0
- data/sipper_test/test_freeze.rb +81 -0
- data/sipper_test/test_generated.rb +90 -0
- data/sipper_test/test_header_parameters.rb +75 -0
- data/sipper_test/test_header_parse.rb +141 -0
- data/sipper_test/test_http_client1.rb +84 -0
- data/sipper_test/test_http_client2.rb +90 -0
- data/sipper_test/test_ict_with_timeout.rb +62 -0
- data/sipper_test/test_in_dialog_request.rb +61 -0
- data/sipper_test/test_inline_controller.rb +67 -0
- data/sipper_test/test_invite_client_transaction.rb +272 -0
- data/sipper_test/test_invite_replace.rb +147 -0
- data/sipper_test/test_invite_retransmission.rb +90 -0
- data/sipper_test/test_invite_server_transaction.rb +208 -0
- data/sipper_test/test_lower_cseq.rb +79 -0
- data/sipper_test/test_media.rb +52 -0
- data/sipper_test/test_message.rb +392 -0
- data/sipper_test/test_method_specific_response_handling.rb +81 -0
- data/sipper_test/test_multi_homed1.rb +127 -0
- data/sipper_test/test_multi_homed2.rb +109 -0
- data/sipper_test/test_multi_homed_duplicate.rb +87 -0
- data/sipper_test/test_multi_homed_with_detached.rb +88 -0
- data/sipper_test/test_multiple.rb +49 -0
- data/sipper_test/test_multiple_contacts.rb +89 -0
- data/sipper_test/test_non2xx_retransmission_with_ist.rb +87 -0
- data/sipper_test/test_non_invite_client_transaction.rb +210 -0
- data/sipper_test/test_non_invite_retransmission.rb +91 -0
- data/sipper_test/test_non_invite_server_transaction.rb +202 -0
- data/sipper_test/test_offer_answer_prack.rb +103 -0
- data/sipper_test/test_pickup.rb +258 -0
- data/sipper_test/test_prack.rb +105 -0
- data/sipper_test/test_prack_store_and_dispatch.rb +101 -0
- data/sipper_test/test_prack_timer.rb +105 -0
- data/sipper_test/test_ps_sipper_map.rb +56 -0
- data/sipper_test/test_re_invite_uas_ongoing_ict.rb +81 -0
- data/sipper_test/test_re_invite_uas_ongoing_ist.rb +84 -0
- data/sipper_test/test_re_invite_with_ongoing_ict.rb +101 -0
- data/sipper_test/test_re_invite_with_ongoing_ist.rb +89 -0
- data/sipper_test/test_recorder_swap.rb +157 -0
- data/sipper_test/test_refer.rb +121 -0
- data/sipper_test/test_registeration_clearing.rb +97 -0
- data/sipper_test/test_registrar.rb +109 -0
- data/sipper_test/test_registration_controller.rb +73 -0
- data/sipper_test/test_registration_timeout.rb +90 -0
- data/sipper_test/test_remote_controller.rb +39 -0
- data/sipper_test/test_remote_target_update_on2xx.rb +140 -0
- data/sipper_test/test_request.rb +106 -0
- data/sipper_test/test_response.rb +40 -0
- data/sipper_test/test_response_without_to_tag.rb +92 -0
- data/sipper_test/test_rport.rb +88 -0
- data/sipper_test/test_sdp.rb +91 -0
- data/sipper_test/test_sdp_parser.rb +145 -0
- data/sipper_test/test_session.rb +276 -0
- data/sipper_test/test_session_callback_handler.rb +68 -0
- data/sipper_test/test_session_lifetime.rb +66 -0
- data/sipper_test/test_session_manager.rb +141 -0
- data/sipper_test/test_session_recorder.rb +145 -0
- data/sipper_test/test_session_state_user_defined.rb +84 -0
- data/sipper_test/test_session_states.rb +91 -0
- data/sipper_test/test_simple_dialog_state.rb +86 -0
- data/sipper_test/test_simple_re_invite.rb +86 -0
- data/sipper_test/test_sip_uri.rb +234 -0
- data/sipper_test/test_sipper_util.rb +45 -0
- data/sipper_test/test_smc_controller.rb +17 -0
- data/sipper_test/test_smoke.rb +80 -0
- data/sipper_test/test_stray.rb +28 -0
- data/sipper_test/test_stray_inline.rb +89 -0
- data/sipper_test/test_stray_res_acked.rb +103 -0
- data/sipper_test/test_stray_respond.rb +104 -0
- data/sipper_test/test_stray_retry.rb +92 -0
- data/sipper_test/test_stray_retry_failure.rb +93 -0
- data/sipper_test/test_stray_retry_initial.rb +100 -0
- data/sipper_test/test_strict_router_with_angled.rb +84 -0
- data/sipper_test/test_string_record.rb +31 -0
- data/sipper_test/test_subscribe_notify.rb +141 -0
- data/sipper_test/test_subscribe_notify_client_timeout.rb +158 -0
- data/sipper_test/test_subscribe_notify_dialog.rb +146 -0
- data/sipper_test/test_subscribe_notify_expires.rb +155 -0
- data/sipper_test/test_subscribe_notify_multiple_subscription.rb +157 -0
- data/sipper_test/test_subscribe_notify_server_timeout.rb +144 -0
- data/sipper_test/test_subsequent_unsent.rb +88 -0
- data/sipper_test/test_target_refresh_proxy_detached.rb +128 -0
- data/sipper_test/test_target_refresh_proxy_udp.rb +130 -0
- data/sipper_test/test_target_refresh_rr_proxy_udp.rb +133 -0
- data/sipper_test/test_target_refresh_with_new_port.rb +158 -0
- data/sipper_test/test_target_refresh_with_proxy1.rb +113 -0
- data/sipper_test/test_target_refresh_with_rr_update_proxy.rb +145 -0
- data/sipper_test/test_target_refresh_with_update_proxy.rb +144 -0
- data/sipper_test/test_target_refresh_with_update_proxy2.rb +139 -0
- data/sipper_test/test_timer_manager.rb +71 -0
- data/sipper_test/test_timer_task.rb +60 -0
- data/sipper_test/test_transport_handler.rb +19 -0
- data/sipper_test/test_transport_multi_handler.rb +18 -0
- data/sipper_test/test_udp_transport.rb +119 -0
- data/sipper_test/test_unparsed.rb +70 -0
- data/sipper_test/test_validations.rb +69 -0
- data/sipper_test/test_with_rr_proxy.rb +111 -0
- data/sipper_test/testmediacontroller.rb +71 -0
- data/sipper_test/tracing.rb +23 -0
- data/sipper_test/transaction_test_helper.rb +176 -0
- data/sipper_test/transport_filters.rb +26 -0
- data/sipper_test/ts_sipper.rb +91 -0
- data/sipper_test/ts_smoke.rb +3 -0
- data/sipper_test/tt.cmd +20 -0
- metadata +455 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# Holds references for -
|
2
|
+
# :Tm => Transport Manager
|
3
|
+
# :Cs => Controller Selector
|
4
|
+
# :Sipper => Main class
|
5
|
+
# :Tlocks => A hash of locks structure for tests signaling. If not found locally then this is
|
6
|
+
# additionally searched in the remote TestServer if present in the configuration.
|
7
|
+
# This is for the cases where the UAS is running on a separate node
|
8
|
+
# :Sth => SIP Timer helper, which is the central class to schedule the SIP timers including
|
9
|
+
# app level timers.
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'sipper_configurator'
|
13
|
+
|
14
|
+
module SIP
|
15
|
+
|
16
|
+
class Locator
|
17
|
+
|
18
|
+
@@services_hash = {}
|
19
|
+
@@ro = nil
|
20
|
+
|
21
|
+
def Locator.[](k)
|
22
|
+
@@services_hash[k]
|
23
|
+
end
|
24
|
+
|
25
|
+
def Locator.[]=(k,v)
|
26
|
+
@@services_hash[k] = v
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'sip_logger'
|
2
|
+
|
3
|
+
module SipperUtil
|
4
|
+
class MessageFill
|
5
|
+
|
6
|
+
include SipLogger
|
7
|
+
|
8
|
+
SUBS = {
|
9
|
+
:lip => /_PH_LIP_/,
|
10
|
+
:lp => /_PH_LP_/,
|
11
|
+
:rip => /_PH_RIP_/,
|
12
|
+
:rp => /_PH_RP_/,
|
13
|
+
:gcnt => /_PH_GCNT_/, #global accross process
|
14
|
+
:lcnts => /_PH_LCNTS_/, #local seq maintained for session for sent msg
|
15
|
+
:lcntr => /_PH_LCNTR_/, #local maintained for session for recvd msg
|
16
|
+
:lctg => /_PH_LCTG_/, #local tag
|
17
|
+
:trans => /_PH_TRANS_/, #transport UDP/TCP/TLS/SCTP
|
18
|
+
:cl => /_PH_CL_/, #content length
|
19
|
+
:rnd => /_PH_RND_/ # random string
|
20
|
+
}
|
21
|
+
|
22
|
+
# just plain strings
|
23
|
+
def MessageFill.sub(str, h)
|
24
|
+
h.each do |k,v|
|
25
|
+
str.gsub!(SUBS[k], v)
|
26
|
+
end
|
27
|
+
str
|
28
|
+
end
|
29
|
+
|
30
|
+
def MessageFill.fill(msg, h)
|
31
|
+
SipLogger['siplog::messagefill'].debug("msg is a #{msg.class}")
|
32
|
+
return MessageFill.sub(msg, h) if msg.is_a?(String)
|
33
|
+
msg.each do |k, v|
|
34
|
+
#SipLogger['siplog::messagefill'].debug("Processing for #{k} the value is #{v}")
|
35
|
+
unless v.nil?
|
36
|
+
msg[k] = v.map do |e|
|
37
|
+
case e
|
38
|
+
when String
|
39
|
+
MessageFill.sub(e, h)
|
40
|
+
when ::SipHeaders::Header
|
41
|
+
str = e.to_s
|
42
|
+
if str =~ /_PH_/
|
43
|
+
e.assign(MessageFill.sub(str, h))
|
44
|
+
else
|
45
|
+
e
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise TypeError, "#{e.class} is not an acceptable type for message fill"
|
49
|
+
end # case
|
50
|
+
end # map
|
51
|
+
end # v.nil?
|
52
|
+
SipLogger['siplog::messagefill'].debug("Processed for #{k} the value is #{msg[k]}")
|
53
|
+
end # each
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'sipper_configurator'
|
2
|
+
require 'pstore'
|
3
|
+
require 'util/persistence/sipper_map'
|
4
|
+
|
5
|
+
module SipperUtil
|
6
|
+
module Persistence
|
7
|
+
|
8
|
+
# Uses the pstore data store
|
9
|
+
# Data access to the map is transactional.
|
10
|
+
class PsSipperMap < SipperMap
|
11
|
+
def initialize(name)
|
12
|
+
super
|
13
|
+
path = SipperConfigurator[:PStorePath]||SipperConfigurator[:LogPath]
|
14
|
+
@ps = PStore.new(File.join(path, name))
|
15
|
+
end
|
16
|
+
|
17
|
+
def put(k,v)
|
18
|
+
@ps.transaction do
|
19
|
+
@ps[k] = v
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(k)
|
24
|
+
@ps.transaction(true) do
|
25
|
+
return @ps[k]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_all_keys
|
30
|
+
@ps.transaction(true) do
|
31
|
+
@ps.roots
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def put_all(h)
|
37
|
+
@ps.transaction do
|
38
|
+
h.each_pair {|k,v| @ps[k] = v}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete(k)
|
43
|
+
@ps.transaction do
|
44
|
+
@ps.delete(k)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete_all
|
49
|
+
@ps.transaction do
|
50
|
+
@ps.roots.each do |k|
|
51
|
+
@ps.delete(k)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def destroy
|
57
|
+
self.delete_all
|
58
|
+
File.delete @ps.path
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module SipperUtil
|
2
|
+
module Persistence
|
3
|
+
|
4
|
+
# A simple map like data structure that is persisted based on several
|
5
|
+
# persistence choices.
|
6
|
+
# Data access to the map is transactional.
|
7
|
+
class SipperMap
|
8
|
+
|
9
|
+
# The name identifies the underlying data structure, in case of
|
10
|
+
# file based persistence it is the file name, in case of database
|
11
|
+
# it is the name of db table.
|
12
|
+
def initialize(name)
|
13
|
+
@name = name
|
14
|
+
end
|
15
|
+
|
16
|
+
def put(k,v)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(k)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_all_keys
|
23
|
+
end
|
24
|
+
|
25
|
+
def put_all(h)
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete(k)
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete_all
|
32
|
+
end
|
33
|
+
|
34
|
+
# Deletes all data and removes the underlying data
|
35
|
+
# structure
|
36
|
+
def destroy
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'sip_headers/header'
|
2
|
+
require 'sip_logger'
|
3
|
+
require 'strscan'
|
4
|
+
require 'facets/core/string/underscore'
|
5
|
+
|
6
|
+
module SipperUtil
|
7
|
+
include SipLogger
|
8
|
+
|
9
|
+
RCOLON = /: /
|
10
|
+
SCOLON = /;/
|
11
|
+
NUMERIC_CSEQ = /\d+\s?/
|
12
|
+
SUCC_RANGE = 200..299
|
13
|
+
RPROV_RANGE = 101..199
|
14
|
+
BOOL_MAP = { :true=>true, :false=>false }
|
15
|
+
|
16
|
+
def log_and_raise(err_msg, ex=RuntimeError)
|
17
|
+
loge(err_msg)
|
18
|
+
raise ex, err_msg
|
19
|
+
end
|
20
|
+
|
21
|
+
def SipperUtil.trand
|
22
|
+
((Time.now.usec)/1000).to_s + rand(10000).to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
# Converts the given file name into a well formed
|
26
|
+
# classname. Assumes that file names are underscore
|
27
|
+
# separated and class names are camel case
|
28
|
+
# -4 to remove .rb
|
29
|
+
#
|
30
|
+
def SipperUtil.classify(fname)
|
31
|
+
if fname =~ /\.rb$/
|
32
|
+
fname[0..-4].split("_").map{|x| x.capitalize}.join
|
33
|
+
else
|
34
|
+
fname.split("_").map{|x| x.capitalize}.join
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# does reverse of classify, i.e generates a filename compliant with
|
39
|
+
# Ruby conventions from a class name.
|
40
|
+
def SipperUtil.filify(cname)
|
41
|
+
cname.underscore + ".rb" # from facets
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# Taken from Rails. This converts a fqcname string to a class constant.
|
46
|
+
def SipperUtil.constantize(camel_cased_word)
|
47
|
+
unless /^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ camel_cased_word
|
48
|
+
raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
|
49
|
+
end
|
50
|
+
camel_cased_word = "::#{camel_cased_word}" unless $1
|
51
|
+
Object.module_eval(camel_cased_word, __FILE__, __LINE__)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# converts the header names like p_asserted_identity to
|
56
|
+
# P-Asserted_Identity.
|
57
|
+
# -- Here is an ugly handling for WWW-Authenticate header todo fix this
|
58
|
+
# and also Call-ID handling, as Call-Id is valid yet some tools such
|
59
|
+
# as sipp does not handle it.
|
60
|
+
# ++
|
61
|
+
def SipperUtil.headerize(hname)
|
62
|
+
return nil if hname.nil?
|
63
|
+
arr = hname.to_s.split('_')
|
64
|
+
arr.each do |i|
|
65
|
+
if i.downcase === "www"
|
66
|
+
i.upcase!
|
67
|
+
else
|
68
|
+
i.capitalize!
|
69
|
+
end
|
70
|
+
end
|
71
|
+
hdr = arr.join('-')
|
72
|
+
hdr = "Call-ID" if hdr == "Call-Id"
|
73
|
+
hdr
|
74
|
+
end
|
75
|
+
|
76
|
+
# Reverse of headerize.
|
77
|
+
# P-Asserted_Identity => p_asserted_identity
|
78
|
+
def SipperUtil.methodize(hdr)
|
79
|
+
return nil if hdr.nil?
|
80
|
+
arr = hdr.to_s.downcase.split('-')
|
81
|
+
arr.join('_')
|
82
|
+
end
|
83
|
+
|
84
|
+
# Simply takes the "Header: xxx" and returns "xxx"
|
85
|
+
def SipperUtil.header_value(hdr_string)
|
86
|
+
m = RCOLON.match(hdr_string)
|
87
|
+
m ? m.post_match.strip : hdr_string
|
88
|
+
end
|
89
|
+
|
90
|
+
# Separates the header and params and returns them in
|
91
|
+
# an array.
|
92
|
+
def SipperUtil.header_value_separate_parameters(hdr_string)
|
93
|
+
hdr = SipperUtil.header_value(hdr_string)
|
94
|
+
m = SCOLON.match(hdr)
|
95
|
+
m ? [m.pre_match.strip, m.post_match.strip] : [hdr, nil]
|
96
|
+
end
|
97
|
+
|
98
|
+
# If there are parameters then returns them in a hash with header value.
|
99
|
+
# Takes full header and also just separated params and returns
|
100
|
+
# the array with header value and params hash.
|
101
|
+
# with "My-Header: myvalue" returns ["myvalue", {}]
|
102
|
+
# with "My-Header: myvalue;a=1;b=2" returns ["myvalue", {"a"=>"1", "b"=>"2"}]
|
103
|
+
# with "a=1;b=2" returns [nil, {"a"=>"1", "b"=>"2"}]
|
104
|
+
def SipperUtil.parameterize_header(hdr_string)
|
105
|
+
p_hash = {}
|
106
|
+
p = SipperUtil.header_value_separate_parameters(hdr_string)
|
107
|
+
params = p[1]
|
108
|
+
|
109
|
+
if params
|
110
|
+
params.split(";").each do |x|
|
111
|
+
a = x.split("=")
|
112
|
+
key = a.shift
|
113
|
+
val = a.shift
|
114
|
+
if key
|
115
|
+
val = "" unless val
|
116
|
+
p_hash[key] = val
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
return [p[0], p_hash]
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def SipperUtil.find_parser_and_parse(hname, val, parse_option)
|
125
|
+
if val.class <= SipHeaders::Header
|
126
|
+
return val.dup
|
127
|
+
else
|
128
|
+
val = val.dup.to_s
|
129
|
+
end
|
130
|
+
# val = val.to_s
|
131
|
+
if hname
|
132
|
+
klass = SipHeaders.const_get(SipperUtil.classify(hname.to_s))
|
133
|
+
else
|
134
|
+
str = "Not a header, cannot parse"
|
135
|
+
SipLogger['siplog::message'].warn(str)
|
136
|
+
raise TypeError, str
|
137
|
+
end
|
138
|
+
obj = klass.new
|
139
|
+
obj.name = SipperUtil.headerize(hname.to_s) unless obj.name
|
140
|
+
obj.assign(val, parse_option)
|
141
|
+
return obj
|
142
|
+
rescue NameError => e
|
143
|
+
#SipLogger['siplog::message'].warn("No parser for header #{hname} using default parser")
|
144
|
+
SipperUtil.find_parser_and_parse("Header", val, parse_option)
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# Returns the parameter value if the parameter is available.
|
150
|
+
def SipperUtil.get_parameter(hdr_string, param_name)
|
151
|
+
SipperUtil.parameterize_header(hdr_string)[1][param_name.to_s]
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns true of the named parameter is present, false otherwise.
|
155
|
+
# Can be used for valueless parameter like "lr" matching a string
|
156
|
+
# not a header. For a Header object we can check using the hash access
|
157
|
+
# Header.has_key?
|
158
|
+
def SipperUtil.has_parameter_in_string?(hdr_string, param_name)
|
159
|
+
SipperUtil.parameterize_header(hdr_string)[1].has_key?(param_name.to_s)
|
160
|
+
end
|
161
|
+
|
162
|
+
def SipperUtil.add_parameter(hdr, param, value)
|
163
|
+
hdr << ";" << param << "=" << value
|
164
|
+
return hdr
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
def SipperUtil.cseq_number(cseq_header)
|
169
|
+
val = cseq_header.to_s
|
170
|
+
val = SipperUtil.header_value(cseq_header) if cseq_header =~ /:/
|
171
|
+
m = NUMERIC_CSEQ.match(val)
|
172
|
+
m ? m[0].strip.to_i : nil
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def SipperUtil.cseq_method(cseq_header)
|
177
|
+
val = cseq_header.to_s
|
178
|
+
val = SipperUtil.header_value(cseq_header) if cseq_header =~ /:/
|
179
|
+
m = val.split(/\s+/)
|
180
|
+
if m[1] && m[1] =~ /[A-Za-z]/
|
181
|
+
return m[1].upcase
|
182
|
+
else
|
183
|
+
return nil
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def SipperUtil.recordify(msg)
|
188
|
+
unless msg.class <= Message
|
189
|
+
msg = msg.to_s
|
190
|
+
msg = msg.split(" ").join("_")
|
191
|
+
msg.extend(SipperUtil::Recordable)
|
192
|
+
end
|
193
|
+
return msg
|
194
|
+
end
|
195
|
+
|
196
|
+
# arg can be a symbol or a boolean value true/false
|
197
|
+
def SipperUtil.boolify(arg)
|
198
|
+
v = nil
|
199
|
+
if arg.is_a? Symbol
|
200
|
+
v = SipperUtil::BOOL_MAP[arg]
|
201
|
+
else
|
202
|
+
v = arg
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
# Takes a hash and populates the
|
208
|
+
# instance variables of the name as keys and value as hash values
|
209
|
+
# eg. hash = {:b=>2, :a=>1} results in the population of the
|
210
|
+
# instance variables "b" and "a" to 2 and 1 respectively in the
|
211
|
+
# object obj.
|
212
|
+
def SipperUtil.hash_to_iv(h, obj)
|
213
|
+
h.each_pair {|k,v| obj.send("#{k}=", v) }
|
214
|
+
end
|
215
|
+
|
216
|
+
# take the expectaion string like "< INVITE, > 100 {2,}, > 200" and
|
217
|
+
# returns "< INVITE% > 100 {2,}% > 200". Such that it can be split
|
218
|
+
# without any ambiguity.
|
219
|
+
def SipperUtil.make_expectation_parsable(str)
|
220
|
+
ss = StringScanner.new(str)
|
221
|
+
ns = ""
|
222
|
+
while (c = ss.getch)
|
223
|
+
if c == "{"
|
224
|
+
in_angle = true
|
225
|
+
elsif c == "}"
|
226
|
+
in_angle = false
|
227
|
+
elsif c == ","
|
228
|
+
c = "%" unless in_angle
|
229
|
+
end
|
230
|
+
ns << c
|
231
|
+
end
|
232
|
+
return ns
|
233
|
+
end
|
234
|
+
|
235
|
+
# Takes a string or a primitive array and prints it in the standard array
|
236
|
+
# form and returns a string that is properly formatted ruby style array code
|
237
|
+
# eg. ["a", "b", "c"], with elements as strings.
|
238
|
+
def SipperUtil.print_arr arr
|
239
|
+
s = "["
|
240
|
+
arr.each_with_index do |x,i|
|
241
|
+
s += "'" + x.to_s + "'"
|
242
|
+
s += "," unless i == arr.length-1
|
243
|
+
end
|
244
|
+
s += "]"
|
245
|
+
return s
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
def SipperUtil.load_yaml(path)
|
250
|
+
File.open(path) {|yf| YAML::load(yf)}
|
251
|
+
end
|
252
|
+
|
253
|
+
# Formats a SipperMedia command according to the SM protocol
|
254
|
+
def SipperUtil.formatted_media_command(str)
|
255
|
+
sprintf("%s%s", [str.length+1].pack("N"), str)
|
256
|
+
end
|
257
|
+
|
258
|
+
def SipperUtil.print_stack_trace
|
259
|
+
begin; raise; rescue => e; puts e.backtrace.join("\n"); end;
|
260
|
+
end
|
261
|
+
|
262
|
+
module Recordable
|
263
|
+
def p_session_record
|
264
|
+
'msg-info'
|
265
|
+
end
|
266
|
+
|
267
|
+
def call_id
|
268
|
+
'precallid'
|
269
|
+
end
|
270
|
+
end # module Recordable
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
# Wraps every method, except "name" because that is used to verify
|
276
|
+
# where the method is actually invoked.
|
277
|
+
module WrapExtender
|
278
|
+
|
279
|
+
def WrapExtender.extended(xtendee)
|
280
|
+
xtendee.class.instance_methods(false).each do |m|
|
281
|
+
WrapExtender.wrap_method(xtendee.class, m) unless m.to_s == "name"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def WrapExtender.wrap_method(klass, meth)
|
286
|
+
klass.class_eval do
|
287
|
+
alias_method "old_#{meth}", "#{meth}"
|
288
|
+
define_method(meth) do |*args|
|
289
|
+
["#{klass.name}", self.send("old_#{meth}",*args)]
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
def WrapExtender.last_class ret_val
|
295
|
+
if ret_val[1].is_a? Array
|
296
|
+
WrapExtender.last_class ret_val[1]
|
297
|
+
else
|
298
|
+
ret_val[0]
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
end #WrapExtender
|
303
|
+
|
304
|
+
|
305
|
+
end
|