<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi all,</p>
    <p>I'm trying to resolve a weird issue with SIP routing.</p>
    <p>I have a number of SIP trunks, from a selection of providers, all
      of which are registered in sip.conf:</p>
    <blockquote>
      <p><tt>[general]</tt><tt><br>
        </tt><tt>context=default</tt><tt><br>
        </tt><tt>allowguest=no</tt><tt><br>
        </tt><tt>allowoverlap=no</tt><tt><br>
        </tt><tt>udpbindaddr=0.0.0.0</tt><tt><br>
        </tt><tt>tcpenable=yes</tt><tt><br>
        </tt><tt>tcpbindaddr=0.0.0.0</tt><tt><br>
        </tt><tt>transport=udp</tt><tt><br>
        </tt><tt>bindport=15060</tt><tt><br>
        </tt><tt>srvlookup=yes</tt><tt><br>
        </tt><tt>allowsubscribe=yes</tt><tt><br>
        </tt><tt>limitonpeers=yes</tt><tt><br>
        </tt><tt>callcounter=yes</tt><tt><br>
        </tt><tt>vmexten=5199</tt><tt><br>
        </tt><tt>nat=no</tt><tt><br>
        </tt></p>
      <p><tt>; SE registrations</tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user1:password1@sipgate.co.uk:5060/se2489">user1:password1@sipgate.co.uk:5060/se2489</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user2:password2@sipgate.co.uk:5060/se1268">user2:password2@sipgate.co.uk:5060/se1268</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user3:password3@sipgate.co.uk:5060/se0845">user3:password3@sipgate.co.uk:5060/se0845</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user4:password4@callcentric.com:5060/se1777">user4:password4@callcentric.com:5060/se1777</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user5:password5@sipgate.co.uk:5060/se4130">user5:password5@sipgate.co.uk:5060/se4130</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user9:password9@sip.vohippo.com:5060/se1413">user9:password9@sip.vohippo.com:5060/se1413</a></tt><tt><br>
        </tt>
      </p>
      <p><tt>; SJ registrations</tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user6:password6@sipgate.co.uk:5060/sj0151">user6:password6@sipgate.co.uk:5060/sj0151</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user7:password7@callcentric.com:5060/sj1777">user7:password7@callcentric.com:5060/sj1777</a></tt><tt><br>
        </tt><tt>register =>
          <a class="moz-txt-link-abbreviated" href="mailto:user8:password8@sipgate.co.uk:5060/sj0203">user8:password8@sipgate.co.uk:5060/sj0203</a></tt><br>
      </p>
    </blockquote>
    <p>I then have a selection of #included files. The first defines
      se2489:</p>
    <blockquote>
      <p><tt>[se2489]</tt><tt><br>
        </tt><tt>type=friend</tt><tt><br>
        </tt><tt>insecure=port,invite</tt><tt><br>
        </tt><tt>secret=password1</tt><tt><br>
        </tt><tt>defaultuser=user1</tt><tt><br>
        </tt><tt>fromuser=user1</tt><tt><br>
        </tt><tt>fromdomain=sipgate.co.uk</tt><tt><br>
        </tt><tt>host=sipgate.co.uk</tt><tt><br>
        </tt><tt>port=5060</tt><tt><br>
        </tt><tt>outboundproxy=proxy.live.sipgate.co.uk</tt><tt><br>
        </tt><tt>disallow=all</tt><tt><br>
        </tt><tt>allow=ulaw</tt><tt><br>
        </tt><tt>context=external-se</tt><tt><br>
        </tt><tt>qualify=yes</tt><tt><br>
        </tt><tt>canreinvite=no</tt><tt><br>
        </tt><tt>dtmfmode=rfc2833</tt><br>
      </p>
    </blockquote>
    <p>The second defines sj0151:</p>
    <blockquote>
      <p><tt>[sj0151]</tt><tt><br>
        </tt><tt>type=friend</tt><tt><br>
        </tt><tt>insecure=port,invite</tt><tt><br>
        </tt><tt>secret=password6</tt><tt><br>
        </tt><tt>defaultuser=user6</tt><tt><br>
        </tt><tt>fromuser=user6</tt><tt><br>
        </tt><tt>fromdomain=sipgate.co.uk</tt><tt><br>
        </tt><tt>host=sipgate.co.uk</tt><tt><br>
        </tt><tt>outboundproxy=proxy.live.sipgate.co.uk</tt><tt><br>
        </tt><tt>disallow=all</tt><tt><br>
        </tt><tt>allow=ulaw</tt><tt><br>
        </tt><tt>context=sj-main</tt><tt><br>
        </tt><tt>regcontext=sj-main       ; Added to try to fix wrong
          context on IB calls</tt><tt><br>
        </tt><tt>subscribecontext=sj-main ; Added to try to fix wrong
          context on IB calls</tt><tt><br>
        </tt><tt>qualify=yes</tt><tt><br>
        </tt><tt>canreinvite=no</tt><tt><br>
        </tt><tt>dtmfmode=rfc2833</tt><br>
      </p>
    </blockquote>
    <p>When an inbound call comes in to sj0151, I get the following
      error:</p>
    <blockquote>
      <p><tt>NOTICE[10777][C-00000000]: chan_sip.c:26407
          handle_request_invite: Call from 'user1' (217.10.79.23:5060)
          to extension 'sj0151' rejected because extension not found in
          context 'external-se'.</tt><br>
      </p>
    </blockquote>
    <p>Surely it should have looked in sj-main, not external-se?</p>
    <p>Also, the "Call from 'user1' is always 'user1' no matter which
      sipgate account originated the call. The Callcentric numbers can't
      receive inbound calls, the vohippo number shows "Call from
      'user9'" as one would expect. ALL of them look in context
      'external-se', but the SJ registrations should all be looking in
      'sj-main'. What's more, it seems to be struggling with pattern
      matching... The extension is passed correctly (albeit to the wrong
      context, for 3 of the numbers), so the following dialplan should
      pick them all up, surely?:</p>
    <blockquote>
      <p><tt>[external-se]</tt><tt><br>
        </tt><tt>; Transfer any call from any SE external trunk to the
          IVR @ the office.</tt><tt><br>
        </tt><tt>; If the office is unavailable (no internet, for
          example), then go to voicemail)</tt><tt><br>
        </tt><tt>exten => _se.,1,Dial(IAX2/cloud/1000,30,r)</tt><tt><br>
        </tt><tt>same  => n,Voicemail(5000)</tt><tt><br>
        </tt><tt>same  => n,Hangup()</tt><br>
      </p>
    </blockquote>
    <p>However, it simply doesn't work. If I replace _se. with _se2489.
      (or just se2489), it works fine (for calls arriving on the se2489
      extension; obviously the others bork).</p>
    <p><br>
    </p>
    <p>Can anyone tell me what I'm doing wrong, based on the above?</p>
    <p>FWIW; this seems to have occurred because I've been attempting to
      prune my dialplan; I used to have them all going into a single
      context, and I picked them out & routed them individually. I
      am _trying_ to simplify the structure/mess that is
      extensions.conf... but as a result I ran into this little
      conundrum. The main problem is to resolve the "wrong context"; I
      have a suspicion I could fix the "can't find extension" problem by
      getting rid of the letters & using a purely numeric extension.<br>
    </p>
    <p>Many thanks,</p>
    <p>Ade.<br>
    </p>
  </body>
</html>