[asterisk-commits] russell: branch russell/chan_console r53977 - in /team/russell/chan_console: ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Feb 11 17:35:40 MST 2007


Author: russell
Date: Sun Feb 11 18:35:39 2007
New Revision: 53977

URL: http://svn.digium.com/view/asterisk?view=rev&rev=53977
Log:
Merged revisions 53851,53882-53885,53914,53932-53933,53953 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r53851 | kpfleming | 2007-02-10 00:14:55 -0600 (Sat, 10 Feb 2007) | 11 lines

Merged revisions 53850 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r53850 | kpfleming | 2007-02-10 00:06:08 -0600 (Sat, 10 Feb 2007) | 3 lines

don't display the --with-imap message unless --with-imap was specified without a path
use '-n' instead of '! -z' for tests

........

................
r53882 | pcadach | 2007-02-10 03:19:58 -0600 (Sat, 10 Feb 2007) | 8 lines

Blocked revisions 53878 via svnmerge

........
r53878 | pcadach | 2007-02-10 01:04:47 -0800 (Сбт, 10 Фев 2007) | 1 line

Bring deprecated 'debug channel <x|all>' command back
........

................
r53883 | pcadach | 2007-02-10 03:21:22 -0600 (Sat, 10 Feb 2007) | 9 lines

Merged revisions 53879 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r53879 | pcadach | 2007-02-10 01:07:11 -0800 (Сбт, 10 Фев 2007) | 1 line

Provide correct DTMF duration
........

................
r53884 | pcadach | 2007-02-10 03:22:15 -0600 (Sat, 10 Feb 2007) | 9 lines

Merged revisions 53880 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r53880 | pcadach | 2007-02-10 01:08:55 -0800 (Сбт, 10 Фев 2007) | 1 line

Much simpler than previous one ;-)
........

................
r53885 | pcadach | 2007-02-10 03:23:09 -0600 (Sat, 10 Feb 2007) | 9 lines

Merged revisions 53881 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r53881 | pcadach | 2007-02-10 01:09:49 -0800 (Сбт, 10 Фев 2007) | 1 line

Fix VLDTMF reception
........

................
r53914 | oej | 2007-02-11 13:15:55 -0600 (Sun, 11 Feb 2007) | 2 lines

Fix debug handling in acl.c

................
r53932 | oej | 2007-02-11 13:42:55 -0600 (Sun, 11 Feb 2007) | 5 lines

Add support for outbound proxy for peers and [general]

This replaces the older, broken, implementation where a setting in
[general] did not do anything and the [peer] part was broken.

................
r53933 | oej | 2007-02-11 14:04:49 -0600 (Sun, 11 Feb 2007) | 2 lines

Small fix in outbound proxy support.

................
r53953 | oej | 2007-02-11 14:49:38 -0600 (Sun, 11 Feb 2007) | 2 lines

Be careful with debug messages in trunk, they tend to stay around for release....

................

Modified:
    team/russell/chan_console/   (props changed)
    team/russell/chan_console/apps/app_echo.c
    team/russell/chan_console/channels/chan_h323.c
    team/russell/chan_console/channels/chan_sip.c
    team/russell/chan_console/configs/sip.conf.sample
    team/russell/chan_console/configure
    team/russell/chan_console/configure.ac
    team/russell/chan_console/main/acl.c
    team/russell/chan_console/main/channel.c

Propchange: team/russell/chan_console/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/russell/chan_console/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/russell/chan_console/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Feb 11 18:35:39 2007
@@ -1,1 +1,1 @@
-/trunk:1-53845
+/trunk:1-53976

Modified: team/russell/chan_console/apps/app_echo.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/apps/app_echo.c?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/apps/app_echo.c (original)
+++ team/russell/chan_console/apps/app_echo.c Sun Feb 11 18:35:39 2007
@@ -69,21 +69,14 @@
 			break;
 		f->delivery.tv_sec = 0;
 		f->delivery.tv_usec = 0;
-		switch (f->frametype) {
-		case AST_FRAME_DTMF:
-			if (f->subclass == '#') {
-				res = 0;
-				if (ast_write(chan, f))
-					res = -1;
-				ast_frfree(f);
-				goto end;
-			}
-			/* fall through */
-		default:
-			if (ast_write(chan, f)) {
-				ast_frfree(f);
-				goto end;
-			}
+		if (ast_write(chan, f)) {
+			ast_frfree(f);
+			goto end;
+		}
+		if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) {
+			res = 0;
+			ast_frfree(f);
+			goto end;
 		}
 		ast_frfree(f);
 	}

Modified: team/russell/chan_console/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_h323.c?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/channels/chan_h323.c (original)
+++ team/russell/chan_console/channels/chan_h323.c Sun Feb 11 18:35:39 2007
@@ -367,6 +367,7 @@
 			.frametype = AST_FRAME_DTMF_END,
 			.subclass = pvt->newdigit,
 			.samples = pvt->newduration * 8,
+			.len = pvt->newduration,
 			.src = "UPDATE_INFO",
 		};
 		if (pvt->newdigit == ' ') {		/* signalUpdate message */
@@ -561,14 +562,14 @@
 	if (pvt->rtp && (pvt->options.dtmfmode & H323_DTMF_RFC2833) && ((pvt->dtmf_pt[0] > 0) || (pvt->dtmf_pt[0] > 0))) {
 		/* out-of-band DTMF */
 		if (h323debug) {
-			ast_log(LOG_DTMF, "End sending out-of-band digit %c on %s\n", digit, c->name);
+			ast_log(LOG_DTMF, "End sending out-of-band digit %c on %s, duration %d\n", digit, c->name, duration);
 		}
 		ast_rtp_senddigit_end(pvt->rtp, digit);
 		ast_mutex_unlock(&pvt->lock);
 	} else {
 		/* in-band DTMF */
 		if (h323debug) {
-			ast_log(LOG_DTMF, "End sending inband digit %c on %s\n", digit, c->name);
+			ast_log(LOG_DTMF, "End sending inband digit %c on %s, duration %d\n", digit, c->name, duration);
 		}
 		pvt->txDtmfDigit = ' ';
 		token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
@@ -1847,6 +1848,7 @@
 				.frametype = AST_FRAME_DTMF_END,
 				.subclass = digit,
 				.samples = duration * 8,
+				.len = duration,
 				.src = "SEND_DIGIT",
 			};
 			if (digit == ' ') {		/* signalUpdate message */
@@ -1856,10 +1858,20 @@
 					pvt->DTMFsched = -1;
 				}
 			} else {				/* Regular input or signal message */
+				if (pvt->DTMFsched >= 0) {
+					/* We still don't send DTMF END from previous event, send it now */
+					ast_sched_del(sched, pvt->DTMFsched);
+					pvt->DTMFsched = -1;
+					f.subclass = pvt->curDTMF;
+					f.samples = f.len = 0;
+					ast_queue_frame(pvt->owner, &f);
+					/* Restore values */
+					f.subclass = digit;
+					f.samples = duration * 8;
+					f.len = duration;
+				}
 				if (duration) {		/* This is a signal, signalUpdate follows */
 					f.frametype = AST_FRAME_DTMF_BEGIN;
-					if (pvt->DTMFsched >= 0)
-						ast_sched_del(sched, pvt->DTMFsched);
 					pvt->DTMFsched = ast_sched_add(sched, duration, oh323_simulate_dtmf_end, pvt);
 					if (h323debug)
 						ast_log(LOG_DTMF, "Scheduled DTMF END simulation for %d ms, id=%d\n", duration, pvt->DTMFsched);
@@ -2454,6 +2466,8 @@
 		if (h323debug) {
 			int i;
 			for (i = 0; i < 32; ++i) {
+				if (!prefs->order[i])
+					break;
 				ast_log(LOG_DEBUG, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
 			}
 		}

Modified: team/russell/chan_console/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_sip.c?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/channels/chan_sip.c (original)
+++ team/russell/chan_console/channels/chan_sip.c Sun Feb 11 18:35:39 2007
@@ -354,6 +354,20 @@
 	REG_STATE_FAILED,	/*!< Registration failed after several tries */
 };
 
+/*! \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 */
+};
+
 enum can_create_dialog {
 	CAN_NOT_CREATE_DIALOG,
 	CAN_CREATE_DIALOG,
@@ -560,6 +574,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;
@@ -947,6 +962,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 */
@@ -1116,6 +1132,7 @@
 	int rtpkeepalive;		/*!<  Send RTP packets for keepalive */
 	ast_group_t callgroup;		/*!<  Call group */
 	ast_group_t pickupgroup;	/*!<  Pickup group */
+	struct sip_proxy *outboundproxy;	/*!< Outbound proxy for this peer */
 	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 */
@@ -1206,7 +1223,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;
 
@@ -1656,6 +1672,14 @@
 	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)));
+
+
 /*! \brief Convert transfer status to string */
 static const char *referstatus2str(enum referstatus rstatus)
 {
@@ -1695,6 +1719,57 @@
 	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'.
@@ -1786,6 +1861,9 @@
 /*! \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;
 }
 
@@ -1864,13 +1942,6 @@
 		*us = bindaddr.sin_addr;
 	return AST_SUCCESS;
 }
-
-/*! \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)));
 
 /*! \brief Append to SIP dialog history with arg list  */
 static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
@@ -2115,6 +2186,15 @@
 	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;
@@ -2238,6 +2318,13 @@
 {
 	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)) {
 		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
@@ -2479,6 +2566,9 @@
 {
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
+
+	if (peer->outboundproxy)
+		free(peer->outboundproxy);
 
 	/* Delete it, it needs to disappear */
 	if (peer->call)
@@ -2794,6 +2884,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))
@@ -2847,6 +2938,19 @@
 		unref_peer(peer);
 		return res;
 	}
+
+	ast_string_field_set(dialog, tohost, peername);
+
+	/* 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) {
@@ -2866,7 +2970,6 @@
 		ast_log(LOG_WARNING, "No such host: %s\n", peername);
 		return -1;
 	}
-	ast_string_field_set(dialog, tohost, peername);
 	memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr));
 	dialog->sa.sin_port = htons(portno);
 	dialog->recv = dialog->sa;
@@ -5309,12 +5412,14 @@
 	}
 	
 	if (sin.sin_addr.s_addr && !sendonly) {
-		ast_log(LOG_DEBUG, "Queueing UNHOLD!\n");
+		if (option_debug > 1)
+			ast_log(LOG_DEBUG, "Setting call off HOLD! - %s\n", p->callid);
 		ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
 		/* Activate a re-invite */
 		ast_queue_frame(p->owner, &ast_null_frame);
 	} else if (!sin.sin_addr.s_addr || sendonly) {
-		ast_log(LOG_DEBUG, "Going on HOLD!\n");
+		if (option_debug > 1)
+			ast_log(LOG_DEBUG, "Setting call on HOLD! - %s\n", p->callid);
 		ast_queue_control_data(p->owner, AST_CONTROL_HOLD, 
 				       S_OR(p->mohsuggest, NULL),
 				       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
@@ -7310,6 +7415,9 @@
 		}
 		if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY))
 			append_history(p, "RegistryInit", "Account: %s@%s", r->username, r->hostname);
+
+		p->outboundproxy = obproxy_get(p, NULL);
+
 		/* Find address to hostname */
 		if (create_addr(p, r->hostname)) {
 			/* we have what we hope is a temporary network error,
@@ -7444,8 +7552,9 @@
 	add_header_contentLength(&req, 0);
 
 	initialize_initreq(p, &req);
-	if (sip_debug_test_pvt(p))
+	if (sip_debug_test_pvt(p)) {
 		ast_verbose("REGISTER %d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
+	}
 	r->regstate = auth ? REG_STATE_AUTHSENT : REG_STATE_REGSENT;
 	r->regattempts++;	/* Another attempt */
 	if (option_debug > 3)
@@ -10240,6 +10349,9 @@
 		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)));
@@ -10533,8 +10645,11 @@
 	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);
@@ -16028,7 +16143,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 */
@@ -16113,22 +16227,33 @@
 			ast_set2_flag(&peer->flags[0], ast_true(v->value), SIP_USEREQPHONE);
 		} else if (!strcasecmp(v->name, "fromuser")) {
 			ast_copy_string(peer->fromuser, v->value, sizeof(peer->fromuser));
-		} else if (!strcasecmp(v->name, "host") || !strcasecmp(v->name, "outboundproxy")) {
+		} else if (!strcasecmp(v->name, "outboundproxy")) {
+			char *port, *next, *force, *proxyname;
+			int forceopt = FALSE;
+			/* Set peer channel variable */
+			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);
+		} else if (!strcasecmp(v->name, "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 {
@@ -16137,19 +16262,9 @@
 					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);
 			}
 		} else if (!strcasecmp(v->name, "defaultip")) {
 			if (ast_get_ip(&peer->defaddr, v->value)) {
@@ -16300,7 +16415,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;
@@ -16331,8 +16445,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;
@@ -16341,7 +16456,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 */
@@ -16507,12 +16621,21 @@
 		} else if (!strcasecmp(v->name, "fromdomain")) {
 			ast_copy_string(default_fromdomain, v->value, sizeof(default_fromdomain));
 		} else if (!strcasecmp(v->name, "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);
-		} else if (!strcasecmp(v->name, "outboundproxyport")) {
-			/* 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);
+			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);
+
 		} else if (!strcasecmp(v->name, "autocreatepeer")) {
 			autocreatepeer = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "match_auth_username")) {

Modified: team/russell/chan_console/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/configs/sip.conf.sample?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/configs/sip.conf.sample (original)
+++ team/russell/chan_console/configs/sip.conf.sample Sun Feb 11 18:35:39 2007
@@ -148,6 +148,10 @@
 				; for Sipura and Grandstream ATAs, among others). This is
 				; contrary to the RFC3551 specification, the peer _should_
 				; be negotiating AAL2-G726-32 instead :-(
+
+;outboundproxy=proxy.provider.domain           ; send outbound signaling to this proxy, not directly to the devices
+;outboundproxy=proxy.provider.domain:8080       ; send outbound signaling to this proxy, not directly to the devices
+;outboundproxy=proxy.provider.domain,force      ; Send ALL outbound signalling to proxy, ignoring route: headers
 
 ;
 ; If regcontext is specified, Asterisk will dynamically create and destroy a
@@ -536,10 +540,10 @@
 ;host=box.provider.com
 ;usereqphone=yes			; This provider requires ";user=phone" on URI
 ;call-limit=5				; permit only 5 simultaneous outgoing calls to this peer
+					; Call-limits will not be enforced on real-time peers,
+					; since they are not stored in-memory
 ;busy-level=2				; Signal busy at 2 or more calls
 ;outboundproxy=proxy.provider.domain	; send outbound signaling to this proxy, not directly to the peer
-					; Call-limits will not be enforced on real-time peers,
-					; since they are not stored in-memory
 ;port=80				; The port number we want to connect to on the remote side
 					; Also used as "defaultport" in combination with "defaultip" settings
 

Modified: team/russell/chan_console/configure
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/configure?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/configure (original)
+++ team/russell/chan_console/configure Sun Feb 11 18:35:39 2007
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 53031 .
+# From configure.ac Revision: 53746 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.60.
 #
@@ -21006,14 +21006,16 @@
 if test "${USE_IMAP_TK}" != "no"; then
    if test "${IMAP_TK_DIR}" = ""; then
       IMAP_TK_DIR=`pwd`"/../imap-2004g"
-      { echo "$as_me:$LINENO: The --with-imap option does not search your system for installed" >&5
+      if test  -n "${IMAP_TK_MANDATORY}"; then
+	 { echo "$as_me:$LINENO: The --with-imap option does not search your system for installed" >&5
 echo "$as_me: The --with-imap option does not search your system for installed" >&6;}
-      { echo "$as_me:$LINENO: c-client library/header files. Since you did not provide a path" >&5
+	 { echo "$as_me:$LINENO: c-client library/header files. Since you did not provide a path" >&5
 echo "$as_me: c-client library/header files. Since you did not provide a path" >&6;}
-      { echo "$as_me:$LINENO: the configure script will assume you have placed built the c-client" >&5
+	 { echo "$as_me:$LINENO: the configure script will assume you have placed built the c-client" >&5
 echo "$as_me: the configure script will assume you have placed built the c-client" >&6;}
-      { echo "$as_me:$LINENO: files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file." >&5
+	 { echo "$as_me:$LINENO: files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file." >&5
 echo "$as_me: files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file." >&6;}
+      fi
    fi
    { echo "$as_me:$LINENO: checking for UW IMAP Toolkit c-client library" >&5
 echo $ECHO_N "checking for UW IMAP Toolkit c-client library... $ECHO_C" >&6; }
@@ -29863,7 +29865,7 @@
 
 
 if test "${USE_PWLIB}" != "no"; then
-	if test ! -z "${PWLIB_DIR}"; then
+	if test -n "${PWLIB_DIR}"; then
 		PWLIBDIR="${PWLIB_DIR}"
 	fi
 
@@ -30424,7 +30426,7 @@
 fi
 
 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
-	if test ! -z "${OPENH323_DIR}"; then
+	if test -n "${OPENH323_DIR}"; then
 		OPENH323DIR="${OPENH323_DIR}"
 	fi
 

Modified: team/russell/chan_console/configure.ac
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/configure.ac?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/configure.ac (original)
+++ team/russell/chan_console/configure.ac Sun Feb 11 18:35:39 2007
@@ -429,10 +429,12 @@
 if test "${USE_IMAP_TK}" != "no"; then
    if test "${IMAP_TK_DIR}" = ""; then
       IMAP_TK_DIR=`pwd`"/../imap-2004g"
-      AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
-      AC_MSG_NOTICE([c-client library/header files. Since you did not provide a path])
-      AC_MSG_NOTICE([the configure script will assume you have placed built the c-client])
-      AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
+      if test  -n "${IMAP_TK_MANDATORY}"; then
+	 AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
+	 AC_MSG_NOTICE([c-client library/header files. Since you did not provide a path])
+	 AC_MSG_NOTICE([the configure script will assume you have placed built the c-client])
+	 AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
+      fi
    fi
    AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
    saved_cppflags="${CPPFLAGS}"
@@ -712,7 +714,7 @@
 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_new], [libss7.h])
 
 if test "${USE_PWLIB}" != "no"; then
-	if test ! -z "${PWLIB_DIR}"; then
+	if test -n "${PWLIB_DIR}"; then
 		PWLIBDIR="${PWLIB_DIR}"
 	fi
 	AST_CHECK_PWLIB()
@@ -731,7 +733,7 @@
 fi
 
 if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
-	if test ! -z "${OPENH323_DIR}"; then
+	if test -n "${OPENH323_DIR}"; then
 		OPENH323DIR="${OPENH323_DIR}"
 	fi
 	AST_CHECK_OPENH323()

Modified: team/russell/chan_console/main/acl.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/main/acl.c?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/main/acl.c (original)
+++ team/russell/chan_console/main/acl.c Sun Feb 11 18:35:39 2007
@@ -212,7 +212,8 @@
 		/* DEBUG */
 		ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf));
 		ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2));
-		ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
 		/* For each rule, if this address and the netmask = the net address
 		   apply the current rule */
 		if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)

Modified: team/russell/chan_console/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/main/channel.c?view=diff&rev=53977&r1=53976&r2=53977
==============================================================================
--- team/russell/chan_console/main/channel.c (original)
+++ team/russell/chan_console/main/channel.c Sun Feb 11 18:35:39 2007
@@ -2132,7 +2132,7 @@
 			}
 			break;
 		case AST_FRAME_DTMF_END:
-			ast_log(LOG_DTMF, "DTMF end '%c' received on %s\n", f->subclass, chan->name);
+			ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass, chan->name, f->len);
 			/* Queue it up if DTMF is deffered, or if DTMF emulation is forced.
 			 * However, only let emulation be forced if the other end cares about BEGIN frames */
 			if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF) ||
@@ -2155,7 +2155,7 @@
 			} else {
 				ast_clear_flag(chan, AST_FLAG_IN_DTMF);
 				if (!f->len)
-					f->len = ast_tvdiff_ms(chan->dtmf_begin_tv, ast_tvnow());
+					f->len = ast_tvdiff_ms(ast_tvnow(), chan->dtmf_begin_tv);
 			}
 			break;
 		case AST_FRAME_DTMF_BEGIN:
@@ -2186,6 +2186,7 @@
 					chan->emulate_dtmf_duration = 0;
 					f->frametype = AST_FRAME_DTMF_END;
 					f->subclass = chan->emulate_dtmf_digit;
+					f->len = ast_tvdiff_ms(ast_tvnow(), chan->dtmf_begin_tv);
 				} else {
 					chan->emulate_dtmf_duration -= f->samples / 8; /* XXX 8kHz */
 					ast_frfree(f);



More information about the asterisk-commits mailing list