[asterisk-commits] trunk r26103 - in /trunk: channel.c
include/asterisk/channel.h
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue May 9 08:01:11 MST 2006
Author: markster
Date: Tue May 9 10:01:10 2006
New Revision: 26103
URL: http://svn.digium.com/view/asterisk?rev=26103&view=rev
Log:
Make sure that we don't accept an answer on an inbound call and don't permit asterisk to answer an outbound call
Modified:
trunk/channel.c
trunk/include/asterisk/channel.h
Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=26103&r1=26102&r2=26103&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Tue May 9 10:01:10 2006
@@ -1485,6 +1485,9 @@
{
int res = 0;
ast_channel_lock(chan);
+ /* You can't answer an outbound call */
+ if (ast_test_flag(chan, AST_FLAG_OUTGOING))
+ return 0;
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
ast_channel_unlock(chan);
@@ -1953,13 +1956,17 @@
switch (f->frametype) {
case AST_FRAME_CONTROL:
if (f->subclass == AST_CONTROL_ANSWER) {
- if (prestate == AST_STATE_UP) {
+ if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
+ ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
+ f = &ast_null_frame;
+ } else if (prestate == AST_STATE_UP) {
ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
f = &ast_null_frame;
+ } else {
+ /* Answer the CDR */
+ ast_setstate(chan, AST_STATE_UP);
+ ast_cdr_answer(chan->cdr);
}
- /* Answer the CDR */
- ast_setstate(chan, AST_STATE_UP);
- ast_cdr_answer(chan->cdr);
}
break;
case AST_FRAME_DTMF:
@@ -2638,9 +2645,11 @@
int res = -1;
/* Stop if we're a zombie or need a soft hangup */
ast_channel_lock(chan);
- if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan))
+ if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
if (chan->tech->call)
res = chan->tech->call(chan, addr, timeout);
+ ast_set_flag(chan, AST_FLAG_OUTGOING);
+ }
ast_channel_unlock(chan);
return res;
}
Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?rev=26103&r1=26102&r2=26103&view=diff
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Tue May 9 10:01:10 2006
@@ -466,6 +466,7 @@
so when ->priority is set, it will get incremented before
finding the next priority to run
*/
+#define AST_FLAG_OUTGOING (1 << 10) /*! Is this call outgoing */
/* @} */
#define AST_FEATURE_PLAY_WARNING (1 << 0)
More information about the asterisk-commits
mailing list