[asterisk-commits] mmichelson: trunk r370773 - in /trunk: ./ channels/ channels/sip/ channels/si...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 3 16:53:04 CDT 2012


Author: mmichelson
Date: Fri Aug  3 16:52:57 2012
New Revision: 370773

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370773
Log:
Multiple revisions 370769-370771

........
  r370769 | mmichelson | 2012-08-03 16:35:00 -0500 (Fri, 03 Aug 2012) | 24 lines
  
  Fix error in the "IPorHost" section of a SIP dialstring.
  
  This is based on the review request posted by Walter Doekes
  (referenced lower in the commit message)
  
  The main fix here is to treat the IPorHost portion of the dial
  string as a temporary outbound proxy. This ensures requests
  get sent to the proper location.
  
  Due to the age of the request, some parts were no longer relevant.
  For instance, the request moved outbound proxy parsing code into
  a single method. This is done in a previous commit, so it was not
  necessary to do again.
  
  Also, the review request fixed some errors with regards to request
  routing for CANCEL and ACK requests. This has also been fixed in
  more recent commits.
  
  (closes issue ASTERISK-19677)
  reported by Walter Doekes
  
  Review https://reviewboard.asterisk.org/r/1859
........
  r370770 | mmichelson | 2012-08-03 16:39:35 -0500 (Fri, 03 Aug 2012) | 3 lines
  
  Remove unused variable.
........
  r370771 | mmichelson | 2012-08-03 16:43:52 -0500 (Fri, 03 Aug 2012) | 5 lines
  
  Seriously? Another compilation error fixed.
  
  Somebody beat me.
........

Merged revisions 370769-370771 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 370772 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/channels/sip/config_parser.c
    trunk/channels/sip/include/sip.h

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=370773&r1=370772&r2=370773
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Aug  3 16:52:57 2012
@@ -1590,7 +1590,7 @@
 static const struct ast_sockaddr *sip_real_dst(const struct sip_pvt *p);
 static void build_via(struct sip_pvt *p);
 static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer);
-static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_sockaddr *addr, int newdialog, struct ast_sockaddr *remote_address);
+static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_sockaddr *addr, int newdialog);
 static char *generate_random_string(char *buf, size_t size);
 static void build_callid_pvt(struct sip_pvt *pvt);
 static void change_callid_pvt(struct sip_pvt *pvt, const char *callid);
@@ -2015,7 +2015,7 @@
 
 	sip_pvt_lock(monitor_instance->subscription_pvt);
 	ast_set_flag(&monitor_instance->subscription_pvt->flags[0], SIP_OUTGOING);
-	create_addr(monitor_instance->subscription_pvt, monitor_instance->peername, 0, 1, NULL);
+	create_addr(monitor_instance->subscription_pvt, monitor_instance->peername, 0, 1);
 	ast_sip_ouraddrfor(&monitor_instance->subscription_pvt->sa, &monitor_instance->subscription_pvt->ourip, monitor_instance->subscription_pvt);
 	monitor_instance->subscription_pvt->subscribed = CALL_COMPLETION;
 	monitor_instance->subscription_pvt->expiry = when;
@@ -3316,6 +3316,12 @@
 /*! \brief Get default outbound proxy or global proxy */
 static struct sip_proxy *obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
 {
+	if (dialog && dialog->options && dialog->options->outboundproxy) {
+		if (sipdebug) {
+			ast_debug(1, "BLAH\n");
+		}
+		return dialog->options->outboundproxy;
+	}
 	if (peer && peer->outboundproxy) {
 		if (sipdebug) {
 			ast_debug(1, "OBPROXY: Applying peer OBproxy to this call\n");
@@ -5712,7 +5718,7 @@
 /*! \brief create address structure from device name
  *      Or, if peer not found, find it in the global DNS
  *      returns TRUE (-1) on failure, FALSE on success */
-static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_sockaddr *addr, int newdialog, struct ast_sockaddr *remote_address)
+static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_sockaddr *addr, int newdialog)
 {
 	struct sip_peer *peer;
 	char *peername, *peername2, *hostn;
@@ -5743,9 +5749,6 @@
 			set_socket_transport(&dialog->socket, 0);
 		}
 		res = create_addr_from_peer(dialog, peer);
-		if (!ast_sockaddr_isnull(remote_address)) {
-			ast_sockaddr_copy(&dialog->sa, remote_address);
-		}
 		dialog->relatedpeer = sip_ref_peer(peer, "create_addr: setting dialog's relatedpeer pointer");
 		sip_unref_peer(peer, "create_addr: unref peer from sip_find_peer hashtab lookup");
 		return res;
@@ -6114,8 +6117,12 @@
 	if (dumphistory)
 		sip_dump_history(p);
 
-	if (p->options)
+	if (p->options) {
+		if (p->options->outboundproxy) {
+			ao2_ref(p->options->outboundproxy, -1);
+		}
 		ast_free(p->options);
+	}
 
 	if (p->notify) {
 		ast_variables_destroy(p->notify->headers);
@@ -13281,7 +13288,7 @@
 
 	sip_pvt_lock(pvt);
 
-	if (create_addr(pvt, epa_entry->destination, NULL, TRUE, NULL)) {
+	if (create_addr(pvt, epa_entry->destination, NULL, TRUE)) {
 		sip_pvt_unlock(pvt);
 		dialog_unlink_all(pvt);
 		dialog_unref(pvt, "create_addr failed in transmit_publish. Unref dialog");
@@ -13587,7 +13594,7 @@
 	}
 	
 	/* Setup the destination of our subscription */
-	if (create_addr(mwi->call, mwi->hostname, &mwi->us, 0, NULL)) {
+	if (create_addr(mwi->call, mwi->hostname, &mwi->us, 0)) {
 		dialog_unlink_all(mwi->call);
 		mwi->call = dialog_unref(mwi->call, "unref dialog after unlink_all");
 		return 0;
@@ -14102,7 +14109,7 @@
 		return 0;
 	}
 
-	if (create_addr(p, channame, NULL, 0, NULL)) {
+	if (create_addr(p, channame, NULL, 0)) {
 		/* Maybe they're not registered, etc. */
 		dialog_unlink_all(p);
 		dialog_unref(p, "unref dialog inside for loop" );
@@ -14446,7 +14453,7 @@
 		}
 
 		/* Find address to hostname */
-		if (create_addr(p, S_OR(r->peername, r->hostname), &r->us, 0, NULL)) {
+		if (create_addr(p, S_OR(r->peername, r->hostname), &r->us, 0)) {
 			/* we have what we hope is a temporary network error,
 			 * probably DNS.  We need to reschedule a registration try */
 			dialog_unlink_all(p);
@@ -20609,7 +20616,7 @@
 			return CLI_FAILURE;
 		}
 
-		if (create_addr(p, a->argv[i], NULL, 1, NULL)) {
+		if (create_addr(p, a->argv[i], NULL, 1)) {
 			/* Maybe they're not registered, etc. */
 			dialog_unlink_all(p);
 			dialog_unref(p, "unref dialog inside for loop" );
@@ -22131,6 +22138,9 @@
 		ast_debug(3, "Got 200 OK on subscription for MWI\n");
 		set_pvt_allowed_methods(p, req);
 		if (p->options) {
+			if (p->options->outboundproxy) {
+				ao2_ref(p->options->outboundproxy, -1);
+			}
 			ast_free(p->options);
 			p->options = NULL;
 		}
@@ -25844,7 +25854,7 @@
 	sip_pvt_lock(pvt);
 
 	/* Look up the host to contact */
-	if (create_addr(pvt, to_host, NULL, TRUE, NULL)) {
+	if (create_addr(pvt, to_host, NULL, TRUE)) {
 		sip_pvt_unlock(pvt);
 		dialog_unlink_all(pvt);
 		dialog_unref(pvt, "create_addr failed sending a MESSAGE");
@@ -28559,7 +28569,6 @@
 	char dialstring[256];
 	char *remote_address;
 	enum sip_transport transport = 0;
-	struct ast_sockaddr remote_address_sa = { {0,} };
 	struct ast_callid *callid;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(peerorhost);
@@ -28675,15 +28684,9 @@
 	}
 
 	if (!ast_strlen_zero(remote_address)) {
-		if (ast_sockaddr_resolve_first_transport(&remote_address_sa, remote_address, 0, transport)) {
-			ast_log(LOG_WARNING, "Unable to find IP address for host %s. We will not use this remote IP address\n", remote_address);
-		} else {
-			if (!ast_sockaddr_port(&remote_address_sa)) {
-				ast_sockaddr_set_port(&remote_address_sa,
-						      transport & SIP_TRANSPORT_TLS ?
-						      STANDARD_TLS_PORT :
-						      STANDARD_SIP_PORT);
-			}
+		p->options->outboundproxy = proxy_from_config(remote_address, 0, NULL);
+		if (!p->options->outboundproxy) {
+			ast_log(LOG_WARNING, "Unable to parse outboundproxy %s. We will not use this remote IP address\n", remote_address);
 		}
 	}
 
@@ -28694,7 +28697,7 @@
 		ext = extension (user part of URI)
 		dnid = destination of the call (applies to the To: header)
 	*/
-	if (create_addr(p, host, NULL, 1, &remote_address_sa)) {
+	if (create_addr(p, host, NULL, 1)) {
 		*cause = AST_CAUSE_UNREGISTERED;
 		ast_debug(3, "Cant create SIP call - target device not registered\n");
 		dialog_unlink_all(p);

Modified: trunk/channels/sip/config_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/config_parser.c?view=diff&rev=370773&r1=370772&r2=370773
==============================================================================
--- trunk/channels/sip/config_parser.c (original)
+++ trunk/channels/sip/config_parser.c Fri Aug  3 16:52:57 2012
@@ -652,14 +652,17 @@
 	if ((*hostname = strstr(line, "://"))) {
 		*hostname += 3;
 
-		if (!strncasecmp(line, "tcp", 3))
+		if (!strncasecmp(line, "tcp", 3)) {
 			*transport = SIP_TRANSPORT_TCP;
-		else if (!strncasecmp(line, "tls", 3))
+		} else if (!strncasecmp(line, "tls", 3)) {
 			*transport = SIP_TRANSPORT_TLS;
-		else if (!strncasecmp(line, "udp", 3))
+		} else if (!strncasecmp(line, "udp", 3)) {
 			*transport = SIP_TRANSPORT_UDP;
-		else
+		} else if (lineno) {
 			ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type on line %d of sip.conf. defaulting to udp.\n", line, lineno);
+		} else {
+			ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type in sip config. defaulting to udp.\n", line);
+		}
 	} else {
 		*hostname = line;
 		*transport = SIP_TRANSPORT_UDP;
@@ -671,14 +674,22 @@
 		line = *hostname;
 
 	if (ast_sockaddr_split_hostport(line, hostname, &port, 0) == 0) {
-		ast_log(LOG_WARNING, "Cannot parse host '%s' on line %d of sip.conf.\n",
-			line, lineno);
+		if (lineno) {
+			ast_log(LOG_WARNING, "Cannot parse host '%s' on line %d of sip.conf.\n",
+				line, lineno);
+		} else {
+			ast_log(LOG_WARNING, "Cannot parse host '%s' in sip config.\n", line);
+		}
 		return -1;
 	}
 
 	if (port) {
 		if (!sscanf(port, "%5u", portnum)) {
-			ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
+			if (lineno) {
+				ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", port, lineno);
+			} else {
+				ast_log(LOG_NOTICE, "'%s' is not a valid port number in sip config. using default.\n", port);
+			}
 			port = NULL;
 		}
 	}

Modified: trunk/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/sip.h?view=diff&rev=370773&r1=370772&r2=370773
==============================================================================
--- trunk/channels/sip/include/sip.h (original)
+++ trunk/channels/sip/include/sip.h Fri Aug  3 16:52:57 2012
@@ -851,6 +851,7 @@
 	enum sip_auth_type auth_type;  /*!< Authentication type */
 	const char *replaces;       /*!< Replaces header for call transfers */
 	int transfer;               /*!< Flag - is this Invite part of a SIP transfer? (invite/replaces) */
+	struct sip_proxy *outboundproxy; /*!< Outbound proxy URI */
 };
 
 /*! \brief Structure to save routing information for a SIP session */




More information about the asterisk-commits mailing list