chan = ast_request(type, format, data, &cause); if (chan) { if (oh) { ast_set_variables(chan, oh->vars); ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num); } ast_set_callerid(chan, cid_num, cid_name, cid_num); if (!ast_call(chan, data, 0)) { while(timeout && (chan->_state != AST_STATE_UP)) { res = ast_waitfor(chan, timeout); if (res < 0) { /* Something not cool, or timed out */ break; } /* If done, break out */ if (!res) break; if (timeout > -1) timeout = res; f = ast_read(chan); if (!f) { state = AST_CONTROL_HANGUP; res = 0; break; } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_RINGING) state = AST_CONTROL_RINGING; else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) { state = f->subclass; ast_frfree(f); break; } else if (f->subclass == AST_CONTROL_ANSWER) { state = f->subclass; ast_frfree(f); break; } else if (f->subclass == AST_CONTROL_PROGRESS) { /* Ignore */ } else if (f->subclass == -1) { /* Ignore -- just stopping indications */ } else { ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass); } } ast_frfree(f);