Summary:ASTERISK-09117: Find_peer finds the first registered peer, resulting in inproper SIP channel display in the CDR and LOG
Reporter:Attila Megyeri (amegyeri)Labels:
Date Opened:2007-03-27 15:37:42Date Closed:2007-04-22 20:15:23
Versions:Frequency of
Environment:Attachments:( 0) call1
( 1) call2
( 2) sip.conf
Description:I have 2 SIP accounts registered at two independent providers, that are being hosted on the same IP address.
Provider A - Account A1 - IP Address C
Provider B - Account B1 - IP Address C
Both accounts are administered as peers and users as well.

Call comes in to Account A1, SIP Debug says 'found peer Provider A". This is correct.
Call comes in to Account B1, SIP Debug says 'found peer Provider A". This is incorrect.
I tracked down the issue - it is in the
  channel_sip.c=> find_peer => ASTOBJ_CONTAINER_FIND

The ASTOBJ_CONTAINER_FIND returns the first iteration from the peer list, even though it is a completely different provider. This is very confusing in the CDRs.

Expeced behaviour:
In case if there are multiple peers with the same IP address, the correct one should be matched. If this is impossible, the CDR(channel) should not show an exact SIP channel (e.g. SIP/DID_of_accountA1 for calls coming to DID_of_accountB1).
Comments:By: Joshua C. Colp (jcolp) 2007-03-27 16:32:51

Please attach your sip.conf (with passwords masked) and a sip debug of the two calls from different providers.

By: Attila Megyeri (amegyeri) 2007-03-27 17:52:34

Uploaded the sip conf, and 2 files from the two providers.
As you can see they are registered to a completely different number, but sill the channel is SIP/36213500200... for both.
36213500200 is btw the last peer in sip.conf.

By: Joshua C. Colp (jcolp) 2007-03-27 18:53:28

Both of the subdomains provided resolve to the same IP address:

With the way you have sip.conf written the mi-out entry is doing IP based matching on it, and thus will always be chosen. The only way that I can think of for you have this match on separate entries would be to have the provider do username/password based authentication so they authenticated as different users.

By: Attila Megyeri (amegyeri) 2007-04-14 17:08:21

Unfortunately I have no influence on the way the provider authenticates.

It seems I'll have to live with the SIP channels being misrecognized. Or is there any planned fix for this issue?

By: Olle Johansson (oej) 2007-04-18 04:58:59

At this point, this is an effect of the ASterisk sip channel architecture, it's well documented and it's bad. There are plans to change it, pending funding. See http://www.codename-pineapple.org

By: Joshua C. Colp (jcolp) 2007-04-22 20:15:23

Per mine and oej's comment, this is only fixable in the new architecture.