[svn-commits] rizzo: branch rizzo/astobj2 r57944 - /team/rizzo/astobj2/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Mar 5 13:39:31 MST 2007


Author: rizzo
Date: Mon Mar  5 14:39:30 2007
New Revision: 57944

URL: http://svn.digium.com/view/asterisk?view=rev&rev=57944
Log:
merge from trunk svn 53992.

need to fix 3 places marked #if 0 /* XXX */
and also replace strchr() with strsep in those places.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=57944&r1=57943&r2=57944
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Mon Mar  5 14:39:30 2007
@@ -565,6 +565,7 @@
 static int global_t1min;		/*!< T1 roundtrip time minimum */
 static int global_autoframing;          /*!< Turn autoframing on or off. */
 static enum transfermodes global_allowtransfer;	/*!< SIP Refer restriction scheme */
+static struct sip_proxy global_outboundproxy;   /*!< Outbound proxy */
 
 /*! \brief Codecs that we support by default: */
 static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
@@ -993,6 +994,7 @@
 	int jointnoncodeccapability;            /*!< Joint Non codec capability */
 	int redircodecs;			/*!< Redirect codecs */
 	int maxcallbitrate;			/*!< Maximum Call Bitrate for Video Calls */	
+	struct sip_proxy *outboundproxy;        /*!< Outbound proxy for this dialog */
 	struct t38properties t38;		/*!< T38 settings */
 	struct sockaddr_in udptlredirip;	/*!< Where our T.38 UDPTL should be going if not to us */
 	struct ast_udptl *udptl;		/*!< T.38 UDPTL session */
@@ -1182,6 +1184,7 @@
 	struct ast_codec_pref prefs;	/*!<  codec prefs */
 	ast_group_t callgroup;		/*!<  Call group */
 	ast_group_t pickupgroup;	/*!<  Pickup group */
+	struct sip_proxy *outboundproxy;        /*!< Outbound proxy for this peer */
 	unsigned int sipoptions;	/*!<  Supported SIP options */
 	struct ast_flags flags[2];	/*!<  SIP_ flags */
 	int amaflags;			/*!< AMA Flags (for billing) */
@@ -1189,7 +1192,7 @@
 	int capability;			/*!<  Codec capability */
 	int inUse;			/*!< Number of calls in use */
 	int call_limit;			/*!< Limit of concurrent calls */
-	int busy_limit;			/*!< Limit where we signal busy */
+	int busy_level;			/*!< Level where we signal busy */
 	enum transfermodes allowtransfer;	/*! SIP Refer restriction scheme */
 	struct ast_ha *ha;		/*!<  Access control list */
 	struct ast_variable *chanvars;	/*!<  Variables to set for channel created by user */
@@ -1261,6 +1264,20 @@
 
 	REG_STATE_FAILED,	/*!< Registration failed after several tries */
 		/* fatal - no chance to proceed */
+};
+
+/*! \brief definition of a sip proxy server
+ *
+ * For outbound proxies, this is allocated in the SIP peer dynamically or
+ * statically as the global_outboundproxy. The pointer in a SIP message is just
+ * a pointer and should *not* be de-allocated.
+ */
+struct sip_proxy {
+	char name[MAXHOSTNAMELEN];      /*!< DNS name of domain/host or IP */
+	struct sockaddr_in ip;          /*!< Currently used IP address and port */
+	time_t last_dnsupdate;          /*!< When this was resolved */
+	int force;                      /*!< If it's an outbound proxy, Force use of this outbound proxy for all outbound requests */
+	/* Room for a SRV record chain based on the name */
 };
 
 /*!
@@ -1356,7 +1373,6 @@
 static int externrefresh = 10;
 static struct ast_ha *localaddr;		/*!< List of local networks, on the same side of NAT as this Asterisk */
 static struct in_addr __ourip;
-static struct sockaddr_in outboundproxyip;
 static int ourport;
 static struct sockaddr_in debugaddr;
 
@@ -1874,6 +1890,13 @@
 	set_udptl_peer: sip_set_udptl_peer,
 };
 
+/*! \brief Append to SIP dialog history
+	 \return Always returns 0 */
+#define append_history(p, event, fmt , args... )        append_history_full(p, "%-15s " fmt, event, ## args)
+
+static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+ 
 static const struct _map_x_s referstatusstrings[] = {
 	{ REFER_IDLE,		"<none>" },
 	{ REFER_SENT,		"Request sent" },
@@ -1922,7 +1945,59 @@
 		ast_log(LOG_DEBUG, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
 	ast_set_flag(&dialog->flags[0], SIP_ALREADYGONE);
 }
-  	 
+
+
+/*! Resolve DNS srv name or host name in a sip_proxy structure */
+static int proxy_update(struct sip_proxy *proxy)
+{
+	/* if it's actually an IP address and not a name,
+	there's no need for a managed lookup */
+	if (!inet_aton(proxy->name, &proxy->ip.sin_addr)) {
+		/* Ok, not an IP address, then let's check if it's a domain or host */
+		/* XXX Todo - if we have proxy port, don't do SRV */
+		if (ast_get_ip_or_srv(&proxy->ip, proxy->name, global_srvlookup ? "_sip._udp" : NULL) < 0) {
+			ast_log(LOG_WARNING, "Unable to locate host '%s'\n", proxy->name);
+			return FALSE;
+		}
+	}
+	proxy->last_dnsupdate = time(NULL);
+	return TRUE;
+}
+
+/*! \brief Allocate and initialize sip proxy */
+static struct sip_proxy *proxy_allocate(char *name, char *port, int force)
+{
+	struct sip_proxy *proxy;
+	proxy = ast_calloc(1, sizeof(struct sip_proxy));
+	if (!proxy)
+		return NULL;
+	proxy->force = force;
+	ast_copy_string(proxy->name, name, sizeof(proxy->name));
+	if (!ast_strlen_zero(port))
+		proxy->ip.sin_port = htons(atoi(port));
+	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)
+{
+	if (peer && peer->outboundproxy) {
+		if (option_debug && sipdebug)
+			ast_log(LOG_DEBUG, "OBPROXY: Applying peer OBproxy to this call\n");
+		append_history(dialog, "OBproxy", "Using peer obproxy %s", peer->outboundproxy->name);
+		return peer->outboundproxy;
+	}
+	if (global_outboundproxy.name[0]) {
+		if (option_debug && sipdebug)
+			ast_log(LOG_DEBUG, "OBPROXY: Applying global OBproxy to this call\n");
+		append_history(dialog, "OBproxy", "Using global obproxy %s", global_outboundproxy.name);
+		return &global_outboundproxy;
+	}
+	if (option_debug && sipdebug)
+		ast_log(LOG_DEBUG, "OBPROXY: Not applying OBproxy to this call\n");
+	return NULL;
+}
 
 /*! \brief returns true if 'name' (with optional trailing whitespace)
  * matches the sip method 'id'.
@@ -2014,6 +2089,8 @@
 /*! \brief The real destination address for a write */
 static const struct sockaddr_in *sip_real_dst(const struct sip_pvt *p)
 {
+	if (p->outboundproxy)
+		return &p->outboundproxy->ip;
 	return ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_ROUTE ? &p->recv : &p->sa;
 }
 
@@ -2104,15 +2181,6 @@
 {
 	return !ast_test_flag(&p->flags[0], SIP_NO_HISTORY);
 }
-
-/*! \brief Append to SIP dialog history 
-	\return Always returns 0 */
-#define append_history(p, event, fmt , args... )	do {	\
-	if (p && record_history(p))	append_history_full(p, "%-15s " fmt, event, ## args); \
-	} while (0)
-
-static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
 
 /*! \brief Append to SIP dialog history with arg list  */
 static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
@@ -2384,6 +2452,14 @@
 	const char *msg = "Not Found";	/* used only for debugging */
 
 	sip_pvt_lock(p);
+        /* If we have an outbound proxy for this dialog, then delete it now since
+  	   the rest of the requests in this dialog needs to follow the routing.
+  	   If obforcing is set, we will keep the outbound proxy during the whole
+  	   dialog, regardless of what the SIP rfc says
+  	 */
+  	if (p->outboundproxy && !p->outboundproxy->force)
+  		p->outboundproxy = NULL;
+
 	for (cur = p->packets; cur; prev = cur, cur = cur->next) {
 		if (cur->seqno != seqno || ast_test_flag(cur, FLAG_RESPONSE) != resp)
 			continue;
@@ -2487,6 +2563,11 @@
 {
 	int res;
 
+	/* If we have an outbound proxy, reset peer address
+		 Only do this once.
+	 */
+  	if (p->outboundproxy)
+		 p->sa = p->outboundproxy->ip;
 	add_blank(req);
 	if (sip_debug_test_pvt(p)) {
 		const struct sockaddr_in *dst = sip_real_dst(p);
@@ -2760,6 +2841,10 @@
 {
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
+
+	if (peer->outboundproxy)
+		free(peer->outboundproxy);
+	peer->outboundproxy = NULL;
 
 	/* Delete it, it needs to disappear */
 	if (peer->call)
@@ -3075,6 +3160,7 @@
 			ast_string_field_build(dialog, callid, "%s@%s", tmpcall, peer->fromdomain);
 		}
 	}
+	dialog->outboundproxy = obproxy_get(dialog, peer);
 	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))
@@ -3128,6 +3214,17 @@
 		unref_peer(peer);
 		return res;
 	}
+
+	/* Get the outbound proxy information */
+  	dialog->outboundproxy = obproxy_get(dialog, NULL);
+  	 
+  	/* If we have an outbound proxy, don't bother with DNS resolution at all */
+  	if (dialog->outboundproxy)
+  		return 0;
+  	 
+  	/* Let's see if we can find the host in DNS. First try DNS SRV records,
+  	   then hostname lookup */
+
 	hostn = peername;
 	portno = port ? atoi(port) : STANDARD_SIP_PORT;
 	if (global_srvlookup) {
@@ -5221,7 +5318,6 @@
 	int iterator;
 	int sendonly = 0;
 	int numberofports;
-	struct ast_channel *bridgepeer = NULL;
 	struct ast_rtp *newaudiortp, *newvideortp;	/* Buffers for codec handling */
 	int newjointcapability;				/* Negotiated capability */
 	int newpeercapability;
@@ -5712,8 +5808,6 @@
 		ast_set_write_format(p->owner, p->owner->writeformat);
 	}
 	
-	/* Turn on/off music on hold if we are holding/unholding */
-	if ((bridgepeer = ast_bridged_channel(p->owner))) {
 		if (sin.sin_addr.s_addr && !sendonly) {
 			ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
 			/* Activate a re-invite */
@@ -5728,7 +5822,6 @@
 			/* Activate a re-invite */
 			ast_queue_frame(p->owner, &ast_null_frame);
 		}
-	}
 
 	/* Manager Hold and Unhold events must be generated, if necessary */
 	if (sin.sin_addr.s_addr && !sendonly) {
@@ -7681,17 +7774,20 @@
 		/* Allocate SIP dialog for registration */
 		if (!(p = sip_alloc(r->callid, NULL, 0, SIP_REGISTER))) {
 			ast_log(LOG_WARNING, "Unable to allocate registration transaction (memory or socket error)\n");
-		} else if (create_addr(p, r->hostname)) {	/* lookup the address */
-			/* Address lookup error, hopefully just a DNS problem, so retry later */
-			ast_log(LOG_WARNING, "Probably a DNS error for registration to %s@%s, trying REGISTER again after %d seconds)\n",
+		} else {
+			append_history(p, "RegistryInit", "Account: %s@%s", r->username, r->hostname);
+			p->outboundproxy = obproxy_get(p, NULL);
+			if (create_addr(p, r->hostname)) {	/* lookup the address */
+				/* Address lookup error, hopefully just a DNS problem, so retry later */
+				ast_log(LOG_WARNING, "Probably a DNS error for registration to %s@%s, trying REGISTER again after %d seconds)\n",
 					r->username, r->hostname, global_reg_timeout);
-			p = sip_destroy(p);	/* and the reference goes */
+				p = sip_destroy(p);	/* and the reference goes */
+			}
 		}
 		if (p == NULL) {
 			r->timeout = ast_sched_add(sched, global_reg_timeout*1000, sip_reg_timeout, r);
 			return 0;	/* non fatal error */
 		}
-		append_history(p, "RegistryInit", "Account: %s@%s", r->username, r->hostname);
 		/* Copy back Call-ID in case create_addr changed it */
 		ast_string_field_set(r, callid, p->callid);
 		if (r->portno)
@@ -10649,8 +10745,8 @@
 		ast_cli(fd, "  VM Extension : %s\n", peer->vmexten);
 		ast_cli(fd, "  LastMsgsSent : %d/%d\n", (peer->lastmsgssent & 0x7fff0000) >> 16, peer->lastmsgssent & 0xffff);
 		ast_cli(fd, "  Call limit   : %d\n", peer->call_limit);
-		if (peer->busy_limit)
-			ast_cli(fd, "  Busy limit   : %d\n", peer->busy_limit);
+		if (peer->busy_level)
+			ast_cli(fd, "  Busy level   : %d\n", peer->busy_level);
 		ast_cli(fd, "  Dynamic      : %s\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)?"Yes":"No"));
 		ast_cli(fd, "  Callerid     : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
 		ast_cli(fd, "  RegisterFrom : %s\n", S_OR(peer->register_from_hdr, ""));
@@ -10672,6 +10768,10 @@
 		ast_cli(fd, "  Send RPID    : %s\n", ast_test_flag(&peer->flags[0], SIP_SENDRPID) ? "Yes" : "No");
 		ast_cli(fd, "  Subscriptions: %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE) ? "Yes" : "No");
 		ast_cli(fd, "  Overlap dial : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWOVERLAP) ? "Yes" : "No");
+		if (peer->outboundproxy)
+			ast_cli(fd, "  Outb. proxy  : %s %s\n",
+				ast_strlen_zero(peer->outboundproxy->name) ? "<not set>" : peer->outboundproxy->name,
+				peer->outboundproxy->force ? "(forced)" : "");
 
 		/* - is enumerated */
 		ast_cli(fd, "  DTMFmode     : %s\n", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF)));
@@ -10741,7 +10841,7 @@
 		astman_append(s, "TransferMode: %s\r\n", transfermode2str(peer->allowtransfer));
 		astman_append(s, "LastMsgsSent: %d\r\n", peer->lastmsgssent);
 		astman_append(s, "Call-limit: %d\r\n", peer->call_limit);
-		astman_append(s, "Busy-limit: %d\r\n", peer->busy_limit);
+		astman_append(s, "Busy-level: %d\r\n", peer->busy_level);
 		astman_append(s, "MaxCallBR: %d kbps\r\n", peer->maxcallbitrate);
 		astman_append(s, "Dynamic: %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)?"Y":"N"));
 		astman_append(s, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, ""));
@@ -10968,8 +11068,10 @@
 	ast_cli(fd, "  Notify ringing state:   %s\n", global_notifyringing ? "Yes" : "No");
 	ast_cli(fd, "  Notify hold state:      %s\n", global_notifyhold ? "Yes" : "No");
 	ast_cli(fd, "  SIP Transfer mode:      %s\n", transfermode2str(global_allowtransfer));
-	ast_cli(fd, "  Max Call Bitrate:       %d kbps\r\n", default_maxcallbitrate);
-	ast_cli(fd, "  Auto-Framing:           %s \r\n", global_autoframing ? "Yes" : "No");
+	ast_cli(fd, "  Max Call Bitrate:       %d kbps\n", default_maxcallbitrate);
+	ast_cli(fd, "  Auto-Framing:           %s\n", global_autoframing ? "Yes" : "No");
+	ast_cli(fd, "  Outb. proxy:            %s %s\n", ast_strlen_zero(global_outboundproxy.name) ? "<not set>" : global_outboundproxy.name,
+  	                                                         global_outboundproxy.force ? "(forced)" : "");
 	ast_cli(fd, "\nDefault Settings:\n");
 	ast_cli(fd, "-----------------\n");
 	ast_cli(fd, "  Context:                %s\n", default_context);
@@ -16012,6 +16114,13 @@
 
 	If we return AST_DEVICE_UNKNOWN, the device state engine will try to find
 	out a state by walking the channel list.
+
+	The queue system (\ref app_queue.c) treats a member as "active"
+  	if devicestate is != AST_DEVICE_UNAVAILBALE && != AST_DEVICE_INVALID
+  	 
+  	When placing a call to the queue member, queue system sets a member to busy if
+  	!= AST_DEVICE_NOT_INUSE and != AST_DEVICE_UNKNOWN
+  	 
 */
 static int sip_devicestate(void *data)
 {
@@ -16053,7 +16162,7 @@
 					res = AST_DEVICE_RINGINUSE;
 			} else if (p->call_limit && (p->inUse == p->call_limit)) /* check call limit */
 				res = AST_DEVICE_BUSY;
-			else if (p->call_limit && p->busy_limit && p->inUse >= p->busy_limit)
+			else if (p->call_limit && p->busy_level && p->inUse >= p->busy_level)
 				/* We're forcing busy before we've reached the call limit */
 				res = AST_DEVICE_BUSY;
 			else if (p->call_limit && p->inUse)	/* Not busy, but we do have a call */
@@ -16675,7 +16784,6 @@
 {
 	struct sip_peer *peer = NULL;
 	struct ast_ha *oldha = NULL;
-	int obproxyfound=0;
 	int found=0;
 	int firstpass=1;
 	int format=0;		/* Ama flags */
@@ -16755,22 +16863,36 @@
 		M_STR("fromdomain", peer->fromdomain)
 		M_F("usereqphone", ast_set2_flag(&peer->flags[0], ast_true(v->value), SIP_USEREQPHONE);)
 		M_STR("fromuser", peer->fromuser)
-		M_F("|host|outboundproxy|", {
+#if 0 /* XXX fixme */
+		M_F("outboundproxy", {
+			char *port, *next, *force, *proxyname;
+			int forceopt = FALSE;
+			/* Set peer channel variable */
+			/* XXX use strsep here... */
+			next = proxyname = ast_strdupa(v->value);
+			if ((port = strchr(proxyname, ':'))) {
+				*port++ = '\0';
+				next = port;
+			}
+			if ((force = strchr(next, ','))) {
+				*force++ = '\0';
+				forceopt = strcmp(force, "force");
+			}
+			/* Allocate proxy object */
+			peer->outboundproxy = proxy_allocate(proxyname, port, forceopt);
+		} )
+		M_F("host", {{
 			if (!strcasecmp(v->value, "dynamic")) {
-				if (!strcasecmp(v->name, "outboundproxy") || obproxyfound) {
-					ast_log(LOG_WARNING, "You can't have a dynamic outbound proxy, you big silly head at line %d.\n", v->lineno);
-				} else {
-					/* They'll register with us */
-					ast_set_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
-					if (!found) {
-						/* Initialize stuff iff we're not found, otherwise
-						   we keep going with what we had */
-						memset(&peer->addr.sin_addr, 0, 4);
-						if (peer->addr.sin_port) {
-							/* If we've already got a port, make it the default rather than absolute */
-							peer->defaddr.sin_port = peer->addr.sin_port;
-							peer->addr.sin_port = 0;
-						}
+				/* They'll register with us */
+				ast_set_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
+				if (!found) {
+					/* Initialize stuff iff we're not found, otherwise
+					   we keep going with what we had */
+					memset(&peer->addr.sin_addr, 0, 4);
+					if (peer->addr.sin_port) {
+						/* If we've already got a port, make it the default rather than absolute */
+						peer->defaddr.sin_port = peer->addr.sin_port;
+						peer->addr.sin_port = 0;
 					}
 				}
 			} else {
@@ -16779,20 +16901,11 @@
 					ast_sched_del(sched, peer->expire);
 				peer->expire = -1;
 				ast_clear_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
-				if (!obproxyfound || !strcasecmp(v->name, "outboundproxy")) {
-					if (ast_get_ip_or_srv(&peer->addr, v->value, global_srvlookup ? "_sip._udp" : NULL)) {
-						unref_peer(peer);
-						return NULL;
-					}
-				}
-				if (!strcasecmp(v->name, "outboundproxy"))
-					obproxyfound=1;
-				else {
-					ast_copy_string(peer->tohost, v->value, sizeof(peer->tohost));
-					if (!peer->addr.sin_port)
-						peer->addr.sin_port = htons(STANDARD_SIP_PORT);
-				}
+				ast_copy_string(peer->tohost, v->value, sizeof(peer->tohost));
+				if (!peer->addr.sin_port)
+					peer->addr.sin_port = htons(STANDARD_SIP_PORT);
 			}} )
+#endif
 		M_F("defaultip", {
 			if (ast_get_ip(&peer->defaddr, v->value)) {
 				unref_peer(peer);
@@ -16811,6 +16924,7 @@
 		M_STR("regexten", peer->regexten)
 		M_STR("callbackextension", callback)
 		M_INT_GE0("call-limit", peer->call_limit, 0)
+		M_INT_GE0("busy-limit", peer->busy_level, 0)
 		M_F("amaflags", {
 			format = ast_cdr_amaflags2int(v->value);
 			if (format < 0) {
@@ -16893,7 +17007,6 @@
 	char *cat, *stringp, *context, *oldregcontext;
 	char newcontexts[AST_MAX_CONTEXT], oldcontexts[AST_MAX_CONTEXT];
 	struct hostent *hp;
-	int format;
 	struct ast_flags dummy[2];
 	int auto_sip_domains = FALSE;
 	struct sockaddr_in old_bindaddr = bindaddr;
@@ -16924,8 +17037,9 @@
 	memset(&localaddr, 0, sizeof(localaddr));
 	memset(&externip, 0, sizeof(externip));
 	memset(&default_prefs, 0 , sizeof(default_prefs));
-	outboundproxyip.sin_port = htons(STANDARD_SIP_PORT);
-	outboundproxyip.sin_family = AF_INET;	/* Type of address: IPv4 */
+	memset(&global_outboundproxy, 0, sizeof(struct sip_proxy));
+	global_outboundproxy.ip.sin_port = htons(STANDARD_SIP_PORT);
+	global_outboundproxy.ip.sin_family = AF_INET;   /* Type of address: IPv4 */
 	ourport = STANDARD_SIP_PORT;
 	global_srvlookup = DEFAULT_SRVLOOKUP;
 	global_tos_sip = DEFAULT_TOS_SIP;
@@ -16934,7 +17048,6 @@
 	externhost[0] = '\0';			/* External host name (for behind NAT DynDNS support) */
 	externexpire = 0;			/* Expiration for DNS re-issuing */
 	externrefresh = 10;
-	memset(&outboundproxyip, 0, sizeof(outboundproxyip));
 
 	/* Reset channel settings to default before re-configuring */
 	allow_external_domains = DEFAULT_ALLOW_EXT_DOM;				/* Allow external invites */
@@ -17054,13 +17167,23 @@
 			ast_copy_string(global_regcontext, v->value, sizeof(global_regcontext)); } )
 		M_STR("callerid", default_callerid)
 		M_STR("fromdomain", default_fromdomain)
+#if 0 /* XXX fixme */
 		M_F("outboundproxy", {
-			if (ast_get_ip_or_srv(&outboundproxyip, v->value, global_srvlookup ? "_sip._udp" : NULL) < 0)
-				ast_log(LOG_WARNING, "Unable to locate host '%s'\n", v->value); } )
-		M_F("outboundproxyport", {
-			/* XXX Port needs to be after IP */
-			sscanf(v->value, "%d", &format);
-			outboundproxyip.sin_port = htons(format); } )
+			char *name, *port = NULL, *force;
+			name = ast_strdupa(v->value);
+			/* XXX use strsep here */
+			if ((port = strchr(name, ':'))) {
+				*port++ = '\0';
+				global_outboundproxy.ip.sin_port = htons(atoi(port));
+			}
+			if ((force = strchr(port ? port : name, ','))) {
+				*force++ = '\0';
+				 global_outboundproxy.force = (!strcasecmp(force, "force"));
+			 }
+			 ast_copy_string(global_outboundproxy.name, name, sizeof(global_outboundproxy.name));
+			 proxy_update(&global_outboundproxy);
+			} )
+#endif
 		M_BOOL("autocreatepeer", autocreatepeer)
 		M_BOOL("match_auth_username", global_match_auth_username)
 		M_BOOL("srvlookup", global_srvlookup)
@@ -17639,9 +17762,15 @@
 	if (i == -1 || i == SIP_DTMF_AUTO)	/* XXX should we filter this out ? */
 		ast_log(LOG_WARNING, "I don't know about this dtmf mode: %s\n", mode);
 	else {
+		p->jointnoncodeccapability &= ~AST_RTP_DTMF;
 		ast_clear_flag(&p->flags[0], SIP_DTMF);
 		ast_set_flag(&p->flags[0], i);
-	}
+		/* XXX check in svn53139 why this is special */
+		if (i == SIP_DTMF_RFC2833)
+			p->jointnoncodeccapability |= AST_RTP_DTMF;
+	}
+	if (p->rtp)
+		ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
 	/* XXX shouldn't it also look for a change in the mode ? */
 	if (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) {
 		if (!p->vad) {



More information about the svn-commits mailing list