[Freeswitch-users] How to manipulate destination number beforerouting to PSTN GW

Ken Rice krice at freeswitch.org
Sat May 7 19:23:42 MSD 2011


His originatl expression should work fine since the + is not in the () in
his regex, however set_effective_destination number does not over write the
destination_number field you need to transfer the call to get
destination_number reset
Or use the ${effective_destination_number} as your field in the 9 to gw
extension


On 5/7/11 10:15 AM, "Madovsky" <infos at madovsky.org> wrote:

> use expression="(+)(\d)"
> and $2 as result
>>  
>> ----- Original Message -----
>>  
>> From:  fieldpeak <mailto:fieldpeak at gmail.com>
>>  
>> To: FreeSWITCH-users <mailto:FreeSWITCH-users at lists.freeswitch.org>
>>  
>> Sent: Saturday, May 07, 2011 11:04  AM
>>  
>> Subject: [Freeswitch-users] How to  manipulate destination number
>> beforerouting to PSTN GW
>>  
>> 
>>  
>> 
>> Gurus,
>>  
>> 
>>  
>> i met an issue for dial plan, it sounds easy but puzzled me  a few days not
>> fix it yet...i belive gurus here could help me...
>>  
>> 
>>  
>> i want to remove the + of destination number before routing  to PSTN GW, e.g.
>> when i dial +9123, i would like FS remove +, and then route  to the PSTN GW,
>> below is the dial plan and log,
>>  
>> See the log, FS did remove '+' of '+9123', but then when it  checks the rule
>> Œ9_to_GW¹, it still checks '+9123' (I expect it is '9123'),  and then failed.
>>  
>> Thanks.
>>  
>>  
>>  
>> Dial plan:
>>  
>> <extension name="remove_plus_of_dst_num"  continue="true">
>>  
>>     <condition field="destination_number" expression="^\+(\d+)$">
>>  
>>         <action application="set"  data="effective_destination_number=$1"/>
>>  
>>     </condition>
>>  
>> </extension>
>>  
>> Š...
>>  
>> <extension name="9_to_GW" >
>>  
>>     <condition field="destination_number" expression="^(9\d+)$">
>>  
>>         <action application="bridge"
>> data="sofia/internal/$1 at 192.168.200.101"/>
>>  
>>     </condition>
>>  
>> </extension>
>>  
>>  
>>  
>> Log:
>>  
>> freeswitch at mypc> 2011-05-07 22:48:05.717537 [DEBUG]  sofia.c:6488 IP
>> 192.168.200.201
>>  
>>  Approved by  acl "192.168.0.0/16[] <http://192.168.0.0/16[]> ". Access
>> Granted.
>>  
>> 2011-05-07 22:48:05.717537 [NOTICE] switch_channel.c:812  New Channel
>> sofia/inter
>>  
>> nal/+4001 at 192.168.200.100  [92568c57-ff7b-4dbc-b322-a9babf893e62]
>>  
>> 2011-05-07 22:48:05.719537 [DEBUG] sofia.c:4760 Channel
>> sofia/internal/+4001 at 192
>>  
>> .168.200.100 entering state [received][100]
>>  
>> 2011-05-07 22:48:05.719537 [DEBUG] sofia.c:4771 Remote  SDP:
>>  
>> v=0
>>  
>> o=AudiocodesGW 1062502113 1062501981 IN IP4  192.168.200.201
>>  
>> s=Phone-Call
>>  
>> c=IN IP4 192.168.200.201
>>  
>> t=0 0
>>  
>> m=audio 6060 RTP/AVP 8 0 96
>>  
>> a=rtpmap:8 PCMA/8000
>>  
>> a=rtpmap:0 PCMU/8000
>>  
>> a=rtpmap:96 telephone-event/8000
>>  
>> a=fmtp:96 0-15
>>  
>> a=ptime:20
>>  
>>  
>>  
>> 2011-05-07 22:48:05.719537 [DEBUG] sofia.c:4908
>> (sofia/internal/+4001 at 192.168.20
>>  
>> 0.100) State Change CS_NEW -> CS_INIT
>>  
>> 2011-05-07 22:48:05.719537 [DEBUG]  switch_core_session.c:1116 Send signal
>> sofia/
>>  
>> internal/+4001 at 192.168.200.100 [BREAK]
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_state_machine.c:325
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Running State  Change CS_INIT
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_state_machine.c:361
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State INIT
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG] mod_sofia.c:84
>> sofia/internal/+4001 at 192.168.2
>>  
>> 00.100 SOFIA INIT
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG] mod_sofia.c:124
>> (sofia/internal/+4001 at 192.168
>>  
>> .200.100) State Change CS_INIT -> CS_ROUTING
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_session.c:1116 Send signal
>> sofia/
>>  
>> internal/+4001 at 192.168.200.100 [BREAK]
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_state_machine.c:361
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State INIT going  to sleep
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_state_machine.c:325
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Running State  Change CS_ROUTING
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG] switch_channel.c:1668
>> (sofia/internal/+4001 at 1
>>  
>> 92.168.200.100) Callstate Change DOWN -> RINGING
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_state_machine.c:364
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State ROUTING
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG] mod_sofia.c:147
>> sofia/internal/+4001 at 192.168.
>>  
>> 200.100 SOFIA ROUTING
>>  
>> 2011-05-07 22:48:05.722537 [DEBUG]  switch_core_state_machine.c:77
>> sofia/internal
>>  
>> /+4001 at 192.168.200.100 Standard  ROUTING
>>  
>> 2011-05-07 22:48:05.722537 [INFO] mod_dialplan_xml.c:331  Processing +4001
>> <+4001
>>  
>>> >->+9123 in context default
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing  [default->unloop]
>> continu
>>  
>> e=false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (PASS)  [unloop]
>> ${unroll_lo
>>  
>> ops}(true) =~ /^true$/ break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (FAIL)  [unloop]
>> ${sip_loope
>>  
>> d_call}() =~ /^true$/ break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing
>> [default->remove_plus_of_
>>  
>> dst_num]  continue=true
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (PASS)
>> [remove_plus_of_dst_
>>  
>> num]  destination_number(+9123) =~ /^\+(\d+)$/ break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Action
>> set(destination_number=912
>>  
>> 3)
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing
>> [default->remove_plus_of_
>>  
>> src_num] continue=true
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (PASS)
>> [remove_plus_of_src_
>>  
>> num] caller_id_number(+4001) =~ /^\+(\d+)$/  break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Action
>> set(effective_caller_id_na
>>  
>> me=4001)
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Action
>> set(effective_caller_id_nu
>>  
>> mber=4001)
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing
>> [default->7_8_to_Lync] co
>>  
>> ntinue=false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (FAIL)  [7_8_to_Lync]
>> destin
>>  
>> ation_number(+9123) =~ /^([78]\d{3})$/ break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing  [default->9_to_GW]
>> contin
>>  
>> ue=false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (FAIL)  [9_to_GW]
>> destinatio
>>  
>> n_number(+9123) =~ /^(9\d+)$/  break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing  [default->1_to_IPP]
>> conti
>>  
>> nue=false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (FAIL)  [1_to_IPP]
>> destinati
>>  
>> on_number(+9123) =~ /^(1\d{3})$/ break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing  [default->DISA]
>> continue=
>>  
>> false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (FAIL)  [DISA]
>> destination_n
>>  
>> umber(+9123) =~ /^\*(3472)$/ break=on-false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 parsing  [default->Recordings]
>> con
>>  
>> tinue=false
>>  
>> Dialplan: sofia/internal/+4001 at 192.168.200.100 Regex (FAIL)  [Recordings]
>> destina
>>  
>> tion_number(+9123) =~ /^\*(732673)$/ break=on-false
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG]  switch_core_state_machine.c:119
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State Change  CS_ROUTING -> CS_EXECUTE
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG]  switch_core_session.c:1116 Send signal
>> sofia/
>>  
>> internal/+4001 at 192.168.200.100 [BREAK]
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG]  switch_core_state_machine.c:364
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State ROUTING  going to sleep
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG]  switch_core_state_machine.c:325
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Running State  Change CS_EXECUTE
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG]  switch_core_state_machine.c:371
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State EXECUTE
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG] mod_sofia.c:240
>> sofia/internal/+4001 at 192.168.
>>  
>> 200.100 SOFIA EXECUTE
>>  
>> 2011-05-07 22:48:05.727537 [DEBUG]  switch_core_state_machine.c:157
>> sofia/interna
>>  
>> l/+4001 at 192.168.200.100 Standard  EXECUTE
>>  
>> EXECUTE sofia/internal/+4001 at 192.168.200.100  set(destination_number=9123)
>>  
>> 2011-05-07 22:48:05.728537 [DEBUG] mod_dptools.c:1060
>> sofia/internal/+4001 at 192.1
>>  
>> 68.200.100 SET [destination_number]=[9123]
>>  
>> EXECUTE sofia/internal/+4001 at 192.168.200.100
>> set(effective_caller_id_name=4001)
>>  
>> 2011-05-07 22:48:05.728537 [DEBUG] mod_dptools.c:1060
>> sofia/internal/+4001 at 192.1
>>  
>> 68.200.100 SET [effective_caller_id_name]=[4001]
>>  
>> EXECUTE sofia/internal/+4001 at 192.168.200.100
>> set(effective_caller_id_number=4001
>>  
>> )
>>  
>> 2011-05-07 22:48:05.729537 [DEBUG] mod_dptools.c:1060
>> sofia/internal/+4001 at 192.1
>>  
>> 68.200.100 SET [effective_caller_id_number]=[4001]
>>  
>> 2011-05-07 22:48:05.729537 [NOTICE]  switch_core_state_machine.c:189
>> sofia/intern
>>  
>> al/+4001 at 192.168.200.100 has executed the  last dialplan instruction, hanging
>> up.
>>  
>>  
>>  
>> 2011-05-07 22:48:05.729537 [DEBUG] switch_channel.c:2563
>> (sofia/internal/+4001 at 1
>>  
>> 92.168.200.100) Callstate Change RINGING -> HANGUP
>>  
>> 2011-05-07 22:48:05.729537 [NOTICE]  switch_core_state_machine.c:191 Hangup
>> sofia
>>  
>> /internal/+4001 at 192.168.200.100 [CS_EXECUTE]  [NORMAL_CLEARING]
>>  
>> 2011-05-07 22:48:05.730538 [DEBUG] switch_channel.c:2579  Send signal
>> sofia/inter
>>  
>> nal/+4001 at 192.168.200.100 [KILL]
>>  
>> 2011-05-07 22:48:05.730538 [DEBUG]  switch_core_session.c:1116 Send signal
>> sofia/
>>  
>> internal/+4001 at 192.168.200.100 [BREAK]
>>  
>> 2011-05-07 22:48:05.730538 [DEBUG]  switch_core_state_machine.c:371
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State EXECUTE  going to sleep
>>  
>> 2011-05-07 22:48:05.730538 [DEBUG]  switch_core_state_machine.c:325
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Running State  Change CS_HANGUP
>>  
>> 2011-05-07 22:48:05.731538 [DEBUG]  switch_core_state_machine.c:565
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State HANGUP
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG] mod_sofia.c:457 Channel
>> sofia/internal/+4001@
>>  
>> 192.168.200.100 hanging up, cause: NORMAL_CLEARING
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG] mod_sofia.c:519  Responding to INVITE
>> with: 48
>>  
>> 0
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG]  switch_core_state_machine.c:46
>> sofia/internal
>>  
>> /+4001 at 192.168.200.100 Standard HANGUP,  cause: NORMAL_CLEARING
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG]  switch_core_state_machine.c:565
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State HANGUP  going to sleep
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG]  switch_core_state_machine.c:356
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State Change  CS_HANGUP -> CS_REPORTING
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG]  switch_core_session.c:1116 Send signal
>> sofia/
>>  
>> internal/+4001 at 192.168.200.100 [BREAK]
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG]  switch_core_state_machine.c:325
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Running State  Change CS_REPORTING
>>  
>> 2011-05-07 22:48:05.732538 [DEBUG]  switch_core_state_machine.c:625
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State  REPORTING
>>  
>> 2011-05-07 22:48:06.017554 [DEBUG]  switch_core_state_machine.c:53
>> sofia/internal
>>  
>> /+4001 at 192.168.200.100 Standard  REPORTING, cause: NORMAL_CLEARING
>>  
>> 2011-05-07 22:48:06.017554 [DEBUG]  switch_core_state_machine.c:625
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State REPORTING  going to sleep
>>  
>> 2011-05-07 22:48:06.017554 [DEBUG]  switch_core_state_machine.c:350
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State Change  CS_REPORTING -> CS_DESTROY
>>  
>> 2011-05-07 22:48:06.017554 [DEBUG]  switch_core_session.c:1116 Send signal
>> sofia/
>>  
>> internal/+4001 at 192.168.200.100 [BREAK]
>>  
>> 2011-05-07 22:48:06.017554 [DEBUG]  switch_core_session.c:1288 Session 2
>> (sofia/i
>>  
>> nternal/+4001 at 192.168.200.100) Locked, Waiting  on external entities
>>  
>> 2011-05-07 22:48:06.017554 [NOTICE]  switch_core_session.c:1306 Session 2
>> (sofia/
>>  
>> internal/+4001 at 192.168.200.100) Ended
>>  
>> 2011-05-07 22:48:06.017554 [NOTICE]  switch_core_session.c:1308 Close Channel
>> sof
>>  
>> ia/internal/+4001 at 192.168.200.100 [CS_DESTROY]
>>  
>> 2011-05-07 22:48:06.018554 [DEBUG]  switch_core_state_machine.c:454
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Callstate Change  HANGUP -> DOWN
>>  
>> 2011-05-07 22:48:06.018554 [DEBUG]  switch_core_state_machine.c:457
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) Running State  Change CS_DESTROY
>>  
>> 2011-05-07 22:48:06.018554 [DEBUG]  switch_core_state_machine.c:467
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State DESTROY
>>  
>> 2011-05-07 22:48:06.018554 [DEBUG] mod_sofia.c:362
>> sofia/internal/+4001 at 192.168.
>>  
>> 200.100 SOFIA DESTROY
>>  
>> 2011-05-07 22:48:06.018554 [DEBUG]  switch_core_state_machine.c:60
>> sofia/internal
>>  
>> /+4001 at 192.168.200.100 Standard  DESTROY
>>  
>> 2011-05-07 22:48:06.018554 [DEBUG]  switch_core_state_machine.c:467
>> (sofia/intern
>>  
>> al/+4001 at 192.168.200.100) State DESTROY  going to sleep
>>  
>>  
>> 
>>  
>> 
>> _______________________________________________
>> FreeSWITCH-users  mailing  list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>> 
>> 
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110507/13b67e37/attachment-0001.html 


More information about the FreeSWITCH-users mailing list