[svn-commits] kmoore: trunk r423505 - in /trunk: ./ include/asterisk/ main/ res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Sep 19 07:50:10 CDT 2014


Author: kmoore
Date: Fri Sep 19 07:50:08 2014
New Revision: 423505

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=423505
Log:
PJSIP: Prevent T38 framehook being put on wrong channel

This change gives framehooks a reverse-direction masquerade callback in
addition to chan_fixup_cb similar to the callback added to datastores
to handle the same situation. The new callback provides the same
parameters as the fixup callback, but is called on the new channel's
framehooks before moving framehooks from the old channel to the new
channel. This gives the framehooks an oppurtunity to decide whether
they should remain on the new channel or be removed.

This new callback is used to prevent the PJSIP T.38 framehook from
remaining on a masqueraded channel if the new channel is not also a
PJSIP channel. This was causing a crash when a local channel was
masqueraded into a PJSIP channel and the framehook was executed on the
local channel since the channel's tech private data was not structured
as expected.

Review: https://reviewboard.asterisk.org/r/4001/
........

Merged revisions 423503 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 423504 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/framehook.h
    trunk/main/framehook.c
    trunk/res/res_pjsip_t38.c

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

Modified: trunk/include/asterisk/framehook.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/framehook.h?view=diff&rev=423505&r1=423504&r2=423505
==============================================================================
--- trunk/include/asterisk/framehook.h (original)
+++ trunk/include/asterisk/framehook.h Fri Sep 19 07:50:08 2014
@@ -224,7 +224,7 @@
 typedef void (*ast_framehook_chan_fixup_callback)(void *data, int framehook_id,
 	struct ast_channel *old_chan, struct ast_channel *new_chan);
 
-#define AST_FRAMEHOOK_INTERFACE_VERSION 3
+#define AST_FRAMEHOOK_INTERFACE_VERSION 4
 /*! This interface is required for attaching a framehook to a channel. */
 struct ast_framehook_interface {
 	/*! framehook interface version number */
@@ -242,6 +242,10 @@
 	 * on is masqueraded and should be used to move any essential framehook data onto the channel the
 	 * old channel was masqueraded to. */
 	ast_framehook_chan_fixup_callback chan_fixup_cb;
+	/*! chan_breakdown_cb is optional. This function is called when another channel is masqueraded into
+	 * the channel that a framehook is running on and should be used to evaluate whether the framehook
+	 * should remain on the channel. */
+	ast_framehook_chan_fixup_callback chan_breakdown_cb;
 	/*! disable_inheritance is optional. If set to non-zero, when a channel using this framehook is
 	 * masqueraded, detach and destroy the framehook instead of moving it to the new channel. */
 	int disable_inheritance;

Modified: trunk/main/framehook.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/framehook.c?view=diff&rev=423505&r1=423504&r2=423505
==============================================================================
--- trunk/main/framehook.c (original)
+++ trunk/main/framehook.c Fri Sep 19 07:50:08 2014
@@ -227,6 +227,21 @@
 	struct ast_framehook *framehook;
 	int moved_framehook_id;
 
+	if (ast_channel_framehooks(new_chan)) {
+		AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_channel_framehooks(new_chan)->list, framehook, list) {
+			if (framehook->i.disable_inheritance) {
+				ast_framehook_detach(new_chan, framehook->id);
+				continue;
+			}
+
+			if (framehook->i.chan_breakdown_cb) {
+				framehook->i.chan_breakdown_cb(framehook->i.data, framehook->id,
+					old_chan, new_chan);
+			}
+		}
+		AST_LIST_TRAVERSE_SAFE_END;
+	}
+
 	if (!ast_channel_framehooks(old_chan)) {
 		return;
 	}

Modified: trunk/res/res_pjsip_t38.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_t38.c?view=diff&rev=423505&r1=423504&r2=423505
==============================================================================
--- trunk/res/res_pjsip_t38.c (original)
+++ trunk/res/res_pjsip_t38.c Fri Sep 19 07:50:08 2014
@@ -440,12 +440,25 @@
 	return f;
 }
 
+static void t38_masq(void *data, int framehook_id,
+        struct ast_channel *old_chan, struct ast_channel *new_chan)
+{
+	if (ast_channel_tech(old_chan) == ast_channel_tech(new_chan)) {
+		return;
+	}
+
+	/* This framehook is only applicable to PJSIP channels */
+	ast_framehook_detach(new_chan, framehook_id);
+}
+
 /*! \brief Function called to attach T.38 framehook to channel when appropriate */
 static void t38_attach_framehook(struct ast_sip_session *session)
 {
 	static struct ast_framehook_interface hook = {
 		.version = AST_FRAMEHOOK_INTERFACE_VERSION,
 		.event_cb = t38_framehook,
+		.chan_fixup_cb = t38_masq,
+		.chan_breakdown_cb = t38_masq,
 	};
 
 	/* Only attach the framehook on the first outgoing INVITE or the first incoming INVITE */




More information about the svn-commits mailing list