[asterisk-commits] simon.perreault: branch group/v6-new r272530 - /team/group/v6-new/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 25 13:52:05 CDT 2010


Author: simon.perreault
Date: Fri Jun 25 13:52:01 2010
New Revision: 272530

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=272530
Log:
Make per-peer outboundproxy work.

Modified:
    team/group/v6-new/channels/chan_sip.c

Modified: team/group/v6-new/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/channels/chan_sip.c?view=diff&rev=272530&r1=272529&r2=272530
==============================================================================
--- team/group/v6-new/channels/chan_sip.c (original)
+++ team/group/v6-new/channels/chan_sip.c Fri Jun 25 13:52:01 2010
@@ -2884,23 +2884,6 @@
 	return port;
 }
 
-/*! \brief Allocate and initialize sip proxy */
-static struct sip_proxy *proxy_allocate(char *name, int force)
-{
-	struct sip_proxy *proxy;
-
-	if (ast_strlen_zero(name)) {
-		return NULL;
-	}
-
-	proxy = ao2_alloc(sizeof(*proxy), NULL);
-	if (!proxy)
-		return NULL;
-	proxy->force = force;
-	proxy_update(proxy);
-	return proxy;
-}
-
 /*! \brief Get default outbound proxy or global proxy */
 static struct sip_proxy *obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
 {
@@ -25332,16 +25315,37 @@
 			} else if (!strcasecmp(v->name, "fromuser")) {
 				ast_string_field_set(peer, fromuser, v->value);
 			} else if (!strcasecmp(v->name, "outboundproxy")) {
-				char *next, *force, *proxyname;
-				int forceopt = FALSE;
-				/* Set peer channel variable */
-				next = proxyname = ast_strdupa(v->value);
-				if ((force = strchr(next, ','))) {
-					*force++ = '\0';
-					forceopt = strcmp(force, "force");
+				char *tok, *proxyname;
+
+				if (ast_strlen_zero(v->value)) {
+					ast_log(LOG_WARNING, "no value given for outbound proxy on line %d of sip.conf.", v->lineno);
+					continue;
 				}
-				/* Allocate proxy object */
-				peer->outboundproxy = proxy_allocate(proxyname, forceopt);
+
+				peer->outboundproxy =
+				    ao2_alloc(sizeof(*peer->outboundproxy), NULL);
+
+				sip_parse_host(tok, v->lineno, &proxyname,
+					       &peer->outboundproxy->port,
+					       &peer->outboundproxy->transport);
+
+				tok = ast_skip_blanks(strtok(ast_strdupa(v->value), ","));
+
+				if ((tok = strtok(NULL, ","))) {
+					peer->outboundproxy->force = !strncasecmp(ast_skip_blanks(tok), "force", 5);
+				} else {
+					peer->outboundproxy->force = FALSE;
+				}
+
+				if (ast_strlen_zero(proxyname)) {
+					ast_log(LOG_WARNING, "you must specify a name for the outboundproxy on line %d of sip.conf.", v->lineno);
+					sip_cfg.outboundproxy.name[0] = '\0';
+					continue;
+				}
+
+				ast_copy_string(peer->outboundproxy->name, proxyname, sizeof(peer->outboundproxy->name));
+
+				proxy_update(peer->outboundproxy);
 			} else if (!strcasecmp(v->name, "host")) {
 				if (!strcasecmp(v->value, "dynamic")) {
 					/* They'll register with us */




More information about the asterisk-commits mailing list