diff options
author | Kinsey Moore <kmoore@digium.com> | 2014-09-19 12:45:53 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2014-09-19 12:45:53 +0000 |
commit | fade256307fdf54f35734fd668aeb19f8368017c (patch) | |
tree | cf762bb0acec8b10ee9955455f930476de4a2628 /res/res_pjsip_t38.c | |
parent | 6b3c47bd6ab2bbb00ca3a7a4b4d2452b71dfe582 (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423504 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_t38.c')
-rw-r--r-- | res/res_pjsip_t38.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index c5d0412c4..a031716d9 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -440,12 +440,25 @@ static struct ast_frame *t38_framehook(struct ast_channel *chan, struct ast_fram 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 */ |