buffer[sizeof(buffer)-1]=0;
va_end(args);
- if (call)
+ if ((unsigned long)call > 1)
sprintf(call_text, "%ld", call->ref);
if (ast)
strncpy(ast_text, ast->name, sizeof(ast_text)-1);
static
struct ast_channel *lcr_request(const char *type, int format, void *data, int *cause)
{
- union parameter newparam;
struct ast_channel *ast;
- struct chan_call *call;
ast_mutex_lock(&chan_lock);
CERROR(NULL, NULL, "Rejecting call from Asterisk, because LCR not running.\n");
return NULL;
}
-
- /* create call instance */
- call = alloc_call();
- if (!call)
- {
- /* failed to create instance */
- return NULL;
- }
+
/* create asterisk channel instrance */
ast = ast_channel_alloc(1, AST_STATE_RESERVED, NULL, NULL, "", NULL, "", 0, "%s/%d", lcr_type, ++glob_channel);
if (!ast)
{
CERROR(NULL, NULL, "Failed to create Asterisk channel.\n");
- free_call(call);
/* failed to create instance */
return NULL;
}
- /* link together */
- call->ast = ast;
- ast->tech_pvt = call;
ast->tech = &lcr_tech;
- ast->fds[0] = call->pipe[0];
+ ast->tech_pvt = (void *)1L; // or asterisk will not call
/* configure channel */
#ifdef TODO
snprintf(ast->name, sizeof(ast->name), "%s/%d", lcr_type, ++glob_channel);
#endif
ast->priority = 1;
ast->hangupcause = 0;
- /* send MESSAGE_NEWREF */
- memset(&newparam, 0, sizeof(union parameter));
- newparam.direction = 0; /* request from app */
- send_message(MESSAGE_NEWREF, 0, &newparam);
- /* set state */
- call->state = CHAN_LCR_STATE_OUT_PREPARE;
ast_mutex_unlock(&chan_lock);
static int lcr_call(struct ast_channel *ast, char *dest, int timeout)
{
struct chan_call *call;
+ union parameter newparam;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
- CERROR(NULL, ast, "Received call from Asterisk, but no call instance exists.\n");
+ if ((unsigned long)call > 1) {
+ CERROR(NULL, ast, "Received call from Asterisk, but call instance already exists.\n");
ast_mutex_unlock(&chan_lock);
return -1;
}
- CDEBUG(call, ast, "Received call from Asterisk.\n");
+ CDEBUG(NULL, ast, "Received call from Asterisk.\n");
-#warning was passiert zwischen lcr_request und lcr_call ?
+ /* create call instance */
+ call = alloc_call();
+ if (!call)
+ {
+ /* failed to create instance */
+ return -1;
+ }
+ /* link together */
+ call->ast = ast;
+ ast->tech_pvt = call;
+ ast->fds[0] = call->pipe[0];
+ /* pbx process is started */
call->pbx_started = 1;
-
- /* send setup message, if we already have a callref */
- if (call->ref)
- send_setup_to_lcr(call);
+ /* send MESSAGE_NEWREF */
+ memset(&newparam, 0, sizeof(union parameter));
+ newparam.direction = 0; /* request from app */
+ send_message(MESSAGE_NEWREF, 0, &newparam);
+ /* set state */
+ call->state = CHAN_LCR_STATE_OUT_PREPARE;
ast_mutex_unlock(&chan_lock);
return 0;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
CERROR(NULL, ast, "Received digit from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
return -1;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
CERROR(NULL, ast, "Received answer from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
return -1;
if (!pthread_equal(tid, chan_tid))
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
CERROR(NULL, ast, "Received hangup from Asterisk, but no call instance exists.\n");
if (!pthread_equal(tid, chan_tid))
ast_mutex_unlock(&chan_lock);
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
ast_mutex_unlock(&chan_lock);
return -1;
}
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
ast_mutex_unlock(&chan_lock);
return NULL;
}
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
CERROR(NULL, ast, "Received indicate from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
return -1;
ast_mutex_lock(&chan_lock);
call = oldast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
CERROR(NULL, oldast, "Received fixup from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
return -1;
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
- if (!call) {
+ if ((unsigned long)call <= 1) {
CERROR(NULL, ast, "Received send_text from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
return -1;