[asterisk-commits] qwell: branch 1.4 r76803 - /branches/1.4/channels/chan_iax2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 24 11:32:21 CDT 2007
Author: qwell
Date: Tue Jul 24 11:32:20 2007
New Revision: 76803
URL: http://svn.digium.com/view/asterisk?view=rev&rev=76803
Log:
Don't create the Asterisk channel until we are starting the PBX on it.
(ASA-2007-018)
Modified:
branches/1.4/channels/chan_iax2.c
Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=76803&r1=76802&r2=76803
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Tue Jul 24 11:32:20 2007
@@ -498,6 +498,10 @@
unsigned short callno;
/*! Peer callno */
unsigned short peercallno;
+ /*! Negotiated format, this is only used to remember what format was
+ chosen for an unauthenticated call so that the channel can get
+ created later using the right format */
+ int chosenformat;
/*! Peer selected format */
int peerformat;
/*! Peer capability */
@@ -1961,7 +1965,7 @@
} else if ((peer = find_peer(argv[3], 0))) {
if(ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
ast_set_flag(peer, IAX_RTAUTOCLEAR);
- expire_registry((void*)peer->name);
+ expire_registry((void *)peer->name);
ast_cli(fd, "OK peer %s was removed from the cache.\n", argv[3]);
} else {
ast_cli(fd, "SORRY peer %s is not eligible for this operation.\n", argv[3]);
@@ -3329,7 +3333,7 @@
}
/*! \brief Create new call, interface with the PBX core */
-static struct ast_channel *ast_iax2_new(int callno, int state, int capability, unsigned int delaypbx)
+static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
{
struct ast_channel *tmp;
struct chan_iax2_pvt *i;
@@ -3384,9 +3388,7 @@
for (v = i->vars ; v ; v = v->next)
pbx_builtin_setvar_helper(tmp, v->name, v->value);
- if (delaypbx) {
- ast_set_flag(i, IAX_DELAYPBXSTART);
- } else if (state != AST_STATE_DOWN) {
+ if (state != AST_STATE_DOWN) {
if (ast_pbx_start(tmp)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
ast_hangup(tmp);
@@ -6843,10 +6845,7 @@
(f.frametype == AST_FRAME_IAX)) {
if (ast_test_flag(iaxs[fr->callno], IAX_DELAYPBXSTART)) {
ast_clear_flag(iaxs[fr->callno], IAX_DELAYPBXSTART);
- if (ast_pbx_start(iaxs[fr->callno]->owner)) {
- ast_log(LOG_WARNING, "Unable to start PBX on %s\n", iaxs[fr->callno]->owner->name);
- ast_hangup(iaxs[fr->callno]->owner);
- iaxs[fr->callno]->owner = NULL;
+ if (!ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->chosenformat)) {
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
@@ -7130,10 +7129,8 @@
VERBOSE_PREFIX_4,
using_prefs);
- /* create an Asterisk channel for this call, but don't start
- a PBX on it until we have received a full frame from the peer */
- if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format, 1)))
- iax2_destroy(fr->callno);
+ iaxs[fr->callno]->chosenformat = format;
+ ast_set_flag(iaxs[fr->callno], IAX_DELAYPBXSTART);
} else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);
/* If this is a TBD call, we're ready but now what... */
@@ -7514,7 +7511,7 @@
using_prefs);
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
- if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format, 0)))
+ if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format)))
iax2_destroy(fr->callno);
} else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);
@@ -7542,7 +7539,7 @@
ast_verbose(VERBOSE_PREFIX_3 "Accepting DIAL from %s, formats = 0x%x\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat);
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1);
- if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat, 0)))
+ if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat)))
iax2_destroy(fr->callno);
}
}
@@ -8246,7 +8243,7 @@
if (cai.found)
ast_string_field_set(iaxs[callno], host, pds.peer);
- c = ast_iax2_new(callno, AST_STATE_DOWN, cai.capability, 0);
+ c = ast_iax2_new(callno, AST_STATE_DOWN, cai.capability);
ast_mutex_unlock(&iaxsl[callno]);
More information about the asterisk-commits
mailing list