[asterisk-commits] nadi: branch group/trunk-cm-csel-hash r46355 -
/team/group/trunk-cm-csel-hash...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Oct 27 06:07:19 MST 2006
Author: nadi
Date: Fri Oct 27 08:07:18 2006
New Revision: 46355
URL: http://svn.digium.com/view/asterisk?rev=46355&view=rev
Log:
struct chan_list lost the "state" field.
Modified:
team/group/trunk-cm-csel-hash/channels/chan_misdn.c
Modified: team/group/trunk-cm-csel-hash/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/channels/chan_misdn.c?rev=46355&r1=46354&r2=46355&view=diff
==============================================================================
--- team/group/trunk-cm-csel-hash/channels/chan_misdn.c (original)
+++ team/group/trunk-cm-csel-hash/channels/chan_misdn.c Fri Oct 27 08:07:18 2006
@@ -137,7 +137,6 @@
char allowed_bearers[BUFFERSIZE];
struct state_machine *sm;
- enum misdn_chan_state state;
int need_queue_hangup;
int need_hangup;
@@ -957,8 +956,8 @@
{
for (; list; list = list->next) {
chan_misdn_log(4, bc->port, "$$$ find_holded: --> holded:%d channel:%d\n",
- list->state == MISDN_HOLDED, list->hold_info.channel);
- if (list->state == MISDN_HOLDED && list->hold_info.port == bc->port)
+ state_machine_get_state(list->sm) == MISDN_HOLDED, list->hold_info.channel);
+ if (state_machine_get_state(list->sm) == MISDN_HOLDED && list->hold_info.port == bc->port)
return list;
}
@@ -969,7 +968,7 @@
static struct chan_list * find_holded_l3 (struct chan_list *list, unsigned long l3_id, int w)
{
for (; list; list = list->next)
- if (list->state == MISDN_HOLDED && list->l3id == l3_id)
+ if (state_machine_get_state(list->sm) == MISDN_HOLDED && list->l3id == l3_id)
return list;
return NULL;
@@ -1225,11 +1224,11 @@
return NULL;
for (i = 0; i < sizeof(ch_states) / sizeof(struct ch_state); ++i) {
- if (ch_states[i].state == p->state)
+ if (ch_states[i].state == state_machine_get_state(p->sm))
return ch_states[i].txt;
}
- snprintf(state, sizeof(state), "%d", p->state);
+ snprintf(state, sizeof(state), "%d", state_machine_get_state(p->sm));
return state;
}
@@ -1574,7 +1573,7 @@
ast->hangupcause = bc->cause;
if (bc->cause == 21 || bc->cause == 17) {
- ch->state = MISDN_BUSY;
+ state_machine_set_state(ch->sm, MISDN_BUSY);
if (!ch->need_busy) {
chan_misdn_log(1, bc->port, "Queued busy already\n");
} else {
@@ -1721,7 +1720,6 @@
}
}
- ch->state = MISDN_CLEANING;
cl_dequeue_chan(&cl_te, ch);
state_machine_destroy(ch->sm);
free(ch);
@@ -1730,9 +1728,9 @@
static void misdn_transfer_bc (struct chan_list *tmp_ch, struct chan_list *holded_chan)
{
chan_misdn_log(4, 0, "TRANSFERING %s to %s\n", holded_chan->ast->name, tmp_ch->ast->name);
- tmp_ch->state = MISDN_HOLD_DISCONNECT;
+ state_machine_set_state(tmp_ch->sm, MISDN_HOLD_DISCONNECT);
ast_moh_stop(AST_BRIDGED_P(holded_chan->ast));
- holded_chan->state = MISDN_CONNECTED;
+ state_machine_set_state(holded_chan->sm, MISDN_CONNECTED);
/* misdn_lib_transfer(holded_chan->bc); */
ast_channel_masquerade(holded_chan->ast, AST_BRIDGED_P(tmp_ch->ast));
}
@@ -1744,7 +1742,7 @@
struct ast_frame fr;
strncpy(predial, ast->exten, sizeof(predial) - 1);
- ch->state = MISDN_DIALING;
+ state_machine_set_state(ch->sm, MISDN_DIALING);
misdn_lib_send_event(bc, (bc->nt || misdn_lib_is_ptp(bc->port)) ? EVENT_SETUP_ACKNOWLEDGE : EVENT_PROCEEDING);
if (!bc->nt && (ch->orginator == ORG_MISDN) && !ch->incoming_early_audio)
@@ -1815,9 +1813,9 @@
int diff;
struct chan_list *ch = (struct chan_list *)data;
- chan_misdn_log(4, ch->bc->port, "overlap dial task, chan_state: %d\n", ch->state);
-
- if (ch->state != MISDN_WAITING4DIGS) {
+ chan_misdn_log(4, ch->bc->port, "overlap dial task, chan_state: %d\n", state_machine_get_state(ch->sm));
+
+ if (state_machine_get_state(ch->sm) != MISDN_WAITING4DIGS) {
ch->overlap_dial_task = -1;
return 0;
}
@@ -1835,7 +1833,7 @@
/* if we are 100ms near the timeout, we are satisfied.. */
stop_indicate(ch);
if (ast_exists_extension(ch->ast, ch->context, ch->bc->dad, 1, ch->bc->oad)) {
- ch->state = MISDN_DIALING;
+ state_machine_set_state(ch->sm, MISDN_DIALING);
if (pbx_start_chan(ch) < 0) {
chan_misdn_log(-1, ch->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
goto misdn_overlap_dial_task_disconnect;
@@ -2033,7 +2031,7 @@
if (bc) {
print_bc_info(fd, help, bc);
} else {
- if (help->state == MISDN_HOLDED)
+ if (state_machine_get_state(help->sm) == MISDN_HOLDED)
chan_misdn_log(0, 0, "IT'S A HOLDED BC:\n --> l3_id: %x\n --> dad:%s oad:%s\n --> hold_port: %d\n --> hold_channel: %d\n",
help->l3id, ast->exten, AST_CID_P(ast), help->hold_info.port, help->hold_info.channel);
else
@@ -2689,7 +2687,7 @@
chan_misdn_log(1, bc->port, "* IND : Digit %c\n", digit);
- switch (p->state) {
+ switch (state_machine_get_state(p->sm)) {
case MISDN_CALLING:
buf[0] = digit;
buf[1] = 0;
@@ -2820,8 +2818,6 @@
if (newbc->nt)
stop_bc_tones(ch);
- ch->state = state_machine_get_state(ch->sm);
-
return 0;
}
@@ -2915,6 +2911,7 @@
const char *varcause;
int tmpcause,
re;
+ int state;
if (!ast || !(p = MISDN_ASTERISK_TECH_PVT(ast)))
return -1;
@@ -2926,12 +2923,14 @@
MISDN_ASTERISK_TECH_PVT(ast) = NULL;
p->ast = NULL;
+ state = state_machine_get_state(p->sm);
+
if (!bc ||
ast->_state == AST_STATE_RESERVED ||
- p->state == MISDN_NOTHING ||
- p->state == MISDN_HOLDED ||
- p->state == MISDN_FIXUP ||
- p->state == MISDN_HOLD_DISCONNECT) {
+ state == MISDN_NOTHING ||
+ state == MISDN_HOLDED ||
+ state == MISDN_FIXUP ||
+ state == MISDN_HOLD_DISCONNECT) {
/* between request and call */
if (!bc)
ast_log(LOG_WARNING,"Hangup with private but no bc ? state:%s l3id:%x\n", get_ch_state(p), p->l3id);
@@ -2967,7 +2966,6 @@
return -1;
}
- p->state = state_machine_get_state(p->sm);
chan_misdn_log(1, bc->port, "Channel: %s hanguped new state:%s\n", ast->name, get_ch_state(p));
return 0;
@@ -3057,7 +3055,6 @@
}
state_machine_run(p->sm, AEVENT_ANSWER);
- p->state = state_machine_get_state(p->sm);
start_bc_tones(p);
@@ -3196,7 +3193,7 @@
if (!ast || !(ch = MISDN_ASTERISK_TECH_PVT(ast)))
return -1;
- if (ch->state == MISDN_HOLDED) {
+ if (state_machine_get_state(ch->sm) == MISDN_HOLDED) {
chan_misdn_log(7, ch->bc ? ch->bc->port : 0, "misdn_write: Returning because holded\n");
return 0;
}
@@ -3268,7 +3265,7 @@
chan_misdn_log(1, p->bc->port, " --> * SEND: State Busy pid:%d\n", p->bc->pid);
ast_setstate(ast, AST_STATE_BUSY);
p->bc->out_cause = 17;
- if (p->state != MISDN_CONNECTED) {
+ if (state_machine_get_state(p->sm) != MISDN_CONNECTED) {
start_bc_tones(p);
misdn_lib_send_event(p->bc, EVENT_DISCONNECT);
} else
@@ -3278,7 +3275,7 @@
chan_misdn_log(1, p->bc->port, " --> * IND :\tring pid:%d\n", p->bc->pid);
return -1;
case AST_CONTROL_RINGING:
- switch (p->state) {
+ switch (state_machine_get_state(p->sm)) {
case MISDN_ALERTING:
chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d but I was Ringing before, so ignoreing it\n", p->bc->pid);
break;
@@ -3286,7 +3283,7 @@
chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d but Connected, so just send TONE_ALERTING without state changes \n", p->bc->pid);
return -1;
default:
- p->state = MISDN_ALERTING;
+ state_machine_set_state(p->sm, MISDN_ALERTING);
chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d\n", p->bc->pid);
misdn_lib_send_event(p->bc, EVENT_ALERTING);
if (p->other_ch && p->other_ch->bc) {
@@ -3331,7 +3328,7 @@
case AST_CONTROL_CONGESTION:
chan_misdn_log(1, p->bc->port, " --> * IND :\tcongestion pid:%d\n", p->bc->pid);
p->bc->out_cause = 42;
- if (p->state != MISDN_CONNECTED) {
+ if (state_machine_get_state(p->sm) != MISDN_CONNECTED) {
start_bc_tones(p);
misdn_lib_send_event(p->bc, EVENT_RELEASE);
} else
@@ -3342,7 +3339,7 @@
case -1:
chan_misdn_log(1, p->bc->port, " --> * IND :\t-1! (stop indication) pid:%d\n", p->bc->pid);
stop_indicate(p);
- if (p->state == MISDN_CONNECTED)
+ if (state_machine_get_state(p->sm) == MISDN_CONNECTED)
start_bc_tones(p);
break;
case AST_CONTROL_HOLD:
@@ -3367,7 +3364,7 @@
chan_misdn_log(1, p->bc ? p->bc->port : 0, "* IND: Got Fixup State:%s L3id:%x\n", get_ch_state(p), p->l3id);
p->ast = ast;
- p->state = MISDN_FIXUP;
+ state_machine_set_state(p->sm, MISDN_FIXUP);
return 0;
}
@@ -3486,7 +3483,7 @@
case EVENT_INFORMATION:
{
stop_indicate(ch);
- if (ch->state == MISDN_WAITING4DIGS) {
+ if (state_machine_get_state(ch->sm) == MISDN_WAITING4DIGS) {
/* Ok, incomplete Setup, waiting till extension exists */
if (ast_strlen_zero(bc->info_dad) && !ast_strlen_zero(bc->keypad)) {
chan_misdn_log(1, bc->port, " --> using keypad as info\n");
@@ -3503,8 +3500,7 @@
if (ast_pickup_call(ch->ast))
hangup_chan(ch);
else {
- ch->state = MISDN_CALLING_ACKNOWLEDGE;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_CALLING_ACKNOWLEDGE);
ast_setstate(ch->ast, AST_STATE_DOWN);
hangup_chan(ch);
ch->ast = NULL;
@@ -3515,8 +3511,7 @@
chan_misdn_log(-1, bc->port, "Extension can never match, so disconnecting.\n");
if (bc->nt)
hanguptone_indicate(ch);
- ch->state = MISDN_EXTCANTMATCH;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_EXTCANTMATCH);
bc->out_cause = 1;
misdn_lib_send_event(bc, EVENT_DISCONNECT);
break;
@@ -3530,8 +3525,7 @@
break;
}
if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
- ch->state = MISDN_DIALING;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_DIALING);
stop_indicate(ch);
if (pbx_start_chan(ch) < 0) {
hangup_chan(ch);
@@ -3541,7 +3535,7 @@
misdn_lib_send_event(bc, EVENT_DISCONNECT);
}
}
- } else if (ch->state != MISDN_CONNECTED) {
+ } else if (state_machine_get_state(ch->sm) != MISDN_CONNECTED) {
/* sending INFOS as DTMF-Frames */
struct ast_frame fr;
strncat(bc->dad, bc->info_dad, sizeof(bc->dad));
@@ -3571,7 +3565,7 @@
dad_len;
if (ch) {
- if (ch->state == MISDN_NOTHING)
+ if (state_machine_get_state(ch->sm) == MISDN_NOTHING)
ch = NULL;
else {
chan_misdn_log(1, bc->port, " --> Ignoring Call we already have one\n");
@@ -3654,8 +3648,7 @@
if (allowed_bearers[i].cap == bc->capability && !strstr(ch->allowed_bearers, allowed_bearers[i].name)) {
chan_misdn_log(0, bc->port, "Bearer Not allowed!\b");
bc->out_cause = 88;
- ch->state = MISDN_EXTCANTMATCH;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_EXTCANTMATCH);
misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
return RESPONSE_OK;
}
@@ -3666,8 +3659,7 @@
if (ast_pickup_call(chan))
hangup_chan(ch);
else {
- ch->state = MISDN_CALLING_ACKNOWLEDGE;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_CALLING_ACKNOWLEDGE);
ast_setstate(chan, AST_STATE_DOWN);
hangup_chan(ch);
ch->ast = NULL;
@@ -3688,16 +3680,14 @@
chan_misdn_log(-1, bc->port, "Extension can never match, so disconnecting\n");
if (bc->nt)
hanguptone_indicate(ch);
- ch->state = MISDN_EXTCANTMATCH;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_EXTCANTMATCH);
bc->out_cause = 1;
misdn_lib_send_event(bc, bc->nt ? EVENT_RELEASE_COMPLETE : EVENT_RELEASE);
break;
}
if (!ch->overlap_dial && ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
- ch->state = MISDN_DIALING;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_DIALING);
misdn_lib_send_event(bc, (bc->nt || (bc->need_more_infos && misdn_lib_is_ptp(bc->port))) ?
EVENT_SETUP_ACKNOWLEDGE : EVENT_PROCEEDING);
if (pbx_start_chan(ch) < 0) {
@@ -3710,8 +3700,7 @@
}
} else {
if (bc->sending_complete) {
- ch->state = MISDN_EXTCANTMATCH;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_EXTCANTMATCH);
bc->out_cause = 1;
chan_misdn_log(0, bc->port, " --> sending_complete so we never match ..\n");
misdn_lib_send_event(bc, bc->nt ? EVENT_RELEASE_COMPLETE : EVENT_RELEASE);
@@ -3725,8 +3714,7 @@
stop_indicate(ch);
else
dialtone_indicate(ch);
- ch->state = MISDN_WAITING4DIGS;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_WAITING4DIGS);
if (ch->overlap_dial && !dad_len) {
ast_mutex_lock(&ch->overlap_tv_lock);
ch->overlap_tv = ast_tvnow();
@@ -3739,8 +3727,7 @@
}
break;
case EVENT_SETUP_ACKNOWLEDGE:
- ch->state = MISDN_CALLING_ACKNOWLEDGE;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_CALLING_ACKNOWLEDGE);
if (bc->channel)
update_name(ch->ast, bc->port, bc->channel);
if (!ast_strlen_zero(bc->infos_pending)) {
@@ -3757,8 +3744,7 @@
case EVENT_PROCEEDING:
if (misdn_cap_is_speech(bc->capability) && misdn_inband_avail(bc))
start_bc_tones(ch);
- ch->state = MISDN_PROCEEDING;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_PROCEEDING);
ast_queue_control(ch->ast, AST_CONTROL_PROCEEDING);
break;
case EVENT_PROGRESS:
@@ -3766,13 +3752,11 @@
if (misdn_cap_is_speech(bc->capability) && misdn_inband_avail(bc))
start_bc_tones(ch);
ast_queue_control(ch->ast, AST_CONTROL_PROGRESS);
- ch->state = MISDN_PROGRESS;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_PROGRESS);
}
break;
case EVENT_ALERTING:
- ch->state = MISDN_ALERTING;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_ALERTING);
ast_queue_control(ch->ast, AST_CONTROL_RINGING);
ast_setstate(ch->ast, AST_STATE_RINGING);
cb_log(1, bc->port, "Set State Ringing\n");
@@ -3805,8 +3789,7 @@
ch->l3id = bc->l3_id;
ch->addr = bc->addr;
start_bc_tones(ch);
- ch->state = MISDN_CONNECTED;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_CONNECTED);
ast_queue_control(ch->ast, AST_CONTROL_ANSWER);
break;
case EVENT_DISCONNECT:
@@ -3814,10 +3797,10 @@
struct chan_list *holded_ch;
/* we might not have an ch->ast ptr here anymore */
if (ch) {
- chan_misdn_log(3, bc->port, " --> org:%d nt:%d, inbandavail:%d state:%d\n", ch->orginator, bc->nt, misdn_inband_avail(bc), ch->state);
- ch->state = MISDN_DISCONNECTED;
- state_machine_set_state(ch->sm, ch->state);
- if (ch->orginator == ORG_AST && !bc->nt && misdn_inband_avail(bc) && ch->state != MISDN_CONNECTED) {
+ chan_misdn_log(3, bc->port, " --> org:%d nt:%d, inbandavail:%d state:%d\n",
+ ch->orginator, bc->nt, misdn_inband_avail(bc), state_machine_get_state(ch->sm));
+ state_machine_set_state(ch->sm, MISDN_DISCONNECTED);
+ if (ch->orginator == ORG_AST && !bc->nt && misdn_inband_avail(bc) && state_machine_get_state(ch->sm) != MISDN_CONNECTED) {
/* If there's inband information available (e.g. a recorded message saying what was wrong with the
* dialled number, or perhaps even giving an alternative number, then play it instead of
* immediately releasing the call */
@@ -3827,7 +3810,7 @@
}
/* Check for holded channel, to implement transfer */
holded_ch = find_holded(cl_te, bc);
- if (holded_ch && holded_ch != ch && ch->ast && ch->state == MISDN_CONNECTED) {
+ if (holded_ch && holded_ch != ch && ch->ast && state_machine_get_state(ch->sm) == MISDN_CONNECTED) {
cb_log(1, bc->port, " --> found holded ch\n");
misdn_transfer_bc(ch, holded_ch) ;
}
@@ -3850,12 +3833,11 @@
stop_bc_tones(ch);
hangup_chan(ch);
release_chan(bc);
- ch->state = MISDN_CLEANING;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_CLEANING);
break;
case EVENT_CLEANUP:
stop_bc_tones(ch);
- if (ch->state == MISDN_CALLING)
+ if (state_machine_get_state(ch->sm) == MISDN_CALLING)
bc->cause = 27; /* Destination out of order */
hangup_chan(ch);
release_chan(bc);
@@ -3929,7 +3911,7 @@
case EVENT_TIMEOUT:
if (ch && bc)
chan_misdn_log(1, bc->port, "--> state: %s\n", get_ch_state(ch));
- switch (ch->state) {
+ switch (state_machine_get_state(ch->sm)) {
case MISDN_CALLING:
case MISDN_DIALING:
case MISDN_PROGRESS:
@@ -3978,8 +3960,7 @@
/*remember the channel again*/
ch->bc = bc;
- ch->state = MISDN_CONNECTED;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_CONNECTED);
hold_ast = AST_BRIDGED_P(ch->ast);
if (hold_ast)
@@ -4002,8 +3983,7 @@
bridged = AST_BRIDGED_P(ch->ast);
if (bridged){
chan_misdn_log(2, bc->port, "Bridge Partner is of type: %s\n", bridged->tech->type);
- ch->state = MISDN_HOLDED;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch->sm, MISDN_HOLDED);
ch->l3id = bc->l3_id;
misdn_lib_send_event(bc, EVENT_HOLD_ACKNOWLEDGE);
/* XXX This should queue an AST_CONTROL_HOLD frame on this channel
@@ -4028,8 +4008,7 @@
struct ast_channel *bridged = AST_BRIDGED_P(ch->ast);
struct chan_list *ch_br = bridged ? MISDN_ASTERISK_TECH_PVT(bridged) : NULL;
if (ch_br && ch_br->bc && ast_exists_extension(bridged, ch->context, (char *)bc->fac_in.u.CDeflection.DeflectedToNumber, 1, bc->oad)) {
- ch_br->state = MISDN_DIALING;
- state_machine_set_state(ch->sm, ch->state);
+ state_machine_set_state(ch_br->sm, MISDN_DIALING);
if (pbx_start_chan(ch_br) < 0)
chan_misdn_log(-1, ch_br->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
}
More information about the asterisk-commits
mailing list