Adding user=phone to URI and headers

Go down

Adding user=phone to URI and headers Empty Adding user=phone to URI and headers

Post by Admin on Tue Jan 22, 2019 7:36 am

In some cases far ends wants to see user=phone on URI and headers. You can simply add this to your URI and headers with following;


  1. Create a new script named add_user_phone
    Adding user=phone to URI and headers Add_us10

  2. Copy following  script part and Save
    Code:
    #
    # Script version 1.0
    #
    # Version history:
    #  1.0  Initial version of this script
    #
    # This filter is used to add "user=phone" to call URI's

    #

    module AddUserPhone
      def init_add_user_phone(params)
      end

      def add_sip_header_param( call, field, param_level, value )
        call[ field ] = {} unless call[ field ].is_a? Hash
        call[ field ] ||= {} # Create a hash if not already present
        call[ field ][ param_level ] ||= "" # Create a string if not already present
        call[ field ][ param_level ] += ";" if call[ field ][ param_level  ] != "" # Append ; if already some parameters
        call[ field ][ param_level ] += value # Append the value
      end

      def add_user_phone(params)
        call = params[ :call ]

        # Add to SIP URI
        call[:request_uri_forward_enabled] = true
        if call[:request_uri] && !call[:request_uri].include?( "user=phone" )
         call[:request_uri] += ";user=phone"
        end

        add_sip_header_param( call, :calling_parameters,          :uri_param, "user=phone" ) # Add to From header
        add_sip_header_param( call, :called_parameters,           :uri_param, "user=phone" ) # Add to To header
        add_sip_header_param( call, :contact_parameters,          :uri_param, "user=phone" ) # Add to Contact header
        add_sip_header_param( call, :private_address_parameters,  :uri_param, "user=phone" ) # Add to P-Asserted-Identity
      add_sip_header_param( call, :redirecting_number_parameters, :uri_param, "user=phone") # Add to SIP Diversion
        # header
        # Remote-party-id -> Can't modify for now
        

        params
      end  
    end

  3. Select simple_routing_sbc script and add following script parts and Save
    Code:

    .
    .
    require 'add_user_phone'
    .
    .
    include AddUserPhone
    .
    .
    after_filter :method => :add_user_phone
    .
    .
    [*]Activate the configuration


Admin
Admin

Number of Messages : 245
Point : 652
Registration Date : 2017-11-27

http://freesbc.yetkinforum.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum