No subject


Thu Jan 15 22:29:28 CST 2009


      Limiting the time period of extending the tone is necessary
      to avoid that a tone "gets stuck". Regardless of the
      algorithm used, the tone SHOULD NOT be extended by more than
      three packet interarrival times. A slight extension of tone
      durations and shortening of pauses is generally harmless.

Three seconds will pretty much _always_ be far more than three packet 
interarrival times.  However, that behavior is not required, so I'm going to
leave it with our legacy behavior for now.

Code from svn/asterisk/team/russell/issue_14460

(closes issue #14460)
Reported by: moliveras

........

................
r175127 | dvossel | 2009-02-12 10:07:17 -0700 (Thu, 12 Feb 2009) | 4 lines

Setting key rotation to be off by default

Key rotation breaks compatibility between (trunk/1.6.1) and (1.2/1.4/1.6.0).  As a follow up to this, I am investigating possible ways to allow key rotation to be on by default and not affect the other branches, but for now it must be turned off. 

................
r175188 | jpeeler | 2009-02-12 11:00:11 -0700 (Thu, 12 Feb 2009) | 12 lines

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

........
  r175187 | jpeeler | 2009-02-12 11:57:10 -0600 (Thu, 12 Feb 2009) | 6 lines
  
  Fix crash in event of failed attempt to transfer to parking
  
  The peer may not necessarily exist, such as in the case of a transfer to 
  ParkAndAnnounce. In this case don't try to play a sound to it.
........

................
r175250 | kpfleming | 2009-02-12 11:48:52 -0700 (Thu, 12 Feb 2009) | 1 line

correct warning message to not refer specifically to DAHDI
................
r175255 | russell | 2009-02-12 12:11:08 -0700 (Thu, 12 Feb 2009) | 4 lines

Don't enable something by default that has a dependency on something _not_ enabled by default.

menuselect was not happy with this.

................
r175295 | russell | 2009-02-12 13:45:47 -0700 (Thu, 12 Feb 2009) | 2 lines

Avoid using ast_strdupa() in a loop.

................
r175298 | jpeeler | 2009-02-12 13:48:56 -0700 (Thu, 12 Feb 2009) | 15 lines

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

........
  r175294 | jpeeler | 2009-02-12 14:34:36 -0600 (Thu, 12 Feb 2009) | 9 lines
  
  Fix ParkedCall event information for From field in the case of a blind transfer
  
  If the parker information can not be obtained from the peer, try and see if
  the BLINDTRANSFER channel variable has been set. Previously, a blind transfer
  to the ParkAndAnnounce app would return nothing for the From.
  
  Closes AST-189
........

................
r175334 | tilghman | 2009-02-12 14:25:14 -0700 (Thu, 12 Feb 2009) | 16 lines

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

........
  r175311 | tilghman | 2009-02-12 15:19:40 -0600 (Thu, 12 Feb 2009) | 9 lines
  
  Fix crashes when receiving certain T.38 packets.  Also, increase the maximum
  size of T.38 packets and warn users when they try to set the limits above those
  maximums.
  (closes issue #13050)
   Reported by: schern
   Patches: 
         20090212__bug13050.diff.txt uploaded by Corydon76 (license 14)
   Tested by: schern
........

................
r175344 | dvossel | 2009-02-12 14:27:11 -0700 (Thu, 12 Feb 2009) | 10 lines

Adds force encryption option to iax.conf

This patch adds forceencryption=yes as an iax.conf option.  When force encryption is enabled, no unencrypted connections are allowed.  This insures all connections are encrypted.  This is a new feature, so CHANGES and iax.conf.sample are updated as well.   

(closes issue #13285)
Reported by: sgofferj
Tested by: russell
Review: http://reviewboard.digium.com/r/150/


................
r175368 | russell | 2009-02-12 14:41:01 -0700 (Thu, 12 Feb 2009) | 2 lines

Remove useless string copy, and make sscanf safe again

................
r175408 | mmichelson | 2009-02-12 16:23:47 -0700 (Thu, 12 Feb 2009) | 17 lines

Blocked revisions 175407 via svnmerge

........
  r175407 | mmichelson | 2009-02-12 17:22:44 -0600 (Thu, 12 Feb 2009) | 12 lines
  
  Fix a place where filestreams were not refcounted properly
  
  This section was already present in trunk and other branches,
  but did not exist in 1.4.
  
  (closes issue #14395)
  Reported by: ZX81
  Patches:
        14395.patch uploaded by putnopvut (license 60)
  Tested by: ZX81
........

................
r175411 | dhubbard | 2009-02-12 17:13:38 -0700 (Thu, 12 Feb 2009) | 13 lines

Add dynamic fax buffer configuration option to chan_dahdi.conf

When the 'faxdetect' configuration option is used, one may also want to use
the 'faxbuffers' configuration option in chan_dahdi.conf.  This option will
dynamically use the configured 'faxbuffers' buffer policy on a channel for
the life of the call following the detection of fax tones.  The faxbuffers
buffer policy will be reverted during call teardown.

An example use of 'faxbuffers' is below.  This example would switch to using
6 buffers with a full buffer policy.

faxbuffers=>6,full

................
r175475 | dhubbard | 2009-02-12 21:22:35 -0700 (Thu, 12 Feb 2009) | 1 line

add 'faxbuffers' configuration option information to CHANGES
................
r175508 | kpfleming | 2009-02-13 06:35:24 -0700 (Fri, 13 Feb 2009) | 15 lines

Add basic (passthrough, playback, record) support for ITU G.722.1 and G.722.1C (also known as Siren7 and Siren14)

This patch adds passthrough, file recording and file playback support for the codecs listed above, with negotiation over SIP/SDP supported. Due to Asterisk's current limitation of treating a codec/bitrate combination as a unique codec, only G.722.1 at 32 kbps and G.722.1C at 48 kbps are supported.

Along the way, some related work was done:

1) The rtpPayloadType structure definition, used as a return result for an API call in rtp.h, was moved from rtp.c to rtp.h so that the API call was actually usable. The only previous used of the API all was chan_h323.c, which had a duplicate of the structure definition instead of doing it the right way.

2) The hardcoded SDP sample rates for various codecs in chan_sip.c were removed, in favor of storing these sample rates in rtp.c along with the codec definitions there. A new API call was added to allow retrieval of the sample rate for a given codec.

3) Some basic 'a=fmtp' parsing for SDP was added to chan_sip, because chan_sip *must* decline any media streams offered for these codecs that are not at the bitrates that we support (otherwise Bad Things (TM) would result).

Review: http://reviewboard.digium.com/r/158/


................
r175512 | kpfleming | 2009-02-13 06:41:52 -0700 (Fri, 13 Feb 2009) | 3 lines

document G.722.1/.1C support


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

Added:
    team/group/newcdr/formats/format_siren14.c
      - copied unchanged from r175512, trunk/formats/format_siren14.c
    team/group/newcdr/formats/format_siren7.c
      - copied unchanged from r175512, trunk/formats/format_siren7.c
Modified:
    team/group/newcdr/   (props changed)
    team/group/newcdr/CHANGES
    team/group/newcdr/apps/app_dial.c
    team/group/newcdr/apps/app_dictate.c
    team/group/newcdr/apps/app_queue.c
    team/group/newcdr/apps/app_waitforsilence.c
    team/group/newcdr/build_tools/cflags.xml
    team/group/newcdr/channels/chan_dahdi.c
    team/group/newcdr/channels/chan_gtalk.c
    team/group/newcdr/channels/chan_h323.c
    team/group/newcdr/channels/chan_iax2.c
    team/group/newcdr/channels/chan_sip.c
    team/group/newcdr/configs/chan_dahdi.conf.sample
    team/group/newcdr/configs/iax.conf.sample
    team/group/newcdr/include/asterisk/astobj2.h
    team/group/newcdr/include/asterisk/channel.h
    team/group/newcdr/include/asterisk/frame.h
    team/group/newcdr/include/asterisk/rtp.h
    team/group/newcdr/main/astobj2.c
    team/group/newcdr/main/channel.c
    team/group/newcdr/main/features.c
    team/group/newcdr/main/frame.c
    team/group/newcdr/main/pbx.c
    team/group/newcdr/main/rtp.c
    team/group/newcdr/main/udptl.c

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Feb 13 09:47:56 2009
@@ -1,1 +1,1 @@
-/trunk:1-174895
+/trunk:1-175544

Modified: team/group/newcdr/CHANGES
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/CHANGES?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/CHANGES (original)
+++ team/group/newcdr/CHANGES Fri Feb 13 09:47:56 2009
@@ -48,6 +48,7 @@
    first INVITE is generated - SIPRemoveHeader()
  * Channel variables set with setvar= in a device configuration is now 
    set both for inbound and outbound calls.
+ * Added support for ITU G.722.1 and G.722.1C (Siren7 and Siren14) media streams.
 
 Skinny Changes
 --------------
@@ -59,6 +60,13 @@
 -------------
  * The UK option waitfordialtone has been added for use with BT analog
    lines.
+ * Added a 'faxbuffers' configuration option to chan_dahdi.conf.  This option
+   is used in conjunction with the 'faxdetect' configuration option.  When
+   'faxbuffers' is used and fax tones are detected, the channel will dynamically
+   switch to the configured faxbuffers policy.  For example, to use 6 buffers
+   and a 'full' buffer policy for a fax transmission, add:
+     faxbuffers=>6,full
+   The faxbuffers configuration will be in affect until the call is torn down.
 
 Dialplan Functions
 ------------------
@@ -128,6 +136,8 @@
  * The contrib/scripts/ directory now has a script called sip_nat_settings that will
    give you the correct output for an asterisk box behind nat. It will give you the
    externhost and localnet settings.
+ * The Asterisk core now supports ITU G.722.1 and G.722.1C media streams, and
+   can connect calls in passthrough mode, as well as record and play back files.
 
 Asterisk Manager Interface
 --------------------------
@@ -563,6 +573,7 @@
   * Added support for OSP.  The token is set and retrieved through the CHANNEL()
      dialplan function.
   * Added immediate option to iax.conf
+  * Added forceencryption option to iax.conf
 
 XMPP Google Talk/Jingle changes
 -------------------------------

Modified: team/group/newcdr/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_dial.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/apps/app_dial.c (original)
+++ team/group/newcdr/apps/app_dial.c Fri Feb 13 09:47:56 2009
@@ -1596,6 +1596,10 @@
 		res = -1; /* reset default */
 	}
 
+	if (ast_test_flag64(&opts, OPT_DTMF_EXIT)) {
+		__ast_answer(chan, 0, 0);
+	}
+
 	if (continue_exec)
 		*continue_exec = 0;
 

Modified: team/group/newcdr/apps/app_dictate.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_dictate.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/apps/app_dictate.c (original)
+++ team/group/newcdr/apps/app_dictate.c Fri Feb 13 09:47:56 2009
@@ -127,7 +127,9 @@
 		return -1;
 	}
 
-	ast_answer(chan);
+	if (chan->_state != AST_STATE_UP) {
+		ast_answer(chan);
+	}
 	ast_safe_sleep(chan, 200);
 	for (res = 0; !res;) {
 		if (ast_strlen_zero(filename)) {

Modified: team/group/newcdr/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_queue.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/apps/app_queue.c (original)
+++ team/group/newcdr/apps/app_queue.c Fri Feb 13 09:47:56 2009
@@ -2012,6 +2012,7 @@
 static int say_position(struct queue_ent *qe, int ringing)
 {
 	int res = 0, avgholdmins, avgholdsecs, announceposition = 0;
+	int say_thanks = 1;
 	time_t now;
 
 	/* Let minannouncefrequency seconds pass between the start of each position announcement */
@@ -2120,15 +2121,16 @@
 			if (res)
 				goto playout;
 		}
-
+	} else if (qe->parent->announceholdtime && !qe->parent->announceposition) {
+		say_thanks = 0;
 	}
 
 posout:
-	if (announceposition == 1){
-		if (qe->parent->announceposition) {
-			ast_verb(3, "Told %s in %s their queue position (which was %d)\n",
-				qe->chan->name, qe->parent->name, qe->pos);
-		}
+	if (qe->parent->announceposition) {
+		ast_verb(3, "Told %s in %s their queue position (which was %d)\n",
+			qe->chan->name, qe->parent->name, qe->pos);
+	}
+	if (say_thanks) {
 		res = play_file(qe->chan, qe->parent->sound_thanks);
 	}
 playout:

Modified: team/group/newcdr/apps/app_waitforsilence.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/apps/app_waitforsilence.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/apps/app_waitforsilence.c (original)
+++ team/group/newcdr/apps/app_waitforsilence.c Fri Feb 13 09:47:56 2009
@@ -210,7 +210,9 @@
 	int iterations = 1, i;
 	time_t waitstart;
 
-	res = ast_answer(chan); /* Answer the channel */
+	if (chan->_state != AST_STATE_UP) {
+		res = ast_answer(chan); /* Answer the channel */
+	}
 
 	if (!data || ( (sscanf(data, "%d,%d,%d", &timereqd, &iterations, &timeout) != 3) &&
 		(sscanf(data, "%d,%d", &timereqd, &iterations) != 2) &&

Modified: team/group/newcdr/build_tools/cflags.xml
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/build_tools/cflags.xml?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/build_tools/cflags.xml (original)
+++ team/group/newcdr/build_tools/cflags.xml Fri Feb 13 09:47:56 2009
@@ -22,7 +22,6 @@
 			<defaultenabled>no</defaultenabled>
 		</member>
 		<member name="G711_REDUCED_BRANCHING" displayname="New ulaw/alaw codec, reduced branching (might help it run faster in some architectures)">
-			<defaultenabled>yes</defaultenabled>
 			<depend>G711_NEW_ALGORITHM</depend>
 		</member>
 		<member name="TEST_CODING_TABLES" displayname="New ulaw/alaw codec, turn on table tests on init">

Modified: team/group/newcdr/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_dahdi.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/channels/chan_dahdi.c (original)
+++ team/group/newcdr/channels/chan_dahdi.c Fri Feb 13 09:47:56 2009
@@ -584,8 +584,11 @@
 	struct dahdi_pvt *master;				/*!< Master to us (we follow their conferencing) */
 	int inconference;				/*!< If our real should be in the conference */
 
+	int bufsize;                /*!< Size of the buffers */
 	int buf_no;					/*!< Number of buffers */
 	int buf_policy;				/*!< Buffer policy */
+	int faxbuf_no;              /*!< Number of Fax buffers */
+	int faxbuf_policy;          /*!< Fax buffer policy */
 	int sig;					/*!< Signalling style */
 	/*!
 	 * \brief Nonzero if the signaling type is sent over a radio.
@@ -682,6 +685,10 @@
 	unsigned int echocanon:1;
 	/*! \brief TRUE if a fax tone has already been handled. */
 	unsigned int faxhandled:1;
+	/*! \brief TRUE if dynamic faxbuffers are configured for use, default is OFF */
+	unsigned int usefaxbuffers:1;
+	/*! \brief TRUE while dynamic faxbuffers are in use */
+	unsigned int faxbuffersinuse:1;
 	/*! \brief TRUE if over a radio and dahdi_read() has been called. */
 	unsigned int firstradio:1;
 	/*!
@@ -1234,7 +1241,10 @@
 			.sendcalleridafter = DEFAULT_CIDRINGS,
 
 			.buf_policy = DAHDI_POLICY_IMMEDIATE,
-			.buf_no = numbufs
+			.buf_no = numbufs,
+			.usefaxbuffers = 0,
+			.faxbuf_policy = DAHDI_POLICY_IMMEDIATE,
+			.faxbuf_no = numbufs,
 		},
 		.timing = {
 			.prewinktime = -1,
@@ -3716,6 +3726,22 @@
 			p->dsp = NULL;
 		}
 
+		if (p->faxbuffersinuse) {
+			/* faxbuffers are in use, revert them */
+			struct dahdi_bufferinfo bi = {
+				.txbufpolicy = p->buf_policy,
+				.rxbufpolicy = p->buf_policy,
+				.bufsize = p->bufsize,
+				.numbufs = p->buf_no
+			};
+			int bpres;
+
+			if ((bpres = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SET_BUFINFO, &bi)) < 0) {
+				ast_log(LOG_WARNING, "Channel '%s' unable to revert faxbuffer policy: %s\n", ast->name, strerror(errno));
+			}
+			p->faxbuffersinuse = 0;	
+		}
+
 		law = DAHDI_LAW_DEFAULT;
 		res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETLAW, &law);
 		if (res < 0)
@@ -4804,6 +4830,21 @@
 	} else if (f->subclass == 'f') {
 		/* Fax tone -- Handle and return NULL */
 		if ((p->callprogress & CALLPROGRESS_FAX) && !p->faxhandled) {
+			/* If faxbuffers are configured, use them for the fax transmission */
+			if (p->usefaxbuffers && !p->faxbuffersinuse) {
+				struct dahdi_bufferinfo bi = {
+					.txbufpolicy = p->faxbuf_policy,
+					.bufsize = p->bufsize,
+					.numbufs = p->faxbuf_no
+				};
+				int res;
+			
+				if ((res = ioctl(p->subs[idx].dfd, DAHDI_SET_BUFINFO, &bi)) < 0) {
+					ast_log(LOG_WARNING, "Channel '%s' unable to set faxbuffer policy, reason: %s\n", ast->name, strerror(errno));
+				} else {
+					p->faxbuffersinuse = 1;
+				}
+			}
 			p->faxhandled = 1;
 			if (strcmp(ast->exten, "fax")) {
 				const char *target_context = S_OR(ast->macrocontext, ast->context);
@@ -9313,8 +9354,19 @@
 				if (res < 0) {
 					ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d: %s\n", channel, strerror(errno));
 				}
-			} else
+			} else {
 				ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d: %s\n", channel, strerror(errno));
+			}
+			tmp->buf_policy = conf->chan.buf_policy;
+			tmp->buf_no = conf->chan.buf_no;
+			tmp->usefaxbuffers = conf->chan.usefaxbuffers;
+			tmp->faxbuf_policy = conf->chan.faxbuf_policy;
+			tmp->faxbuf_no = conf->chan.faxbuf_no;
+			/* This is not as gnarly as it may first appear.  If the ioctl above failed, we'd be setting
+			 * tmp->bufsize to zero which would cause subsequent faxbuffer-related ioctl calls to fail.
+			 * The reason the ioctl call above failed should to be determined before worrying about the
+			 * faxbuffer-related ioctl calls */
+			tmp->bufsize = bi.bufsize;
 		}
 #endif
 		tmp->immediate = conf->chan.immediate;
@@ -14528,6 +14580,27 @@
 #endif
 			} else {
 				ast_log(LOG_WARNING, "Invalid policy name given (%s).\n", policy);
+			}
+		} else if (!strcasecmp(v->name, "faxbuffers")) {
+			int res;
+			char policy[21] = "";
+
+			res = sscanf(v->value, "%d,%20s", &confp->chan.faxbuf_no, policy);
+			if (res != 2) {
+				ast_log(LOG_WARNING, "Parsing faxbuffers option data failed, using defaults.\n");
+				confp->chan.faxbuf_no = numbufs;
+				continue;
+			}
+			confp->chan.usefaxbuffers = 1;
+			if (confp->chan.faxbuf_no < 0)
+				confp->chan.faxbuf_no = numbufs;
+			if (!strcasecmp(policy, "full")) {
+				confp->chan.faxbuf_policy = DAHDI_POLICY_WHEN_FULL;
+			} else if (!strcasecmp(policy, "immediate")) {
+				confp->chan.faxbuf_policy = DAHDI_POLICY_IMMEDIATE;
+			} else {
+				ast_log(LOG_WARNING, "Invalid policy name given (%s).\n", policy);
+				confp->chan.usefaxbuffers = 0;
 			}
  		} else if (!strcasecmp(v->name, "dahdichan")) {
  			ast_copy_string(dahdichan, v->value, sizeof(dahdichan));

Modified: team/group/newcdr/channels/chan_gtalk.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_gtalk.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/channels/chan_gtalk.c (original)
+++ team/group/newcdr/channels/chan_gtalk.c Fri Feb 13 09:47:56 2009
@@ -43,6 +43,7 @@
 #include <sys/signal.h>
 #include <iksemel.h>
 #include <pthread.h>
+#include <ctype.h>
 
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
@@ -382,6 +383,7 @@
 	int pref_codec = 0;
 	int alreadysent = 0;
 	int codecs_num = 0;
+	char *lowerto = NULL;
 
 	iq = iks_new("iq");
 	gtalk = iks_new("session");
@@ -428,7 +430,14 @@
 
 	iks_insert_attrib(gtalk, "xmlns", "http://www.google.com/session");
 	iks_insert_attrib(gtalk, "type",initiator ? "initiate": "accept");
-	iks_insert_attrib(gtalk, "initiator", initiator ? from : to);
+	/* put the initiator attribute to lower case if we receive the call 
+	 * otherwise GoogleTalk won't establish the session */
+	if (!initiator) {
+	        char c;
+	        char *t = lowerto = ast_strdupa(to);
+		while (((c = *t) != '/') && (*t++ = tolower(c)));
+	}
+	iks_insert_attrib(gtalk, "initiator", initiator ? from : lowerto);
 	iks_insert_attrib(gtalk, "id", sid);
 	iks_insert_node(iq, gtalk);
 	iks_insert_node(gtalk, dcodecs);
@@ -448,6 +457,8 @@
 static int gtalk_invite_response(struct gtalk_pvt *p, char *to , char *from, char *sid, int initiator)
 {
 	iks *iq, *session, *transport;
+	char *lowerto = NULL;
+
 	iq = iks_new("iq");
 	session = iks_new("session");
 	transport = iks_new("transport");
@@ -465,7 +476,14 @@
 	ast_aji_increment_mid(p->parent->connection->mid);
 	iks_insert_attrib(session, "type", "transport-accept");
 	iks_insert_attrib(session, "id", sid);
-	iks_insert_attrib(session, "initiator", initiator ? from : to);
+	/* put the initiator attribute to lower case if we receive the call 
+	 * otherwise GoogleTalk won't establish the session */
+	if (!initiator) {
+	        char c;
+		char *t = lowerto = ast_strdupa(to);
+		while (((c = *t) != '/') && (*t++ = tolower(c)));
+	}
+	iks_insert_attrib(session, "initiator", initiator ? from : lowerto);
 	iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
 	iks_insert_attrib(transport, "xmlns", "http://www.google.com/transport/p2p");
 	iks_insert_node(iq,session);
@@ -761,6 +779,7 @@
 	struct in_addr us;
 	iks *iq, *gtalk, *candidate, *transport;
 	char user[17], pass[17], preference[5], port[7];
+	char *lowerfrom = NULL;
 
 
 	iq = iks_new("iq");
@@ -793,6 +812,9 @@
 
 	ast_rtp_get_us(p->rtp, &sin);
 	ast_find_ourip(&us, bindaddr);
+	if (!strcmp(ast_inet_ntoa(us), "127.0.0.1")) {
+		ast_log(LOG_WARNING, "Found a loopback IP on the system, check your network configuration or set the bindaddr attribute.");
+	}
 
 	/* Setup our gtalk candidates */
 	ast_copy_string(ours1->name, "rtp", sizeof(ours1->name));
@@ -839,7 +861,14 @@
 		ast_aji_increment_mid(c->mid);
 		iks_insert_attrib(gtalk, "type", "transport-info");
 		iks_insert_attrib(gtalk, "id", sid);
-		iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : from);
+		/* put the initiator attribute to lower case if we receive the call 
+		 * otherwise GoogleTalk won't establish the session */
+		if (!p->initiator) {
+		        char c;
+			char *t = lowerfrom = ast_strdupa(from);
+			while (((c = *t) != '/') && (*t++ = tolower(c)));
+		}
+		iks_insert_attrib(gtalk, "initiator", (p->initiator) ? to : lowerfrom);
 		iks_insert_attrib(gtalk, "xmlns", GOOGLE_NS);
 		iks_insert_attrib(candidate, "name", tmp->name);
 		iks_insert_attrib(candidate, "address", tmp->ip);
@@ -1049,6 +1078,7 @@
 {
 	iks *request, *session = NULL;
 	int res = -1;
+	char *lowerthem = NULL;
 
 	request = iks_new("iq");
 	if (request) {
@@ -1061,7 +1091,14 @@
 		if (session) {
 			iks_insert_attrib(session, "type", action);
 			iks_insert_attrib(session, "id", p->sid);
-			iks_insert_attrib(session, "initiator", p->initiator ? p->us : p->them);
+			/* put the initiator attribute to lower case if we receive the call 
+			 * otherwise GoogleTalk won't establish the session */
+			if (!p->initiator) {
+			        char c;
+				char *t = lowerthem = ast_strdupa(p->them);
+				while (((c = *t) != '/') && (*t++ = tolower(c)));
+			}
+			iks_insert_attrib(session, "initiator", p->initiator ? p->us : lowerthem);
 			iks_insert_attrib(session, "xmlns", "http://www.google.com/session");
 			iks_insert_node(request, session);
 			ast_aji_send(client->connection, request);
@@ -1477,6 +1514,7 @@
 	struct gtalk *client = p->parent;
 	iks *iq, *gtalk, *dtmf;
 	char buffer[2] = {digit, '\0'};
+	char *lowerthem = NULL;
 	iq = iks_new("iq");
 	gtalk = iks_new("gtalk");
 	dtmf = iks_new("dtmf");
@@ -1495,7 +1533,14 @@
 	ast_aji_increment_mid(client->connection->mid);
 	iks_insert_attrib(gtalk, "xmlns", "http://jabber.org/protocol/gtalk");
 	iks_insert_attrib(gtalk, "action", "session-info");
-	iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: p->them);
+	/* put the initiator attribute to lower case if we receive the call 
+	 * otherwise GoogleTalk won't establish the session */
+	if (!p->initiator) {
+	        char c;
+	        char *t = lowerthem = ast_strdupa(p->them);
+	        while (((c = *t) != '/') && (*t++ = tolower(c)));
+	}
+	iks_insert_attrib(gtalk, "initiator", p->initiator ? p->us: lowerthem);
 	iks_insert_attrib(gtalk, "sid", p->sid);
 	iks_insert_attrib(dtmf, "xmlns", "http://jabber.org/protocol/gtalk/info/dtmf");
 	iks_insert_attrib(dtmf, "code", buffer);

Modified: team/group/newcdr/channels/chan_h323.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_h323.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/channels/chan_h323.c (original)
+++ team/group/newcdr/channels/chan_h323.c Fri Feb 13 09:47:56 2009
@@ -1922,15 +1922,6 @@
 	return info;
 }
 
-/* 
- * Definition taken from rtp.c for rtpPayloadType because we need it here.
- */
-
-struct rtpPayloadType {
-	int isAstFormat;	/* whether the following code is an AST_FORMAT */
-	int code;
-};
-
 /*! \brief
   * Call-back function passing remote ip/port information from H.323 to asterisk
   *

Modified: team/group/newcdr/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/newcdr/channels/chan_iax2.c?view=diff&rev=175546&r1=175545&r2=175546
==============================================================================
--- team/group/newcdr/channels/chan_iax2.c (original)
+++ team/group/newcdr/channels/chan_iax2.c Fri Feb 13 09:47:56 2009
@@ -377,6 +377,7 @@
 	IAX_ALLOWFWDOWNLOAD =   (1 << 26),	/*!< Allow the FWDOWNL command? */
 	IAX_NOKEYROTATE =       (1 << 27),	/*!< Disable key rotation with encryption */
 	IAX_IMMEDIATE =		(1 << 28),      /*!< Allow immediate off-hook to extension s */
+	IAX_FORCE_ENCRYPT =	(1 << 29),      /*!< Forces call encryption, if encryption not possible hangup */
 };
 
 static int global_rtautoclear = 120;
@@ -1939,8 +1940,7 @@
 			iaxs[x]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
 			iaxs[x]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
 			iaxs[x]->amaflags = amaflags;
-			ast_copy_flags(iaxs[x], &globalflags, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE);
-			
+			ast_copy_flags(iaxs[x], &globalflags, IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE | IAX_FORCE_ENCRYPT);	
 			ast_string_field_set(iaxs[x], accountcode, accountcode);
 			ast_string_field_set(iaxs[x], mohinterpret, mohinterpret);
 			ast_string_field_set(iaxs[x], mohsuggest, mohsuggest);
@@ -3556,7 +3556,7 @@
 	if (peer->maxms && ((peer->lastms > peer->maxms) || (peer->lastms < 0)))
 		goto return_unref;
 
-	ast_copy_flags(cai, peer, IAX_SENDANI | IAX_TRUNK | IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE);
+	ast_copy_flags(cai, peer, IAX_SENDANI | IAX_TRUNK | IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_NOKEYROTATE | IAX_FORCE_ENCRYPT);
 	cai->maxtime = peer->maxms;
 	cai->capability = peer->capability;
 	cai->encmethods = peer->encmethods;
@@ -3756,16 +3756,17 @@
 		ast_log(LOG_WARNING, "No peer provided in the IAX2 dial string '%s'\n", dest);
 		return -1;
 	}
-
 	if (!pds.exten) {
 		pds.exten = defaultrdest;
 	}
-
 	if (create_addr(pds.peer, c, &sin, &cai)) {
 		ast_log(LOG_WARNING, "No address associated with '%s'\n", pds.peer);
 		return -1;
 	}
-
+	if (ast_strlen_zero(cai.secret) && ast_test_flag(iaxs[callno], IAX_FORCE_ENCRYPT)) {
+		ast_log(LOG_WARNING, "Call terminated. No secret given and force encrypt enabled\n");
+		return -1;
+	}
 	if (!pds.username && !ast_strlen_zero(cai.username))
 		pds.username = cai.username;
 	if (!pds.password && !ast_strlen_zero(cai.secret))
@@ -6221,11 +6222,7 @@
 		if (user->maxauthreq > 0)
 			ast_set_flag(iaxs[callno], IAX_MAXAUTHREQ);
 		iaxs[callno]->prefs = user->prefs;
-		ast_copy_flags(iaxs[callno], user, IAX_CODEC_USER_FIRST);
-		ast_copy_flags(iaxs[callno], user, IAX_IMMEDIATE);
-		ast_copy_flags(iaxs[callno], user, IAX_CODEC_NOPREFS);
-		ast_copy_flags(iaxs[callno], user, IAX_CODEC_NOCAP);
-		ast_copy_flags(iaxs[callno], user, IAX_NOKEYROTATE);
+		ast_copy_flags(iaxs[callno], user, IAX_CODEC_USER_FIRST | IAX_IMMEDIATE | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP | IAX_NOKEYROTATE | IAX_FORCE_ENCRYPT);
 		iaxs[callno]->encmethods = user->encmethods;
 		/* Store the requested username if not specified */
 		if (ast_strlen_zero(iaxs[callno]->username))
@@ -6403,7 +6400,10 @@
 		ast_string_field_set(p, host, user->name);
 		user = user_unref(user);
 	}
-
+	if (ast_test_flag(p, IAX_FORCE_ENCRYPT) && !p->encmethods) { 
+		ast_log(LOG_NOTICE, "Call Terminated, Incomming call is unencrypted while force encrypt is enabled.");
+		return res;
+	}
 	if (!ast_test_flag(&p->state, IAX_STATE_AUTHENTICATED))
 		return res;
 	if (ies->password)
@@ -6723,8 +6723,13 @@
 			}
 		}
 	}
-	if (ies->encmethods)
+
+	if (ies->encmethods) {
 		ast_set_flag(p, IAX_ENCRYPTED | IAX_KEYPOPULATED);
+	} else if (ast_test_flag(iaxs[callno], IAX_FORCE_ENCRYPT)) {
+		ast_log(LOG_NOTICE, "Call initiated without encryption while forceencryption=yes option is set");
+		return -1;             /* if force encryption is yes, and no encryption methods, then return -1 to hangup */
+	}
 	if (!res) {
 		struct ast_datastore *variablestore;
 		struct ast_variable *var, *prev = NULL;
@@ -8839,6 +8844,11 @@
 					auth_fail(fr->callno, IAX_COMMAND_REJECT);
 					if (authdebug)
 						ast_log(LOG_NOTICE, "Rejected connect attempt from %s, who was trying to reach '%s@%s'\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
+					break;
+				}
+				if (ast_strlen_zero(iaxs[fr->callno]->secret) && ast_test_flag(iaxs[fr->callno], IAX_FORCE_ENCRYPT)) {
+					auth_fail(fr->callno, IAX_COMMAND_REJECT);
+					ast_log(LOG_WARNING, "Rejected connect attempt.  No secret present while force encrypt enabled.\n");
 					break;
 				}
 				if (strcasecmp(iaxs[fr->callno]->exten, "TBD")) {
@@ -10670,7 +10680,7 @@
 			if (ast_test_flag(&globalflags, IAX_NOKEYROTATE)) {
 				ast_copy_flags(peer, &globalflags, IAX_NOKEYROTATE);
 			}
-			ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+			ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_FORCE_ENCRYPT);
 			peer->encmethods = iax2_encryption;
 			peer->adsi = adsi;
 			ast_string_field_set(peer,secret,"");
@@ -10720,6 +10730,18 @@
 				peer->authmethods = get_auth_methods(v->value);
 			} else if (!strcasecmp(v->name, "encryption")) {
 				peer->encmethods = get_encrypt_methods(v->value);
+				if (!peer->encmethods) {
+					ast_clear_flag(peer, IAX_FORCE_ENCRYPT);
+				}
+			} else if (!strcasecmp(v->name, "forceencryption")) {
+				if (ast_false(v->value)) {
+					ast_clear_flag(peer, IAX_FORCE_ENCRYPT);
+				} else {
+					peer->encmethods = get_encrypt_methods(v->value);
+					if (peer->encmethods) {
+						ast_set_flag(peer, IAX_FORCE_ENCRYPT);
+					}
+				}
 			} else if (!strcasecmp(v->name, "keyrotate")) {
 				if (ast_false(v->value))
 					ast_set_flag(peer, IAX_NOKEYROTATE);
@@ -10934,7 +10956,7 @@
 			user->adsi = adsi;
 			ast_string_field_set(user, name, name);
 			ast_string_field_set(user, language, language);
-			ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP | IAX_NOKEYROTATE);	
+			ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP | IAX_NOKEYROTATE | IAX_FORCE_ENCRYPT);	
 			ast_clear_flag(user, IAX_HASCALLERID);
 			ast_string_field_set(user, cid_name, "");
 			ast_string_field_set(user, cid_num, "");
@@ -10973,13 +10995,25 @@
 			} else if (!strcasecmp(v->name, "trunk")) {
 				ast_set2_flag(user, ast_true(v->value), IAX_TRUNK);	
 				if (ast_test_flag(user, IAX_TRUNK) && (timingfd < 0)) {
-					ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without DAHDI timing\n", user->name);
+					ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without a timing interface\n", user->name);
 					ast_clear_flag(user, IAX_TRUNK);
 				}
 			} else if (!strcasecmp(v->name, "auth")) {
 				user->authmethods = get_auth_methods(v->value);
 			} else if (!strcasecmp(v->name, "encryption")) {
 				user->encmethods = get_encrypt_methods(v->value);
+				if (!user->encmethods) {
+					ast_clear_flag(user, IAX_FORCE_ENCRYPT);
+				}
+			} else if (!strcasecmp(v->name, "forceencryption")) {
+				if (ast_false(v->value)) {
+					ast_clear_flag(user, IAX_FORCE_ENCRYPT);
+				} else {
+					user->encmethods = get_encrypt_methods(v->value);
+					if (user->encmethods) {
+						ast_set_flag(user, IAX_FORCE_ENCRYPT);
+					}
+				}
 			} else if (!strcasecmp(v->name, "keyrotate")) {
 				if (ast_false(v->value))
 					ast_set_flag(user, IAX_NOKEYROTATE);
@@ -11249,7 +11283,7 @@
 	/* Reset Global Flags */
 	memset(&globalflags, 0, sizeof(globalflags));
 	ast_set_flag(&globalflags, IAX_RTUPDATE);
-
+	ast_set_flag(&globalflags, IAX_NOKEYROTATE); /* turn off key rotate by default since it breaks backwards compatibility at the moment. */
 #ifdef SO_NO_CHECK
 	nochecksums = 0;
 #endif
@@ -11355,11 +11389,23 @@
 					ast_netsock_unref(ns);
 				}
 			}
-		} else if (!strcasecmp(v->name, "authdebug"))
+		} else if (!strcasecmp(v->name, "authdebug")) {
 			authdebug = ast_true(v->value);
-		else if (!strcasecmp(v->name, "encryption"))
-			iax2_encryption = get_encrypt_methods(v->value);
-		else if (!strcasecmp(v->name, "keyrotate")) {
+		} else if (!strcasecmp(v->name, "encryption")) {
+				iax2_encryption = get_encrypt_methods(v->value);
+				if (!iax2_encryption) {
+					ast_clear_flag((&globalflags), IAX_FORCE_ENCRYPT);
+				}
+		} else if (!strcasecmp(v->name, "forceencryption")) {
+			if (ast_false(v->value)) {
+				ast_clear_flag((&globalflags), IAX_FORCE_ENCRYPT);
+			} else {
+				iax2_encryption = get_encrypt_methods(v->value);
+				if (iax2_encryption) {
+					ast_set_flag((&globalflags), IAX_FORCE_ENCRYPT);
+				}
+			}

[... 1312 lines stripped ...]



More information about the asterisk-commits mailing list