The issue with gateways, is you can not depend on us being able to match that the call actually came from that "gateway".  Carriers do all kinds of strange things in how they send calls.  What i typically do is either treat all calls from the outside world as public, or use ip matching in dialplan if I know for sure that it is going to be stable to change context.


On Sep 3, 2014, at 8:27 AM, Pavel <my.post@hotmail.com> wrote:


Thanks for your answer. But I found https://wiki.freeswitch.org/wiki/Authentication page which mentions the context as a parameter of gateway. Can we somehow use it ?

Date: Wed, 3 Sep 2014 07:55:26 -0400
From: rtreleaven@bunnykick.ca
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] How to place incoming unauth calls to different contexts.

Pavel gateways do not have a context property.
Transfer calls to the desired context via the dialplan.



On Wed, Sep 3, 2014 at 7:35 AM, Pavel <my.post@hotmail.com> wrote:
Hello Everyone !

My /sip_profiles/external.xml looks like:

<profile name="external">
  <gateways>
     <gateway name="gw1">
         <param name="username" value="username"/>
         <param name="realm" value="192.168.1.1"/>
         <param name="password" value="password"/>
         <param name="proxy" value="192.168.1.1"/>
         <param name="register" value="false"/>
         <param name="context" value="gw1"/>
     </gateway>
     <gateway name="gw2">
         <param name="username" value="username"/>
         <param name="realm" value="192.168.1.2"/>
         <param name="password" value="password"/>
         <param name="proxy" value="192.168.1.2"/>
         <param name="register" value="false"/>
         <param name="context" value="gw2"/>
     </gateway>  
  </gateways>
  <aliases>
        <alias name="outbound"/>
        <alias name="nat"/>
  </aliases>
  <domains>
    <domain name="all" alias="false" parse="true"/>
  </domains>
  <settings>
    <param name="debug" value="0"/>
    <param name="sip-trace" value="no"/>
    <param name="sip-capture" value="no"/>
    <param name="rfc2833-pt" value="101"/>
    <param name="sip-port" value="$${external_sip_port}"/>
    <param name="dialplan" value="XML"/>
    <param name="context" value="public"/>
    <param name="dtmf-duration" value="2000"/>
    <param name="inbound-codec-prefs" value="$${global_codec_prefs}"/>
    <param name="outbound-codec-prefs" value="$${outbound_codec_prefs}"/>
    <param name="hold-music" value="$${hold_music}"/>
    <param name="rtp-timer-name" value="soft"/>
    <param name="local-network-acl" value="localnet.auto"/>
    <param name="manage-presence" value="false"/>
    <param name="inbound-codec-negotiation" value="generous"/>
    <param name="nonce-ttl" value="60"/>
    <param name="auth-calls" value="false"/>
    <param name="inbound-late-negotiation" value="true"/>
    <param name="inbound-zrtp-passthru" value="true"/> <!-- (also enables late negotiation) -->
    <param name="rtp-ip" value="$${local_ip_v4}"/>
    <param name="sip-ip" value="$${local_ip_v4}"/>
    <param name="ext-rtp-ip" value="auto-nat"/>
    <param name="ext-sip-ip" value="auto-nat"/>
    <param name="rtp-timeout-sec" value="300"/>
    <param name="rtp-hold-timeout-sec" value="1800"/>
    <param name="tls" value="$${external_ssl_enable}"/>
    <param name="tls-only" value="false"/>
    <param name="tls-bind-params" value="transport=tls"/>
    <param name="tls-sip-port" value="$${external_tls_port}"/>
    <param name="tls-passphrase" value=""/>
    <param name="tls-verify-date" value="true"/>
    <param name="tls-verify-policy" value="none"/>
    <param name="tls-verify-depth" value="2"/>
    <param name="tls-verify-in-subjects" value=""/>
    <param name="tls-version" value="$${sip_tls_version}"/>
  </settings>
</profile>


Incoming unauthenticated calls from either gw1 or gw2 keep hitting context "public". Any way to place them in the appropriate contexts (eg. "gw1" and "gw2").


Thanks for your attention.


Rergards,
Pavel.