[asterisk-commits] dvossel: branch 1.6.1 r193389 - in /branches/1.6.1: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 8 15:51:20 CDT 2009


Author: dvossel
Date: Fri May  8 15:51:17 2009
New Revision: 193389

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=193389
Log:
Merged revisions 193387 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r193387 | dvossel | 2009-05-08 15:32:51 -0500 (Fri, 08 May 2009) | 7 lines
  
  TCP not matching valid peer.
  
  find_peer() does not find a valid peer when using pvt->recv as the sockaddr_in argument.  Because of the way TCP works, the port number in pvt->recv is not what we're looking for at all.  There is currently only one place that find_peer searches for a peer using the sockaddr_in argument.  If the peer is not found after using pvt->recv (works for UDP since the port number will be correct), a temp sockaddr_in struct is made using the Contact header in the sip_request.  This has the correct port number in it.
  
  Review: http://reviewboard.digium.com/r/236/
........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/channels/chan_sip.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/channels/chan_sip.c?view=diff&rev=193389&r1=193388&r2=193389
==============================================================================
--- branches/1.6.1/channels/chan_sip.c (original)
+++ branches/1.6.1/channels/chan_sip.c Fri May  8 15:51:17 2009
@@ -12231,6 +12231,22 @@
 		/* Then find devices based on IP */
 		if (!peer) {
 			peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE);
+		}
+
+		/* If the peer is still not found, try the address and port from the
+		 * contact header.  If the transport type is TCP or TLS it is not possible
+		 * to find the peer using p->recv. Because of the way TCP works, the received
+		 * packet's destination port will not match the one the peer table is
+		 * built with. */
+		if (!peer && (p->socket.type != SIP_TRANSPORT_UDP)) {
+			struct sockaddr_in tmpsin;
+			char contact[SIPBUFSIZE];
+			char *tmp;
+			memcpy(&tmpsin, &p->recv, sizeof(tmpsin));
+			ast_copy_string(contact, get_header(req, "Contact"), sizeof(contact));
+			tmp = get_in_brackets(contact);
+			__set_address_from_contact(tmp, &tmpsin, 1);
+			peer = find_peer(NULL, &tmpsin, TRUE, FINDPEERS, FALSE);
 		}
 	}
 




More information about the asterisk-commits mailing list