[Asterisk-Users] Why does incoming SIP call match a "peer" context in sip.conf?

Andreas Greulich andreas.greulich at spl.ch
Sun Oct 10 03:22:42 MST 2004


Hi all,

I got the problem that my voip provider (Sipgate) is using a differnet codec for
vm than for normal calls. So I setup it such that incoming calls should find
their way into the context [Sipgate], while outgoing calls are directed to
[Sipgate] and [Sipgate-vm] depending on the dialplan. Consequently, I set up
[Sipgate] as "friend" (calls come in and go out), while [Sipgate-vm] is set
up as "peer" (it shoudl not get any incoming calls). The relevant parts look
like that:

sip.conf:
  [Sipgate]
  type=friend
  username=1838074
  secret=###
  host=sipgate.de
  fromuser=1838074
  fromdomain=sipgate.de
  nat=no
  dtmfmode=info
  canreinvite=no
  insecure=very
  disallow=all ; Disallow all codecs
  allow=ilbc

  [Sipgate-vm]
  type=peer
  username=1838074
  secret=###
  host=sipgate.de
  fromuser=1838074
  fromdomain=sipgate.de
  nat=no
  dtmfmode=info
  canreinvite=no
  disallow=all ; Disallow all codecs
  allow=g726

extensions.conf:
  [intern]
  ...
  include => sipgate-vm
  include => sipgate-out
  ...
  include => sip

  [sipgate-vm]
  exten => h,1,Hangup
  exten => 50000,1,SetCallerID(${SIPGATEID})
  exten => 50000,2,SetVar(SIP_CODEC=g726)
  exten => 50000,3,Dial(SIP/50000 at Sipgate-vm,60,)

  [sipgate-out]
  exten => h,1,Hangup
  exten => _X.,1,SetCallerID(${SIPGATEID})
  exten => _X.,2,SetVar(SIP_CODEC=ilbc)
  exten => _X.,3,Dial(SIP/${EXTEN}@Sipgate,60,)


It works perfectly for outgoing calls and sets codecs to g726 for both my local
phone and Sipgate. If I am called though, * seems to choose [Sipgate-vm]
context instead of [Sipgate]! In my understanding, this should not happen as
Sipagte-vm is defined as peer and not as user or friend? I thought incoming
calls should only match againt "friend" and "user" contexts... The following sip
debug (shortened) output shows what's happening on an incoming call:

INVITE sip:1838074 at 217.162.36.14:5060 SIP/2.0
Record-Route: <sip:1838074 at 217.10.79.9;ftag=as2317ebbc;lr=on>
Max-Forwards: 9
Record-Route: <sip:4991130838074 at 217.10.79.8;ftag=as2317ebbc;lr=on>
Via: SIP/2.0/UDP 217.10.79.9;branch=z9hG4bK66f7.0c523115.1
Via: SIP/2.0/UDP 217.10.79.8;branch=z9hG4bK66f7.8b995de6.0
Via: SIP/2.0/UDP 217.10.66.11:5060;branch=z9hG4bK0e7c88f6
From: "0" <sip:0 at 217.10.66.11>;tag=as2317ebbc
To: <sip:4991130838074 at sipgate.net>
Contact: <sip:0 at 217.10.66.11>
Call-ID: 21e41c1b763e327e5b99540e171566ff at 217.10.66.11
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Date: Sun, 10 Oct 2004 09:44:09 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Content-Type: application/sdp
Content-Length: 343
Sipgate-Authentication: accepted
...
Found description format PCMA
Found description format PCMU
Found description format GSM
Found description format L16
Found description format iLBC
Found description format G729
Found description format G726-32
Found description format DVI4
Capabilities: us - 0x51c(ULAW|ALAW|G726|G729A|ILBC), peer -
audio=0x57e(GSM|ULAW|ALAW|G726|ADPCM|SLINR|G729A|ILBC)/video=0x0(EMPTY),
combined - 0x51c(ULAW|ALAW|G726|G729A|ILBC)
Non-codec capabilities: us - 0x1(G723), peer - 0x0(EMPTY), combined - 0x0(EMPTY)
Found peer 'Sipgate-vm'   <<<<<<<<<<<< !!!!!!!!!!!!

I found no way to prevent this behavious (not even commenting out username
fields). Finally, I just reversed the order of the contexts in sip.conf
([Sipgate.vm] before [Sipgate]), and now it is working, as the later context
seems to have precedence. But of course this is not a documented feature, so I'd
like a more robust way to do this. Did I miss there something? Is there any
otehr way than using different contexts for outgoing calls to the same provider
that should use different codecs? Or is it a bug in *?

Thanks in advance, Andy



-- 

Andreas Greulich
E-Mail: andreas.greulich at spl.ch
Skype: klaymen-neverhood

Sermo datur cunctis, animi sapientia paucis.




More information about the asterisk-users mailing list