[Freeswitch-users] Dialplan expression matching

Kevin Wormington kworm at sofnet.com
Thu Sep 29 19:03:20 MSD 2016


expression is spelled wrong on ua_local and ua_mobile

> On Sep 29, 2016, at 9:54 AM, Vladyslav Zakhozhai <v.zakhozhai at gmail.com> wrote:
> 
> Mirko, thank you for your answer.
> Your information is very useful for me (I did not think that I need to close every condition but nevermind).
> 
> But it is not actually my problem. Let me put it this way:
> 
> <context name="internal">
> <extension name="echo_test" continue=true>
>     <condition field="destination_number" expression="^(echo|9999)$">
>         <action application="log" data="Start echo test."/>
>         <action application="answer"/>
>         <action application="echo" data =""/>
>     </condition>
> </extension>
> 
> <extension name="ua_local" continue=true>
>     <condition field="destination_number" experession="^[2-5][0-9]{6}$">
>         <action application="log" data="INFO Extension ua_local"/>
>         <action application="bridge" data="sofia/gateway/golden/${destination_number}"/>
>     </condition>
> </extension>
> 
> <extension name="ua_mobile" continue=true>
>     <condition field="destination_number" experession="^0[1-9]{9}$">
>         <action application="log" data="INFO Extension ua_mobile"/>
>         <action application="bridge" data="sofia/gateway/golden/${destination_number}"/>
>     </condition>
> </extension>
> </context>
> 
> I've added some verbosity with logging extension name.
> Logs says that ua_mobile passed pattern check. But ua_local also passed the check. And ua_local is to be executed.
> 
> But how 0930000000 can match ^[2-5][0-9]{6}$? And why in logs I see empty pattern against ua_local and ua_mobile:
> 
> In case echo_test: destination_number(0930000000) =~ /^(echo|9999)$/ break=on-false
> In case ua_local and ua_mobile: destination_number(0930000000) =~ // break=on-false
> 
> I'm pretty confused :)
> 
> And FS log:
> 
> 2016-09-29 17:45:24.303629 [INFO] mod_dialplan_xml.c:637 Processing vlakas <vlakas>->0930000000 in context internal
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->echo_test] continue=false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (FAIL) [echo_test] destination_number(0930000000) =~ /^(echo|9999)$/ break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->ua_local] continue=true
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (PASS) [ua_local] destination_number(0930000000) =~ // break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action log(INFO Extension ua_local) 
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action bridge(sofia/gateway/golden/${destination_number}) 
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->ua_mobile] continue=true
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (PASS) [ua_mobile] destination_number(0930000000) =~ // break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action log(INFO Extension ua_mobile) 
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action bridge(sofia/gateway/golden/${destination_number}) 
> 2016-09-29 17:45:24.303629 [DEBUG] switch_core_state_machine.c:286 (sofia/internal/vlakas at unitrans.tull.pp.ua) State Change CS_ROUTING -> CS_EXECUTE
> 2016-09-29 17:45:24.303629 [DEBUG] switch_core_state_machine.c:602 (sofia/internal/vlakas at unitrans.tull.pp.ua) State ROUTING going to sleep
> 2016-09-29 17:45:24.303629 [DEBUG] switch_core_state_machine.c:543 (sofia/internal/vlakas at unitrans.tull.pp.ua) Running State Change CS_EXECUTE
> 2016-09-29 17:45:24.303629 [DEBUG] switch_core_state_machine.c:609 (sofia/internal/vlakas at unitrans.tull.pp.ua) State EXECUTE
> 2016-09-29 17:45:24.303629 [DEBUG] mod_sofia.c:198 sofia/internal/vlakas at unitrans.tull.pp.ua SOFIA EXECUTE
> 2016-09-29 17:45:24.303629 [DEBUG] switch_core_state_machine.c:328 sofia/internal/vlakas at unitrans.tull.pp.ua Standard EXECUTE
> EXECUTE sofia/internal/vlakas at unitrans.tull.pp.ua log(INFO Extension ua_local)
> 2016-09-29 17:45:24.303629 [INFO] mod_dptools.c:1713 Extension ua_local
> EXECUTE sofia/internal/vlakas at unitrans.tull.pp.ua bridge(sofia/gateway/golden/0930000000)
> 
> 
> On Thu, Sep 29, 2016 at 4:33 PM Mirko Brankovic <mirkobrankovic at gmail.com> wrote:
> You need to close both conditions.
> Correct this one:
>     <extension name="is_internal_call">
>         <condition field="destination_number" expression=".*"/>
>         <condition field="${sip_h_X-Exten-Type}" expression="internal">
>               Some action
>          </condition>
>     </extension>
> 
> with this one/or remove one:
> 
>     <extension name="is_internal_call">
>         <condition field="destination_number" expression=".*"/>
>         <condition field="${sip_h_X-Exten-Type}" expression="internal">
>               Some action
>          </condition>
>          </condition>
>     </extension>
> 
> On Thu, Sep 29, 2016 at 3:04 PM, Vladyslav Zakhozhai <v.zakhozhai at gmail.com> wrote:
> David, thank you for your answer.
> 
> I've mentioned that I have no problems with extension is_local_call. It will be matched only if SIP message has custom header X-Exten-Type=internal.
> 
> If SIP message has no this header and To user is 0930000000 it does not match ua_mobile, but ua_local for some reason.
> 
> When I'd remove is_local_call all numeric destinations are matched against ua_local.
> 
> Here is part of FS log:
> 
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->echo_test] continue=false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (FAIL) [echo_test] destination_number(0930000000) =~ /^(echo|9999)$/ break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->is_internal_call] continue=false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (PASS) [is_internal_call] destination_number(0930000000) =~ /.*/ break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (FAIL) [is_internal_call] ${sip_h_X-Exten-Type}() =~ /internal/ break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->ua_local] continue=false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (PASS) [ua_local] destination_number(0930000000) =~ // break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action log(sip_h_X-Exten-Type: ${sip_h_X-Exten-Type}.) 
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action bridge(sofia/gateway/golden/${destination_number}) 
> 
> I've removed extension is_local_call and have:
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->echo_test] continue=false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (FAIL) [echo_test] destination_number(0930000000) =~ /^(echo|9999)$/ break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua parsing [internal->ua_local] continue=false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Regex (PASS) [ua_local] destination_number(0930000000) =~ // break=on-false
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action log(sip_h_X-Exten-Type: ${sip_h_X-Exten-Type}.) 
> Dialplan: sofia/internal/vlakas at unitrans.tull.pp.ua Action bridge(sofia/gateway/golden/${destination_number}) 
> 
> I can't understand why expression in log for ua_local is empty
> 
> Regex (PASS) [ua_local] destination_number(0930000000) =~ // break=on-false
> 
> 
> 
> On Thu, Sep 29, 2016 at 3:03 PM David Villasmil <david.villasmil.work at gmail.com> wrote:
> you're hitting internal before  09
> 
>  <extension name="is_internal_call">
>         <condition field="destination_number" expression=".*"/>
>         <condition field="${sip_h_X-Exten-Type}" expression="internal">
>               Some action
>          </condition>
>     </extension>
> 
>     <extension name="ua_mobile">
>         <condition field="destination_number" experession="^0[0-9]{9}$">
>             <action application="bridge" data="sofia/gateway/golden/${destination_number}"/>
>         </condition>
>     </extension>
> 
> try removing "        <condition field="destination_number" expression=".*"/>"
> 
> On Thu, Sep 29, 2016 at 10:41 AM, Vladyslav Zakhozhai <v.zakhozhai at gmail.com> wrote:
> Hi,
> 
> I've mentioned that pattern matching in my dialplan works incorrectly but I can't figure out the main reason.
> 
> For example I have the following dialplan:
> <context name="internal">
>     <extension name="echo_test">
>         <condition field="destination_number" expression="^(echo|9999)$">
>              Some action
>         </condition>
>     </extension>
>     <extension name="is_internal_call">
>         <condition field="destination_number" expression=".*"/>
>         <condition field="${sip_h_X-Exten-Type}" expression="internal">
>               Some action
>          </condition>
>     </extension>
>     <extension name="ua_local">
>         <condition field="destination_number" experession="^[2-5][0-9]{6}$">
>             Some action
>          </condition
>     </extension>
>     <extension name="ua_mobile">
>         <condition field="destination_number" experession="^0[0-9]{9}$">
>             <action application="bridge" data="sofia/gateway/golden/${destination_number}"/>
>         </condition>
>     </extension>
> </context>
> 
> 1. Call to "echo" - OK (echo_test)
> 2. Call to some extension with custom header X-Exten-Type - OK (is_internal_call)
> 3. Call to 5930000 - OK (ua_local)
> 4. Call to 0930000000 - FAILED to match ua_mobile extension. 
> 
> The last call matches ua_local. But why?
> 
> The result of regex dp_tool
> freeswitch at vlakas> regex 5930000|^[2-5][0-9]{6}$
> true
> freeswitch at vlakas> regex 0930000000|^[2-5][0-9]{6}$
> false
> 
> So, everything is correct. I can't understand why almost everyting goes to ua_local extension.
> 
> I appreciate you help.
> 
> 
> -- 
> Best regards,
> Vladyslav Zakhozhai
> email: v.zakhozhai at gmail.com
> tel.: +380(93) 757-21-61
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> 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
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> 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
> -- 
> Best regards,
> Vladyslav Zakhozhai
> email: v.zakhozhai at gmail.com
> tel.: +380(93) 757-21-61
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> 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
> 
> 
> 
> -- 
> Regards,
> Mirko
> ¯\_(ツ)_/¯
> 
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> 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
> -- 
> Best regards,
> Vladyslav Zakhozhai
> email: v.zakhozhai at gmail.com
> tel.: +380(93) 757-21-61
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services: 
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> 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





Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list