if(option_verbose >= 4)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: DTMF Digit Timeout on %s\n", chan->name);
- ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
res = 1;
break;
}
if ((r = ast_waitfor(chan, -1) < 0)) {
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", r);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waitfor returned %d\n", r);
continue;
}
res = fprintf(logfile, "[events]\n\n");
if(res < 0){
+ if (option_verbose >= 3 )
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n");
- ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n");
}
else
res = 0;
fd = mkstemp(workstring);
- if(fd == -1){
- ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't make temporary file\n");
- ast_log(LOG_DEBUG,"AlarmReceiver: can't make temporary file\n");
+ 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");
res = -1;
}
got_some_digits = 1;
- if(option_verbose >= 2)
+ if (option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Received Event %s\n", event);
- ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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");
- ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n");
continue;
}
database_increment("format-errors");
if(option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Wrong message type\n");
- ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n");
continue;
}
}
*/
if((!res) && (!ast_strlen_zero(event_app)) && (event_head)){
- ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app);
ast_safe_system(event_app);
}
family = strsep(&argv, "/");
keytree = strsep(&argv, "\0");
if (!family || !keytree) {
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
family = strsep(&argv, "/");
key = strsep(&argv, "\0");
if (!family || !key) {
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
}
ast_module_user_remove(u);
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]);
- ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
res = 0;
} else {
ast_log(LOG_ERROR, "Could not find application Macro\n");
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
+#include "asterisk/options.h"
#define PICKUPMARK "PICKUPMARK"
ast_mutex_unlock(&origin->lock);
} else {
- ast_log(LOG_DEBUG, "No originating channel found.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No originating channel found.\n");
}
if (res)
continue;
if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING) ) ) {
- ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
chan->name);
res = ast_answer(chan);
if (res) {
#include "asterisk/ulaw.h"
#include "asterisk/callerid.h"
#include "asterisk/stringfields.h"
+#include "asterisk/options.h"
static char *app = "DISA";
return -1;
}
- ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
- ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
+ ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
+ }
tmp = ast_strdupa(data);
if (ast_strlen_zero(args.mailbox))
args.mailbox = "";
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
-
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
special_noanswer = 0;
if ((!args.noanswer) || strcmp(args.noanswer,"NOANSWER"))
acctcode[0] = 0;
/* can we access DISA without password? */
- ast_log(LOG_DEBUG, "Context: %s\n",args.context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Context: %s\n",args.context);
if (!strcasecmp(args.passcode, "no-password")) {
k |= 1; /* We have the password */
- ast_log(LOG_DEBUG, "DISA no-password login success\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
- ((k&1) ? "extension" : "password"),chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
+ ((k&1) ? "extension" : "password"),chan->name);
break;
}
if ((res = ast_waitfor(chan, -1) < 0)) {
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
continue;
}
AST_STANDARD_APP_ARGS(args, pwline);
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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;
- ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
continue;
}
}
}
fprintf(handle, "%s\n", tmp);
- ast_chan_log(LOG_DEBUG, chan, "sent '%s'\n", tmp);
+ if (option_debug)
+ ast_chan_log(LOG_DEBUG, chan, "sent '%s'\n", tmp);
}
static void *gen_alloc(struct ast_channel *chan, void *params)
command = ast_strip(input);
- ast_chan_log(LOG_DEBUG, chan, "got command '%s'\n", input);
+ if (option_debug)
+ ast_chan_log(LOG_DEBUG, chan, "got command '%s'\n", input);
if (strlen(input) < 4)
continue;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "User pressed a key\n");
if (intkeys && strchr(intkeys, f->subclass)) {
res = f->subclass;
ast_frfree(f);
break;
}
if (res < needed) { /* last frame */
- ast_log(LOG_DEBUG, "Last frame\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Last frame\n");
res=0;
ast_frfree(f);
break;
}
} else {
- ast_log(LOG_DEBUG, "No more waveform\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No more waveform\n");
res = 0;
}
}
intstr = AST_DIGIT_ANY;
}
- ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
/* Connect to local festival server */
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (fd < 0) {
+ if (fd < 0) {
ast_log(LOG_WARNING,"festival_client: can't get socket\n");
ast_config_destroy(cfg);
ast_module_user_remove(u);
- return -1;
+ return -1;
}
- memset(&serv_addr, 0, sizeof(serv_addr));
- if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
- /* its a name rather than an ipnum */
- serverhost = ast_gethostbyname(host, &ahp);
- if (serverhost == (struct hostent *)0) {
- ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
+
+ memset(&serv_addr, 0, sizeof(serv_addr));
+
+ if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
+ /* its a name rather than an ipnum */
+ serverhost = ast_gethostbyname(host, &ahp);
+
+ if (serverhost == (struct hostent *)0) {
+ ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
ast_config_destroy(cfg);
ast_module_user_remove(u);
- return -1;
- }
- memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
- }
+ return -1;
+ }
+ memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
+ }
+
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
if (fdesc!=-1) {
writecache=1;
strln=strlen((char *)data);
- ast_log(LOG_DEBUG,"line length : %d\n",strln);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"line length : %d\n",strln);
write(fdesc,&strln,sizeof(int));
write(fdesc,data,strln);
seekpos=lseek(fdesc,0,SEEK_CUR);
- ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
}
} else {
read(fdesc,&strln,sizeof(int));
- ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
if (strlen((char *)data)==strln) {
- ast_log(LOG_DEBUG,"Size OK\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Size OK\n");
read(fdesc,&bigstring,strln);
bigstring[strln] = 0;
if (strcmp(bigstring,data)==0) {
if (readcache==1) {
close(fd);
fd=fdesc;
- ast_log(LOG_DEBUG,"Reading from cache...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Reading from cache...\n");
} else {
- ast_log(LOG_DEBUG,"Passing text to festival...\n");
- fs=fdopen(dup(fd),"wb");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Passing text to festival...\n");
+ fs=fdopen(dup(fd),"wb");
fprintf(fs,festivalcommand,(char *)data);
fflush(fs);
fclose(fs);
/* Write to cache and then pass it down */
if (writecache==1) {
- ast_log(LOG_DEBUG,"Writing result to cache...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Writing result to cache...\n");
while ((strln=read(fd,buffer,16384))!=0) {
write(fdesc,buffer,strln);
}
lseek(fd,seekpos,SEEK_SET);
}
- ast_log(LOG_DEBUG,"Passing data to channel...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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 */
- ast_log(LOG_DEBUG,"Festival WV command\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Festival WV command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
res = send_waveform_to_channel(chan,waveform,filesize, intstr);
free(waveform);
break;
}
else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
- ast_log(LOG_DEBUG,"Festival LP command\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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);
/* Wait for audio, and stream */
ms = ast_waitfor(chan, -1);
if (ms < 0) {
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
}
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
res = -1;
break;
}
/* If we are to run the macro exclusively, take the mutex */
if (exclusive) {
- ast_log(LOG_DEBUG, "Locking macrolock for '%s'\n", fullmacro);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
break;
}
switch(res) {
}
/* don't stop executing extensions when we're in "h" */
if (chan->_softhangup && strcasecmp(oldexten,"h") && strcasecmp(chan->macroexten,"h")) {
- 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);
+ 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);
goto out;
}
chan->priority++;
/* Unlock the macro */
if (exclusive) {
- ast_log(LOG_DEBUG, "Unlocking macrolock for '%s'\n", fullmacro);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
return RESULT_SUCCESS;
} else
return RESULT_SHOWUSAGE;
- ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
+
admin_exec(NULL, cmdline);
return 0;
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
ast_mutex_unlock(&conf->playlock);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
ret = 0;
ast_frfree(f);
break;
if (!cnf) {
if (dynamic) {
/* No need to parse meetme.conf */
- ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno);
}
ast_config_destroy(cfg);
}
struct ast_conference *conf;
struct ast_sla *sla, *sla2;
- ast_log(LOG_DEBUG, "asked for sla state for '%s'\n", data);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "asked for sla state for '%s'\n", data);
/* Find conference */
AST_LIST_LOCK(&confs);
sla = sla2 = ASTOBJ_CONTAINER_FIND(&slas, data);
ASTOBJ_UNREF(sla2, sla_destroy);
- ast_log(LOG_DEBUG, "for '%s' conf = %p, sla = %p\n", data, conf, sla);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "for '%s' conf = %p, sla = %p\n", data, conf, sla);
if (!conf && !sla)
return AST_DEVICE_INVALID;
break;
}
} else {
- ast_log(LOG_DEBUG, "No more mp3\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No more mp3\n");
res = 0;
break;
}
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
break;
}
} else {
- ast_log(LOG_DEBUG, "No more mp3\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No more mp3\n");
res = 0;
break;
}
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
- ast_log(LOG_DEBUG, "OSP: privatekey '%s'\n", p->privatekey);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
- ast_log(LOG_DEBUG, "OSP: localcert '%s'\n", p->localcert);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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]));
- ast_log(LOG_DEBUG, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "OSP: maxconnections '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "OSP: retrydelay '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "OSP: retrylimit '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "OSP: timeout '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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));
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", p->source);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
if (p->cacount < 1) {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s-cacert.pem", ast_config_AST_KEY_DIR, provider);
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
p->cacount++;
}
for (i = 0; i < p->cacount; i++) {
free(p);
res = -1;
} else {
- ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider);
ast_mutex_lock(&osplock);
p->next = ospproviders;
ospproviders = p;
while(p) {
if (!strcasecmp(p->name, provider)) {
*policy = p->authpolicy;
- ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", *policy);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", *policy);
res = 1;
break;
}
if (!strcasecmp(p->name, provider)) {
error = OSPPTransactionNew(p->handle, transaction);
if (error == OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction);
ast_copy_string(source, p->source, sourcesize);
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", source);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: source '%s'\n", source);
res = 1;
} else {
*transaction = OSP_INVALID_HANDLE;
- ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error);
res = -1;
}
break;
&dummy, NULL,
osp_tokenformat);
if (error != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n");
res = -1;
} else if (authorised) {
- ast_log(LOG_DEBUG, "OSP: Authorised\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Authorised\n");
res = 1;
} else {
- ast_log(LOG_DEBUG, "OSP: Unauthorised\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unauthorised\n");
res = 0;
}
int error;
if (strlen(destination) <= 2) {
- ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
if ((error = OSPPTransactionIsDestOSPEnabled(result->outhandle, &enabled)) != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
}
if ((error = OSPPTransactionGetDestProtocol(result->outhandle, &protocol)) != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
result->token[0] = '\0';
return -1;
destination[strlen(destination) - 1] = '\0';
switch(protocol) {
case OSPE_DEST_PROT_H323_SETUP:
- ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
ast_copy_string(result->tech, "H323", sizeof(result->tech));
snprintf(result->dest, sizeof(result->dest), "%s@%s", called, destination + 1);
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_SIP:
- ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
ast_copy_string(result->tech, "SIP", sizeof(result->tech));
snprintf(result->dest, sizeof(result->dest), "%s@%s", called, destination + 1);
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_IAX:
- ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
ast_copy_string(result->tech, "IAX", sizeof(result->tech));
snprintf(result->dest, sizeof(result->dest), "%s@%s", called, destination + 1);
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
default:
- ast_log(LOG_DEBUG, "OSP: Unknown protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unknown protocol '%d'\n", protocol);
*reason = OSPC_FAIL_PROTOCOL_ERROR;
result->token[0] = '\0';
res = 0;
*timelimit = OSP_DEF_TIMELIMIT;
res = osp_get_policy(provider, &policy);
if (!res) {
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP authentication policy\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unabe to find OSP authentication policy\n");
return res;
}
if (ast_strlen_zero(token)) {
res = 0;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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_create_transaction(provider, &result->outhandle, sizeof(source), source)) <= 0) {
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
error = OSPPTransactionRequestAuthorisation(result->outhandle, source, srcdev, calling ? calling : "",
OSPC_E164, called, OSPC_E164, NULL, 0, NULL, NULL, &result->numresults, &dummy, NULL);
if (error != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: No more destination\n");
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
}
error = OSPPTransactionGetFirstDestination(result->outhandle, 0, NULL, NULL, &result->outtimelimit, &callidlen, callid,
sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token);
if (error != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to get first route\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- 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);
+ 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);
+ }
if ((res = osp_check_destination(callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
return 1;
}
if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- 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);
+ 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);
+ }
if ((res = osp_check_destination(callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
break;
} else if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 (result->outhandle == OSP_INVALID_HANDLE) {
- ast_log(LOG_DEBUG, "OSP: Transaction handle undefined\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- 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);
+ 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);
+ }
if ((res = osp_check_destination(callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
res = 1;
break;
} else if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
result->token[0] = '\0';
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
error = OSPPTransactionReportUsage(handle, difftime(end, connect), start, end, alert, connect, isPddInfoPresent, pdd,
release, (unsigned char *) "", 0, 0, 0, 0, &dummy, NULL);
if (error == OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Usage reported\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Usage reported\n");
res = 1;
} else {
- ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error);
res = -1;
}
OSPPTransactionDelete(handle);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPAuth: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: priority jump '%d'\n", priority_jump);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
token = ast_var_value(current);
}
}
- ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
- ast_log(LOG_DEBUG, "OSPAuth: token size '%zd'\n", strlen(token));
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
+ ast_log(LOG_DEBUG, "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);
- ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", timelimit);
pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer);
- ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status);
- ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
if(res <= 0) {
if (priority_jump || ast_opt_priority_jumping) {
AST_STANDARD_APP_ARGS(args, tmp);
- ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPLookup: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: priority jump '%d'\n", priority_jump);
result.inhandle = OSP_INVALID_HANDLE;
result.intimelimit = OSP_DEF_TIMELIMIT;
srcdev = ast_var_value(current);
}
}
- 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: source device '%s'\n", srcdev);
+ 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: 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);
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status);
- ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
if (!strcasecmp(result.tech, "SIP")) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "P-OSP-Auth-Token: %s", result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, "H323")) {
} else if (!strcasecmp(result.tech, "IAX")) {
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPNext: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: priority jump '%d'\n", priority_jump);
result.inhandle = OSP_INVALID_HANDLE;
result.outhandle = OSP_INVALID_HANDLE;
}
}
}
- 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: OSPRESULTS '%d'\n", result.numresults);
+ 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: OSPRESULTS '%d'\n", result.numresults);
+ }
if ((res = osp_next(cause, &result)) > 0) {
status = AST_OSP_SUCCESS;
}
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status);
- ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
if (!strcasecmp(result.tech, "SIP")) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "P-OSP-Auth-Token: %s", result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, "H323")) {
} else if (!strcasecmp(result.tech, "IAX")) {
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPFinish: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPFinish: priority jump '%d'\n", priority_jump);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
}
}
}
- 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);
+ 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);
+ }
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
if (chan->cdr) {
start = chan->cdr->start.tv_sec;
connect = 0;
end = 0;
}
- 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);
+ 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);
+ }
release = chan->_softhangup ? 0 : 1;
if (osp_finish(outhandle, recorded, cause, start, connect, end, release) <= 0) {
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for outbound call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for inbound call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
- ast_log(LOG_DEBUG, "OSP: osp_hardware '%d'\n", osp_hardware);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
}
- ast_log(LOG_DEBUG, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
return 1;
}
/*! \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. */
- ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename);
q->dead = 1;
/* Delete if unused (else will be deleted when last caller leaves). */
if (strcmp(mem->interface, member->interface))
continue;
- ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
if (q->weight > rq->weight) {
- 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);
+ 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);
found = 1;
break;
}
return 0;
}
if (use_weight && compare_weight(qe->parent,tmp->member)) {
- ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
if (pos == 1 /* not found */) {
if (numlines == (numbusies + numnochan)) {
- ast_log(LOG_DEBUG, "Everyone is busy at this time\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
}
}
ast_frfree(f);
if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) {
if ((mem = interface_exists(q, interface))) {
found++;
- if (mem->paused == paused)
- ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface);
+ 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);
+ }
mem->paused = paused;
if (queue_persistent_members)
switch (remove_from_queue(args.queuename, args.interface)) {
case RES_OKAY:
- ast_log(LOG_DEBUG, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED");
res = 0;
break;
case RES_EXISTS:
- ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
if (priority_jump || ast_opt_priority_jumping)
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE");
ast_frfree(f);
}
if (!f) {
- ast_log(LOG_DEBUG, "Got hangup\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got hangup\n");
res = -1;
}
#include "asterisk/translate.h"
#include "asterisk/utils.h"
#include "asterisk/dsp.h"
+#include "asterisk/options.h"
static char *app = "BackgroundDetect";
}
}
}
- ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n",
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
ms = 0;
if ((ms > min) && ((max < 0) || (ms < max))) {
char ms_str[10];
- ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
/* Save detected talk time (in milliseconds) */
sprintf(ms_str, "%d", ms );
res = 0;
ast_frfree(fr);
break;
- } else
- ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
+ }
notsilent = 0;
}
} else {
if (!notsilent) {
/* Heard some audio, mark the begining of the token */
start = ast_tvnow();
- ast_log(LOG_DEBUG, "Start of voice token!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Start of voice token!\n");
notsilent = 1;
}
}
ast_log(LOG_NOTICE, "No samples were received from the other side!\n");
return -1;
}
- ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
return (noise / samples);
}
fprintf(f, "SERVERCHAN: %s\n", chan->name);
fprintf(f, "SERVERTEST ID: %s\n", testid);
fprintf(f, "ANSWER: PASS\n");
- ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 1: Send "1" */
}
if (!strcmp(format, "wav49"))
format = "WAV";
- 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));
+ if (option_debug)
+ 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));
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
if ((p = vm_mkftemp(tmp)) == NULL) {
create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
tmpfd = mkstemp(newtmp);
- ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
}
fprintf(p, "--%s\n", bound);
fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", ctype, format, msgnum, format);
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
}
return 0;
}
ast_log(LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {
- ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
}
} else if (!ast_strlen_zero(externnotify)) {
if (inboxcount(ext_context, &newvoicemails, &oldvoicemails)) {
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);
- ast_log(LOG_DEBUG, "Executing %s\n", arguments);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Executing %s\n", arguments);
ast_safe_system(arguments);
}
}
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
} else {
- ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%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) {
- ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
return -1;
/* Check if mailbox is full */
if (vms->quota_usage >= vms->quota_limit) {
- ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
ast_play_and_wait(chan, "vm-mailboxfull");
return -1;
}
if (!res)
res = ast_waitstream(chan, "");
/* play_record_review does recording and verify */
- ast_log(LOG_DEBUG, "About to record message in file %s\n",fn);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "About to record message in file %s\n",fn);
res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration, dir, options->record_gain);
if (res == '0') {
goto transfer;
if (box == 1) return 10;
/* get the real IMAP message number for this message */
sprintf(sequence,"%ld",vms->msgArray[msg]);
- if(option_debug > 2)
+ if (option_debug > 2)
ast_log(LOG_DEBUG, "Copying sequence %s to mailbox %s\n",sequence,dbox);
res = mail_copy(vms->mailstream,sequence,dbox);
if (res == 1) return 0;
bytes += ast_adsi_voice_mode(buf + bytes, 0);
ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
- ast_log(LOG_DEBUG, "Done downloading scripts...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- ast_log(LOG_DEBUG, "Restarting session...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Restarting session...\n");
bytes = 0;
/* Load the session now */
}
if (!strcasecmp(fmt, "wav49"))
fmt = "WAV";
- if(option_debug > 2)
+ if (option_debug > 2)
ast_log (LOG_DEBUG,"**** 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/imap", VM_SPOOL_DIR);
make_gsm_file(vms->fn, vms->imapuser, todir, vms->curmsg);
- if(option_debug > 2)
+ 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);
/*mail_fetchstructure (mailstream, vmArray[0], &body); */
mail_fetchstructure (vms->mailstream, vms->msgArray[vms->curmsg], &body);
return res;
/* Strip off caller ID number from name */
- ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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++){
- ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
if ((strcmp(cidinternalcontexts[i], context) == 0))
break;
}
}
else if (!res){
- ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
if ((!res) && (durationm >= minduration)) {
res = wait_file2(chan, vms, "vm-duration");
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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 */
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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);
}
- ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Before ast_answer\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Before ast_answer\n");
ast_answer(chan);
}
if (!valid)
res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
- ast_log(LOG_DEBUG, "After vm_authenticate\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Before open_mailbox\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Before open_mailbox\n");
res = open_mailbox(&vms, vmu, 1);
if (res == ERROR_LOCK_PATH)
goto out;
vms.oldmessages = vms.lastmsg + 1;
- ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
/* Select proper mailbox FIRST!! */
if (play_auto) {
if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) {
ast_copy_string(externnotify, notifystr, sizeof(externnotify));
- ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
if (!strcasecmp(externnotify, "smdi")) {
- ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
if ((smdistr = ast_variable_retrieve(cfg, "general", "smdiport"))) {
smdi_iface = ast_smdi_interface_find(smdistr);
} else {
- ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
}
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling external voicemail notification\n");
externnotify[0] = '\0';
} else {
- ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
}
}
} else {
ast_set2_flag((&globalflags), ast_true(astforcegreet), VM_FORCEGREET);
if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
- ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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]));
- ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
} else {
cidinternalcontexts[x][0] = '\0';
}
}
}
if (!(astreview = ast_variable_retrieve(cfg, "general", "review"))){
- ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
astreview = "no";
}
ast_set2_flag((&globalflags), ast_true(astreview), VM_REVIEW);
/*Temperary greeting reminder */
if (!(asttempgreetwarn = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
- ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n");
asttempgreetwarn = "no";
} else {
- ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option enabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option enabled globally\n");
}
ast_set2_flag((&globalflags), ast_true(asttempgreetwarn), VM_TEMPGREETWARN);
if (!(astcallop = ast_variable_retrieve(cfg, "general", "operator"))){
- ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
astcallop = "no";
}
ast_set2_flag((&globalflags), ast_true(astcallop), VM_OPERATOR);
if (!(astsaycid = ast_variable_retrieve(cfg, "general", "saycid"))) {
- ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
astsaycid = "no";
}
ast_set2_flag((&globalflags), ast_true(astsaycid), VM_SAYCID);
if (!(send_voicemail = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){
- ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
send_voicemail = "no";
}
ast_set2_flag((&globalflags), ast_true(send_voicemail), VM_SVMAIL);
if (!(asthearenv = ast_variable_retrieve(cfg, "general", "envelope"))) {
- ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
asthearenv = "yes";
}
ast_set2_flag((&globalflags), ast_true(asthearenv), VM_ENVELOPE);
if (!(astsaydurationinfo = ast_variable_retrieve(cfg, "general", "sayduration"))) {
- ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
astsaydurationinfo = "yes";
}
ast_set2_flag((&globalflags), ast_true(astsaydurationinfo), VM_SAYDURATION);
}
if (!(astskipcmd = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
- ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
astskipcmd = "no";
}
ast_set2_flag((&globalflags), ast_true(astskipcmd), VM_SKIPAFTERCMD);
if ((dialoutcxt = ast_variable_retrieve(cfg, "general", "dialout"))) {
ast_copy_string(dialcontext, dialoutcxt, sizeof(dialcontext));
- ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
} else {
dialcontext[0] = '\0';
}
if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) {
ast_copy_string(callcontext, callbackcxt, sizeof(callcontext));
- ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
} else {
callcontext[0] = '\0';
}
if ((exitcxt = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
ast_copy_string(exitcontext, exitcxt, sizeof(exitcontext));
- ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
} else {
exitcontext[0] = '\0';
}
/* Ended happily with silence */
res = 1;
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "SILENCE");
- ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n");
break;
}
if ( timeout && (difftime(time(&now),waitstart) >= timeout) ) {
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "TIMEOUT");
- ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n");
res = 0;
break;
}
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
close(fd);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
/* Kill old pseudo */
close(fd);
}
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
retryzap = 0;
goto zapretry;
}
if (!res) {
/* Check for hangup */
if (chan->_softhangup && !signalled) {
- ast_log(LOG_DEBUG, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
close(fd);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
/* Kill old pseudo */
close(fd);
}
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
retryzap = 0;
goto zapretry;
}
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
+#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- ast_log(LOG_DEBUG, "logging time in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "logging time in GMT\n");
}
}
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
}
}
if (tmp) {
loguserfield = ast_true(tmp);
if (loguserfield) {
- ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
}
}
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
}
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
loguniqueid = 0;
}
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
}
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
usegmtime = 0;
}
ptr = ast_variable_retrieve(cfg,"global","table");
if (ptr == NULL) {
- ast_log(LOG_DEBUG,"cdr_tds: table not specified. Assuming cdr\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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) { \
- ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", 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); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ if (option_debug) \
+ ast_log(LOG_DEBUG, "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)
+ if (p->chan && option_debug)
ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
status = pbx_builtin_getvar_helper(p->chan, "CHANLOCALSTATUS");
if (p->chan && !p->chan->_bridge) {
if (strcasecmp(p->chan->tech->type, "Local")) {
p->chan->_bridge = ast;
- if (p->chan)
+ 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);
}
}
(f->subclass == p->chan->writeformat)) {
res = ast_write(p->chan, f);
} else {
- 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);
+ 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);
res = 0;
}
}
p->acknowledged = 0;
if (!p->chan) {
if (p->pending) {
- ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
newstate = AST_STATE_DIALING;
res = 0;
} else {
ast_hangup(p->chan);
p->chan = NULL;
}
- ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if (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 )
+ if (option_debug > 4 && !res)
ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
return res;
res = 0;
} else {
if (option_debug > 2)
- ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_log(LOG_DEBUG, "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_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
}
}
if (!res) {
struct agent_pvt *p;
int res=0;
- ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
if (p) {
ast_mutex_unlock(&newlyavailable->lock);
if (option_debug > 2)
- ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_log(LOG_DEBUG, "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_log(LOG_DEBUG, "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_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
}
ast_mutex_lock(&newlyavailable->lock);
}
chan = agent_new(p, AST_STATE_DOWN);
if (!chan)
ast_log(LOG_WARNING, "Weird... Fix this to drop the unused pending agent\n");
- } else
- ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ }
}
*cause = hasagent ? AST_CAUSE_BUSY : AST_CAUSE_UNREGISTERED;
AST_LIST_UNLOCK(&agents);
if (err < 0) {
ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
return NULL;
- } else
- ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ }
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_hw_params_any(handle, hwparams);
err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction);
if (err < 0)
ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err));
- else
- ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ }
buffer_size = 4096 * 2; /* period_size * 16; */
err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size);
if (err < 0)
ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err));
- else
- ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ }
#if 0
direction = 0;
err = snd_pcm_poll_descriptors_count(handle);
if (err <= 0)
ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
- if (err != 1)
- ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ if (err != 1) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ }
snd_pcm_poll_descriptors(handle, &pfd, err);
- ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- ast_log(LOG_DEBUG, "XRUN write\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "XRUN write\n");
#endif
snd_pcm_prepare(alsa.ocard);
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
int tinthreeway;
struct ast_channel *towner;
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
towner = p->subs[a].owner;
tinthreeway = p->subs[a].inthreeway;
{
struct gtalk_pvt *tmp;
char *from;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))
/* 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 (option_debug)
+ ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
return -1;
}
- ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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();
fr->af.delivery = ast_tvadd(iaxs[fr->callno]->rxcore, ast_samp2tv(fr->ts, 1000));
else {
#if 0
- ast_log(LOG_DEBUG, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
+ 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");
#endif
fr->af.delivery = ast_tv(0,0);
}
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&iaxsl[callno]);
if (callno && iaxs[callno]) {
- ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
iax2_destroy(callno);
}
}
#ifdef SO_NO_CHECK
setsockopt(tpeer->sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums));
#endif
- ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ 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_LIST_INSERT_TAIL(&tpeers, tpeer, list);
}
}
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
tpeer->trunkdata = tmp;
- 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);
+ 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);
} 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);
/* Simple, just queue for transmission */
res = iax2_send(iaxs[callno], f, 0, -1, 0, 0, 0);
} else {
- ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
}
}
/* If it's already gone, just return */
if (!p)
return;
- ast_log(LOG_DEBUG, "Expiring registration for peer '%s'\n", p->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- 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));
+ 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));
#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 */
- ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
+ 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));
free(drop->trunkdata);
ast_mutex_unlock(&drop->lock);
ast_mutex_destroy(&drop->lock);
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
- } else
- ast_log(LOG_DEBUG, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
+ } 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);
+ }
}
if (inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
((f.frametype != AST_FRAME_IAX) ||
if (f.frametype == AST_FRAME_VOICE) {
if (f.subclass != iaxs[fr->callno]->voiceformat) {
iaxs[fr->callno]->voiceformat = f.subclass;
- ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
}
if (f.frametype == AST_FRAME_VIDEO) {
if (f.subclass != iaxs[fr->callno]->videoformat) {
- ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
iaxs[fr->callno]->videoformat = f.subclass & ~0x1;
}
}
break;
case IAX_COMMAND_HANGUP:
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received hangup\n", fr->callno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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>");
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n",
- fr->callno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 (!strcmp(ies.called_number, ast_parking_ext())) {
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
- ast_log(LOG_DEBUG, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- 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);
+ 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);
+ }
}
- } else
+ } else {
+ if (option_debug)
ast_log(LOG_DEBUG, "Async goto not applicable on call %d\n", fr->callno);
+ }
break;
case IAX_COMMAND_ACCEPT:
/* Ignore if call is already up or needs authentication or is a TBD */
}
if (!format) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- 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);
+ 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);
format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
}
if (!format) {
break;
case IAX_COMMAND_INVAL:
iaxs[fr->callno]->error = ENOTCONN;
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
break;
case IAX_COMMAND_VNAK:
- ast_log(LOG_DEBUG, "Received VNAK: resending outstanding frames\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
ast_log(LOG_DEBUG, "Provisioning '%s' from template '%s'\n", dest, template);
if (iax_provision_build(&provdata, &sig, template, force)) {
- ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
return 0;
}
pthread_testcancel();
count = ast_sched_runq(sched);
- if (count >= 20)
+ if (count >= 20 && option_debug)
ast_log(LOG_DEBUG, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&iaxq.queue);
- if (count >= 20)
+ if (count >= 20 && option_debug)
ast_log(LOG_DEBUG, "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, -1);
if (res >= 0) {
- if (res >= 20)
+ if (res >= 20 && option_debug)
ast_log(LOG_DEBUG, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
}
}
res = bind(sd, sa, salen);
if (res < 0) {
- ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
close(sd);
return 1;
}
srcaddr, peer->name);
return -1;
} else {
- ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
return 0;
}
}
if (create_addr(pds.peer, &sin, &cai))
return -1;
- ast_log(LOG_DEBUG, "peer: %s, username: %s, password: %s, context: %s\n",
- pds.peer, pds.username, pds.password, pds.context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
{
struct jingle_pvt *tmp;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))
ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name, p->parent->name);
return -1;
}
- ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
*/
return 0;
}
struct mgcp_request **queue, *q, *r, *t;
ast_mutex_t *l;
- ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
if (p->slowsequence) {
queue = &p->cmd_queue;
l = &p->cmd_queue_lock;
ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
}
if (!ast->tech_pvt) {
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) {
- ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
return 0;
}
ast_mutex_lock(&sub->lock);
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != sub->owner->nativeformats) {
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
break;
} else if (name && !strcasecmp(p->name, tmp)) {
- ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
- p->name, g->name, p->sub->id);
+ 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);
sub = p->sub;
found = 1;
break;
res = ast_waitfordigit(chan, timeout);
timeout = 0;
if (res < 0) {
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
ast_hangup(chan);
timeout = matchdigittimeout;
}
} else if (res == 0) {
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);*/
for (;;) {
res = ast_waitfordigit(chan, to);
if (!res) {
- ast_log(LOG_DEBUG, "Timeout...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Timeout...\n");
break;
}
if (res < 0) {
- ast_log(LOG_DEBUG, "Got hangup...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got hangup...\n");
ast_hangup(chan);
break;
}
/* Tell the caller not to hangup */
return 1;
} else {
- 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);
+ 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);
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;
- ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
-
-
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
/*** CLI HANDLING ***/
{
struct chan_list *p;
struct misdn_bchannel *bc=NULL;
-
- ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) ) ) return -1;
if (ast->_state == AST_STATE_RESERVED || p->state == MISDN_NOTHING) {
/* between request and call */
- ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
if (tmp->faxdetect && (f->subclass == 'f')) {
/* Fax tone -- Handle and return NULL */
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, context);
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n", context, ast->exten);
- } else
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ }
break;
case 2:
ast_verbose(VERBOSE_PREFIX_3 "Not redirecting %s to fax extension, nojump is set.\n", ast->name);
break;
}
- } else
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Fax already handled\n");
+ }
}
if (tmp->ast_dsp && (f->subclass != 'f')) {
p->fr.delivery.tv_sec = 0;
p->fr.delivery.tv_usec = 0;
- ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
return &p->fr;
}
{
struct phone_pvt *p = chan->tech_pvt;
int res=-1;
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
/* If it's an FXO, hang them up */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
- 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)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
+ }
}
/* If they're off hook, give a busy signal */
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))
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
- else
- ast_log(LOG_DEBUG, "Took linejack off hook\n");
+ 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");
+ }
}
phone_setup(ast);
if (option_debug)
union telephony_exception phonee;
/* XXX Do something XXX */
#if 0
- ast_log(LOG_DEBUG, "Exception!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Exception!\n");
#endif
phonee.bytes = ioctl(i->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
}
/* Okay, select has finished. Let's see what happened. */
if (res < 0) {
- ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
continue;
}
/* If there are no fd's changed, just continue, it's probably time
return NULL;
}
if (mode == MODE_FXO) {
- if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN))
- ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ }
} else {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_POTS))
if (mode != MODE_FXS)
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))
- 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)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)
a dialog */
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
{
- if (p->initreq.headers) {
+ if (p->initreq.headers && option_debug) {
ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
}
/* Use this as the basis */
((ast_test_flag(cur, FLAG_RESPONSE)) ||
(!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
if (!resp && (seqno == p->pendinginvite)) {
- ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
p->pendinginvite = 0;
}
/* this is our baby */
case AST_CAUSE_NOTDEFINED:
default:
- ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
return NULL;
}
struct ast_channel *oldowner = ast;
if (!p) {
- ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
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
- ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %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");
int ret = -1;
struct sip_pvt *p;
- if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE))
+ 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))
+ if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE) && option_debug)
ast_log(LOG_DEBUG, "Old channel is zombie\n");
if (!newchan || !newchan->tech_pvt) {
framing = strtol(tmp, NULL, 10);
if (framing == LONG_MIN || framing == LONG_MAX) {
framing = 0;
- ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
}
}
if (framing && last_rtpmap_codec) {
ast_sched_del(sched, r->timeout);
}
r->timeout = ast_sched_add(sched, global_reg_timeout * 1000, sip_reg_timeout, r);
- ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
}
if (strchr(r->username, '@')) {
/* Once a persistant route is set, don't fool with it */
if (p->route && p->route_persistant) {
- ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
return;
}
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)) {
- ast_log(LOG_DEBUG, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
+ 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);
return -2;
}
}
}
usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE);
if (p->rtp) {
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", usenatroute ? "On" : "Off");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", usenatroute ? "On" : "Off");
ast_rtp_setnat(p->rtp, usenatroute);
}
if (p->vrtp) {
- ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", usenatroute ? "On" : "Off");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", usenatroute ? "On" : "Off");
ast_rtp_setnat(p->vrtp, usenatroute);
}
if (p->udptl) {
- ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", usenatroute ? "On" : "Off");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", usenatroute ? "On" : "Off");
ast_udptl_setnat(p->udptl, usenatroute);
}
ast_string_field_set(p, peersecret, peer->secret);
if (!dialog)
return;
+ if (!option_debug && !sipdebug) {
+ ast_log(LOG_NOTICE, "You must have debugging enabled (SIP or Asterisk) in order to dump SIP history.\n");
+ return;
+ }
+
ast_log(LOG_DEBUG, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
if (dialog->subscribed)
ast_log(LOG_DEBUG, " * Subscription\n");
e = strchr(s, '/');
if (e)
*e = '\0';
- ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
}
if (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
- ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
return;
}
r->regtime = time(NULL); /* Reset time of last succesful registration */
manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
r->regattempts = 0;
- ast_log(LOG_DEBUG, "Registration successful\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Registration successful\n");
if (r->timeout > -1) {
- ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
ast_sched_del(sched, r->timeout);
}
r->timeout=-1;
if (sipmethod == SIP_INVITE)
handle_response_invite(p, resp, rest, req, seqno);
else {
- ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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... */
- ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
/* Wait for 487, then destroy */
} else if (sipmethod == SIP_NOTIFY) {
}
ast_channel_unlock(transferer);
if (!transferer || !transferee) {
- if (!transferer)
- ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
- if (!transferee)
- ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ if (!transferer) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
+ }
+ if (!transferee) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ }
return -1;
}
if ((d = ast_calloc(1, sizeof(*d)))) {
}
} else {
p->jointcapability = p->capability;
- ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
}
if (recordhistory) /* This is a response, note what it was for */
append_history(p, "ReInv", "Re-invite received");
append_history(transferer, "Xfer", "Refer succeeded");
transferer->refer->status = REFER_200OK;
if (targetcall_pvt->owner) {
- ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
ast_channel_unlock(targetcall_pvt->owner);
}
}
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))
+ 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");
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))
+ if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
ast_log(LOG_DEBUG, "SIP transfer to non-SIP uri denied\n");
break;
default:
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))
+ 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);
break;
}
/* 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 */
- 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);
+ 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);
return 0;
} else if (ast_test_flag(req, SIP_PKT_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 (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 (ast_strlen_zero(configuration))
return authlist;
- ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
ast_copy_string(authcopy, configuration, sizeof(authcopy));
stringp = authcopy;
timeout = matchdigittimeout;
}
} else if (res == 0) {
- ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
transmit_tone(s, SKINNY_REORDER);
ast_hangup(c);
return NULL;
struct skinnysession *s;
if (!sub) {
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if(c) {
int tinthreeway;
struct ast_channel *towner;
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
tchan = p->subs[a].chan;
towner = p->subs[a].owner;
ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel);
return -1;
}
- ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
pvt->dialing = 1;
pvt->begindigit = digit;
}
if (pvt->begindigit) {
x = -1;
- ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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));
- ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
return 0;
}
if (!p)
return;
if (p->echocanon) {
- ast_log(LOG_DEBUG, "Echo cancellation already on\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Echo cancellation already on\n");
return;
}
if (p->digital) {
- ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
}
- } else
- ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ }
}
static void zt_train_ec(struct zt_pvt *p)
if (res)
ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
else {
- ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
}
- } else
- ast_log(LOG_DEBUG, "No echo training requested\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- ast_log(LOG_DEBUG, "disabled 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);
+ }
}
p->echocanon = 0;
}
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
return res;
}
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
return res;
}
if (c) {
p->dop.op = ZT_DIAL_OP_REPLACE;
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
- ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
} else {
p->dop.dialstr[0] = '\0';
}
#ifdef HAVE_PRI
}
#endif
- ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
p->dop.op = ZT_DIAL_OP_REPLACE;
c += p->stripmsd;
ast_mutex_unlock(&p->lock);
return -1;
}
- } else
- ast_log(LOG_DEBUG, "Deferring dialing...\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Deferring dialing...\n");
+ }
p->dialing = 1;
if (ast_strlen_zero(c))
p->dialednone = 1;
p->dialdest[0] = '\0';
break;
default:
- ast_log(LOG_DEBUG, "not yet implemented\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "not yet implemented\n");
ast_mutex_unlock(&p->lock);
return -1;
}
}
if (p->bearer || (mysig == SIG_FXSKS)) {
if (p->bearer) {
- 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);
+ 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);
p->bearer->call = p->call;
- } else
- ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "No digit string sent to application!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No digit string sent to application!\n");
return -1;
}
p = (struct zt_pvt *)chan->tech_pvt;
if (!p) {
- ast_log(LOG_DEBUG, "Unable to find technology private\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to find technology private\n");
return -1;
}
ast_mutex_lock(&p->lock);
if (!p->pri || !p->call) {
- ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
if (p->exten)
p->exten[0] = '\0';
- 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);
+ 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);
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)) {
- ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)
- ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Finally swapping real and threeway\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
if (p->tdd)
tdd_free(p->tdd);
p->tdd = 0;
break;
}
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n",
- (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
+ 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);
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) {
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
if (res != size) {
if (res == -1) return -1;
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
if (!p->dsp)
break;
cp = (char *) data;
- ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n",
- *cp ? "ON" : "OFF", (int) *cp, chan->name);
+ 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_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) {
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
x = 0;
zt_disable_ec(p);
} else {
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
- ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n",
- oprmode->mode, chan->name,oprmode->peer->name);;
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
zt_enable_ec(p);
} else {
- ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
}
- ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n",
- master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
- op0->channel, oi0, op1->channel, oi1);
+ 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);
res = AST_BRIDGE_RETRY;
goto return_from_bridge;
}
who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &timeoutms);
if (!who) {
- ast_log(LOG_DEBUG, "Ooh, empty read...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, empty read...\n");
continue;
}
f = ast_read(who);
struct zt_pvt *p = newchan->tech_pvt;
int x;
ast_mutex_lock(&p->lock);
- ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- 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);
+ 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);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
return -1;
}
} else
res = zt_get_event(p->subs[index].zfd);
- ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig == SIG_PRI && p->pri && p->pri->overlapdial) {
/* absorb event */
}
if (res & ZT_EVENT_DTMFDOWN) {
- ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
&nb