From af21d33a75e856e875f170498ea702b7e9d2e19c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 6 May 2013 14:23:55 +0200 Subject: start_dtmf only if out-of-band DTMF is absend in SDP description --- misc/freeswitch/scripts/dialplan/sip_call.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/sip_call.lua') diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 0cde601..f401c5c 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -233,11 +233,19 @@ function SipCall.fork(self, destinations, arg ) end if arg.detect_dtmf_after_bridge_caller and self.caller.auth_account then - session:execute('start_dtmf'); + if not string.match(self.caller:to_s('switch_r_sdp'), '101 telephone%-event') then + self.log:notice('FORK A_LEG inband dtmf detection - channel_uuid: ', session:get_uuid()); + session:execute('start_dtmf'); + end end + if arg.detect_dtmf_after_bridge_callee and destination.type == 'sipaccount' then - session_callee:execute('start_dtmf'); + if not string.match(tostring(session_callee:getVariable('switch_r_sdp')), '101 telephone%-event') then + self.log:notice('FORK B_LEG inband dtmf detection - channel_uuid: ', session_callee:get_uuid()); + session_callee:execute('start_dtmf'); + end end + if arg.bypass_media_network then local callee_uuid = session_callee:get_uuid(); -- cgit v1.2.3 From 9a34bfecca1bb3d6da4af4faa4e8f8c3cf13b153 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 11 Jun 2013 14:55:22 +0200 Subject: privacy and cid_type options added --- misc/freeswitch/scripts/dialplan/sip_call.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'misc/freeswitch/scripts/dialplan/sip_call.lua') diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index f401c5c..66cba0e 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -96,6 +96,18 @@ function SipCall.fork(self, destinations, arg ) table.insert(origination_variables, 'ignore_display_updates=true'); end + local origination_privacy = ''; + + if self.caller.clir then + origination_privacy = 'hide_name:hide_number'; + end + + if self.caller.account then + origination_privacy = origination_privacy .. ':screen'; + end + + table.insert(origination_variables, 'origination_privacy=' .. origination_privacy); + if not destination.node_local or destination.type == 'node' then require 'common.node' local node = nil; @@ -168,6 +180,9 @@ function SipCall.fork(self, destinations, arg ) if destination.caller_id_name then table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'"); end + if gateway.settings.sip_cid_type then + table.insert(origination_variables, "sip_cid_type='" .. gateway.settings.sip_cid_type .. "'"); + end if destination.channel_variables then for key, value in pairs(destination.channel_variables) do table.insert(origination_variables, tostring(key) .. "='" .. tostring(value) .. "'"); -- cgit v1.2.3 From 8f05b452f8d57e87fa8927b0960a17aa386c0864 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 12 Jun 2013 09:20:37 +0200 Subject: caller_id and privacy --- misc/freeswitch/scripts/dialplan/sip_call.lua | 60 ++++++++++++++++++--------- 1 file changed, 40 insertions(+), 20 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/sip_call.lua') diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 66cba0e..c8e40fc 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -96,18 +96,6 @@ function SipCall.fork(self, destinations, arg ) table.insert(origination_variables, 'ignore_display_updates=true'); end - local origination_privacy = ''; - - if self.caller.clir then - origination_privacy = 'hide_name:hide_number'; - end - - if self.caller.account then - origination_privacy = origination_privacy .. ':screen'; - end - - table.insert(origination_variables, 'origination_privacy=' .. origination_privacy); - if not destination.node_local or destination.type == 'node' then require 'common.node' local node = nil; @@ -124,6 +112,7 @@ function SipCall.fork(self, destinations, arg ) table.insert(origination_variables, 'sip_h_X-GS_auth_account_type=' .. tostring(self.caller.auth_account_type)); table.insert(origination_variables, 'sip_h_X-GS_auth_account_uuid=' .. tostring(self.caller.auth_account_uuid)); table.insert(origination_variables, 'sip_h_X-GS_loop_count=' .. tostring(self.caller.loop_count)); + table.insert(origination_variables, 'sip_h_X-GS_clir=' .. tostring(self.caller.clir)); table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/gateway/' .. node.record.name .. '/' .. destination.number); end elseif destination.type == 'sipaccount' then @@ -158,6 +147,11 @@ function SipCall.fork(self, destinations, arg ) table.insert(origination_variables, "gs_auth_account_uuid='" .. common.str.to_s(self.caller.auth_account.uuid) .. "'"); end + if self.caller.clir then + table.insert(origination_variables, "origination_caller_id_number='anonymous'"); + table.insert(origination_variables, "origination_caller_id_name='" .. ( self.caller.anonymous_name or 'Anonymous') .. "'"); + end + table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/' .. sip_account.record.profile_name .. '/' .. sip_account.record.auth_name .. '%' .. sip_account.record.sip_host); if destination.pickup_groups and #destination.pickup_groups > 0 then for key=1, #destination.pickup_groups do @@ -174,15 +168,41 @@ function SipCall.fork(self, destinations, arg ) local gateway = common.gateway.Gateway:new{ log = self.log, database = self.database}:find_by_id(destination.id); if gateway and gateway.outbound then - if destination.caller_id_number then - table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'"); - end - if destination.caller_id_name then - table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'"); - end - if gateway.settings.sip_cid_type then - table.insert(origination_variables, "sip_cid_type='" .. gateway.settings.sip_cid_type .. "'"); + local caller_id_type = tostring(gateway.settings.caller_id_type); + + if caller_id_type == 'pid' or caller_id_type == '' or caller_id_type == 'nil' then + local identity = '"' .. (destination.caller_id_name or self.caller.caller_id_name) .. '" '; + + local account_uuid = common.array.try(self.caller, 'account.uuid'); + local auth_account_uuid = common.array.try(self.caller, 'auth_account.uuid'); + + if account_uuid and auth_account_uuid and account_uuid == auth_account_uuid then + table.insert(origination_variables, "sip_h_P-Asserted-Identity='" .. identity .. "'"); + else + table.insert(origination_variables, "sip_h_P-Preferred-Identity='" .. identity .. "'"); + end + + if self.caller.clir then + table.insert(origination_variables, "origination_caller_id_number='anonymous'"); + table.insert(origination_variables, "origination_caller_id_name='" .. ( self.caller.anonymous_name or 'Anonymous') .. "'"); + table.insert(origination_variables, "sip_h_P-Privacy='id'"); + else + if destination.caller_id_number then + table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'"); + end + if destination.caller_id_name then + table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'"); + end + end + else + if destination.caller_id_number then + table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'"); + end + if destination.caller_id_name then + table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'"); + end end + if destination.channel_variables then for key, value in pairs(destination.channel_variables) do table.insert(origination_variables, tostring(key) .. "='" .. tostring(value) .. "'"); -- cgit v1.2.3 From db8867ef5779e40b84da50870ddc6ecf2e52ac10 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 12 Jun 2013 13:57:29 +0200 Subject: gateway dependent caller_id handling --- misc/freeswitch/scripts/dialplan/sip_call.lua | 54 ++++++++++++++++++--------- 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/sip_call.lua') diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index c8e40fc..7e3cddc 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -90,7 +90,7 @@ function SipCall.fork(self, destinations, arg ) for index, destination in ipairs(destinations) do local origination_variables = { 'gs_fork_index=' .. index } - self.log:info('FORK ', index, '/', #destinations, ' - ', destination.type, '=', destination.id, '/', destination.uuid, '@', destination.node_id, ', number: ', destination.number, ', caller_id: "', destination.caller_id_name, '" <', destination.caller_id_number, '>'); + self.log:info('FORK ', index, '/', #destinations, ' - ', destination.type, '=', destination.id, '/', destination.uuid, '@', destination.node_id, ', number: ', destination.number); if not common.str.to_b(arg.update_callee_display) then table.insert(origination_variables, 'ignore_display_updates=true'); @@ -125,6 +125,8 @@ function SipCall.fork(self, destinations, arg ) else local call_waiting = self:call_waiting_busy(sip_account); if not call_waiting then + local caller_id_number = destination.caller_id_number or self.caller.caller_id_number; + local caller_id_name = destination.caller_id_name or self.caller.caller_id_name; destinations[index].numbers = sip_account:phone_numbers(); if not arg.callee_id_name then @@ -148,10 +150,15 @@ function SipCall.fork(self, destinations, arg ) end if self.caller.clir then - table.insert(origination_variables, "origination_caller_id_number='anonymous'"); - table.insert(origination_variables, "origination_caller_id_name='" .. ( self.caller.anonymous_name or 'Anonymous') .. "'"); + caller_id_number = self.caller.anonymous_number or 'anonymous'; + caller_id_name = self.caller.anonymous_name or 'Anonymous'; + table.insert(origination_variables, "origination_caller_id_number='" .. caller_id_number .. "'"); + table.insert(origination_variables, "origination_caller_id_name='" .. caller_id_name .. "'"); + table.insert(origination_variables, "sip_h_Privacy='id'"); end + self.log:info('FORK ', index, '/', #destinations, ' - caller_id: "', caller_id_name, '" <', caller_id_number, '>, privacy: ', self.caller.clir); + table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/' .. sip_account.record.profile_name .. '/' .. sip_account.record.auth_name .. '%' .. sip_account.record.sip_host); if destination.pickup_groups and #destination.pickup_groups > 0 then for key=1, #destination.pickup_groups do @@ -168,24 +175,25 @@ function SipCall.fork(self, destinations, arg ) local gateway = common.gateway.Gateway:new{ log = self.log, database = self.database}:find_by_id(destination.id); if gateway and gateway.outbound then - local caller_id_type = tostring(gateway.settings.caller_id_type); - - if caller_id_type == 'pid' or caller_id_type == '' or caller_id_type == 'nil' then - local identity = '"' .. (destination.caller_id_name or self.caller.caller_id_name) .. '" '; - - local account_uuid = common.array.try(self.caller, 'account.uuid'); - local auth_account_uuid = common.array.try(self.caller, 'auth_account.uuid'); + local asserted_identity = tostring(gateway.settings.asserted_identity); + local asserted_identity_clir = tostring(gateway.settings.asserted_identity); + local caller_id_number = destination.caller_id_number or self.caller.caller_id_number; + local caller_id_name = destination.caller_id_name or self.caller.caller_id_name; + local from_uri = common.array.expand_variables(gateway.settings.from, destination, self.caller, { gateway = gateway }); - if account_uuid and auth_account_uuid and account_uuid == auth_account_uuid then - table.insert(origination_variables, "sip_h_P-Asserted-Identity='" .. identity .. "'"); - else - table.insert(origination_variables, "sip_h_P-Preferred-Identity='" .. identity .. "'"); - end + self.log:devel('DESTINATION: ', destination); + if gateway.settings.asserted_identity then + local identity = common.array.expand_variables(gateway.settings.asserted_identity, destination, self.caller, { gateway = gateway }) + if self.caller.clir then - table.insert(origination_variables, "origination_caller_id_number='anonymous'"); - table.insert(origination_variables, "origination_caller_id_name='" .. ( self.caller.anonymous_name or 'Anonymous') .. "'"); - table.insert(origination_variables, "sip_h_P-Privacy='id'"); + caller_id_number = self.caller.anonymous_number or 'anonymous'; + caller_id_name = self.caller.anonymous_name or 'Anonymous'; + from_uri = common.array.expand_variables(gateway.settings.from_clir, destination, self.caller, { gateway = gateway }) or from_uri; + identity = common.array.expand_variables(gateway.settings.asserted_identity_clir, destination, self.caller, { gateway = gateway }) or identity; + table.insert(origination_variables, "origination_caller_id_number='" .. caller_id_number .. "'"); + table.insert(origination_variables, "origination_caller_id_name='" .. caller_id_name .. "'"); + table.insert(origination_variables, "sip_h_Privacy='id'"); else if destination.caller_id_number then table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'"); @@ -194,6 +202,16 @@ function SipCall.fork(self, destinations, arg ) table.insert(origination_variables, "origination_caller_id_name='" .. destination.caller_id_name .. "'"); end end + + if from_uri then + table.insert(origination_variables, "sip_from_uri='" .. from_uri .. "'"); + end + + if identity then + table.insert(origination_variables, "sip_h_P-Asserted-Identity='" .. identity .. "'"); + end + + self.log:info('FORK ', index, '/', #destinations, ' - from: ', from_uri, ', identity: ', identity, ', privacy: ', self.caller.clir); else if destination.caller_id_number then table.insert(origination_variables, "origination_caller_id_number='" .. destination.caller_id_number .. "'"); -- cgit v1.2.3 From d8dce422831675d0aca7b9a640b20bb5a5e947ab Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 12 Jun 2013 13:59:43 +0200 Subject: log line removed --- misc/freeswitch/scripts/dialplan/sip_call.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/sip_call.lua') diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 7e3cddc..256508a 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -181,8 +181,6 @@ function SipCall.fork(self, destinations, arg ) local caller_id_name = destination.caller_id_name or self.caller.caller_id_name; local from_uri = common.array.expand_variables(gateway.settings.from, destination, self.caller, { gateway = gateway }); - self.log:devel('DESTINATION: ', destination); - if gateway.settings.asserted_identity then local identity = common.array.expand_variables(gateway.settings.asserted_identity, destination, self.caller, { gateway = gateway }) -- cgit v1.2.3 From 29eb5c09076e2966224d7653146ea06f066481b0 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 12 Jun 2013 18:27:14 +0200 Subject: settings can be nil --- misc/freeswitch/scripts/dialplan/sip_call.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/sip_call.lua') diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua index 256508a..1966a41 100644 --- a/misc/freeswitch/scripts/dialplan/sip_call.lua +++ b/misc/freeswitch/scripts/dialplan/sip_call.lua @@ -179,16 +179,16 @@ function SipCall.fork(self, destinations, arg ) local asserted_identity_clir = tostring(gateway.settings.asserted_identity); local caller_id_number = destination.caller_id_number or self.caller.caller_id_number; local caller_id_name = destination.caller_id_name or self.caller.caller_id_name; - local from_uri = common.array.expand_variables(gateway.settings.from, destination, self.caller, { gateway = gateway }); + local from_uri = common.array.expand_variables(gateway.settings.from or '', destination, self.caller, { gateway = gateway }); if gateway.settings.asserted_identity then - local identity = common.array.expand_variables(gateway.settings.asserted_identity, destination, self.caller, { gateway = gateway }) + local identity = common.array.expand_variables(gateway.settings.asserted_identity or '', destination, self.caller, { gateway = gateway }) if self.caller.clir then caller_id_number = self.caller.anonymous_number or 'anonymous'; caller_id_name = self.caller.anonymous_name or 'Anonymous'; - from_uri = common.array.expand_variables(gateway.settings.from_clir, destination, self.caller, { gateway = gateway }) or from_uri; - identity = common.array.expand_variables(gateway.settings.asserted_identity_clir, destination, self.caller, { gateway = gateway }) or identity; + from_uri = common.array.expand_variables(gateway.settings.from_clir or '', destination, self.caller, { gateway = gateway }) or from_uri; + identity = common.array.expand_variables(gateway.settings.asserted_identity_clir or '', destination, self.caller, { gateway = gateway }) or identity; table.insert(origination_variables, "origination_caller_id_number='" .. caller_id_number .. "'"); table.insert(origination_variables, "origination_caller_id_name='" .. caller_id_name .. "'"); table.insert(origination_variables, "sip_h_Privacy='id'"); -- cgit v1.2.3