[asterisk-commits] mnicholson: branch 1.6.0 r221486 - in /branches/1.6.0: ./ channels/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 30 18:08:34 CDT 2009


Author: mnicholson
Date: Wed Sep 30 18:08:29 2009
New Revision: 221486

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=221486
Log:
Merged revisions 221432 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r221432 | mnicholson | 2009-09-30 15:40:20 -0500 (Wed, 30 Sep 2009) | 17 lines
  
  Merged revisions 221360 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r221360 | mnicholson | 2009-09-30 14:36:06 -0500 (Wed, 30 Sep 2009) | 10 lines
    
    Fix SRV lookup and Request-URI generation in chan_sip.
    
    This patch adds a new field "portinuri" to the sip dialog struct and the sip peer struct.  That field is used during RURI generation to determine if the port should be included in the RURI.  It is also used in some places to determine if an SRV lookup should occur.
    
    (closes issue #14418)
    Reported by: klaus3000
    Tested by: klaus3000, mnicholson
    
    Review: https://reviewboard.asterisk.org/r/369/
  ........
................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/chan_sip.c
    branches/1.6.0/configs/sip.conf.sample

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

Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=221486&r1=221485&r2=221486
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Wed Sep 30 18:08:29 2009
@@ -1233,6 +1233,7 @@
 	char tag[11];				/*!< Our tag for this session */
 	int sessionid;				/*!< SDP Session ID */
 	int sessionversion;			/*!< SDP Session Version */
+	int portinuri:1;			/*!< Non zero if a port has been specified, will also disable srv lookups */
 	int64_t sessionversion_remote;		/*!< Remote UA's SDP Session Version */
 	int session_modify;			/*!< Session modification request true/false  */
 	struct sockaddr_in sa;			/*!< Our peer */
@@ -1500,6 +1501,7 @@
 	struct ast_dnsmgr_entry *dnsmgr;/*!<  DNS refresh manager for peer */
 	struct sockaddr_in addr;	/*!<  IP address of peer */
 	int maxcallbitrate;		/*!< Maximum Bitrate for a video call */
+	int portinuri:1;		/*!< Whether the port should be included in the URI */
 
 	/* Qualification */
 	struct sip_pvt *call;		/*!<  Call pointer */
@@ -4345,6 +4347,8 @@
 	dialog->rtptimeout = peer->rtptimeout;
 	dialog->peerauth = peer->auth;
 	dialog->maxcallbitrate = peer->maxcallbitrate;
+	if (!dialog->portinuri)
+		dialog->portinuri = peer->portinuri;
 	if (ast_strlen_zero(dialog->tohost))
 		ast_string_field_set(dialog, tohost, ast_inet_ntoa(dialog->sa.sin_addr));
 	if (!ast_strlen_zero(peer->fromdomain)) {
@@ -4406,8 +4410,10 @@
 
 	ast_copy_string(peername, opeer, sizeof(peername));
 	port = strchr(peername, ':');
-	if (port)
+	if (port) {
 		*port++ = '\0';
+		dialog->portinuri = 1;
+	}
 	dialog->sa.sin_family = AF_INET;
 	dialog->timer_t1 = global_t1; /* Default SIP retransmission timer T1 (RFC 3261) */
 	dialog->timer_b = global_timer_b; /* Default SIP transaction timer B (RFC 3261) */
@@ -9334,7 +9340,7 @@
 			ast_str_append(&invite, 0, "%s@", n);
 		}
 		ast_str_append(&invite, 0, "%s", p->tohost);
-		if (ntohs(p->sa.sin_port) != STANDARD_SIP_PORT)
+		if (p->portinuri)
 			ast_str_append(&invite, 0, ":%d", ntohs(p->sa.sin_port));
 		ast_str_append(&invite, 0, "%s", urioptions);
 	}
@@ -10335,6 +10341,7 @@
 	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", peer->name);
 	register_peer_exten(peer, FALSE);	/* Remove regexten */
 	peer->expire = -1;
+	peer->portinuri = 0;
 	ast_device_state_changed("SIP/%s", peer->name);
 
 	/* Do we need to release this peer from memory? 
@@ -10556,6 +10563,7 @@
 		peer->useragent[0] = '\0';
 		peer->sipoptions = 0;
 		peer->lastms = 0;
+		peer->portinuri = 0;
 		pvt->expiry = 0;
 
 		ast_verb(3, "Unregistered SIP '%s'\n", peer->name);
@@ -10573,6 +10581,11 @@
 	if (parse_uri(curi, "sip:,sips:", &curi, NULL, &host, &pt, NULL, &transport)) {
 		ast_log(LOG_NOTICE, "Not a valid SIP contact (missing sip:) trying to use anyway\n");
 	}
+
+	if (!ast_strlen_zero(pt))
+		peer->portinuri = 1;
+	else
+		peer->portinuri = 0;
 
 	/* handle the transport type specified in Contact header. */
 	if ((transport_type = get_transport_str2enum(transport))) {
@@ -21337,6 +21350,9 @@
 		/* XXX should unregister ? */
 	}
 
+	if (found)
+		peer->portinuri = 0;
+
 	/* If we have realm authentication information, remove them (reload) */
 	clear_realm_authentication(peer->auth);
 	peer->auth = NULL;
@@ -21471,6 +21487,7 @@
 					ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
 				}
 			} else if (!strcasecmp(v->name, "port")) {
+				peer->portinuri = 1;
 				if (!realtime && peer->host_dynamic) {
 					peer->defaddr.sin_port = htons(atoi(v->value));
 				} else {
@@ -21773,7 +21790,7 @@
 
 		if (srvlookup) {
 			if (ast_get_ip_or_srv(&peer->addr, srvlookup, 
-								global_srvlookup ?  
+								global_srvlookup && !peer->portinuri ?
 									((peer->socket.type & SIP_TRANSPORT_UDP) ? "_sip._udp" :
 									 (peer->socket.type & SIP_TRANSPORT_TCP) ? "_sip._tcp" :
 									 "_sip._tls")

Modified: branches/1.6.0/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/configs/sip.conf.sample?view=diff&rev=221486&r1=221485&r2=221486
==============================================================================
--- branches/1.6.0/configs/sip.conf.sample (original)
+++ branches/1.6.0/configs/sip.conf.sample Wed Sep 30 18:08:29 2009
@@ -146,6 +146,9 @@
                                 ; Disabling DNS SRV lookups disables the 
                                 ; ability to place SIP calls based on domain 
                                 ; names to some other SIP users on the Internet
+                                ; Specifying a port in a SIP peer definition or
+                                ; when dialing outbound calls will supress SRV
+                                ; lookups for that peer or call.
                                 
 ;pedantic=yes                   ; Enable checking of tags in headers, 
                                 ; international character conversions in URIs




More information about the asterisk-commits mailing list