[asterisk-dev] [Code Review]: SIP: peer matching by callbackextension

Terry Wilson reviewboard at asterisk.org
Wed Feb 1 18:25:30 CST 2012



On Nov. 4, 2011, 4:10 a.m., David Vossel wrote:
> > I haven't had the need for this. Having the peer set its username in the From: or using match_auth_username has worked fine for my purposes. Is this really needed?

Here is the use case I can think of for this.

If you:

  1. Have multiple accounts with a particular provider and each requires registration
  2. The provider sends you calls based on the Contact header you registered with (which callbackextension sets)
  3. You don't authenticate inbound calls from this provider, but rely on the host/ip of the INVITE request
  4. You need to match inbound calls from this provider to the specific peer that registered for "some purpose" (billing, whatever)

then I can see where this would be useful. You could just set all of the peers so that it doesn't matter which one matches and then do lots of dialplan magic to determine what to do with the call, but this would make things a bit easier.

My initial reaction was "Matching by callbackextension seems crazy. Why would you create multiple peers that all point to the same host?" But, I thought that callbackextension was where Asterisk would send the call after matching the peer. This is not the case as callbackextension sets the Contact header so that that particular extension will be the one the other side uses for calling us back. The *only* way we determine what extension to hit is via the Request URI. So really, the peers with matching hosts and different callbackextensions are different entities with different contact addresses. After giving it some more thought, I think this feature makes sense. I plan on doing code review for it tomorrow, so if anyone has any comments...I suggest they hurry. ;-)


- Terry


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/344/#review4681
-----------------------------------------------------------


On Dec. 9, 2010, 12:16 p.m., David Vossel wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/344/
> -----------------------------------------------------------
> 
> (Updated Dec. 9, 2010, 12:16 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> If there are a number of peers with different callbackextension parameters and the same host address.  The first peer found matching the address is used regardless if that peer's callbackextension matches the incoming extension or not.
> 
> Now, to better match peers with incoming calls, if an incoming call's address can match multiple peers by address, we check each of those peer's callbackextension against the incoming extension for the best possible match.
> 
> It is possible that my implementation may be too expensive and only serve to address a minor edge case in the usage of chan_sip.  I do not fully understand the impact my changes may have upon performance when a large number of peers are present.  This patch assumes the new parse_uri() change has been made.
> 
> -------------------------------------------
> for example with two peers as follows
> [trunk1]
> host=sip.myitsp.com
> callbackextension=9991
> ...
> [trunk2]
> host=sip.myitsp.com
> callbackextension=9992
> ...
> 
> incoming calls to 9991 and to 9992 are both matched to the peer trunk1
> --------------------------------------------
> 
> 
> This addresses bug 14340.
>     https://issues.asterisk.org/jira/browse/14340
> 
> 
> Diffs
> -----
> 
>   /trunk/channels/chan_sip.c 297950 
>   /trunk/channels/sip/include/sip.h 297950 
>   /trunk/configs/sip.conf.sample 297950 
> 
> Diff: https://reviewboard.asterisk.org/r/344/diff
> 
> 
> Testing
> -------
> 
> Tested multiple peers with the same address containing different callbackextensions. Verified the correct peers were matched with incoming calls.
> 
> 
> Thanks,
> 
> David
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120202/61c864dd/attachment-0001.htm>


More information about the asterisk-dev mailing list