Hi,

A couple of days ago I posted regarding SIP 'SUBSCRIBE's failing from
our snom190 phones here:
    http://lists.digium.com/pipermail/asterisk-users/2005-May/106545.html

I did some more analysis, and it seems that the problem is caused
because each of our phones REGISTERs as two or more users on the same
server (So that the user can choose an identity for outgoing calls)

This means that when a subscribe comes in, it calls to
check_user_full(...), which then calls find_peer(NULL,ip_address) -
the find_peer call was of course only returning ONE of the
registrations for that IP address.

The failure was due to an inability to authenticate the SUBSCRIBE, and
this was happening when the phone was trying to SUBSCRIBE using
credentials from "SIP/line1", and find_peer(...) was returning
credentials for the correct phone, but for "SIP/line2".

I have provided 2 versions of a simple patch, one against 1.0.7 and
once against CVS-HEAD, and would appreciate comments. I have given the
1.0.7 version some basic testing, and have found no obvious problems.

Thanks,
Steve
--- ./channels/chan_sip.c~	2005-04-13 14:39:08.000000000 +0100
+++ ./channels/chan_sip.c	2005-05-13 10:48:31.000000000 +0100
@@ -5490,11 +5490,17 @@
 	if (!user) {
 		/* If we didn't find a user match, check for peers */
 		ast_mutex_lock(&peerl.lock);
-		/* Look for peer based on the IP address we received data from */
-		/* If peer is registred from this IP address or have this as a default
-		   IP address, this call is from the peer 
+		/* First look for peer based on username, otherwise we might
+		   Have many registrations, and get one that fails to match and
+		   Authenticate
+		*/
+		peer = find_peer(of, NULL);
+		/* Look for peer based on the IP address we received data from
+		   If peer is registred from this IP address or have this as a
+		   default IP address, this call is from the peer 
  		*/
-		peer = find_peer(NULL, &p->recv);
+		if (!peer)
+			peer = find_peer(NULL, &p->recv);
 		if (peer) {
 			if (debug)
 				ast_verbose("Found peer '%s'\n", peer->name);
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.728
diff -u -r1.728 chan_sip.c
--- chan_sip.c	8 May 2005 16:49:28 -0000	1.728
+++ chan_sip.c	13 May 2005 10:16:36 -0000
@@ -5969,12 +5969,17 @@
 	}
 
 	if (!user) {
-		/* If we didn't find a user match, check for peers */
-		/* Look for peer based on the IP address we received data from */
-		/* If peer is registred from this IP address or have this as a default
-		   IP address, this call is from the peer 
- 		*/
-		peer = find_peer(NULL, &p->recv, 1);
+		/* First look for peer based on username, otherwise we might
+		   Have many registrations, and get one that fails to match and
+		   Authenticate
+		*/
+		peer = find_peer(of, NULL, 1);
+		/* Look for peer based on the IP address we received data from
+		   If peer is registred from this IP address or have this as a
+		   default IP address, this call is from the peer
+		*/
+		if (!peer)
+			peer = find_peer(NULL, &p->recv, 1);
 		if (peer) {
 			if (debug)
 				ast_verbose("Found peer '%s'\n", peer->name);
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to