diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-09 15:01:10 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-09 15:01:10 +0000 |
commit | f38c5a3817a2221e6492928f36ef1b24ad656e61 (patch) | |
tree | 8c162f5352ded721d4551aedb9e8467c6d9ed42d /channel.c | |
parent | feaaea804f6bd59c76c65abac23d904e6e44956a (diff) |
Make sure that we don't accept an answer on an inbound call and don't permit asterisk to answer an outbound call
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@26103 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r-- | channel.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1485,6 +1485,9 @@ int ast_answer(struct ast_channel *chan) { 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 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) 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 ast_call(struct ast_channel *chan, char *addr, int timeout) 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; } |