if(option_verbose >= 4)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: DTMF Digit Timeout on %s\n", chan->name);
- if (option_debug)
- ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
+ ast_debug(1,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
res = 1;
break;
}
if ((r = ast_waitfor(chan, -1) < 0)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", r);
+ ast_debug(1, "Waitfor returned %d\n", r);
continue;
}
if (option_verbose >= 3 )
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n");
- if (option_debug)
- ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n");
+ ast_debug(1,"AlarmReceiver: can't write metadata\n");
}
else
res = 0;
if(fd == -1) {
if (option_verbose >= 3)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't make temporary file\n");
- if (option_debug)
- ast_log(LOG_DEBUG,"AlarmReceiver: can't make temporary file\n");
+ ast_debug(1,"AlarmReceiver: can't make temporary file\n");
res = -1;
}
if (option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Received Event %s\n", event);
- if (option_debug)
- ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event);
+ ast_debug(1, "AlarmReceiver: Received event: %s\n", event);
/* Calculate checksum */
database_increment("checksum-errors");
if (option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Nonzero checksum\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n");
+ ast_debug(1, "AlarmReceiver: Nonzero checksum\n");
continue;
}
database_increment("format-errors");
if(option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Wrong message type\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n");
+ ast_debug(1, "AlarmReceiver: Wrong message type\n");
continue;
}
}
*/
if((!res) && (!ast_strlen_zero(event_app)) && (event_head)){
- if (option_debug)
- ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app);
+ ast_debug(1,"Alarmreceiver: executing: %s\n", event_app);
ast_safe_system(event_app);
}
maximumNumberOfWords = atoi(args.argMaximumNumberOfWords);
if (!ast_strlen_zero(args.argSilenceThreshold))
silenceThreshold = atoi(args.argSilenceThreshold);
- } else if (option_debug)
- ast_log(LOG_DEBUG, "AMD using the default parameters.\n");
+ } else {
+ ast_debug(1, "AMD using the default parameters.\n");
+ }
/* Now we're ready to roll! */
if (option_verbose > 2)
if (!(f = ast_read(chan))) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup\n");
+ ast_debug(1, "Got hangup\n");
strcpy(amdStatus, "HANGUP");
break;
}
goto chanquit;
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio);
+ ast_debug(2, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio);
if (ast_async_goto_if_exists(chan2, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio))
ast_log(LOG_WARNING, "%s failed for %s\n", app, args.channel);
tmp[0] = res;
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
- ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
+ ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
pbx_builtin_setvar_helper(chan, "SPY_CHANNEL", name);
running = -2;
break;
- } else if (option_debug > 1) {
- ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ } else {
+ ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
}
} else if (res >= '0' && res <= '9') {
inp[x++] = res;
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
goto exit;
- else if (option_debug > 1)
- ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ else
+ ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
}
}
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
goto exit;
- else if (option_debug > 1)
- ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ else
+ ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
}
/* reset for the next loop around, unless overridden later */
family = strsep(&argv, "/");
keytree = strsep(&argv, "\0");
if (!family || !keytree) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ ast_debug(1, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
family = strsep(&argv, "/");
key = strsep(&argv, "\0");
if (!family || !key) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ ast_debug(1, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
+ ast_debug(1, "Ignoring, no parameters\n");
}
ast_module_user_remove(u);
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
}
} else if (single) {
/* XXX are we sure the logic is correct ? or we should just switch on f->frametype ? */
/* check the results of ast_call */
if (res) {
/* Again, keep going even if there's an error */
- if (option_debug)
- ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
+ ast_debug(1, "ast call on peer returned %d\n", res);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst);
ast_hangup(tc);
number = numsubst;
pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number);
if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", args.url);
+ ast_debug(1, "app_dial: sendurl=%s.\n", args.url);
ast_channel_sendurl( peer, args.url );
}
if ( (ast_test_flag(&opts, OPT_PRIVACY) || ast_test_flag(&opts, OPT_SCREENING)) && pa.privdb_val == AST_PRIVACY_UNKNOWN) {
if (theapp && !res) { /* XXX why check res here ? */
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
+ ast_debug(1, "Macro exited with status %d\n", res);
res = 0;
} else {
ast_log(LOG_ERROR, "Could not find application Macro\n");
hanguptree(outgoing, NULL);
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
senddialendevent(chan, pa.status);
- if (option_debug)
- ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", pa.status);
+ ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) {
if (calldurationlimit)
{
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Call pickup on '%s' by '%s'\n", target->name, chan->name);
+ ast_debug(1, "Call pickup on '%s' by '%s'\n", target->name, chan->name);
if ((res = ast_answer(chan))) {
ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
return -1;
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
- ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
- }
+ ast_debug(1, "Digittimeout: %d\n", digittimeout);
+ ast_debug(1, "Responsetimeout: %d\n", firstdigittimeout);
tmp = ast_strdupa(data);
if (!ast_strlen_zero(args.options))
ast_app_parse_options(app_opts, &flags, NULL, args.options);
- if (option_debug)
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
+ ast_debug(1, "Mailbox: %s\n",args.mailbox);
special_noanswer = 0;
if (ast_test_flag(&flags, NOANSWER_FLAG)) {
acctcode[0] = 0;
/* can we access DISA without password? */
- if (option_debug)
- ast_log(LOG_DEBUG, "Context: %s\n",args.context);
+ ast_debug(1, "Context: %s\n",args.context);
if (!strcasecmp(args.passcode, "no-password")) {
k |= 1; /* We have the password */
- if (option_debug)
- ast_log(LOG_DEBUG, "DISA no-password login success\n");
+ ast_debug(1, "DISA no-password login success\n");
}
lastdigittime = ast_tvnow();
/* if outa time, give em reorder */
if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) >
((k&2) ? digittimeout : firstdigittimeout)) {
- if (option_debug)
- ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
- ((k&1) ? "extension" : "password"),chan->name);
+ ast_debug(1,"DISA %s entry timeout on chan %s\n",
+ ((k&1) ? "extension" : "password"),chan->name);
break;
}
if ((res = ast_waitfor(chan, -1) < 0)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
+ ast_debug(1, "Waitfor returned %d\n", res);
continue;
}
AST_STANDARD_APP_ARGS(args, pwline);
- if (option_debug)
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
+ ast_debug(1, "Mailbox: %s\n",args.mailbox);
/* password must be in valid format (numeric) */
if (sscanf(args.passcode,"%d", &j) < 1)
}
/* password good, set to dial state */
- if (option_debug)
- ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name);
+ ast_debug(1,"DISA on chan %s password is good\n",chan->name);
play_dialtone(chan, args.mailbox);
k|=1; /* In number mode */
exten[sizeof(acctcode)] = 0;
ast_copy_string(acctcode, exten, sizeof(acctcode));
exten[0] = 0;
- if (option_debug)
- ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
+ ast_debug(1,"Successful DISA log-in on chan %s\n", chan->name);
continue;
}
}
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (option_debug)
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ ast_debug(1, "User pressed a key\n");
if (intkeys && strchr(intkeys, f->subclass)) {
res = f->subclass;
ast_frfree(f);
break;
}
if (res < needed) { /* last frame */
- if (option_debug)
- ast_log(LOG_DEBUG, "Last frame\n");
+ ast_debug(1, "Last frame\n");
res=0;
ast_frfree(f);
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No more waveform\n");
+ ast_debug(1, "No more waveform\n");
res = 0;
}
}
intstr = AST_DIGIT_ANY;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
+ ast_debug(1, "Text passed to festival server : %s\n",(char *)data);
/* Connect to local festival server */
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fdesc!=-1) {
writecache=1;
strln=strlen((char *)data);
- if (option_debug)
- ast_log(LOG_DEBUG,"line length : %d\n",strln);
+ ast_debug(1,"line length : %d\n",strln);
write(fdesc,&strln,sizeof(int));
write(fdesc,data,strln);
seekpos=lseek(fdesc,0,SEEK_CUR);
- if (option_debug)
- ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
+ ast_debug(1,"Seek position : %d\n",seekpos);
}
} else {
read(fdesc,&strln,sizeof(int));
- if (option_debug)
- ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
+ ast_debug(1,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
if (strlen((char *)data)==strln) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Size OK\n");
+ ast_debug(1,"Size OK\n");
read(fdesc,&bigstring,strln);
bigstring[strln] = 0;
if (strcmp(bigstring,data)==0) {
if (readcache==1) {
close(fd);
fd=fdesc;
- if (option_debug)
- ast_log(LOG_DEBUG,"Reading from cache...\n");
+ ast_debug(1,"Reading from cache...\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"Passing text to festival...\n");
+ ast_debug(1,"Passing text to festival...\n");
fs=fdopen(dup(fd),"wb");
fprintf(fs,festivalcommand,(char *)data);
fflush(fs);
/* Write to cache and then pass it down */
if (writecache==1) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Writing result to cache...\n");
+ ast_debug(1,"Writing result to cache...\n");
while ((strln=read(fd,buffer,16384))!=0) {
write(fdesc,buffer,strln);
}
lseek(fd,seekpos,SEEK_SET);
}
- if (option_debug)
- ast_log(LOG_DEBUG,"Passing data to channel...\n");
+ ast_debug(1,"Passing data to channel...\n");
/* Read back info from server */
/* This assumes only one waveform will come back, also LP is unlikely */
}
ack[3] = '\0';
if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */
- if (option_debug)
- ast_log(LOG_DEBUG,"Festival WV command\n");
+ ast_debug(1,"Festival WV command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
res = send_waveform_to_channel(chan,waveform,filesize, intstr);
ast_free(waveform);
break;
}
else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
- if (option_debug)
- ast_log(LOG_DEBUG,"Festival LP command\n");
+ ast_debug(1,"Festival LP command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
waveform[filesize]='\0';
ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform);
*tmp = '\0';
ast_copy_string(cur->number, number, sizeof(cur->number));
cur->order = numorder;
- if (option_debug)
- ast_log(LOG_DEBUG, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout);
+ ast_debug(1, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout);
return cur;
}
if (!strcasecmp(f->name, cat))
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "New profile %s.\n", cat);
+ ast_debug(1, "New profile %s.\n", cat);
if (!f) {
/* Make one then */
f = alloc_profile(cat);
AST_LIST_INSERT_TAIL(&f->numbers, cur, entry);
} else {
profile_set_param(f, var->name, var->value, var->lineno, 1);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
+ ast_debug(2, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
}
var = var->next;
} /* End while(var) loop */
ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", winner->name);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
break;
}
}
if (winner->stream)
ast_stopstream(winner);
tmpuser->digts = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF received: %c\n",(char) f->subclass);
+ ast_debug(1, "DTMF received: %c\n",(char) f->subclass);
tmpuser->yn[tmpuser->ynidx] = (char) f->subclass;
tmpuser->ynidx++;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF string: %s\n", tmpuser->yn);
+ ast_debug(1, "DTMF string: %s\n", tmpuser->yn);
if (tmpuser->ynidx >= ynlongest) {
- if (option_debug)
- ast_log(LOG_DEBUG, "reached longest possible match - doing evals\n");
+ ast_debug(1, "reached longest possible match - doing evals\n");
if (!strcmp(tmpuser->yn, tpargs->takecall)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Match to take the call!\n");
+ ast_debug(1, "Match to take the call!\n");
ast_frfree(f);
return tmpuser->ochan;
}
if (!strcmp(tmpuser->yn, tpargs->nextindp)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Next in dial plan step requested.\n");
+ ast_debug(1, "Next in dial plan step requested.\n");
*status = 1;
ast_frfree(f);
return NULL;
ast_frfree(f);
} else {
if (winner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "we didn't get a frame. hanging up. dg is %d\n",dg);
+ ast_debug(1, "we didn't get a frame. hanging up. dg is %d\n",dg);
if (!dg) {
clear_calling_tree(findme_user_list);
return NULL;
tmpuser->state = -1;
ast_hangup(winner);
livechannels--;
- if (option_debug)
- ast_log(LOG_DEBUG, "live channels left %d\n", livechannels);
+ ast_debug(1, "live channels left %d\n", livechannels);
if (!livechannels) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "no live channels left. exiting.\n");
}
} else
- if (option_debug)
- ast_log(LOG_DEBUG, "timed out waiting for action\n");
+ ast_debug(1, "timed out waiting for action\n");
}
} else {
while (nm) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Number %s timeout %ld\n", nm->number,nm->timeout);
+ ast_debug(2, "Number %s timeout %ld\n", nm->number,nm->timeout);
time(&start_time);
number = ast_strdupa(nm->number);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "examining %s\n", number);
+ ast_debug(3, "examining %s\n", number);
do {
rest = strchr(number, '&');
if (rest) {
}
AST_LIST_UNLOCK(&followmes);
- if (option_debug)
- ast_log(LOG_DEBUG, "New profile %s.\n", args.followmeid);
+ ast_debug(1, "New profile %s.\n", args.followmeid);
if (!f) {
ast_log(LOG_WARNING, "Profile requested, %s, not found in the configuration.\n", args.followmeid);
res = 0;
/* Wait for audio, and stream */
ms = ast_waitfor(chan, -1);
if (ms < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ ast_debug(1, "Hangup detected\n");
res = -1;
break;
}
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ ast_debug(1, "Null frame == hangup() detected\n");
res = -1;
break;
}
/* If we are to run the macro exclusively, take the mutex */
if (exclusive) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Locking macrolock for '%s'\n", fullmacro);
+ ast_debug(1, "Locking macrolock for '%s'\n", fullmacro);
ast_autoservice_start(chan);
if (ast_context_lockmacro(fullmacro)) {
ast_log(LOG_WARNING, "Failed to lock macro '%s' as in-use\n", fullmacro);
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) ||
(res == '*') || (res == '#')) {
/* Just return result as to the previous application as if it had been dialed */
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
+ ast_debug(1, "Oooh, got something to jump out with ('%c')!\n", res);
break;
}
switch(res) {
res = 0;
goto out;
case AST_PBX_KEEPALIVE:
- if (option_debug)
- ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
- else if (option_verbose > 1)
+ ast_debug(2, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
+ if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE in macro '%s' on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
goto out;
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
- else if (option_verbose > 1)
+ ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
+ if (option_verbose > 1)
ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
dead = 1;
goto out;
}
}
- ast_log(LOG_DEBUG, "Executed application: %s\n", runningapp);
+ ast_debug(1, "Executed application: %s\n", runningapp);
if (!strcasecmp(runningapp, "GOSUB")) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
} else if (!strcasecmp(runningapp, "GOSUBIF")) {
char tmp2[1024] = "", *cond, *app, *app2 = tmp2;
pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1);
if (pbx_checkcondition(cond)) {
if (!ast_strlen_zero(app)) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
}
} else {
if (!ast_strlen_zero(app2)) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
}
}
} else if (!strcasecmp(runningapp, "RETURN")) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
} else if (!strcasecmp(runningapp, "STACKPOP")) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
} else if (!strncasecmp(runningapp, "EXEC", 4)) {
/* Must evaluate args to find actual app */
char tmp2[1024] = "", *tmp3 = NULL;
tmp3 = tmp2;
if (tmp3)
- ast_log(LOG_DEBUG, "Last app: %s\n", tmp3);
+ ast_debug(1, "Last app: %s\n", tmp3);
if (tmp3 && !strncasecmp(tmp3, "GOSUB", 5)) {
gosub_level++;
- ast_log(LOG_DEBUG, "Incrementing gosub_level\n");
+ ast_debug(1, "Incrementing gosub_level\n");
} else if (tmp3 && !strncasecmp(tmp3, "RETURN", 6)) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
} else if (tmp3 && !strncasecmp(tmp3, "STACKPOP", 8)) {
gosub_level--;
- ast_log(LOG_DEBUG, "Decrementing gosub_level\n");
+ ast_debug(1, "Decrementing gosub_level\n");
}
}
/* don't stop executing extensions when we're in "h" */
if (chan->_softhangup && !inhangup) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n",
- chan->exten, chan->macroexten, chan->priority);
+ ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", chan->exten, chan->macroexten, chan->priority);
goto out;
}
chan->priority++;
/* Unlock the macro */
if (exclusive) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlocking macrolock for '%s'\n", fullmacro);
+ ast_debug(1, "Unlocking macrolock for '%s'\n", fullmacro);
if (ast_context_unlockmacro(fullmacro)) {
ast_log(LOG_ERROR, "Failed to unlock macro '%s' - that isn't good\n", fullmacro);
res = 0;
} else
return RESULT_SHOWUSAGE;
- if (option_debug)
- ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
+ ast_debug(1, "Cmdline: %s\n", cmdline);
admin_exec(NULL, cmdline);
AST_RWLIST_UNLOCK(&sla_stations);
if (!trunk_ref) {
- ast_log(LOG_DEBUG, "Trunk not found for event!\n");
+ ast_debug(1, "Trunk not found for event!\n");
return;
}
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
ast_mutex_unlock(&conf->playlock);
goto outrun;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
+ ast_debug(1, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
if (!sent_event) {
manager_event(EVENT_FLAG_CALL, "MeetmeJoin",
close(fd);
using_pseudo = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ ast_debug(1, "Ooh, something swapped out under us, starting over\n");
retryzap = strcasecmp(c->tech->type, "Zap");
user->zapchannel = !retryzap;
goto zapretry;
tmp[0] = f->subclass;
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
+ ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
ret = 0;
ast_frfree(f);
break;
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ } else {
+ ast_debug(2, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ }
} else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) {
ret = 0;
ast_frfree(f);
if (!cnf) {
if (dynamic) {
/* No need to parse meetme.conf */
- if (option_debug)
- ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno);
+ ast_debug(1, "Building dynamic conference '%s'\n", confno);
if (dynamic_pin) {
if (dynamic_pin[0] == 'q') {
/* Query the user to enter a PIN */
}
}
if (!var) {
- ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno);
+ ast_debug(1, "%s isn't a valid conference\n", confno);
}
ast_config_destroy(cfg);
}
ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1);
ast_mutex_unlock(&sla.lock);
if (!ringing_trunk) {
- ast_log(LOG_DEBUG, "Found no ringing trunk for station '%s' to answer!\n",
- ringing_station->station->name);
+ ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name);
break;
}
/* Track the channel that answered this trunk */
ast_cond_destroy(&cond);
ast_autoservice_stop(chan);
if (!trunk_ref->trunk->chan) {
- ast_log(LOG_DEBUG, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan);
+ ast_debug(1, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan);
pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION");
sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
trunk_ref->chan = NULL;
}
while (var) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name);
+ ast_debug(3, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name);
if (!strcasecmp(var->name, "fromaddress")) {
ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress));
} else if (!strcasecmp(var->name, "fromemail")) {
ast_log(LOG_NOTICE, "No username or domain? \n");
return NULL;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain);
+ ast_debug(3, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain);
AST_LIST_LOCK(&minivm_accounts);
AST_LIST_TRAVERSE(&minivm_accounts, cur, list) {
AST_LIST_UNLOCK(&minivm_accounts);
if (cur) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Found account for %s@%s\n", username, domain);
+ ast_debug(3, "-_-_- Found account for %s@%s\n", username, domain);
vmu = cur;
} else
if (vmu) {
ast_copy_string(vmu->username, username, sizeof(vmu->username));
ast_copy_string(vmu->domain, domain, sizeof(vmu->domain));
- if (option_debug)
- ast_log(LOG_DEBUG, "--- Created temporary account\n");
+ ast_debug(1, "--- Created temporary account\n");
}
}
return -1;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name);
+ ast_debug(3, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name);
if (!strcmp(format, "wav49"))
format = "WAV";
int tmpfd;
snprintf(newtmp, sizeof(newtmp), "/tmp/XXXXXX");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ ast_debug(3, "newtmp: %s\n", newtmp);
tmpfd = mkstemp(newtmp);
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
ast_safe_system(tmpcmd);
/* Create file name */
snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format);
- if (option_debug && template->attachment)
- ast_log(LOG_DEBUG, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail);
+ if (template->attachment)
+ ast_debug(1, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail);
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
close(pfd);
pfd = -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "-_-_- Opening temp file for e-mail: %s\n", tmp);
+ ast_debug(1, "-_-_- Opening temp file for e-mail: %s\n", tmp);
}
if (!p) {
ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp);
if (ast_strlen_zero(fromaddress)) {
fprintf(p, "From: Asterisk PBX <%s>\n", who);
} else {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "-_-_- Fromaddress template: %s\n", fromaddress);
+ ast_debug(4, "-_-_- Fromaddress template: %s\n", fromaddress);
/* Allocate a buffer big enough for variable substitution */
int vmlen = strlen(fromaddress) * 3 + 200;
return -1;
}
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata);
+ ast_debug(4, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata);
fprintf(p, "Message-ID: <Asterisk-%d-%s-%d-%s>\n", (unsigned int)rand(), vmu->username, getpid(), who);
len_passdata = strlen(vmu->fullname) * 2 + 3;
fclose(p);
return -1;
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "-_-_- Subject now: %s\n", passdata);
+
+ ast_debug(4, "-_-_- Subject now: %s\n", passdata);
+
} else {
fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain);
- ast_log(LOG_DEBUG, "-_-_- Using default subject for this email \n");
+ ast_debug(1, "-_-_- Using default subject for this email \n");
}
if ((passdata = alloca(vmlen))) {
memset(passdata, 0, vmlen);
pbx_substitute_variables_helper(ast, template->body, passdata, vmlen);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Message now: %s\n-----\n", passdata);
+ ast_debug(3, "Message now: %s\n-----\n", passdata);
fprintf(p, "%s\n", passdata);
} else
ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
"in mailbox %s from %s, on %s so you might\n"
"want to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname,
dur, vmu->username, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Using default message body (no template)\n-----\n");
+ ast_debug(3, "Using default message body (no template)\n-----\n");
}
/* Eww. We want formats to tell us their own MIME type */
if (template->attachment) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Attaching file to message: %s\n", fname);
+ ast_debug(3, "-_-_- Attaching file to message: %s\n", fname);
char *ctype = "audio/x-";
if (!strcasecmp(format, "ogg"))
ctype = "application/";
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- if (option_debug) {
- ast_log(LOG_DEBUG, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Actual command used: %s\n", tmp2);
- }
+ ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : "");
+ ast_debug(3, "-_-_- Actual command used: %s\n", tmp2);
if (ast)
ast_channel_free(ast);
return 0;
return -1;
}
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest);
+ ast_debug(2, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest);
return 0;
}
int res;
char fn[PATH_MAX];
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Still preparing to play message ...\n");
+ ast_debug(2, "-_-_- Still preparing to play message ...\n");
snprintf(fn, sizeof(fn), "%s%s/%s/greet", MVM_SPOOL_DIR, domain, username);
int numericusername = 1;
char *i = username;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- No personal prompts. Using default prompt set for language\n");
+ ast_debug(2, "-_-_- No personal prompts. Using default prompt set for language\n");
while (*i) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Numeric? Checking %c\n", *i);
+ ast_debug(2, "-_-_- Numeric? Checking %c\n", *i);
if (!isdigit(*i)) {
numericusername = FALSE;
break;
{
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "-_-_- Deleting voicemail file %s\n", file);
+ ast_debug(1, "-_-_- Deleting voicemail file %s\n", file);
res = unlink(file); /* Remove the meta data file */
res |= ast_filedelete(file, NULL); /* remove the media file */
vmu->username, vmu->domain,
chan->cid.cid_name, chan->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Executing: %s\n", arguments);
-
+ ast_debug(1, "Executing: %s\n", arguments);
ast_safe_system(arguments);
}
if (!ast_strlen_zero(etemplate->locale)) {
char *newlocale;
ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale));
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale);
+ ast_debug(2, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale);
newlocale = setlocale(LC_TIME, etemplate->locale);
if (newlocale == NULL) {
ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale);
/* Read counter if available */
counter = pbx_builtin_getvar_helper(chan, "MVM_COUNTER");
- if (option_debug > 1) {
- if (ast_strlen_zero(counter))
- ast_log(LOG_DEBUG, "-_-_- MVM_COUNTER not found\n");
- else
- ast_log(LOG_DEBUG, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter);
+ if (ast_strlen_zero(counter)) {
+ ast_debug(2, "-_-_- MVM_COUNTER not found\n");
+ } else {
+ ast_debug(2, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter);
}
res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_EMAIL, counter);
/* If we have no user directory, use generic temporary directory */
if (!userdir) {
create_dirpath(tmpdir, sizeof(tmpdir), "0000_minivm_temp", "mediafiles", "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Creating temporary directory %s\n", tmpdir);
+ ast_debug(3, "Creating temporary directory %s\n", tmpdir);
}
/* OEJ XXX Maybe this can be turned into a log file? Hmm. */
/* Store information */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Open file for metadata: %s\n", tmptxtfile);
+ ast_debug(2, "Open file for metadata: %s\n", tmptxtfile);
res = play_record_review(chan, NULL, tmptxtfile, global_vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain);
}
fclose(txt); /* Close log file */
if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
+ ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n");
unlink(tmptxtfile);
pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED))
// /* Go ahead and delete audio files from system, they're not needed any more */
// if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
// ast_filedelete(tmptxtfile, NULL);
-// if (option_debug > 1)
-// ast_log(LOG_DEBUG, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile);
+// /* Even not being used at the moment, it's better to convert ast_log to ast_debug anyway */
+// ast_debug(2, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile);
// }
if (res > 0)
ast_module_user_remove(u);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain);
+ ast_debug(1, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain);
if (!(vmu = find_account(domain, username, TRUE))) {
ast_log(LOG_ERROR, "Could not allocate memory. \n");
/* Check for temporary greeting - it overrides busy and unavail */
snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", MVM_SPOOL_DIR, vmu->domain, username);
if (!(res = check_dirpath(dest, sizeof(dest), vmu->domain, username, "temp"))) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Temporary message directory does not exist, using default (%s)\n", tempfile);
+ ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile);
ast_copy_string(prefile, tempfile, sizeof(prefile));
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Preparing to play message ...\n");
+ ast_debug(2, "-_-_- Preparing to play message ...\n");
/* Check current or macro-calling context for special extensions */
if (ast_test_flag(vmu, MVM_OPERATOR)) {
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+ ast_debug(2, "%s doesn't exist, doing what we can\n", prefile);
res = invent_message(chan, vmu->domain, username, ast_test_flag(&leave_options, OPT_BUSY_GREETING), ecodes);
}
if (res < 0) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+ ast_debug(2, "Hang up during prefile playback\n");
pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "FAILED");
if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu);
if (ast_fileexists(filename, NULL, NULL) > 0) {
res = vm_delete(filename);
if (res) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Can't delete file: %s\n", filename);
+ ast_debug(2, "-_-_- Can't delete file: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED");
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Deleted voicemail file :: %s \n", filename);
+ ast_debug(2, "-_-_- Deleted voicemail file :: %s \n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "SUCCESS");
}
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Filename does not exist: %s\n", filename);
+ ast_debug(2, "-_-_- Filename does not exist: %s\n", filename);
pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED");
}
/* Maybe we should check the result of play_record_review ? */
cmd = play_record_review(chan, prompt, filename, global_maxgreet, default_vmformat, 0, vmu, &duration, NULL, FALSE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Recorded new %s message in %s (duration %d)\n", message, filename, duration);
+ ast_debug(1, "Recorded new %s message in %s (duration %d)\n", message, filename, duration);
if(ast_test_flag(vmu, MVM_ALLOCED))
free_user(vmu);
char *username;
char accbuf[BUFSIZ];
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name);
+ ast_debug(3, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name);
ast_copy_string(accbuf, name, sizeof(accbuf));
username = accbuf;
return 0;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Creating static account for user %s domain %s\n", username, domain);
+ ast_debug(3, "Creating static account for user %s domain %s\n", username, domain);
/* Allocate user account */
vmu = ast_calloc(1, sizeof(*vmu));
populate_defaults(vmu);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "...Configuring account %s\n", name);
+ ast_debug(3, "...Configuring account %s\n", name);
while (var) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name);
+ ast_debug(3, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name);
if (!strcasecmp(var->name, "serveremail")) {
ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail));
} else if (!strcasecmp(var->name, "email")) {
}
var = var->next;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "...Linking account %s\n", name);
+ ast_debug(3, "...Linking account %s\n", name);
AST_LIST_LOCK(&minivm_accounts);
AST_LIST_INSERT_TAIL(&minivm_accounts, vmu, list);
global_stats.voicemailaccounts++;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : "");
+ ast_debug(2, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : "");
return 0;
}
fclose(fi);
messagebody = ast_calloc(1, strlen(buf + 1));
ast_copy_string(messagebody, buf, strlen(buf) + 1);
- if (option_debug > 3) {
- ast_log(LOG_DEBUG, "---> Size of allocation %d\n", (int) strlen(buf + 1) );
- ast_log(LOG_DEBUG, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody);
- }
+ ast_debug(4, "---> Size of allocation %d\n", (int) strlen(buf + 1) );
+ ast_debug(4, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody);
return messagebody;
}
message_destroy_list(); /* Destroy list of voicemail message templates */
timezone_destroy_list(); /* Destroy list of timezones */
vmaccounts_destroy_list(); /* Destroy list of voicemail accounts */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Destroyed memory objects...\n");
+ ast_debug(2, "Destroyed memory objects...\n");
/* First, set some default settings */
global_externnotify[0] = '\0';
return 0;
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "-_-_- Loaded configuration file, now parsing\n");
+ ast_debug(2, "-_-_- Loaded configuration file, now parsing\n");
/* General settings */
cat = ast_category_browse(cfg, NULL);
while (cat) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-_-_- Found configuration section [%s]\n", cat);
+ ast_debug(3, "-_-_- Found configuration section [%s]\n", cat);
if (!strcasecmp(cat, "general")) {
/* Nothing right now */
error += apply_general_options(ast_variable_browse(cfg, cat));
minivmlogfile = fopen(global_logfile, "a");
if(!minivmlogfile)
ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno));
- if (option_debug > 2 && minivmlogfile)
- ast_log(LOG_DEBUG, "-_-_- Opened log file %s \n", global_logfile);
+ if (minivmlogfile)
+ ast_debug(3, "-_-_- Opened log file %s \n", global_logfile);
}
return 0;
counterfile = fopen(filename, "r");
if (counterfile) {
if(fgets(readbuf, sizeof(readbuf), counterfile)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Read this string from counter file: %s\n", readbuf);
+ ast_debug(3, "Read this string from counter file: %s\n", readbuf);
old = counter = atoi(readbuf);
}
fclose(counterfile);
switch (operand) {
case 0: /* Read only */
ast_unlock_path(directory);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter);
+ ast_debug(2, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter);
return counter;
break;
case 1: /* Set new value */
fprintf(counterfile, "%d\n\n", counter);
fclose(counterfile);
ast_unlock_path(directory);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter);
+ ast_debug(2, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter);
return counter;
}
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No more mp3\n");
+ ast_debug(1, "No more mp3\n");
res = 0;
break;
}
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ ast_debug(1, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ ast_debug(1, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (option_debug)
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ ast_debug(1, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No more mp3\n");
+ ast_debug(1, "No more mp3\n");
res = 0;
break;
}
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ ast_debug(1, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ ast_debug(1, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- if (option_debug)
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ ast_debug(1, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
} else {
snprintf(p->privatekey, sizeof(p->privatekey), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: privatekey '%s'\n", p->privatekey);
+ ast_debug(1, "OSP: privatekey '%s'\n", p->privatekey);
} else if (!strcasecmp(v->name, "localcert")) {
if (v->value[0] == '/') {
ast_copy_string(p->localcert, v->value, sizeof(p->localcert));
} else {
snprintf(p->localcert, sizeof(p->localcert), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: localcert '%s'\n", p->localcert);
+ ast_debug(1, "OSP: localcert '%s'\n", p->localcert);
} else if (!strcasecmp(v->name, "cacert")) {
if (p->cacount < OSP_MAX_CERTS) {
if (v->value[0] == '/') {
} else {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ ast_debug(1, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
p->cacount++;
} else {
ast_log(LOG_WARNING, "OSP: Too many CA Certificates at line %d\n", v->lineno);
} else if (!strcasecmp(v->name, "servicepoint")) {
if (p->spcount < OSP_MAX_SRVS) {
ast_copy_string(p->srvpoints[p->spcount], v->value, sizeof(p->srvpoints[0]));
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]);
+ ast_debug(1, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]);
p->spcount++;
} else {
ast_log(LOG_WARNING, "OSP: Too many Service Points at line %d\n", v->lineno);
} else if (!strcasecmp(v->name, "maxconnections")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_MAXCONNECTIONS) && (t <= OSP_MAX_MAXCONNECTIONS)) {
p->maxconnections = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: maxconnections '%d'\n", t);
+ ast_debug(1, "OSP: maxconnections '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: maxconnections should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_MAXCONNECTIONS, OSP_MAX_MAXCONNECTIONS, v->value, v->lineno);
} else if (!strcasecmp(v->name, "retrydelay")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_RETRYDELAY) && (t <= OSP_MAX_RETRYDELAY)) {
p->retrydelay = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: retrydelay '%d'\n", t);
+ ast_debug(1, "OSP: retrydelay '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: retrydelay should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_RETRYDELAY, OSP_MAX_RETRYDELAY, v->value, v->lineno);
} else if (!strcasecmp(v->name, "retrylimit")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_RETRYLIMIT) && (t <= OSP_MAX_RETRYLIMIT)) {
p->retrylimit = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: retrylimit '%d'\n", t);
+ ast_debug(1, "OSP: retrylimit '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: retrylimit should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_RETRYLIMIT, OSP_MAX_RETRYLIMIT, v->value, v->lineno);
} else if (!strcasecmp(v->name, "timeout")) {
if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_TIMEOUT) && (t <= OSP_MAX_TIMEOUT)) {
p->timeout = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: timeout '%d'\n", t);
+ ast_debug(1, "OSP: timeout '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: timeout should be an integer from %d to %d, not '%s' at line %d\n",
OSP_MIN_TIMEOUT, OSP_MAX_TIMEOUT, v->value, v->lineno);
}
} else if (!strcasecmp(v->name, "source")) {
ast_copy_string(p->source, v->value, sizeof(p->source));
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", p->source);
+ ast_debug(1, "OSP: source '%s'\n", p->source);
} else if (!strcasecmp(v->name, "authpolicy")) {
if ((sscanf(v->value, "%d", &t) == 1) && ((t == OSP_AUTH_NO) || (t == OSP_AUTH_YES) || (t == OSP_AUTH_EXCLUSIVE))) {
p->authpolicy = t;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", t);
+ ast_debug(1, "OSP: authpolicy '%d'\n", t);
} else {
ast_log(LOG_WARNING, "OSP: authpolicy should be %d, %d or %d, not '%s' at line %d\n",
OSP_AUTH_NO, OSP_AUTH_YES, OSP_AUTH_EXCLUSIVE, v->value, v->lineno);
} else if (!strcasecmp(v->name, "defaultprotocol")) {
if (!strcasecmp(v->value, OSP_PROT_SIP)) {
p->defaultprotocol = OSP_PROT_SIP;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol);
+ ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol);
} else if (!strcasecmp(v->value, OSP_PROT_H323)) {
p->defaultprotocol = OSP_PROT_H323;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol);
+ ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol);
} else if (!strcasecmp(v->value, OSP_PROT_IAX)) {
p->defaultprotocol = OSP_PROT_IAX;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol);
+ ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol);
} else {
ast_log(LOG_WARNING, "OSP: default protocol should be %s, %s, %s, or %s not '%s' at line %d\n",
OSP_PROT_SIP, OSP_PROT_H323, OSP_PROT_IAX, OSP_PROT_OTHER, v->value, v->lineno);
if (p->cacount < 1) {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s-cacert.pem", ast_config_AST_KEY_DIR, provider);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ ast_debug(1, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
p->cacount++;
}
for (i = 0; i < p->cacount; i++) {
ast_free(p);
res = -1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider);
+ ast_debug(1, "OSP: provider '%s'\n", provider);
ast_mutex_lock(&osplock);
p->next = ospproviders;
ospproviders = p;
while(p) {
if (!strcasecmp(p->name, name)) {
*provider = p;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: find provider '%s'\n", name);
+ ast_debug(1, "OSP: find provider '%s'\n", name);
res = 1;
break;
}
if (!strcasecmp(p->name, provider)) {
error = OSPPTransactionNew(p->handle, transaction);
if (error == OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction);
+ ast_debug(1, "OSP: transaction '%d'\n", *transaction);
ast_copy_string(source, p->source, sourcesize);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", source);
+ ast_debug(1, "OSP: source '%s'\n", source);
res = 1;
} else {
*transaction = OSP_INVALID_HANDLE;
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to create transaction handle, error '%d'\n", error);
res = -1;
}
break;
NULL,
osp_tokenformat);
if (error != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n");
+ ast_debug(1, "OSP: Unable to validate inbound token\n");
res = -1;
} else if (authorised) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Authorised\n");
+ ast_debug(1, "OSP: Authorised\n");
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unauthorised\n");
+ ast_debug(1, "OSP: Unauthorised\n");
res = 0;
}
int error;
if (strlen(destination) <= 2) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination);
+ ast_debug(1, "OSP: Wrong destination format '%s'\n", destination);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
if ((error = OSPPTransactionIsDestOSPEnabled(result->outhandle, &enabled)) != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get destination OSP version, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
}
if ((error = OSPPTransactionGetDestNetworkId(result->outhandle, result->networkid)) != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get destination network ID, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get destination network ID, error '%d'\n", error);
result->networkid[0] = '\0';
}
if ((error = OSPPTransactionGetDestProtocol(result->outhandle, &protocol)) != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get destination protocol, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
result->token[0] = '\0';
result->networkid[0] = '\0';
destination[strlen(destination) - 1] = '\0';
switch(protocol) {
case OSPE_DEST_PROT_H323_SETUP:
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_H323);
+ ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_H323);
ast_copy_string(result->tech, OSP_TECH_H323, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_SIP:
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_SIP);
+ ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_SIP);
ast_copy_string(result->tech, OSP_TECH_SIP, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_IAX:
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_IAX);
+ ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_IAX);
ast_copy_string(result->tech, OSP_TECH_IAX, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
break;
case OSPE_DEST_PROT_UNDEFINED:
case OSPE_DEST_PROT_UNKNOWN:
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: unknown/undefined protocol '%d'\n", protocol);
- ast_log(LOG_DEBUG, "OSP: use default protocol '%s'\n", provider->defaultprotocol);
- }
+ ast_debug(1, "OSP: unknown/undefined protocol '%d'\n", protocol);
+ ast_debug(1, "OSP: use default protocol '%s'\n", provider->defaultprotocol);
+
ast_copy_string(result->tech, provider->defaultprotocol, sizeof(result->tech));
ast_copy_string(result->dest, destination + 1, sizeof(result->dest));
ast_copy_string(result->called, called, sizeof(result->called));
*timelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_get_provider(provider, &p)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider);
+ ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider);
return res;
}
if (ast_strlen_zero(token)) {
res = 0;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ ast_debug(1, "OSP: Unable to generate transaction handle\n");
*transaction = OSP_INVALID_HANDLE;
res = 0;
} else if((res = osp_validate_token(*transaction, source, dest, calling, called, token, timelimit)) <= 0) {
if (ast_strlen_zero(token)) {
res = 1;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ ast_debug(1, "OSP: Unable to generate transaction handle\n");
*transaction = OSP_INVALID_HANDLE;
res = 0;
} else if((res = osp_validate_token(*transaction, source, dest, calling, called, token, timelimit)) <= 0) {
result->outtimelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_get_provider(provider, &p)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider);
+ ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider);
return res;
}
if ((res = osp_create_transaction(provider, &result->outhandle, sizeof(source), source)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ ast_debug(1, "OSP: Unable to generate transaction handle\n");
result->outhandle = OSP_INVALID_HANDLE;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
}
if (error != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");
+ ast_debug(1, "OSP: Unable to request authorization\n");
result->numresults = 0;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
}
if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
}
&tokenlen,
token);
if (error != OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get first route\n");
+ ast_debug(1, "OSP: Unable to get first route\n");
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->inhandle != OSP_INVALID_HANDLE) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit);
- ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum);
- ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum);
- ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination);
- ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen);
- }
+ ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit);
+ ast_debug(1, "OSP: called '%s'\n", callednum);
+ ast_debug(1, "OSP: calling '%s'\n", callingnum);
+ ast_debug(1, "OSP: destination '%s'\n", destination);
+ ast_debug(1, "OSP: token size '%d'\n", tokenlen);
if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
return 1;
}
if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
result->outtimelimit = OSP_DEF_TIMELIMIT;
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
if (error == OSPC_ERR_NO_ERROR) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit);
- ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum);
- ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum);
- ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination);
- ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen);
- }
+ ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit);
+ ast_debug(1, "OSP: called '%s'\n", callednum);
+ ast_debug(1, "OSP: calling '%s'\n", callingnum);
+ ast_debug(1, "OSP: destination '%s'\n", destination);
+ ast_debug(1, "OSP: token size '%d'\n", tokenlen);
+
if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
break;
} else if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get route, error '%d'\n", error);
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->inhandle != OSP_INVALID_HANDLE) {
result->outtimelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_get_provider(provider, &p)) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider);
+ ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider);
return res;
}
if (result->outhandle == OSP_INVALID_HANDLE) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Transaction handle undefined\n");
+ ast_debug(1, "OSP: Transaction handle undefined\n");
result->numresults = 0;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
reason = asterisk2osp(cause);
if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
if (error == OSPC_ERR_NO_ERROR) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit);
- ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum);
- ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum);
- ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination);
- ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen);
- }
+ ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit);
+ ast_debug(1, "OSP: called '%s'\n", callednum);
+ ast_debug(1, "OSP: calling '%s'\n", callingnum);
+ ast_debug(1, "OSP: destination '%s'\n", destination);
+ ast_debug(1, "OSP: token size '%d'\n", tokenlen);
+
if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
res = 1;
break;
} else if (!result->numresults) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ ast_debug(1, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to get route, error '%d'\n", error);
result->token[0] = '\0';
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
&dummy,
NULL);
if (error == OSPC_ERR_NO_ERROR) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Usage reported\n");
+ ast_debug(1, "OSP: Usage reported\n");
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error);
+ ast_debug(1, "OSP: Unable to report usage, error '%d'\n", error);
res = -1;
}
OSPPTransactionDelete(handle);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
-
- }
+ ast_debug(1, "OSPAuth: provider '%s'\n", provider);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
- ast_log(LOG_DEBUG, "OSPAuth: token size '%zd'\n", strlen(token));
- }
+ ast_debug(1, "OSPAuth: source '%s'\n", source);
+ ast_debug(1, "OSPAuth: token size '%zd'\n", strlen(token));
if ((res = osp_auth(provider, &handle, source, chan->cid.cid_num, chan->exten, token, &timelimit)) > 0) {
status = AST_OSP_SUCCESS;
snprintf(buffer, sizeof(buffer), "%d", handle);
pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
+ ast_debug(1, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", timelimit);
pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
+ ast_debug(1, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
+ ast_debug(1, "OSPAuth: %s\n", status);
if(res <= 0) {
res = -1;
AST_STANDARD_APP_ARGS(args, tmp);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
+ ast_debug(1, "OSPLookup: exten '%s'\n", args.exten);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
+ ast_debug(1, "OSPlookup: provider '%s'\n", provider);
if (args.options) {
if (strchr(args.options, 'h')) {
callidtypes |= OSP_CALLID_IAX;
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPLookup: call id types '%d'\n", callidtypes);
- }
+ ast_debug(1, "OSPLookup: call id types '%d'\n", callidtypes);
result.inhandle = OSP_INVALID_HANDLE;
result.intimelimit = OSP_DEF_TIMELIMIT;
srcdev = ast_var_value(current);
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle);
- ast_log(LOG_DEBUG, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit);
- ast_log(LOG_DEBUG, "OSPLookup: OSPINNETWORKID '%s'\n", netid);
- ast_log(LOG_DEBUG, "OSPLookup: source device '%s'\n", srcdev);
- }
+ ast_debug(1, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle);
+ ast_debug(1, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit);
+ ast_debug(1, "OSPLookup: OSPINNETWORKID '%s'\n", netid);
+ ast_debug(1, "OSPLookup: source device '%s'\n", srcdev);
if ((cres = ast_autoservice_start(chan)) < 0) {
ast_module_user_remove(u);
snprintf(buffer, sizeof(buffer), "%d", result.outhandle);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
+ ast_debug(1, "OSPLookup: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
+ ast_debug(1, "OSPLookup: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLED", result.called);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPCALLED '%s'\n", result.called);
+ ast_debug(1, "OSPLookup: OSPCALLED '%s'\n", result.called);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
+ ast_debug(1, "OSPLookup: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ ast_debug(1, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", callidtypes);
pbx_builtin_setvar_helper(chan, "OSPOUTCALLIDTYPES", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
+ ast_debug(1, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
+ ast_debug(1, "OSPLookup: %s\n", status);
if (!strcasecmp(result.tech, OSP_TECH_H323)) {
if ((callidtypes & OSP_CALLID_H323) && (result.outcallid.len != 0)) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "%s%s", OSP_SIP_HEADER, result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, OSP_TECH_IAX)) {
snprintf(buffer, sizeof(buffer), "%s/%s/%s", result.tech, result.dest, result.called);
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
+ ast_debug(1, "OSPNext: cause '%d'\n", cause);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
+ ast_debug(1, "OSPlookup: provider '%s'\n", provider);
result.inhandle = OSP_INVALID_HANDLE;
result.outhandle = OSP_INVALID_HANDLE;
}
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle);
- ast_log(LOG_DEBUG, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
- ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%d'\n", result.numresults);
- }
+ ast_debug(1, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle);
+ ast_debug(1, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle);
+ ast_debug(1, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit);
+ ast_debug(1, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes);
+ ast_debug(1, "OSPNext: OSPRESULTS '%d'\n", result.numresults);
if ((res = osp_next(provider, cause, &result)) > 0) {
status = AST_OSP_SUCCESS;
}
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
+ ast_debug(1, "OSPNext: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
+ ast_debug(1, "OSPNext: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLED", result.called);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPCALLED'%s'\n", result.called);
+ ast_debug(1, "OSPNext: OSPCALLED'%s'\n", result.called);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
+ ast_debug(1, "OSPNext: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ ast_debug(1, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
+ ast_debug(1, "OSPNext: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
+ ast_debug(1, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
+ ast_debug(1, "OSPNext: %s\n", status);
if (!strcasecmp(result.tech, OSP_TECH_H323)) {
if ((callidtypes & OSP_CALLID_H323) && (result.outcallid.len != 0)) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "%s%s", OSP_SIP_HEADER, result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, OSP_TECH_IAX)) {
snprintf(buffer, sizeof(buffer), "%s/%s/%s", result.tech, result.dest, result.called);
}
}
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPFinish: OSPINHANDLE '%d'\n", inhandle);
- ast_log(LOG_DEBUG, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
- ast_log(LOG_DEBUG, "OSPFinish: recorded '%d'\n", recorded);
- }
+ ast_debug(1, "OSPFinish: OSPINHANDLE '%d'\n", inhandle);
+ ast_debug(1, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle);
+ ast_debug(1, "OSPFinish: recorded '%d'\n", recorded);
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
+ ast_debug(1, "OSPFinish: cause '%d'\n", cause);
if (chan->cdr) {
start = chan->cdr->start.tv_sec;
connect = 0;
end = 0;
}
- if (option_debug) {
- ast_log(LOG_DEBUG, "OSPFinish: start '%ld'\n", start);
- ast_log(LOG_DEBUG, "OSPFinish: connect '%ld'\n", connect);
- ast_log(LOG_DEBUG, "OSPFinish: end '%ld'\n", end);
- }
+ ast_debug(1, "OSPFinish: start '%ld'\n", start);
+ ast_debug(1, "OSPFinish: connect '%ld'\n", connect);
+ ast_debug(1, "OSPFinish: end '%ld'\n", end);
release = chan->_softhangup ? 0 : 1;
if (osp_finish(outhandle, recorded, cause, start, connect, end, release) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for outbound call\n");
+ ast_debug(1, "OSPFinish: Unable to report usage for outbound call\n");
}
switch (cause) {
case AST_CAUSE_NORMAL_CLEARING:
break;
}
if (osp_finish(inhandle, recorded, cause, start, connect, end, release) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for inbound call\n");
+ ast_debug(1, "OSPFinish: Unable to report usage for inbound call\n");
}
snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
} else {
OSPPInit(0);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: osp_hardware '%d'\n", osp_hardware);
+ ast_debug(1, "OSP: osp_hardware '%d'\n", osp_hardware);
t = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "tokenformat");
if (t) {
TOKEN_ALGO_SIGNED, TOKEN_ALGO_UNSIGNED, TOKEN_ALGO_BOTH, t);
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
+ ast_debug(1, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
t = ast_category_browse(cfg, NULL);
while(t) {
ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n");
return 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
+ ast_debug(1, "OSP: osp_initialized '%d'\n", osp_initialized);
return 1;
}
AST_LIST_UNLOCK(&interfaces);
if (!curint) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
+ ast_debug(3, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
+ ast_debug(1, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
return 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
+ ast_debug(1, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
if ((curint = ast_calloc(1, sizeof(*curint)))) {
ast_copy_string(curint->interface, interface, sizeof(curint->interface));
AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
if (!strcasecmp(curint->interface, interface)) {
if (!interface_exists_global(interface)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
+ ast_debug(1, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
AST_LIST_REMOVE_CURRENT(&interfaces, list);
ast_free(curint);
}
q->announcefrequency = atoi(val);
} else if (!strcasecmp(param, "min-announce-frequency")) {
q->minannouncefrequency = atoi(val);
- ast_log(LOG_DEBUG, "%s=%s for queue '%s'\n", param, val, q->name);
+ ast_debug(1, "%s=%s for queue '%s'\n", param, val, q->name);
} else if (!strcasecmp(param, "announce-round-seconds")) {
q->roundingseconds = atoi(val);
/* Rounding to any other values just doesn't make sense... */
/*! \note Hmm, can't seem to distinguish a DB failure from a not
found condition... So we might delete an in-core queue
in case of DB failure. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename);
+ ast_debug(1, "Queue %s not found in realtime.\n", queuename);
q->dead = 1;
/* Delete if unused (else will be deleted when last caller leaves). */
S_OR(qe->chan->cid.cid_num, "unknown"), /* XXX somewhere else it is <unknown> */
S_OR(qe->chan->cid.cid_name, "unknown"),
q->name, qe->pos, q->count, qe->chan->uniqueid );
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
+ ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
}
ast_mutex_unlock(&q->lock);
AST_LIST_UNLOCK(&queues);
manager_event(EVENT_FLAG_CALL, "Leave",
"Channel: %s\r\nQueue: %s\r\nCount: %d\r\nUniqueid: %s\r\n",
qe->chan->name, q->name, q->count, qe->chan->uniqueid);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name );
+ ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name );
/* Take us out of the queue */
if (prev)
prev->next = cur->next;
if (strcmp(mem->interface, member->interface))
continue;
- if (option_debug)
- ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
+ ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
if (q->weight > rq->weight) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
+ ast_debug(1, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
found = 1;
break;
}
/* on entry here, we know that tmp->chan == NULL */
if (qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wrapuptime not yet expired for %s\n", tmp->interface);
+ ast_debug(1, "Wrapuptime not yet expired for %s\n", tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
}
if (!qe->parent->ringinuse && (tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s in use, can't receive call\n", tmp->interface);
+ ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
}
if (tmp->member->paused) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s paused, can't receive call\n", tmp->interface);
+ ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
return 0;
}
if (use_weight && compare_weight(qe->parent,tmp->member)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
+ ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0;
/* Place the call, but don't wait on the answer */
if ((res = ast_call(tmp->chan, location, 0))) {
/* Again, keep going even if there's an error */
- if (option_debug)
- ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
+ ast_debug(1, "ast call on peer returned %d\n", res);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", tmp->interface);
do_hang(tmp);
while (ret == 0) {
struct callattempt *best = find_best(outgoing);
if (!best) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Nobody left to try ringing in queue\n");
+ ast_debug(1, "Nobody left to try ringing in queue\n");
break;
}
if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
/* Ring everyone who shares this best metric (for ringall) */
for (cur = outgoing; cur; cur = cur->q_next) {
if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) {
- if (option_debug)
- ast_log(LOG_DEBUG, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric);
+ ast_debug(1, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric);
ring_entry(qe, cur, busies);
}
}
} else {
/* Ring just the best channel */
- if (option_debug)
- ast_log(LOG_DEBUG, "Trying '%s' with metric %d\n", best->interface, best->metric);
+ ast_debug(1, "Trying '%s' with metric %d\n", best->interface, best->metric);
ring_entry(qe, best, busies);
}
if (best->chan) /* break out with result = 1 */
if (best) {
/* Ring just the best channel */
- if (option_debug)
- ast_log(LOG_DEBUG, "Next is '%s' with metric %d\n", best->interface, best->metric);
+ ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric);
qe->parent->rrpos = best->metric % 1000;
} else {
/* Just increment rrpos */
}
if (pos == 1 /* not found */) {
if (numlines == (numbusies + numnochan)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Everyone is busy at this time\n");
+ ast_debug(1, "Everyone is busy at this time\n");
} else {
ast_log(LOG_NOTICE, "No one is answering queue '%s' (%d/%d/%d)\n", queue, numlines, numbusies, numnochan);
}
/* Ignore going off hook */
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ ast_debug(1, "Dunno what to do with control type %d\n", f->subclass);
}
}
ast_frfree(f);
ch = qe->parent->head;
/* If we are now at the top of the head, break out */
if (ch == qe) {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's our turn (%s).\n", qe->chan->name);
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's not our turn (%s).\n", qe->chan->name);
res = 0;
}
ch = qe->parent->head;
if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl);
+ ast_debug(1, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl);
avl = 1;
} else {
for (cur = qe->parent->members; cur; cur = cur->next) {
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "There are %d available members.\n", avl);
+ ast_debug(1, "There are %d available members.\n", avl);
while ((idx < avl) && (ch) && (ch != qe)) {
idx++;
/* If the queue entry is within avl [the number of available members] calls from the top ... */
if (ch && idx < avl) {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's our turn (%s).\n", qe->chan->name);
res = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name);
+ ast_debug(1, "It's not our turn (%s).\n", qe->chan->name);
res = 0;
}
if (use_weight)
AST_LIST_LOCK(&queues);
ast_mutex_lock(&qe->parent->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "%s is trying to call a queue member.\n",
+ ast_debug(1, "%s is trying to call a queue member.\n",
qe->chan->name);
ast_copy_string(queuename, qe->parent->name, sizeof(queuename));
cur = qe->parent->members;
} else {
res = digit;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Nobody answered.\n", qe->chan->name);
+ ast_debug(1, "%s: Nobody answered.\n", qe->chan->name);
} else { /* peer is valid */
/* Ah ha! Someone answered within the desired timeframe. Of course after this
we will always return with -1 so that it is hung up properly after the
/* Begin Monitoring */
if (qe->parent->monfmt && *qe->parent->monfmt) {
if (!qe->parent->montype) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting Monitor as requested.\n");
+ ast_debug(1, "Starting Monitor as requested.\n");
monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
if (pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC") || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS"))
which = qe->chan;
if (qe->parent->monjoin)
ast_monitor_setjoinfiles(which, 1);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting MixMonitor as requested.\n");
+ ast_debug(1, "Starting MixMonitor as requested.\n");
monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
if (!monitorfilename) {
if (qe->chan->cdr)
else
snprintf(mixmonargs, sizeof(mixmonargs)-1, "%s|b%s", tmpid2, monitor_options);
- if (option_debug)
- ast_log(LOG_DEBUG, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
+ ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
ret = pbx_exec(qe->chan, mixmonapp, mixmonargs);
/* Drop out of the queue at this point, to prepare for next caller */
leave_queue(qe);
if (!ast_strlen_zero(url) && ast_channel_supports_html(peer)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url);
+ ast_debug(1, "app_queue: sendurl=%s.\n", url);
ast_channel_sendurl(peer, url);
}
}
if (!ast_strlen_zero(macroexec)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: macro=%s.\n", macroexec);
+ ast_debug(1, "app_queue: macro=%s.\n", macroexec);
res = ast_autoservice_start(qe->chan);
if (res) {
if (app) {
res = pbx_exec(qe->chan, app, macroexec);
- if (option_debug)
- ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
+ ast_debug(1, "Macro exited with status %d\n", res);
res = 0;
} else {
ast_log(LOG_ERROR, "Could not find application Macro\n");
}
if (!ast_strlen_zero(agi)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: agi=%s.\n", agi);
+ ast_debug(1, "app_queue: agi=%s.\n", agi);
app = pbx_findapp("agi");
if (app) {
agiexec = ast_strdupa(agi);
if ((mem = interface_exists(q, interface))) {
found++;
if (mem->paused == paused) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface);
+ ast_debug(1, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface);
}
mem->paused = paused;
if (ast_strlen_zero(membername))
membername = interface;
- if (option_debug)
- ast_log(LOG_DEBUG, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused);
+ ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused);
if (add_to_queue(queue_name, interface, membername, penalty, paused, 0) == RES_OUTOFMEMORY) {
ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n");
res = 0;
break;
case RES_EXISTS:
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
+ ast_debug(1, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE");
res = 0;
break;
user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO");
if (user_priority) {
if (sscanf(user_priority, "%d", &prio) == 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Got priority %d from ${QUEUE_PRIO}.\n",
- chan->name, prio);
+ ast_debug(1, "%s: Got priority %d from ${QUEUE_PRIO}.\n", chan->name, prio);
} else {
ast_log(LOG_WARNING, "${QUEUE_PRIO}: Invalid value (%s), channel %s.\n",
user_priority, chan->name);
prio = 0;
}
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "NO QUEUE_PRIO variable found. Using default.\n");
+ ast_debug(3, "NO QUEUE_PRIO variable found. Using default.\n");
prio = 0;
}
/* Get the maximum penalty from the variable ${QUEUE_MAX_PENALTY} */
if ((max_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MAX_PENALTY"))) {
if (sscanf(max_penalty_str, "%d", &max_penalty) == 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n",
- chan->name, max_penalty);
+ ast_debug(1, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n", chan->name, max_penalty);
} else {
ast_log(LOG_WARNING, "${QUEUE_MAX_PENALTY}: Invalid value (%s), channel %s.\n",
max_penalty_str, chan->name);
if (args.options && (strchr(args.options, 'c')))
qcontinue = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
- args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio);
+ ast_debug(1, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
+ args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio);
qe.chan = chan;
qe.prio = prio;
* of the queue, go and check for our turn again.
*/
if (!is_our_turn(&qe)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Darn priorities, going back in queue (%s)!\n",
- qe.chan->name);
+ ast_debug(1, "Darn priorities, going back in queue (%s)!\n", qe.chan->name);
goto check_turns;
}
}
if (!q->count)
destroy_queue(q);
else
- ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n");
+ ast_debug(1, "XXX Leaking a little memory :( XXX\n");
} else {
ast_mutex_lock(&q->lock);
for (cur = q->members; cur; cur = cur->next)
ast_frfree(f);
}
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup\n");
+ ast_debug(1, "Got hangup\n");
res = -1;
}
return DC_ERROR;
ast_copy_string(digitbuf, digits, sizeof(digitbuf));
-
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ ilink param = %s, digitbuf = %s\n", S_OR(param, "(null)"), digitbuf);
+ ast_debug(1, "@@@@ ilink param = %s, digitbuf = %s\n", S_OR(param, "(null)"), digitbuf);
switch (myatoi(param)) {
case 1: /* Link off */
if (!myrpt->enable)
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Autopatch up\n");
+ ast_debug(1, "@@@@ Autopatch up\n");
if (!myrpt->callmode) {
/* Set defaults */
if (!myrpt->enable)
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Autopatch down\n");
+ ast_debug(1, "@@@@ Autopatch down\n");
rpt_mutex_lock(&myrpt->lock);
if (!myrpt->enable)
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
+ ast_debug(1, "@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
switch (myatoi(param)) {
case 1: /* System ID */
if ((!myrpt->remote) && (!myrpt->enable))
return DC_ERROR;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
+ ast_debug(1, "@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
mychannel = myrpt->remchannel;
AST_APP_ARG(param);
);
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Digits collected: %s, source: %d\n", digits, command_source);
+ ast_debug(1, "@@@@ Digits collected: %s, source: %d\n", digits, command_source);
if (command_source == SOURCE_DPHONE) {
if (!myrpt->p.dphone_functions)
stringp = ast_strdupa(vp->value);
AST_NONSTANDARD_APP_ARGS(args, stringp, ',');
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ action: %s, param = %s\n", args.action, S_OR(args.param, "(null)"));
+ ast_debug(1, "@@@@ action: %s, param = %s\n", args.action, S_OR(args.param, "(null)"));
/* Look up the action */
for (i = 0; i < (sizeof(function_table) / sizeof(struct function_table_tag)); i++) {
if (!strncasecmp(args.action, function_table[i].action, strlen(args.action)))
break;
}
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ table index i = %d\n", i);
+ ast_debug(1, "@@@@ table index i = %d\n", i);
if (i == (sizeof(function_table) / sizeof(struct function_table_tag))) {
/* Error, action not in table */
return DC_ERROR;
}
if (function_table[i].function == NULL) {
/* Error, function undefined */
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ NULL for action: %s\n", args.action);
+ ast_debug(1, "@@@@ NULL for action: %s\n", args.action);
return DC_ERROR;
}
functiondigits = digits + strlen(vp->name);
int i;
struct zt_radio_param prm;
- if (debug) {
- char *buf = alloca(30 + txbytes * 3);
- int len;
- ast_copy_string(buf, "String output was: ", 30 + txbytes * 3);
- len = strlen(buf);
- for (i = 0; i < txbytes; i++)
- len += snprintf(buf + len, 30 + txbytes * 3 - len, "%02X ", (unsigned char) txbuf[i]);
- strcat(buf + len, "\n");
- ast_log(LOG_DEBUG, "%s", buf);
- }
+ char *buf = alloca(30 + txbytes * 3);
+ int len;
+ ast_copy_string(buf, "String output was: ", 30 + txbytes * 3);
+ len = strlen(buf);
+ for (i = 0; i < txbytes; i++)
+ len += snprintf(buf + len, 30 + txbytes * 3 - len, "%02X ", (unsigned char) txbuf[i]);
+ strcat(buf + len, "\n");
+ ast_debug(1, "%s", buf);
prm.radpar = ZT_RADPAR_REMMODE;
if (asciiflag)
/* if no decimal, is invalid */
if (s == NULL) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Frequency needs a decimal\n");
+ ast_debug(1, "@@@@ Frequency needs a decimal\n");
return -1;
}
*s++ = 0;
if (strlen(tmp) < 2) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad MHz digits: %s\n", tmp);
+ ast_debug(1, "@@@@ Bad MHz digits: %s\n", tmp);
return -1;
}
if (strlen(s) < 3) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad KHz digits: %s\n", s);
+ ast_debug(1, "@@@@ Bad KHz digits: %s\n", s);
return -1;
}
if ((s[2] != '0') && (s[2] != '5')) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ KHz must end in 0 or 5: %c\n", s[2]);
+ ast_debug(1, "@@@@ KHz must end in 0 or 5: %c\n", s[2]);
return -1;
}
band = rbi_mhztoband(tmp);
if (band == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad Band: %s\n", tmp);
+ ast_debug(1, "@@@@ Bad Band: %s\n", tmp);
return -1;
}
txpl = rbi_pltocode(myrpt->txpl);
if (txpl == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ Bad TX PL: %s\n", myrpt->txpl);
+ ast_debug(1, "@@@@ Bad TX PL: %s\n", myrpt->txpl);
return -1;
}
int fd, m, d;
fd = 0;
- if (debug)
- ast_log(LOG_DEBUG, "New frequency: %s\n", newfreq);
+ ast_debug(1, "New frequency: %s\n", newfreq);
if (split_freq(&m, &d, newfreq))
return -1;
{
int res;
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ lock on\n");
+ ast_debug(1, "@@@@ lock on\n");
res = simple_command_ft897(myrpt, 0x00); /* LOCK on */
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ ptt off\n");
+ ast_debug(1, "@@@@ ptt off\n");
if (!res)
res = simple_command_ft897(myrpt, 0x88); /* PTT off */
- if (debug)
- ast_log(LOG_DEBUG, "Modulation mode\n");
+ ast_debug(1, "Modulation mode\n");
if (!res)
res = set_mode_ft897(myrpt, myrpt->remmode); /* Modulation mode */
- if (debug)
- ast_log(LOG_DEBUG, "Split off\n");
+ ast_debug(1, "Split off\n");
if (!res)
simple_command_ft897(myrpt, 0x82); /* Split off */
- if (debug)
- ast_log(LOG_DEBUG, "Frequency\n");
+ ast_debug(1, "Frequency\n");
if (!res)
res = set_freq_ft897(myrpt, myrpt->freq); /* Frequency */
if ((myrpt->remmode == REM_MODE_FM)) {
- if (debug)
- ast_log(LOG_DEBUG, "Offset\n");
+ ast_debug(1, "Offset\n");
if (!res)
res = set_offset_ft897(myrpt, myrpt->offset); /* Offset if FM */
if ((!res)&&(myrpt->rxplon || myrpt->txplon)) {
- if (debug)
- ast_log(LOG_DEBUG, "CTCSS tone freqs.\n");
+ ast_debug(1, "CTCSS tone freqs.\n");
res = set_ctcss_freq_ft897(myrpt, myrpt->txpl, myrpt->rxpl); /* CTCSS freqs if CTCSS is enabled */
}
if (!res) {
- if (debug)
- ast_log(LOG_DEBUG, "CTCSS mode\n");
+ ast_debug(1, "CTCSS mode\n");
res = set_ctcss_mode_ft897(myrpt, myrpt->txplon, myrpt->rxplon); /* CTCSS mode */
}
}
if ((myrpt->remmode == REM_MODE_USB)||(myrpt->remmode == REM_MODE_LSB)) {
- if (debug)
- ast_log(LOG_DEBUG, "Clarifier off\n");
+ ast_debug(1, "Clarifier off\n");
simple_command_ft897(myrpt, 0x85); /* Clarifier off if LSB or USB */
}
return res;
{
int m, d;
- if (debug)
- ast_log(LOG_DEBUG, "Before bump: %s\n", myrpt->freq);
+ ast_debug(1, "Before bump: %s\n", myrpt->freq);
if (split_freq(&m, &d, myrpt->freq))
return -1;
}
if (check_freq_ft897(m, d, NULL)) {
- if (debug)
- ast_log(LOG_DEBUG, "Bump freq invalid\n");
+ ast_debug(1, "Bump freq invalid\n");
return -1;
}
snprintf(myrpt->freq, MAXREMSTR, "%d.%05d", m, d);
-
- if (debug)
- ast_log(LOG_DEBUG, "After bump: %s\n", myrpt->freq);
+ ast_debug(1, "After bump: %s\n", myrpt->freq);
return set_freq_ft897(myrpt, myrpt->freq);
}
/* Check frequency for validity and establish a default mode */
snprintf(freq, sizeof(freq), "%s.%03d%02d", args.s1, k, ht);
-
- if (debug)
- ast_log(LOG_DEBUG, "New frequency: %s\n", freq);
+ ast_debug(1, "New frequency: %s\n", freq);
split_freq(&mhz, &decimals, freq);
i = strlen(digitbuf) - 1;
if ((j != 1) || (k < 2)|| (l != 1))
break; /* Not yet */
- if (debug)
- ast_log(LOG_DEBUG, "PL digits entered %s\n", digitbuf);
+ ast_debug(1, "PL digits entered %s\n", digitbuf);
ast_copy_string(tmp, digitbuf, sizeof(tmp));
/* see if we have at least 1 */
i = strlen(digitbuf) - 1;
if ((j != 1) || (k < 2)|| (l != 1))
break; /* Not yet */
- if (debug)
- ast_log(LOG_DEBUG, "PL digits entered %s\n", digitbuf);
+ ast_debug(1, "PL digits entered %s\n", digitbuf);
ast_copy_string(tmp, digitbuf, sizeof(tmp));
/* see if we have at least 1 */
if (who == myrpt->rxchannel) { /* if it was a read from rx */
f = ast_read(myrpt->rxchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
continue;
} else if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
if ((!lasttx) || (myrpt->p.duplex > 1)) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx key\n");
+ ast_debug(8, "@@@@ rx key\n");
myrpt->keyed = 1;
}
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
if ((!lasttx) || (myrpt->p.duplex > 1)) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx un-key\n");
+ ast_debug(8, "@@@@ rx un-key\n");
if (myrpt->keyed) {
rpt_telemetry(myrpt, UNKEY, NULL);
}
if (who == myrpt->pchannel) { /* if it was a read from pseudo */
f = ast_read(myrpt->pchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
if (who == myrpt->txchannel) { /* if it was a read from tx */
f = ast_read(myrpt->txchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
- if (debug == 7 )
- ast_log(LOG_DEBUG, "@@@@ rx key\n");
+ ast_debug(8, "@@@@ rx key\n");
l->lastrx = 1;
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx un-key\n");
+ ast_debug(8, "@@@@ rx un-key\n");
l->lastrx = 0;
}
if (f->subclass == AST_CONTROL_HANGUP) {
rpt_mutex_unlock(&myrpt->lock);
f = ast_read(l->pchan);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
toexit = 1;
rpt_mutex_lock(&myrpt->lock);
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
toexit = 1;
rpt_mutex_lock(&myrpt->lock);
if (who == myrpt->txpchannel) { /* if it was a read from remote tx */
f = ast_read(myrpt->txpchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
ast_free(ll);
}
rpt_mutex_unlock(&myrpt->lock);
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung up channel\n");
+ ast_debug(1, "@@@@ rpt:Hung up channel\n");
myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
return NULL;
if (who == chan) { /* if it was a read from incoming */
f = ast_read(chan);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n");
+ ast_debug(1, "@@@@ link:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
if (f->frametype == AST_FRAME_DTMF) {
myrpt->remchannel = chan; /* Save copy of channel */
if (handle_remote_phone_dtmf(myrpt, f->subclass, &keyed, phone_mode) == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
if (f->frametype == AST_FRAME_TEXT) {
myrpt->remchannel = chan; /* Save copy of channel */
if (handle_remote_data(myrpt, f->data) == -1) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx key\n");
+ ast_debug(8, "@@@@ rx key\n");
keyed = 1;
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ rx un-key\n");
+ ast_debug(8, "@@@@ rx un-key\n");
keyed = 0;
}
}
if (who == myrpt->rxchannel) { /* if it was a read from radio */
f = ast_read(myrpt->rxchannel);
if (!f) {
- if (debug) ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n");
+ ast_debug(1, "@@@@ link:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_VOICE) {
ast_write(chan, f);
} else if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
/* if RX key */
if (f->subclass == AST_CONTROL_RADIO_KEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ remote rx key\n");
+ ast_debug(8, "@@@@ remote rx key\n");
if (!myrpt->remotetx) {
ast_indicate(chan, AST_CONTROL_RADIO_KEY);
myrpt->remoterx = 1;
}
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY) {
- if (debug == 7)
- ast_log(LOG_DEBUG, "@@@@ remote rx un-key\n");
+ ast_debug(8, "@@@@ remote rx un-key\n");
if (!myrpt->remotetx) {
ast_indicate(chan, AST_CONTROL_RADIO_UNKEY);
myrpt->remoterx = 0;
/* do this cuz you have to */
f = ast_read(myrpt->txchannel);
if (!f) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n");
+ ast_debug(1, "@@@@ link:Hung Up\n");
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass == AST_CONTROL_HANGUP) {
- if (debug)
- ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n");
+ ast_debug(1, "@@@@ rpt:Hung Up\n");
ast_frfree(f);
break;
}
oldframe = AST_LIST_REMOVE_HEAD(oldlist, entries);
AST_LIST_UNLOCK(oldlist);
- if (oldframe)
+ if (oldframe) {
gosub_release_frame(chan, oldframe);
- else if (option_debug)
- ast_log(LOG_DEBUG, "%s called with an empty gosub stack\n", app_pop);
-
+ } else {
+ ast_debug(1, "%s called with an empty gosub stack\n", app_pop);
+ }
return 0;
}
u = ast_module_user_add(chan);
if (!stack_store) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Channel %s has no datastore, so we're allocating one.\n", chan->name);
+ ast_debug(1, "Channel %s has no datastore, so we're allocating one.\n", chan->name);
stack_store = ast_channel_datastore_alloc(&stack_info, NULL);
if (!stack_store) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. Gosub will fail.\n");
for (i = 0; i < args2.argc; i++) {
snprintf(argname, sizeof(argname), "ARG%d", i + 1);
pbx_builtin_pushvar_helper(chan, argname, args2.argval[i]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting '%s' to '%s'\n", argname, args2.argval[i]);
+ ast_debug(1, "Setting '%s' to '%s'\n", argname, args2.argval[i]);
}
/* And finally, save our return address */
}
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n",
- tmp, sil, min, max);
+ ast_debug(1, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n", tmp, sil, min, max);
if (chan->_state != AST_STATE_UP) {
/* Otherwise answer unless we're supposed to send this while on-hook */
res = ast_answer(chan);
ms = 0;
if ((ms > min) && ((max < 0) || (ms < max))) {
char ms_str[10];
- if (option_debug)
- ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
+ ast_debug(1, "Found qualified token of %d ms\n", ms);
/* Save detected talk time (in milliseconds) */
sprintf(ms_str, "%d", ms );
ast_frfree(fr);
break;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
+ ast_debug(1, "Found unqualified token of %d ms\n", ms);
}
notsilent = 0;
}
if (!notsilent) {
/* Heard some audio, mark the begining of the token */
start = ast_tvnow();
- if (option_debug)
- ast_log(LOG_DEBUG, "Start of voice token!\n");
+ ast_debug(1, "Start of voice token!\n");
notsilent = 1;
}
}
ast_log(LOG_NOTICE, "No samples were received from the other side!\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
+ ast_debug(1, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
return (noise / samples);
}
/* Transmit client version */
if (!res)
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "Transmit client version\n");
+ ast_debug(1, "Transmit client version\n");
/* Read server version */
- if (option_debug)
- ast_log(LOG_DEBUG, "Read server version\n");
+ ast_debug(1, "Read server version\n");
if (!res)
res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0);
if (res > 0)
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "server version: %s\n", serverver);
+ ast_debug(1, "server version: %s\n", serverver);
if (res > 0)
res = 0;
res = ast_dtmf_stream(chan, NULL, testid, 0);
if (!res)
res = ast_dtmf_stream(chan, NULL, "#", 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "send test identifier: %s\n", testid);
+ ast_debug(1, "send test identifier: %s\n", testid);
if ((res >=0) && (!ast_strlen_zero(testid))) {
/* Make the directory to hold the test results in case it's not there */
if (!res) {
/* Step 1: Wait for "1" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 2. Wait DTMF 1\n");
+ ast_debug(1, "TestClient: 2. Wait DTMF 1\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS");
if (res == '1')
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 2: Send "2" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 2. Send DTMF 2\n");
+ ast_debug(1, "TestClient: 2. Send DTMF 2\n");
res = ast_dtmf_stream(chan, NULL, "2", 0);
fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 3: Wait one second */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 3. Wait one second\n");
+ ast_debug(1, "TestClient: 3. Wait one second\n");
res = ast_safe_sleep(chan, 1000);
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 4: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 4. Measure noise\n");
+ ast_debug(1, "TestClient: 4. Measure noise\n");
res = measurenoise(chan, 5000, "TestClient");
fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
}
if (!res) {
/* Step 5: Wait for "4" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 5. Wait DTMF 4\n");
+ ast_debug(1, "TestClient: 5. Wait DTMF 4\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS");
if (res == '4')
}
if (!res) {
/* Step 6: Transmit tone noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 6. Transmit tone\n");
+ ast_debug(1, "TestClient: 6. Transmit tone\n");
res = sendnoise(chan, 6000);
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
}
if (!res || (res == '5')) {
/* Step 7: Wait for "5" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 7. Wait DTMF 5\n");
+ ast_debug(1, "TestClient: 7. Wait DTMF 5\n");
if (!res)
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS");
}
if (!res) {
/* Step 8: Wait one second */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 8. Wait one second\n");
+ ast_debug(1, "TestClient: 8. Wait one second\n");
res = ast_safe_sleep(chan, 1000);
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 9: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 6. Measure tone\n");
+ ast_debug(1, "TestClient: 6. Measure tone\n");
res = measurenoise(chan, 4000, "TestClient");
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
}
if (!res) {
/* Step 10: Send "7" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 7. Send DTMF 7\n");
+ ast_debug(1, "TestClient: 7. Send DTMF 7\n");
res = ast_dtmf_stream(chan, NULL, "7", 0);
fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 11: Wait for "8" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestClient: 11. Wait DTMF 8\n");
+ ast_debug(1, "TestClient: 11. Wait DTMF 8\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS");
if (res == '8')
}
if (option_debug && !res ) {
/* Step 12: Hangup! */
- ast_log(LOG_DEBUG, "TestClient: 12. Hangup\n");
+ ast_debug(1, "TestClient: 12. Hangup\n");
}
- if (option_debug)
- ast_log(LOG_DEBUG, "-- TEST COMPLETE--\n");
+ ast_debug(1, "-- TEST COMPLETE--\n");
fprintf(f, "-- END TEST--\n");
fclose(f);
res = -1;
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
/* Read version */
- if (option_debug)
- ast_log(LOG_DEBUG, "Read client version\n");
+ ast_debug(1, "Read client version\n");
if (!res)
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
if (res > 0)
res = 0;
- if (option_debug) {
- ast_log(LOG_DEBUG, "client version: %s\n", testid);
- ast_log(LOG_DEBUG, "Transmit server version\n");
- }
+
+ ast_debug(1, "client version: %s\n", testid);
+ ast_debug(1, "Transmit server version\n");
+
res = ast_safe_sleep(chan, 1000);
if (!res)
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0);
if (!res)
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "read test identifier: %s\n", testid);
+ ast_debug(1, "read test identifier: %s\n", testid);
/* Check for sneakyness */
if (strchr(testid, '/'))
res = -1;
fprintf(f, "SERVERCHAN: %s\n", chan->name);
fprintf(f, "SERVERTEST ID: %s\n", testid);
fprintf(f, "ANSWER: PASS\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
+ ast_debug(1, "Processing Test ID '%s'\n", testid);
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 1: Send "1" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 1. Send DTMF 1\n");
+ ast_debug(1, "TestServer: 1. Send DTMF 1\n");
res = ast_dtmf_stream(chan, NULL, "1", 0);
fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 2: Wait for "2" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 2. Wait DTMF 2\n");
+ ast_debug(1, "TestServer: 2. Wait DTMF 2\n");
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS");
if (res == '2')
}
if (!res) {
/* Step 3: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 3. Measure noise\n");
+ ast_debug(1, "TestServer: 3. Measure noise\n");
res = measurenoise(chan, 6000, "TestServer");
fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
}
if (!res) {
/* Step 4: Send "4" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 4. Send DTMF 4\n");
+ ast_debug(1, "TestServer: 4. Send DTMF 4\n");
res = ast_dtmf_stream(chan, NULL, "4", 0);
fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
if (!res) {
/* Step 5: Wait one second */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 5. Wait one second\n");
+ ast_debug(1, "TestServer: 5. Wait one second\n");
res = ast_safe_sleep(chan, 1000);
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
if (!res) {
/* Step 6: Measure noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 6. Measure tone\n");
+ ast_debug(1, "TestServer: 6. Measure tone\n");
res = measurenoise(chan, 4000, "TestServer");
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
if (!res) {
/* Step 7: Send "5" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 7. Send DTMF 5\n");
+ ast_debug(1, "TestServer: 7. Send DTMF 5\n");
res = ast_dtmf_stream(chan, NULL, "5", 0);
fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
if (!res) {
/* Step 8: Transmit tone noise */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 8. Transmit tone\n");
+ ast_debug(1, "TestServer: 8. Transmit tone\n");
res = sendnoise(chan, 6000);
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
}
if (!res || (res == '7')) {
/* Step 9: Wait for "7" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 9. Wait DTMF 7\n");
+ ast_debug(1, "TestServer: 9. Wait DTMF 7\n");
if (!res)
res = ast_waitfordigit(chan, 3000);
fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS");
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 10: Send "8" */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 10. Send DTMF 8\n");
+ ast_debug(1, "TestServer: 10. Send DTMF 8\n");
res = ast_dtmf_stream(chan, NULL, "8", 0);
fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
}
if (!res) {
/* Step 11: Wait for hangup to arrive! */
- if (option_debug)
- ast_log(LOG_DEBUG, "TestServer: 11. Waiting for hangup\n");
+ ast_debug(1, "TestServer: 11. Waiting for hangup\n");
res = ast_safe_sleep(chan, 10000);
fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL");
}
/* check users.conf and update the password stored for the mailbox*/
/* if no vmsecret entry exists create one. */
if ((cfg = ast_config_load_with_comments("users.conf"))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "we are looking for %s\n", vmu->mailbox);
+ ast_debug(4, "we are looking for %s\n", vmu->mailbox);
while ((category = ast_category_browse(cfg, category))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "users.conf: %s\n", category);
+ ast_debug(4, "users.conf: %s\n", category);
if (!strcasecmp(category, vmu->mailbox)) {
if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "looks like we need to make vmsecret!\n");
+ ast_debug(3, "looks like we need to make vmsecret!\n");
var = ast_variable_new("vmsecret", newpassword);
}
new = alloca(strlen(newpassword)+1);
sprintf(new, "%s", newpassword);
if (!(cat = ast_category_get(cfg, category))) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "failed to get category!\n");
+ ast_debug(4, "failed to get category!\n");
break;
}
if (!var)
ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n",msgnum,messageNum);
return;
}
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
+ ast_debug(3, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
/* delete message */
sprintf (arg,"%lu",messageNum);
mail_setflag (vms->mailstream,arg,"\\DELETED");
create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
tmpfd = mkstemp(newtmp);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ ast_debug(3, "newtmp: %s\n", newtmp);
if (vmu->volgain < -.001 || vmu->volgain > .001) {
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
ast_safe_system(tmpcmd);
attach = newtmp;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
}
fprintf(p, "--%s" ENDL, bound);
fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
}
if (!strcmp(format, "wav49"))
format = "WAV";
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
+ ast_debug(3, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
if ((p = vm_mkftemp(tmp)) == NULL) {
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
+ ast_debug(1, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
}
return 0;
}
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
+ ast_debug(1, "Sent page to %s with command '%s'\n", pager, mailcmd);
return 0;
}
if (!strcmp(fmt, "wav49"))
fmt = "WAV";
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Storing file '%s', format '%s'\n", fn, fmt);
+ ast_debug(3, "Storing file '%s', format '%s'\n", fn, fmt);
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
fclose(p);
unlink(tmp);
ast_free(buf);
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "%s stored\n", fn);
+ ast_debug(3, "%s stored\n", fn);
return 0;
}
if (oldmsgs)
*oldmsgs = 0;
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Mailbox is set to %s\n",mailbox);
+ ast_debug(3,"Mailbox is set to %s\n",mailbox);
/* If no mailbox, return immediately */
if (ast_strlen_zero(mailbox))
}
/* We have to get the user before we can open the stream! */
- /*ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
+ /*ast_debug(1,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
if (!(vmu = find_user(NULL, context, mailboxnc))) {
ast_log(LOG_ERROR, "Couldn't find mailbox %s in context %s\n", mailboxnc, context);
return -1;
/* check if someone is accessing this box right now... */
if ((vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1)) || (vms_p = get_vm_state_by_mailbox(mailboxnc, 1))) {
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Returning before search - user is logged in\n");
+ ast_debug(3,"Returning before search - user is logged in\n");
*newmsgs = vms_p->newmessages;
*oldmsgs = vms_p->oldmessages;
free_user(vmu);
/* add one if not there... */
if (!(vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0)) && !(vms_p = get_vm_state_by_mailbox(mailboxnc, 0))) {
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
+ ast_debug(3,"Adding new vmstate for %s\n",vmu->imapuser);
if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
free_user(vmu);
return -1;
ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
ast_copy_string(vms_p->username, mailboxnc, sizeof(vms_p->username)); /* save for access from interactive entry point */
vms_p->mailstream = NIL; /* save for access from interactive entry point */
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
+ ast_debug(3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
vms_p->updated = 1;
/* set mailbox to INBOX! */
ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
ast_log(LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
+ ast_debug(1, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
}
}
ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension);
} else {
snprintf(arguments, sizeof(arguments), "%s %s %s %d&", externnotify, context, extension, newvoicemails);
- if (option_debug)
- ast_log(LOG_DEBUG, "Executing %s\n", arguments);
+ ast_debug(1, "Executing %s\n", arguments);
ast_safe_system(arguments);
}
}
category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Before find_user\n");
+ ast_debug(3, "Before find_user\n");
if (!(vmu = find_user(&svm, context, ext))) {
ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+ ast_debug(1, "%s doesn't exist, doing what we can\n", prefile);
res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
}
DISPOSE(prefile, -1);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+ ast_debug(1, "Hang up during prefile playback\n");
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
return -1;
/* must open stream for this user to get info! */
vms = get_vm_state_by_mailbox(ext,0);
if (vms) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Using vm_state, interactive set to %d.\n",vms->interactive);
+ ast_debug(3, "Using vm_state, interactive set to %d.\n",vms->interactive);
newmsgs = vms->newmessages++;
oldmsgs = vms->oldmessages;
} else {
}
/* here is a big difference! We add one to it later */
msgnum = newmsgs + oldmsgs;
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum);
+ ast_debug(3, "Messagecount set to %d\n",msgnum);
snprintf(fn, sizeof(fn), "%s/imap/msg%s%04d", VM_SPOOL_DIR, vmu->mailbox, msgnum);
/* set variable for compatibility */
pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE");
/* Check if mailbox is full */
if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) {
- if (option_debug)
- ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
+ ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
ast_play_and_wait(chan, "vm-mailboxfull");
return -1;
}
/* here is a big difference! We add one to it later */
msgnum = newmsgs + oldmsgs;
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum);
+ ast_debug(3, "Messagecount set to %d\n",msgnum);
#else
if (count_messages(vmu, dir) >= vmu->maxmsg) {
ast_filedelete(tmptxtfile, NULL);
unlink(tmptxtfile);
} else if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
+ ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n");
unlink(tmptxtfile);
ast_unlock_path(dir);
if (ast_check_realtime("voicemail_data")) {
/* get the real IMAP message number for this message */
sprintf(sequence,"%ld",vms->msgArray[msg]);
imap_mailbox_name(dbox, vms, box, 1);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Copying sequence %s to mailbox %s\n",sequence,dbox);
+ ast_debug(3, "Copying sequence %s to mailbox %s\n",sequence,dbox);
res = mail_copy(vms->mailstream, sequence, dbox);
if (res == 1) return 0;
return 1;
bytes += ast_adsi_voice_mode(buf + bytes, 0);
ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done downloading scripts...\n");
+ ast_debug(1, "Done downloading scripts...\n");
#ifdef DISPLAY
/* Add last dot */
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Restarting session...\n");
+ ast_debug(1, "Restarting session...\n");
bytes = 0;
/* Load the session now */
AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
#ifdef IMAP_STORAGE
/* Need to get message content */
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
+ ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
if (!vms->msgArray[vms->curmsg]) {
ast_log (LOG_WARNING,"Trying to access unknown message\n");
return -1;
}
if (!strcasecmp(fmt, "wav49"))
fmt = "WAV";
- if (option_debug > 2)
- ast_log (LOG_DEBUG,"**** format set to %s, vmfmts set to %s\n",fmt,vmfmts);
+ ast_debug(3,"**** format set to %s, vmfmts set to %s\n",fmt,vmfmts);
/* ast_copy_string(fmt, vmfmts, sizeof(fmt));*/
/* if (!ast_strlen_zero(fmt)) { */
snprintf(todir, sizeof(todir), "%s%s/%s/tmp", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox);
make_gsm_file(vms->fn, vms->imapuser, todir, vms->curmsg);
- if (option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_fetchstructure, message number is %ld, filename is:%s\n",vms->msgArray[vms->curmsg], vms->fn);
+ ast_debug(3,"Before mail_fetchstructure, message number is %ld, filename is:%s\n",vms->msgArray[vms->curmsg], vms->fn);
/*mail_fetchstructure (mailstream, vmArray[0], &body); */
mail_fetchstructure (vms->mailstream, vms->msgArray[vms->curmsg], &body);
save_body(body,vms,"3","gsm");
return res;
/* Strip off caller ID number from name */
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
+ ast_debug(1, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
ast_callerid_parse(cid, &name, &callerid);
if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) {
/* Check for internal contexts and only */
/* say extension when the call didn't come from an internal context in the list */
for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
+ ast_debug(1, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
if ((strcmp(cidinternalcontexts[i], context) == 0))
break;
}
}
else if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n", callerid);
+ ast_debug(1, "VM-CID: Numeric caller id: (%s)\n", callerid);
/* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
if (!callback)
res = wait_file2(chan, vms, "vm-from-phonenumber");
}
} else {
/* Number unknown */
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
+ ast_debug(1, "VM-CID: From an unknown number\n");
/* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */
res = wait_file2(chan, vms, "vm-unknown-caller");
}
durations=atoi(duration);
durationm=(durations / 60);
- if (option_debug)
- ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
+ ast_debug(1, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
if ((!res) && (durationm >= minduration)) {
res = wait_file2(chan, vms, "vm-duration");
char buf[1024];
vms->starting = 0;
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
+ ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
if (!vms->msgArray[vms->curmsg]) {
ast_log (LOG_WARNING,"Trying to access unknown message\n");
ast_log (LOG_ERROR,"vm_state is NULL!\n");
return -1;
}
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"vm_state user is:%s\n",vms->imapuser);
+ ast_debug(3,"vm_state user is:%s\n",vms->imapuser);
if (vms->mailstream == NIL || !vms->mailstream) {
- if (option_debug)
- ast_log (LOG_DEBUG,"mailstream not set.\n");
+ ast_debug(1,"mailstream not set.\n");
} else {
stream = vms->mailstream;
}
}
/* Now connect to the target folder */
imap_mailbox_name(tmp, vms, box, 1);
- if(option_debug > 2)
- ast_log (LOG_DEBUG,"Before mail_open, server: %s, box:%d\n", tmp, box);
+ ast_debug(3,"Before mail_open, server: %s, box:%d\n", tmp, box);
vms->mailstream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
if (vms->mailstream == NIL) {
return -1;
char dbox[256];
ast_copy_string(vms->imapuser,vmu->imapuser, sizeof(vms->imapuser));
-
- if(option_debug > 2)
- ast_log(LOG_DEBUG,"Before init_mailstream, user is %s\n",vmu->imapuser);
+ ast_debug(3,"Before init_mailstream, user is %s\n",vmu->imapuser);
if ((ret = init_mailstream(vms, box)) || !vms->mailstream) {
ast_log (LOG_ERROR,"Could not initialize mailstream\n");
pgm->unseen = 0;
}
- if(option_debug > 2)
- ast_log(LOG_DEBUG,"Before mail_search_full, user is %s\n",vmu->imapuser);
+ ast_debug(3,"Before mail_search_full, user is %s\n",vmu->imapuser);
vms->vmArrayIndex = 0;
mail_search_full (vms->mailstream, NULL, pgm, NIL);
if (vms->deleted) {
for (x=0;x < vmu->maxmsg;x++) {
if (vms->deleted[x]) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG,"IMAP delete of %d\n",x);
+ ast_debug(3,"IMAP delete of %d\n",x);
IMAP_DELETE(vms->curdir, x, vms->fn, vms);
}
}
if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd))
vm_change_password_shell(vmu, newpassword);
- if (option_debug)
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
cmd = ast_play_and_wait(chan, vm_passchanged);
/* If forcename is set, have the user record their name */
if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd))
vm_change_password_shell(vmu, newpassword);
- if (option_debug)
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
cmd = ast_play_and_wait(chan, vm_passchanged);
break;
case '*':
ast_copy_string(mailbox, fullusername, mailbox_size);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox);
+ ast_debug(1, "Before find user for mailbox %s\n",mailbox);
vmu = find_user(&vmus, context, mailbox);
if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) {
/* saved password is blank, so don't bother asking */
memset(&vmus, 0, sizeof(vmus));
if (chan->_state != AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Before ast_answer\n");
+ ast_debug(1, "Before ast_answer\n");
ast_answer(chan);
}
if (!valid)
res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "After vm_authenticate\n");
+ ast_debug(1, "After vm_authenticate\n");
if (!res) {
valid = 1;
if (!skipuser)
create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
#endif
/* Retrieve old and new message counts */
- if (option_debug)
- ast_log(LOG_DEBUG, "Before open_mailbox\n");
+ ast_debug(1, "Before open_mailbox\n");
res = open_mailbox(&vms, vmu, 1);
if (res == ERROR_LOCK_PATH)
goto out;
vms.oldmessages = vms.lastmsg + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages);
+ ast_debug(1, "Number of old messages: %d\n",vms.oldmessages);
/* Start in INBOX */
res = open_mailbox(&vms, vmu, 0);
if (res == ERROR_LOCK_PATH)
goto out;
vms.newmessages = vms.lastmsg + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
+ ast_debug(1, "Number of new messages: %d\n",vms.newmessages);
/* Select proper mailbox FIRST!! */
if (play_auto) {
}
}
#ifdef IMAP_STORAGE
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit);
+ ast_debug(3, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit);
if (vms.quota_limit && vms.quota_usage >= vms.quota_limit) {
- if (option_debug)
- ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
+ ast_debug(1, "*** QUOTA EXCEEDED!!\n");
cmd = ast_play_and_wait(chan, "vm-mailboxfull");
}
#endif
}
#ifdef IMAP_STORAGE
/* expunge message - use UID Expunge if supported on IMAP server*/
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup);
+ ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup);
if (vmu && deleted == 1 && expungeonhangup == 1) {
#ifdef HAVE_IMAP_TK2006
if (LEVELUIDPLUS (vms.mailstream)) {
/* External voicemail notify application */
if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
ast_copy_string(externnotify, val, sizeof(externnotify));
- if (option_debug)
- ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
+ ast_debug(1, "found externnotify: %s\n", externnotify);
} else {
externnotify[0] = '\0';
}
/* SMDI voicemail notification */
if ((s = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(s)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabled SMDI voicemail notification\n");
+ ast_debug(1, "Enabled SMDI voicemail notification\n");
if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
smdi_iface = ast_smdi_interface_find(val);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
+ ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
}
if (!smdi_iface) {
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
+ ast_debug(1, "Using SMDI port %s\n", smdi_iface->name);
}
}
ast_set2_flag((&globalflags), ast_true(val), VM_FORCEGREET);
if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
- if (option_debug)
- ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
+ ast_debug(1,"VM_CID Internal context string: %s\n",s);
stringp = ast_strdupa(s);
for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
if (!ast_strlen_zero(stringp)) {
while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
q++;
ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x]));
- if (option_debug)
- ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
+ ast_debug(1,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
} else {
cidinternalcontexts[x][0] = '\0';
}
}
}
if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
- if (option_debug)
- ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
+ ast_debug(1,"VM Review Option disabled globally\n");
val = "no";
}
ast_set2_flag((&globalflags), ast_true(val), VM_REVIEW);
/*Temporary greeting reminder */
if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "VM Temporary Greeting Reminder Option disabled globally\n");
+ ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
val = "no";
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "VM Temporary Greeting Reminder Option enabled globally\n");
+ ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n");
}
ast_set2_flag((&globalflags), ast_true(val), VM_TEMPGREETWARN);
if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){
- if (option_debug)
- ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
+ ast_debug(1,"VM Operator break disabled globally\n");
val = "no";
}
ast_set2_flag((&globalflags), ast_true(val), VM_OPERATOR);
if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) {
- if (option_debug)
- ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
+ ast_debug(1,"VM CID Info before msg disabled globally\n");
val = "no";
}
ast_set2_flag((&globalflags), ast_true(val), VM_SAYCID);
if (!(val = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){
- if (option_debug)
- ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
+ ast_debug(1,"Send Voicemail msg disabled globally\n");
val = "no";
}
ast_set2_flag((&globalflags), ast_true(val), VM_SVMAIL);
if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) {
- if (option_debug)
- ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
+ ast_debug(1,"ENVELOPE before msg enabled globally\n");
val = "yes";
}
ast_set2_flag((&globalflags), ast_true(val), VM_ENVELOPE);
if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
+ ast_debug(1,"Duration info before msg enabled globally\n");
val = "yes";
}
ast_set2_flag((&globalflags), ast_true(val), VM_SAYDURATION);
}
if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
- if (option_debug)
- ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
+ ast_debug(1,"We are not going to skip to the next msg after save/delete\n");
val = "no";
}
ast_set2_flag((&globalflags), ast_true(val), VM_SKIPAFTERCMD);
if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) {
ast_copy_string(dialcontext, val, sizeof(dialcontext));
- if (option_debug)
- ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
+ ast_debug(1, "found dialout context: %s\n", dialcontext);
} else {
dialcontext[0] = '\0';
}
if ((val = ast_variable_retrieve(cfg, "general", "callback"))) {
ast_copy_string(callcontext, val, sizeof(callcontext));
- if (option_debug)
- ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
+ ast_debug(1, "found callback context: %s\n", callcontext);
} else {
callcontext[0] = '\0';
}
if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
ast_copy_string(exitcontext, val, sizeof(exitcontext));
- if (option_debug)
- ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
+ ast_debug(1, "found operator context: %s\n", exitcontext);
} else {
exitcontext[0] = '\0';
}
/* START HERE */
/* get the message info!! */
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", vms->curmsg, vms->msgArray[vms->curmsg]);
+ ast_debug(3, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", vms->curmsg, vms->msgArray[vms->curmsg]);
if (!vms->msgArray[vms->curmsg]) {
ast_log(LOG_WARNING, "Trying to access unknown message\n");
return;
}
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "saving mailbox message number %lu as message %d. Interactive set to %d\n", number, vms->vmArrayIndex, vms->interactive);
+ ast_debug(3, "saving mailbox message number %lu as message %d. Interactive set to %d\n", number, vms->vmArrayIndex, vms->interactive);
vms->msgArray[vms->vmArrayIndex++] = number;
}
void mm_exists(MAILSTREAM * stream, unsigned long number)
{
/* mail_ping will callback here if new mail! */
- if(option_debug > 3)
- ast_log (LOG_DEBUG, "Entering EXISTS callback for message %ld\n", number);
+ ast_debug(4, "Entering EXISTS callback for message %ld\n", number);
if (number == 0) return;
set_update(stream);
}
void mm_expunged(MAILSTREAM * stream, unsigned long number)
{
/* mail_ping will callback here if expunged mail! */
- if(option_debug > 3)
- ast_log (LOG_DEBUG, "Entering EXPUNGE callback for message %ld\n", number);
+ ast_debug(4, "Entering EXPUNGE callback for message %ld\n", number);
if (number == 0) return;
set_update(stream);
}
void mm_flags(MAILSTREAM * stream, unsigned long number)
{
/* mail_ping will callback here if read mail! */
- if(option_debug > 3)
- ast_log (LOG_DEBUG, "Entering FLAGS callback for message %ld\n", number);
+ ast_debug(4, "Entering FLAGS callback for message %ld\n", number);
if (number == 0) return;
set_update(stream);
}
delimiter = delim;
ast_mutex_unlock(&delimiter_lock);
}
- if (option_debug > 4) {
- ast_log(LOG_DEBUG, "Delimiter set to %c and mailbox %s\n",delim, mailbox);
- if (attributes & LATT_NOINFERIORS)
- ast_log(LOG_DEBUG, "no inferiors\n");
- if (attributes & LATT_NOSELECT)
- ast_log(LOG_DEBUG, "no select\n");
- if (attributes & LATT_MARKED)
- ast_log(LOG_DEBUG, "marked\n");
- if (attributes & LATT_UNMARKED)
- ast_log(LOG_DEBUG, "unmarked\n");
- }
+
+ ast_debug(5, "Delimiter set to %c and mailbox %s\n",delim, mailbox);
+ if (attributes & LATT_NOINFERIORS)
+ ast_debug(5, "no inferiors\n");
+ if (attributes & LATT_NOSELECT)
+ ast_debug(5, "no select\n");
+ if (attributes & LATT_MARKED)
+ ast_debug(5, "marked\n");
+ if (attributes & LATT_UNMARKED)
+ ast_debug(5, "unmarked\n");
}
void mm_lsub(MAILSTREAM * stream, int delimiter, char *mailbox, long attributes)
{
- if (option_debug > 4) {
- ast_log(LOG_DEBUG, "Delimiter set to %c and mailbox %s\n",delimiter, mailbox);
- if (attributes & LATT_NOINFERIORS)
- ast_log(LOG_DEBUG, "no inferiors\n");
- if (attributes & LATT_NOSELECT)
- ast_log(LOG_DEBUG, "no select\n");
- if (attributes & LATT_MARKED)
- ast_log(LOG_DEBUG, "marked\n");
- if (attributes & LATT_UNMARKED)
- ast_log(LOG_DEBUG, "unmarked\n");
- }
+ ast_debug(5, "Delimiter set to %c and mailbox %s\n",delimiter, mailbox);
+ if (attributes & LATT_NOINFERIORS)
+ ast_debug(5, "no inferiors\n");
+ if (attributes & LATT_NOSELECT)
+ ast_debug(5, "no select\n");
+ if (attributes & LATT_MARKED)
+ ast_debug(5, "marked\n");
+ if (attributes & LATT_UNMARKED)
+ ast_debug(5, "unmarked\n");
}
{
switch ((short) errflg) {
case NIL:
- if(option_debug)
- ast_log(LOG_DEBUG,"IMAP Info: %s\n", string);
+ ast_debug(1,"IMAP Info: %s\n", string);
break;
case PARSE:
case WARN:
{
struct ast_vm_user *vmu;
- if(option_debug > 3)
- ast_log(LOG_DEBUG, "Entering callback mm_login\n");
+ ast_debug(4, "Entering callback mm_login\n");
ast_copy_string(user, mb->user, MAILTMPLEN);
return;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "User %s usage is %lu, limit is %lu\n", user, usage, limit);
+ ast_debug(3, "User %s usage is %lu, limit is %lu\n", user, usage, limit);
vms->quota_usage = usage;
vms->quota_limit = limit;
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
if (!vlist->vms) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "error: vms is NULL for %s\n", user);
+ ast_debug(3, "error: vms is NULL for %s\n", user);
continue;
}
if (!vlist->vms->imapuser) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "error: imapuser is NULL for %s\n", user);
+ ast_debug(3, "error: imapuser is NULL for %s\n", user);
continue;
}
return vlist->vms;
}
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "%s not found in vmstates\n", user);
+ ast_debug(3, "%s not found in vmstates\n", user);
return NULL;
}
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
if (!vlist->vms) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "error: vms is NULL for %s\n", mailbox);
+ ast_debug(3, "error: vms is NULL for %s\n", mailbox);
continue;
}
if (!vlist->vms->username) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "error: username is NULL for %s\n", mailbox);
+ ast_debug(3, "error: username is NULL for %s\n", mailbox);
continue;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "comparing mailbox %s (i=%d) to vmstate mailbox %s (i=%d)\n", mailbox, interactive, vlist->vms->username, vlist->vms->interactive);
+ ast_debug(3, "comparing mailbox %s (i=%d) to vmstate mailbox %s (i=%d)\n", mailbox, interactive, vlist->vms->username, vlist->vms->interactive);
if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Found it!\n");
+ ast_debug(3, "Found it!\n");
return vlist->vms;
}
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s not found in vmstates\n", mailbox);
+ ast_debug(3, "%s not found in vmstates\n", mailbox);
return NULL;
}
if (vms->interactive == 1) {
altvms = get_vm_state_by_mailbox(vms->username,0);
if (altvms) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Duplicate mailbox %s, copying message info...\n",vms->username);
+ ast_debug(3, "Duplicate mailbox %s, copying message info...\n",vms->username);
vms->newmessages = altvms->newmessages;
vms->oldmessages = altvms->oldmessages;
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "check_msgArray before memcpy\n");
+ ast_debug(3, "check_msgArray before memcpy\n");
check_msgArray(vms);
/* memcpy(vms->msgArray, altvms->msgArray, sizeof(long)*256); */
copy_msgArray(vms, altvms);
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "check_msgArray after memcpy\n");
+ ast_debug(3, "check_msgArray after memcpy\n");
check_msgArray(vms);
vms->vmArrayIndex = altvms->vmArrayIndex;
vms->lastmsg = altvms->lastmsg;
v->vms = vms;
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Inserting vm_state for user:%s, mailbox %s\n",vms->imapuser,vms->username);
+ ast_debug(3, "Inserting vm_state for user:%s, mailbox %s\n",vms->imapuser,vms->username);
AST_LIST_LOCK(&vmstates);
AST_LIST_INSERT_TAIL(&vmstates, v, list);
/* If interactive, we should copy pertinent info
back to the persistent state (to make update immediate) */
if (vms->interactive == 1 && (altvms = vms->persist_vms)) {
- if(option_debug > 2)
- ast_log(LOG_DEBUG, "Duplicate mailbox %s, copying message info...\n", vms->username);
+ ast_debug(3, "Duplicate mailbox %s, copying message info...\n", vms->username);
altvms->newmessages = vms->newmessages;
altvms->oldmessages = vms->oldmessages;
altvms->updated = 2;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username);
+ ast_debug(3, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username);
AST_LIST_LOCK(&vmstates);
AST_LIST_TRAVERSE_SAFE_BEGIN(&vmstates, vc, list) {
return;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "User %s mailbox set for update.\n", user);
+ ast_debug(3, "User %s mailbox set for update.\n", user);
vms->updated = 2; /* Set updated flag since mailbox changed */
}
int x;
for (x = 0; x<256; x++) {
if (vms->msgArray[x]!=0) {
- if(option_debug)
- ast_log (LOG_DEBUG, "Item %d set to %ld\n",x,vms->msgArray[x]);
+ ast_debug(1, "Item %d set to %ld\n",x,vms->msgArray[x]);
}
}
}
body_content = mail_fetchbody (vms->mailstream, vms->msgArray[vms->curmsg], section, &len);
if (body_content != NIL) {
sprintf(filename,"%s.%s", vms->fn, format);
- /* ast_log (LOG_DEBUG,body_content); */
+ /* ast_debug(1,body_content); */
body_decoded = rfc822_base64 ((unsigned char *)body_content, len, &newlen);
write_file (filename, (char *) body_decoded, newlen);
}
/* Ended happily with silence */
res = 1;
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "SILENCE");
- if (option_debug)
- ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n");
+ ast_debug(1, "WAITSTATUS was set to SILENCE\n");
break;
}
if ( timeout && (difftime(time(&now),waitstart) >= timeout) ) {
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "TIMEOUT");
- if (option_debug)
- ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n");
+ ast_debug(1, "WAITSTATUS was set to TIMEOUT\n");
res = 0;
break;
}
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
close(fd);
goto outrun;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
/* Kill old pseudo */
close(fd);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ ast_debug(1, "Ooh, something swapped out under us, starting over\n");
retryzap = 0;
goto zapretry;
}
if (!res) {
/* Check for hangup */
if (chan->_softhangup && !signalled) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid);
+ ast_debug(1, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid);
kill(pid, SIGTERM);
signalled=1;
}
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
close(fd);
goto outrun;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
/* Kill old pseudo */
close(fd);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ ast_debug(1, "Ooh, something swapped out under us, starting over\n");
retryzap = 0;
goto zapretry;
}
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- if (option_debug)
- ast_log(LOG_DEBUG, "logging time in GMT\n");
+ ast_debug(1, "logging time in GMT\n");
}
}
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- if (option_debug)
- ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
+ ast_debug(1, "logging CDR field UNIQUEID\n");
}
}
if (tmp) {
loguserfield = ast_true(tmp);
if (loguserfield) {
- if (option_debug)
- ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
+ ast_debug(1, "logging CDR user-defined field\n");
}
}
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
+ ast_debug(1,"cdr_odbc: Logging uniqueid\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ ast_debug(1,"cdr_odbc: Not logging uniqueid\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ ast_debug(1,"cdr_odbc: Not logging uniqueid\n");
loguniqueid = 0;
}
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
+ ast_debug(1,"cdr_odbc: Logging in GMT\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ ast_debug(1,"cdr_odbc: Not logging in GMT\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ ast_debug(1,"cdr_odbc: Not logging in GMT\n");
usegmtime = 0;
}
return -1;
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "cdr_pgsql: inserting a CDR record.\n");
+ ast_debug(2, "cdr_pgsql: inserting a CDR record.\n");
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,"
"lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES"
table,timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,
cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "cdr_pgsql: SQL command executed: %s\n",sqlcmd);
+ ast_debug(3, "cdr_pgsql: SQL command executed: %s\n",sqlcmd);
/* Test to be sure we're still connected... */
/* If we're connected, and connection is working, good. */
if (option_debug) {
if (ast_strlen_zero(pghostname))
- ast_log(LOG_DEBUG, "cdr_pgsql: using default unix socket\n");
+ ast_debug(1, "cdr_pgsql: using default unix socket\n");
else
- ast_log(LOG_DEBUG, "cdr_pgsql: got hostname of %s\n", pghostname);
- ast_log(LOG_DEBUG, "cdr_pgsql: got port of %s\n", pgdbport);
- ast_log(LOG_DEBUG, "cdr_pgsql: got user of %s\n", pgdbuser);
- ast_log(LOG_DEBUG, "cdr_pgsql: got dbname of %s\n", pgdbname);
- ast_log(LOG_DEBUG, "cdr_pgsql: got password of %s\n", pgpassword);
- ast_log(LOG_DEBUG, "cdr_pgsql: got sql table name of %s\n", table);
+ ast_debug(1, "cdr_pgsql: got hostname of %s\n", pghostname);
+ ast_debug(1, "cdr_pgsql: got port of %s\n", pgdbport);
+ ast_debug(1, "cdr_pgsql: got user of %s\n", pgdbuser);
+ ast_debug(1, "cdr_pgsql: got dbname of %s\n", pgdbname);
+ ast_debug(1, "cdr_pgsql: got password of %s\n", pgpassword);
+ ast_debug(1, "cdr_pgsql: got sql table name of %s\n", table);
}
conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
if (PQstatus(conn) != CONNECTION_BAD) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Successfully connected to PostgreSQL database.\n");
+ ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
} else {
pgerror = PQerrorMessage(conn);
VALUE_PAIR *send = NULL;
if (build_radius_record(&send, cdr)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to create RADIUS record. CDR not recorded!\n");
+ ast_debug(1, "Unable to create RADIUS record. CDR not recorded!\n");
return result;
}
ptr = ast_variable_retrieve(cfg,"global","table");
if (ptr == NULL) {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_tds: table not specified. Assuming cdr\n");
+ ast_debug(1,"cdr_tds: table not specified. Assuming cdr\n");
ptr = "cdr";
}
table = strdup(ptr);
#define CHECK_FORMATS(ast, p) do { \
if (p->chan) {\
if (ast->nativeformats != p->chan->nativeformats) { \
- if (option_debug) \
- ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
+ ast_debug(1, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- if (option_debug) \
- ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ ast_debug(1, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
ast_set_read_format(ast, ast->readformat); \
ast_set_write_format(ast, ast->writeformat); \
} \
/* Note that we don't hangup if it's not a callback because Asterisk will do it
for us when the PBX instance that called login finishes */
if (!ast_strlen_zero(p->loginchan)) {
- if (p->chan && option_debug)
- ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
+ if (p->chan)
+ ast_debug(1, "Bridge on '%s' being cleared (2)\n", p->chan->name);
status = pbx_builtin_getvar_helper(p->chan, "CHANLOCALSTATUS");
if (autologoffunavail && status && !strcasecmp(status, "CHANUNAVAIL")) {
if (p->chan && !p->chan->_bridge) {
if (strcasecmp(p->chan->tech->type, "Local")) {
p->chan->_bridge = ast;
- if (p->chan && option_debug)
- ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
+ if (p->chan)
+ ast_debug(1, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
}
}
ast_mutex_unlock(&p->lock);
(f->subclass == p->chan->writeformat)) {
res = ast_write(p->chan, f);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping one incompatible %s frame on '%s' to '%s'\n",
- f->frametype == AST_FRAME_VOICE ? "audio" : "video",
- ast->name, p->chan->name);
+ ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n",
+ f->frametype == AST_FRAME_VOICE ? "audio" : "video",
+ ast->name, p->chan->name);
res = 0;
}
}
p->acknowledged = 0;
if (!p->chan) {
if (p->pending) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
+ ast_debug(1, "Pretending to dial on pending agent\n");
newstate = AST_STATE_DIALING;
res = 0;
} else {
return res;
}
ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", p->chan->language);
res = ast_streamfile(p->chan, beep, p->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(3, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(p->chan, "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(3, "Waited for stream, result '%d'\n", res);
}
if (!res) {
res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Set read format, result '%d'\n", res);
+ ast_debug(3, "Set read format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
} else {
if (!res) {
res = ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Set write format, result '%d'\n", res);
+ ast_debug(3, "Set write format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
}
* as in apps/app_chanisavail.c:chanavail_exec()
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
+ ast_debug(1, "Hangup called for state %s\n", ast_state2str(ast->_state));
if (p->start && (ast->_state != AST_STATE_UP)) {
howlong = time(NULL) - p->start;
p->start = 0;
ast_hangup(p->chan);
p->chan = NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
+ ast_debug(1, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {
long logintime = time(NULL) - p->loginstart;
p->loginstart = 0;
}
ast_mutex_unlock(&p->lock);
- if (option_debug > 4 && !res)
- ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
+ if (!res)
+ ast_debug(5, "agent_cont_sleep() returning %d\n", res );
return res;
}
ret = p->chan;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
+ ast_debug(1, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
return ret;
}
struct agent_pvt *p;
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking availability of '%s'\n", newlyavailable->agent);
+ ast_debug(1, "Checking availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
}
ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
+ ast_debug(1, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
/* We found a pending call, time to merge */
chan = agent_new(newlyavailable, AST_STATE_DOWN);
parent = p->owner;
/* Don't do beep here */
res = 0;
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, beep, newlyavailable->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(3, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- if (option_debug)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(1, "Waited for stream, result '%d'\n", res);
}
}
if (!res) {
ast_mutex_unlock(&parent->lock);
p->abouttograb = 0;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sneaky, parent disappeared in the mean time...\n");
+ ast_debug(1, "Sneaky, parent disappeared in the mean time...\n");
agent_cleanup(newlyavailable);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ugh... Agent hung up at exactly the wrong time\n");
+ ast_debug(1, "Ugh... Agent hung up at exactly the wrong time\n");
agent_cleanup(newlyavailable);
}
}
struct agent_pvt *p;
int res=0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
+ ast_debug(1, "Checking beep availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
}
ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call '%s' looks like a would-be winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
+ ast_debug(1, "Call '%s' looks like a would-be winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
ast_mutex_unlock(&p->lock);
break;
}
AST_LIST_UNLOCK(&agents);
if (p) {
ast_mutex_unlock(&newlyavailable->lock);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, beep, newlyavailable->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(1, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- if (option_debug)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(1, "Waited for stream, result '%d'\n", res);
}
ast_mutex_lock(&newlyavailable->lock);
}
/* No agent available -- but we're requesting to wait for one.
Allocate a place holder */
if (hasagent) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Creating place holder for '%s'\n", s);
+ ast_debug(1, "Creating place holder for '%s'\n", s);
p = add_agent(data, 1);
p->group = groupmatch;
chan = agent_new(p, AST_STATE_DOWN);
if (!chan)
ast_log(LOG_WARNING, "Weird... Fix this to drop the unused pending agent\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ ast_debug(1, "Not creating place holder for '%s' since nobody logged in\n", s);
}
}
*cause = hasagent ? AST_CAUSE_BUSY : AST_CAUSE_UNREGISTERED;
ast_mutex_lock(&p->lock);
if (p->lastdisc.tv_sec) {
if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > p->wrapuptime) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wrapup time for %s expired!\n", p->agent);
+ ast_debug(1, "Wrapup time for %s expired!\n", p->agent);
p->lastdisc = ast_tv(0, 0);
if (p->ackcall > 1)
check_beep(p, 0);
snprintf(buf, sizeof(buf), "%s;%s", cur_agent->loginchan, cur_agent->logincallerid);
if (ast_db_put(pa_family, cur_agent->agent, buf))
ast_log(LOG_WARNING, "failed to create persistent entry in ASTdb for %s!\n", buf);
- else if (option_debug)
- ast_log(LOG_DEBUG, "Saved Agent: %s on %s\n", cur_agent->agent, cur_agent->loginchan);
+ else
+ ast_debug(1, "Saved Agent: %s on %s\n", cur_agent->agent, cur_agent->loginchan);
} else {
/* Delete - no agent or there is an error */
ast_db_del(pa_family, cur_agent->agent);
} else
ast_mutex_unlock(&cur_agent->lock);
if (!ast_db_get(pa_family, agent_num, agent_data, sizeof(agent_data)-1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
+ ast_debug(1, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
parse = agent_data;
agent_chan = strsep(&parse, ";");
agent_callerid = strsep(&parse, ";");
ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
return NULL;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
}
snd_pcm_hw_params_alloca(&hwparams);
if (err < 0)
ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ ast_debug(1, "Period size is %d\n", err);
}
buffer_size = 4096 * 2; /* period_size * 16; */
if (err < 0)
ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ ast_debug(1, "Buffer size is set to %d frames\n", err);
}
#if 0
if (err <= 0)
ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
if (err != 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ ast_debug(1, "Can't handle more than one device\n");
}
snd_pcm_poll_descriptors(handle, &pfd, err);
- if (option_debug)
- ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd);
+ ast_debug(1, "Acquired fd %d from the poll descriptor\n", pfd.fd);
if (stream == SND_PCM_STREAM_CAPTURE)
readdev = pfd.fd;
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
if (res == -EPIPE) {
#if DEBUG
- if (option_debug)
- ast_log(LOG_DEBUG, "XRUN write\n");
+ ast_debug(1, "XRUN write\n");
#endif
snd_pcm_prepare(alsa.ocard);
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
int tinthreeway;
struct ast_channel *towner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ ast_debug(1, "Swapping %d and %d\n", a, b);
towner = p->subs[a].owner;
tinthreeway = p->subs[a].inthreeway;
struct gtalk_pvt *p = ast->tech_pvt;
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answer!\n");
+ ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
gtalk_invite(p, p->them, p->us,p->sid, 0);
ast_mutex_unlock(&p->lock);
{
struct gtalk_pvt *tmp;
char *from;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
struct gtalk_pvt *tmp;
char *from;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
char idroster[200];
char *data, *exten = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
+ ast_debug(1, "The client is %s for alloc\n", client->name);
if (!sid && !strchr(them, '/')) { /* I started call! */
if (!strcasecmp(client->name, "guest")) {
buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, them);
else
ast_rtp_stun_request(p->rtp, &sin, username);
- if (aux.sin_addr.s_addr && option_debug > 3) {
- ast_log(LOG_DEBUG, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
- ast_log(LOG_DEBUG, "Sending STUN request to %s\n", tmp->ip);
+ if (aux.sin_addr.s_addr) {
+ ast_debug(4, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
+ ast_debug(4, "Sending STUN request to %s\n", tmp->ip);
}
tmp = tmp->next;
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats =
(p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- if (option_debug)
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
/* New call */
gtalk_newcall(client, pak);
} else if (iks_find_with_attrib(pak->x, "session", "type", "candidates") || iks_find_with_attrib(pak->x, "session", "type", "transport-info")) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "About to add candidate!\n");
+ ast_debug(3, "About to add candidate!\n");
gtalk_add_candidate(client, pak);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Candidate Added!\n");
+ ast_debug(3, "Candidate Added!\n");
} else if (iks_find_with_attrib(pak->x, "session", "type", "accept") || iks_find_with_attrib(pak->x, "session", "type", "transport-accept")) {
gtalk_is_answered(client, pak);
} else if (iks_find_with_attrib(pak->x, "session", "type", "content-info")) {
static void oh323_destroy_alias(struct oh323_alias *alias)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying alias '%s'\n", alias->name);
+ ast_debug(1, "Destroying alias '%s'\n", alias->name);
ast_free(alias);
}
static void oh323_destroy_user(struct oh323_user *user)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying user '%s'\n", user->name);
+ ast_debug(1, "Destroying user '%s'\n", user->name);
ast_free_ha(user->ha);
ast_free(user);
}
static void oh323_destroy_peer(struct oh323_peer *peer)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying peer '%s'\n", peer->name);
+ ast_debug(1, "Destroying peer '%s'\n", peer->name);
ast_free_ha(peer->ha);
ast_free(peer);
}
{
if (c->nativeformats != pvt->nativeformats) {
if (h323debug)
- ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name);
+ ast_debug(1, "Preparing %s for new native format\n", c->name);
c->nativeformats = pvt->nativeformats;
ast_set_read_format(c, c->readformat);
ast_set_write_format(c, c->writeformat);
}
if (pvt->needhangup) {
if (h323debug)
- ast_log(LOG_DEBUG, "Process pending hangup for %s\n", c->name);
+ ast_debug(1, "Process pending hangup for %s\n", c->name);
c->_softhangup |= AST_SOFTHANGUP_DEV;
c->hangupcause = pvt->hangupcause;
ast_queue_hangup(c);
if (pvt->owner) {
ast_channel_lock(pvt->owner);
if (h323debug)
- ast_log(LOG_DEBUG, "Detaching from %s\n", pvt->owner->name);
+ ast_debug(1, "Detaching from %s\n", pvt->owner->name);
pvt->owner->tech_pvt = NULL;
ast_channel_unlock(pvt->owner);
}
static void oh323_destroy(struct oh323_pvt *pvt)
{
if (h323debug) {
- ast_log(LOG_DEBUG, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
+ ast_debug(1, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
}
ast_mutex_lock(&iflock);
ast_mutex_lock(&pvt->lock);
char called_addr[1024];
if (h323debug) {
- ast_log(LOG_DEBUG, "Calling to %s on %s\n", dest, c->name);
+ ast_debug(1, "Calling to %s on %s\n", dest, c->name);
}
if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "Line is already in use (%s)\n", c->name);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Requested transfer capability: 0x%.2x - %s\n", c->transfercapability, ast_transfercapability2str(c->transfercapability));
if (h323debug)
- ast_log(LOG_DEBUG, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
+ ast_debug(1, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
ast_mutex_unlock(&pvt->lock);
res = h323_make_call(called_addr, &(pvt->cd), &pvt->options);
if (res) {
char *token;
if (h323debug)
- ast_log(LOG_DEBUG, "Answering on %s\n", c->name);
+ ast_debug(1, "Answering on %s\n", c->name);
ast_mutex_lock(&pvt->lock);
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
if (h323debug)
- ast_log(LOG_DEBUG, "Hanging up and scheduling destroy of call %s\n", c->name);
+ ast_debug(1, "Hanging up and scheduling destroy of call %s\n", c->name);
if (!c->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return &ast_null_frame;
}
if (h323debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
pvt->owner->nativeformats = f->subclass;
pvt->nativeformats = f->subclass;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "OH323: Indicating %d on %s (%s)\n", condition, token, c->name);
+ ast_debug(1, "OH323: Indicating %d on %s (%s)\n", condition, token, c->name);
switch(condition) {
case AST_CONTROL_RINGING:
}
if (h323debug)
- ast_log(LOG_DEBUG, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
+ ast_debug(1, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
if (token)
ast_free(token);
oh323_update_info(c);
return -1;
}
if (h323debug)
- ast_log(LOG_DEBUG, "Created RTP channel\n");
+ ast_debug(1, "Created RTP channel\n");
ast_rtp_setqos(pvt->rtp, tos, cos);
if (h323debug)
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
+ ast_debug(1, "Setting NAT on RTP to %d\n", pvt->options.nat);
ast_rtp_setnat(pvt->rtp, pvt->options.nat);
if (pvt->dtmf_pt[0] > 0)
u = realtime_user(cd);
if (!u && h323debug)
- ast_log(LOG_DEBUG, "Could not find user by name %s or address %s\n", cd->call_source_aliases, cd->sourceIp);
+ ast_debug(1, "Could not find user by name %s or address %s\n", cd->call_source_aliases, cd->sourceIp);
return u;
}
p = realtime_peer(peer, sin);
if (!p && h323debug)
- ast_log(LOG_DEBUG, "Could not find peer by name %s or address %s\n", (peer ? peer : "<NONE>"), (sin ? ast_inet_ntoa(sin->sin_addr) : "<NONE>"));
+ ast_debug(1, "Could not find peer by name %s or address %s\n", (peer ? peer : "<NONE>"), (sin ? ast_inet_ntoa(sin->sin_addr) : "<NONE>"));
return p;
}
char tmp[256], tmp1[256];
if (h323debug)
- ast_log(LOG_DEBUG, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
+ ast_debug(1, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
pvt = oh323_alloc(0);
if (!pvt) {
ast_copy_string(pvt->exten, ext, sizeof(pvt->exten));
}
if (h323debug)
- ast_log(LOG_DEBUG, "Extension: %s Host: %s\n", pvt->exten, host);
+ ast_debug(1, "Extension: %s Host: %s\n", pvt->exten, host);
if (gatekeeper_disable) {
if (create_addr(pvt, host)) {
ast_copy_string(info->addr, ast_inet_ntoa(us.sin_addr), sizeof(info->addr));
info->port = ntohs(us.sin_port);
if (h323debug)
- ast_log(LOG_DEBUG, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
+ ast_debug(1, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
return info;
}
enum { NEED_NONE, NEED_HOLD, NEED_UNHOLD } rtp_change = NEED_NONE;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting up RTP connection for %s\n", token);
+ ast_debug(1, "Setting up RTP connection for %s\n", token);
/* Find the call or allocate a private structure if call not found */
pvt = find_call_locked(call_reference, token);
if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
rtptype = ast_rtp_lookup_pt(pvt->rtp, pt);
if (h323debug)
- ast_log(LOG_DEBUG, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
+ ast_debug(1, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
if (pvt->nativeformats != rtptype.code) {
pvt->nativeformats = rtptype.code;
nativeformats_changed = 1;
/* Re-build translation path only if native format(s) has been changed */
if (pvt->owner->nativeformats != pvt->nativeformats) {
if (h323debug)
- ast_log(LOG_DEBUG, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
+ ast_debug(1, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
pvt->owner->nativeformats = pvt->nativeformats;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
ast_set_write_format(pvt->owner, pvt->owner->writeformat);
else if (rtp_change == NEED_UNHOLD)
pvt->newcontrol = AST_CONTROL_UNHOLD;
if (h323debug)
- ast_log(LOG_DEBUG, "RTP connection preparation for %s is pending...\n", token);
+ ast_debug(1, "RTP connection preparation for %s is pending...\n", token);
}
}
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "RTP connection prepared for %s\n", token);
+ ast_debug(1, "RTP connection prepared for %s\n", token);
return;
}
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Call %s answered\n", token);
+ ast_debug(1, "Call %s answered\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Received ALERT/PROGRESS message for %s tones\n", (inband ? "inband" : "self-generated"));
+ ast_debug(1, "Received ALERT/PROGRESS message for %s tones\n", (inband ? "inband" : "self-generated"));
pvt = find_call_locked(call_reference, token);
if (!pvt) {
struct oh323_alias *alias = NULL;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting up incoming call for %s\n", cd->call_token);
+ ast_debug(1, "Setting up incoming call for %s\n", cd->call_token);
/* allocate the call*/
pvt = oh323_alloc(cd->call_reference);
ast_copy_string(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten));
}
if (h323debug)
- ast_log(LOG_DEBUG, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
+ ast_debug(1, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
} else {
if (user->host) {
if (strcasecmp(cd->sourceIp, ast_inet_ntoa(user->addr.sin_addr))) {
char tmp_exten[sizeof(pvt->exten)];
if (h323debug)
- ast_log(LOG_DEBUG, "Preparing Asterisk to answer for %s\n", token);
+ ast_debug(1, "Preparing Asterisk to answer for %s\n", token);
/* Find the call or allocate a private structure if call not found */
pvt = find_call_locked(call_reference, token);
return 0;
} else if ((try_exten != ext_original) && (strcmp(pvt->exten, tmp_exten) != 0)) {
if (h323debug)
- ast_log(LOG_DEBUG, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
+ ast_debug(1, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
ast_copy_string(pvt->exten, tmp_exten, sizeof(pvt->exten));
}
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Ringing on %s\n", token);
+ ast_debug(1, "Ringing on %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Cleaning connection to %s\n", call_token);
+ ast_debug(1, "Cleaning connection to %s\n", call_token);
while (1) {
pvt = find_call_locked(call_reference, call_token);
if (!pvt) {
if (h323debug)
- ast_log(LOG_DEBUG, "No connection for %s\n", call_token);
+ ast_debug(1, "No connection for %s\n", call_token);
return;
}
if (!pvt->owner || !ast_channel_trylock(pvt->owner))
}
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "Connection to %s cleaned\n", call_token);
+ ast_debug(1, "Connection to %s cleaned\n", call_token);
return;
}
{
struct oh323_pvt *pvt;
- if (h323debug) {
- ast_log(LOG_DEBUG, "Hanging up connection to %s with cause %d\n", token, cause);
- }
+ if (h323debug)
+ ast_debug(1, "Hanging up connection to %s with cause %d\n", token, cause);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
- if (h323debug) {
- ast_log(LOG_DEBUG, "Connection to %s already cleared\n", token);
- }
+ if (h323debug)
+ ast_debug(1, "Connection to %s already cleared\n", token);
return;
}
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
pvt->needhangup = 1;
pvt->hangupcause = cause;
if (h323debug)
- ast_log(LOG_DEBUG, "Hangup for %s is pending\n", token);
+ ast_debug(1, "Hangup for %s is pending\n", token);
}
ast_mutex_unlock(&pvt->lock);
}
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting %s DTMF payload to %d on %s\n", (is_cisco ? "Cisco" : "RFC2833"), payload, token);
+ ast_debug(1, "Setting %s DTMF payload to %d on %s\n", (is_cisco ? "Cisco" : "RFC2833"), payload, token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
pvt->dtmf_pt[is_cisco ? 1 : 0] = payload;
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "DTMF payload on %s set to %d\n", token, payload);
+ ast_debug(1, "DTMF payload on %s set to %d\n", token, payload);
}
static void set_peer_capabilities(unsigned call_reference, const char *token, int capabilities, struct ast_codec_pref *prefs)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Got remote capabilities from connection %s\n", token);
+ ast_debug(1, "Got remote capabilities from connection %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
for (i = 0; i < 32; ++i) {
if (!prefs->order[i])
break;
- ast_log(LOG_DEBUG, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
+ ast_debug(1, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
}
}
if (pvt->rtp)
struct ast_codec_pref prefs;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting capabilities for connection %s\n", token);
+ ast_debug(1, "Setting capabilities for connection %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
h323_set_capabilities(token, capability, dtmfmode, &prefs, pref_codec);
if (h323debug)
- ast_log(LOG_DEBUG, "Capabilities for connection %s is set\n", token);
+ ast_debug(1, "Capabilities for connection %s is set\n", token);
}
static void remote_hold(unsigned call_reference, const char *token, int is_hold)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting %shold status for connection %s\n", (is_hold ? "" : "un"), token);
+ ast_debug(1, "Setting %shold status for connection %s\n", (is_hold ? "" : "un"), token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
max = x + 1;
}
maxtrunkcall = max;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "New max trunk callno is %d\n", max);
+ if (iaxdebug)
+ ast_debug(1, "New max trunk callno is %d\n", max);
}
static void update_max_nontrunk(void)
max = x + 1;
}
maxnontrunkcall = max;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "New max nontrunk callno is %d\n", max);
+ if (iaxdebug)
+ ast_debug(1, "New max nontrunk callno is %d\n", max);
}
static int make_trunk(unsigned short callno, int locked)
ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x);
+ ast_debug(1, "Made call %d into trunk call %d\n", callno, x);
/* We move this call from a non-trunked to a trunked call */
update_max_trunk();
update_max_nontrunk();
iaxs[x] = new_iax(sin, lockpeer, host);
update_max_nontrunk();
if (iaxs[x]) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Creating new call structure %d\n", x);
+ if (iaxdebug)
+ ast_debug(1, "Creating new call structure %d\n", x);
iaxs[x]->sockfd = sockfd;
iaxs[x]->addr.sin_port = sin->sin_port;
iaxs[x]->addr.sin_family = sin->sin_family;
res = sendto(sockfd, f->data, f->datalen, 0,(struct sockaddr *)sin,
sizeof(*sin));
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ ast_debug(1, "Received error: %s\n", strerror(errno));
handle_error();
} else
res = 0;
return -1;
/* Called with iaxsl held */
- if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
+ if (iaxdebug)
+ ast_debug(3, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
if (f->transfer) {
if (iaxdebug)
iax_showframe(f, NULL, 0, &iaxs[callno]->transfer, f->datalen - sizeof(struct ast_iax2_full_hdr));
sizeof(iaxs[callno]->addr));
}
if (res < 0) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ if (iaxdebug)
+ ast_debug(1, "Received error: %s\n", strerror(errno));
handle_error();
} else
res = 0;
gotten the update from the main packet. We'll just pretend that we did, and
update the timestamp appropriately. */
fr->ts = ( (iaxs[fr->callno]->last & 0xFFFF0000) + 0x10000) | (fr->ts & 0xFFFF);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "schedule_delivery: pushed forward timestamp\n");
+ if (iaxdebug)
+ ast_debug(1, "schedule_delivery: pushed forward timestamp\n");
}
if (x > 50000) {
/* Sudden apparent big jump forwards in timestamp:
top-16-bit timestamp that has turned up out of order.
Adjust the timestamp appropriately. */
fr->ts = ( (iaxs[fr->callno]->last & 0xFFFF0000) - 0x10000) | (fr->ts & 0xFFFF);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "schedule_delivery: pushed back timestamp\n");
+ if (iaxdebug)
+ ast_debug(1, "schedule_delivery: pushed back timestamp\n");
}
}
}
fr->af.delivery = ast_tvadd(iaxs[fr->callno]->rxcore, ast_samp2tv(fr->ts, 1000));
else {
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
+ ast_debug(1, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
#endif
fr->af.delivery = ast_tv(0,0);
}
if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
memset(&peer->addr, 0, sizeof(peer->addr));
realtime_update_peer(peer->name, &peer->addr, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
- peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
- peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
}
} else
ast_log(LOG_WARNING, "OSP token is too long\n");
- } else if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "OSP token is undefined\n");
+ } else if (iaxdebug)
+ ast_debug(1, "OSP token is undefined\n");
/* send the command using the appropriate socket for this peer */
iaxs[callno]->sockfd = cai.sockfd;
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&iaxsl[callno]);
if (callno && iaxs[callno]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
+ ast_debug(1, "We're hanging up %s now...\n", c->name);
alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
/* Send the hangup unless we have had a transmission error or are already gone */
iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
iax2_predestroy(callno);
/* If we were already gone to begin with, destroy us now */
if (alreadygone) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
+ ast_debug(1, "Really destroying %s now...\n", c->name);
iax2_destroy(callno);
}
}
static int iax2_answer(struct ast_channel *c)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering IAX2 call\n");
+ ast_debug(1, "Answering IAX2 call\n");
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno])
iax2_ami_channelupdate(iaxs[callno]);
struct chan_iax2_pvt *pvt;
int res = 0;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
+ if (iaxdebug)
+ ast_debug(1, "Indicating condition %d\n", condition);
ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, tmp);
if (context)
iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, context);
- if (option_debug)
- ast_log(LOG_DEBUG, "Transferring '%s' to '%s'\n", c->name, dest);
+ ast_debug(1, "Transferring '%s' to '%s'\n", c->name, dest);
return send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1);
}
/* If we have a time that the frame arrived, always use it to make our timestamp */
if (delivery && !ast_tvzero(*delivery)) {
ms = ast_tvdiff_ms(*delivery, p->offset);
- if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "calc_timestamp: call %d/%d: Timestamp slaved to delivery time\n", p->callno, iaxs[p->callno]->peercallno);
+ if (iaxdebug)
+ ast_debug(3, "calc_timestamp: call %d/%d: Timestamp slaved to delivery time\n", p->callno, iaxs[p->callno]->peercallno);
} else {
ms = ast_tvdiff_ms(ast_tvnow(), p->offset);
if (ms < 0)
* frame size too) */
if (iaxdebug && abs(ms - p->nextpred) > MAX_TIMESTAMP_SKEW )
- ast_log(LOG_DEBUG, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n",
+ ast_debug(1, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n",
abs(ms - p->nextpred), MAX_TIMESTAMP_SKEW);
if (f->samples >= 8) /* check to make sure we dont core dump */
/* Setup rxcore if necessary */
if (ast_tvzero(p->rxcore)) {
p->rxcore = ast_tvnow();
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %dms\n",
+ if (iaxdebug)
+ ast_debug(1, "calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %dms\n",
p->callno, (int)(p->rxcore.tv_sec), (int)(p->rxcore.tv_usec), offset);
p->rxcore = ast_tvsub(p->rxcore, ast_samp2tv(offset, 1000));
#if 1
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "calc_rxstamp: call=%d: works out as %d.%6.6d\n",
+ if (iaxdebug)
+ ast_debug(1, "calc_rxstamp: call=%d: works out as %d.%6.6d\n",
p->callno, (int)(p->rxcore.tv_sec),(int)( p->rxcore.tv_usec));
#endif
}
#ifdef SO_NO_CHECK
setsockopt(tpeer->sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums));
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ ast_debug(1, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
AST_LIST_INSERT_TAIL(&tpeers, tpeer, list);
}
}
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
tpeer->trunkdata = tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
+ ast_debug(1, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
} else {
ast_log(LOG_WARNING, "Maximum trunk data space exceeded to %s:%d\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
ast_mutex_unlock(&tpeer->lock);
memcpy_decrypt(workspace, efh->encdata, *datalen - sizeof(struct ast_iax2_full_enc_hdr), dcx);
padding = 16 + (workspace[15] & 0xf);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, workspace[15]);
+ if (iaxdebug)
+ ast_debug(1, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, workspace[15]);
if (*datalen < padding + sizeof(struct ast_iax2_full_hdr))
return -1;
}
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Decoding mini with length %d\n", *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Decoding mini with length %d\n", *datalen);
if (*datalen < 16 + sizeof(struct ast_iax2_mini_hdr))
return -1;
/* Decrypt */
return -1;
if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding full frame %d/%d with length %d\n", fh->type, fh->csub, *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Encoding full frame %d/%d with length %d\n", fh->type, fh->csub, *datalen);
padding = 16 - ((*datalen - sizeof(struct ast_iax2_full_enc_hdr)) % 16);
padding = 16 + (padding & 0xf);
memcpy(workspace, poo, padding);
memcpy(workspace + padding, efh->encdata, *datalen - sizeof(struct ast_iax2_full_enc_hdr));
workspace[15] &= 0xf0;
workspace[15] |= (padding & 0xf);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, workspace[15]);
+ if (iaxdebug)
+ ast_debug(1, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, workspace[15]);
*datalen += padding;
memcpy_encrypt(efh->encdata, workspace, *datalen - sizeof(struct ast_iax2_full_enc_hdr), ecx);
if (*datalen >= 32 + sizeof(struct ast_iax2_full_enc_hdr))
memcpy(poo, workspace + *datalen - 32, 32);
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding mini frame with length %d\n", *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Encoding mini frame with length %d\n", *datalen);
padding = 16 - ((*datalen - sizeof(struct ast_iax2_mini_enc_hdr)) % 16);
padding = 16 + (padding & 0xf);
memcpy(workspace, poo, padding);
/* Simple, just queue for transmission */
res = iax2_send(iaxs[callno], f, 0, -1, 0, 0, 0);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
+ ast_debug(1, "Write error: %s\n", strerror(errno));
}
}
/* If it's already gone, just return */
#if 0
if (option_debug)
#endif
- ast_log(LOG_DEBUG, "Raw Hangup %s:%d, src=%d, dst=%d\n",
+ ast_debug(1, "Raw Hangup %s:%d, src=%d, dst=%d\n",
ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
return sendto(sockfd, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
}
if (!p)
return;
- if (option_debug)
- ast_log(LOG_DEBUG, "Expiring registration for peer '%s'\n", p->name);
+ ast_debug(1, "Expiring registration for peer '%s'\n", p->name);
if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
realtime_update_peer(p->name, &p->addr, 0);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", p->name);
res = transmit_trunk(fr, &tpeer->addr, tpeer->sockfd);
calls = tpeer->calls;
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
+ ast_debug(1, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
#endif
/* Reset transmit trunk side data */
tpeer->trunkdatalen = 0;
ast_mutex_lock(&drop->lock);
/* Once we have this lock, we're sure nobody else is using it or could use it once we release it,
because by the time they could get tpeerlock, we've already grabbed it */
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
+ ast_debug(1, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
ast_free(drop->trunkdata);
ast_mutex_unlock(&drop->lock);
ast_mutex_destroy(&drop->lock);
snprintf(rsi, sizeof(rsi), "si-%s", si);
if (iax_provision_version(&ourver, rsi, 1))
return 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
+ ast_debug(1, "Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
if (ourver != ver)
iax2_provision(sin, sockfd, NULL, rsi, 1);
return 0;
iaxs[fr->callno]->peercallno = (unsigned short)(ntohs(mh->callno) & ~IAX_FLAG_FULL);
}
if (ntohs(mh->callno) & IAX_FLAG_FULL) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
+ if (iaxdebug)
+ ast_debug(1, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
/* Check if it's out of order (and not an ACK or INVAL) */
fr->oseqno = fh->oseqno;
fr->iseqno = fh->iseqno;
fr->ts = ntohl(fh->ts);
#ifdef IAXTESTS
if (test_resync) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Simulating frame ts resync, was %u now %u\n", fr->ts, fr->ts + test_resync);
+ ast_debug(1, "Simulating frame ts resync, was %u now %u\n", fr->ts, fr->ts + test_resync);
fr->ts += test_resync;
}
#endif /* IAXTESTS */
(f.subclass != IAX_COMMAND_VNAK)) ||
(f.frametype != AST_FRAME_IAX)) {
/* If it's not an ACK packet, it's out of order. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
+ ast_debug(1, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
iaxs[fr->callno]->iseqno, fr->oseqno, f.frametype, f.subclass);
if (iaxs[fr->callno]->iseqno > fr->oseqno) {
/* If we've already seen it, ack it XXX There's a border condition here XXX */
if ((f.frametype != AST_FRAME_IAX) ||
((f.subclass != IAX_COMMAND_ACK) && (f.subclass != IAX_COMMAND_INVAL))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acking anyway\n");
+ ast_debug(1, "Acking anyway\n");
/* XXX Maybe we should handle its ack to us, but then again, it's probably outdated anyway, and if
we have anything to send, we'll retransmit and get an ACK back anyway XXX */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
that it says to */
for (x=iaxs[fr->callno]->rseqno; x != fr->iseqno; x++) {
/* Ack the packet with the given timestamp */
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Cancelling transmission of packet %d\n", x);
+ if (iaxdebug)
+ ast_debug(1, "Cancelling transmission of packet %d\n", x);
call_to_destroy = 0;
AST_LIST_LOCK(&queue);
AST_LIST_TRAVERSE(&queue, cur, list) {
}
AST_LIST_UNLOCK(&queue);
if (call_to_destroy) {
- if (iaxdebug && option_debug)
- ast_log(LOG_DEBUG, "Really destroying %d, having been acked on final message\n", call_to_destroy);
+ if (iaxdebug)
+ ast_debug(1, "Really destroying %d, having been acked on final message\n", call_to_destroy);
iax2_destroy(call_to_destroy);
}
}
return 1;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
+ ast_debug(1, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
}
}
if (inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
if (f.frametype == AST_FRAME_VOICE) {
if (f.subclass != iaxs[fr->callno]->voiceformat) {
iaxs[fr->callno]->voiceformat = f.subclass;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
+ ast_debug(1, "Ooh, voice format changed to %d\n", f.subclass);
if (iaxs[fr->callno]->owner) {
int orignative;
retryowner:
ast_mutex_unlock(&iaxs[fr->callno]->owner->lock);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
+ ast_debug(1, "Neat, somebody took away the channel at a magical time but i found it!\n");
/* Free remote variables (if any) */
if (ies.vars)
ast_variables_destroy(ies.vars);
}
if (f.frametype == AST_FRAME_VIDEO) {
if (f.subclass != iaxs[fr->callno]->videoformat) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
+ ast_debug(1, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
iaxs[fr->callno]->videoformat = f.subclass & ~0x1;
}
}
iaxs[fr->callno]->initid = -1;
}
/* Handle the IAX pseudo frame itself */
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "IAX subclass %d received\n", f.subclass);
+ if (iaxdebug)
+ ast_debug(1, "IAX subclass %d received\n", f.subclass);
/* Update last ts unless the frame's timestamp originated with us. */
if (iaxs[fr->callno]->last < fr->ts &&
f.subclass != IAX_COMMAND_PONG &&
f.subclass != IAX_COMMAND_LAGRP) {
iaxs[fr->callno]->last = fr->ts;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
+ if (iaxdebug)
+ ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
}
switch(f.subclass) {
break;
case IAX_COMMAND_HANGUP:
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received hangup\n", fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received hangup\n", fr->callno);
/* Set hangup cause according to remote */
if (ies.causecode && iaxs[fr->callno]->owner)
iaxs[fr->callno]->owner->hangupcause = ies.causecode;
ast_log(LOG_WARNING, "Call rejected by %s: %s\n",
ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr),
ies.cause ? ies.cause : "<Unknown>");
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n",
- fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received reject\n",
+ fr->callno);
}
/* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK,
if (iax_park(ast_bridged_channel(iaxs[fr->callno]->owner), iaxs[fr->callno]->owner)) {
ast_log(LOG_WARNING, "Failed to park call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
} else if (ast_bridged_channel(iaxs[fr->callno]->owner)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
+ ast_debug(1, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
}
} else {
if (ast_async_goto(ast_bridged_channel(iaxs[fr->callno]->owner), iaxs[fr->callno]->context, ies.called_number, 1))
ast_log(LOG_WARNING, "Async goto of '%s' to '%s@%s' failed\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
ies.called_number, iaxs[fr->callno]->context);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Async goto of '%s' to '%s@%s' started\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
- ies.called_number, iaxs[fr->callno]->context);
+ ast_debug(1, "Async goto of '%s' to '%s@%s' started\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
+ ies.called_number, iaxs[fr->callno]->context);
}
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Async goto not applicable on call %d\n", fr->callno);
+ ast_debug(1, "Async goto not applicable on call %d\n", fr->callno);
}
break;
case IAX_COMMAND_ACCEPT:
/* And wrap up the qualify call */
iax2_destroy(fr->callno);
peer->callno = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
+ ast_debug(1, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
}
break;
case IAX_COMMAND_LAGRQ:
/* This is a reply we've been given, actually measure the difference */
ts = calc_timestamp(iaxs[fr->callno], 0, &fr->af);
iaxs[fr->callno]->lag = ts - fr->ts;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Peer %s lag measured as %dms\n",
+ if (iaxdebug)
+ ast_debug(1, "Peer %s lag measured as %dms\n",
ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->lag);
}
break;
}
if (!format) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
+ ast_debug(1, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
}
if (!format) {
break;
case IAX_COMMAND_INVAL:
iaxs[fr->callno]->error = ENOTCONN;
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received INVAL\n", fr->callno);
iax2_destroy(fr->callno);
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying call %d\n", fr->callno);
+ ast_debug(1, "Destroying call %d\n", fr->callno);
break;
case IAX_COMMAND_VNAK:
- if (option_debug)
- ast_log(LOG_DEBUG, "Received VNAK: resending outstanding frames\n");
+ ast_debug(1, "Received VNAK: resending outstanding frames\n");
/* Force retransmission */
vnak_retransmit(fr->callno, fr->iseqno);
break;
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_FWDATA, 0, ied0.buf, ied0.pos, -1);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
+ ast_debug(1, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_byte(&ied0, IAX_IE_IAX_UNKNOWN, f.subclass);
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_UNSUPPORT, 0, ied0.buf, ied0.pos, -1);
/*iaxs[fr->callno]->last = fr->ts; (do it afterwards cos schedule/forward_delivery needs the last ts too)*/
fr->outoforder = 0;
} else {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
+ if (iaxdebug)
+ ast_debug(1, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
fr->outoforder = -1;
}
duped_fr = iaxfrdup2(fr);
if (iaxs[fr->callno] && iaxs[fr->callno]->last < fr->ts) {
iaxs[fr->callno]->last = fr->ts;
#if 1
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
+ if (iaxdebug)
+ ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
#endif
}
static int iax2_do_register(struct iax2_registry *reg)
{
struct iax_ie_data ied;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Sending registration request for '%s'\n", reg->username);
+ if (iaxdebug)
+ ast_debug(1, "Sending registration request for '%s'\n", reg->username);
if (reg->dnsmgr &&
((reg->regstate == REG_STATE_TIMEOUT) || !reg->addr.sin_addr.s_addr)) {
reg->callno = 0;
}
if (!reg->addr.sin_addr.s_addr) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Unable to send registration request for '%s' without IP address\n", reg->username);
+ if (iaxdebug)
+ ast_debug(1, "Unable to send registration request for '%s' without IP address\n", reg->username);
/* Setup the next registration attempt */
if (reg->expire > -1)
ast_sched_del(sched, reg->expire);
}
if (!reg->callno) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocate call number\n");
+ ast_debug(1, "Allocate call number\n");
reg->callno = find_callno(0, 0, ®->addr, NEW_FORCE, 1, defaultsockfd);
if (reg->callno < 1) {
ast_log(LOG_WARNING, "Unable to create call for registration\n");
return -1;
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Registration created on call %d\n", reg->callno);
+ } else
+ ast_debug(1, "Registration created on call %d\n", reg->callno);
iaxs[reg->callno]->reg = reg;
}
/* Schedule the next registration attempt */
memset(&cai, 0, sizeof(cai));
- if (option_debug)
- ast_log(LOG_DEBUG, "Provisioning '%s' from template '%s'\n", dest, template);
+ ast_debug(1, "Provisioning '%s' from template '%s'\n", dest, template);
if (iax_provision_build(&provdata, &sig, template, force)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
+ ast_debug(1, "No provisioning found for template '%s'\n", template);
return 0;
}
pthread_testcancel();
count = ast_sched_runq(sched);
- if (count >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
+ if (count >= 20)
+ ast_debug(1, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
}
return NULL;
AST_LIST_UNLOCK(&queue);
pthread_testcancel();
- if (count >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
+ if (count >= 20)
+ ast_debug(1, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
/* Now do the IO, and run scheduled tasks */
res = ast_io_wait(io, wakeup);
if (res >= 0) {
- if (res >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
+ if (res >= 20)
+ ast_debug(1, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
}
}
return NULL;
res = bind(sd, sa, salen);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
+ ast_debug(1, "Can't bind: %s\n", strerror(errno));
close(sd);
return 1;
}
srcaddr, peer->name);
return -1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
+ ast_debug(1, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
return 0;
}
}
if (create_addr(pds.peer, &sin, &cai))
return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "peer: %s, username: %s, password: %s, context: %s\n",
- pds.peer, pds.username, pds.password, pds.context);
+ ast_debug(1, "peer: %s, username: %s, password: %s, context: %s\n",
+ pds.peer, pds.username, pds.password, pds.context);
callno = find_callno(0, 0, &sin, NEW_FORCE, 1, cai.sockfd);
if (callno < 1) {
if (ast_strlen_zero(pds.peer))
return res;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for device %s\n", pds.peer);
+ ast_debug(3, "Checking device state for device %s\n", pds.peer);
/* SLD: FIXME: second call to find_peer during registration */
if (!(p = find_peer(pds.peer, 1)))
return res;
res = AST_DEVICE_UNAVAILABLE;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
- pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
+ ast_debug(3, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
+ pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
(!p->maxms || ((p->lastms > -1) && (p->historicms <= p->maxms)))) {
struct jingle *client = p->parent;
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answer!\n");
+ ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
jingle_accept_call(client, p);
ast_mutex_unlock(&p->lock);
{
struct jingle_pvt *tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
{
struct jingle_pvt *tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
struct aji_buddy *buddy;
char idroster[200];
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
+ ast_debug(1, "The client is %s for alloc\n", client->name);
if (!sid && !strchr(from, '/')) { /* I started call! */
if (!strcasecmp(client->name, "guest")) {
buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, from);
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats =
(p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
}
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
- if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ if (f && (f->frametype == AST_FRAME_DTMF))
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
/* New call */
jingle_newcall(client, pak);
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_NEGOTIATE)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "About to add candidate!\n");
+ ast_debug(3, "About to add candidate!\n");
jingle_add_candidate(client, pak);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Candidate Added!\n");
+ ast_debug(3, "Candidate Added!\n");
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_ACCEPT)) {
jingle_is_answered(client, pak);
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "content-info")) {
if ((opts = strchr(context, '/')))
*opts = '\0';
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
+ ast_debug(3, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
res = ast_exists_extension(NULL, context, exten, 1, NULL);
if (!res)
if (!ast_test_flag(p, LOCAL_ALREADY_MASQED))
res = local_queue_frame(p, isoutbound, f, ast);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
+ ast_debug(1, "Not posting to queue since already masked on '%s'\n", ast->name);
res = 0;
}
if (!res)
ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name, p->parent->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
+ ast_debug(1, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
sub->owner = NULL;
if (!ast_strlen_zero(sub->cxident)) {
/* XXX Should schedule retransmission XXX */
/* SC
} else
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
+ ast_debug(1, "Deferring transmission of transaction %d\n", seqno);
*/
return 0;
}
struct mgcp_request **queue, *q, *r, *t;
ast_mutex_t *l;
- if (option_debug)
- ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
+ ast_debug(1, "Slow sequence is %d\n", p->slowsequence);
if (p->slowsequence) {
queue = &p->cmd_queue;
l = &p->cmd_queue_lock;
struct mgcp_subchannel *sub = ast->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
- if (option_debug) {
- ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
- }
+ ast_debug(1, "mgcp_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ ast_debug(1, "Asked to hangup channel not connected\n");
return 0;
}
if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
+ ast_debug(1, "Invalid magic. MGCP subchannel freed up already.\n");
return 0;
}
ast_mutex_lock(&sub->lock);
}
if (ast->_state != AST_STATE_UP) {
ast_setstate(ast, AST_STATE_UP);
- if (option_debug)
- ast_log(LOG_DEBUG, "mgcp_answer(%s)\n", ast->name);
+ ast_debug(1, "mgcp_answer(%s)\n", ast->name);
transmit_notify_request(sub, "");
transmit_modify_request(sub);
}
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != sub->owner->nativeformats) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
sub->owner->nativeformats = f->subclass;
ast_set_read_format(sub->owner, sub->owner->readformat);
ast_set_write_format(sub->owner, sub->owner->writeformat);
/* SC */
p = g->endpoints;
while(p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Searching on %s@%s for subchannel\n",
- p->name, g->name);
+ ast_debug(1, "Searching on %s@%s for subchannel\n",
+ p->name, g->name);
if (msgid) {
#if 0 /* new transport mech */
sub = p->sub;
do {
- if (option_debug)
- ast_log(LOG_DEBUG, "Searching on %s@%s-%d for subchannel with lastout: %d\n",
- p->name, g->name, sub->id, msgid);
+ ast_debug(1, "Searching on %s@%s-%d for subchannel with lastout: %d\n",
+ p->name, g->name, sub->id, msgid);
if (sub->lastout == msgid) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found subchannel sub%d to handle request %d sub->lastout: %d\n",
- sub->id, msgid, sub->lastout);
+ ast_debug(1, "Found subchannel sub%d to handle request %d sub->lastout: %d\n",
+ sub->id, msgid, sub->lastout);
found = 1;
break;
}
/* SC */
break;
} else if (name && !strcasecmp(p->name, tmp)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
- p->name, g->name, p->sub->id);
+ ast_debug(1, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
+ p->name, g->name, p->sub->id);
sub = p->sub;
found = 1;
break;
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ ast_debug(1, "not enough digits (and no ambiguous match)...\n");
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
transmit_notify_request(sub, "G/cg");
/*zt_wait_event(p->subs[index].zfd);*/
timeout = firstdigittimeout;
} else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1, chan->cid.cid_num) &&
((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+ ast_debug(1, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
break;
}
if (!timeout)
for (;;) {
res = ast_waitfordigit(chan, to);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Timeout...\n");
+ ast_debug(1, "Timeout...\n");
break;
}
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup...\n");
+ ast_debug(1, "Got hangup...\n");
ast_hangup(chan);
break;
}
/* Tell the caller not to hangup */
return 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n",
- p->sub->owner->name, p->sub->next->owner->name);
+ ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
+ p->sub->owner->name, p->sub->next->owner->name);
p->sub->next->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (p->sub->next->owner) {
p->sub->next->alreadygone = 1;
ev = get_header(req, "O");
s = strchr(ev, '/');
if (s) ev = s + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
+ ast_debug(1, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
/* Keep looking for events unless this was a hangup */
if (strcasecmp(ev, "hu") && strcasecmp(ev, "hd") && strcasecmp(ev, "ping")) {
transmit_notify_request(sub, p->curtone);
} else if (!strcasecmp(ev, "hu")) {
p->hookstate = MGCP_ONHOOK;
sub->cxmode = MGCP_CX_RECVONLY;
- if (option_debug)
- ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
+ ast_debug(1, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
/* Do we need to send MDCX before a DLCX ?
if (sub->rtp) {
transmit_modify_request(sub);
ast_mutex_lock(&gw->msgs_lock);
for (prev = NULL, cur = gw->msgs; cur; prev = cur, cur = cur->next) {
if (cur->seqno == ident) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident);
+ ast_debug(1, "Got response back on transaction %d\n", ident);
if (prev)
prev->next = cur->next;
else
ast_playtones_start(chan,0,dtmf_tones[15], 0);
else {
/* not handled */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
/*** CLI HANDLING ***/
struct misdn_bchannel *bc = NULL;
const char *varcause = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
+ ast_debug(1, "misdn_hangup(%s)\n", ast->name);
if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) ) ) return -1;
CLEAN_CH:
/* between request and call */
- if (option_debug)
- ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
+ ast_debug(1, "State Reserved (or nothing) => chanIsAvail\n");
MISDN_ASTERISK_TECH_PVT(ast) = NULL;
cl_dequeue_chan(&cl_te, p);
if (!f || (f->frametype != AST_FRAME_DTMF))
return frame;
- if (option_debug)
- ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
+ ast_debug(1, "Detected inband DTMF digit: %c\n", f->subclass);
if (tmp->faxdetect && (f->subclass == 'f')) {
/* Fax tone -- Handle and return NULL */
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n", context, ast->exten);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
}
break;
case 2:
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ ast_debug(1, "Fax already handled\n");
}
}
{
int i, max = 5 > frame->samples ? frame->samples : 5;
- ast_log(LOG_DEBUG, "write2mISDN %p %d bytes: ", p, frame->samples);
+ ast_debug(1, "write2mISDN %p %d bytes: ", p, frame->samples);
for (i = 0; i < max ; i++)
- ast_log(LOG_DEBUG, "%2.2x ", ((char*) frame->data)[i]);
+ ast_debug(1, "%2.2x ", ((char*) frame->data)[i]);
}
#endif
}
/* When we call, it just works, really, there's no destination... Just
ring the phone and wait for someone to answer */
- if (option_debug)
- ast_log(LOG_DEBUG, "Calling %s on %s\n", dest, ast->name);
+ ast_debug(1, "Calling %s on %s\n", dest, ast->name);
/* If we can't connect, return congestion */
if (nbs_connect(p->nbs)) {
{
struct nbs_pvt *p;
p = ast->tech_pvt;
- if (option_debug)
- ast_log(LOG_DEBUG, "nbs_hangup(%s)\n", ast->name);
+ ast_debug(1, "nbs_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
p->fr.delivery.tv_sec = 0;
p->fr.delivery.tv_usec = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
+ ast_debug(1, "Returning null frame on %s\n", ast->name);
return &p->fr;
}
{
struct phone_pvt *p = chan->tech_pvt;
int res=-1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
switch(condition) {
case AST_CONTROL_FLASH:
ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
struct phone_pvt *p;
int outdigit;
p = ast->tech_pvt;
- ast_log(LOG_DEBUG, "Dialed %c\n", digit);
+ ast_debug(1, "Dialed %c\n", digit);
switch(digit) {
case '0':
case '1':
ast_log(LOG_WARNING, "Unknown digit '%c'\n", digit);
return -1;
}
- ast_log(LOG_DEBUG, "Dialed %d\n", outdigit);
+ ast_debug(1, "Dialed %d\n", outdigit);
ioctl(p->fd, PHONE_PLAY_TONE, outdigit);
p->lastformat = -1;
return 0;
ast_log(LOG_WARNING, "phone_call called on %s, neither down nor reserved\n", ast->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
+ ast_debug(1, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
start = IXJ_PHONE_RING_START(cid);
if (start == -1)
{
struct phone_pvt *p;
p = ast->tech_pvt;
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_hangup(%s)\n", ast->name);
+ ast_debug(1, "phone_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
/* If it's an FXO, hang them up */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
- }
+ if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
}
/* If they're off hook, give a busy signal */
if (ioctl(p->fd, PHONE_HOOKSTATE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hunghup, giving busy signal\n");
+ ast_debug(1, "Got hunghup, giving busy signal\n");
ioctl(p->fd, PHONE_BUSY);
p->cpt = 1;
}
p = ast->tech_pvt;
/* In case it's a LineJack, take it off hook */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
- }
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Took linejack off hook\n");
- }
+ if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
+ else
+ ast_debug(1, "Took linejack off hook\n");
}
phone_setup(ast);
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_answer(%s)\n", ast->name);
+ ast_debug(1, "phone_answer(%s)\n", ast->name);
ast->rings = 0;
ast_setstate(ast, AST_STATE_UP);
return 0;
phonee.bytes = ioctl(p->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_exception(): DTMF\n");
+ ast_debug(1, "phone_exception(): DTMF\n");
/* We've got a digit -- Just handle this nicely and easily */
digit = ioctl(p->fd, PHONE_GET_DTMF_ASCII);
return &p->fr;
}
if (phonee.bits.hookstate) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hookstate changed\n");
+ ast_debug(1, "Hookstate changed\n");
res = ioctl(p->fd, PHONE_HOOKSTATE);
/* See if we've gone on hook, if so, notify by returning NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "New hookstate: %d\n", res);
+ ast_debug(1, "New hookstate: %d\n", res);
if (!res && (p->mode != MODE_FXO))
return NULL;
else {
union telephony_exception phonee;
/* XXX Do something XXX */
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Exception!\n");
+ ast_debug(1, "Exception!\n");
#endif
phonee.bytes = ioctl(i->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
/* XXX This should probably be justified better XXX */
} else if (!ast_canmatch_extension(NULL, "default", i->ext, 1, i->cid_num)) {
/* It's not a valid extension, give a busy signal */
- if (option_debug)
- ast_log(LOG_DEBUG, "%s can't match anything in %s or default\n", i->ext, i->context);
+ ast_debug(1, "%s can't match anything in %s or default\n", i->ext, i->context);
ioctl(i->fd, PHONE_BUSY);
i->cpt = 1;
}
}
/* Okay, select has finished. Let's see what happened. */
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
+ ast_debug(1, "select return %d: %s\n", res, strerror(errno));
continue;
}
/* If there are no fd's changed, just continue, it's probably time
}
if (mode == MODE_FXO) {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ ast_debug(1, "Unable to set port to PSTN\n");
}
} else {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_POTS))
if (mode != MODE_FXS)
- ast_log(LOG_DEBUG, "Unable to set port to POTS\n");
+ ast_debug(1, "Unable to set port to POTS\n");
}
ioctl(tmp->fd, PHONE_PLAY_STOP);
ioctl(tmp->fd, PHONE_REC_STOP);
ioctl(tmp->fd, PHONE_RING_STOP);
ioctl(tmp->fd, PHONE_CPT_STOP);
- if (ioctl(tmp->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",iface, strerror(errno));
- }
+ if (ioctl(tmp->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",iface, strerror(errno));
if (echocancel != AEC_OFF)
ioctl(tmp->fd, IXJCTL_AEC_START, echocancel);
if (silencesupression)
static void registry_unref(struct sip_registry *reg)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
+ ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
ASTOBJ_UNREF(reg, sip_registry_destroy);
}
/*! \brief Add object reference to SIP registry */
static struct sip_registry *registry_addref(struct sip_registry *reg)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
+ ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
return ASTOBJ_REF(reg); /* Add pointer to registry in packet */
}
a dialog */
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
{
- if (option_debug) {
- if (p->initreq.headers)
- ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
- else
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
- }
+ if (p->initreq.headers)
+ ast_debug(1, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
+ else
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
/* Use this as the basis */
copy_request(&p->initreq, req);
parse_request(&p->initreq);
/*! \brief Encapsulate setting of SIP_ALREADYGONE to be able to trace it with debugging */
static void sip_alreadygone(struct sip_pvt *dialog)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
+ ast_debug(3, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
ast_set_flag(&dialog->flags[0], SIP_ALREADYGONE);
}
static struct sip_proxy *obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
{
if (peer && peer->outboundproxy) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Applying peer OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Applying peer OBproxy to this call\n");
append_history(dialog, "OBproxy", "Using peer obproxy %s", peer->outboundproxy->name);
return peer->outboundproxy;
}
if (global_outboundproxy.name[0]) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Applying global OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Applying global OBproxy to this call\n");
append_history(dialog, "OBproxy", "Using global obproxy %s", global_outboundproxy.name);
return &global_outboundproxy;
}
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Not applying OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Not applying OBproxy to this call\n");
return NULL;
}
return 0;
temp = ast_strdupa(supported);
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
+ if (sipdebug)
+ ast_debug(3, "Begin: parsing SIP \"Supported: %s\"\n", supported);
for (next = temp; next; next = sep) {
found = FALSE;
if ( (sep = strchr(next, ',')) != NULL)
*sep++ = '\0';
next = ast_skip_blanks(next);
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Found SIP option: -%s-\n", next);
+ if (sipdebug)
+ ast_debug(3, "Found SIP option: -%s-\n", next);
for (i=0; i < (sizeof(sip_options) / sizeof(sip_options[0])); i++) {
if (!strcasecmp(next, sip_options[i].text)) {
profile |= sip_options[i].id;
found = TRUE;
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Matched SIP option: %s\n", next);
+ if (sipdebug)
+ ast_debug(3, "Matched SIP option: %s\n", next);
break;
}
}
- if (!found && option_debug > 2 && sipdebug) {
+ if (!found && sipdebug) {
if (!strncasecmp(next, "x-", 2))
- ast_log(LOG_DEBUG, "Found private SIP option, not supported: %s\n", next);
+ ast_debug(3, "Found private SIP option, not supported: %s\n", next);
else
- ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
+ ast_debug(3, "Found no match for SIP option: %s (Please file bug report!)\n", next);
}
}
ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
}
*us = externip.sin_addr;
- if (option_debug) {
- ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n",
- ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
- }
+ ast_debug(1, "Target address %s is not local, substituting externip\n",
+ ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
} else if (bindaddr.sin_addr.s_addr)
*us = bindaddr.sin_addr;
return AST_SUCCESS;
if (pkt->retrans < MAX_RETRANS) {
pkt->retrans++;
if (!pkt->timer_t1) { /* Re-schedule using timer_a and timer_t1 */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n", pkt->retransid, sip_methods[pkt->method].text, pkt->method);
+ if (sipdebug)
+ ast_debug(4, "SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n", pkt->retransid, sip_methods[pkt->method].text, pkt->method);
} else {
int siptimer_a;
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n", pkt->retransid, pkt->retrans, sip_methods[pkt->method].text, pkt->method);
+ if (sipdebug)
+ ast_debug(4, "SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n", pkt->retransid, pkt->retrans, sip_methods[pkt->method].text, pkt->method);
if (!pkt->timer_a)
pkt->timer_a = 2 ;
else
/* Reschedule re-transmit */
reschedule = siptimer_a;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
+ ast_debug(4, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
}
if (sip_debug_test_pvt(pkt->owner)) {
if (pkt->method != SIP_OPTIONS && pkt->method != SIP_REGISTER) {
ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);
sip_alreadygone(pkt->owner);
- if (option_debug)
- append_history(pkt->owner, "DialogKill", "Killing this failed dialog immediately");
+ append_history(pkt->owner, "DialogKill", "Killing this failed dialog immediately");
}
}
}
/* Schedule retransmission */
pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
+ if (sipdebug)
+ ast_debug(4, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
pkt->next = p->packets;
p->packets = pkt;
if (sipmethod == SIP_INVITE) {
transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE); /* Send last notification */
p->subscribed = NONE;
append_history(p, "Subscribestatus", "timeout");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
+ ast_debug(3, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
return 10000; /* Reschedule this destruction so that we know that it's gone */
}
ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text);
ast_queue_hangup(p->owner);
} else if (p->refer) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Finally hanging up channel after transfer: %s\n", p->callid);
+ ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid);
transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else {
append_history(p, "AutoDestroy", "%s", p->callid);
- if (option_debug)
- ast_log(LOG_DEBUG, "Auto destroying SIP dialog '%s'\n", p->callid);
+ ast_debug(3, "Auto destroying SIP dialog '%s'\n", p->callid);
sip_destroy(p); /* Go ahead and destroy dialog. All attempts to recover is done */
}
return 0;
if (ast_test_flag(cur, FLAG_RESPONSE) || cur->method == sipmethod) {
msg = "Found";
if (!resp && (seqno == p->pendinginvite)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
+ ast_debug(1, "Acked pending invite %d\n", p->pendinginvite);
p->pendinginvite = 0;
}
if (cur->retransid > -1) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
+ if (sipdebug)
+ ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
ast_sched_del(sched, cur->retransid);
cur->retransid = -1;
}
}
}
sip_pvt_unlock(p);
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n",
- p->callid, resp ? "Response" : "Request", seqno, msg);
+ ast_debug(1, "Stopping retransmission on '%s' of %s %d: Match %s\n",
+ p->callid, resp ? "Response" : "Request", seqno, msg);
}
/*! \brief Pretend to ack all packets
(ast_test_flag(cur, FLAG_RESPONSE) || method_match(sipmethod, cur->data))) {
/* this is our baby */
if (cur->retransid > -1) {
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
+ if (sipdebug)
+ ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
ast_sched_del(sched, cur->retransid);
cur->retransid = -1;
}
break;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
+ ast_debug(1, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
return res;
}
ast_string_field_build(p, url, "<%s>;mode=active", data);
- if (sip_debug_test_pvt(p) && option_debug)
- ast_log(LOG_DEBUG, "Send URL %s, state = %d!\n", data, chan->_state);
+ if (sip_debug_test_pvt(p))
+ ast_debug(1, "Send URL %s, state = %d!\n", data, chan->_state);
switch (chan->_state) {
case AST_STATE_RING:
/*! \brief Destroy peer object from memory */
static void sip_destroy_peer(struct sip_peer *peer)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
+ ast_debug(3, "Destroying SIP peer %s\n", peer->name);
if (peer->outboundproxy)
ast_free(peer->outboundproxy);
apeerobjs--;
else if (ast_test_flag(&peer->flags[0], SIP_REALTIME)) {
rpeerobjs--;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
+ ast_debug(3,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
} else
speerobjs--;
clear_realm_authentication(peer->auth);
return NULL;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
+ ast_debug(3,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
/* Cache peer */
/*! \brief Remove user object from in-memory storage */
static void sip_destroy_user(struct sip_user *user)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying user object from memory: %s\n", user->name);
+ ast_debug(3, "Destroying user object from memory: %s\n", user->name);
ast_free_ha(user->ha);
if (user->chanvars) {
ast_variables_destroy(user->chanvars);
const char *mode = natflags ? "On" : "Off";
if (p->rtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on RTP to %s\n", mode);
ast_rtp_setnat(p->rtp, natflags);
}
if (p->vrtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on VRTP to %s\n", mode);
ast_rtp_setnat(p->vrtp, natflags);
}
if (p->udptl) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", mode);
+ ast_debug(1, "Setting NAT on UDPTL to %s\n", mode);
ast_udptl_setnat(p->udptl, natflags);
}
if (p->trtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on TRTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on TRTP to %s\n", mode);
ast_rtp_setnat(p->trtp, natflags);
}
}
else if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_NONE )
dialog->t38.capability |= T38FAX_UDP_EC_NONE;
dialog->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"Our T38 capability (%d)\n", dialog->t38.capability);
+ ast_debug(2,"Our T38 capability (%d)\n", dialog->t38.capability);
}
dialog->t38.jointcapability = dialog->t38.capability;
} else if (dialog->udptl) {
p->options->replaces = ast_var_value(current);
} else if (!strcasecmp(ast_var_name(current), "T38CALL")) {
p->t38.state = T38_LOCAL_DIRECT;
- if (option_debug)
- ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(1,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
}
}
char buf[BUFSIZ/2];
if (referer) {
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "Call for %s transfered by %s\n", p->username, referer);
+ if (sipdebug)
+ ast_debug(3, "Call for %s transfered by %s\n", p->username, referer);
snprintf(buf, sizeof(buf)-1, "-> %s (via %s)", p->cid_name, referer);
} else
snprintf(buf, sizeof(buf)-1, "-> %s", p->cid_name);
ast_string_field_set(p, cid_name, buf);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username);
+ ast_debug(1, "Outgoing Call for %s\n", p->username);
res = update_call_counter(p, INC_CALL_RINGING);
int xmitres;
p->t38.jointcapability = p->t38.capability;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
+ ast_debug(2,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
xmitres = transmit_invite(p, SIP_INVITE, 1, 2);
if (xmitres == XMIT_ERROR)
return -1;
static void sip_registry_destroy(struct sip_registry *reg)
{
/* Really delete */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
+ ast_debug(3, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
if (reg->call) {
/* Clear registry before destroying to ensure
we don't get reentered trying to grab the registry lock */
reg->call->registry = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
sip_destroy(reg->call);
}
if (reg->expire > -1)
struct sip_pvt *cur, *prev = NULL;
struct sip_pkt *cp;
- if (sip_debug_test_pvt(p) || option_debug > 2)
+ if (sip_debug_test_pvt(p))
ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
update_call_counter(p, DEC_CALL_LIMIT);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
+ ast_debug(2, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
}
/* Remove link from peer to subscription of MWI */
if (p->owner) {
if (lockowner)
ast_channel_lock(p->owner);
- if (option_debug)
- ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
+ ast_debug(1, "Detaching from %s\n", p->owner->name);
p->owner->tech_pvt = NULL;
if (lockowner)
ast_channel_unlock(p->owner);
struct sip_user *u = NULL;
struct sip_peer *p = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
+ ast_debug(3, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
/* Test if we need to check call limits, in order to avoid
realtime lookups if we do not need it */
ast_copy_string(name, fup->peername, sizeof(name));
}
if (!p && !u) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name);
+ ast_debug(2, "%s is not a local device, no call limit\n", name);
return 0;
}
/* Decrement onhold count if applicable */
if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold)
sip_peer_hold(fup, FALSE);
- if (option_debug > 1 || sipdebug)
- ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
+ if (sipdebug)
+ ast_debug(2, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
break;
case INC_CALL_RINGING:
/* Continue */
ast_atomic_fetchadd_int(inuse, +1);
ast_set_flag(&fup->flags[0], SIP_INC_COUNT);
- if (option_debug > 1 || sipdebug) {
- ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
+ if (sipdebug) {
+ ast_debug(2, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
}
break;
/*! \brief Destroy SIP call structure */
static void sip_destroy(struct sip_pvt *p)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP dialog %s\n", p->callid);
+ ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
__sip_destroy(p, TRUE, TRUE);
}
case AST_CAUSE_NOTDEFINED:
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
+ ast_debug(1, "AST hangup cause %d (no match found in SIP)\n", cause);
return NULL;
}
struct ast_channel *oldowner = ast;
if (!p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
+ ast_debug(1, "Asked to hangup channel that was not connected\n");
return 0;
}
if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+ if (sipdebug)
+ ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
}
- if (option_debug >3)
- ast_log(LOG_DEBUG, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
+ ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
if (p->autokillid > -1)
sip_cancel_destroy(p);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
p->owner = NULL; /* Owner will be gone after we return, so take it away */
return 0;
}
- if (option_debug) {
- if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer && option_debug)
- ast_log(LOG_DEBUG, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
- }
- }
- if (option_debug && ast_test_flag(ast, AST_FLAG_ZOMBIE))
- ast_log(LOG_DEBUG, "Hanging up zombie call. Be scared.\n");
+ if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer)
+ ast_debug(1, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
+ else
+ ast_debug(1, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
+
+ if (ast_test_flag(ast, AST_FLAG_ZOMBIE))
+ ast_debug(1, "Hanging up zombie call. Be scared.\n");
sip_pvt_lock(p);
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+ if (sipdebug)
+ ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
}
/* In case of re-invites, the call might be UP even though we have an incomplete invite transaction */
if (p->invitestate < INV_COMPLETED && p->owner->_state != AST_STATE_UP) {
needcancel = TRUE;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
+ ast_debug(4, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
}
stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
try_suggested_sip_codec(p);
ast_setstate(ast, AST_STATE_UP);
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP answering channel: %s\n", ast->name);
+ ast_debug(1, "SIP answering channel: %s\n", ast->name);
if (p->t38.state == T38_PEER_DIRECT) {
p->t38.state = T38_ENABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(2,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
res = transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
} else
res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
int ret = -1;
struct sip_pvt *p;
- if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE) && option_debug)
- ast_log(LOG_DEBUG, "New channel is zombie\n");
- if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE) && option_debug)
- ast_log(LOG_DEBUG, "Old channel is zombie\n");
+ if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE))
+ ast_debug(1, "New channel is zombie\n");
+ if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE))
+ ast_debug(1, "Old channel is zombie\n");
if (!newchan || !newchan->tech_pvt) {
if (!newchan)
p->owner = newchan;
ret = 0;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
+ ast_debug(3, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
sip_pvt_unlock(p);
return ret;
/* Set the native formats for audio and merge in video */
tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | video | text;
- if (option_debug > 2) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, tmp->nativeformats));
- ast_log(LOG_DEBUG, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->jointcapability));
- ast_log(LOG_DEBUG, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->capability));
- ast_log(LOG_DEBUG, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, ast_codec_choose(&i->prefs, what, 1)));
- if (i->prefcodec)
- ast_log(LOG_DEBUG, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->prefcodec));
- }
+ char buf[BUFSIZ];
+ ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, tmp->nativeformats));
+ ast_debug(3, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->jointcapability));
+ ast_debug(3, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->capability));
+ ast_debug(3, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, ast_codec_choose(&i->prefs, what, 1)));
+ if (i->prefcodec)
+ ast_debug(3, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->prefcodec));
/* XXX Why are we choosing a codec from the native formats?? */
fmt = ast_best_codec(tmp->nativeformats);
needtext = i->jointcapability & AST_FORMAT_TEXT_MASK; /* Inbound call */
}
- if (option_debug > 2) {
- if (needvideo)
- ast_log(LOG_DEBUG, "This channel can handle video! HOLLYWOOD next!\n");
- else
- ast_log(LOG_DEBUG, "This channel will not be able to handle video.\n");
- }
+ if (needvideo)
+ ast_debug(3, "This channel can handle video! HOLLYWOOD next!\n");
+ else
+ ast_debug(3, "This channel will not be able to handle video.\n");
if (f && f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
if (!(f->subclass & p->jointcapability)) {
- if (option_debug) {
- ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
- ast_getformatname(f->subclass), p->owner->name);
- }
+ ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
+ ast_getformatname(f->subclass), p->owner->name);
return &ast_null_frame;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
f = ast_dsp_process(p->owner, p->vad, f);
if (f && f->frametype == AST_FRAME_DTMF) {
if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+ ast_debug(1, "Fax CNG detected on %s\n", ast->name);
*faxdetect = 1;
- } else if (option_debug) {
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ } else {
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
}
}
}
if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
+ ast_debug(3, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
p->t38.state = T38_LOCAL_REINVITE;
transmit_reinvite_with_sdp(p, TRUE);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
}
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
+ ast_debug(3, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
p->next = dialoglist;
dialoglist = p;
dialoglist_unlock();
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
+ ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
return p;
}
tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
- if (option_debug > 4 )
- ast_log(LOG_DEBUG, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
+ ast_debug(5, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
/* All messages must always have From: tag */
if (ast_strlen_zero(fromtag)) {
- if (option_debug > 4 )
- ast_log(LOG_DEBUG, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+ ast_debug(5, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
return NULL;
}
/* reject requests that must always have a To: tag */
if (ast_strlen_zero(totag) && (req->method == SIP_ACK || req->method == SIP_BYE || req->method == SIP_INFO )) {
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+ ast_debug(5, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
return NULL;
}
}
found = (!strcmp(p->callid, callid) &&
(!pedanticsipchecking || !tag || ast_strlen_zero(p->theirtag) || !strcmp(p->theirtag, tag))) ;
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
+ ast_debug(5, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
/* If we get a new request within an existing to-tag - check the to tag as well */
if (pedanticsipchecking && found && req->method != SIP_RESPONSE) { /* SIP Request */
found = FALSE; /* This is not our packet */
}
}
- if (!found && option_debug > 4)
- ast_log(LOG_DEBUG, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, totag, sip_methods[req->method].text);
+ if (!found)
+ ast_debug(5, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, totag, sip_methods[req->method].text);
}
Sorry, we apologize for the inconvienience
*/
transmit_response_using_temp(callid, sin, 1, intended_method, req, "500 Server internal error");
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
+ ast_debug(4, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
}
}
return p;
} else if( sip_methods[intended_method].can_create == CAN_CREATE_DIALOG_UNSUPPORTED_METHOD) {
/* A method we do not support, let's take it on the volley */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "501 Method Not Implemented");
- if (option_debug > 1 )
- ast_log(LOG_DEBUG, "Got a request with unsupported SIP method.\n");
+ ast_debug(2, "Got a request with unsupported SIP method.\n");
} else if (intended_method != SIP_RESPONSE && intended_method != SIP_ACK) {
/* This is a request outside of a dialog that we don't know about */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "481 Call leg/transaction does not exist");
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
+ ast_debug(2, "That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
}
/* We do not respond to responses for dialogs that we don't know about, we just drop
the session quickly */
- if (option_debug > 1 && intended_method == SIP_RESPONSE)
- ast_log(LOG_DEBUG, "That's odd... Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
+ if (intended_method == SIP_RESPONSE)
+ ast_debug(2, "That's odd... Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
return p;
}
*c = '\0';
else if (*c == '\n') { /* end of this line */
*c = '\0';
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+ if (sipdebug)
+ ast_debug(4, "%7s %2d [%3d]: %s\n",
req->headers < 0 ? "Header" : "Body",
i, (int)strlen(dst[i]), dst[i]);
if (ast_strlen_zero(dst[i]) && req->headers < 0) {
but since some devices send without, we'll be generous in what we accept.
*/
if (!ast_strlen_zero(dst[i])) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+ if (sipdebug)
+ ast_debug(4, "%7s %2d [%3d]: %s\n",
req->headers < 0 ? "Header" : "Body",
i, (int)strlen(dst[i]), dst[i]);
i++;
if (p->owner && p->lastinvite) {
p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
} else {
p->t38.state = T38_PEER_DIRECT; /* T38 Offered directly from peer in first invite */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else
ast_log(LOG_WARNING, "Unsupported SDP media type in offer: %s\n", m);
sin.sin_port = htons(udptlportno);
ast_udptl_set_peer(p->udptl, &sin);
if (debug)
- ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ ast_debug(1,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
ast_udptl_stop(p->udptl);
if (debug)
- ast_log(LOG_DEBUG, "Peer doesn't provide T.38 UDPTL\n");
+ ast_debug(1, "Peer doesn't provide T.38 UDPTL\n");
}
}
framing = strtol(tmp, NULL, 10);
if (framing == LONG_MIN || framing == LONG_MAX) {
framing = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
+ ast_debug(1, "Can't read framing from SDP: %s\n", a);
}
}
if (framing && last_rtpmap_codec) {
format = ast_rtp_codec_getformat(found_rtpmap_codecs[codec_n]);
if (!format) /* non-codec or not found */
continue;
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format, framing);
+ ast_debug(1, "Setting framing for %d to %ld\n", format, framing);
ast_codec_pref_setsize(pref, format, framing);
}
ast_rtp_codec_setpref(p->rtp, pref);
while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "MaxBufferSize:%d\n",x);
+ ast_debug(3, "MaxBufferSize:%d\n",x);
} else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"T38MaxBitRate: %d\n",x);
+ ast_debug(3,"T38MaxBitRate: %d\n",x);
switch (x) {
case 14400:
peert38capability |= T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
}
} else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FaxVersion: %d\n",x);
+ ast_debug(3, "FaxVersion: %d\n",x);
if (x == 0)
peert38capability |= T38FAX_VERSION_0;
else if (x == 1)
peert38capability |= T38FAX_VERSION_1;
} else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FaxMaxDatagram: %d\n",x);
+ ast_debug(3, "FaxMaxDatagram: %d\n",x);
ast_udptl_set_far_max_datagram(p->udptl, x);
ast_udptl_set_local_max_datagram(p->udptl, x);
} else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
+ ast_debug(3, "FillBitRemoval: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_FILL_BIT_REMOVAL;
} else if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
+ ast_debug(3, "Transcoding MMR: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_MMR;
}
if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
+ ast_debug(3, "Transcoding JBIG: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_JBIG;
} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "RateManagement: %s\n", s);
+ ast_debug(3, "RateManagement: %s\n", s);
if (!strcasecmp(s, "localTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
else if (!strcasecmp(s, "transferredTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
} else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "UDP EC: %s\n", s);
+ ast_debug(3, "UDP EC: %s\n", s);
if (!strcasecmp(s, "t38UDPRedundancy")) {
peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
p->t38.jointcapability |= (peert38capability & p->t38.capability); /* Put the lower of our's and peer's speed */
}
if (debug)
- ast_log(LOG_DEBUG, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
+ ast_debug(1, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
} else {
p->t38.state = T38_DISABLED;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(3, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
/* Now gather all of the codecs that we are asked for: */
/* Do NOT Change current setting */
return -1;
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Have T.38 but no audio codecs, accepting offer anyway\n");
+ ast_debug(3, "Have T.38 but no audio codecs, accepting offer anyway\n");
return 0;
}
}
}
/* Ok, we're going with this offer */
- if (option_debug > 1) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "We're settling with these formats: %s\n", ast_getformatname_multiple(buf, BUFSIZ, p->jointcapability));
- }
+ char buf[BUFSIZ];
+ ast_debug(2, "We're settling with these formats: %s\n", ast_getformatname_multiple(buf, BUFSIZ, p->jointcapability));
if (!p->owner) /* There's no open channel owning us so we can return here. For a re-invite or so, we proceed */
return 0;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "We have an owner, now see if we need to change this call\n");
+ ast_debug(4, "We have an owner, now see if we need to change this call\n");
if (!(p->owner->nativeformats & p->jointcapability) && (p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
if (debug) {
char s1[BUFSIZ], s2[BUFSIZ];
- ast_log(LOG_DEBUG, "Oooh, we need to change our audio formats since our peer supports only %s and not %s\n",
+ ast_debug(1, "Oooh, we need to change our audio formats since our peer supports only %s and not %s\n",
ast_getformatname_multiple(s1, BUFSIZ, p->jointcapability),
ast_getformatname_multiple(s2, BUFSIZ, p->owner->nativeformats));
}
if (p->route && !ast_strlen_zero(p->route->hop) && strstr(p->route->hop,";lr") == NULL) {
is_strict = TRUE;
if (sipdebug)
- ast_log(LOG_DEBUG, "Strict routing enforced for session %s\n", p->callid);
+ ast_debug(1, "Strict routing enforced for session %s\n", p->callid);
}
if (sipmethod == SIP_CANCEL)
int maxrate = (t38cap & (T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400));
if (maxrate & T38FAX_RATE_14400) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 14400 found\n");
+ ast_debug(2, "T38MaxFaxRate 14400 found\n");
return 14400;
} else if (maxrate & T38FAX_RATE_12000) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 12000 found\n");
+ ast_debug(2, "T38MaxFaxRate 12000 found\n");
return 12000;
} else if (maxrate & T38FAX_RATE_9600) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 9600 found\n");
+ ast_debug(2, "T38MaxFaxRate 9600 found\n");
return 9600;
} else if (maxrate & T38FAX_RATE_7200) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 7200 found\n");
+ ast_debug(2, "T38MaxFaxRate 7200 found\n");
return 7200;
} else if (maxrate & T38FAX_RATE_4800) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 4800 found\n");
+ ast_debug(2, "T38MaxFaxRate 4800 found\n");
return 4800;
} else if (maxrate & T38FAX_RATE_2400) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 2400 found\n");
+ ast_debug(2, "T38MaxFaxRate 2400 found\n");
return 2400;
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
+ ast_debug(2, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
return 0;
}
}
}
if (debug)
- ast_log(LOG_DEBUG, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
+ ast_debug(1, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
/* We break with the "recommendation" and send our IP, in order that our
peer doesn't have to ast_gethostbyname() us */
if (debug) {
- ast_log(LOG_DEBUG, "Our T38 capability (%d), peer T38 capability (%d), joint capability (%d)\n",
+ ast_debug(1, "Our T38 capability (%d), peer T38 capability (%d), joint capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
capability = p->jointcapability;
- if (option_debug > 1) {
- char codecbuf[BUFSIZ];
- ast_log(LOG_DEBUG, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
- ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
- ast_log(LOG_DEBUG, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
- }
+ char codecbuf[BUFSIZ];
+ ast_debug(1, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
+ ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
+ ast_debug(1, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_RTP)) {
if ((capability & AST_FORMAT_VIDEO_MASK) && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
if (p->vrtp) {
needvideo = TRUE;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs video offers!\n");
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs video offers, but there's no video support enabled!\n");
+ ast_debug(2, "This call needs video offers!\n");
+ } else
+ ast_debug(2, "This call needs video offers, but there's no video support enabled!\n");
}
/* Get our media addresses */
if (p->trtp) {
if (sipdebug_text) ast_verbose("And we have a text rtp object\n");
needtext = TRUE;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs text offers! \n");
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs text offers, but there's no text support enabled ! \n");
+ ast_debug(2, "This call needs text offers! \n");
+ } else
+ ast_debug(2, "This call needs text offers, but there's no text support enabled ! \n");
}
/* Ok, we need text. Let's add what we need for text and set codecs.
debug);
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-- Done with adding codecs to SDP\n");
+ ast_debug(3, "-- Done with adding codecs to SDP\n");
if (!p->owner || !ast_internal_timing_enabled(p->owner))
ast_build_string(&a_audio_next, &a_audio_left, "a=silenceSupp:off - - - -\r\n");
/* Update lastrtprx when we send our SDP */
p->lastrtprx = p->lastrtptx = time(NULL); /* XXX why both ? */
- if (option_debug > 2) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, BUFSIZ, capability));
- }
+ char buf[BUFSIZ];
+ ast_debug(3, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, BUFSIZ, capability));
return AST_SUCCESS;
}
respprep(&resp, p, msg, req);
if (p->rtp) {
if (!p->autoframing && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing from config on incoming call\n");
+ ast_debug(1, "Setting framing from config on incoming call\n");
ast_rtp_codec_setpref(p->rtp, &p->prefs);
}
try_suggested_sip_codec(p);
add_header(&req, headdup, content);
if (sipdebug)
- ast_log(LOG_DEBUG, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
+ ast_debug(1, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
}
}
}
if (sdp) {
if (p->udptl && p->t38.state == T38_LOCAL_DIRECT) {
ast_udptl_offered_from_local(p->udptl, 1);
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
add_t38_sdp(&req, p);
} else if (p->rtp)
add_sdp(&req, p);
ast_sched_del(sched, r->timeout);
}
r->timeout = ast_sched_add(sched, global_reg_timeout * 1000, sip_reg_timeout, r);
- if (option_debug)
- ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
+ ast_debug(1, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
}
if (strchr(r->username, '@')) {
/* We have auth data to reuse, build a digest header! */
if (sipdebug)
- ast_log(LOG_DEBUG, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
+ ast_debug(1, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
ast_string_field_set(p, realm, r->realm);
ast_string_field_set(p, nonce, r->nonce);
ast_string_field_set(p, domain, r->domain);
char *ttag, *ftag;
char *theirtag = ast_strdupa(p->theirtag);
- if (option_debug || sipdebug)
- ast_log(LOG_DEBUG, "SIP transfer of %s to %s\n", p->callid, dest);
+ if (sipdebug)
+ ast_debug(1, "SIP transfer of %s to %s\n", p->callid, dest);
/* Are we transfering an inbound or outbound call ? */
if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
/* Do we need to release this peer from memory?
Only for realtime peers and autocreated peers
*/
- if (option_debug > 2 && ast_test_flag(&peer->flags[0], SIP_REALTIME))
- ast_log(LOG_DEBUG,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
+ if (ast_test_flag(&peer->flags[0], SIP_REALTIME))
+ ast_debug(3,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT) ||
ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
if (contact)
ast_copy_string(peer->fullcontact, contact, sizeof(peer->fullcontact));
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
- peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
+ ast_debug(2, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
+ peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
memset(&peer->addr, 0, sizeof(peer->addr));
peer->addr.sin_family = AF_INET;
/* Once a persistant route is set, don't fool with it */
if (p->route && p->route_persistant) {
- if (option_debug)
- ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
+ ast_debug(1, "build_route: Retaining previous route: <%s>\n", p->route->hop);
return;
}
if ((thishop = ast_malloc(sizeof(*thishop) + len))) {
/* ast_calloc is not needed because all fields are initialized in this block */
ast_copy_string(thishop->hop, rr, len);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "build_route: Record-Route hop: <%s>\n", thishop->hop);
+ ast_debug(2, "build_route: Record-Route hop: <%s>\n", thishop->hop);
/* Link in */
if (backwards) {
/* Link in at head so they end up in reverse order */
/* Can be multiple Contact headers, comma separated values - we just take the first */
contact = get_header(req, "Contact");
if (!ast_strlen_zero(contact)) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact);
+ ast_debug(2, "build_route: Contact hop: %s\n", contact);
/* Look for <: delimited address */
c = strchr(contact, '<');
if (c) {
domain_context[0] = '\0';
if (!check_sip_domain(p->domain, domain_context, sizeof(domain_context))) {
if (!allow_external_domains && (req->method == SIP_INVITE || req->method == SIP_REFER)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
+ ast_debug(1, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
return -2;
}
}
struct sip_pvt *sip_pvt_ptr;
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
+ if (totag)
+ ast_debug(4, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
/* Search dialogs and find the match */
dialoglist_lock();
continue;
}
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n",
+ if (totag)
+ ast_debug(4, "Matched %s call - their tag is %s Our tag is %s\n",
ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
}
}
dialoglist_unlock();
- if (option_debug > 3 && !sip_pvt_ptr)
- ast_log(LOG_DEBUG, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
+ if (!sip_pvt_ptr)
+ ast_debug(4, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
return sip_pvt_ptr;
}
ast_copy_string(referdata->replaces_callid_fromtag, ptr, sizeof(referdata->replaces_callid_fromtag));
}
- if (option_debug > 1) {
- if (!pedanticsipchecking)
- ast_log(LOG_DEBUG,"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", referdata->replaces_callid );
- else
- ast_log(LOG_DEBUG,"Attended transfer: Will use Replace-Call-ID : %s F-tag: %s T-tag: %s\n", referdata->replaces_callid, referdata->replaces_callid_fromtag ? referdata->replaces_callid_fromtag : "<none>", referdata->replaces_callid_totag ? referdata->replaces_callid_totag : "<none>" );
- }
+ if (!pedanticsipchecking)
+ ast_debug(2,"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", referdata->replaces_callid );
+ else
+ ast_debug(2,"Attended transfer: Will use Replace-Call-ID : %s F-tag: %s T-tag: %s\n", referdata->replaces_callid, referdata->replaces_callid_fromtag ? referdata->replaces_callid_fromtag : "<none>", referdata->replaces_callid_totag ? referdata->replaces_callid_totag : "<none>" );
}
}
}
if (ast_exists_extension(NULL, transfer_context, c, 1, NULL)) {
/* This is a blind transfer */
- if (option_debug)
- ast_log(LOG_DEBUG,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
+ ast_debug(1,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
ast_copy_string(referdata->refer_to, c, sizeof(referdata->refer_to));
ast_copy_string(referdata->referred_by, "", sizeof(referdata->referred_by));
ast_copy_string(referdata->refer_contact, "", sizeof(referdata->refer_contact));
return;
}
- ast_log(LOG_DEBUG, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
+ ast_debug(1, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
if (dialog->subscribed)
- ast_log(LOG_DEBUG, " * Subscription\n");
+ ast_debug(1, " * Subscription\n");
else
- ast_log(LOG_DEBUG, " * SIP Call\n");
+ ast_debug(1, " * SIP Call\n");
if (dialog->history)
AST_LIST_TRAVERSE(dialog->history, hist, list)
- ast_log(LOG_DEBUG, " %-3.3d. %s\n", ++x, hist->event);
+ ast_debug(1, " %-3.3d. %s\n", ++x, hist->event);
if (!x)
- ast_log(LOG_DEBUG, "Call '%s' has no history\n", dialog->callid);
- ast_log(LOG_DEBUG, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
+ ast_debug(1, "Call '%s' has no history\n", dialog->callid);
+ ast_debug(1, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
}
}
ast_unlock_call_features();
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a Request to Record the channel, state %s\n", c);
+ ast_debug(1, "Got a Request to Record the channel, state %s\n", c);
transmit_response(p, "200 OK", req);
return;
}
p->authtries++;
auth_headers(code, &header, &respheader);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Auth attempt %d on %s\n", p->authtries, sip_methods[sipmethod].text);
+ ast_debug(2, "Auth attempt %d on %s\n", p->authtries, sip_methods[sipmethod].text);
memset(digest, 0, sizeof(digest));
if (reply_digest(p, req, header, sipmethod, digest, sizeof(digest) )) {
/* No way to authenticate */
secret = auth->secret;
md5secret = auth->md5secret;
if (sipdebug)
- ast_log(LOG_DEBUG,"Using realm %s authentication for call %s\n", p->realm, p->callid);
+ ast_debug(1,"Using realm %s authentication for call %s\n", p->realm, p->callid);
} else {
/* No authentication, use peer or register= config */
username = p->authname;
e = strchr(s, '/');
if (e)
*e = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
+ ast_debug(2, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
e = strchr(s, ';'); /* And username ; parameters? */
if (e)
*e = '\0';
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain);
+ ast_debug(2, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain);
if (p->owner) {
pbx_builtin_setvar_helper(p->owner, "SIPDOMAIN", domain);
ast_string_field_set(p->owner, call_forward, s);
ast_clear_flag(&p->flags[0], SIP_PENDINGBYE);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else if (ast_test_flag(&p->flags[0], SIP_NEEDREINVITE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending pending reinvite on '%s'\n", p->callid);
+ ast_debug(2, "Sending pending reinvite on '%s'\n", p->callid);
/* Didn't get to reinvite yet, so do it now */
transmit_reinvite_with_sdp(p, FALSE);
ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);
int reinvite = (p->owner && p->owner->_state == AST_STATE_UP);
struct ast_channel *bridgepeer = NULL;
- if (option_debug > 3) {
- if (reinvite)
- ast_log(LOG_DEBUG, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
- else
- ast_log(LOG_DEBUG, "SIP response %d to standard invite\n", resp);
- }
+ if (reinvite)
+ ast_debug(4, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
+ else
+ ast_debug(4, "SIP response %d to standard invite\n", resp);
if (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
+ ast_debug(1, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
return;
}
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange... The other side of the bridge does not have a udptl struct\n");
+ ast_debug(2, "Strange... The other side of the bridge does not have a udptl struct\n");
sip_pvt_lock(bridgepvt);
bridgepvt->t38.state = T38_DISABLED;
sip_pvt_unlock(bridgepvt);
- if (option_debug)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->tech->type);
+ ast_debug(1,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->tech->type);
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else {
/* Other side is not a SIP channel */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange... The other side of the bridge is not a SIP channel\n");
+ ast_debug(2, "Strange... The other side of the bridge is not a SIP channel\n");
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
}
if ((p->t38.state == T38_LOCAL_REINVITE) || (p->t38.state == T38_LOCAL_DIRECT)) {
/* If there was T38 reinvite and we are supposed to answer with 200 OK than this should set us to T38 negotiated mode */
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
/* The transferee is now sending INVITE to target */
p->refer->status = REFER_ACCEPTED;
/* Now wait for next message */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Got 202 accepted on transfer\n");
+ ast_debug(3, "Got 202 accepted on transfer\n");
/* We should hang along, waiting for NOTIFY's here */
break;
r->regtime = time(NULL); /* Reset time of last succesful registration */
manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
r->regattempts = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Registration successful\n");
+ ast_debug(1, "Registration successful\n");
if (r->timeout > -1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
+ ast_debug(1, "Cancelling timeout %d\n", r->timeout);
ast_sched_del(sched, r->timeout);
}
r->timeout=-1;
if (!p->refer) {
ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name);
ast_queue_hangup(p->owner);
- } else if (option_debug > 3)
- ast_log(LOG_DEBUG, "Got OK on REFER Notify message\n");
+ } else
+ ast_debug(4, "Got OK on REFER Notify message\n");
} else {
if (p->subscribed == NONE)
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
res = handle_response_register(p, resp, rest, req, seqno);
else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got timeout on bye. Thanks for the answer. Now, kill this call\n");
+ ast_debug(4, "Got timeout on bye. Thanks for the answer. Now, kill this call\n");
} else {
if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
if (sipmethod == SIP_INVITE)
handle_response_invite(p, resp, rest, req, seqno);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
+ ast_debug(1, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
}
break;
is yet another failure of not having a layer 2 (again, YAY
IETF for thinking ahead). So we treat this as a call
forward and hope we end up at the right place... */
- if (option_debug)
- ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
+ ast_debug(1, "Hairpin detected, setting up call forward for what it's worth\n");
if (p->owner)
ast_string_field_build(p->owner, call_forward,
"Local/%s@%s", p->username, p->context);
if (sipmethod == SIP_INVITE) {
handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_CANCEL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
+ ast_debug(1, "Got 200 OK on CANCEL\n");
/* Wait for 487, then destroy */
} else if (sipmethod == SIP_NOTIFY) {
/* They got the notify, this is the end */
if (p->owner) {
if (p->refer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 200 OK on NOTIFY for transfer\n");
+ ast_debug(1, "Got 200 OK on NOTIFY for transfer\n");
} else
ast_log(LOG_WARNING, "Notify answer on an owned channel?\n");
/* ast_queue_hangup(p->owner); Disabled */
} else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
} else if (sipdebug) {
- ast_log (LOG_DEBUG, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
+ ast_debug(1, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
}
break;
case 501: /* Not Implemented */
ast_log(LOG_ERROR, "Missing channels for parking! Transferer %s Transferee %s\n", transferer ? "<available>" : "<missing>", transferee ? "<available>" : "<missing>" );
return NULL;
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name);
+ ast_debug(4, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name);
ast_channel_lock(transferee);
if (ast_do_masquerade(transferee)) {
transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "200 OK", TRUE);
transferer->hangupcause = AST_CAUSE_NORMAL_CLEARING;
ast_hangup(transferer); /* This will cause a BYE */
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP Call parked on extension '%d'\n", ext);
+ ast_debug(1, "SIP Call parked on extension '%d'\n", ext);
} else {
transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "503 Service Unavailable", TRUE);
append_history(transferer->tech_pvt, "SIPpark","Parking failed\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP Call parked failed \n");
+ ast_debug(1, "SIP Call parked failed \n");
/* Do not hangup call */
}
return NULL;
ast_channel_unlock(transferer);
if (!transferer || !transferee) {
if (!transferer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
+ ast_debug(1, "No transferer channel, giving up parking\n");
}
if (!transferee) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ ast_debug(1, "No transferee channel, giving up parking\n");
}
return -1;
}
/* We will try to connect the transferee with the target and hangup
all channels to the transferer */
- if (option_debug > 3) {
- ast_log(LOG_DEBUG, "Sip transfer:--------------------\n");
- if (transferer->chan1)
- ast_log(LOG_DEBUG, "-- Transferer to PBX channel: %s State %s\n", transferer->chan1->name, ast_state2str(transferer->chan1->_state));
- else
- ast_log(LOG_DEBUG, "-- No transferer first channel - odd??? \n");
- if (target->chan1)
- ast_log(LOG_DEBUG, "-- Transferer to PBX second channel (target): %s State %s\n", target->chan1->name, ast_state2str(target->chan1->_state));
- else
- ast_log(LOG_DEBUG, "-- No target first channel ---\n");
- if (transferer->chan2)
- ast_log(LOG_DEBUG, "-- Bridged call to transferee: %s State %s\n", transferer->chan2->name, ast_state2str(transferer->chan2->_state));
- else
- ast_log(LOG_DEBUG, "-- No bridged call to transferee\n");
- if (target->chan2)
- ast_log(LOG_DEBUG, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? target->chan2->name : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
- else
- ast_log(LOG_DEBUG, "-- No target second channel ---\n");
- ast_log(LOG_DEBUG, "-- END Sip transfer:--------------------\n");
- }
+ ast_debug(4, "Sip transfer:--------------------\n");
+ if (transferer->chan1)
+ ast_debug(4, "-- Transferer to PBX channel: %s State %s\n", transferer->chan1->name, ast_state2str(transferer->chan1->_state));
+ else
+ ast_debug(4, "-- No transferer first channel - odd??? \n");
+ if (target->chan1)
+ ast_debug(4, "-- Transferer to PBX second channel (target): %s State %s\n", target->chan1->name, ast_state2str(target->chan1->_state));
+ else
+ ast_debug(4, "-- No target first channel ---\n");
+ if (transferer->chan2)
+ ast_debug(4, "-- Bridged call to transferee: %s State %s\n", transferer->chan2->name, ast_state2str(transferer->chan2->_state));
+ else
+ ast_debug(4, "-- No bridged call to transferee\n");
+ if (target->chan2)
+ ast_debug(4, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? target->chan2->name : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
+ else
+ ast_debug(4, "-- No target second channel ---\n");
+ ast_debug(4, "-- END Sip transfer:--------------------\n");
if (transferer->chan2) { /* We have a bridge on the transferer's channel */
peera = transferer->chan1; /* Transferer - PBX -> transferee channel * the one we hangup */
peerb = target->chan1; /* Transferer - PBX -> target channel - This will get lost in masq */
peerc = transferer->chan2; /* Asterisk to Transferee */
peerd = target->chan2; /* Asterisk to Target */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP transfer: Four channels to handle\n");
+ ast_debug(3, "SIP transfer: Four channels to handle\n");
} else if (target->chan2) { /* Transferer has no bridge (IVR), but transferee */
peera = target->chan1; /* Transferer to PBX -> target channel */
peerb = transferer->chan1; /* Transferer to IVR*/
peerc = target->chan2; /* Asterisk to Target */
peerd = transferer->chan2; /* Nothing */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP transfer: Three channels to handle\n");
+ ast_debug(3, "SIP transfer: Three channels to handle\n");
}
if (peera && peerb && peerc && (peerb != peerc)) {
peerb->cdr = peerc->cdr;
peerc->cdr = NULL;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
+ ast_debug(4, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
if (ast_channel_masquerade(peerb, peerc)) {
ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name, peerc->name);
res = -1;
} else
- ast_log(LOG_DEBUG, "SIP transfer: Succeeded to masquerade channels.\n");
+ ast_debug(4, "SIP transfer: Succeeded to masquerade channels.\n");
return res;
} else {
ast_log(LOG_NOTICE, "SIP Transfer attempted with no appropriate bridged calls to transfer\n");
eventid = sep;
}
- if (option_debug > 1 && sipdebug)
- ast_log(LOG_DEBUG, "Got NOTIFY Event: %s\n", event);
+ if (sipdebug)
+ ast_debug(2, "Got NOTIFY Event: %s\n", event);
if (strcmp(event, "refer")) {
/* We don't understand this event. */
If there are several REFERs in the same dialog, we need to
match the ID of the event header...
*/
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
+ ast_debug(3, "* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
cmd = ast_skip_blanks(buf);
code = cmd;
/* We are at SIP/2.0 */
if (!(targetcall = ast_bridged_channel(replacecall))) {
/* We have no bridge */
if (!earlyreplace) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, " Attended transfer attempted to replace call with no bridge (maybe ringing). Channel %s!\n", replacecall->name);
+ ast_debug(2, " Attended transfer attempted to replace call with no bridge (maybe ringing). Channel %s!\n", replacecall->name);
oneleggedreplace = 1;
}
}
- if (option_debug > 3 && targetcall && targetcall->_state == AST_STATE_RINGING)
- ast_log(LOG_DEBUG, "SIP transfer: Target channel is in ringing state\n");
+ if (targetcall && targetcall->_state == AST_STATE_RINGING)
+ ast_debug(4, "SIP transfer: Target channel is in ringing state\n");
- if (option_debug > 3) {
- if (targetcall)
- ast_log(LOG_DEBUG, "SIP transfer: Invite Replace incoming channel should bridge to channel %s while hanging up channel %s\n", targetcall->name, replacecall->name);
- else
- ast_log(LOG_DEBUG, "SIP transfer: Invite Replace incoming channel should replace and hang up channel %s (one call leg)\n", replacecall->name);
- }
+ if (targetcall)
+ ast_debug(4, "SIP transfer: Invite Replace incoming channel should bridge to channel %s while hanging up channel %s\n", targetcall->name, replacecall->name);
+ else
+ ast_debug(4, "SIP transfer: Invite Replace incoming channel should replace and hang up channel %s (one call leg)\n", replacecall->name);
if (ast_test_flag(req, SIP_PKT_IGNORE)) {
ast_log(LOG_NOTICE, "Ignoring this INVITE with replaces in a stupid way.\n");
/* Stop music on hold and other generators */
ast_quiet_chan(replacecall);
ast_quiet_chan(targetcall);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replaces: preparing to masquerade %s into %s\n", c->name, replacecall->name);
+ ast_debug(4, "Invite/Replaces: preparing to masquerade %s into %s\n", c->name, replacecall->name);
/* Unlock clone, but not original (replacecall) */
ast_channel_unlock(c);
/* Prepare the masquerade - if this does not happen, we will be gone */
if(ast_channel_masquerade(replacecall, c))
ast_log(LOG_ERROR, "Failed to masquerade C into Replacecall\n");
- else if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replaces: Going to masquerade %s into %s\n", c->name, replacecall->name);
+ else
+ ast_debug(4, "Invite/Replaces: Going to masquerade %s into %s\n", c->name, replacecall->name);
/* The masquerade will happen as soon as someone reads a frame from the channel */
if ((f = ast_read(replacecall))) { /* Force the masq to happen */
ast_frfree(f);
f = NULL;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replace: Could successfully read frame from RING channel!\n");
+ ast_debug(4, "Invite/Replace: Could successfully read frame from RING channel!\n");
} else {
ast_log(LOG_WARNING, "Invite/Replace: Could not read frame from RING channel \n");
}
/* Masq ok */
ast_frfree(f);
f = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Invite/Replace: Could successfully read frame from channel! Masq done.\n");
+ ast_debug(3, "Invite/Replace: Could successfully read frame from channel! Masq done.\n");
} else {
ast_log(LOG_WARNING, "Invite/Replace: Could not read frame from channel. Transfer failed\n");
}
sip_pvt_unlock(p->refer->refer_call);
ast_setstate(c, AST_STATE_DOWN);
- if (option_debug > 3) {
- struct ast_channel *test;
- ast_log(LOG_DEBUG, "After transfer:----------------------------\n");
- ast_log(LOG_DEBUG, " -- C: %s State %s\n", c->name, ast_state2str(c->_state));
- if (replacecall)
- ast_log(LOG_DEBUG, " -- replacecall: %s State %s\n", replacecall->name, ast_state2str(replacecall->_state));
- if (p->owner) {
- ast_log(LOG_DEBUG, " -- P->owner: %s State %s\n", p->owner->name, ast_state2str(p->owner->_state));
- test = ast_bridged_channel(p->owner);
- if (test)
- ast_log(LOG_DEBUG, " -- Call bridged to P->owner: %s State %s\n", test->name, ast_state2str(test->_state));
- else
- ast_log(LOG_DEBUG, " -- No call bridged to C->owner \n");
- } else
- ast_log(LOG_DEBUG, " -- No channel yet \n");
- ast_log(LOG_DEBUG, "End After transfer:----------------------------\n");
- }
+ struct ast_channel *test;
+ ast_debug(4, "After transfer:----------------------------\n");
+ ast_debug(4, " -- C: %s State %s\n", c->name, ast_state2str(c->_state));
+ if (replacecall)
+ ast_debug(4, " -- replacecall: %s State %s\n", replacecall->name, ast_state2str(replacecall->_state));
+ if (p->owner) {
+ ast_debug(4, " -- P->owner: %s State %s\n", p->owner->name, ast_state2str(p->owner->_state));
+ test = ast_bridged_channel(p->owner);
+ if (test)
+ ast_debug(4, " -- Call bridged to P->owner: %s State %s\n", test->name, ast_state2str(test->_state));
+ else
+ ast_debug(4, " -- No call bridged to C->owner \n");
+ } else
+ ast_debug(4, " -- No channel yet \n");
+ ast_debug(4, "End After transfer:----------------------------\n");
ast_channel_unlock(p->owner); /* Unlock new owner */
sip_pvt_unlock(p); /* Unlock SIP structure */
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->pendinginvite) {
/* We already have a pending invite. Sorry. You are on hold. */
transmit_response(p, "491 Request Pending", req);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
+ ast_debug(1, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
/* Don't destroy dialog here */
return 0;
}
int error = 0;
if (p->owner) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
+ ast_debug(3, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
transmit_response(p, "400 Bad request", req); /* The best way to not not accept the transfer */
/* Do not destroy existing call */
return -1;
}
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "INVITE part of call transfer. Replaces [%s]\n", p_replaces);
+ if (sipdebug)
+ ast_debug(3, "INVITE part of call transfer. Replaces [%s]\n", p_replaces);
/* Create a buffer we can manipulate */
replace_id = ast_strdupa(p_replaces);
ast_uri_decode(replace_id);
}
}
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG,"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
+ if (sipdebug)
+ ast_debug(4,"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
/* Try to find call that we are replacing
check_via(p, req);
copy_request(&p->initreq, req); /* Save this INVITE as the transaction basis */
- if (sipdebug && option_debug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
if (!p->owner) { /* Not a re-invite */
if (debug)
ast_verbose("Using INVITE request as basis request - %s\n", p->callid);
}
} else {
p->jointcapability = p->capability;
- if (option_debug)
- ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
+ ast_debug(1, "Hm.... No sdp for the moment\n");
}
if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY)) /* This is a response, note what it was for */
append_history(p, "ReInv", "Re-invite received");
transmit_response_reliable(p, "488 Not acceptable here", req);
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- if (option_debug)
- ast_log(LOG_DEBUG, "No compatible codecs for this SIP call.\n");
+ ast_debug(1, "No compatible codecs for this SIP call.\n");
return -1;
}
} else { /* No SDP in invite, call control session */
p->jointcapability = p->capability;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "No SDP in Invite, third party call control\n");
+ ast_debug(2, "No SDP in Invite, third party call control\n");
}
/* Queue NULL frame to prod ast_rtp_bridge if appropriate */
/* Check number of concurrent calls -vs- incoming limit HERE */
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking SIP call limits for device %s\n", p->username);
+ ast_debug(1, "Checking SIP call limits for device %s\n", p->username);
if ((res = update_call_counter(p, INC_CALL_LIMIT))) {
if (res < 0) {
ast_log(LOG_NOTICE, "Failed to place call for user %s, too many calls\n", p->username);
}
}
} else {
- if (option_debug > 1 && sipdebug) {
+ if (sipdebug) {
if (!ast_test_flag(req, SIP_PKT_IGNORE))
- ast_log(LOG_DEBUG, "Got a SIP re-invite for call %s\n", p->callid);
+ ast_debug(2, "Got a SIP re-invite for call %s\n", p->callid);
else
- ast_log(LOG_DEBUG, "Got a SIP re-transmit of INVITE for call %s\n", p->callid);
+ ast_debug(2, "Got a SIP re-transmit of INVITE for call %s\n", p->callid);
}
reinvite = 1;
c = p->owner;
if (replace_id) { /* Attended transfer or call pickup - we're the target */
/* Go and take over the target call */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Sending this call to the invite/replcaes handler %s\n", p->callid);
+ if (sipdebug)
+ ast_debug(4, "Sending this call to the invite/replcaes handler %s\n", p->callid);
return handle_invite_replaces(p, req, debug, ast_test_flag(req, SIP_PKT_IGNORE), seqno, sin);
}
if (c) { /* We have a call -either a new call or an old one (RE-INVITE) */
switch(c->_state) {
case AST_STATE_DOWN:
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s: New call is still down.... Trying... \n", c->name);
+ ast_debug(2, "%s: New call is still down.... Trying... \n", c->name);
transmit_response(p, "100 Trying", req);
p->invitestate = INV_PROCEEDING;
ast_setstate(c, AST_STATE_RING);
p->invitestate = INV_PROCEEDING;
break;
case AST_STATE_UP:
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s: This call is UP.... \n", c->name);
+ ast_debug(2, "%s: This call is UP.... \n", c->name);
if (p->t38.state == T38_PEER_REINVITE) {
struct ast_channel *bridgepeer = NULL;
sip_pvt_lock(bridgepvt);
bridgepvt->t38.state = T38_DISABLED;
sip_pvt_unlock(bridgepvt);
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
+ ast_debug(2,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
if (ast_test_flag(req, SIP_PKT_IGNORE))
transmit_response(p, "488 Not acceptable here", req);
else
/* The other side is already setup for T.38 most likely so we need to acknowledge this too */
transmit_response_with_t38_sdp(p, "200 OK", req, XMIT_CRITICAL);
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else {
/* Other side is not a SIP channel */
else
transmit_response_reliable(p, "488 Not acceptable here", req);
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
if (!p->lastinvite) /* Only destroy if this is *not* a re-invite */
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
/* we are not bridged in a call */
transmit_response_with_t38_sdp(p, "200 OK", req, XMIT_CRITICAL);
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else if (p->t38.state == T38_DISABLED) { /* Channel doesn't have T38 offered or enabled */
int sendok = TRUE;
return -1;
}
/* Fall through for remote transfers that we did not find locally */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP attended transfer: Not our call - generating INVITE with replaces\n");
+ ast_debug(3, "SIP attended transfer: Not our call - generating INVITE with replaces\n");
return 0;
}
transmit_response(transferer, "202 Accepted", req);
append_history(transferer, "Xfer", "Refer accepted");
if (!targetcall_pvt->owner) { /* No active channel */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: No owner of target call\n");
+ ast_debug(4, "SIP attended transfer: Error: No owner of target call\n");
/* Cancel transfer */
transmit_notify_with_sipfrag(transferer, seqno, "503 Service Unavailable", TRUE);
append_history(transferer, "Xfer", "Refer failed");
if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
/* Wrong state of new channel */
- if (option_debug > 3) {
- if (target.chan2)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
- else if (target.chan1->_state != AST_STATE_RING)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: No target channel\n");
- else
- ast_log(LOG_DEBUG, "SIP attended transfer: Attempting transfer in ringing state\n");
- }
+ if (target.chan2)
+ ast_debug(4, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
+ else if (target.chan1->_state != AST_STATE_RING)
+ ast_debug(4, "SIP attended transfer: Error: No target channel\n");
+ else
+ ast_debug(4, "SIP attended transfer: Attempting transfer in ringing state\n");
}
/* Transfer */
- if (option_debug > 3 && sipdebug) {
+ if (sipdebug) {
if (current->chan2) /* We have two bridges */
- ast_log(LOG_DEBUG, "SIP attended transfer: trying to bridge %s and %s\n", target.chan1->name, current->chan2->name);
+ ast_debug(4, "SIP attended transfer: trying to bridge %s and %s\n", target.chan1->name, current->chan2->name);
else /* One bridge, propably transfer of IVR/voicemail etc */
- ast_log(LOG_DEBUG, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
+ ast_debug(4, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
}
ast_set_flag(&transferer->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Delay hangup */
append_history(transferer, "Xfer", "Refer succeeded");
transferer->refer->status = REFER_200OK;
if (targetcall_pvt->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
+ ast_debug(1, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
ast_channel_unlock(targetcall_pvt->owner);
}
}
if (!p->owner) {
/* This is a REFER outside of an existing SIP dialog */
/* We can't handle that, so decline it */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Call %s: Declined REFER, outside of dialog...\n", p->callid);
+ ast_debug(3, "Call %s: Declined REFER, outside of dialog...\n", p->callid);
transmit_response(p, "603 Declined (No dialog)", req);
if (!ast_test_flag(req, SIP_PKT_IGNORE)) {
append_history(p, "Xfer", "Refer failed. Outside of dialog.");
case -2: /* Syntax error */
transmit_response(p, "400 Bad Request (Refer-to missing)", req);
append_history(p, "Xfer", "Refer failed. Refer-to missing.");
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to black hole can't be handled (no refer-to: )\n");
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to black hole can't be handled (no refer-to: )\n");
break;
case -3:
transmit_response(p, "603 Declined (Non sip: uri)", req);
append_history(p, "Xfer", "Refer failed. Non SIP uri");
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to non-SIP uri denied\n");
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to non-SIP uri denied\n");
break;
default:
/* Refer-to extension not found, fake a failed transfer */
append_history(p, "Xfer", "Refer failed. Bad extension.");
transmit_notify_with_sipfrag(p, seqno, "404 Not found", TRUE);
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to bad extension: %s\n", p->refer->refer_to);
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to bad extension: %s\n", p->refer->refer_to);
break;
}
return 0;
/* If we do not support SIP domains, all transfers are local */
if (allow_external_domains && check_sip_domain(p->refer->refer_to_domain, NULL, 0)) {
p->refer->localtransfer = 1;
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "This SIP transfer is local : %s\n", p->refer->refer_to_domain);
+ if (sipdebug)
+ ast_debug(3, "This SIP transfer is local : %s\n", p->refer->refer_to_domain);
} else if (AST_LIST_EMPTY(&domain_list)) {
/* This PBX don't bother with SIP domains, so all transfers are local */
p->refer->localtransfer = 1;
} else
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "This SIP transfer is to a remote SIP extension (remote domain %s)\n", p->refer->refer_to_domain);
+ if (sipdebug)
+ ast_debug(3, "This SIP transfer is to a remote SIP extension (remote domain %s)\n", p->refer->refer_to_domain);
/* Is this a repeat of a current request? Ignore it */
/* Don't know what else to do right now. */
/* Find the other part of the bridge (2) - transferee */
current.chan2 = ast_bridged_channel(current.chan1);
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "SIP %s transfer: Transferer channel %s, transferee channel %s\n", p->refer->attendedtransfer ? "attended" : "blind", current.chan1->name, current.chan2 ? current.chan2->name : "<none>");
+ if (sipdebug)
+ ast_debug(3, "SIP %s transfer: Transferer channel %s, transferee channel %s\n", p->refer->attendedtransfer ? "attended" : "blind", current.chan1->name, current.chan2 ? current.chan2->name : "<none>");
if (!current.chan2 && !p->refer->attendedtransfer) {
/* No bridged channel, propably IVR or echo or similar... */
/* Guess we should masquerade or something here */
/* Until we figure it out, refuse transfer of such calls */
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG,"Refused SIP transfer on non-bridged channel.\n");
+ if (sipdebug)
+ ast_debug(3,"Refused SIP transfer on non-bridged channel.\n");
p->refer->status = REFER_FAILED;
append_history(p, "Xfer", "Refer failed. Non-bridged channel.");
transmit_response(p, "603 Declined", req);
}
if (current.chan2) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Got SIP transfer, applying to bridged peer '%s'\n", current.chan2->name);
+ if (sipdebug)
+ ast_debug(4, "Got SIP transfer, applying to bridged peer '%s'\n", current.chan2->name);
ast_queue_control(current.chan1, AST_CONTROL_UNHOLD);
}
if ((res = local_attended_transfer(p, ¤t, req, seqno)))
return res; /* We're done with the transfer */
/* Fall through for remote transfers that we did not find locally */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP attended transfer: Still not our call - generating INVITE with replaces\n");
+ if (sipdebug)
+ ast_debug(4, "SIP attended transfer: Still not our call - generating INVITE with replaces\n");
/* Fallthrough if we can't find the call leg internally */
}
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
p->refer->status = REFER_200OK;
append_history(p, "Xfer", "REFER to call parking.");
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name);
+ if (sipdebug)
+ ast_debug(4, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name);
sip_park(current.chan2, current.chan1, req, seqno);
return res;
}
transmit_response(p, "202 Accepted", req);
if (current.chan1 && current.chan2) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "chan1->name: %s\n", current.chan1->name);
+ ast_debug(3, "chan1->name: %s\n", current.chan1->name);
pbx_builtin_setvar_helper(current.chan1, "BLINDTRANSFER", current.chan2->name);
}
if (current.chan2) {
if (!res) {
/* Success - we have a new channel */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_debug(3, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
transmit_notify_with_sipfrag(p, seqno, "200 Ok", TRUE);
if (p->refer->localtransfer)
p->refer->status = REFER_200OK;
res = 0;
} else {
ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Don't delay hangup */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_debug(3, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
append_history(p, "Xfer", "Refer failed.");
/* Failure of some kind */
p->refer->status = REFER_FAILED;
if (p->owner && p->owner->_state == AST_STATE_UP) {
/* This call is up, cancel is ignored, we need a bye */
transmit_response(p, "200 OK", req);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got CANCEL on an answered call. Ignoring... \n");
+ ast_debug(1, "Got CANCEL on an answered call. Ignoring... \n");
return 0;
}
p->invitestate = INV_TERMINATED;
copy_request(&p->initreq, req);
- if (sipdebug && option_debug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
sip_alreadygone(p);
}
} else if (p->owner) {
ast_queue_hangup(p->owner);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Received bye, issuing owner hangup\n");
+ ast_debug(3, "Received bye, issuing owner hangup\n");
} else {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Received bye, no owner, selfdestruct soon.\n");
+ ast_debug(3, "Received bye, no owner, selfdestruct soon.\n");
}
transmit_response(p, "200 OK", req);
/* For transfers, this could happen, but since we haven't seen it happening, let us just refuse this */
transmit_response(p, "403 Forbidden (within dialog)", req);
/* Do not destroy session, since we will break the call if we do */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
+ ast_debug(1, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
return 0;
} else if (ast_test_flag(req, SIP_PKT_DEBUG)) {
- if (option_debug) {
- if (resubscribe)
- ast_log(LOG_DEBUG, "Got a re-subscribe on existing subscription %s\n", p->callid);
- else
- ast_log(LOG_DEBUG, "Got a new subscription %s (possibly with auth)\n", p->callid);
- }
+ if (resubscribe)
+ ast_debug(1, "Got a re-subscribe on existing subscription %s\n", p->callid);
+ else
+ ast_debug(1, "Got a new subscription %s (possibly with auth)\n", p->callid);
}
}
ast_verbose("Creating new subscription\n");
copy_request(&p->initreq, req);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
} else if (ast_test_flag(req, SIP_PKT_DEBUG) && ast_test_flag(req, SIP_PKT_IGNORE))
ast_verbose("Ignoring this SUBSCRIBE request\n");
/* Find parameters to Event: header value and remove them for now */
if (ast_strlen_zero(eventheader)) {
transmit_response(p, "489 Bad Event", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: <none>\n");
+ ast_debug(2, "Received SIP subscribe for unknown event package: <none>\n");
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
}
if (!ast_strlen_zero(accept) && strcmp(accept, "application/simple-message-summary")) {
/* Format requested that we do not support */
transmit_response(p, "406 Not Acceptable", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP mailbox subscription for unknown format: %s\n", accept);
+ ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", accept);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (authpeer)
unref_peer(authpeer);
/* Do not release authpeer here */
} else { /* At this point, Asterisk does not understand the specified event */
transmit_response(p, "489 Bad Event", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event);
+ ast_debug(2, "Received SIP subscribe for unknown event package: %s\n", event);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (authpeer)
unref_peer(authpeer);
if (p->expiry < min_expiry && p->expiry > 0)
p->expiry = min_expiry;
- if (sipdebug || option_debug > 1) {
+ if (sipdebug) {
if (p->subscribed == MWI_NOTIFICATION && p->relatedpeer)
- ast_log(LOG_DEBUG, "Adding subscription for mailbox notification - peer %s Mailbox %s\n", p->relatedpeer->name, p->relatedpeer->mailbox);
+ ast_debug(2, "Adding subscription for mailbox notification - peer %s Mailbox %s\n", p->relatedpeer->name, p->relatedpeer->mailbox);
else
- ast_log(LOG_DEBUG, "Adding subscription for extension %s context %s for peer %s\n", p->exten, p->context, p->username);
+ ast_debug(2, "Adding subscription for extension %s context %s for peer %s\n", p->exten, p->context, p->username);
}
if (p->autokillid > -1)
sip_cancel_destroy(p); /* Remove subscription expiry for renewals */
/* Use this as the basis */
copy_request(&p->initreq, req);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
if ((res = register_verify(p, sin, req, e)) < 0) {
const char *reason;
within an existing dialog */
/* Response to our request -- Do some sanity checks */
if (p->ocseq < seqno) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
+ ast_debug(1, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
return -1;
} else if (p->ocseq != seqno) {
/* ignore means "don't do anything with it" but still have to
*/
p->method = req->method; /* Find out which SIP method they are using */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
+ ast_debug(4, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
if (p->icseq && (p->icseq > seqno)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
+ ast_debug(1, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
if (req->method != SIP_ACK)
transmit_response(p, "503 Server error", req); /* We must respond according to RFC 3261 sec 12.2 */
return -1;
respond appropriately. We do this if we receive a repeat of
the last sequence number */
ast_set_flag(req, SIP_PKT_IGNORE);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
+ ast_debug(3, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
}
if (seqno >= p->icseq)
transmit_response(p, "481 Call/Transaction Does Not Exist", req);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got ACK for unknown dialog... strange.\n");
+ ast_debug(1, "Got ACK for unknown dialog... strange.\n");
}
return res;
}
ast_log(LOG_WARNING, "Recv error: %s\n", strerror(errno));
return 1;
}
- if (option_debug && res == sizeof(req.data)) {
- ast_log(LOG_DEBUG, "Received packet exceeds buffer. Data is possibly lost\n");
+ if (res == sizeof(req.data)) {
+ ast_debug(1, "Received packet exceeds buffer. Data is possibly lost\n");
req.data[sizeof(req.data) - 1] = '\0';
} else
req.data[res] = '\0';
/* Find the active SIP dialog or create a new one */
p = find_call(&req, &sin, req.method); /* returns p locked */
if (p == NULL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid SIP message - rejected , no callid, len %d\n", req.len);
+ ast_debug(1, "Invalid SIP message - rejected , no callid, len %d\n", req.len);
ast_mutex_unlock(&netlock);
return 1;
}
/* becaues this is deadlock-prone, we need to try and unlock if failed */
if (!p->owner || !ast_channel_trylock(p->owner))
break; /* locking succeeded */
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
+ ast_debug(1, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
sip_pvt_unlock(p);
ast_mutex_unlock(&netlock);
/* Sleep for a very short amount of time */
nounlock = 0;
if (handle_request(p, &req, &sin, &recount, &nounlock) == -1) {
/* Request failed */
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
+ ast_debug(1, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
}
if (p->owner && !nounlock)
if ((res < 0) || (res > 1000))
res = 1000;
res = ast_io_wait(io, res);
- if (option_debug && res > 20)
- ast_log(LOG_DEBUG, "chan_sip: ast_io_wait ran %d all at once\n", res);
+ if (res > 20)
+ ast_debug(1, "chan_sip: ast_io_wait ran %d all at once\n", res);
ast_mutex_lock(&monlock);
if (res >= 0) {
res = ast_sched_runq(sched);
- if (option_debug && res >= 20)
- ast_log(LOG_DEBUG, "chan_sip: ast_sched_runq ran %d all at once\n", res);
+ if (res >= 20)
+ ast_debug(1, "chan_sip: ast_sched_runq ran %d all at once\n", res);
}
ast_mutex_unlock(&monlock);
}
if ((tmp = strchr(host, '@')))
host = tmp + 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for peer %s\n", host);
+ ast_debug(3, "Checking device state for peer %s\n", host);
if ((p = find_peer(host, NULL, 1))) {
if (p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) {
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; /* Can't find codec to connect to host */
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
+ ast_debug(1, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
if (!(p = sip_alloc(NULL, NULL, 0, SIP_INVITE))) {
ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", dest);
if (create_addr(p, host)) {
*cause = AST_CAUSE_UNREGISTERED;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Cant create SIP call - target device not registred\n");
+ ast_debug(3, "Cant create SIP call - target device not registred\n");
sip_destroy(p);
return NULL;
}
AST_LIST_UNLOCK(&domain_list);
if (sipdebug)
- ast_log(LOG_DEBUG, "Added local SIP domain '%s'\n", domain);
+ ast_debug(1, "Added local SIP domain '%s'\n", domain);
return 1;
}
if (ast_strlen_zero(configuration))
return authlist;
- if (option_debug)
- ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
+ ast_debug(1, "Auth config :: %s\n", configuration);
ast_copy_string(authcopy, configuration, sizeof(authcopy));
stringp = authcopy;
if (realtime) {
rpeerobjs++;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
+ ast_debug(3,"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
} else
speerobjs++;
ASTOBJ_INIT(peer);
if ((nowtime - regseconds) > 0) {
destroy_association(peer);
memset(&peer->addr, 0, sizeof(peer->addr));
- if (option_debug)
- ast_log(LOG_DEBUG, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
ast_copy_string(global_realm, v->value, sizeof(global_realm));
} else if (!strcasecmp(v->name, "useragent")) {
ast_copy_string(global_useragent, v->value, sizeof(global_useragent));
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
+ ast_debug(1, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
} else if (!strcasecmp(v->name, "allowtransfer")) {
global_allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
} else if (!strcasecmp(v->name, "rtcachefriends")) {
if (context)
*context++ = '\0';
- if (option_debug && ast_strlen_zero(context))
- ast_log(LOG_DEBUG, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
+ if (ast_strlen_zero(context))
+ ast_debug(1, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
if (ast_strlen_zero(domain))
ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
else
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
- }
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
transmit_reinvite_with_sdp(p, TRUE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
- }
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
}
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
transmit_reinvite_with_sdp(p, TRUE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
} else {
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
}
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
pvt->t38.state = T38_ENABLED;
p->t38.state = T38_ENABLED;
- if (option_debug > 1) {
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", pvt->t38.state, pvt->owner ? pvt->owner->name : "<none>");
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
- }
+ ast_debug(2, "T38 changed state to %d on channel %s\n", pvt->t38.state, pvt->owner ? pvt->owner->name : "<none>");
+ ast_debug(2, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
p->lastrtprx = p->lastrtptx = time(NULL);
sip_pvt_unlock(p);
if (chan->_state != AST_STATE_UP) { /* We are in early state */
if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY))
append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
- if (option_debug)
- ast_log(LOG_DEBUG, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
+ ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
} else if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
- }
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
transmit_reinvite_with_sdp(p, FALSE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
- }
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
/* We have a pending Invite. Send re-invite when we're done with the invite */
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
if (ok) {
pbx_builtin_setvar_helper (chan, varbuf, inbuf);
if (sipdebug)
- ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
+ ast_debug(1,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
} else {
ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n");
}
/*! \brief Reload module */
static int sip_do_reload(enum channelreloadreason reason)
{
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- SIP reload started\n");
+ ast_debug(4, "--------------- SIP reload started\n");
clear_realm_authentication(authl);
clear_sip_domains();
ASTOBJ_CONTAINER_TRAVERSE(®l, 1, do {
ASTOBJ_RDLOCK(iterator);
if (iterator->call) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
/* This will also remove references to the registry */
sip_destroy(iterator->call);
}
/* Then, actually destroy users and registry */
ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying user list\n");
+ ast_debug(4, "--------------- Done destroying user list\n");
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying registry list\n");
+ ast_debug(4, "--------------- Done destroying registry list\n");
ASTOBJ_CONTAINER_MARKALL(&peerl);
reload_config(reason);
/* Prune peers who still are supposed to be deleted */
ASTOBJ_CONTAINER_PRUNE_MARKED(&peerl, sip_destroy_peer);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying pruned peers\n");
+ ast_debug(4, "--------------- Done destroying pruned peers\n");
/* Send qualify (OPTIONS) to all peers */
sip_poke_all_peers();
/* Register with all services */
sip_send_all_registers();
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- SIP reload done\n");
+ ast_debug(4, "--------------- SIP reload done\n");
return 0;
}
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
+ ast_debug(1, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
transmit_tone(s, SKINNY_REORDER);
if (sub->owner && sub->owner->_state != AST_STATE_UP) {
ast_indicate(c, -1);
struct skinnysession *s;
if (!sub) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ ast_debug(1, "Asked to hangup channel not connected\n");
return 0;
}
l = sub->parent;
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != ast->nativeformats) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
ast->nativeformats = f->subclass;
ast_set_read_format(ast, ast->readformat);
ast_set_write_format(ast, ast->writeformat);
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
+ ast_debug(1, "Current subchannel [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if (c) {
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
+ ast_debug(1, "Current sub [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if (c) {
res = AST_BRIDGE_RETRY;
break;
}
- ast_log(LOG_DEBUG, "%s: vpb_bridge: Empty frame read...\n",p0->dev);
+ ast_debug(1, "%s: vpb_bridge: Empty frame read...\n",p0->dev);
/* check for hangup / whentohangup */
if (ast_check_hangup(c0) || ast_check_hangup(c1))
break;
((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1))))) {
*fo = f;
*rc = who;
- ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
+ ast_debug(1, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
/*
if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) {
if (pr0->set_rtp_peer(c0, NULL, NULL, 0))
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
} else
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
} else
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ ast_debug(1, "Fax already handled\n");
}
else if (e->data == VPB_GRUNT) {
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
*/
ast_mutex_lock(&p->lock);
- ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name);
+ ast_debug(1, "New owner for channel %s is %s\n", p->dev, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
#endif
if (res != VPB_OK) {
- ast_log(LOG_DEBUG, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res));
+ ast_debug(1, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res));
res = -1;
} else
res = 0;
/* ast_mutex_unlock(&p->lock); */
return 0;
}
-/* ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame type..\n", p->dev); */
+/* ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */
fmt = ast2vpbformat(frame->subclass);
}
tdiff = ast_tvdiff_ms(ast_tvnow(), p->lastplay);
- ast_log(LOG_DEBUG, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff);
+ ast_debug(1, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff);
if (tdiff < (VPB_SAMPLES/8 - 1)){
- ast_log(LOG_DEBUG, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen);
+ ast_debug(1, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen);
// return 0;
}
p->lastplay = ast_tvnow();
/*
- ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame format..\n", p->dev);
+ ast_debug(1, "%s: vpb_write: Checked frame format..\n", p->dev);
*/
ast_mutex_lock(&p->play_lock);
/*
- ast_log(LOG_DEBUG, "%s: vpb_write: Got play lock..\n", p->dev);
+ ast_debug(1, "%s: vpb_write: Got play lock..\n", p->dev);
*/
/* Check if we have set up the play_buf */
if( p->txswgain > MAX_VPB_GAIN )
a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen/sizeof(short));
-/* ast_log(LOG_DEBUG, "%s: vpb_write: Applied gain..\n", p->dev); */
-/* ast_log(LOG_DEBUG, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
+/* ast_debug(1, "%s: vpb_write: Applied gain..\n", p->dev); */
+/* ast_debug(1, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
if ((p->read_state == 1)&&(p->play_buf_time<5)){
play_buf_time_start = ast_tvnow();
}
else {
p->chuck_count++;
- ast_log(LOG_DEBUG, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count);
+ ast_debug(1, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count);
p->play_buf_time=0;
}
/* afmt = (p->owner) ? p->owner->rawreadformat : AST_FORMAT_SLINEAR; */
if (p->owner){
afmt = p->owner->rawreadformat;
-/* ast_log(LOG_DEBUG,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
+/* ast_debug(1,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
else {
afmt = AST_FORMAT_SLINEAR;
-/* ast_log(LOG_DEBUG,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
+/* ast_debug(1,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
fmt = ast2vpbformat(afmt);
if (fmt < 0) {
if ((use_ast_dtmfdet)&&(p->vad)){
fr = ast_dsp_process(p->owner,p->vad,fr);
if (fr && (fr->frametype == AST_FRAME_DTMF))
- ast_log(LOG_DEBUG, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass);
+ ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass);
if (fr->subclass == 'm'){
/* conf mute request */
fr->frametype = AST_FRAME_NULL;
int tinthreeway;
struct ast_channel *towner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ ast_debug(1, "Swapping %d and %d\n", a, b);
tchan = p->subs[a].chan;
towner = p->subs[a].owner;
p->subs[x].zfd = -1;
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
+ ast_debug(1, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
return 0;
} else
ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel);
+ ast_debug(1, "Released sub %d of channel %d\n", x, p->channel);
if (p->subs[x].zfd > -1) {
zt_close(p->subs[x].zfd);
}
ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->span);
} else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) {
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
+ ast_debug(1, "Queueing digit '%c' since setup_ack not yet received\n", digit);
res = strlen(pvt->dialdest);
pvt->dialdest[res++] = digit;
pvt->dialdest[res] = '\0';
else
pvt->dialing = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
+ ast_debug(1, "Started VLDTMF digit '%c'\n", digit);
pvt->dialing = 1;
pvt->begindigit = digit;
}
if (pvt->begindigit) {
x = -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
+ ast_debug(1, "Ending VLDTMF digit '%c'\n", digit);
res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &x);
pvt->dialing = 0;
pvt->begindigit = 0;
p->confno = zi.confno;
}
memcpy(&c->curconf, &zi, sizeof(c->curconf));
- if (option_debug)
- ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ ast_debug(1, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return 0;
}
ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ ast_debug(1, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
memcpy(&c->curconf, &zi, sizeof(c->curconf));
return 0;
}
Kill it. */
p->confno = -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
+ ast_debug(1, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
return 0;
}
if (!p)
return;
if (p->echocanon) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Echo cancellation already on\n");
+ ast_debug(1, "Echo cancellation already on\n");
return;
}
if (p->digital) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
+ ast_debug(1, "Echo cancellation isn't required on digital connection\n");
return;
}
if (p->echocancel) {
ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d\n", p->channel);
else {
p->echocanon = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
+ ast_debug(1, "Enabled echo cancellation on channel %d\n", p->channel);
}
- } else if (option_debug)
- ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ } else
+ ast_debug(1, "No echo cancellation requested\n");
}
static void zt_train_ec(struct zt_pvt *p)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
if (res)
ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
- }
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No echo training requested\n");
- }
+ else
+ ast_debug(1, "Engaged echo training on channel %d\n", p->channel);
+ } else
+ ast_debug(1, "No echo training requested\n");
}
static void zt_disable_ec(struct zt_pvt *p)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
if (res)
ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
- else if (option_debug)
- ast_log(LOG_DEBUG, "disabled echo cancellation on channel %d\n", p->channel);
+ else
+ ast_debug(1, "disabled echo cancellation on channel %d\n", p->channel);
}
p->echocanon = 0;
}
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
return res;
}
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
return res;
}
ast_log(LOG_WARNING, "Unable to set conference info: %s\n", strerror(errno));
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Disabled conferencing\n");
+ ast_debug(1, "Disabled conferencing\n");
return 0;
}
return -1;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Restored conferencing\n");
+ ast_debug(1, "Restored conferencing\n");
return 0;
}
if (c) {
p->dop.op = ZT_DIAL_OP_REPLACE;
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
- if (option_debug)
- ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
+ ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
} else {
p->dop.dialstr[0] = '\0';
}
#ifdef HAVE_PRI
}
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
+ ast_debug(1, "Dialing '%s'\n", c);
p->dop.op = ZT_DIAL_OP_REPLACE;
c += p->stripmsd;
ast_mutex_unlock(&p->lock);
return -1;
}
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring dialing...\n");
- }
+ } else
+ ast_debug(1, "Deferring dialing...\n");
+
p->dialing = 1;
if (ast_strlen_zero(c))
p->dialednone = 1;
p->dialdest[0] = '\0';
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "not yet implemented\n");
+ ast_debug(1, "not yet implemented\n");
ast_mutex_unlock(&p->lock);
return -1;
}
}
if (p->bearer || (mysig == SIG_FXSKS)) {
if (p->bearer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel);
+ ast_debug(1, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel);
p->bearer->call = p->call;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n");
- }
+ } else
+ ast_debug(1, "I'm being setup with no bearer right now...\n");
+
pri_set_crv(p->pri->pri, p->call, p->channel, 0);
}
p->digital = IS_DIGITAL(ast->transfercapability);
char *digits = (char *) data;
if (ast_strlen_zero(digits)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No digit string sent to application!\n");
+ ast_debug(1, "No digit string sent to application!\n");
return -1;
}
p = (struct zt_pvt *)chan->tech_pvt;
if (!p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find technology private\n");
+ ast_debug(1, "Unable to find technology private\n");
return -1;
}
ast_mutex_lock(&p->lock);
if (!p->pri || !p->call) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n");
+ ast_debug(1, "Unable to find pri or call on channel!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
pri_keypad_facility(p->pri->pri, p->call, digits);
pri_rel(p->pri);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
+ ast_debug(1, "Unable to grab pri to send keypad facility!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
struct zt_pvt *prev = NULL;
ZT_PARAMS par;
- if (option_debug)
- ast_log(LOG_DEBUG, "zt_hangup(%s)\n", ast->name);
+ ast_debug(1, "zt_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
if (p->exten)
p->exten[0] = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
- p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+ ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
+ p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->ignoredtmf = 0;
if (index > -1) {
zt_setlinear(p->subs[index].zfd, 0);
if (index == SUB_REAL) {
if ((p->subs[SUB_CALLWAIT].zfd > -1) && (p->subs[SUB_THREEWAY].zfd > -1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n");
+ ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
if (p->subs[SUB_CALLWAIT].inthreeway) {
/* We had flipped over to answer a callwait and now it's gone */
- if (option_debug)
- ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n");
+ ast_debug(1, "We were flipped over to the callwait, moving back and unowning.\n");
/* Move to the call-wait, but un-own us until they flip back. */
swap_subs(p, SUB_CALLWAIT, SUB_REAL);
unalloc_sub(p, SUB_CALLWAIT);
p->owner = NULL;
} else {
/* The three way hung up, but we still have a call wait */
- if (option_debug)
- ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
+ ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
swap_subs(p, SUB_THREEWAY, SUB_REAL);
unalloc_sub(p, SUB_THREEWAY);
if (p->subs[SUB_REAL].inthreeway) {
/* This was part of a three way call. Immediately make way for
another call */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ ast_debug(1, "Call was complete, setting owner to former third call\n");
p->owner = p->subs[SUB_REAL].owner;
} else {
/* This call hasn't been completed yet... Set owner to NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ ast_debug(1, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
if (p->subs[SUB_REAL].inthreeway) {
/* This was part of a three way call. Immediately make way for
another call */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ ast_debug(1, "Call was complete, setting owner to former third call\n");
p->owner = p->subs[SUB_REAL].owner;
} else {
/* This call hasn't been completed yet... Set owner to NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ ast_debug(1, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
if (!pri_grab(p, p->pri)) {
if (p->alreadyhungup) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
+ ast_debug(1, "Already hungup... Calling hangup once, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
} else {
const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
int icause = ast->hangupcause ? ast->hangupcause : -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
+ ast_debug(1, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
}
} else {
if (p->bearer)
- if (option_debug)
- ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
+ ast_debug(1, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
p->call = NULL;
res = 0;
}
res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par);
if (!res) {
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
+ ast_debug(1, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
#endif
/* If they're off hook, try playing congestion */
if ((par.rxisoffhook) && (!(p->radio || (p->oprmode < 0))))
}
#ifdef HAVE_PRI
if (p->bearer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel);
+ ast_debug(1, "Freeing up bearer channel %d\n", p->bearer->channel);
/* Free up the bearer channel as well, and
don't use its file descriptor anymore */
update_conf(p->bearer);
case SIG_FXOGS:
case SIG_FXOKS:
/* Pick up the line */
- if (option_debug)
- ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name);
+ ast_debug(1, "Took %s off hook\n", ast->name);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
p->dialing = 0;
if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) {
if (oldstate == AST_STATE_RINGING) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Finally swapping real and threeway\n");
+ ast_debug(1, "Finally swapping real and threeway\n");
tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, -1);
swap_subs(p, SUB_THREEWAY, SUB_REAL);
p->owner = p->subs[SUB_REAL].owner;
ast_log(LOG_WARNING, "No index in TXGAIN?\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
+ ast_debug(1, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
return set_actual_txgain(p->subs[index].zfd, 0, p->txgain + (float) *scp, p->law);
case AST_OPTION_RXGAIN:
scp = (signed char *) data;
ast_log(LOG_WARNING, "No index in RXGAIN?\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
+ ast_debug(1, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
return set_actual_rxgain(p->subs[index].zfd, 0, p->rxgain + (float) *scp, p->law);
case AST_OPTION_TONE_VERIFY:
if (!p->dsp)
cp = (char *) data;
switch (*cp) {
case 1:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | p->dtmfrelax); /* set mute mode if desired */
break;
case 2:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX | p->dtmfrelax); /* set mute mode if desired */
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); /* set mute mode if desired */
break;
}
cp = (char *) data;
p->mate = 0;
if (!*cp) { /* turn it off */
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
+ ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
if (p->tdd)
tdd_free(p->tdd);
p->tdd = 0;
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n",
- (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
+ ast_debug(1, "Set option TDD MODE, value: %s(%d) on %s\n",
+ (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
zt_disable_ec(p);
/* otherwise, turn it on */
if (!p->didtdd) { /* if havent done it yet */
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
continue;
}
/* if got exception */
if (fds[0].revents & POLLPRI)
return -1;
if (!(fds[0].revents & POLLOUT)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ ast_debug(1, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
if (res != size) {
if (res == -1) return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
if (!p->dsp)
break;
cp = (char *) data;
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n",
- *cp ? "ON" : "OFF", (int) *cp, chan->name);
+ ast_debug(1, "Set option RELAX DTMF, value: %s(%d) on %s\n",
+ *cp ? "ON" : "OFF", (int) *cp, chan->name);
ast_dsp_digitmode(p->dsp, ((*cp) ? DSP_DIGITMODE_RELAXDTMF : DSP_DIGITMODE_DTMF) | p->dtmfrelax);
break;
case AST_OPTION_AUDIO_MODE: /* Set AUDIO mode (or not) */
cp = (char *) data;
if (!*cp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
+ ast_debug(1, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
x = 0;
zt_disable_ec(p);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
+ ast_debug(1, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
x = 1;
}
if (ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x) == -1)
pp->oprmode = oprmode->mode;
p->oprmode = -oprmode->mode;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n",
- oprmode->mode, chan->name,oprmode->peer->name);
+ ast_debug(1, "Set Operator Services mode, value: %d on %s/%s\n",
+ oprmode->mode, chan->name,oprmode->peer->name);
break;
case AST_OPTION_ECHOCAN:
cp = (char *) data;
if (*cp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
+ ast_debug(1, "Enabling echo cancelation on %s\n", chan->name);
zt_enable_ec(p);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name);
+ ast_debug(1, "Disabling echo cancelation on %s\n", chan->name);
zt_disable_ec(p);
}
break;
if (master->slaves[x]) {
if (!slave || (master->slaves[x] == slave)) {
/* Take slave out of the conference */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
+ ast_debug(1, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
conf_del(master, &master->slaves[x]->subs[SUB_REAL], SUB_REAL);
conf_del(master->slaves[x], &master->subs[SUB_REAL], SUB_REAL);
master->slaves[x]->master = NULL;
ast_log(LOG_WARNING, "Replacing master %d with new master, %d\n", slave->master->channel, master->channel);
slave->master = master;
- if (option_debug)
- ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
+ ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
}
static void disable_dtmf_detect(struct zt_pvt *p)
nothingok = 0;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n",
- master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
+ ast_debug(1, "master: %d, slave: %d, nothingok: %d\n",
+ master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
if (master && slave) {
/* Stop any tones, or play ringtone as appropriate. If they're bridged
in an active threeway call with a channel that is ringing, we should
p1->subs[SUB_REAL].owner &&
p1->subs[SUB_REAL].inthreeway &&
(p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
+ ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
tone_zone_play_tone(p0->subs[oi0].zfd, ZT_TONE_RINGTONE);
os1 = p1->subs[SUB_REAL].owner->_state;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
+ ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
tone_zone_play_tone(p0->subs[oi0].zfd, -1);
}
if ((oi0 == SUB_THREEWAY) &&
p0->subs[SUB_REAL].owner &&
p0->subs[SUB_REAL].inthreeway &&
(p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
+ ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
tone_zone_play_tone(p1->subs[oi1].zfd, ZT_TONE_RINGTONE);
os0 = p0->subs[SUB_REAL].owner->_state;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
+ ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
tone_zone_play_tone(p1->subs[oi0].zfd, -1);
}
if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) {
(t1 != p1->subs[SUB_REAL].inthreeway) ||
(oi0 != i0) ||
(oi1 != i1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
- op0->channel, oi0, op1->channel, oi1);
+ ast_debug(1, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
+ op0->channel, oi0, op1->channel, oi1);
res = AST_BRIDGE_RETRY;
goto return_from_bridge;
}
who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &timeoutms);
if (!who) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, empty read...\n");
+ ast_debug(1, "Ooh, empty read...\n");
continue;
}
f = ast_read(who);
struct zt_pvt *p = newchan->tech_pvt;
int x;
ast_mutex_lock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
+ ast_debug(1, "New owner for channel %d is %s\n", p->channel, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
}
/* Tell the caller not to hangup */
return 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n",
- p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name);
+ ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
+ p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
return -1;
}
struct zt_pvt *p = ast->tech_pvt;
struct ast_frame *f = *dest;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name);
+ ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name);
if (p->confirmanswer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Confirm answer on %s!\n", ast->name);
+ ast_debug(1, "Confirm answer on %s!\n", ast->name);
/* Upon receiving a DTMF digit, consider this an answer confirmation instead
of a DTMF digit */
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->confirmanswer = 0;
} else if (p->callwaitcas) {
if ((f->subclass == 'A') || (f->subclass == 'D')) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n");
+ ast_debug(1, "Got some DTMF, but it's for the CAS\n");
if (p->cidspill)
ast_free(p->cidspill);
send_cwcidspill(p);
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ } else
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
+ } else
+ ast_debug(1, "Fax already handled\n");
zt_confmute(p, 0);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
} else
res = zt_get_event(p->subs[index].zfd);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
+ ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
if (res & (ZT_EVENT_PULSEDIGIT | ZT_EVENT_DTMFUP)) {
p->pulsedial = (res & ZT_EVENT_PULSEDIGIT) ? 1 : 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
+ ast_debug(1, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig == SIG_PRI && p->pri && (p->pri->overlapdial & ZAP_OVERLAPDIAL_INCOMING)) {
/* absorb event */
}
if (res & ZT_EVENT_DTMFDOWN) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff);
+ ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
/* Mute conference */
zt_confmute(p, 1);
p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
if (p->inalarm) break;
if ((p->radio || (p->oprmode < 0))) break;
if (ioctl(p->subs[index].zfd,ZT_DIALING,&x) == -1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name);
+ ast_debug(1, "ZT_DIALING ioctl failed on %s\n",ast->name);
return NULL;
}
if (!x) { /* if not still dialing in driver */
}
if (ast->_state == AST_STATE_DIALING) {
if ((p->callprogress & 1) && CANPROGRESSDETECT(p) && p->dsp && p->outgoing) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n");
+ ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n");
} else if (p->confirmanswer || (!p->dialednone && ((mysig == SIG_EM) || (mysig == SIG_EM_E1) || (mysig == SIG_EMWINK) || (mysig == SIG_FEATD) || (mysig == SIG_FEATDMF_TA) || (mysig == SIG_FEATDMF) || (mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF) || (mysig == SIG_FEATB) || (mysig == SIG_SF) || (mysig == SIG_SFWINK) || (mysig == SIG_SF_FEATD) || (mysig == SIG_SF_FEATDMF) || (mysig == SIG_SF_FEATB)))) {
ast_setstate(ast, AST_STATE_RINGING);
} else if (!p->answeronpolarityswitch) {
return NULL;
}
mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
- if (option_debug)
- ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
+ ast_debug(1, "Last flash was %d ms ago\n", mssinceflash);
if (mssinceflash < MIN_MS_SINCE_FLASH) {
/* It hasn't been long enough since the last flashook. This is probably a bounce on
hanging up. Hangup both channels now */
if (p->subs[SUB_THREEWAY].owner)
ast_queue_hangup(p->subs[SUB_THREEWAY].owner);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
- if (option_debug)
- ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
+ ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
} else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) {
if (p->transfer) {
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
/* Make sure it stops ringing */
zt_set_hook(p->subs[index].zfd, ZT_OFFHOOK);
- if (option_debug)
- ast_log(LOG_DEBUG, "channel %d answered\n", p->channel);
+ ast_debug(1, "channel %d answered\n", p->channel);
if (p->cidspill) {
/* Cancel any running CallerID spill */
ast_free(p->cidspill);
p->dop.dialstr[0] = '\0';
return NULL;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
+ ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
p->dialing = 1;
ast->rings = 1;
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
- if (option_debug)
- ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel);
+ ast_debug(1, "channel %d picked up\n", p->channel);
return &p->subs[index].f;
case AST_STATE_UP:
/* Make sure it stops ringing */
/* If we get a ring then we cannot be in
* reversed polarity. So we reset to idle */
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting IDLE polarity due "
- "to ring. Old polarity was %d\n",
- p->polarity);
+ ast_debug(1, "Setting IDLE polarity due "
+ "to ring. Old polarity was %d\n",
+ p->polarity);
p->polarity = POLARITY_IDLE;
/* Fall through */
if (ast->_state == AST_STATE_PRERING)
ast_setstate(ast, AST_STATE_RING);
if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ring detected\n");
+ ast_debug(1, "Ring detected\n");
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RING;
} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Line answered\n");
+ ast_debug(1, "Line answered\n");
if (p->confirmanswer) {
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
case SIG_FXOLS:
case SIG_FXOGS:
case SIG_FXOKS:
- if (option_debug)
- ast_log(LOG_DEBUG, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
- index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+ ast_debug(1, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
+ index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->callwaitcas = 0;
if (index != SUB_REAL) {
swap_subs(p, SUB_REAL, SUB_CALLWAIT);
tone_zone_play_tone(p->subs[SUB_REAL].zfd, -1);
p->owner = p->subs[SUB_REAL].owner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name);
+ ast_debug(1, "Making %s the new owner\n", p->owner->name);
if (p->owner->_state == AST_STATE_RINGING) {
ast_setstate(p->owner, AST_STATE_UP);
p->subs[SUB_REAL].needanswer = 1;
if (!((ast->pbx) ||
(ast->_state == AST_STATE_UP) ||
(ast->_state == AST_STATE_RING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Flash when call not up or ringing\n");
+ ast_debug(1, "Flash when call not up or ringing\n");
goto winkflashdone;
}
if (alloc_sub(p, SUB_THREEWAY)) {
/* Already have a 3 way call */
if (p->subs[SUB_THREEWAY].inthreeway) {
/* Call is already up, drop the last person */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got flash with three way call up, dropping last call on %d\n", p->channel);
+ ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
/* If the primary call isn't answered yet, use it */
if ((p->subs[SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_UP)) {
/* Swap back -- we're dropping the real 3-way that isn't finished yet*/
p->subs[otherindex].needunhold = 1;
p->owner = p->subs[SUB_REAL].owner;
if (ast->_state == AST_STATE_RINGING) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n");
+ ast_debug(1, "Enabling ringtone on real and threeway\n");
res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
res = tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE);
}
case SIG_FXSGS:
if (option_debug) {
if (p->dialing)
- ast_log(LOG_DEBUG, "Ignoring wink on channel %d\n", p->channel);
+ ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
else
- ast_log(LOG_DEBUG, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
+ ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
}
break;
case SIG_FEATDMF_TA:
switch (p->whichwink) {
case 0:
- if (option_debug)
- ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+ ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
break;
case 1:
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
return NULL;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr);
+
p->dop.dialstr[0] = '\0';
break;
default:
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
return NULL;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr);
+
p->dop.dialstr[0] = '\0';
p->dop.op = ZT_DIAL_OP_REPLACE;
break;
case SIG_FEATB:
case SIG_SF_FEATDMF:
case SIG_SF_FEATB:
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
+ ast_debug(1, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
break;
default:
break;
if (p->answeronpolarityswitch &&
((ast->_state == AST_STATE_DIALING) ||
(ast->_state == AST_STATE_RINGING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
+ ast_debug(1, "Answering on polarity switch!\n");
ast_setstate(p->owner, AST_STATE_UP);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
- }
+ } else
+ ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+
}
/* Removed else statement from here as it was preventing hangups from ever happening*/
/* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */
(p->polarity == POLARITY_REV) &&
((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
/* Added log_debug information below to provide a better indication of what is going on */
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+ ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
+ ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
p->polarity = POLARITY_IDLE;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
- }
+ } else
+ ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
+
} else {
p->polarity = POLARITY_IDLE;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
+ ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
}
/* Added more log_debug information below to provide a better indication of what is going on */
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+ ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
+ ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
}
return &p->subs[index].f;
}
/* Switch to real if there is one and this isn't something really silly... */
if ((res != ZT_EVENT_RINGEROFF) && (res != ZT_EVENT_RINGERON) &&
(res != ZT_EVENT_HOOKCOMPLETE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res);
+ ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
p->owner = p->subs[SUB_REAL].owner;
if (p->owner && ast_bridged_channel(p->owner))
ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
f = &p->subs[index].f;
return f;
}
- if (!(p->radio || (p->oprmode < 0)) && option_debug)
- ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+ if (!(p->radio || (p->oprmode < 0)))
+ ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
/* If it's not us, return NULL immediately */
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_HOLD;
ast_mutex_unlock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name);
+ ast_debug(1, "Sending hold on '%s'\n", ast->name);
return &p->subs[index].f;
}
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_UNHOLD;
ast_mutex_unlock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name);
+ ast_debug(1, "Sending unhold on '%s'\n", ast->name);
return &p->subs[index].f;
}
return f;
}
if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
+ ast_debug(1, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
f = __zt_exception(ast);
ast_mutex_unlock(&p->lock);
return f;
c = tdd_feed(p->tdd,readbuf,READ_SIZE);
if (c < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG,"tdd_feed failed\n");
+ ast_debug(1,"tdd_feed failed\n");
ast_mutex_unlock(&p->lock);
return NULL;
}
p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]);
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
+ ast_debug(1, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
#endif
if (p->dialing || /* Transmitting something */
(index && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
size = (linear ? READ_SIZE * 2 : READ_SIZE);
res = write(fd, buf, size);
if (res != size) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
return sent;
}
len -= size;
return -1;
}
if (p->dialing) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since I'm still dialing on %s...\n",ast->name);
+ ast_debug(1, "Dropping frame since I'm still dialing on %s...\n",ast->name);
return 0;
}
if (!p->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since there is no active owner on %s...\n",ast->name);
+ ast_debug(1, "Dropping frame since there is no active owner on %s...\n",ast->name);
return 0;
}
if (p->cidspill) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since I've still got a callerid spill\n");
+ ast_debug(1, "Dropping frame since I've still got a callerid spill\n");
return 0;
}
/* Return if it's not valid data */
int func = ZT_FLASH;
ast_mutex_lock(&p->lock);
index = zt_get_index(chan, p, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
if (index == SUB_REAL) {
switch (condition) {
case AST_CONTROL_BUSY:
}
break;
case AST_CONTROL_PROCEEDING:
- if (option_debug)
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
+ ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) {
if (p->pri->pri) {
res = 0;
break;
case AST_CONTROL_PROGRESS:
- if (option_debug)
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
+ ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
#ifdef HAVE_PRI
p->digital = 0; /* Digital-only calls isn't allows any inband progress messages */
if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) {
}
if (features) {
if (i->dsp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
+ ast_debug(1, "Already have a dsp on %s?\n", tmp->name);
} else {
if (i->channel != CHAN_PSEUDO)
i->dsp = ast_dsp_new();
timeout = gendigittimeout;
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
ast_log(LOG_WARNING, "PBX exited non-zero!\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
+ ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
chan->hangupcause = AST_CAUSE_UNALLOCATED;
ast_hangup(chan);
p->exten[0] = '\0';
}
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
ast_hangup(chan);
return NULL;
} else if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hung up before digits finished\n");
+ ast_debug(1, "Got hung up before digits finished\n");
ast_hangup(chan);
return NULL;
}
res = ast_waitfordigit(chan, timeout);
timeout = 0;
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
res = tone_zone_play_tone(p->subs[index].zfd, -1);
ast_hangup(chan);
return NULL;
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ ast_debug(1, "not enough digits (and no ambiguous match)...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
ast_hangup(chan);
}
zt_enable_ec(p);
if (ast_pickup_call(chan)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
+ ast_debug(1, "No call pickup possible...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
}
}
} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
((exten[0] != '*') || (strlen(exten) > 2))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+ ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
break;
}
if (!timeout)
res = 0;
ast_frfree(f);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got ring!\n");
+ ast_debug(1, "Got ring!\n");
res = 0;
break;
}
else if (smdi_msg->type == 'N')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u");
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name);
+ ast_debug(1, "Recieved SMDI message on %s\n", chan->name);
} else {
ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n");
}
if (p->cid_signalling == CID_SIG_DTMF) {
int i = 0;
cs = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Receiving DTMF cid on "
- "channel %s\n", chan->name);
+ ast_debug(1, "Receiving DTMF cid on "
+ "channel %s\n", chan->name);
zt_setlinear(p->subs[index].zfd, 0);
res = 2000;
for (;;) {
f = ast_read(chan);
if (f->frametype == AST_FRAME_DTMF) {
dtmfbuf[i++] = f->subclass;
- if (option_debug)
- ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass);
+ ast_debug(1, "CID got digit '%c'\n", f->subclass);
res = 2000;
}
ast_frfree(f);
dtmfbuf[i] = '\0';
zt_setlinear(p->subs[index].zfd, p->subs[index].linear);
/* Got cid and ring. */
- if (option_debug)
- ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf);
+ ast_debug(1, "CID got string '%s'\n", dtmfbuf);
callerid_get_dtmf(dtmfbuf, dtmfcid, &flags);
- if (option_debug)
- ast_log(LOG_DEBUG, "CID is '%s', flags %d\n",
- dtmfcid, flags);
+ ast_debug(1, "CID is '%s', flags %d\n",
+ dtmfcid, flags);
/* If first byte is NULL, we have no cid */
if (!ast_strlen_zero(dtmfcid))
number = dtmfcid;
}
if (res == 1) {
callerid_get(cs, &name, &number, &flags);
- if (option_debug)
- ast_log(LOG_DEBUG, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
+ ast_debug(1, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
}
if (distinctiveringaftercid == 1) {
/* Clear the current ring data array so we dont have old data in it. */
ast_log(LOG_WARNING, "Unable to set cancel type to asynchronous\n");
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor starting...\n");
+ ast_debug(1, "Monitor starting...\n");
#endif
for (;;) {
/* Lock the interface list */
res = has_voicemail(last);
if (last->msgstate != res) {
int x;
- if (option_debug)
- ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
+ ast_debug(1, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
x = ZT_FLUSH_BOTH;
res2 = ioctl(last->subs[SUB_REAL].zfd, ZT_FLUSH, &x);
if (res2)
res = zt_get_event(i->subs[SUB_REAL].zfd);
if (res)
{
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
} else {
ast_log(LOG_WARNING, "Read failed with %d: %s\n", res, strerror(errno));
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events -- race with chlock */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
continue;
}
res = zt_get_event(i->subs[SUB_REAL].zfd);
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
return 1;
#endif
} else if (par.rxisoffhook) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel);
+ ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
/* Not available when the other end is off hook */
return 0;
}
if (!backwards && (x >= pri->numchans))
break;
if (pri->pvts[x] && !pri->pvts[x]->inalarm && !pri->pvts[x]->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n",
- pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
+ ast_debug(1, "Found empty available channel %d/%d\n",
+ pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
return x;
}
if (backwards)
#endif
if (p && available(p, channelmatch, groupmatch, &busy, &channelmatched, &groupmatched)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using channel %d\n", p->channel);
- if (p->inalarm)
- goto next;
+ ast_debug(1, "Using channel %d\n", p->channel);
+ if (p->inalarm)
+ goto next;
callwait = (p->owner != NULL);
#ifdef HAVE_PRI
ast_log(LOG_NOTICE, "Failed to allocate place holder pseudo channel!\n");
p = NULL;
break;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n");
- }
+ } else
+ ast_debug(1, "Allocated placeholder pseudo channel\n");
+
p->pri = pri;
}
}
}
switch (x) {
case ZT_EVENT_OVERRUN:
- ast_log(LOG_DEBUG, "Overrun detected!\n");
+ ast_debug(1, "Overrun detected!\n");
break;
case ZT_EVENT_BADFCS:
- ast_log(LOG_DEBUG, "Bad FCS\n");
+ ast_debug(1, "Bad FCS\n");
break;
case ZT_EVENT_ABORT:
- ast_log(LOG_DEBUG, "HDLC Abort\n");
+ ast_debug(1, "HDLC Abort\n");
break;
case ZT_EVENT_ALARM:
ast_log(LOG_ERROR, "Alarm on link!\n");
}
break;
case MTP2_LINK_UP:
- ast_log(LOG_DEBUG, "MTP2 link up\n");
+ ast_debug(1, "MTP2 link up\n");
break;
case ISUP_EVENT_CPG:
chanpos = ss7_find_cic(linkset, e->cpg.cic);
case CPG_EVENT_INBANDINFO:
{
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, };
- ast_log(LOG_DEBUG, "Queuing frame PROGRESS on CIC %d\n", p->cic);
+ ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic);
zap_queue_frame(p, &f, ss7);
p->progress = 1;
}
break;
default:
- ast_log(LOG_DEBUG, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
+ ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
}
ast_mutex_unlock(&p->lock);
isup_rlc(ss7, e->rsc.call);
break;
case ISUP_EVENT_GRS:
- ast_log(LOG_DEBUG, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
+ ast_debug(1, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
chanpos = ss7_find_cic(linkset, e->grs.startcic);
if (chanpos < 0) {
ast_log(LOG_WARNING, "GRS on unconfigured CIC %d\n", e->grs.startcic);
ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.status, 1);
break;
case ISUP_EVENT_IAM:
- ast_log(LOG_DEBUG, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num);
+ ast_debug(1, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num);
chanpos = ss7_find_cic(linkset, e->iam.cic);
if (chanpos < 0) {
ast_log(LOG_WARNING, "IAM on unconfigured CIC %d\n", e->iam.cic);
} else
ss7_start_call(p, linkset);
} else {
- ast_log(LOG_DEBUG, "Call on CIC for unconfigured extension %s\n", p->exten);
+ ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten);
isup_rel(ss7, e->iam.call, -1);
}
ast_mutex_unlock(&p->lock);
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
+ ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
ast_mutex_lock(&p->lock);
zap_queue_frame(p, &f, linkset);
break;
}
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Blocking CIC %d\n", e->blo.cic);
+ ast_debug(1, "Blocking CIC %d\n", e->blo.cic);
ast_mutex_lock(&p->lock);
p->remotelyblocked = 1;
ast_mutex_unlock(&p->lock);
break;
}
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Unblocking CIC %d\n", e->ubl.cic);
+ ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic);
ast_mutex_lock(&p->lock);
p->remotelyblocked = 0;
ast_mutex_unlock(&p->lock);
}
break;
default:
- ast_log(LOG_DEBUG, "Unknown event %s\n", ss7_event2str(e->e));
+ ast_debug(1, "Unknown event %s\n", ss7_event2str(e->e));
break;
}
}
zt_close(crv->subs[SUB_REAL].zfd);
pri->pvts[principle]->call = crv->call;
pri_assign_bearer(crv, pri, pri->pvts[principle]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Assigning bearer %d/%d to CRV %d:%d\n",
- pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset,
- pri->trunkgroup, crv->channel);
+ ast_debug(1, "Assigning bearer %d/%d to CRV %d:%d\n",
+ pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset,
+ pri->trunkgroup, crv->channel);
wakeup_sub(crv, SUB_REAL, pri);
}
return principle;
pri_restart(pri->dchans[which]);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
+ ast_debug(1, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
} else if (fds[which].revents & POLLIN) {
e = pri_check_event(pri->dchans[which]);
}
break;
} else {
/* This is where we handle initial glare */
- ast_log(LOG_DEBUG, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n",
+ ast_debug(1, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n",
PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
chanpos = -1;
pri_assign_bearer(crv, pri, pri->pvts[chanpos]);
c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
pri->pvts[chanpos]->owner = &inuse;
- if (option_debug)
- ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
+ ast_debug(1, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
} else {
c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
}
zt_enable_ec(pri->pvts[chanpos]);
pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
pri->pvts[chanpos]->alerting = 1;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
- }
+ } else
+ ast_debug(1, "Deferring ringing notification because of extra digits to dial...\n");
+
#ifdef PRI_PROGRESS_MASK
if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) {
#else
}
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
+ ast_debug(1, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
+ ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
pri->pvts[chanpos]->dsp_features = 0;
}
if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n");
+ ast_debug(1, "Starting up GR-303 trunk now that we got CONNECT...\n");
x = ZT_START;
res = ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_HOOK, &x);
if (res < 0) {
if (res < 0) {
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", pri->pvts[chanpos]->channel);
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
+
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
} else if (pri->pvts[chanpos]->confirmanswer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
+ ast_debug(1, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
} else {
pri->pvts[chanpos]->subs[SUB_REAL].needanswer =1;
/* Enable echo cancellation if it's not on already */
if (pri->pvts[x] && pri->pvts[x]->resetting) {
chanpos = x;
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan,
- pri->pvts[chanpos]->prioffset, pri->span);
+ ast_debug(1, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan,
+ pri->pvts[chanpos]->prioffset, pri->span);
if (pri->pvts[chanpos]->realcall)
pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
else if (pri->pvts[chanpos]->owner) {
pri->pvts[chanpos]->setup_ack = 1;
/* Send any queued digits */
for (x = 0;x < strlen(pri->pvts[chanpos]->dialdest); x++) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
+ ast_debug(1, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
pri_information(pri->pri, pri->pvts[chanpos]->call,
pri->pvts[chanpos]->dialdest[x]);
}
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Event: %d\n", e->e);
+ ast_debug(1, "Event: %d\n", e->e);
}
}
ast_mutex_unlock(&pri->lock);
if (option_verbose > 0)
ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading zaptel configuration.\n");
while (iflist) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying zaptel channel no. %d\n", iflist->channel);
+ ast_debug(1, "Destroying zaptel channel no. %d\n", iflist->channel);
/* Also updates iflist: */
destroy_channel(NULL, iflist, 1);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n");
+ ast_debug(1, "Channels destroyed. Now re-reading config.\n");
if (setup_zap(1) != 0) {
ast_log(LOG_WARNING, "Reload channels from zap config failed!\n");
return 1;
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
continue;
}
/* if got exception */
if (fds[0].revents & POLLPRI)
return -1;
if (!(fds[0].revents & POLLOUT)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ ast_debug(1, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
ast_free(mybuf);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
if (sscanf(tmp, "v%x", version) != 1) {
if (strcmp(tmp, "u")) {
ret = iax_provision_build(&ied, version, template, force);
- if (ret && option_debug)
- ast_log(LOG_DEBUG, "Unable to create provisioning packet for '%s'\n", template);
+ if (ret)
+ ast_debug(1, "Unable to create provisioning packet for '%s'\n", template);
} else
ret = -1;
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
+ } else
+ ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
ast_mutex_unlock(&provlock);
return ret;
}
info.op = ZT_TCOP_GETINFO;
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0) {
- ast_log(LOG_DEBUG, "No Zaptel transcoder support!\n");
+ ast_debug(1, "No Zaptel transcoder support!\n");
return 0;
}
for (info.tcnum = 0; !(res = ioctl(fd, ZT_TRANSCODE_OP, &info)); info.tcnum++) {
{
struct g726_desc *s = (struct g726_desc *)tmp->private;
s->rate = rate;
- if (option_debug)
- ast_log(LOG_DEBUG, "Created filestream G.726-%dk.\n",
- 40 - s->rate * 8);
+ ast_debug(1, "Created filestream G.726-%dk.\n", 40 - s->rate * 8);
return 0;
}
}
for (ptr = tmp->vc.user_comments; *ptr; ptr++)
- ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr);
- ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
- ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
+ ast_debug(1, "OGG/Vorbis comment: %s\n", *ptr);
+ ast_debug(1, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
+ ast_debug(1, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
if (tmp->vi.channels != 1) {
ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");
bytes = fs->maxlen - here;
if (bytes < 0)
bytes = 0;
-/* ast_log(LOG_DEBUG, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
+/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
}
if (ast_db_get(args.family, args.key, buf, len - 1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family,
- args.key);
+ ast_debug(1, "DB: %s/%s not found in database.\n", args.family, args.key);
} else
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
}
if (ast_db_get(args.family, args.key, buf, len - 1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key);
+ ast_debug(1, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key);
} else {
if (ast_db_del(args.family, args.key)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DB_DELETE: %s/%s could not be deleted from the database\n",
- args.family, args.key);
+ ast_debug(1, "DB_DELETE: %s/%s could not be deleted from the database\n", args.family, args.key);
}
}
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
incount = strlen(args.text);
- if (option_debug)
- ast_log(LOG_DEBUG, "Iconv: \"%s\" %s -> %s\n", args.text, args.in_charset, args.out_charset);
+ ast_debug(1, "Iconv: \"%s\" %s -> %s\n", args.text, args.in_charset, args.out_charset);
cd = iconv_open(args.out_charset, args.in_charset);
max_int = min_int;
min_int = tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "max<min\n");
+ ast_debug(1, "max<min\n");
}
response_int = min_int + (ast_random() % (max_int - min_int + 1));
- if (option_debug)
- ast_log(LOG_DEBUG, "%d was the lucky number in range [%d,%d]\n",
- response_int, min_int, max_int);
+ ast_debug(1, "%d was the lucky number in range [%d,%d]\n", response_int, min_int, max_int);
snprintf(buffer, buflen, "%d", response_int);
ast_module_user_remove(u);
if ((*args.str == ' ') || (*args.str == '\t'))
args.str++;
- if (option_debug)
- ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
+ ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
if ((errcode = regcomp(®exbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
regerror(errcode, ®exbuf, buf, len);
* want them to be surprised by the result. Hence, we prefer commas as the
* delimiter, but we'll fall back to vertical bars if commas aren't found.
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2);
+ ast_debug(1, "array (%s=%s)\n", var, value2);
if (strchr(var, ','))
AST_NONSTANDARD_APP_ARGS(arg1, var, ',');
else
AST_STANDARD_APP_ARGS(arg2, value2);
for (i = 0; i < arg1.argc; i++) {
- if (option_debug)
- ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i],
+ ast_debug(1, "array set value (%s=%s)\n", arg1.var[i],
arg2.val[i]);
if (i < arg2.argc) {
if (ishash) {
}
- if (option_debug)
- ast_log(LOG_DEBUG, "VERSION returns %s result, given %s argument\n",
- response_char, args.info);
+ ast_debug(1, "VERSION returns %s result, given %s argument\n", response_char, args.info);
snprintf(buffer, buflen, "%s", response_char);
ast_module_user_remove(u);
ret = ha;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
+ ast_debug(1, "%s/%s appended to acl for peer\n", stuff, nm);
return ret;
}
/* DEBUG */
ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf));
ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2));
- if (option_debug)
- ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
+ ast_debug(1, "##### Testing %s with %s\n", iabuf, iabuf2);
/* For each rule, if this address and the netmask = the net address
apply the current rule */
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)
#define build_stub(func_name,...) \
static int stub_##func_name(__VA_ARGS__) \
{ \
- if (option_debug > 4) \
- ast_log(LOG_DEBUG, "ADSI support not loaded!\n"); \
+ ast_debug(5, "ADSI support not loaded!\n"); \
return -1; \
} \
\
/* We go at next loop if we got the restart char */
if (restart && strchr(restart, res)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
+ ast_debug(1, "we'll restart the stream here at next loop\n");
pause_restart_point = 0;
continue;
}
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
+ ast_debug(1, "play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
if (playfile || beep) {
stringp = fmts;
strsep(&stringp, "|");
- if (option_debug)
- ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts);
+ ast_debug(1, "Recording Formats: sfmts=%s\n", fmts);
sfmt[0] = ast_strdupa(fmts);
while ((fmt = strsep(&stringp, "|"))) {
for (;;) {
res = ast_waitfor(chan, 2000);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
+ ast_debug(1, "One waitfor failed, trying another\n");
/* Try one more time in case of masq */
res = ast_waitfor(chan, 2000);
if (!res) {
ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno));
return AST_LOCK_TIMEOUT;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
+ ast_debug(1, "Locked path '%s'\n", path);
return AST_LOCK_SUCCESS;
}
}
if ((res = unlink(s)))
ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
+ ast_debug(1, "Unlocked path '%s'\n", path);
}
return res;
while (menu->options[pos].option) {
if (!strcasecmp(menu->options[pos].option, exten)) {
res = ivr_dispatch(chan, menu->options + pos, exten, cbdata);
- if (option_debug)
- ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
+ ast_debug(1, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
if (res < 0)
break;
else if (res & RES_UPONE)
if (!maxretries)
maxretries = 3;
if ((maxretries > 0) && (retries >= maxretries)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries);
+ ast_debug(1, "Max retries %d exceeded\n", maxretries);
return -2;
} else {
if (option_exists(menu, "g") > -1)
pos = 0;
continue;
} else if (res && strchr(AST_DIGIT_ANY, res)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got start of extension, %c\n", res);
+ ast_debug(1, "Got start of extension, %c\n", res);
exten[1] = '\0';
exten[0] = res;
if ((res = read_newoption(chan, menu, exten, sizeof(exten))))
break;
if (option_exists(menu, exten) < 0) {
if (option_exists(menu, "i")) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n");
+ ast_debug(1, "Invalid extension entered, going to 'i'!\n");
strcpy(exten, "i");
pos = 0;
continue;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n");
+ ast_debug(1, "Aborting on invalid entry, with no 'i' option!\n");
res = -2;
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "New existing extension: %s\n", exten);
+ ast_debug(1, "New existing extension: %s\n", exten);
pos = 0;
continue;
}
}
pos++;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res);
+ ast_debug(1, "Stopping option '%s', res is %d\n", exten, res);
pos = 0;
if (!strcasecmp(exten, "s"))
strcpy(exten, "g");
/* Called on exit */
if (option_verbose && ast_opt_console)
ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num);
+ ast_debug(1, "Asterisk ending (%d).\n", num);
manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False");
if (ast_socket > -1) {
pthread_cancel(lthread);
number[0] = 0;
if (strlen(cidstring) < 2) {
- ast_log(LOG_DEBUG, "No cid detected\n");
+ ast_debug(1, "No cid detected\n");
*flags = CID_UNKNOWN_NUMBER;
return;
}
else if (code == 10)
*flags = CID_PRIVATE_NUMBER;
else
- ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code);
+ ast_debug(1, "Unknown DTMF code %d\n", code);
} else if (cidstring[0] == 'D' && cidstring[2] == '#') {
/* .DK special code */
if (cidstring[1] == '1')
if (isdigit(cidstring[i]))
number[i-1] = cidstring[i];
else
- ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n",
+ ast_debug(1, "Unknown CID digit '%c'\n",
cidstring[i]);
}
number[i-1] = 0;
}
number[i] = 0;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", cidstring[0]);
+ ast_debug(1, "Unknown CID protocol, start digit '%c'\n", cidstring[0]);
*flags = CID_UNKNOWN_NUMBER;
}
}
case 0x06: /* short dial number */
case 0x07: /* reserved */
default: /* reserved */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]);
+ ast_debug(2, "cid info:#1=%X\n", cid->rawdata[x]);
break ;
}
x++;
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]);
+ ast_debug(2, "cid info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
case 'C': /* pay phone */
case 'S': /* service congested */
cid->flags |= CID_UNKNOWN_NUMBER;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]);
+ ast_debug(2, "no cid reason:%c\n",cid->rawdata[x]);
break ;
}
x++;
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]);
+ ast_debug(2, "did info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
/* if configured, spawn a new thread to post these CDRs,
also try to save as much as possible if we are shutting down safely */
if (batchscheduleronly || shutdown) {
- if (option_debug)
- ast_log(LOG_DEBUG, "CDR single-threaded batch processing begins now\n");
+ ast_debug(1, "CDR single-threaded batch processing begins now\n");
do_batch_backend_process(oldbatchitems);
} else {
if (ast_pthread_create_detached_background(&batch_post_thread, NULL, do_batch_backend_process, oldbatchitems)) {
ast_log(LOG_WARNING, "CDR processing thread could not detach, now trying in this thread\n");
do_batch_backend_process(oldbatchitems);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "CDR multi-threaded batch processing begins now\n");
+ ast_debug(1, "CDR multi-threaded batch processing begins now\n");
}
}
}
/* maybe they disabled CDR stuff completely, so just drop it */
if (!enabled) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping CDR !\n");
+ ast_debug(1, "Dropping CDR !\n");
ast_set_flag(cdr, AST_CDR_FLAG_POST_DISABLED);
ast_cdr_free(cdr);
return;
}
/* otherwise, each CDR gets put into a batch list (at the end) */
- if (option_debug)
- ast_log(LOG_DEBUG, "CDR detaching from this thread\n");
+ ast_debug(1, "CDR detaching from this thread\n");
/* we'll need a new tail for every CDR */
if (!(newtail = ast_calloc(1, sizeof(*newtail)))) {
ast_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
numevents = ast_sched_runq(sched);
ast_mutex_unlock(&cdr_pending_lock);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Processed %d scheduled CDR batches from the run queue\n", numevents);
+ ast_debug(2, "Processed %d scheduled CDR batches from the run queue\n", numevents);
}
return NULL;
chan->tech = tech;
AST_LIST_INSERT_HEAD(&backends, chan, list);
- if (option_debug)
- ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
+ ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->tech->type,
{
struct chanlist *chan;
- if (option_debug)
- ast_log(LOG_DEBUG, "Unregistering channel type '%s'\n", tech->type);
+ ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
AST_RWLIST_WRLOCK(&channels);
ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name);
CRASH;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
+ ast_debug(1, "Dropping voice to exceptionally long queue on %s\n", chan->name);
ast_frfree(f);
ast_channel_unlock(chan);
return 0;
/* this is slightly unsafe, as we _should_ hold the lock to access c->name */
done = c == NULL || ast_channel_trylock(c) == 0;
if (!done) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
+ ast_debug(1, "Avoiding %s for channel '%p'\n", msg, c);
if (retries == 9) {
/* We are about to fail due to a deadlock, so report this
* while we still have the list lock.
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n", c, retries);
+ ast_debug(1, "Failure, could not lock '%p' after %d retries!\n", c, retries);
/* As we have deadlocked, we will skip this channel and
* see if there is another match.
* NOTE: No point doing this for a full-name match,
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s added to channel %s\n",
- spy->type, chan->name);
+ ast_debug(1, "Spy %s added to channel %s\n",
+ spy->type, chan->name);
return 0;
}
}
/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
+ ast_debug(1, "Spy %s removed from channel %s\n", spy->type, chan->name);
ast_mutex_unlock(&spy->lock);
/*! \brief Softly hangup a channel, don't lock */
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
{
- if (option_debug)
- ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
/* Inform channel driver that we need to be hung up, if it cares */
chan->_softhangup |= cause;
ast_queue_frame(chan, &ast_null_frame);
trans->path = NULL;
}
if (!trans->path) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
+ ast_debug(1, "Building translator from %s to SLINEAR for spies on channel %s\n",
ast_getformatname(f->subclass), chan->name);
if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n",
if (dir == SPY_WRITE) {
ast_set_flag(spy, CHANSPY_TRIGGER_WRITE);
ast_clear_flag(spy, CHANSPY_TRIGGER_READ);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to write-trigger mode\n",
- spy->type, chan->name);
+ ast_debug(1, "Switching spy '%s' on '%s' to write-trigger mode\n",
+ spy->type, chan->name);
}
break;
case CHANSPY_TRIGGER_WRITE:
if (dir == SPY_READ) {
ast_set_flag(spy, CHANSPY_TRIGGER_READ);
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to read-trigger mode\n",
- spy->type, chan->name);
+ ast_debug(1, "Switching spy '%s' on '%s' to read-trigger mode\n",
+ spy->type, chan->name);
}
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Triggering queue flush for spy '%s' on '%s'\n",
- spy->type, chan->name);
+ ast_debug(1, "Triggering queue flush for spy '%s' on '%s'\n",
+ spy->type, chan->name);
ast_set_flag(spy, CHANSPY_TRIGGER_FLUSH);
ast_cond_signal(&spy->trigger);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
- spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
+ ast_debug(1, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
+ spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
while (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) {
struct ast_frame *drop = AST_LIST_REMOVE_HEAD(&queue->list, frame_list);
queue->samples -= drop->samples;
CRASH;
}
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Hanging up channel '%s'\n", chan->name);
if (chan->tech->hangup)
res = chan->tech->hangup(chan);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name);
+ ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
}
ast_channel_unlock(chan);
res = generate(chan, tmp, 0, 160);
chan->generatordata = tmp;
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ ast_debug(1, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
return 0;
samples = 0;
data = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
+ ast_debug(1, "Scheduling timer at %d sample intervals\n", samples);
res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples);
c->timingfunc = func;
c->timingdata = data;
case AST_FRAME_CONTROL:
if (f->subclass == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
+ ast_debug(1, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
f = &ast_null_frame;
} else if (prestate == AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
+ ast_debug(1, "Dropping duplicate answer!\n");
ast_frfree(f);
f = &ast_null_frame;
} else {
int res;
if (chan->timingfunc) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n");
+ ast_debug(2, "Generator got voice, switching to phase locked mode\n");
ast_settimeout(chan, 0, NULL, NULL);
}
res = chan->generator->generate(chan, tmp, f->datalen, f->samples);
chan->generatordata = tmp;
if (res) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ ast_debug(2, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
} else if (f->frametype == AST_FRAME_CNG) {
if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Generator got CNG, switching to timed mode\n");
+ ast_debug(2, "Generator got CNG, switching to timed mode\n");
ast_settimeout(chan, 160, generator_force, chan);
}
}
int ast_internal_timing_enabled(struct ast_channel *chan)
{
int ret = ast_opt_internal_timing && chan->timingfd > -1;
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
+ ast_debug(5, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
return ret;
}
break;
}
if (ts && ts->data[0]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
+ ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
ast_playtones_start(chan,0,ts->data, 1);
res = 0;
} else if (condition == AST_CONTROL_PROGRESS) {
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
return 0;
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
+ ast_debug(1, "Prodding channel '%s'\n", chan->name);
a.subclass = chan->rawwriteformat;
a.data = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
/* writing */
*trans = ast_translator_build_path(*rawformat, *format);
ast_channel_unlock(chan);
- if (option_debug)
- ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name,
- direction ? "write" : "read", ast_getformatname(fmt));
+ ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
+ direction ? "write" : "read", ast_getformatname(fmt));
return 0;
}
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
- clone->name, original->name);
+ ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
+ clone->name, original->name);
if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->masq->name, original->name);
clone->masqr = original;
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clone, &ast_null_frame);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
+ ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
res = 0;
}
newvar = ast_var_assign(&varname[1], ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
- if (option_debug)
- ast_log(LOG_DEBUG, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
+ ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
}
break;
case 2:
newvar = ast_var_assign(ast_var_full_name(current), ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
- if (option_debug)
- ast_log(LOG_DEBUG, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
+ ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Not copying variable %s.\n", ast_var_name(current));
+ ast_debug(1, "Not copying variable %s.\n", ast_var_name(current));
break;
}
}
char masqn[100];
char zombn[100];
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
- clone->name, clone->_state, original->name, original->_state);
+ ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
+ clone->name, clone->_state, original->name, original->_state);
manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n",
clone->name, ast_state2str(clone->_state), original->name, ast_state2str(original->_state));
/* We need the clone's lock, too */
ast_channel_lock(clone);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
+ ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
/* Having remembered the original read/write formats, we turn off any translation on either
one */
/* Copy the music class */
ast_string_field_set(original, musicclass, clone->musicclass);
- if (option_debug)
- ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+ ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */
if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
+ ast_debug(1, "Destroying channel clone '%s'\n", clone->name);
ast_channel_unlock(clone);
manager_event(EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n"
);
ast_channel_free(clone);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
+ ast_debug(1, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &ast_null_frame);
ast_channel_unlock(clone);
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state);
+ ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state);
return 0;
}
if (!f) {
*fo = NULL;
*rc = who;
- if (option_debug)
- ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
+ ast_debug(1, "Didn't get a frame from channel: %s\n",who->name);
break;
}
*fo = f;
*rc = who;
bridge_exit = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
break;
}
if (bridge_exit)
f->frametype == AST_FRAME_DTMF_BEGIN)) {
*fo = f;
*rc = who;
- if (option_debug)
- ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n",
- f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
- who->name);
+ ast_debug(1, "Got DTMF %s on channel (%s)\n",
+ f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
+ who->name);
break;
}
/* Write immediately frames, not passed through jb */
c1->_softhangup = 0;
c0->_bridge = c1;
c1->_bridge = c0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n");
+ ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
continue;
}
if (who)
*rc = who;
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
- c0->name, c1->name,
- ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c0) ? "Yes" : "No",
- ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c1) ? "Yes" : "No");
+ ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
+ c0->name, c1->name,
+ ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
+ ast_check_hangup(c0) ? "Yes" : "No",
+ ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
+ ast_check_hangup(c1) ? "Yes" : "No");
break;
}
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
+ ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
+ ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
return res;
}
ast_activate_generator(chan, &silence_generator, state);
- if (option_debug)
- ast_log(LOG_DEBUG, "Started silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Started silence generator on '%s'\n", chan->name);
return state;
}
ast_deactivate_generator(chan);
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopped silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
if (ast_set_write_format(chan, state->old_write_format) < 0)
ast_log(LOG_ERROR, "Could not return write format to its original state\n");
int ast_channel_unlock(struct ast_channel *chan)
{
int res = 0;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name);
+ ast_debug(3, "::::==== Unlocking AST channel %s\n", chan->name);
if (!chan) {
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
+ ast_debug(1, "::::==== Unlocking non-existing channel \n");
return 0;
}
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
+ ast_debug(3, ":::=== Still have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was unlocked\n", chan->name);
if (res == EINVAL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
+ ast_debug(3, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
}
}
if (res == EPERM) {
/* We had no lock, so okay any way*/
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked at all \n", chan->name);
+ ast_debug(4, "::::==== Channel %s was not locked at all \n", chan->name);
res = 0;
}
return res;
{
int res;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name);
+ ast_debug(4, "====:::: Locking AST channel %s\n", chan->name);
res = ast_mutex_lock(&chan->lock);
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ ast_debug(4, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ ast_debug(4, "::::==== Channel %s was locked\n", chan->name);
if (res == EDEADLK) {
/* We had no lock, so okey any way */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
+ ast_debug(4, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
}
if (res == EINVAL) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
+ ast_debug(4, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
}
}
return res;
{
int res;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "====:::: Trying to lock AST channel %s\n", chan->name);
+ ast_debug(3, "====:::: Trying to lock AST channel %s\n", chan->name);
res = ast_mutex_trylock(&chan->lock);
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ ast_debug(3, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was locked\n", chan->name);
if (res == EBUSY) {
/* We failed to lock */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
+ ast_debug(3, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
}
if (res == EDEADLK) {
/* We had no lock, so okey any way*/
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
}
- if (res == EINVAL && option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
+ if (res == EINVAL)
+ ast_debug(3, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
}
return res;
}
fflush(stdout);
}
if (!(f = fopen(fn, "r"))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
+ ast_debug(1, "No file to parse: %s\n", fn);
if (option_verbose > 1)
ast_verbose( "Not found (%s)\n", strerror(errno));
continue;
}
count++;
- if (option_debug)
- ast_log(LOG_DEBUG, "Parsing %s\n", fn);
+ ast_debug(1, "Parsing %s\n", fn);
if (option_verbose > 1)
ast_verbose("Found\n");
while (!feof(f)) {
if ((option_verbose > 1) && !option_debug)
ast_verbose("Saved\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn);
+ ast_debug(1, "Unable to open for writing: %s\n", fn);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno));
return -1;
/* Be sure to NULL terminate our data either way */
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ ast_debug(1, "Unable to find key '%s' in family '%s'\n", keys, family);
} else {
#if 0
printf("Got value of size %d\n", data.size);
ast_mutex_unlock(&dblock);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ ast_debug(1, "Unable to find key '%s' in family '%s'\n", keys, family);
}
return res;
}
}
if (provider) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
+ ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
return getproviderstate(provider, number);
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "No provider found, checking channel drivers for %s - %s\n", tech, number);
+ ast_debug(4, "No provider found, checking channel drivers for %s - %s\n", tech, number);
if (!(chan_tech = ast_get_channel_tech(tech)))
return AST_DEVICE_INVALID;
AST_RWLIST_RDLOCK(&devstate_provs);
AST_RWLIST_TRAVERSE(&devstate_provs, devprov, list) {
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "Checking provider %s with %s\n", devprov->label, provider);
+ ast_debug(5, "Checking provider %s with %s\n", devprov->label, provider);
if (!strcasecmp(devprov->label, provider)) {
res = devprov->callback(address);
struct ast_event *event;
state = ast_device_state(device);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));
+ ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));
if (!(event = ast_event_new(AST_EVENT_DEVICE_STATE,
AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device,
struct state_change *change;
char *tmp = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf);
+ ast_debug(3, "Notification of state change to be queued on device/channel %s\n", buf);
device = buf;
/* Ensure required arguments are passed */
if (!dial || (!chan && !async)) {
- ast_log(LOG_DEBUG, "invalid #1\n");
+ ast_debug(1, "invalid #1\n");
return AST_DIAL_RESULT_INVALID;
}
/* If there are no channels to dial we can't very well try to dial them */
if (AST_LIST_EMPTY(&dial->channels)) {
- ast_log(LOG_DEBUG, "invalid #2\n");
+ ast_debug(1, "invalid #2\n");
return AST_DIAL_RESULT_INVALID;
}
ret = -1;
}
else if (ret == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname);
+ ast_debug(1, "No matches found in DNS for %s\n", dname);
ret = 0;
}
else
#ifndef BUSYDETECT_TONEONLY
#if 1
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+ ast_debug(1, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
}
#endif
#endif
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
dsp->f.subclass = AST_CONTROL_BUSY;
- if (option_debug)
- ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
+ ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
return &dsp->f;
}
if ((dsp->features & DSP_FEATURE_DTMF_DETECT)) {
{
dsp->busy_tonelength = tonelength;
dsp->busy_quietlength = quietlength;
- if (option_debug)
- ast_log(LOG_DEBUG, "dsp busy pattern set to %d,%d\n", tonelength, quietlength);
+ ast_debug(1, "dsp busy pattern set to %d,%d\n", tonelength, quietlength);
}
void ast_dsp_digitreset(struct ast_dsp *dsp)
return -1;
}
- if (option_debug > 2) /* Advanced NAPTR debugging */
- ast_log(LOG_DEBUG, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n",
- naptrinput, flags, services, regexp, repl);
+ ast_debug(3, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n",
+ naptrinput, flags, services, regexp, repl);
if (tolower(flags[0]) != 'u') {
ast_log(LOG_WARNING, "NAPTR Flag must be 'U' or 'u'.\n");
}
}
- ast_log(LOG_DEBUG, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n",
+ ast_debug(1, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n",
number, tech, suffix, context->options, context->position);
if (pos > 128)
if (suffix) {
ast_copy_string(tmp + newpos, suffix, sizeof(tmp) - newpos);
ret = ast_search_dns(context, tmp, C_IN, T_NAPTR, enum_callback);
- ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
+ ast_debug(1, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
} else {
ret = -1; /* this is actually dead code since the demise of app_enum.c */
for (;;) {
ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos);
ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback);
- ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
+ ast_debug(1, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
if (ret > 0)
break;
}
}
if (ret < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno));
+ ast_debug(1, "No such number found: %s (%s)\n", tmp, strerror(errno));
strcpy(dst, "0");
ret = 0;
}
break;
}
if (ret < 0) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno));
+ ast_debug(2, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno));
ret = 0;
}
if (chan)
if (!fs->vfs && fs->filename) {
const char *type = ast_getformatname(f->subclass & ~0x1);
fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
- if (option_debug)
- ast_log(LOG_DEBUG, "Opened video output file\n");
+ ast_debug(1, "Opened video output file\n");
}
if (fs->vfs)
return ast_writestream(fs->vfs, f);
if (fs)
vfs = ast_openvstream(chan, filename, preflang);
if (vfs) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
+ ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
}
if (fs){
if (ast_applystream(chan, fs))
if (ret & AST_FORMAT_AUDIO_MASK)
return ret;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec");
+ ast_debug(4, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec");
return find_best ? ast_best_codec(formats) : 0;
}
framems = 0;
if ((psize = strrchr(this, ':'))) {
*psize++ = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG,"Packetization for codec: %s is %s\n", this, psize);
+ ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
framems = atoi(psize);
if (framems < 0) {
framems = 0;
for(;;) {
if (((res = ast_waitfor(chan, waittime)) < 1)) {
/* Didn't get back DTMF A in time */
- if (option_debug)
- ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res);
+ ast_debug(1, "No ADSI CPE detected (%d)\n", res);
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_UNAVAILABLE;
errno = ENOSYS;
waittime = res;
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup in ADSI\n");
+ ast_debug(1, "Hangup in ADSI\n");
return -1;
}
if (f->frametype == AST_FRAME_DTMF) {
break;
} else {
if (f->subclass == 'D') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n");
+ ast_debug(1, "Off-hook capable CPE only, not ADSI\n");
} else
ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass);
if (!chan->adsicpe)
ast_frfree(f);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n");
+ ast_debug(1, "ADSI Compatible CPE Detected\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already in data mode\n");
+ ast_debug(1, "Already in data mode\n");
}
x = 0;
ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n",
- x + 1, msglen[x], res);
+ ast_debug(1, "Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res);
pos += res;
x++;
}
if (res)
return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos);
+ ast_debug(1, "Sent total spill of %d bytes\n", pos);
memset(ack, 0, sizeof(ack));
/* Get real result */
if (res < 0)
return -1;
if (ack[0] == 'D') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1));
- start += atoi(ack + 1);
+ ast_debug(1, "Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1);
if (start >= x)
break;
else {
retries++;
- if (option_debug)
- ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1);
+ ast_debug(1, "Retransmitting (%d), from %d\n", retries, start + 1);
}
} else {
retries++;
return -1;
if (ack[0] == 'B')
return 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Download was denied by CPE\n");
+ ast_debug(1, "Download was denied by CPE\n");
return -1;
}
for (x=0;x<msglen;x+=(msg[x+1]+2)) {
if (msg[x] == ADSI_SWITCH_TO_DATA) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Switch to data is sent!\n");
+ ast_debug(1, "Switch to data is sent!\n");
waitforswitch++;
newdatamode = ADSI_FLAG_DATAMODE;
}
if (msg[x] == ADSI_SWITCH_TO_VOICE) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Switch to voice is sent!\n");
+ ast_debug(1, "Switch to voice is sent!\n");
waitforswitch++;
newdatamode = 0;
}
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
if (dowait) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch);
+ ast_debug(1, "Wait for switch is '%d'\n", waitforswitch);
while (waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) {
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Waiting for 'B'...\n");
+ ast_debug(1, "Waiting for 'B'...\n");
}
}
if (res < 0)
return -1;
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n");
+ ast_debug(1, "No response from CPE about version. Assuming not there.\n");
return 0;
}
if (!strcmp(resp, "B")) {
- if (option_debug)
- ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver);
+ ast_debug(1, "CPE has script '%s' version %d already loaded\n", app, ver);
return 1;
} else if (!strcmp(resp, "A")) {
- if (option_debug)
- ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
+ ast_debug(1, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
} else {
ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp);
}
if (!ast_strlen_zero(script))
fdprintf(s, "agi_network_script: %s\n", script);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Wow, connected!\n");
+ ast_debug(4, "Wow, connected!\n");
fds[0] = s;
fds[1] = s;
*opid = -1;
return RESULT_SUCCESS;
}
vfs = ast_openvstream(chan, argv[2], chan->language);
- if (vfs && option_debug)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
+ ast_debug(vfs && 1, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (sample_offset %ld)\n", argv[2], edigits, sample_offset);
return RESULT_SUCCESS;
}
vfs = ast_openvstream(chan, argv[2], chan->language);
- if (vfs && option_debug)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
+ ast_debug(vfs && 1, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (timeout %d)\n", argv[2], edigits, timeout);
/* Idle the channel until we get a command */
f = ast_read(c);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s hungup\n", chan->name);
+ ast_debug(1, "%s hungup\n", chan->name);
returnstatus = AGI_RESULT_HANGUP;
break;
} else {
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return NULL;
} else {
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
+ ast_debug(1, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
if ((num_rows = PQntuples(result)) > 0) {
int i = 0;
int numFields = PQnfields(result);
char **fieldnames = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+ ast_debug(1, "Postgresql RealTime: Found %d rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return NULL;
} else {
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
+ ast_debug(1, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
if ((num_rows = PQntuples(result)) > 0) {
int numFields = PQnfields(result);
int rowIndex = 0;
char **fieldnames = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+ ast_debug(1, "Postgresql RealTime: Found %d rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield,
lookup);
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Update SQL: %s\n", sql);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return -1;
} else {
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return -1;
}
numrows = atoi(PQcmdTuples(result));
ast_mutex_unlock(&pgsql_lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows,
- table);
+ ast_debug(1, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows, table);
/* From http://dev.pgsql.com/doc/pgsql/en/pgsql-affected-rows.html
* An integer greater than zero indicates the number of rows affected
ast_build_string(&sql, &sqlleft, "WHERE filename='%s' and commented=0", file);
ast_build_string(&sql, &sqlleft, "ORDER BY cat_metric DESC, var_metric ASC, category, var_name ");
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sqlbuf);
+ ast_debug(1, "Postgresql RealTime: Static SQL: %s\n", sqlbuf);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
if (!(result = PQexec(pgsqlConn, sqlbuf))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return NULL;
} else {
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
if ((num_rows = PQntuples(result)) > 0) {
int rowIndex = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows);
+ ast_debug(1, "Postgresql RealTime: Found %ld rows.\n", num_rows);
for (rowIndex = 0; rowIndex < num_rows; rowIndex++) {
char *field_category = PQgetvalue(result, rowIndex, 0);
if (!pgsql_reconnect(NULL)) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQerrorMessage(pgsqlConn));
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
}
ast_config_engine_register(&pgsql_engine);
if (!pgsql_reconnect(NULL)) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQerrorMessage(pgsqlConn));
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
}
ast_verbose(VERBOSE_PREFIX_2 "Postgresql RealTime reloaded.\n");
if (option_debug) {
if (dbhost) {
- ast_log(LOG_DEBUG, "Postgresql RealTime Host: %s\n", dbhost);
- ast_log(LOG_DEBUG, "Postgresql RealTime Port: %i\n", dbport);
+ ast_debug(1, "Postgresql RealTime Host: %s\n", dbhost);
+ ast_debug(1, "Postgresql RealTime Port: %i\n", dbport);
} else {
- ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock);
+ ast_debug(1, "Postgresql RealTime Socket: %s\n", dbsock);
}
- ast_log(LOG_DEBUG, "Postgresql RealTime User: %s\n", dbuser);
- ast_log(LOG_DEBUG, "Postgresql RealTime Password: %s\n", dbpass);
- ast_log(LOG_DEBUG, "Postgresql RealTime DBName: %s\n", dbname);
+ ast_debug(1, "Postgresql RealTime User: %s\n", dbuser);
+ ast_debug(1, "Postgresql RealTime Password: %s\n", dbpass);
+ ast_debug(1, "Postgresql RealTime DBName: %s\n", dbname);
}
return 1;
sprintf(connInfo, "host=%s port=%d dbname=%s user=%s password=%s",
dbhost, dbport, my_database, dbuser, dbpass);
- if (option_debug)
- ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
+ ast_debug(1, "%u connInfo=%s\n", size, connInfo);
pgsqlConn = PQconnectdb(connInfo);
- if (option_debug)
- ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
+ ast_debug(1, "%u connInfo=%s\n", size, connInfo);
ast_free(connInfo);
connInfo = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn);
+ ast_debug(1, "pgsqlConn=%p\n", pgsqlConn);
if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n");
+ ast_debug(1, "Postgresql RealTime: Successfully connected to database.\n");
connect_time = time(NULL);
return 1;
} else {
ast_log(LOG_ERROR,
"Postgresql RealTime: Failed to connect database server %s on %s. Check debug for more info.\n",
dbname, dbhost);
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQresultErrorMessage(NULL));
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQresultErrorMessage(NULL));
return 0;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n");
+ ast_debug(1, "Postgresql RealTime: Everything is fine.\n");
return 1;
}
}
}
query = tmp_str;
- ast_log(LOG_DEBUG, "SQL query: %s\n", query);
+ ast_debug(1, "SQL query: %s\n", query);
args.var = NULL;
args.last = NULL;
sqlite_freemem(query);
query = tmp_str;
- ast_log(LOG_DEBUG, "SQL query: %s\n", query);
+ ast_debug(1, "SQL query: %s\n", query);
args.cfg = cfg;
args.initfield = initfield;
sqlite_freemem(query);
query = tmp_str;
- ast_log(LOG_DEBUG, "SQL query: %s\n", query);
+ ast_debug(1, "SQL query: %s\n", query);
ast_mutex_lock(&mutex);
key->ktype &= ~KEY_NEEDS_PASSCODE;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Loaded %s key '%s'\n", key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name);
- if (option_debug)
- ast_log(LOG_DEBUG, "Key '%s' loaded OK\n", key->name);
+ ast_debug(1, "Key '%s' loaded OK\n", key->name);
key->delme = 0;
} else
ast_log(LOG_NOTICE, "Key '%s' is not expected size.\n", key->name);
res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name);
+ ast_debug(1, "Key failed verification: %s\n", key->name);
return -1;
}
/* Pass */
while(key) {
nkey = key->next;
if (key->delme) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype);
+ ast_debug(1, "Deleting key %s type %d\n", key->name, key->ktype);
/* Do the delete */
if (last)
last->next = nkey;
/*! \brief Notify metermaids that we've changed an extension */
static void notify_metermaids(const char *exten, char *context)
{
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Notification of state change to metermaids %s@%s\n", exten, context);
+ ast_debug(4, "Notification of state change to metermaids %s@%s\n", exten, context);
/* Send notification to devicestate subsystem */
ast_device_state_changed("park:%s@%s", exten, context);
if (!context)
return res;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Checking state of exten %s in context %s\n", exten, context);
+ ast_debug(4, "Checking state of exten %s in context %s\n", exten, context);
res = ast_exists_extension(NULL, context, exten, 1, NULL);
struct ast_frame *f;
int l;
- if (option_debug)
- ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
+ ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
set_peers(&transferer, &transferee, peer, chan, sense);
transferer_real_context = real_ctx(transferer, transferee);
/* Start autoservice on chan while we talk to the originator */
}
if (!newchan) {
/* Transfer failed, sleeping */
- if (option_debug)
- ast_log(LOG_DEBUG, "Sleeping for %d ms before callback.\n", atxferloopdelay);
+ ast_debug(1, "Sleeping for %d ms before callback.\n", atxferloopdelay);
ast_safe_sleep(transferee, atxferloopdelay);
- if (option_debug)
- ast_log(LOG_DEBUG, "Trying to callback...\n");
+ ast_debug(1, "Trying to callback...\n");
newchan = ast_feature_request_and_dial(transferee, NULL, "Local", ast_best_codec(transferee->nativeformats),
callbackto, atxfernoanswertimeout, &outstate, transferee->cid.cid_num, transferee->cid.cid_name, 0);
}
ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);
else
ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
+ ast_debug(3, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
ast_rwlock_rdlock(&features_lock);
for (x = 0; x < FEATURES_COUNT; x++) {
activated, but that's no excuse to keep things going
indefinitely! */
if (backup_config.feature_timer && ((backup_config.feature_timer -= diff) <= 0)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Timed out, realtime this time!\n");
+ ast_debug(1, "Timed out, realtime this time!\n");
config->feature_timer = 0;
who = chan;
if (f)
} else if (config->feature_timer <= 0) {
/* Not *really* out of time, just out of time for
digits to come in for features. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Timed out for feature!\n");
+ ast_debug(1, "Timed out for feature!\n");
if (!ast_strlen_zero(peer_featurecode)) {
ast_dtmf_stream(chan, peer, peer_featurecode, 0);
memset(peer_featurecode, 0, sizeof(peer_featurecode));
}
config->start_time = ast_tvnow();
config->feature_timer = featuredigittimeout;
- if (option_debug)
- ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer);
+ ast_debug(1, "Set time limit to %ld\n", config->feature_timer);
}
}
if (f)
/*! \todo XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
ast_frfree(f);
if (pu->moh_trys < 3 && !chan->generatordata) {
- if (option_debug)
- ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n");
+ ast_debug(1, "MOH on parked call stopped by outside source. Restarting.\n");
ast_indicate_data(chan, AST_CONTROL_HOLD,
S_OR(parkmohclass, NULL),
!ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
ast_channel_unlock(cur);
}
if (cur) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
+ ast_debug(1, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
res = ast_answer(chan);
if (res)
ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */
ast_channel_unlock(cur);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
+ ast_debug(1, "No call pickup possible...\n");
}
return res;
}
if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) {
if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar))
notify_metermaids(old_parking_ext, old_parking_con);
- if (option_debug)
- ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
+ ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
}
if (!(con = ast_context_find(parking_con)) && !(con = ast_context_create(NULL, parking_con, registrar))) {
/* the bridge has ended, set BRIDGERESULT to SUCCESS. If the other channel has not been hung up, return it to the PBX */
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS");
if (!ast_check_hangup(final_dest_chan)) {
- if (option_debug) {
- ast_log(LOG_DEBUG, "starting new PBX in %s,%s,%d for chan %s\n",
+ ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n",
final_dest_chan->context, final_dest_chan->exten,
final_dest_chan->priority, final_dest_chan->name);
- }
if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) {
ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", final_dest_chan->name);
ast_hangup(final_dest_chan);
- } else if (option_debug)
- ast_log(LOG_DEBUG, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name);
+ } else
+ ast_debug(1, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name);
+ ast_debug(1, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name);
ast_hangup(final_dest_chan);
}
switch (pak->type) {
case IKS_PAK_NONE:
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you NONE\n");
+ ast_debug(1, "JABBER: I Don't know what to do with you NONE\n");
break;
case IKS_PAK_MESSAGE:
aji_handle_message(client, pak);
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you MESSAGE\n");
+ ast_debug(1, "JABBER: I Don't know what to do with you MESSAGE\n");
break;
case IKS_PAK_PRESENCE:
aji_handle_presence(client, pak);
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Do know how to handle presence!!\n");
+ ast_debug(1, "JABBER: I Do know how to handle presence!!\n");
break;
case IKS_PAK_S10N:
aji_handle_subscribe(client, pak);
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Dont know S10N subscribe!!\n");
+ ast_debug(1, "JABBER: I Dont know S10N subscribe!!\n");
break;
case IKS_PAK_IQ:
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Dont have an IQ!!!\n");
+ ast_debug(1, "JABBER: I Dont have an IQ!!!\n");
aji_handle_iq(client, node);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Dont know %i\n", pak->type);
+ ast_debug(1, "JABBER: I Dont know %i\n", pak->type);
break;
}
if(gtalk_yuck(pak->x)) /* gtalk should do discover */
found->cap->jingle = 1;
if(found->cap->jingle && option_debug > 4) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Special case for google till they support discover.\n");
+ ast_debug(1,"Special case for google till they support discover.\n");
}
else {
iks *iq, *query;
res = iks_recv(client->p, 1);
if (client->state == AJI_DISCONNECTING) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Ending our Jabber client's thread due to a disconnect\n");
+ ast_debug(2, "Ending our Jabber client's thread due to a disconnect\n");
pthread_exit(NULL);
}
client->timeout--;
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
ASTOBJ_RDLOCK(iterator);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "JABBER: Releasing and disconneing client: %s\n", iterator->name);
+ ast_debug(3, "JABBER: Releasing and disconneing client: %s\n", iterator->name);
iterator->state = AJI_DISCONNECTING;
ast_aji_disconnect(iterator);
pthread_join(iterator->thread, NULL);
/* so we know this call has been monitored in case we need to bill for it or something */
pbx_builtin_setvar_helper(chan, "__MONITORED","true");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n",
- chan->name);
+ ast_debug(1,"Cannot start monitoring %s, already monitored\n", chan->name);
res = -1;
}
snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
ast_copy_string(tmp, tmp2, sizeof(tmp));
}
- if (option_debug)
- ast_log(LOG_DEBUG,"monitor executing %s\n",tmp);
+ ast_debug(1,"monitor executing %s\n",tmp);
if (ast_safe_system(tmp) == -1)
ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
}
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);
+ ast_debug(1, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);
if (state->samples)
ast_seekstream(chan->stream, state->samples, SEEK_SET);
class->pid = 0;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len);
+ ast_debug(1, "Read %d bytes of audio while expecting %d\n", res2, len);
}
continue;
}
AST_RWLIST_TRAVERSE(&class->members, moh, list) {
/* Write data */
if ((res = write(moh->pipe[1], sbuf, res2)) != res2) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
+ ast_debug(1, "Only wrote %d of %d bytes to pipe\n", res, res2);
}
}
AST_RWLIST_UNLOCK(&mohclasses);
AST_RWLIST_WRLOCK(&mohclasses);
if (get_mohbyname(moh->name)) {
if (reload) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name);
+ ast_debug(1, "Music on Hold class '%s' left alone from initial load.\n", moh->name);
} else {
ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name);
}
AST_RWLIST_WRLOCK(&mohclasses);
while ((moh = AST_RWLIST_REMOVE_HEAD(&mohclasses, list))) {
if (moh->pid > 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
+ ast_debug(1, "killing %d!\n", moh->pid);
stime = time(NULL) + 2;
pid = moh->pid;
moh->pid = 0;
kill(pid, SIGKILL);
while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime)
tbytes = tbytes + bytes;
- if (option_debug)
- ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
+ ast_debug(1, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
close(moh->srcfd);
}
ast_moh_free_class(&moh);
fclose(file);
ASTOBJ_UNLOCK(iface);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name);
+ ast_debug(1, "Sent MWI set message for %s on %s\n", mailbox, iface->name);
return 0;
}
fclose(file);
ASTOBJ_UNLOCK(iface);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name);
+ ast_debug(1, "Sent MWI unset message for %s on %s\n", mailbox, iface->name);
return 0;
}
/* add the message to the message queue */
md_msg->timestamp = ast_tvnow();
ast_smdi_md_message_push(iface, md_msg);
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name);
+ ast_debug(1, "Recieved SMDI MD message on %s\n", iface->name);
ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);
/* add the message to the message queue */
mwi_msg->timestamp = ast_tvnow();
ast_smdi_mwi_message_push(iface, mwi_msg);
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name);
+ ast_debug(1, "Recieved SMDI MWI message on %s\n", iface->name);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {