[asterisk-commits] tilghman: trunk r76807 - in /trunk: ./ channels/chan_iax2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 24 12:05:11 CDT 2007
Author: tilghman
Date: Tue Jul 24 12:05:10 2007
New Revision: 76807
URL: http://svn.digium.com/view/asterisk?view=rev&rev=76807
Log:
Merged revisions 76803 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r76803 | qwell | 2007-07-24 11:32:20 -0500 (Tue, 24 Jul 2007) | 3 lines
Don't create the Asterisk channel until we are starting the PBX on it.
(ASA-2007-018)
........
Modified:
trunk/ (props changed)
trunk/channels/chan_iax2.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=76807&r1=76806&r2=76807
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Jul 24 12:05:10 2007
@@ -519,6 +519,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 */
@@ -2099,7 +2103,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]);
@@ -3530,7 +3534,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;
@@ -3611,9 +3615,7 @@
}
}
- 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);
@@ -7273,12 +7275,42 @@
(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;
+ } else if (ies.vars) {
+ struct ast_datastore *variablestore;
+ struct ast_variable *var, *prev = NULL;
+ AST_LIST_HEAD(, ast_var_t) *varlist;
+ varlist = ast_calloc(1, sizeof(*varlist));
+ variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ if (variablestore && varlist) {
+ variablestore->data = varlist;
+ variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
+ AST_LIST_HEAD_INIT(varlist);
+ for (var = ies.vars; var; var = var->next) {
+ struct ast_var_t *newvar = ast_var_assign(var->name, var->value);
+ if (prev)
+ ast_free(prev);
+ prev = var;
+ if (!newvar) {
+ /* Don't abort list traversal, as this would leave ies.vars in an inconsistent state. */
+ ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
+ } else {
+ AST_LIST_INSERT_TAIL(varlist, newvar, entries);
+ }
+ }
+ if (prev)
+ free(prev);
+ ies.vars = NULL;
+ ast_channel_datastore_add(c, variablestore);
+ } else {
+ ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
+ if (variablestore)
+ ast_channel_datastore_free(variablestore);
+ if (varlist)
+ ast_free(varlist);
+ }
}
}
}
@@ -7565,44 +7597,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);
- else if (ies.vars) {
- struct ast_datastore *variablestore;
- struct ast_variable *var, *prev = NULL;
- AST_LIST_HEAD(, ast_var_t) *varlist;
- varlist = ast_calloc(1, sizeof(*varlist));
- variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
- if (variablestore && varlist) {
- variablestore->data = varlist;
- variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
- AST_LIST_HEAD_INIT(varlist);
- for (var = ies.vars; var; var = var->next) {
- struct ast_var_t *newvar = ast_var_assign(var->name, var->value);
- if (prev)
- ast_free(prev);
- prev = var;
- if (!newvar) {
- /* Don't abort list traversal, as this would leave ies.vars in an inconsistent state. */
- ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
- } else {
- AST_LIST_INSERT_TAIL(varlist, newvar, entries);
- }
- }
- if (prev)
- ast_free(prev);
- ies.vars = NULL;
- ast_channel_datastore_add(c, variablestore);
- } else {
- ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
- if (variablestore)
- ast_channel_datastore_free(variablestore);
- if (varlist)
- ast_free(varlist);
- }
- }
+ 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... */
@@ -7981,7 +7977,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 if (ies.vars) {
struct ast_datastore *variablestore;
@@ -8043,8 +8039,42 @@
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);
+ else if (ies.vars) {
+ struct ast_datastore *variablestore;
+ struct ast_variable *var, *prev = NULL;
+ AST_LIST_HEAD(, ast_var_t) *varlist;
+ varlist = ast_calloc(1, sizeof(*varlist));
+ variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ if (variablestore && varlist) {
+ variablestore->data = varlist;
+ variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
+ AST_LIST_HEAD_INIT(varlist);
+ for (var = ies.vars; var; var = var->next) {
+ struct ast_var_t *newvar = ast_var_assign(var->name, var->value);
+ if (prev)
+ ast_free(prev);
+ prev = var;
+ if (!newvar) {
+ /* Don't abort list traversal, as this would leave ies.vars in an inconsistent state. */
+ ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
+ } else {
+ AST_LIST_INSERT_TAIL(varlist, newvar, entries);
+ }
+ }
+ if (prev)
+ ast_free(prev);
+ ies.vars = NULL;
+ ast_channel_datastore_add(c, variablestore);
+ } else {
+ ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
+ if (variablestore)
+ ast_channel_datastore_free(variablestore);
+ if (varlist)
+ ast_free(varlist);
+ }
+ }
}
}
break;
@@ -8747,7 +8777,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