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,230 @@
|
|
1
|
+
|
2
|
+
require 'transaction/Nict_sm'
|
3
|
+
require 'transaction/transaction'
|
4
|
+
require 'transaction/state_machine_wrapper'
|
5
|
+
require 'util/timer/sip_timer_helper'
|
6
|
+
require 'sip_logger'
|
7
|
+
require 'util/locator'
|
8
|
+
require 'ruby_ext/object'
|
9
|
+
require 'request'
|
10
|
+
require 'util/sipper_util'
|
11
|
+
|
12
|
+
module SIP
|
13
|
+
module Transaction
|
14
|
+
class NonInviteClientTransaction < SIP::Transaction::BaseTransaction
|
15
|
+
include SipLogger
|
16
|
+
|
17
|
+
# to be used for accessing msg for printing/recording
|
18
|
+
attr_accessor :msg_sent, :cancel_ctxn
|
19
|
+
|
20
|
+
# The transport to use, transport flags, remote ip and port
|
21
|
+
# the block is to be used to override the T1, T2, even TimerA etc. timer value.
|
22
|
+
# The block can for example have { self.t1 = 200; self.te=100 } to override the
|
23
|
+
# T1, E on a transaction by transcation basis, otherwise the default is
|
24
|
+
# taken from SipperConfigurator or SIP::Transaction::BaseTransaction::T1
|
25
|
+
# in that order.
|
26
|
+
# Usage: TU creates transaction and starts invoking "Invocation Action"
|
27
|
+
# methods. Also for responses received, checks whether to consume them
|
28
|
+
# or not based on consume? method return value.
|
29
|
+
# There are four call backs into TU from NICT and they are notification on
|
30
|
+
# transport error and transaction timeout.
|
31
|
+
# There are 4 TU callbacks.
|
32
|
+
# (a) transaction_transport_err() gets called should NICT get a transport failure
|
33
|
+
# (b) transaction_timeout() gets called on timeout of transaction
|
34
|
+
# (c) transaction_transaction_cleanup() gets called on transaction termination.
|
35
|
+
# (d) transaction_wrong_state() if the transaction transition is tried in a wrong state
|
36
|
+
# i.e a message is either received or being tried to send out in a state where it is
|
37
|
+
# illegal to do so.
|
38
|
+
def initialize(tu, branch_id, txn_handler, transport, tp_flags, &block)
|
39
|
+
@transaction_name = :Nict # need to have this name defined for every transaction
|
40
|
+
@tu = tu
|
41
|
+
@branch_id = branch_id
|
42
|
+
@transport = transport
|
43
|
+
@txn_handler = txn_handler
|
44
|
+
@tp_flags = tp_flags
|
45
|
+
self.tk = 0 if @transport.reliable? # one line later it can be overidden by arguments.
|
46
|
+
super(&block) # override timers
|
47
|
+
#@sm = Ict_sm.new(self)
|
48
|
+
SIP::Transaction::StateMachineWrapper.bootstrap_machine(self, Nict_sm)
|
49
|
+
@sm = SIP::Transaction::StateMachineWrapper.new(self, @txn_handler, Nict_sm)
|
50
|
+
logd("Created the Non Invite Client Transcation with #{@transport}")
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# Need to handle this after the transition has happened and not in the
|
55
|
+
# _send_to_transport exception handler because state transition from
|
56
|
+
# within a transition is not possible in smc
|
57
|
+
def _check_transport_err
|
58
|
+
@sm.transport_err if @transport_err
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
#--- SM Invocation Actions <start>---------
|
63
|
+
|
64
|
+
#------------------
|
65
|
+
# The two methods txn_send and txn_received are two general purpose methods
|
66
|
+
# that will be called by the TU as against the transcation type specific
|
67
|
+
# methods defined on each type of transaction.
|
68
|
+
#
|
69
|
+
# NICT sends only Non-INVITEs from TU
|
70
|
+
def txn_send(msg)
|
71
|
+
@message = msg # the msg is accessed from transaction
|
72
|
+
raise "NICT can only send Non INVITEs" unless (msg.is_request? && msg.method!="INVITE")
|
73
|
+
self._send_request(msg)
|
74
|
+
end
|
75
|
+
|
76
|
+
# The NICT receives responses (provisional and final)
|
77
|
+
def txn_received(msg)
|
78
|
+
@message = msg
|
79
|
+
raise "NICT can only receive responses" unless msg.is_response?
|
80
|
+
msg.set_request(@request)
|
81
|
+
case msg.code
|
82
|
+
when 100..199
|
83
|
+
_provisional_received
|
84
|
+
when 200..699
|
85
|
+
_final_received(msg)
|
86
|
+
else
|
87
|
+
raise "NICT cannot deal with response #{msg}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
#------------------
|
91
|
+
|
92
|
+
# These method is to be invoked by the TU to send the non-invite
|
93
|
+
# The state machine drives the whole interaction by calling the
|
94
|
+
# callbacks.
|
95
|
+
|
96
|
+
def _send_request(req)
|
97
|
+
@request = req
|
98
|
+
@ok_to_run_timerE = true unless @transport.reliable?
|
99
|
+
@ok_to_run_timerF = true
|
100
|
+
@sm.request
|
101
|
+
_check_transport_err
|
102
|
+
rescue Statemap::TransitionUndefinedException => e
|
103
|
+
loge "Cannot send request in #{self.state} state for #{self}"
|
104
|
+
@tu.transaction_wrong_state(self) if @tu
|
105
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
def _provisional_received
|
110
|
+
@sm.provisional
|
111
|
+
_check_transport_err
|
112
|
+
rescue Statemap::TransitionUndefinedException => e
|
113
|
+
loge "Received a provisional in #{self.state} state for #{self}"
|
114
|
+
@tu.transaction_wrong_state(self) if @tu
|
115
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
def _final_received(res)
|
121
|
+
@response = res
|
122
|
+
@sm.final
|
123
|
+
_check_transport_err
|
124
|
+
rescue Statemap::TransitionUndefinedException => e
|
125
|
+
loge "Received a final response in #{self.state} state for #{self}"
|
126
|
+
@tu.transaction_wrong_state(self) if @tu
|
127
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
128
|
+
end
|
129
|
+
|
130
|
+
#--- SM Invocation Actions <end>---------
|
131
|
+
|
132
|
+
|
133
|
+
#------ Timer callback------
|
134
|
+
def on_timer_expiration(timer_task)
|
135
|
+
super # check for invalidation
|
136
|
+
case timer_task.tid
|
137
|
+
when :te
|
138
|
+
@sm.timer_E(timer_task.duration) if @ok_to_run_timerE
|
139
|
+
_check_transport_err
|
140
|
+
when :tf
|
141
|
+
@sm.timer_F if @ok_to_run_timerF
|
142
|
+
when :tk
|
143
|
+
@sm.timer_K
|
144
|
+
end
|
145
|
+
rescue Statemap::TransitionUndefinedException => e
|
146
|
+
loge "Timer #{timer_task.tid} got fired for #{self}"
|
147
|
+
@tu.transaction_wrong_state(self) if @tu
|
148
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
149
|
+
end
|
150
|
+
#----------------------------
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
#------SM Callbacks <start>--------
|
155
|
+
|
156
|
+
def __send_request
|
157
|
+
logd "Sending Non-INVITE from the Nict #{self}"
|
158
|
+
_send_to_transport(@request)
|
159
|
+
end
|
160
|
+
|
161
|
+
def __start_E
|
162
|
+
return unless @ok_to_run_timerE
|
163
|
+
task = SIP::Locator[:Sth].schedule_for(self, :te, nil, :transaction, self.te)
|
164
|
+
logd("Starting Timer E #{task} from Nict #{self}")
|
165
|
+
end
|
166
|
+
|
167
|
+
def __start_F
|
168
|
+
return unless @ok_to_run_timerF
|
169
|
+
task = SIP::Locator[:Sth].schedule_for(self, :tf, nil, :transaction, self.tf)
|
170
|
+
logd("Starting Timer F #{task} from Nict #{self}")
|
171
|
+
end
|
172
|
+
|
173
|
+
def __start_K
|
174
|
+
task = SIP::Locator[:Sth].schedule_for(self, :tk, nil, :transaction, self.tk)
|
175
|
+
logd("Starting Timer K #{task} from Nict #{self}")
|
176
|
+
end
|
177
|
+
|
178
|
+
def __reset_E(t=self.t2)
|
179
|
+
if t == self.t2
|
180
|
+
self.te = self.t2
|
181
|
+
else
|
182
|
+
self.te = [2*t, self.t2].min
|
183
|
+
end
|
184
|
+
__start_E
|
185
|
+
end
|
186
|
+
|
187
|
+
def __timeout
|
188
|
+
logw("Transaction timeout happened")
|
189
|
+
@txn_handler.timeout(self) if @txn_handler && @txn_handler.respond_to?(:timeout)
|
190
|
+
@tu.transaction_timeout(self) if @tu
|
191
|
+
end
|
192
|
+
|
193
|
+
def __cancel_E
|
194
|
+
logd "canceling timer E"
|
195
|
+
@ok_to_run_timerE = false
|
196
|
+
end
|
197
|
+
|
198
|
+
def __cancel_F
|
199
|
+
logd "canceling timer F"
|
200
|
+
@ok_to_run_timerF = false
|
201
|
+
end
|
202
|
+
|
203
|
+
def __consume_msg(b)
|
204
|
+
@consume = b
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
def __transport_err
|
209
|
+
loge "A transport error was encountered for #{self} calling TU"
|
210
|
+
@txn_handler.transport_err(self) if @txn_handler && @txn_handler.respond_to?(:transport_err)
|
211
|
+
@tu.transaction_transport_err(self) if @tu
|
212
|
+
end
|
213
|
+
|
214
|
+
def __cleanup
|
215
|
+
logd "Cleanup called for #{self}"
|
216
|
+
@tu.transaction_cleanup(self) if @tu
|
217
|
+
@txn_handler.cleanup(self) if @txn_handler && @txn_handler.respond_to?(:cleanup)
|
218
|
+
end
|
219
|
+
#------SM Callbacks <end>--------
|
220
|
+
|
221
|
+
# mask callbacks defined for SM (see Transaction.rb)
|
222
|
+
mask_callbacks
|
223
|
+
|
224
|
+
private :_send_to_transport, :_check_transport_err
|
225
|
+
protected :_send_request, :_provisional_received,
|
226
|
+
:_final_received
|
227
|
+
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
|
2
|
+
require 'transaction/Nist_sm'
|
3
|
+
require 'transaction/transaction'
|
4
|
+
require 'transaction/state_machine_wrapper'
|
5
|
+
require 'util/timer/sip_timer_helper'
|
6
|
+
require 'sip_logger'
|
7
|
+
require 'util/locator'
|
8
|
+
require 'ruby_ext/object'
|
9
|
+
require 'message'
|
10
|
+
require 'util/sipper_util'
|
11
|
+
|
12
|
+
module SIP
|
13
|
+
module Transaction
|
14
|
+
class NonInviteServerTransaction < SIP::Transaction::BaseTransaction
|
15
|
+
include SipLogger
|
16
|
+
include SipperUtil
|
17
|
+
|
18
|
+
# msg_sent is to be used for accessing msg for printing/recording. Here cancel_stxn is the
|
19
|
+
# CANCEL transaction, though unlikely but still possible for a NIST.
|
20
|
+
# transaction_being_canceled is the Stx that is being canceled if this NIST is
|
21
|
+
# actually a CANCEL transaction itself. This will usually be set to an IST for
|
22
|
+
# CANCEL transactions. For all other non CANCEL transactions this will be nil.
|
23
|
+
# ok_to_send_481_to_cancel is a boolean that will be set from session when the
|
24
|
+
# conditions are there for 481/CANCEL to be sent. This will be the case when no STx is
|
25
|
+
# found on receiving CANCEL and both IST and NIST are in use.
|
26
|
+
attr_accessor :msg_sent, :cancel_stxn, :transaction_being_canceled, :ok_to_send_481_to_cancel
|
27
|
+
|
28
|
+
# The transport to use, transport flags, remote ip and port
|
29
|
+
# the block is to be used to override the T1 and TimerJ etc. timer value.
|
30
|
+
# The block can for example have { self.t1 = 200; self.tj=100 } to override the
|
31
|
+
# T1, J on a transaction by transcation basis, otherwise the default is
|
32
|
+
# taken from SipperConfigurator or SIP::Transaction::BaseTransaction::T1
|
33
|
+
# in that order.
|
34
|
+
# Usage: TU creates transaction and starts invoking "Invocation Action"
|
35
|
+
# methods. Also for requests received, checks whether to consume them
|
36
|
+
# or not based on consume? method return value.
|
37
|
+
# There are three call backs into TU from IST and they are notification on
|
38
|
+
# transport error and transaction timeout.
|
39
|
+
# There are 5 TU callbacks.
|
40
|
+
# (a) transaction_transport_err() gets called should IST get a transport failure
|
41
|
+
# (b) transaction_timeout() gets called on timeout of transaction
|
42
|
+
# (c) transaction_transaction_cleanup() gets called on transaction termination.
|
43
|
+
# (d) transaction_wrong_state() if the transaction transition is tried in a wrong state
|
44
|
+
# i.e a message is either received or being tried to send out in a state where it is
|
45
|
+
# illegal to do so.
|
46
|
+
# (e) transaction_record() record the message from the transaction.
|
47
|
+
#
|
48
|
+
def initialize(tu, branch_id, txn_handler, transport, tp_flags, &block)
|
49
|
+
@transaction_name = :Nist # need to have this name defined for every transaction
|
50
|
+
@tu = tu
|
51
|
+
@branch_id = branch_id
|
52
|
+
@transport = transport
|
53
|
+
@txn_handler = txn_handler
|
54
|
+
@tp_flags = tp_flags
|
55
|
+
self.tj = 0 if @transport.reliable? # one line later it can be overidden by arguments.
|
56
|
+
super(&block) # override timers
|
57
|
+
SIP::Transaction::StateMachineWrapper.bootstrap_machine(self, Nist_sm)
|
58
|
+
@sm = SIP::Transaction::StateMachineWrapper.new(self, @txn_handler, Nist_sm)
|
59
|
+
logd("Created the Non Invite Server Transcation with #{@transport}")
|
60
|
+
end
|
61
|
+
|
62
|
+
def cancel_received(cancel, cstxn)
|
63
|
+
@cancel_stxn = cstxn
|
64
|
+
_cancel_received(cancel)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# Need to handle this after the transition has happened and not in the
|
69
|
+
# _send_to_transport exception handler because state transition from
|
70
|
+
# within a transition is not possible in smc
|
71
|
+
def _check_transport_err
|
72
|
+
@sm.transport_err if @transport_err
|
73
|
+
end
|
74
|
+
|
75
|
+
# RFC 3261 section 9.2 4th para last line
|
76
|
+
# A CANCEL request has no impact on the processing
|
77
|
+
# of transactions with any other method (other than INVITE)
|
78
|
+
# defined in this specification.
|
79
|
+
#
|
80
|
+
def _cancel_received(msg)
|
81
|
+
logd "Received a CANCEL in #{self.state} state for #{self} doing nothing"
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
#--- SM Invocation Actions <start>---------
|
86
|
+
|
87
|
+
#------------------
|
88
|
+
# The two methods txn_send and txn_received are two general purpose methods
|
89
|
+
# that will be called by the TU as against the transcation type specific
|
90
|
+
# methods defined on each type of transaction.
|
91
|
+
#
|
92
|
+
# NIST sends only responses from TU
|
93
|
+
def txn_send(msg)
|
94
|
+
@message = msg # the msg is accessed from transaction
|
95
|
+
raise "NIST can only send respones" unless msg.is_response?
|
96
|
+
case msg.code
|
97
|
+
when 100..199
|
98
|
+
_send_provisional(msg)
|
99
|
+
when 200..699
|
100
|
+
_send_final(msg)
|
101
|
+
else
|
102
|
+
raise "NIST cannot deal with this response #{msg}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# The NIST receives requests other than INVITE and ACK only
|
107
|
+
def txn_received(msg)
|
108
|
+
@message = msg
|
109
|
+
raise "NIST can only receive requests" unless msg.is_request?
|
110
|
+
raise "NIST cannot deal with this request #{msg}" if msg.method == "INVITE" || msg.method == "ACK"
|
111
|
+
_request_received(msg)
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
#------------------
|
116
|
+
|
117
|
+
# These methods are to be invoked by the TU to send the responses
|
118
|
+
# The state machine drives the whole interaction by calling the
|
119
|
+
# callbacks.
|
120
|
+
|
121
|
+
def _send_provisional(msg)
|
122
|
+
@last_response_sent = msg
|
123
|
+
@sm.provisional(msg)
|
124
|
+
_check_transport_err
|
125
|
+
rescue Statemap::TransitionUndefinedException => e
|
126
|
+
loge "Cannot send provisional in #{self.state} state for #{self}"
|
127
|
+
@tu.transaction_wrong_state(self) if @tu
|
128
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
129
|
+
end
|
130
|
+
|
131
|
+
def _send_final(msg)
|
132
|
+
@last_response_sent = msg
|
133
|
+
@ok_to_run_timerJ = true unless @transport.reliable?
|
134
|
+
@sm.final(msg)
|
135
|
+
rescue Statemap::TransitionUndefinedException => e
|
136
|
+
loge "Cannot send final in #{self.state} state for #{self}"
|
137
|
+
@tu.transaction_wrong_state(self) if @tu
|
138
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
def _request_received(msg)
|
144
|
+
if msg.method == "CANCEL"
|
145
|
+
if self.transaction_being_canceled
|
146
|
+
logd("Received a CANCEL in NIST with associated ST, sending 200")
|
147
|
+
r = @tu.create_response(200, "OK", msg)
|
148
|
+
@sm.cancel_with_st(r)
|
149
|
+
elsif self.ok_to_send_481_to_cancel
|
150
|
+
logd("Received a CANCEL in NIST with NO associated ST, sending 481")
|
151
|
+
r = @tu.rejection_response_with(481, msg)
|
152
|
+
@sm.cancel_with_no_st(r)
|
153
|
+
else
|
154
|
+
@sm.request
|
155
|
+
end
|
156
|
+
else
|
157
|
+
@sm.request
|
158
|
+
end
|
159
|
+
_check_transport_err
|
160
|
+
rescue Statemap::TransitionUndefinedException => e
|
161
|
+
loge "Received a REQUEST in #{self.state} state for #{self}"
|
162
|
+
@tu.transaction_wrong_state(self) if @tu
|
163
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
164
|
+
end
|
165
|
+
|
166
|
+
#--- TU Invocation Actions <end>---------
|
167
|
+
|
168
|
+
|
169
|
+
#------ Timer callback------
|
170
|
+
def on_timer_expiration(timer_task)
|
171
|
+
super # check for invalidation
|
172
|
+
case timer_task.tid
|
173
|
+
when :tj
|
174
|
+
@sm.timer_J if @ok_to_run_timerJ
|
175
|
+
_check_transport_err
|
176
|
+
end
|
177
|
+
rescue Statemap::TransitionUndefinedException => e
|
178
|
+
loge "Timer #{timer_task.tid} got fired for #{self}"
|
179
|
+
@tu.transaction_wrong_state(self) if @tu
|
180
|
+
@txn_handler.wrong_state(self) if @txn_handler && @txn_handler.respond_to?(:wrong_state)
|
181
|
+
end
|
182
|
+
#----------------------------
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
#------SM Callbacks <start>--------
|
187
|
+
|
188
|
+
|
189
|
+
def __consume_msg(b)
|
190
|
+
@consume = b
|
191
|
+
end
|
192
|
+
|
193
|
+
def __transport_err
|
194
|
+
loge "A transport error was encountered for #{self} calling TU"
|
195
|
+
@tu.transaction_transport_err(self) if @tu
|
196
|
+
@txn_handler.transport_err(self) if @txn_handler && @txn_handler.respond_to?(:transport_err)
|
197
|
+
end
|
198
|
+
|
199
|
+
def __send_provisional_response(r)
|
200
|
+
logd "Sending the provisional response #{r.code} from Nist #{self}"
|
201
|
+
@last_sent_response = r
|
202
|
+
_send_to_transport(r)
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
def __send_last_response
|
207
|
+
if @last_sent_response
|
208
|
+
logd "Sending the last response #{@last_sent_response.code} from Ist #{self}"
|
209
|
+
_send_to_transport(@last_sent_response)
|
210
|
+
else
|
211
|
+
logw("No last response available, not sending anything from #{self}")
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
def __send_final_response(r)
|
217
|
+
logd "Sending a final response #{r.code} from Nist #{self}"
|
218
|
+
@last_sent_response = r
|
219
|
+
_send_to_transport(r)
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
def __start_J
|
224
|
+
return unless @ok_to_run_timerJ
|
225
|
+
task = SIP::Locator[:Sth].schedule_for(self, :tj, nil, :transaction, self.tj)
|
226
|
+
logd("Starting Timer J #{task} from Nist #{self}")
|
227
|
+
end
|
228
|
+
|
229
|
+
def __cancel_J
|
230
|
+
logd "canceling timer J"
|
231
|
+
@ok_to_run_timerJ = false
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
def __timeout
|
236
|
+
logw("Transaction timeout happened")
|
237
|
+
@tu.transaction_timeout(self) if @tu
|
238
|
+
@txn_handler.timeout(self) if @txn_handler && @txn_handler.respond_to?(:timeout)
|
239
|
+
end
|
240
|
+
|
241
|
+
def __wrong_state
|
242
|
+
log_and_raise "Cannot send response in wrong state #{self}"
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
def __cleanup
|
247
|
+
logd "Cleanup called for #{self}"
|
248
|
+
@tu.transaction_cleanup(self) if @tu
|
249
|
+
@txn_handler.cleanup(self) if @txn_handler && @txn_handler.respond_to?(:cleanup)
|
250
|
+
end
|
251
|
+
#------SM Callbacks <end>--------
|
252
|
+
|
253
|
+
# mask callbacks defined for SM (see Transaction.rb)
|
254
|
+
mask_callbacks
|
255
|
+
|
256
|
+
private :_send_to_transport, :_check_transport_err, :_send_final,
|
257
|
+
:_send_provisional, :_request_received
|
258
|
+
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
|