aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-14 19:39:12 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-14 19:39:12 +0000
commitf0424318479863edeed2a6a128e6d1ac926966e3 (patch)
tree4fd144260e58c9a66d331fc81b46473723452479 /channels
parentc8ca7d2f263f5161ce1b29ec2c9de835131fc950 (diff)
Add a massive set of changes for converting to use the ast_debug() macro.
(issue #9957, patches from mvanbaak, caio1982, critch, and dimas) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@69327 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_agent.c104
-rw-r--r--channels/chan_alsa.c18
-rw-r--r--channels/chan_features.c3
-rw-r--r--channels/chan_gtalk.c30
-rw-r--r--channels/chan_h323.c98
-rw-r--r--channels/chan_iax2.c266
-rw-r--r--channels/chan_jingle.c25
-rw-r--r--channels/chan_local.c6
-rw-r--r--channels/chan_mgcp.c71
-rw-r--r--channels/chan_misdn.c22
-rw-r--r--channels/chan_nbs.c9
-rw-r--r--channels/chan_phone.c66
-rw-r--r--channels/chan_sip.c1055
-rw-r--r--channels/chan_skinny.c15
-rw-r--r--channels/chan_vpb.cc34
-rw-r--r--channels/chan_zap.c611
-rw-r--r--channels/iax2-provision.c8
17 files changed, 957 insertions, 1484 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index b7a29b40c..14572bb93 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -184,12 +184,10 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (l
#define CHECK_FORMATS(ast, p) do { \
if (p->chan) {\
if (ast->nativeformats != p->chan->nativeformats) { \
- if (option_debug) \
- ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
+ ast_debug(1, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- if (option_debug) \
- ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ ast_debug(1, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
ast_set_read_format(ast, ast->readformat); \
ast_set_write_format(ast, ast->writeformat); \
} \
@@ -434,8 +432,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
/* Note that we don't hangup if it's not a callback because Asterisk will do it
for us when the PBX instance that called login finishes */
if (!ast_strlen_zero(p->loginchan)) {
- if (p->chan && option_debug)
- ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
+ if (p->chan)
+ ast_debug(1, "Bridge on '%s' being cleared (2)\n", p->chan->name);
status = pbx_builtin_getvar_helper(p->chan, "CHANLOCALSTATUS");
if (autologoffunavail && status && !strcasecmp(status, "CHANUNAVAIL")) {
@@ -505,8 +503,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
if (p->chan && !p->chan->_bridge) {
if (strcasecmp(p->chan->tech->type, "Local")) {
p->chan->_bridge = ast;
- if (p->chan && option_debug)
- ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
+ if (p->chan)
+ ast_debug(1, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
}
}
ast_mutex_unlock(&p->lock);
@@ -551,10 +549,9 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
(f->subclass == p->chan->writeformat)) {
res = ast_write(p->chan, f);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping one incompatible %s frame on '%s' to '%s'\n",
- f->frametype == AST_FRAME_VOICE ? "audio" : "video",
- ast->name, p->chan->name);
+ ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n",
+ f->frametype == AST_FRAME_VOICE ? "audio" : "video",
+ ast->name, p->chan->name);
res = 0;
}
}
@@ -617,8 +614,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
p->acknowledged = 0;
if (!p->chan) {
if (p->pending) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
+ ast_debug(1, "Pretending to dial on pending agent\n");
newstate = AST_STATE_DIALING;
res = 0;
} else {
@@ -643,20 +639,16 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
return res;
}
ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", p->chan->language);
res = ast_streamfile(p->chan, beep, p->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(3, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(p->chan, "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(3, "Waited for stream, result '%d'\n", res);
}
if (!res) {
res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Set read format, result '%d'\n", res);
+ ast_debug(3, "Set read format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
} else {
@@ -666,8 +658,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
if (!res) {
res = ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Set write format, result '%d'\n", res);
+ ast_debug(3, "Set write format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
}
@@ -721,8 +712,7 @@ static int agent_hangup(struct ast_channel *ast)
* as in apps/app_chanisavail.c:chanavail_exec()
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
+ ast_debug(1, "Hangup called for state %s\n", ast_state2str(ast->_state));
if (p->start && (ast->_state != AST_STATE_UP)) {
howlong = time(NULL) - p->start;
p->start = 0;
@@ -751,8 +741,7 @@ static int agent_hangup(struct ast_channel *ast)
ast_hangup(p->chan);
p->chan = NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
+ ast_debug(1, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {
long logintime = time(NULL) - p->loginstart;
p->loginstart = 0;
@@ -830,8 +819,8 @@ static int agent_cont_sleep( void *data )
}
ast_mutex_unlock(&p->lock);
- if (option_debug > 4 && !res)
- ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
+ if (!res)
+ ast_debug(5, "agent_cont_sleep() returning %d\n", res );
return res;
}
@@ -889,8 +878,7 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct
ret = p->chan;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
+ ast_debug(1, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
return ret;
}
@@ -1145,8 +1133,7 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
struct agent_pvt *p;
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking availability of '%s'\n", newlyavailable->agent);
+ ast_debug(1, "Checking availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
@@ -1155,8 +1142,7 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
}
ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
+ ast_debug(1, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
/* We found a pending call, time to merge */
chan = agent_new(newlyavailable, AST_STATE_DOWN);
parent = p->owner;
@@ -1173,15 +1159,12 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
/* Don't do beep here */
res = 0;
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, beep, newlyavailable->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(3, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- if (option_debug)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(1, "Waited for stream, result '%d'\n", res);
}
}
if (!res) {
@@ -1200,13 +1183,11 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
ast_mutex_unlock(&parent->lock);
p->abouttograb = 0;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sneaky, parent disappeared in the mean time...\n");
+ ast_debug(1, "Sneaky, parent disappeared in the mean time...\n");
agent_cleanup(newlyavailable);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ugh... Agent hung up at exactly the wrong time\n");
+ ast_debug(1, "Ugh... Agent hung up at exactly the wrong time\n");
agent_cleanup(newlyavailable);
}
}
@@ -1218,8 +1199,7 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
struct agent_pvt *p;
int res=0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
+ ast_debug(1, "Checking beep availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
@@ -1228,8 +1208,7 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
}
ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call '%s' looks like a would-be winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
+ ast_debug(1, "Call '%s' looks like a would-be winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
ast_mutex_unlock(&p->lock);
break;
}
@@ -1239,15 +1218,12 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
AST_LIST_UNLOCK(&agents);
if (p) {
ast_mutex_unlock(&newlyavailable->lock);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, beep, newlyavailable->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(1, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- if (option_debug)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(1, "Waited for stream, result '%d'\n", res);
}
ast_mutex_lock(&newlyavailable->lock);
}
@@ -1333,16 +1309,14 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat
/* No agent available -- but we're requesting to wait for one.
Allocate a place holder */
if (hasagent) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Creating place holder for '%s'\n", s);
+ ast_debug(1, "Creating place holder for '%s'\n", s);
p = add_agent(data, 1);
p->group = groupmatch;
chan = agent_new(p, AST_STATE_DOWN);
if (!chan)
ast_log(LOG_WARNING, "Weird... Fix this to drop the unused pending agent\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ ast_debug(1, "Not creating place holder for '%s' since nobody logged in\n", s);
}
}
*cause = hasagent ? AST_CAUSE_BUSY : AST_CAUSE_UNREGISTERED;
@@ -1936,8 +1910,7 @@ static int login_exec(struct ast_channel *chan, void *data)
ast_mutex_lock(&p->lock);
if (p->lastdisc.tv_sec) {
if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > p->wrapuptime) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wrapup time for %s expired!\n", p->agent);
+ ast_debug(1, "Wrapup time for %s expired!\n", p->agent);
p->lastdisc = ast_tv(0, 0);
if (p->ackcall > 1)
check_beep(p, 0);
@@ -2096,8 +2069,8 @@ static void dump_agents(void)
snprintf(buf, sizeof(buf), "%s;%s", cur_agent->loginchan, cur_agent->logincallerid);
if (ast_db_put(pa_family, cur_agent->agent, buf))
ast_log(LOG_WARNING, "failed to create persistent entry in ASTdb for %s!\n", buf);
- else if (option_debug)
- ast_log(LOG_DEBUG, "Saved Agent: %s on %s\n", cur_agent->agent, cur_agent->loginchan);
+ else
+ ast_debug(1, "Saved Agent: %s on %s\n", cur_agent->agent, cur_agent->loginchan);
} else {
/* Delete - no agent or there is an error */
ast_db_del(pa_family, cur_agent->agent);
@@ -2136,8 +2109,7 @@ static void reload_agents(void)
} else
ast_mutex_unlock(&cur_agent->lock);
if (!ast_db_get(pa_family, agent_num, agent_data, sizeof(agent_data)-1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
+ ast_debug(1, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
parse = agent_data;
agent_chan = strsep(&parse, ";");
agent_callerid = strsep(&parse, ";");
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index feed79e04..de8f3ffef 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -365,8 +365,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
return NULL;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
}
snd_pcm_hw_params_alloca(&hwparams);
@@ -394,8 +393,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err < 0)
ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ ast_debug(1, "Period size is %d\n", err);
}
buffer_size = 4096 * 2; /* period_size * 16; */
@@ -403,8 +401,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err < 0)
ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ ast_debug(1, "Buffer size is set to %d frames\n", err);
}
#if 0
@@ -465,13 +462,11 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err <= 0)
ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
if (err != 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ ast_debug(1, "Can't handle more than one device\n");
}
snd_pcm_poll_descriptors(handle, &pfd, err);
- if (option_debug)
- ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd);
+ ast_debug(1, "Acquired fd %d from the poll descriptor\n", pfd.fd);
if (stream == SND_PCM_STREAM_CAPTURE)
readdev = pfd.fd;
@@ -634,8 +629,7 @@ static int alsa_write(struct ast_channel *chan, struct ast_frame *f)
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
if (res == -EPIPE) {
#if DEBUG
- if (option_debug)
- ast_log(LOG_DEBUG, "XRUN write\n");
+ ast_debug(1, "XRUN write\n");
#endif
snd_pcm_prepare(alsa.ocard);
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
diff --git a/channels/chan_features.c b/channels/chan_features.c
index 4b65180a8..3d199c36f 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -209,8 +209,7 @@ static void swap_subs(struct feature_pvt *p, int a, int b)
int tinthreeway;
struct ast_channel *towner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ ast_debug(1, "Swapping %d and %d\n", a, b);
towner = p->subs[a].owner;
tinthreeway = p->subs[a].inthreeway;
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index 1402a5a25..537bc00a0 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -515,8 +515,7 @@ static int gtalk_answer(struct ast_channel *ast)
struct gtalk_pvt *p = ast->tech_pvt;
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answer!\n");
+ ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
gtalk_invite(p, p->them, p->us,p->sid, 0);
ast_mutex_unlock(&p->lock);
@@ -603,8 +602,7 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak)
{
struct gtalk_pvt *tmp;
char *from;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
@@ -682,8 +680,7 @@ static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak)
struct gtalk_pvt *tmp;
char *from;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
@@ -839,8 +836,7 @@ static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const
char idroster[200];
char *data, *exten = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
+ ast_debug(1, "The client is %s for alloc\n", client->name);
if (!sid && !strchr(them, '/')) { /* I started call! */
if (!strcasecmp(client->name, "guest")) {
buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, them);
@@ -1173,9 +1169,9 @@ static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p)
else
ast_rtp_stun_request(p->rtp, &sin, username);
- if (aux.sin_addr.s_addr && option_debug > 3) {
- ast_log(LOG_DEBUG, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
- ast_log(LOG_DEBUG, "Sending STUN request to %s\n", tmp->ip);
+ if (aux.sin_addr.s_addr) {
+ ast_debug(4, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
+ ast_debug(4, "Sending STUN request to %s\n", tmp->ip);
}
tmp = tmp->next;
@@ -1280,8 +1276,7 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats =
(p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
@@ -1290,8 +1285,7 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- if (option_debug)
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
@@ -1577,11 +1571,9 @@ static int gtalk_parser(void *data, ikspak *pak)
/* New call */
gtalk_newcall(client, pak);
} else if (iks_find_with_attrib(pak->x, "session", "type", "candidates") || iks_find_with_attrib(pak->x, "session", "type", "transport-info")) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "About to add candidate!\n");
+ ast_debug(3, "About to add candidate!\n");
gtalk_add_candidate(client, pak);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Candidate Added!\n");
+ ast_debug(3, "Candidate Added!\n");
} else if (iks_find_with_attrib(pak->x, "session", "type", "accept") || iks_find_with_attrib(pak->x, "session", "type", "transport-accept")) {
gtalk_is_answered(client, pak);
} else if (iks_find_with_attrib(pak->x, "session", "type", "content-info")) {
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 0c0d937cb..85c912b32 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -287,14 +287,14 @@ static const char* redirectingreason2str(int redirectingreason)
static void oh323_destroy_alias(struct oh323_alias *alias)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying alias '%s'\n", alias->name);
+ ast_debug(1, "Destroying alias '%s'\n", alias->name);
ast_free(alias);
}
static void oh323_destroy_user(struct oh323_user *user)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying user '%s'\n", user->name);
+ ast_debug(1, "Destroying user '%s'\n", user->name);
ast_free_ha(user->ha);
ast_free(user);
}
@@ -302,7 +302,7 @@ static void oh323_destroy_user(struct oh323_user *user)
static void oh323_destroy_peer(struct oh323_peer *peer)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying peer '%s'\n", peer->name);
+ ast_debug(1, "Destroying peer '%s'\n", peer->name);
ast_free_ha(peer->ha);
ast_free(peer);
}
@@ -343,14 +343,14 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
{
if (c->nativeformats != pvt->nativeformats) {
if (h323debug)
- ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name);
+ ast_debug(1, "Preparing %s for new native format\n", c->name);
c->nativeformats = pvt->nativeformats;
ast_set_read_format(c, c->readformat);
ast_set_write_format(c, c->writeformat);
}
if (pvt->needhangup) {
if (h323debug)
- ast_log(LOG_DEBUG, "Process pending hangup for %s\n", c->name);
+ ast_debug(1, "Process pending hangup for %s\n", c->name);
c->_softhangup |= AST_SOFTHANGUP_DEV;
c->hangupcause = pvt->hangupcause;
ast_queue_hangup(c);
@@ -475,7 +475,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
if (pvt->owner) {
ast_channel_lock(pvt->owner);
if (h323debug)
- ast_log(LOG_DEBUG, "Detaching from %s\n", pvt->owner->name);
+ ast_debug(1, "Detaching from %s\n", pvt->owner->name);
pvt->owner->tech_pvt = NULL;
ast_channel_unlock(pvt->owner);
}
@@ -503,7 +503,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
static void oh323_destroy(struct oh323_pvt *pvt)
{
if (h323debug) {
- ast_log(LOG_DEBUG, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
+ ast_debug(1, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
}
ast_mutex_lock(&iflock);
ast_mutex_lock(&pvt->lock);
@@ -599,7 +599,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
char called_addr[1024];
if (h323debug) {
- ast_log(LOG_DEBUG, "Calling to %s on %s\n", dest, c->name);
+ ast_debug(1, "Calling to %s on %s\n", dest, c->name);
}
if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "Line is already in use (%s)\n", c->name);
@@ -659,7 +659,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Requested transfer capability: 0x%.2x - %s\n", c->transfercapability, ast_transfercapability2str(c->transfercapability));
if (h323debug)
- ast_log(LOG_DEBUG, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
+ ast_debug(1, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
ast_mutex_unlock(&pvt->lock);
res = h323_make_call(called_addr, &(pvt->cd), &pvt->options);
if (res) {
@@ -677,7 +677,7 @@ static int oh323_answer(struct ast_channel *c)
char *token;
if (h323debug)
- ast_log(LOG_DEBUG, "Answering on %s\n", c->name);
+ ast_debug(1, "Answering on %s\n", c->name);
ast_mutex_lock(&pvt->lock);
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
@@ -701,7 +701,7 @@ static int oh323_hangup(struct ast_channel *c)
if (h323debug)
- ast_log(LOG_DEBUG, "Hanging up and scheduling destroy of call %s\n", c->name);
+ ast_debug(1, "Hanging up and scheduling destroy of call %s\n", c->name);
if (!c->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
@@ -785,7 +785,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
return &ast_null_frame;
}
if (h323debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
pvt->owner->nativeformats = f->subclass;
pvt->nativeformats = f->subclass;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
@@ -886,7 +886,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "OH323: Indicating %d on %s (%s)\n", condition, token, c->name);
+ ast_debug(1, "OH323: Indicating %d on %s (%s)\n", condition, token, c->name);
switch(condition) {
case AST_CONTROL_RINGING:
@@ -937,7 +937,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
}
if (h323debug)
- ast_log(LOG_DEBUG, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
+ ast_debug(1, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
if (token)
ast_free(token);
oh323_update_info(c);
@@ -978,12 +978,12 @@ static int __oh323_rtp_create(struct oh323_pvt *pvt)
return -1;
}
if (h323debug)
- ast_log(LOG_DEBUG, "Created RTP channel\n");
+ ast_debug(1, "Created RTP channel\n");
ast_rtp_setqos(pvt->rtp, tos, cos);
if (h323debug)
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
+ ast_debug(1, "Setting NAT on RTP to %d\n", pvt->options.nat);
ast_rtp_setnat(pvt->rtp, pvt->options.nat);
if (pvt->dtmf_pt[0] > 0)
@@ -1617,7 +1617,7 @@ static struct oh323_user *find_user(const call_details_t *cd, int realtime)
u = realtime_user(cd);
if (!u && h323debug)
- ast_log(LOG_DEBUG, "Could not find user by name %s or address %s\n", cd->call_source_aliases, cd->sourceIp);
+ ast_debug(1, "Could not find user by name %s or address %s\n", cd->call_source_aliases, cd->sourceIp);
return u;
}
@@ -1647,7 +1647,7 @@ static struct oh323_peer *find_peer(const char *peer, struct sockaddr_in *sin, i
p = realtime_peer(peer, sin);
if (!p && h323debug)
- ast_log(LOG_DEBUG, "Could not find peer by name %s or address %s\n", (peer ? peer : "<NONE>"), (sin ? ast_inet_ntoa(sin->sin_addr) : "<NONE>"));
+ ast_debug(1, "Could not find peer by name %s or address %s\n", (peer ? peer : "<NONE>"), (sin ? ast_inet_ntoa(sin->sin_addr) : "<NONE>"));
return p;
}
@@ -1735,7 +1735,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
char tmp[256], tmp1[256];
if (h323debug)
- ast_log(LOG_DEBUG, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
+ ast_debug(1, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
pvt = oh323_alloc(0);
if (!pvt) {
@@ -1771,7 +1771,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
ast_copy_string(pvt->exten, ext, sizeof(pvt->exten));
}
if (h323debug)
- ast_log(LOG_DEBUG, "Extension: %s Host: %s\n", pvt->exten, host);
+ ast_debug(1, "Extension: %s Host: %s\n", pvt->exten, host);
if (gatekeeper_disable) {
if (create_addr(pvt, host)) {
@@ -1933,7 +1933,7 @@ static struct rtp_info *external_rtp_create(unsigned call_reference, const char
ast_copy_string(info->addr, ast_inet_ntoa(us.sin_addr), sizeof(info->addr));
info->port = ntohs(us.sin_port);
if (h323debug)
- ast_log(LOG_DEBUG, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
+ ast_debug(1, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
return info;
}
@@ -1960,7 +1960,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
enum { NEED_NONE, NEED_HOLD, NEED_UNHOLD } rtp_change = NEED_NONE;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting up RTP connection for %s\n", token);
+ ast_debug(1, "Setting up RTP connection for %s\n", token);
/* Find the call or allocate a private structure if call not found */
pvt = find_call_locked(call_reference, token);
@@ -2004,7 +2004,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
rtptype = ast_rtp_lookup_pt(pvt->rtp, pt);
if (h323debug)
- ast_log(LOG_DEBUG, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
+ ast_debug(1, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
if (pvt->nativeformats != rtptype.code) {
pvt->nativeformats = rtptype.code;
nativeformats_changed = 1;
@@ -2018,7 +2018,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
/* Re-build translation path only if native format(s) has been changed */
if (pvt->owner->nativeformats != pvt->nativeformats) {
if (h323debug)
- ast_log(LOG_DEBUG, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
+ ast_debug(1, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
pvt->owner->nativeformats = pvt->nativeformats;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
ast_set_write_format(pvt->owner, pvt->owner->writeformat);
@@ -2045,13 +2045,13 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
else if (rtp_change == NEED_UNHOLD)
pvt->newcontrol = AST_CONTROL_UNHOLD;
if (h323debug)
- ast_log(LOG_DEBUG, "RTP connection preparation for %s is pending...\n", token);
+ ast_debug(1, "RTP connection preparation for %s is pending...\n", token);
}
}
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "RTP connection prepared for %s\n", token);
+ ast_debug(1, "RTP connection prepared for %s\n", token);
return;
}
@@ -2065,7 +2065,7 @@ static void connection_made(unsigned call_reference, const char *token)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Call %s answered\n", token);
+ ast_debug(1, "Call %s answered\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2092,7 +2092,7 @@ static int progress(unsigned call_reference, const char *token, int inband)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Received ALERT/PROGRESS message for %s tones\n", (inband ? "inband" : "self-generated"));
+ ast_debug(1, "Received ALERT/PROGRESS message for %s tones\n", (inband ? "inband" : "self-generated"));
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2122,7 +2122,7 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
struct oh323_alias *alias = NULL;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting up incoming call for %s\n", cd->call_token);
+ ast_debug(1, "Setting up incoming call for %s\n", cd->call_token);
/* allocate the call*/
pvt = oh323_alloc(cd->call_reference);
@@ -2187,7 +2187,7 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
ast_copy_string(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten));
}
if (h323debug)
- ast_log(LOG_DEBUG, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
+ ast_debug(1, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
} else {
if (user->host) {
if (strcasecmp(cd->sourceIp, ast_inet_ntoa(user->addr.sin_addr))) {
@@ -2243,7 +2243,7 @@ static int answer_call(unsigned call_reference, const char *token)
char tmp_exten[sizeof(pvt->exten)];
if (h323debug)
- ast_log(LOG_DEBUG, "Preparing Asterisk to answer for %s\n", token);
+ ast_debug(1, "Preparing Asterisk to answer for %s\n", token);
/* Find the call or allocate a private structure if call not found */
pvt = find_call_locked(call_reference, token);
@@ -2293,7 +2293,7 @@ static int answer_call(unsigned call_reference, const char *token)
return 0;
} else if ((try_exten != ext_original) && (strcmp(pvt->exten, tmp_exten) != 0)) {
if (h323debug)
- ast_log(LOG_DEBUG, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
+ ast_debug(1, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
ast_copy_string(pvt->exten, tmp_exten, sizeof(pvt->exten));
}
@@ -2331,7 +2331,7 @@ static void chan_ringing(unsigned call_reference, const char *token)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Ringing on %s\n", token);
+ ast_debug(1, "Ringing on %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2357,13 +2357,13 @@ static void cleanup_connection(unsigned call_reference, const char *call_token)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Cleaning connection to %s\n", call_token);
+ ast_debug(1, "Cleaning connection to %s\n", call_token);
while (1) {
pvt = find_call_locked(call_reference, call_token);
if (!pvt) {
if (h323debug)
- ast_log(LOG_DEBUG, "No connection for %s\n", call_token);
+ ast_debug(1, "No connection for %s\n", call_token);
return;
}
if (!pvt->owner || !ast_channel_trylock(pvt->owner))
@@ -2398,7 +2398,7 @@ static void cleanup_connection(unsigned call_reference, const char *call_token)
}
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "Connection to %s cleaned\n", call_token);
+ ast_debug(1, "Connection to %s cleaned\n", call_token);
return;
}
@@ -2406,15 +2406,13 @@ static void hangup_connection(unsigned int call_reference, const char *token, in
{
struct oh323_pvt *pvt;
- if (h323debug) {
- ast_log(LOG_DEBUG, "Hanging up connection to %s with cause %d\n", token, cause);
- }
+ if (h323debug)
+ ast_debug(1, "Hanging up connection to %s with cause %d\n", token, cause);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
- if (h323debug) {
- ast_log(LOG_DEBUG, "Connection to %s already cleared\n", token);
- }
+ if (h323debug)
+ ast_debug(1, "Connection to %s already cleared\n", token);
return;
}
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
@@ -2427,7 +2425,7 @@ static void hangup_connection(unsigned int call_reference, const char *token, in
pvt->needhangup = 1;
pvt->hangupcause = cause;
if (h323debug)
- ast_log(LOG_DEBUG, "Hangup for %s is pending\n", token);
+ ast_debug(1, "Hangup for %s is pending\n", token);
}
ast_mutex_unlock(&pvt->lock);
}
@@ -2437,7 +2435,7 @@ static void set_dtmf_payload(unsigned call_reference, const char *token, int pay
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting %s DTMF payload to %d on %s\n", (is_cisco ? "Cisco" : "RFC2833"), payload, token);
+ ast_debug(1, "Setting %s DTMF payload to %d on %s\n", (is_cisco ? "Cisco" : "RFC2833"), payload, token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2449,7 +2447,7 @@ static void set_dtmf_payload(unsigned call_reference, const char *token, int pay
pvt->dtmf_pt[is_cisco ? 1 : 0] = payload;
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "DTMF payload on %s set to %d\n", token, payload);
+ ast_debug(1, "DTMF payload on %s set to %d\n", token, payload);
}
static void set_peer_capabilities(unsigned call_reference, const char *token, int capabilities, struct ast_codec_pref *prefs)
@@ -2457,7 +2455,7 @@ static void set_peer_capabilities(unsigned call_reference, const char *token, in
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Got remote capabilities from connection %s\n", token);
+ ast_debug(1, "Got remote capabilities from connection %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
@@ -2471,7 +2469,7 @@ static void set_peer_capabilities(unsigned call_reference, const char *token, in
for (i = 0; i < 32; ++i) {
if (!prefs->order[i])
break;
- ast_log(LOG_DEBUG, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
+ ast_debug(1, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
}
}
if (pvt->rtp)
@@ -2487,7 +2485,7 @@ static void set_local_capabilities(unsigned call_reference, const char *token)
struct ast_codec_pref prefs;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting capabilities for connection %s\n", token);
+ ast_debug(1, "Setting capabilities for connection %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
@@ -2500,7 +2498,7 @@ static void set_local_capabilities(unsigned call_reference, const char *token)
h323_set_capabilities(token, capability, dtmfmode, &prefs, pref_codec);
if (h323debug)
- ast_log(LOG_DEBUG, "Capabilities for connection %s is set\n", token);
+ ast_debug(1, "Capabilities for connection %s is set\n", token);
}
static void remote_hold(unsigned call_reference, const char *token, int is_hold)
@@ -2508,7 +2506,7 @@ static void remote_hold(unsigned call_reference, const char *token, int is_hold)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting %shold status for connection %s\n", (is_hold ? "" : "un"), token);
+ ast_debug(1, "Setting %shold status for connection %s\n", (is_hold ? "" : "un"), token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 030fd8257..c89ead79f 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1240,8 +1240,8 @@ static void update_max_trunk(void)
max = x + 1;
}
maxtrunkcall = max;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "New max trunk callno is %d\n", max);
+ if (iaxdebug)
+ ast_debug(1, "New max trunk callno is %d\n", max);
}
static void update_max_nontrunk(void)
@@ -1254,8 +1254,8 @@ static void update_max_nontrunk(void)
max = x + 1;
}
maxnontrunkcall = max;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "New max nontrunk callno is %d\n", max);
+ if (iaxdebug)
+ ast_debug(1, "New max nontrunk callno is %d\n", max);
}
static int make_trunk(unsigned short callno, int locked)
@@ -1298,8 +1298,7 @@ static int make_trunk(unsigned short callno, int locked)
ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x);
+ ast_debug(1, "Made call %d into trunk call %d\n", callno, x);
/* We move this call from a non-trunked to a trunked call */
update_max_trunk();
update_max_nontrunk();
@@ -1373,8 +1372,8 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
iaxs[x] = new_iax(sin, lockpeer, host);
update_max_nontrunk();
if (iaxs[x]) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Creating new call structure %d\n", x);
+ if (iaxdebug)
+ ast_debug(1, "Creating new call structure %d\n", x);
iaxs[x]->sockfd = sockfd;
iaxs[x]->addr.sin_port = sin->sin_port;
iaxs[x]->addr.sin_family = sin->sin_family;
@@ -1753,8 +1752,7 @@ static int transmit_trunk(struct iax_frame *f, struct sockaddr_in *sin, int sock
res = sendto(sockfd, f->data, f->datalen, 0,(struct sockaddr *)sin,
sizeof(*sin));
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ ast_debug(1, "Received error: %s\n", strerror(errno));
handle_error();
} else
res = 0;
@@ -1771,8 +1769,8 @@ static int send_packet(struct iax_frame *f)
return -1;
/* Called with iaxsl held */
- if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
+ if (iaxdebug)
+ ast_debug(3, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
if (f->transfer) {
if (iaxdebug)
iax_showframe(f, NULL, 0, &iaxs[callno]->transfer, f->datalen - sizeof(struct ast_iax2_full_hdr));
@@ -1785,8 +1783,8 @@ static int send_packet(struct iax_frame *f)
sizeof(iaxs[callno]->addr));
}
if (res < 0) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ if (iaxdebug)
+ ast_debug(1, "Received error: %s\n", strerror(errno));
handle_error();
} else
res = 0;
@@ -2330,8 +2328,8 @@ static void unwrap_timestamp(struct iax_frame *fr)
gotten the update from the main packet. We'll just pretend that we did, and
update the timestamp appropriately. */
fr->ts = ( (iaxs[fr->callno]->last & 0xFFFF0000) + 0x10000) | (fr->ts & 0xFFFF);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "schedule_delivery: pushed forward timestamp\n");
+ if (iaxdebug)
+ ast_debug(1, "schedule_delivery: pushed forward timestamp\n");
}
if (x > 50000) {
/* Sudden apparent big jump forwards in timestamp:
@@ -2339,8 +2337,8 @@ static void unwrap_timestamp(struct iax_frame *fr)
top-16-bit timestamp that has turned up out of order.
Adjust the timestamp appropriately. */
fr->ts = ( (iaxs[fr->callno]->last & 0xFFFF0000) - 0x10000) | (fr->ts & 0xFFFF);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "schedule_delivery: pushed back timestamp\n");
+ if (iaxdebug)
+ ast_debug(1, "schedule_delivery: pushed back timestamp\n");
}
}
}
@@ -2474,8 +2472,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
fr->af.delivery = ast_tvadd(iaxs[fr->callno]->rxcore, ast_samp2tv(fr->ts, 1000));
else {
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
+ ast_debug(1, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
#endif
fr->af.delivery = ast_tv(0,0);
}
@@ -2682,14 +2679,12 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
memset(&peer->addr, 0, sizeof(peer->addr));
realtime_update_peer(peer->name, &peer->addr, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
- peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
- peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
@@ -3111,8 +3106,8 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
}
} else
ast_log(LOG_WARNING, "OSP token is too long\n");
- } else if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "OSP token is undefined\n");
+ } else if (iaxdebug)
+ ast_debug(1, "OSP token is undefined\n");
/* send the command using the appropriate socket for this peer */
iaxs[callno]->sockfd = cai.sockfd;
@@ -3147,8 +3142,7 @@ static int iax2_hangup(struct ast_channel *c)
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&iaxsl[callno]);
if (callno && iaxs[callno]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
+ ast_debug(1, "We're hanging up %s now...\n", c->name);
alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
/* Send the hangup unless we have had a transmission error or are already gone */
iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
@@ -3158,8 +3152,7 @@ static int iax2_hangup(struct ast_channel *c)
iax2_predestroy(callno);
/* If we were already gone to begin with, destroy us now */
if (alreadygone) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
+ ast_debug(1, "Really destroying %s now...\n", c->name);
iax2_destroy(callno);
}
}
@@ -3397,8 +3390,7 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
static int iax2_answer(struct ast_channel *c)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering IAX2 call\n");
+ ast_debug(1, "Answering IAX2 call\n");
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno])
iax2_ami_channelupdate(iaxs[callno]);
@@ -3412,8 +3404,8 @@ static int iax2_indicate(struct ast_channel *c, int condition, const void *data,
struct chan_iax2_pvt *pvt;
int res = 0;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
+ if (iaxdebug)
+ ast_debug(1, "Indicating condition %d\n", condition);
ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
@@ -3453,8 +3445,7 @@ static int iax2_transfer(struct ast_channel *c, const char *dest)
iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, tmp);
if (context)
iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, context);
- if (option_debug)
- ast_log(LOG_DEBUG, "Transferring '%s' to '%s'\n", c->name, dest);
+ ast_debug(1, "Transferring '%s' to '%s'\n", c->name, dest);
return send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1);
}
@@ -3628,8 +3619,8 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
/* If we have a time that the frame arrived, always use it to make our timestamp */
if (delivery && !ast_tvzero(*delivery)) {
ms = ast_tvdiff_ms(*delivery, p->offset);
- if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "calc_timestamp: call %d/%d: Timestamp slaved to delivery time\n", p->callno, iaxs[p->callno]->peercallno);
+ if (iaxdebug)
+ ast_debug(3, "calc_timestamp: call %d/%d: Timestamp slaved to delivery time\n", p->callno, iaxs[p->callno]->peercallno);
} else {
ms = ast_tvdiff_ms(ast_tvnow(), p->offset);
if (ms < 0)
@@ -3678,7 +3669,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
* frame size too) */
if (iaxdebug && abs(ms - p->nextpred) > MAX_TIMESTAMP_SKEW )
- ast_log(LOG_DEBUG, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n",
+ ast_debug(1, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n",
abs(ms - p->nextpred), MAX_TIMESTAMP_SKEW);
if (f->samples >= 8) /* check to make sure we dont core dump */
@@ -3721,13 +3712,13 @@ static unsigned int calc_rxstamp(struct chan_iax2_pvt *p, unsigned int offset)
/* Setup rxcore if necessary */
if (ast_tvzero(p->rxcore)) {
p->rxcore = ast_tvnow();
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %dms\n",
+ if (iaxdebug)
+ ast_debug(1, "calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %dms\n",
p->callno, (int)(p->rxcore.tv_sec), (int)(p->rxcore.tv_usec), offset);
p->rxcore = ast_tvsub(p->rxcore, ast_samp2tv(offset, 1000));
#if 1
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "calc_rxstamp: call=%d: works out as %d.%6.6d\n",
+ if (iaxdebug)
+ ast_debug(1, "calc_rxstamp: call=%d: works out as %d.%6.6d\n",
p->callno, (int)(p->rxcore.tv_sec),(int)( p->rxcore.tv_usec));
#endif
}
@@ -3775,8 +3766,7 @@ static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin, int fd)
#ifdef SO_NO_CHECK
setsockopt(tpeer->sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums));
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ ast_debug(1, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
AST_LIST_INSERT_TAIL(&tpeers, tpeer, list);
}
}
@@ -3809,8 +3799,7 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
tpeer->trunkdata = tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
+ ast_debug(1, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
} else {
ast_log(LOG_WARNING, "Maximum trunk data space exceeded to %s:%d\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
ast_mutex_unlock(&tpeer->lock);
@@ -3927,8 +3916,8 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh,
memcpy_decrypt(workspace, efh->encdata, *datalen - sizeof(struct ast_iax2_full_enc_hdr), dcx);
padding = 16 + (workspace[15] & 0xf);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, workspace[15]);
+ if (iaxdebug)
+ ast_debug(1, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, workspace[15]);
if (*datalen < padding + sizeof(struct ast_iax2_full_hdr))
return -1;
@@ -3942,8 +3931,8 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh,
}
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Decoding mini with length %d\n", *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Decoding mini with length %d\n", *datalen);
if (*datalen < 16 + sizeof(struct ast_iax2_mini_hdr))
return -1;
/* Decrypt */
@@ -3966,24 +3955,24 @@ static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh,
return -1;
if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding full frame %d/%d with length %d\n", fh->type, fh->csub, *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Encoding full frame %d/%d with length %d\n", fh->type, fh->csub, *datalen);
padding = 16 - ((*datalen - sizeof(struct ast_iax2_full_enc_hdr)) % 16);
padding = 16 + (padding & 0xf);
memcpy(workspace, poo, padding);
memcpy(workspace + padding, efh->encdata, *datalen - sizeof(struct ast_iax2_full_enc_hdr));
workspace[15] &= 0xf0;
workspace[15] |= (padding & 0xf);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, workspace[15]);
+ if (iaxdebug)
+ ast_debug(1, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, workspace[15]);
*datalen += padding;
memcpy_encrypt(efh->encdata, workspace, *datalen - sizeof(struct ast_iax2_full_enc_hdr), ecx);
if (*datalen >= 32 + sizeof(struct ast_iax2_full_enc_hdr))
memcpy(poo, workspace + *datalen - 32, 32);
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding mini frame with length %d\n", *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Encoding mini frame with length %d\n", *datalen);
padding = 16 - ((*datalen - sizeof(struct ast_iax2_mini_enc_hdr)) % 16);
padding = 16 + (padding & 0xf);
memcpy(workspace, poo, padding);
@@ -4787,8 +4776,7 @@ static int iax2_write(struct ast_channel *c, struct ast_frame *f)
/* Simple, just queue for transmission */
res = iax2_send(iaxs[callno], f, 0, -1, 0, 0, 0);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
+ ast_debug(1, "Write error: %s\n", strerror(errno));
}
}
/* If it's already gone, just return */
@@ -5067,7 +5055,7 @@ static int raw_hangup(struct sockaddr_in *sin, unsigned short src, unsigned shor
#if 0
if (option_debug)
#endif
- ast_log(LOG_DEBUG, "Raw Hangup %s:%d, src=%d, dst=%d\n",
+ ast_debug(1, "Raw Hangup %s:%d, src=%d, dst=%d\n",
ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
return sendto(sockfd, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
}
@@ -5780,8 +5768,7 @@ static void __expire_registry(void *data)
if (!p)
return;
- if (option_debug)
- ast_log(LOG_DEBUG, "Expiring registration for peer '%s'\n", p->name);
+ ast_debug(1, "Expiring registration for peer '%s'\n", p->name);
if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
realtime_update_peer(p->name, &p->addr, 0);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", p->name);
@@ -6214,8 +6201,7 @@ static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
res = transmit_trunk(fr, &tpeer->addr, tpeer->sockfd);
calls = tpeer->calls;
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
+ ast_debug(1, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
#endif
/* Reset transmit trunk side data */
tpeer->trunkdatalen = 0;
@@ -6291,8 +6277,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
ast_mutex_lock(&drop->lock);
/* Once we have this lock, we're sure nobody else is using it or could use it once we release it,
because by the time they could get tpeerlock, we've already grabbed it */
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
+ ast_debug(1, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
ast_free(drop->trunkdata);
ast_mutex_unlock(&drop->lock);
ast_mutex_destroy(&drop->lock);
@@ -6460,8 +6445,7 @@ static int check_provisioning(struct sockaddr_in *sin, int sockfd, char *si, uns
snprintf(rsi, sizeof(rsi), "si-%s", si);
if (iax_provision_version(&ourver, rsi, 1))
return 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
+ ast_debug(1, "Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
if (ourver != ver)
iax2_provision(sin, sockfd, NULL, rsi, 1);
return 0;
@@ -6881,16 +6865,15 @@ static int socket_process(struct iax2_thread *thread)
iaxs[fr->callno]->peercallno = (unsigned short)(ntohs(mh->callno) & ~IAX_FLAG_FULL);
}
if (ntohs(mh->callno) & IAX_FLAG_FULL) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
+ if (iaxdebug)
+ ast_debug(1, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
/* Check if it's out of order (and not an ACK or INVAL) */
fr->oseqno = fh->oseqno;
fr->iseqno = fh->iseqno;
fr->ts = ntohl(fh->ts);
#ifdef IAXTESTS
if (test_resync) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Simulating frame ts resync, was %u now %u\n", fr->ts, fr->ts + test_resync);
+ ast_debug(1, "Simulating frame ts resync, was %u now %u\n", fr->ts, fr->ts + test_resync);
fr->ts += test_resync;
}
#endif /* IAXTESTS */
@@ -6923,15 +6906,13 @@ static int socket_process(struct iax2_thread *thread)
(f.subclass != IAX_COMMAND_VNAK)) ||
(f.frametype != AST_FRAME_IAX)) {
/* If it's not an ACK packet, it's out of order. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
+ ast_debug(1, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
iaxs[fr->callno]->iseqno, fr->oseqno, f.frametype, f.subclass);
if (iaxs[fr->callno]->iseqno > fr->oseqno) {
/* If we've already seen it, ack it XXX There's a border condition here XXX */
if ((f.frametype != AST_FRAME_IAX) ||
((f.subclass != IAX_COMMAND_ACK) && (f.subclass != IAX_COMMAND_INVAL))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acking anyway\n");
+ ast_debug(1, "Acking anyway\n");
/* XXX Maybe we should handle its ack to us, but then again, it's probably outdated anyway, and if
we have anything to send, we'll retransmit and get an ACK back anyway XXX */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
@@ -6986,8 +6967,8 @@ static int socket_process(struct iax2_thread *thread)
that it says to */
for (x=iaxs[fr->callno]->rseqno; x != fr->iseqno; x++) {
/* Ack the packet with the given timestamp */
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Cancelling transmission of packet %d\n", x);
+ if (iaxdebug)
+ ast_debug(1, "Cancelling transmission of packet %d\n", x);
call_to_destroy = 0;
AST_LIST_LOCK(&queue);
AST_LIST_TRAVERSE(&queue, cur, list) {
@@ -7001,8 +6982,8 @@ static int socket_process(struct iax2_thread *thread)
}
AST_LIST_UNLOCK(&queue);
if (call_to_destroy) {
- if (iaxdebug && option_debug)
- ast_log(LOG_DEBUG, "Really destroying %d, having been acked on final message\n", call_to_destroy);
+ if (iaxdebug)
+ ast_debug(1, "Really destroying %d, having been acked on final message\n", call_to_destroy);
iax2_destroy(call_to_destroy);
}
}
@@ -7015,8 +6996,7 @@ static int socket_process(struct iax2_thread *thread)
return 1;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
+ ast_debug(1, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
}
}
if (inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
@@ -7067,8 +7047,7 @@ static int socket_process(struct iax2_thread *thread)
if (f.frametype == AST_FRAME_VOICE) {
if (f.subclass != iaxs[fr->callno]->voiceformat) {
iaxs[fr->callno]->voiceformat = f.subclass;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
+ ast_debug(1, "Ooh, voice format changed to %d\n", f.subclass);
if (iaxs[fr->callno]->owner) {
int orignative;
retryowner:
@@ -7088,8 +7067,7 @@ retryowner:
ast_mutex_unlock(&iaxs[fr->callno]->owner->lock);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
+ ast_debug(1, "Neat, somebody took away the channel at a magical time but i found it!\n");
/* Free remote variables (if any) */
if (ies.vars)
ast_variables_destroy(ies.vars);
@@ -7101,8 +7079,7 @@ retryowner:
}
if (f.frametype == AST_FRAME_VIDEO) {
if (f.subclass != iaxs[fr->callno]->videoformat) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
+ ast_debug(1, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
iaxs[fr->callno]->videoformat = f.subclass & ~0x1;
}
}
@@ -7113,8 +7090,8 @@ retryowner:
iaxs[fr->callno]->initid = -1;
}
/* Handle the IAX pseudo frame itself */
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "IAX subclass %d received\n", f.subclass);
+ if (iaxdebug)
+ ast_debug(1, "IAX subclass %d received\n", f.subclass);
/* Update last ts unless the frame's timestamp originated with us. */
if (iaxs[fr->callno]->last < fr->ts &&
@@ -7122,8 +7099,8 @@ retryowner:
f.subclass != IAX_COMMAND_PONG &&
f.subclass != IAX_COMMAND_LAGRP) {
iaxs[fr->callno]->last = fr->ts;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
+ if (iaxdebug)
+ ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
}
switch(f.subclass) {
@@ -7395,8 +7372,7 @@ retryowner:
break;
case IAX_COMMAND_HANGUP:
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received hangup\n", fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received hangup\n", fr->callno);
/* Set hangup cause according to remote */
if (ies.causecode && iaxs[fr->callno]->owner)
iaxs[fr->callno]->owner->hangupcause = ies.causecode;
@@ -7414,9 +7390,8 @@ retryowner:
ast_log(LOG_WARNING, "Call rejected by %s: %s\n",
ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr),
ies.cause ? ies.cause : "<Unknown>");
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n",
- fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received reject\n",
+ fr->callno);
}
/* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK,
@@ -7434,22 +7409,19 @@ retryowner:
if (iax_park(ast_bridged_channel(iaxs[fr->callno]->owner), iaxs[fr->callno]->owner)) {
ast_log(LOG_WARNING, "Failed to park call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
} else if (ast_bridged_channel(iaxs[fr->callno]->owner)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
+ ast_debug(1, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
}
} else {
if (ast_async_goto(ast_bridged_channel(iaxs[fr->callno]->owner), iaxs[fr->callno]->context, ies.called_number, 1))
ast_log(LOG_WARNING, "Async goto of '%s' to '%s@%s' failed\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
ies.called_number, iaxs[fr->callno]->context);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Async goto of '%s' to '%s@%s' started\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
- ies.called_number, iaxs[fr->callno]->context);
+ ast_debug(1, "Async goto of '%s' to '%s@%s' started\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
+ ies.called_number, iaxs[fr->callno]->context);
}
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Async goto not applicable on call %d\n", fr->callno);
+ ast_debug(1, "Async goto not applicable on call %d\n", fr->callno);
}
break;
case IAX_COMMAND_ACCEPT:
@@ -7566,8 +7538,7 @@ retryowner2:
/* And wrap up the qualify call */
iax2_destroy(fr->callno);
peer->callno = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
+ ast_debug(1, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
}
break;
case IAX_COMMAND_LAGRQ:
@@ -7587,8 +7558,8 @@ retryowner2:
/* This is a reply we've been given, actually measure the difference */
ts = calc_timestamp(iaxs[fr->callno], 0, &fr->af);
iaxs[fr->callno]->lag = ts - fr->ts;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Peer %s lag measured as %dms\n",
+ if (iaxdebug)
+ ast_debug(1, "Peer %s lag measured as %dms\n",
ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->lag);
}
break;
@@ -7663,8 +7634,7 @@ retryowner2:
}
if (!format) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
+ ast_debug(1, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
}
if (!format) {
@@ -7783,15 +7753,12 @@ retryowner2:
break;
case IAX_COMMAND_INVAL:
iaxs[fr->callno]->error = ENOTCONN;
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received INVAL\n", fr->callno);
iax2_destroy(fr->callno);
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying call %d\n", fr->callno);
+ ast_debug(1, "Destroying call %d\n", fr->callno);
break;
case IAX_COMMAND_VNAK:
- if (option_debug)
- ast_log(LOG_DEBUG, "Received VNAK: resending outstanding frames\n");
+ ast_debug(1, "Received VNAK: resending outstanding frames\n");
/* Force retransmission */
vnak_retransmit(fr->callno, fr->iseqno);
break;
@@ -7955,8 +7922,7 @@ retryowner2:
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_FWDATA, 0, ied0.buf, ied0.pos, -1);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
+ ast_debug(1, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_byte(&ied0, IAX_IE_IAX_UNKNOWN, f.subclass);
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_UNSUPPORT, 0, ied0.buf, ied0.pos, -1);
@@ -8054,8 +8020,8 @@ retryowner2:
/*iaxs[fr->callno]->last = fr->ts; (do it afterwards cos schedule/forward_delivery needs the last ts too)*/
fr->outoforder = 0;
} else {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
+ if (iaxdebug)
+ ast_debug(1, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
fr->outoforder = -1;
}
duped_fr = iaxfrdup2(fr);
@@ -8065,8 +8031,8 @@ retryowner2:
if (iaxs[fr->callno] && iaxs[fr->callno]->last < fr->ts) {
iaxs[fr->callno]->last = fr->ts;
#if 1
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
+ if (iaxdebug)
+ ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
#endif
}
@@ -8165,8 +8131,8 @@ static void *iax2_process_thread(void *data)
static int iax2_do_register(struct iax2_registry *reg)
{
struct iax_ie_data ied;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Sending registration request for '%s'\n", reg->username);
+ if (iaxdebug)
+ ast_debug(1, "Sending registration request for '%s'\n", reg->username);
if (reg->dnsmgr &&
((reg->regstate == REG_STATE_TIMEOUT) || !reg->addr.sin_addr.s_addr)) {
@@ -8185,8 +8151,8 @@ static int iax2_do_register(struct iax2_registry *reg)
reg->callno = 0;
}
if (!reg->addr.sin_addr.s_addr) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Unable to send registration request for '%s' without IP address\n", reg->username);
+ if (iaxdebug)
+ ast_debug(1, "Unable to send registration request for '%s' without IP address\n", reg->username);
/* Setup the next registration attempt */
if (reg->expire > -1)
ast_sched_del(sched, reg->expire);
@@ -8195,14 +8161,13 @@ static int iax2_do_register(struct iax2_registry *reg)
}
if (!reg->callno) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocate call number\n");
+ ast_debug(1, "Allocate call number\n");
reg->callno = find_callno(0, 0, &reg->addr, NEW_FORCE, 1, defaultsockfd);
if (reg->callno < 1) {
ast_log(LOG_WARNING, "Unable to create call for registration\n");
return -1;
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Registration created on call %d\n", reg->callno);
+ } else
+ ast_debug(1, "Registration created on call %d\n", reg->callno);
iaxs[reg->callno]->reg = reg;
}
/* Schedule the next registration attempt */
@@ -8239,12 +8204,10 @@ static int iax2_provision(struct sockaddr_in *end, int sockfd, char *dest, const
memset(&cai, 0, sizeof(cai));
- if (option_debug)
- ast_log(LOG_DEBUG, "Provisioning '%s' from template '%s'\n", dest, template);
+ ast_debug(1, "Provisioning '%s' from template '%s'\n", dest, template);
if (iax_provision_build(&provdata, &sig, template, force)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
+ ast_debug(1, "No provisioning found for template '%s'\n", template);
return 0;
}
@@ -8529,8 +8492,8 @@ static void *sched_thread(void *ignore)
pthread_testcancel();
count = ast_sched_runq(sched);
- if (count >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
+ if (count >= 20)
+ ast_debug(1, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
}
return NULL;
@@ -8589,14 +8552,14 @@ static void *network_thread(void *ignore)
AST_LIST_UNLOCK(&queue);
pthread_testcancel();
- if (count >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
+ if (count >= 20)
+ ast_debug(1, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
/* Now do the IO, and run scheduled tasks */
res = ast_io_wait(io, wakeup);
if (res >= 0) {
- if (res >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
+ if (res >= 20)
+ ast_debug(1, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
}
}
return NULL;
@@ -8670,8 +8633,7 @@ static int check_srcaddr(struct sockaddr *sa, socklen_t salen)
res = bind(sd, sa, salen);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
+ ast_debug(1, "Can't bind: %s\n", strerror(errno));
close(sd);
return 1;
}
@@ -8750,8 +8712,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
srcaddr, peer->name);
return -1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
+ ast_debug(1, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
return 0;
}
}
@@ -9808,9 +9769,8 @@ static int cache_get_callno_locked(const char *data)
if (create_addr(pds.peer, &sin, &cai))
return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "peer: %s, username: %s, password: %s, context: %s\n",
- pds.peer, pds.username, pds.password, pds.context);
+ ast_debug(1, "peer: %s, username: %s, password: %s, context: %s\n",
+ pds.peer, pds.username, pds.password, pds.context);
callno = find_callno(0, 0, &sin, NEW_FORCE, 1, cai.sockfd);
if (callno < 1) {
@@ -10247,17 +10207,15 @@ static int iax2_devicestate(void *data)
if (ast_strlen_zero(pds.peer))
return res;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for device %s\n", pds.peer);
+ ast_debug(3, "Checking device state for device %s\n", pds.peer);
/* SLD: FIXME: second call to find_peer during registration */
if (!(p = find_peer(pds.peer, 1)))
return res;
res = AST_DEVICE_UNAVAILABLE;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
- pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
+ ast_debug(3, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
+ pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
(!p->maxms || ((p->lastms > -1) && (p->historicms <= p->maxms)))) {
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 132362439..3035f8c5b 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -407,8 +407,7 @@ static int jingle_answer(struct ast_channel *ast)
struct jingle *client = p->parent;
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answer!\n");
+ ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
jingle_accept_call(client, p);
ast_mutex_unlock(&p->lock);
@@ -495,8 +494,7 @@ static int jingle_is_answered(struct jingle *client, ikspak *pak)
{
struct jingle_pvt *tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
@@ -564,8 +562,7 @@ static int jingle_hangup_farend(struct jingle *client, ikspak *pak)
{
struct jingle_pvt *tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
@@ -710,8 +707,7 @@ static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from,
struct aji_buddy *buddy;
char idroster[200];
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
+ ast_debug(1, "The client is %s for alloc\n", client->name);
if (!sid && !strchr(from, '/')) { /* I started call! */
if (!strcasecmp(client->name, "guest")) {
buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, from);
@@ -1095,8 +1091,7 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats =
(p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
@@ -1104,8 +1099,8 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
}
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
- if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ if (f && (f->frametype == AST_FRAME_DTMF))
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
@@ -1443,11 +1438,9 @@ static int jingle_parser(void *data, ikspak *pak)
/* New call */
jingle_newcall(client, pak);
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_NEGOTIATE)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "About to add candidate!\n");
+ ast_debug(3, "About to add candidate!\n");
jingle_add_candidate(client, pak);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Candidate Added!\n");
+ ast_debug(3, "Candidate Added!\n");
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_ACCEPT)) {
jingle_is_answered(client, pak);
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "content-info")) {
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 1fd7f2fae..47b862b37 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -142,8 +142,7 @@ static int local_devicestate(void *data)
if ((opts = strchr(context, '/')))
*opts = '\0';
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
+ ast_debug(3, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
res = ast_exists_extension(NULL, context, exten, 1, NULL);
if (!res)
@@ -303,8 +302,7 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
if (!ast_test_flag(p, LOCAL_ALREADY_MASQED))
res = local_queue_frame(p, isoutbound, f, ast);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
+ ast_debug(1, "Not posting to queue since already masked on '%s'\n", ast->name);
res = 0;
}
if (!res)
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 20b7447de..9c3161b77 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -490,8 +490,7 @@ static int unalloc_sub(struct mgcp_subchannel *sub)
ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name, p->parent->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
+ ast_debug(1, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
sub->owner = NULL;
if (!ast_strlen_zero(sub->cxident)) {
@@ -757,8 +756,7 @@ static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
/* XXX Should schedule retransmission XXX */
/* SC
} else
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
+ ast_debug(1, "Deferring transmission of transaction %d\n", seqno);
*/
return 0;
}
@@ -771,8 +769,7 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
struct mgcp_request **queue, *q, *r, *t;
ast_mutex_t *l;
- if (option_debug)
- ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
+ ast_debug(1, "Slow sequence is %d\n", p->slowsequence);
if (p->slowsequence) {
queue = &p->cmd_queue;
l = &p->cmd_queue_lock;
@@ -948,17 +945,13 @@ static int mgcp_hangup(struct ast_channel *ast)
struct mgcp_subchannel *sub = ast->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
- if (option_debug) {
- ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
- }
+ ast_debug(1, "mgcp_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ ast_debug(1, "Asked to hangup channel not connected\n");
return 0;
}
if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
+ ast_debug(1, "Invalid magic. MGCP subchannel freed up already.\n");
return 0;
}
ast_mutex_lock(&sub->lock);
@@ -1210,8 +1203,7 @@ static int mgcp_answer(struct ast_channel *ast)
}
if (ast->_state != AST_STATE_UP) {
ast_setstate(ast, AST_STATE_UP);
- if (option_debug)
- ast_log(LOG_DEBUG, "mgcp_answer(%s)\n", ast->name);
+ ast_debug(1, "mgcp_answer(%s)\n", ast->name);
transmit_notify_request(sub, "");
transmit_modify_request(sub);
}
@@ -1232,8 +1224,7 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != sub->owner->nativeformats) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
sub->owner->nativeformats = f->subclass;
ast_set_read_format(sub->owner, sub->owner->readformat);
ast_set_write_format(sub->owner, sub->owner->writeformat);
@@ -1678,20 +1669,17 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
/* SC */
p = g->endpoints;
while(p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Searching on %s@%s for subchannel\n",
- p->name, g->name);
+ ast_debug(1, "Searching on %s@%s for subchannel\n",
+ p->name, g->name);
if (msgid) {
#if 0 /* new transport mech */
sub = p->sub;
do {
- if (option_debug)
- ast_log(LOG_DEBUG, "Searching on %s@%s-%d for subchannel with lastout: %d\n",
- p->name, g->name, sub->id, msgid);
+ ast_debug(1, "Searching on %s@%s-%d for subchannel with lastout: %d\n",
+ p->name, g->name, sub->id, msgid);
if (sub->lastout == msgid) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found subchannel sub%d to handle request %d sub->lastout: %d\n",
- sub->id, msgid, sub->lastout);
+ ast_debug(1, "Found subchannel sub%d to handle request %d sub->lastout: %d\n",
+ sub->id, msgid, sub->lastout);
found = 1;
break;
}
@@ -1707,9 +1695,8 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
/* SC */
break;
} else if (name && !strcasecmp(p->name, tmp)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
- p->name, g->name, p->sub->id);
+ ast_debug(1, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
+ p->name, g->name, p->sub->id);
sub = p->sub;
found = 1;
break;
@@ -2727,8 +2714,7 @@ static void *mgcp_ss(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ ast_debug(1, "not enough digits (and no ambiguous match)...\n");
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
transmit_notify_request(sub, "G/cg");
/*zt_wait_event(p->subs[index].zfd);*/
@@ -2851,8 +2837,7 @@ static void *mgcp_ss(void *data)
timeout = firstdigittimeout;
} else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1, chan->cid.cid_num) &&
((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+ ast_debug(1, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
break;
}
if (!timeout)
@@ -2865,13 +2850,11 @@ static void *mgcp_ss(void *data)
for (;;) {
res = ast_waitfordigit(chan, to);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Timeout...\n");
+ ast_debug(1, "Timeout...\n");
break;
}
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup...\n");
+ ast_debug(1, "Got hangup...\n");
ast_hangup(chan);
break;
}
@@ -2951,9 +2934,8 @@ static int attempt_transfer(struct mgcp_endpoint *p)
/* Tell the caller not to hangup */
return 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n",
- p->sub->owner->name, p->sub->next->owner->name);
+ ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
+ p->sub->owner->name, p->sub->next->owner->name);
p->sub->next->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (p->sub->next->owner) {
p->sub->next->alreadygone = 1;
@@ -3116,8 +3098,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
ev = get_header(req, "O");
s = strchr(ev, '/');
if (s) ev = s + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
+ ast_debug(1, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
/* Keep looking for events unless this was a hangup */
if (strcasecmp(ev, "hu") && strcasecmp(ev, "hd") && strcasecmp(ev, "ping")) {
transmit_notify_request(sub, p->curtone);
@@ -3215,8 +3196,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
} else if (!strcasecmp(ev, "hu")) {
p->hookstate = MGCP_ONHOOK;
sub->cxmode = MGCP_CX_RECVONLY;
- if (option_debug)
- ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
+ ast_debug(1, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
/* Do we need to send MDCX before a DLCX ?
if (sub->rtp) {
transmit_modify_request(sub);
@@ -3388,8 +3368,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
ast_mutex_lock(&gw->msgs_lock);
for (prev = NULL, cur = gw->msgs; cur; prev = cur, cur = cur->next) {
if (cur->seqno == ident) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident);
+ ast_debug(1, "Got response back on transaction %d\n", ident);
if (prev)
prev->next = cur->next;
else
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 450ee6cc3..e74972aa4 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -727,8 +727,7 @@ static void send_digit_to_chan(struct chan_list *cl, char digit )
ast_playtones_start(chan,0,dtmf_tones[15], 0);
else {
/* not handled */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
/*** CLI HANDLING ***/
@@ -2300,8 +2299,7 @@ static int misdn_hangup(struct ast_channel *ast)
struct misdn_bchannel *bc = NULL;
const char *varcause = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
+ ast_debug(1, "misdn_hangup(%s)\n", ast->name);
if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) ) ) return -1;
@@ -2322,8 +2320,7 @@ static int misdn_hangup(struct ast_channel *ast)
CLEAN_CH:
/* between request and call */
- if (option_debug)
- ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
+ ast_debug(1, "State Reserved (or nothing) => chanIsAvail\n");
MISDN_ASTERISK_TECH_PVT(ast) = NULL;
cl_dequeue_chan(&cl_te, p);
@@ -2467,8 +2464,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
if (!f || (f->frametype != AST_FRAME_DTMF))
return frame;
- if (option_debug)
- ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
+ ast_debug(1, "Detected inband DTMF digit: %c\n", f->subclass);
if (tmp->faxdetect && (f->subclass == 'f')) {
/* Fax tone -- Handle and return NULL */
@@ -2504,8 +2500,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n", context, ast->exten);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
}
break;
case 2:
@@ -2513,8 +2508,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ ast_debug(1, "Fax already handled\n");
}
}
@@ -2654,10 +2648,10 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
{
int i, max = 5 > frame->samples ? frame->samples : 5;
- ast_log(LOG_DEBUG, "write2mISDN %p %d bytes: ", p, frame->samples);
+ ast_debug(1, "write2mISDN %p %d bytes: ", p, frame->samples);
for (i = 0; i < max ; i++)
- ast_log(LOG_DEBUG, "%2.2x ", ((char*) frame->data)[i]);
+ ast_debug(1, "%2.2x ", ((char*) frame->data)[i]);
}
#endif
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 3fb606f5a..1c342c6fd 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -102,8 +102,7 @@ static int nbs_call(struct ast_channel *ast, char *dest, int timeout)
}
/* When we call, it just works, really, there's no destination... Just
ring the phone and wait for someone to answer */
- if (option_debug)
- ast_log(LOG_DEBUG, "Calling %s on %s\n", dest, ast->name);
+ ast_debug(1, "Calling %s on %s\n", dest, ast->name);
/* If we can't connect, return congestion */
if (nbs_connect(p->nbs)) {
@@ -173,8 +172,7 @@ static int nbs_hangup(struct ast_channel *ast)
{
struct nbs_pvt *p;
p = ast->tech_pvt;
- if (option_debug)
- ast_log(LOG_DEBUG, "nbs_hangup(%s)\n", ast->name);
+ ast_debug(1, "nbs_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -200,8 +198,7 @@ static struct ast_frame *nbs_xread(struct ast_channel *ast)
p->fr.delivery.tv_sec = 0;
p->fr.delivery.tv_usec = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
+ ast_debug(1, "Returning null frame on %s\n", ast->name);
return &p->fr;
}
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 31cabd4eb..e33d1a1d2 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -208,8 +208,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
{
struct phone_pvt *p = chan->tech_pvt;
int res=-1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
switch(condition) {
case AST_CONTROL_FLASH:
ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
@@ -249,7 +248,7 @@ static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int dur
struct phone_pvt *p;
int outdigit;
p = ast->tech_pvt;
- ast_log(LOG_DEBUG, "Dialed %c\n", digit);
+ ast_debug(1, "Dialed %c\n", digit);
switch(digit) {
case '0':
case '1':
@@ -280,7 +279,7 @@ static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int dur
ast_log(LOG_WARNING, "Unknown digit '%c'\n", digit);
return -1;
}
- ast_log(LOG_DEBUG, "Dialed %d\n", outdigit);
+ ast_debug(1, "Dialed %d\n", outdigit);
ioctl(p->fd, PHONE_PLAY_TONE, outdigit);
p->lastformat = -1;
return 0;
@@ -320,8 +319,7 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
ast_log(LOG_WARNING, "phone_call called on %s, neither down nor reserved\n", ast->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
+ ast_debug(1, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
start = IXJ_PHONE_RING_START(cid);
if (start == -1)
@@ -346,8 +344,7 @@ static int phone_hangup(struct ast_channel *ast)
{
struct phone_pvt *p;
p = ast->tech_pvt;
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_hangup(%s)\n", ast->name);
+ ast_debug(1, "phone_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -365,16 +362,13 @@ static int phone_hangup(struct ast_channel *ast)
/* If it's an FXO, hang them up */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
- }
+ if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
}
/* If they're off hook, give a busy signal */
if (ioctl(p->fd, PHONE_HOOKSTATE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hunghup, giving busy signal\n");
+ ast_debug(1, "Got hunghup, giving busy signal\n");
ioctl(p->fd, PHONE_BUSY);
p->cpt = 1;
}
@@ -467,18 +461,13 @@ static int phone_answer(struct ast_channel *ast)
p = ast->tech_pvt;
/* In case it's a LineJack, take it off hook */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
- }
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Took linejack off hook\n");
- }
+ if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
+ else
+ ast_debug(1, "Took linejack off hook\n");
}
phone_setup(ast);
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_answer(%s)\n", ast->name);
+ ast_debug(1, "phone_answer(%s)\n", ast->name);
ast->rings = 0;
ast_setstate(ast, AST_STATE_UP);
return 0;
@@ -516,8 +505,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
phonee.bytes = ioctl(p->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_exception(): DTMF\n");
+ ast_debug(1, "phone_exception(): DTMF\n");
/* We've got a digit -- Just handle this nicely and easily */
digit = ioctl(p->fd, PHONE_GET_DTMF_ASCII);
@@ -526,12 +514,10 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
return &p->fr;
}
if (phonee.bits.hookstate) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hookstate changed\n");
+ ast_debug(1, "Hookstate changed\n");
res = ioctl(p->fd, PHONE_HOOKSTATE);
/* See if we've gone on hook, if so, notify by returning NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "New hookstate: %d\n", res);
+ ast_debug(1, "New hookstate: %d\n", res);
if (!res && (p->mode != MODE_FXO))
return NULL;
else {
@@ -943,8 +929,7 @@ static void phone_check_exception(struct phone_pvt *i)
union telephony_exception phonee;
/* XXX Do something XXX */
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Exception!\n");
+ ast_debug(1, "Exception!\n");
#endif
phonee.bytes = ioctl(i->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
@@ -972,8 +957,7 @@ static void phone_check_exception(struct phone_pvt *i)
/* XXX This should probably be justified better XXX */
} else if (!ast_canmatch_extension(NULL, "default", i->ext, 1, i->cid_num)) {
/* It's not a valid extension, give a busy signal */
- if (option_debug)
- ast_log(LOG_DEBUG, "%s can't match anything in %s or default\n", i->ext, i->context);
+ ast_debug(1, "%s can't match anything in %s or default\n", i->ext, i->context);
ioctl(i->fd, PHONE_BUSY);
i->cpt = 1;
}
@@ -1100,8 +1084,7 @@ static void *do_monitor(void *data)
}
/* Okay, select has finished. Let's see what happened. */
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
+ ast_debug(1, "select return %d: %s\n", res, strerror(errno));
continue;
}
/* If there are no fd's changed, just continue, it's probably time
@@ -1189,22 +1172,19 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain)
}
if (mode == MODE_FXO) {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ ast_debug(1, "Unable to set port to PSTN\n");
}
} else {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_POTS))
if (mode != MODE_FXS)
- ast_log(LOG_DEBUG, "Unable to set port to POTS\n");
+ ast_debug(1, "Unable to set port to POTS\n");
}
ioctl(tmp->fd, PHONE_PLAY_STOP);
ioctl(tmp->fd, PHONE_REC_STOP);
ioctl(tmp->fd, PHONE_RING_STOP);
ioctl(tmp->fd, PHONE_CPT_STOP);
- if (ioctl(tmp->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",iface, strerror(errno));
- }
+ if (ioctl(tmp->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",iface, strerror(errno));
if (echocancel != AEC_OFF)
ioctl(tmp->fd, IXJCTL_AEC_START, echocancel);
if (silencesupression)
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index bd4f57e47..42894d3bc 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1696,16 +1696,14 @@ static void unref_user(struct sip_user *user)
static void registry_unref(struct sip_registry *reg)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
+ ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
ASTOBJ_UNREF(reg, sip_registry_destroy);
}
/*! \brief Add object reference to SIP registry */
static struct sip_registry *registry_addref(struct sip_registry *reg)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
+ ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
return ASTOBJ_REF(reg); /* Add pointer to registry in packet */
}
@@ -1742,12 +1740,10 @@ static const char *referstatus2str(enum referstatus rstatus)
a dialog */
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
{
- if (option_debug) {
- if (p->initreq.headers)
- ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
- else
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
- }
+ if (p->initreq.headers)
+ ast_debug(1, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
+ else
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
/* Use this as the basis */
copy_request(&p->initreq, req);
parse_request(&p->initreq);
@@ -1758,8 +1754,7 @@ static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
/*! \brief Encapsulate setting of SIP_ALREADYGONE to be able to trace it with debugging */
static void sip_alreadygone(struct sip_pvt *dialog)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
+ ast_debug(3, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
ast_set_flag(&dialog->flags[0], SIP_ALREADYGONE);
}
@@ -1798,19 +1793,19 @@ static struct sip_proxy *proxy_allocate(char *name, char *port, int force)
static struct sip_proxy *obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
{
if (peer && peer->outboundproxy) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Applying peer OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Applying peer OBproxy to this call\n");
append_history(dialog, "OBproxy", "Using peer obproxy %s", peer->outboundproxy->name);
return peer->outboundproxy;
}
if (global_outboundproxy.name[0]) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Applying global OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Applying global OBproxy to this call\n");
append_history(dialog, "OBproxy", "Using global obproxy %s", global_outboundproxy.name);
return &global_outboundproxy;
}
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Not applying OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Not applying OBproxy to this call\n");
return NULL;
}
@@ -1855,30 +1850,30 @@ static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported
return 0;
temp = ast_strdupa(supported);
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
+ if (sipdebug)
+ ast_debug(3, "Begin: parsing SIP \"Supported: %s\"\n", supported);
for (next = temp; next; next = sep) {
found = FALSE;
if ( (sep = strchr(next, ',')) != NULL)
*sep++ = '\0';
next = ast_skip_blanks(next);
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Found SIP option: -%s-\n", next);
+ if (sipdebug)
+ ast_debug(3, "Found SIP option: -%s-\n", next);
for (i=0; i < (sizeof(sip_options) / sizeof(sip_options[0])); i++) {
if (!strcasecmp(next, sip_options[i].text)) {
profile |= sip_options[i].id;
found = TRUE;
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Matched SIP option: %s\n", next);
+ if (sipdebug)
+ ast_debug(3, "Matched SIP option: %s\n", next);
break;
}
}
- if (!found && option_debug > 2 && sipdebug) {
+ if (!found && sipdebug) {
if (!strncasecmp(next, "x-", 2))
- ast_log(LOG_DEBUG, "Found private SIP option, not supported: %s\n", next);
+ ast_debug(3, "Found private SIP option, not supported: %s\n", next);
else
- ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
+ ast_debug(3, "Found no match for SIP option: %s (Please file bug report!)\n", next);
}
}
@@ -1986,10 +1981,8 @@ static enum sip_result ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *
ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
}
*us = externip.sin_addr;
- if (option_debug) {
- ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n",
- ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
- }
+ ast_debug(1, "Target address %s is not local, substituting externip\n",
+ ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
} else if (bindaddr.sin_addr.s_addr)
*us = bindaddr.sin_addr;
return AST_SUCCESS;
@@ -2042,13 +2035,13 @@ static int retrans_pkt(void *data)
if (pkt->retrans < MAX_RETRANS) {
pkt->retrans++;
if (!pkt->timer_t1) { /* Re-schedule using timer_a and timer_t1 */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n", pkt->retransid, sip_methods[pkt->method].text, pkt->method);
+ if (sipdebug)
+ ast_debug(4, "SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n", pkt->retransid, sip_methods[pkt->method].text, pkt->method);
} else {
int siptimer_a;
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n", pkt->retransid, pkt->retrans, sip_methods[pkt->method].text, pkt->method);
+ if (sipdebug)
+ ast_debug(4, "SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n", pkt->retransid, pkt->retrans, sip_methods[pkt->method].text, pkt->method);
if (!pkt->timer_a)
pkt->timer_a = 2 ;
else
@@ -2061,8 +2054,7 @@ static int retrans_pkt(void *data)
/* Reschedule re-transmit */
reschedule = siptimer_a;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
+ ast_debug(4, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
}
if (sip_debug_test_pvt(pkt->owner)) {
@@ -2119,8 +2111,7 @@ static int retrans_pkt(void *data)
if (pkt->method != SIP_OPTIONS && pkt->method != SIP_REGISTER) {
ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);
sip_alreadygone(pkt->owner);
- if (option_debug)
- append_history(pkt->owner, "DialogKill", "Killing this failed dialog immediately");
+ append_history(pkt->owner, "DialogKill", "Killing this failed dialog immediately");
}
}
}
@@ -2176,8 +2167,8 @@ static enum sip_result __sip_reliable_xmit(struct sip_pvt *p, int seqno, int res
/* Schedule retransmission */
pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
+ if (sipdebug)
+ ast_debug(4, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
pkt->next = p->packets;
p->packets = pkt;
if (sipmethod == SIP_INVITE) {
@@ -2206,8 +2197,7 @@ static int __sip_autodestruct(void *data)
transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE); /* Send last notification */
p->subscribed = NONE;
append_history(p, "Subscribestatus", "timeout");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
+ ast_debug(3, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
return 10000; /* Reschedule this destruction so that we know that it's gone */
}
@@ -2222,15 +2212,13 @@ static int __sip_autodestruct(void *data)
ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text);
ast_queue_hangup(p->owner);
} else if (p->refer) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Finally hanging up channel after transfer: %s\n", p->callid);
+ ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid);
transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else {
append_history(p, "AutoDestroy", "%s", p->callid);
- if (option_debug)
- ast_log(LOG_DEBUG, "Auto destroying SIP dialog '%s'\n", p->callid);
+ ast_debug(3, "Auto destroying SIP dialog '%s'\n", p->callid);
sip_destroy(p); /* Go ahead and destroy dialog. All attempts to recover is done */
}
return 0;
@@ -2286,13 +2274,12 @@ static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
if (ast_test_flag(cur, FLAG_RESPONSE) || cur->method == sipmethod) {
msg = "Found";
if (!resp && (seqno == p->pendinginvite)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
+ ast_debug(1, "Acked pending invite %d\n", p->pendinginvite);
p->pendinginvite = 0;
}
if (cur->retransid > -1) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
+ if (sipdebug)
+ ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
ast_sched_del(sched, cur->retransid);
cur->retransid = -1;
}
@@ -2302,9 +2289,8 @@ static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
}
}
sip_pvt_unlock(p);
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n",
- p->callid, resp ? "Response" : "Request", seqno, msg);
+ ast_debug(1, "Stopping retransmission on '%s' of %s %d: Match %s\n",
+ p->callid, resp ? "Response" : "Request", seqno, msg);
}
/*! \brief Pretend to ack all packets
@@ -2336,8 +2322,8 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
(ast_test_flag(cur, FLAG_RESPONSE) || method_match(sipmethod, cur->data))) {
/* this is our baby */
if (cur->retransid > -1) {
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
+ if (sipdebug)
+ ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
ast_sched_del(sched, cur->retransid);
cur->retransid = -1;
}
@@ -2345,8 +2331,7 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
break;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
+ ast_debug(1, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
return res;
}
@@ -2578,8 +2563,8 @@ static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data
ast_string_field_build(p, url, "<%s>;mode=active", data);
- if (sip_debug_test_pvt(p) && option_debug)
- ast_log(LOG_DEBUG, "Send URL %s, state = %d!\n", data, chan->_state);
+ if (sip_debug_test_pvt(p))
+ ast_debug(1, "Send URL %s, state = %d!\n", data, chan->_state);
switch (chan->_state) {
case AST_STATE_RING:
@@ -2698,8 +2683,7 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
/*! \brief Destroy peer object from memory */
static void sip_destroy_peer(struct sip_peer *peer)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
+ ast_debug(3, "Destroying SIP peer %s\n", peer->name);
if (peer->outboundproxy)
ast_free(peer->outboundproxy);
@@ -2731,8 +2715,7 @@ static void sip_destroy_peer(struct sip_peer *peer)
apeerobjs--;
else if (ast_test_flag(&peer->flags[0], SIP_REALTIME)) {
rpeerobjs--;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
+ ast_debug(3,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
} else
speerobjs--;
clear_realm_authentication(peer->auth);
@@ -2833,8 +2816,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
return NULL;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
+ ast_debug(3,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
/* Cache peer */
@@ -2886,8 +2868,7 @@ static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int
/*! \brief Remove user object from in-memory storage */
static void sip_destroy_user(struct sip_user *user)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying user object from memory: %s\n", user->name);
+ ast_debug(3, "Destroying user object from memory: %s\n", user->name);
ast_free_ha(user->ha);
if (user->chanvars) {
ast_variables_destroy(user->chanvars);
@@ -2961,23 +2942,19 @@ static void do_setnat(struct sip_pvt *p, int natflags)
const char *mode = natflags ? "On" : "Off";
if (p->rtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on RTP to %s\n", mode);
ast_rtp_setnat(p->rtp, natflags);
}
if (p->vrtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on VRTP to %s\n", mode);
ast_rtp_setnat(p->vrtp, natflags);
}
if (p->udptl) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", mode);
+ ast_debug(1, "Setting NAT on UDPTL to %s\n", mode);
ast_udptl_setnat(p->udptl, natflags);
}
if (p->trtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on TRTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on TRTP to %s\n", mode);
ast_rtp_setnat(p->trtp, natflags);
}
}
@@ -3016,8 +2993,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
else if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_NONE )
dialog->t38.capability |= T38FAX_UDP_EC_NONE;
dialog->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"Our T38 capability (%d)\n", dialog->t38.capability);
+ ast_debug(2,"Our T38 capability (%d)\n", dialog->t38.capability);
}
dialog->t38.jointcapability = dialog->t38.capability;
} else if (dialog->udptl) {
@@ -3222,8 +3198,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
p->options->replaces = ast_var_value(current);
} else if (!strcasecmp(ast_var_name(current), "T38CALL")) {
p->t38.state = T38_LOCAL_DIRECT;
- if (option_debug)
- ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(1,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
}
}
@@ -3235,15 +3210,14 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
char buf[BUFSIZ/2];
if (referer) {
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "Call for %s transfered by %s\n", p->username, referer);
+ if (sipdebug)
+ ast_debug(3, "Call for %s transfered by %s\n", p->username, referer);
snprintf(buf, sizeof(buf)-1, "-> %s (via %s)", p->cid_name, referer);
} else
snprintf(buf, sizeof(buf)-1, "-> %s", p->cid_name);
ast_string_field_set(p, cid_name, buf);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username);
+ ast_debug(1, "Outgoing Call for %s\n", p->username);
res = update_call_counter(p, INC_CALL_RINGING);
@@ -3262,8 +3236,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
int xmitres;
p->t38.jointcapability = p->t38.capability;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
+ ast_debug(2,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
xmitres = transmit_invite(p, SIP_INVITE, 1, 2);
if (xmitres == XMIT_ERROR)
return -1;
@@ -3281,15 +3254,13 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
static void sip_registry_destroy(struct sip_registry *reg)
{
/* Really delete */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
+ ast_debug(3, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
if (reg->call) {
/* Clear registry before destroying to ensure
we don't get reentered trying to grab the registry lock */
reg->call->registry = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
sip_destroy(reg->call);
}
if (reg->expire > -1)
@@ -3308,13 +3279,12 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
struct sip_pvt *cur, *prev = NULL;
struct sip_pkt *cp;
- if (sip_debug_test_pvt(p) || option_debug > 2)
+ if (sip_debug_test_pvt(p))
ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
update_call_counter(p, DEC_CALL_LIMIT);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
+ ast_debug(2, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
}
/* Remove link from peer to subscription of MWI */
@@ -3358,8 +3328,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
if (p->owner) {
if (lockowner)
ast_channel_lock(p->owner);
- if (option_debug)
- ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
+ ast_debug(1, "Detaching from %s\n", p->owner->name);
p->owner->tech_pvt = NULL;
if (lockowner)
ast_channel_unlock(p->owner);
@@ -3429,8 +3398,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
struct sip_user *u = NULL;
struct sip_peer *p = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
+ ast_debug(3, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
/* Test if we need to check call limits, in order to avoid
realtime lookups if we do not need it */
@@ -3451,8 +3419,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
ast_copy_string(name, fup->peername, sizeof(name));
}
if (!p && !u) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name);
+ ast_debug(2, "%s is not a local device, no call limit\n", name);
return 0;
}
@@ -3473,8 +3440,8 @@ static int update_call_counter(struct sip_pvt *fup, int event)
/* Decrement onhold count if applicable */
if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold)
sip_peer_hold(fup, FALSE);
- if (option_debug > 1 || sipdebug)
- ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
+ if (sipdebug)
+ ast_debug(2, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
break;
case INC_CALL_RINGING:
@@ -3499,8 +3466,8 @@ static int update_call_counter(struct sip_pvt *fup, int event)
/* Continue */
ast_atomic_fetchadd_int(inuse, +1);
ast_set_flag(&fup->flags[0], SIP_INC_COUNT);
- if (option_debug > 1 || sipdebug) {
- ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
+ if (sipdebug) {
+ ast_debug(2, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
}
break;
@@ -3525,8 +3492,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
/*! \brief Destroy SIP call structure */
static void sip_destroy(struct sip_pvt *p)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP dialog %s\n", p->callid);
+ ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
__sip_destroy(p, TRUE, TRUE);
}
@@ -3681,8 +3647,7 @@ static const char *hangup_cause2sip(int cause)
case AST_CAUSE_NOTDEFINED:
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
+ ast_debug(1, "AST hangup cause %d (no match found in SIP)\n", cause);
return NULL;
}
@@ -3701,19 +3666,17 @@ static int sip_hangup(struct ast_channel *ast)
struct ast_channel *oldowner = ast;
if (!p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
+ ast_debug(1, "Asked to hangup channel that was not connected\n");
return 0;
}
if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+ if (sipdebug)
+ ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
}
- if (option_debug >3)
- ast_log(LOG_DEBUG, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
+ ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
if (p->autokillid > -1)
sip_cancel_destroy(p);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -3723,21 +3686,18 @@ static int sip_hangup(struct ast_channel *ast)
p->owner = NULL; /* Owner will be gone after we return, so take it away */
return 0;
}
- if (option_debug) {
- if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer && option_debug)
- ast_log(LOG_DEBUG, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
- }
- }
- if (option_debug && ast_test_flag(ast, AST_FLAG_ZOMBIE))
- ast_log(LOG_DEBUG, "Hanging up zombie call. Be scared.\n");
+ if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer)
+ ast_debug(1, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
+ else
+ ast_debug(1, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
+
+ if (ast_test_flag(ast, AST_FLAG_ZOMBIE))
+ ast_debug(1, "Hanging up zombie call. Be scared.\n");
sip_pvt_lock(p);
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+ if (sipdebug)
+ ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
}
@@ -3751,8 +3711,7 @@ static int sip_hangup(struct ast_channel *ast)
/* In case of re-invites, the call might be UP even though we have an incomplete invite transaction */
if (p->invitestate < INV_COMPLETED && p->owner->_state != AST_STATE_UP) {
needcancel = TRUE;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
+ ast_debug(4, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
}
stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
@@ -3889,12 +3848,10 @@ static int sip_answer(struct ast_channel *ast)
try_suggested_sip_codec(p);
ast_setstate(ast, AST_STATE_UP);
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP answering channel: %s\n", ast->name);
+ ast_debug(1, "SIP answering channel: %s\n", ast->name);
if (p->t38.state == T38_PEER_DIRECT) {
p->t38.state = T38_ENABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(2,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
res = transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
} else
res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
@@ -4003,10 +3960,10 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
int ret = -1;
struct sip_pvt *p;
- if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE) && option_debug)
- ast_log(LOG_DEBUG, "New channel is zombie\n");
- if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE) && option_debug)
- ast_log(LOG_DEBUG, "Old channel is zombie\n");
+ if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE))
+ ast_debug(1, "New channel is zombie\n");
+ if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE))
+ ast_debug(1, "Old channel is zombie\n");
if (!newchan || !newchan->tech_pvt) {
if (!newchan)
@@ -4026,8 +3983,7 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
p->owner = newchan;
ret = 0;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
+ ast_debug(3, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
sip_pvt_unlock(p);
return ret;
@@ -4252,15 +4208,13 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
/* Set the native formats for audio and merge in video */
tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | video | text;
- if (option_debug > 2) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, tmp->nativeformats));
- ast_log(LOG_DEBUG, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->jointcapability));
- ast_log(LOG_DEBUG, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->capability));
- ast_log(LOG_DEBUG, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, ast_codec_choose(&i->prefs, what, 1)));
- if (i->prefcodec)
- ast_log(LOG_DEBUG, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->prefcodec));
- }
+ char buf[BUFSIZ];
+ ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, tmp->nativeformats));
+ ast_debug(3, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->jointcapability));
+ ast_debug(3, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->capability));
+ ast_debug(3, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, ast_codec_choose(&i->prefs, what, 1)));
+ if (i->prefcodec)
+ ast_debug(3, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->prefcodec));
/* XXX Why are we choosing a codec from the native formats?? */
fmt = ast_best_codec(tmp->nativeformats);
@@ -4283,12 +4237,10 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
needtext = i->jointcapability & AST_FORMAT_TEXT_MASK; /* Inbound call */
}
- if (option_debug > 2) {
- if (needvideo)
- ast_log(LOG_DEBUG, "This channel can handle video! HOLLYWOOD next!\n");
- else
- ast_log(LOG_DEBUG, "This channel will not be able to handle video.\n");
- }
+ if (needvideo)
+ ast_debug(3, "This channel can handle video! HOLLYWOOD next!\n");
+ else
+ ast_debug(3, "This channel will not be able to handle video.\n");
@@ -4566,14 +4518,11 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
if (f && f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
if (!(f->subclass & p->jointcapability)) {
- if (option_debug) {
- ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
- ast_getformatname(f->subclass), p->owner->name);
- }
+ ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
+ ast_getformatname(f->subclass), p->owner->name);
return &ast_null_frame;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
@@ -4583,11 +4532,10 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
f = ast_dsp_process(p->owner, p->vad, f);
if (f && f->frametype == AST_FRAME_DTMF) {
if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+ ast_debug(1, "Fax CNG detected on %s\n", ast->name);
*faxdetect = 1;
- } else if (option_debug) {
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ } else {
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
}
}
}
@@ -4611,16 +4559,13 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
+ ast_debug(3, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
p->t38.state = T38_LOCAL_REINVITE;
transmit_reinvite_with_sdp(p, TRUE);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
}
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
+ ast_debug(3, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
@@ -4799,8 +4744,7 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
p->next = dialoglist;
dialoglist = p;
dialoglist_unlock();
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
+ ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
return p;
}
@@ -4836,19 +4780,16 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
- if (option_debug > 4 )
- ast_log(LOG_DEBUG, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
+ ast_debug(5, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
/* All messages must always have From: tag */
if (ast_strlen_zero(fromtag)) {
- if (option_debug > 4 )
- ast_log(LOG_DEBUG, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+ ast_debug(5, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
return NULL;
}
/* reject requests that must always have a To: tag */
if (ast_strlen_zero(totag) && (req->method == SIP_ACK || req->method == SIP_BYE || req->method == SIP_INFO )) {
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+ ast_debug(5, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
return NULL;
}
}
@@ -4865,8 +4806,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
found = (!strcmp(p->callid, callid) &&
(!pedanticsipchecking || !tag || ast_strlen_zero(p->theirtag) || !strcmp(p->theirtag, tag))) ;
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
+ ast_debug(5, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
/* If we get a new request within an existing to-tag - check the to tag as well */
if (pedanticsipchecking && found && req->method != SIP_RESPONSE) { /* SIP Request */
@@ -4878,8 +4818,8 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
found = FALSE; /* This is not our packet */
}
}
- if (!found && option_debug > 4)
- ast_log(LOG_DEBUG, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, totag, sip_methods[req->method].text);
+ if (!found)
+ ast_debug(5, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, totag, sip_methods[req->method].text);
}
@@ -4916,26 +4856,23 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
Sorry, we apologize for the inconvienience
*/
transmit_response_using_temp(callid, sin, 1, intended_method, req, "500 Server internal error");
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
+ ast_debug(4, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
}
}
return p;
} else if( sip_methods[intended_method].can_create == CAN_CREATE_DIALOG_UNSUPPORTED_METHOD) {
/* A method we do not support, let's take it on the volley */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "501 Method Not Implemented");
- if (option_debug > 1 )
- ast_log(LOG_DEBUG, "Got a request with unsupported SIP method.\n");
+ ast_debug(2, "Got a request with unsupported SIP method.\n");
} else if (intended_method != SIP_RESPONSE && intended_method != SIP_ACK) {
/* This is a request outside of a dialog that we don't know about */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "481 Call leg/transaction does not exist");
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
+ ast_debug(2, "That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
}
/* We do not respond to responses for dialogs that we don't know about, we just drop
the session quickly */
- if (option_debug > 1 && intended_method == SIP_RESPONSE)
- ast_log(LOG_DEBUG, "That's odd... Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
+ if (intended_method == SIP_RESPONSE)
+ ast_debug(2, "That's odd... Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
return p;
}
@@ -5079,8 +5016,8 @@ static void parse_request(struct sip_request *req)
*c = '\0';
else if (*c == '\n') { /* end of this line */
*c = '\0';
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+ if (sipdebug)
+ ast_debug(4, "%7s %2d [%3d]: %s\n",
req->headers < 0 ? "Header" : "Body",
i, (int)strlen(dst[i]), dst[i]);
if (ast_strlen_zero(dst[i]) && req->headers < 0) {
@@ -5099,8 +5036,8 @@ static void parse_request(struct sip_request *req)
but since some devices send without, we'll be generous in what we accept.
*/
if (!ast_strlen_zero(dst[i])) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+ if (sipdebug)
+ ast_debug(4, "%7s %2d [%3d]: %s\n",
req->headers < 0 ? "Header" : "Body",
i, (int)strlen(dst[i]), dst[i]);
i++;
@@ -5368,12 +5305,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
if (p->owner && p->lastinvite) {
p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
} else {
p->t38.state = T38_PEER_DIRECT; /* T38 Offered directly from peer in first invite */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else
ast_log(LOG_WARNING, "Unsupported SDP media type in offer: %s\n", m);
@@ -5433,11 +5368,11 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
sin.sin_port = htons(udptlportno);
ast_udptl_set_peer(p->udptl, &sin);
if (debug)
- ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ ast_debug(1,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
ast_udptl_stop(p->udptl);
if (debug)
- ast_log(LOG_DEBUG, "Peer doesn't provide T.38 UDPTL\n");
+ ast_debug(1, "Peer doesn't provide T.38 UDPTL\n");
}
}
@@ -5529,8 +5464,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
framing = strtol(tmp, NULL, 10);
if (framing == LONG_MIN || framing == LONG_MAX) {
framing = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
+ ast_debug(1, "Can't read framing from SDP: %s\n", a);
}
}
if (framing && last_rtpmap_codec) {
@@ -5542,8 +5476,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
format = ast_rtp_codec_getformat(found_rtpmap_codecs[codec_n]);
if (!format) /* non-codec or not found */
continue;
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format, framing);
+ ast_debug(1, "Setting framing for %d to %ld\n", format, framing);
ast_codec_pref_setsize(pref, format, framing);
}
ast_rtp_codec_setpref(p->rtp, pref);
@@ -5585,12 +5518,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "MaxBufferSize:%d\n",x);
+ ast_debug(3, "MaxBufferSize:%d\n",x);
} else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"T38MaxBitRate: %d\n",x);
+ ast_debug(3,"T38MaxBitRate: %d\n",x);
switch (x) {
case 14400:
peert38capability |= T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
@@ -5613,49 +5544,42 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
}
} else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FaxVersion: %d\n",x);
+ ast_debug(3, "FaxVersion: %d\n",x);
if (x == 0)
peert38capability |= T38FAX_VERSION_0;
else if (x == 1)
peert38capability |= T38FAX_VERSION_1;
} else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FaxMaxDatagram: %d\n",x);
+ ast_debug(3, "FaxMaxDatagram: %d\n",x);
ast_udptl_set_far_max_datagram(p->udptl, x);
ast_udptl_set_local_max_datagram(p->udptl, x);
} else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
+ ast_debug(3, "FillBitRemoval: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_FILL_BIT_REMOVAL;
} else if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
+ ast_debug(3, "Transcoding MMR: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_MMR;
}
if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
+ ast_debug(3, "Transcoding JBIG: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_JBIG;
} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "RateManagement: %s\n", s);
+ ast_debug(3, "RateManagement: %s\n", s);
if (!strcasecmp(s, "localTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
else if (!strcasecmp(s, "transferredTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
} else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "UDP EC: %s\n", s);
+ ast_debug(3, "UDP EC: %s\n", s);
if (!strcasecmp(s, "t38UDPRedundancy")) {
peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
@@ -5675,14 +5599,13 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
p->t38.jointcapability |= (peert38capability & p->t38.capability); /* Put the lower of our's and peer's speed */
}
if (debug)
- ast_log(LOG_DEBUG, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
+ ast_debug(1, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
} else {
p->t38.state = T38_DISABLED;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(3, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
/* Now gather all of the codecs that we are asked for: */
@@ -5718,8 +5641,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
/* Do NOT Change current setting */
return -1;
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Have T.38 but no audio codecs, accepting offer anyway\n");
+ ast_debug(3, "Have T.38 but no audio codecs, accepting offer anyway\n");
return 0;
}
}
@@ -5771,21 +5693,18 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
}
/* Ok, we're going with this offer */
- if (option_debug > 1) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "We're settling with these formats: %s\n", ast_getformatname_multiple(buf, BUFSIZ, p->jointcapability));
- }
+ char buf[BUFSIZ];
+ ast_debug(2, "We're settling with these formats: %s\n", ast_getformatname_multiple(buf, BUFSIZ, p->jointcapability));
if (!p->owner) /* There's no open channel owning us so we can return here. For a re-invite or so, we proceed */
return 0;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "We have an owner, now see if we need to change this call\n");
+ ast_debug(4, "We have an owner, now see if we need to change this call\n");
if (!(p->owner->nativeformats & p->jointcapability) && (p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
if (debug) {
char s1[BUFSIZ], s2[BUFSIZ];
- ast_log(LOG_DEBUG, "Oooh, we need to change our audio formats since our peer supports only %s and not %s\n",
+ ast_debug(1, "Oooh, we need to change our audio formats since our peer supports only %s and not %s\n",
ast_getformatname_multiple(s1, BUFSIZ, p->jointcapability),
ast_getformatname_multiple(s2, BUFSIZ, p->owner->nativeformats));
}
@@ -6212,7 +6131,7 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, in
if (p->route && !ast_strlen_zero(p->route->hop) && strstr(p->route->hop,";lr") == NULL) {
is_strict = TRUE;
if (sipdebug)
- ast_log(LOG_DEBUG, "Strict routing enforced for session %s\n", p->callid);
+ ast_debug(1, "Strict routing enforced for session %s\n", p->callid);
}
if (sipmethod == SIP_CANCEL)
@@ -6589,32 +6508,25 @@ static int t38_get_rate(int t38cap)
int maxrate = (t38cap & (T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400));
if (maxrate & T38FAX_RATE_14400) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 14400 found\n");
+ ast_debug(2, "T38MaxFaxRate 14400 found\n");
return 14400;
} else if (maxrate & T38FAX_RATE_12000) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 12000 found\n");
+ ast_debug(2, "T38MaxFaxRate 12000 found\n");
return 12000;
} else if (maxrate & T38FAX_RATE_9600) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 9600 found\n");
+ ast_debug(2, "T38MaxFaxRate 9600 found\n");
return 9600;
} else if (maxrate & T38FAX_RATE_7200) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 7200 found\n");
+ ast_debug(2, "T38MaxFaxRate 7200 found\n");
return 7200;
} else if (maxrate & T38FAX_RATE_4800) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 4800 found\n");
+ ast_debug(2, "T38MaxFaxRate 4800 found\n");
return 4800;
} else if (maxrate & T38FAX_RATE_2400) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 2400 found\n");
+ ast_debug(2, "T38MaxFaxRate 2400 found\n");
return 2400;
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
+ ast_debug(2, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
return 0;
}
}
@@ -6665,13 +6577,13 @@ static int add_t38_sdp(struct sip_request *resp, struct sip_pvt *p)
}
if (debug)
- ast_log(LOG_DEBUG, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
+ ast_debug(1, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
/* We break with the "recommendation" and send our IP, in order that our
peer doesn't have to ast_gethostbyname() us */
if (debug) {
- ast_log(LOG_DEBUG, "Our T38 capability (%d), peer T38 capability (%d), joint capability (%d)\n",
+ ast_debug(1, "Our T38 capability (%d), peer T38 capability (%d), joint capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
@@ -6841,12 +6753,10 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
capability = p->jointcapability;
- if (option_debug > 1) {
- char codecbuf[BUFSIZ];
- ast_log(LOG_DEBUG, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
- ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
- ast_log(LOG_DEBUG, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
- }
+ char codecbuf[BUFSIZ];
+ ast_debug(1, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
+ ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
+ ast_debug(1, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_RTP)) {
@@ -6859,10 +6769,9 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
if ((capability & AST_FORMAT_VIDEO_MASK) && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
if (p->vrtp) {
needvideo = TRUE;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs video offers!\n");
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs video offers, but there's no video support enabled!\n");
+ ast_debug(2, "This call needs video offers!\n");
+ } else
+ ast_debug(2, "This call needs video offers, but there's no video support enabled!\n");
}
/* Get our media addresses */
@@ -6889,10 +6798,9 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
if (p->trtp) {
if (sipdebug_text) ast_verbose("And we have a text rtp object\n");
needtext = TRUE;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs text offers! \n");
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs text offers, but there's no text support enabled ! \n");
+ ast_debug(2, "This call needs text offers! \n");
+ } else
+ ast_debug(2, "This call needs text offers, but there's no text support enabled ! \n");
}
/* Ok, we need text. Let's add what we need for text and set codecs.
@@ -7005,8 +6913,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
debug);
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-- Done with adding codecs to SDP\n");
+ ast_debug(3, "-- Done with adding codecs to SDP\n");
if (!p->owner || !ast_internal_timing_enabled(p->owner))
ast_build_string(&a_audio_next, &a_audio_left, "a=silenceSupp:off - - - -\r\n");
@@ -7064,10 +6971,8 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
/* Update lastrtprx when we send our SDP */
p->lastrtprx = p->lastrtptx = time(NULL); /* XXX why both ? */
- if (option_debug > 2) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, BUFSIZ, capability));
- }
+ char buf[BUFSIZ];
+ ast_debug(3, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, BUFSIZ, capability));
return AST_SUCCESS;
}
@@ -7124,8 +7029,7 @@ static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const
respprep(&resp, p, msg, req);
if (p->rtp) {
if (!p->autoframing && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing from config on incoming call\n");
+ ast_debug(1, "Setting framing from config on incoming call\n");
ast_rtp_codec_setpref(p->rtp, &p->prefs);
}
try_suggested_sip_codec(p);
@@ -7533,7 +7437,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
add_header(&req, headdup, content);
if (sipdebug)
- ast_log(LOG_DEBUG, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
+ ast_debug(1, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
}
}
}
@@ -7542,8 +7446,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
if (sdp) {
if (p->udptl && p->t38.state == T38_LOCAL_DIRECT) {
ast_udptl_offered_from_local(p->udptl, 1);
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
add_t38_sdp(&req, p);
} else if (p->rtp)
add_sdp(&req, p);
@@ -8010,8 +7913,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
ast_sched_del(sched, r->timeout);
}
r->timeout = ast_sched_add(sched, global_reg_timeout * 1000, sip_reg_timeout, r);
- if (option_debug)
- ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
+ ast_debug(1, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
}
if (strchr(r->username, '@')) {
@@ -8069,7 +7971,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
/* We have auth data to reuse, build a digest header! */
if (sipdebug)
- ast_log(LOG_DEBUG, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
+ ast_debug(1, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
ast_string_field_set(p, realm, r->realm);
ast_string_field_set(p, nonce, r->nonce);
ast_string_field_set(p, domain, r->domain);
@@ -8137,8 +8039,8 @@ static int transmit_refer(struct sip_pvt *p, const char *dest)
char *ttag, *ftag;
char *theirtag = ast_strdupa(p->theirtag);
- if (option_debug || sipdebug)
- ast_log(LOG_DEBUG, "SIP transfer of %s to %s\n", p->callid, dest);
+ if (sipdebug)
+ ast_debug(1, "SIP transfer of %s to %s\n", p->callid, dest);
/* Are we transfering an inbound or outbound call ? */
if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
@@ -8315,8 +8217,8 @@ static int expire_register(void *data)
/* Do we need to release this peer from memory?
Only for realtime peers and autocreated peers
*/
- if (option_debug > 2 && ast_test_flag(&peer->flags[0], SIP_REALTIME))
- ast_log(LOG_DEBUG,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
+ if (ast_test_flag(&peer->flags[0], SIP_REALTIME))
+ ast_debug(3,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT) ||
ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
@@ -8376,9 +8278,8 @@ static void reg_source_db(struct sip_peer *peer)
if (contact)
ast_copy_string(peer->fullcontact, contact, sizeof(peer->fullcontact));
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
- peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
+ ast_debug(2, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
+ peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
memset(&peer->addr, 0, sizeof(peer->addr));
peer->addr.sin_family = AF_INET;
@@ -8626,8 +8527,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
/* Once a persistant route is set, don't fool with it */
if (p->route && p->route_persistant) {
- if (option_debug)
- ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
+ ast_debug(1, "build_route: Retaining previous route: <%s>\n", p->route->hop);
return;
}
@@ -8658,8 +8558,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
if ((thishop = ast_malloc(sizeof(*thishop) + len))) {
/* ast_calloc is not needed because all fields are initialized in this block */
ast_copy_string(thishop->hop, rr, len);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "build_route: Record-Route hop: <%s>\n", thishop->hop);
+ ast_debug(2, "build_route: Record-Route hop: <%s>\n", thishop->hop);
/* Link in */
if (backwards) {
/* Link in at head so they end up in reverse order */
@@ -8687,8 +8586,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
/* Can be multiple Contact headers, comma separated values - we just take the first */
contact = get_header(req, "Contact");
if (!ast_strlen_zero(contact)) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact);
+ ast_debug(2, "build_route: Contact hop: %s\n", contact);
/* Look for <: delimited address */
c = strchr(contact, '<');
if (c) {
@@ -9308,8 +9206,7 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
domain_context[0] = '\0';
if (!check_sip_domain(p->domain, domain_context, sizeof(domain_context))) {
if (!allow_external_domains && (req->method == SIP_INVITE || req->method == SIP_REFER)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
+ ast_debug(1, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
return -2;
}
}
@@ -9351,8 +9248,8 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
struct sip_pvt *sip_pvt_ptr;
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
+ if (totag)
+ ast_debug(4, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
/* Search dialogs and find the match */
dialoglist_lock();
@@ -9376,8 +9273,8 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
continue;
}
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n",
+ if (totag)
+ ast_debug(4, "Matched %s call - their tag is %s Our tag is %s\n",
ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
@@ -9391,8 +9288,8 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
}
}
dialoglist_unlock();
- if (option_debug > 3 && !sip_pvt_ptr)
- ast_log(LOG_DEBUG, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
+ if (!sip_pvt_ptr)
+ ast_debug(4, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
return sip_pvt_ptr;
}
@@ -9497,12 +9394,10 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
ast_copy_string(referdata->replaces_callid_fromtag, ptr, sizeof(referdata->replaces_callid_fromtag));
}
- if (option_debug > 1) {
- if (!pedanticsipchecking)
- ast_log(LOG_DEBUG,"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", referdata->replaces_callid );
- else
- ast_log(LOG_DEBUG,"Attended transfer: Will use Replace-Call-ID : %s F-tag: %s T-tag: %s\n", referdata->replaces_callid, referdata->replaces_callid_fromtag ? referdata->replaces_callid_fromtag : "<none>", referdata->replaces_callid_totag ? referdata->replaces_callid_totag : "<none>" );
- }
+ if (!pedanticsipchecking)
+ ast_debug(2,"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", referdata->replaces_callid );
+ else
+ ast_debug(2,"Attended transfer: Will use Replace-Call-ID : %s F-tag: %s T-tag: %s\n", referdata->replaces_callid, referdata->replaces_callid_fromtag ? referdata->replaces_callid_fromtag : "<none>", referdata->replaces_callid_totag ? referdata->replaces_callid_totag : "<none>" );
}
}
@@ -9598,8 +9493,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
}
if (ast_exists_extension(NULL, transfer_context, c, 1, NULL)) {
/* This is a blind transfer */
- if (option_debug)
- ast_log(LOG_DEBUG,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
+ ast_debug(1,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
ast_copy_string(referdata->refer_to, c, sizeof(referdata->refer_to));
ast_copy_string(referdata->referred_by, "", sizeof(referdata->referred_by));
ast_copy_string(referdata->refer_contact, "", sizeof(referdata->refer_contact));
@@ -11669,17 +11563,17 @@ static void sip_dump_history(struct sip_pvt *dialog)
return;
}
- ast_log(LOG_DEBUG, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
+ ast_debug(1, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
if (dialog->subscribed)
- ast_log(LOG_DEBUG, " * Subscription\n");
+ ast_debug(1, " * Subscription\n");
else
- ast_log(LOG_DEBUG, " * SIP Call\n");
+ ast_debug(1, " * SIP Call\n");
if (dialog->history)
AST_LIST_TRAVERSE(dialog->history, hist, list)
- ast_log(LOG_DEBUG, " %-3.3d. %s\n", ++x, hist->event);
+ ast_debug(1, " %-3.3d. %s\n", ++x, hist->event);
if (!x)
- ast_log(LOG_DEBUG, "Call '%s' has no history\n", dialog->callid);
- ast_log(LOG_DEBUG, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
+ ast_debug(1, "Call '%s' has no history\n", dialog->callid);
+ ast_debug(1, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
}
@@ -11803,8 +11697,7 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
}
ast_unlock_call_features();
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a Request to Record the channel, state %s\n", c);
+ ast_debug(1, "Got a Request to Record the channel, state %s\n", c);
transmit_response(p, "200 OK", req);
return;
}
@@ -12015,8 +11908,7 @@ static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, enum sip_au
p->authtries++;
auth_headers(code, &header, &respheader);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Auth attempt %d on %s\n", p->authtries, sip_methods[sipmethod].text);
+ ast_debug(2, "Auth attempt %d on %s\n", p->authtries, sip_methods[sipmethod].text);
memset(digest, 0, sizeof(digest));
if (reply_digest(p, req, header, sipmethod, digest, sizeof(digest) )) {
/* No way to authenticate */
@@ -12138,7 +12030,7 @@ static int build_reply_digest(struct sip_pvt *p, int method, char* digest, int d
secret = auth->secret;
md5secret = auth->md5secret;
if (sipdebug)
- ast_log(LOG_DEBUG,"Using realm %s authentication for call %s\n", p->realm, p->callid);
+ ast_debug(1,"Using realm %s authentication for call %s\n", p->realm, p->callid);
} else {
/* No authentication, use peer or register= config */
username = p->authname;
@@ -12545,8 +12437,7 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
e = strchr(s, '/');
if (e)
*e = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
+ ast_debug(2, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
@@ -12567,8 +12458,7 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
e = strchr(s, ';'); /* And username ; parameters? */
if (e)
*e = '\0';
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain);
+ ast_debug(2, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain);
if (p->owner) {
pbx_builtin_setvar_helper(p->owner, "SIPDOMAIN", domain);
ast_string_field_set(p->owner, call_forward, s);
@@ -12590,8 +12480,7 @@ static void check_pendings(struct sip_pvt *p)
ast_clear_flag(&p->flags[0], SIP_PENDINGBYE);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else if (ast_test_flag(&p->flags[0], SIP_NEEDREINVITE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending pending reinvite on '%s'\n", p->callid);
+ ast_debug(2, "Sending pending reinvite on '%s'\n", p->callid);
/* Didn't get to reinvite yet, so do it now */
transmit_reinvite_with_sdp(p, FALSE);
ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);
@@ -12607,16 +12496,13 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
int reinvite = (p->owner && p->owner->_state == AST_STATE_UP);
struct ast_channel *bridgepeer = NULL;
- if (option_debug > 3) {
- if (reinvite)
- ast_log(LOG_DEBUG, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
- else
- ast_log(LOG_DEBUG, "SIP response %d to standard invite\n", resp);
- }
+ if (reinvite)
+ ast_debug(4, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
+ else
+ ast_debug(4, "SIP response %d to standard invite\n", resp);
if (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
+ ast_debug(1, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
return;
}
@@ -12741,31 +12627,25 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange... The other side of the bridge does not have a udptl struct\n");
+ ast_debug(2, "Strange... The other side of the bridge does not have a udptl struct\n");
sip_pvt_lock(bridgepvt);
bridgepvt->t38.state = T38_DISABLED;
sip_pvt_unlock(bridgepvt);
- if (option_debug)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->tech->type);
+ ast_debug(1,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->tech->type);
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else {
/* Other side is not a SIP channel */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange... The other side of the bridge is not a SIP channel\n");
+ ast_debug(2, "Strange... The other side of the bridge is not a SIP channel\n");
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
}
if ((p->t38.state == T38_LOCAL_REINVITE) || (p->t38.state == T38_LOCAL_DIRECT)) {
/* If there was T38 reinvite and we are supposed to answer with 200 OK than this should set us to T38 negotiated mode */
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
@@ -12916,8 +12796,7 @@ static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struc
/* The transferee is now sending INVITE to target */
p->refer->status = REFER_ACCEPTED;
/* Now wait for next message */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Got 202 accepted on transfer\n");
+ ast_debug(3, "Got 202 accepted on transfer\n");
/* We should hang along, waiting for NOTIFY's here */
break;
@@ -13042,11 +12921,9 @@ static int handle_response_register(struct sip_pvt *p, int resp, char *rest, str
r->regtime = time(NULL); /* Reset time of last succesful registration */
manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
r->regattempts = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Registration successful\n");
+ ast_debug(1, "Registration successful\n");
if (r->timeout > -1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
+ ast_debug(1, "Cancelling timeout %d\n", r->timeout);
ast_sched_del(sched, r->timeout);
}
r->timeout=-1;
@@ -13240,8 +13117,8 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if (!p->refer) {
ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name);
ast_queue_hangup(p->owner);
- } else if (option_debug > 3)
- ast_log(LOG_DEBUG, "Got OK on REFER Notify message\n");
+ } else
+ ast_debug(4, "Got OK on REFER Notify message\n");
} else {
if (p->subscribed == NONE)
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
@@ -13308,8 +13185,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
res = handle_response_register(p, resp, rest, req, seqno);
else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got timeout on bye. Thanks for the answer. Now, kill this call\n");
+ ast_debug(4, "Got timeout on bye. Thanks for the answer. Now, kill this call\n");
} else {
if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
@@ -13346,8 +13222,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if (sipmethod == SIP_INVITE)
handle_response_invite(p, resp, rest, req, seqno);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
+ ast_debug(1, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
}
break;
@@ -13393,8 +13268,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
is yet another failure of not having a layer 2 (again, YAY
IETF for thinking ahead). So we treat this as a call
forward and hope we end up at the right place... */
- if (option_debug)
- ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
+ ast_debug(1, "Hairpin detected, setting up call forward for what it's worth\n");
if (p->owner)
ast_string_field_build(p->owner, call_forward,
"Local/%s@%s", p->username, p->context);
@@ -13461,16 +13335,14 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if (sipmethod == SIP_INVITE) {
handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_CANCEL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
+ ast_debug(1, "Got 200 OK on CANCEL\n");
/* Wait for 487, then destroy */
} else if (sipmethod == SIP_NOTIFY) {
/* They got the notify, this is the end */
if (p->owner) {
if (p->refer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 200 OK on NOTIFY for transfer\n");
+ ast_debug(1, "Got 200 OK on NOTIFY for transfer\n");
} else
ast_log(LOG_WARNING, "Notify answer on an owned channel?\n");
/* ast_queue_hangup(p->owner); Disabled */
@@ -13512,7 +13384,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
} else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
} else if (sipdebug) {
- ast_log (LOG_DEBUG, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
+ ast_debug(1, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
}
break;
case 501: /* Not Implemented */
@@ -13579,8 +13451,7 @@ static void *sip_park_thread(void *stuff)
ast_log(LOG_ERROR, "Missing channels for parking! Transferer %s Transferee %s\n", transferer ? "<available>" : "<missing>", transferee ? "<available>" : "<missing>" );
return NULL;
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name);
+ ast_debug(4, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name);
ast_channel_lock(transferee);
if (ast_do_masquerade(transferee)) {
@@ -13613,13 +13484,11 @@ static void *sip_park_thread(void *stuff)
transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "200 OK", TRUE);
transferer->hangupcause = AST_CAUSE_NORMAL_CLEARING;
ast_hangup(transferer); /* This will cause a BYE */
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP Call parked on extension '%d'\n", ext);
+ ast_debug(1, "SIP Call parked on extension '%d'\n", ext);
} else {
transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "503 Service Unavailable", TRUE);
append_history(transferer->tech_pvt, "SIPpark","Parking failed\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP Call parked failed \n");
+ ast_debug(1, "SIP Call parked failed \n");
/* Do not hangup call */
}
return NULL;
@@ -13687,12 +13556,10 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
ast_channel_unlock(transferer);
if (!transferer || !transferee) {
if (!transferer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
+ ast_debug(1, "No transferer channel, giving up parking\n");
}
if (!transferee) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ ast_debug(1, "No transferee channel, giving up parking\n");
}
return -1;
}
@@ -13737,40 +13604,36 @@ static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target
/* We will try to connect the transferee with the target and hangup
all channels to the transferer */
- if (option_debug > 3) {
- ast_log(LOG_DEBUG, "Sip transfer:--------------------\n");
- if (transferer->chan1)
- ast_log(LOG_DEBUG, "-- Transferer to PBX channel: %s State %s\n", transferer->chan1->name, ast_state2str(transferer->chan1->_state));
- else
- ast_log(LOG_DEBUG, "-- No transferer first channel - odd??? \n");
- if (target->chan1)
- ast_log(LOG_DEBUG, "-- Transferer to PBX second channel (target): %s State %s\n", target->chan1->name, ast_state2str(target->chan1->_state));
- else
- ast_log(LOG_DEBUG, "-- No target first channel ---\n");
- if (transferer->chan2)
- ast_log(LOG_DEBUG, "-- Bridged call to transferee: %s State %s\n", transferer->chan2->name, ast_state2str(transferer->chan2->_state));
- else
- ast_log(LOG_DEBUG, "-- No bridged call to transferee\n");
- if (target->chan2)
- ast_log(LOG_DEBUG, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? target->chan2->name : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
- else
- ast_log(LOG_DEBUG, "-- No target second channel ---\n");
- ast_log(LOG_DEBUG, "-- END Sip transfer:--------------------\n");
- }
+ ast_debug(4, "Sip transfer:--------------------\n");
+ if (transferer->chan1)
+ ast_debug(4, "-- Transferer to PBX channel: %s State %s\n", transferer->chan1->name, ast_state2str(transferer->chan1->_state));
+ else
+ ast_debug(4, "-- No transferer first channel - odd??? \n");
+ if (target->chan1)
+ ast_debug(4, "-- Transferer to PBX second channel (target): %s State %s\n", target->chan1->name, ast_state2str(target->chan1->_state));
+ else
+ ast_debug(4, "-- No target first channel ---\n");
+ if (transferer->chan2)
+ ast_debug(4, "-- Bridged call to transferee: %s State %s\n", transferer->chan2->name, ast_state2str(transferer->chan2->_state));
+ else
+ ast_debug(4, "-- No bridged call to transferee\n");
+ if (target->chan2)
+ ast_debug(4, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? target->chan2->name : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
+ else
+ ast_debug(4, "-- No target second channel ---\n");
+ ast_debug(4, "-- END Sip transfer:--------------------\n");
if (transferer->chan2) { /* We have a bridge on the transferer's channel */
peera = transferer->chan1; /* Transferer - PBX -> transferee channel * the one we hangup */
peerb = target->chan1; /* Transferer - PBX -> target channel - This will get lost in masq */
peerc = transferer->chan2; /* Asterisk to Transferee */
peerd = target->chan2; /* Asterisk to Target */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP transfer: Four channels to handle\n");
+ ast_debug(3, "SIP transfer: Four channels to handle\n");
} else if (target->chan2) { /* Transferer has no bridge (IVR), but transferee */
peera = target->chan1; /* Transferer to PBX -> target channel */
peerb = transferer->chan1; /* Transferer to IVR*/
peerc = target->chan2; /* Asterisk to Target */
peerd = transferer->chan2; /* Nothing */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP transfer: Three channels to handle\n");
+ ast_debug(3, "SIP transfer: Three channels to handle\n");
}
if (peera && peerb && peerc && (peerb != peerc)) {
@@ -13793,13 +13656,12 @@ static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target
peerb->cdr = peerc->cdr;
peerc->cdr = NULL;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
+ ast_debug(4, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
if (ast_channel_masquerade(peerb, peerc)) {
ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name, peerc->name);
res = -1;
} else
- ast_log(LOG_DEBUG, "SIP transfer: Succeeded to masquerade channels.\n");
+ ast_debug(4, "SIP transfer: Succeeded to masquerade channels.\n");
return res;
} else {
ast_log(LOG_NOTICE, "SIP Transfer attempted with no appropriate bridged calls to transfer\n");
@@ -13849,8 +13711,8 @@ static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, str
eventid = sep;
}
- if (option_debug > 1 && sipdebug)
- ast_log(LOG_DEBUG, "Got NOTIFY Event: %s\n", event);
+ if (sipdebug)
+ ast_debug(2, "Got NOTIFY Event: %s\n", event);
if (strcmp(event, "refer")) {
/* We don't understand this event. */
@@ -13910,8 +13772,7 @@ static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, str
If there are several REFERs in the same dialog, we need to
match the ID of the event header...
*/
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
+ ast_debug(3, "* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
cmd = ast_skip_blanks(buf);
code = cmd;
/* We are at SIP/2.0 */
@@ -14007,20 +13868,17 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
if (!(targetcall = ast_bridged_channel(replacecall))) {
/* We have no bridge */
if (!earlyreplace) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, " Attended transfer attempted to replace call with no bridge (maybe ringing). Channel %s!\n", replacecall->name);
+ ast_debug(2, " Attended transfer attempted to replace call with no bridge (maybe ringing). Channel %s!\n", replacecall->name);
oneleggedreplace = 1;
}
}
- if (option_debug > 3 && targetcall && targetcall->_state == AST_STATE_RINGING)
- ast_log(LOG_DEBUG, "SIP transfer: Target channel is in ringing state\n");
+ if (targetcall && targetcall->_state == AST_STATE_RINGING)
+ ast_debug(4, "SIP transfer: Target channel is in ringing state\n");
- if (option_debug > 3) {
- if (targetcall)
- ast_log(LOG_DEBUG, "SIP transfer: Invite Replace incoming channel should bridge to channel %s while hanging up channel %s\n", targetcall->name, replacecall->name);
- else
- ast_log(LOG_DEBUG, "SIP transfer: Invite Replace incoming channel should replace and hang up channel %s (one call leg)\n", replacecall->name);
- }
+ if (targetcall)
+ ast_debug(4, "SIP transfer: Invite Replace incoming channel should bridge to channel %s while hanging up channel %s\n", targetcall->name, replacecall->name);
+ else
+ ast_debug(4, "SIP transfer: Invite Replace incoming channel should replace and hang up channel %s (one call leg)\n", replacecall->name);
if (ast_test_flag(req, SIP_PKT_IGNORE)) {
ast_log(LOG_NOTICE, "Ignoring this INVITE with replaces in a stupid way.\n");
@@ -14068,8 +13926,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
/* Stop music on hold and other generators */
ast_quiet_chan(replacecall);
ast_quiet_chan(targetcall);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replaces: preparing to masquerade %s into %s\n", c->name, replacecall->name);
+ ast_debug(4, "Invite/Replaces: preparing to masquerade %s into %s\n", c->name, replacecall->name);
/* Unlock clone, but not original (replacecall) */
ast_channel_unlock(c);
@@ -14082,8 +13939,8 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
/* Prepare the masquerade - if this does not happen, we will be gone */
if(ast_channel_masquerade(replacecall, c))
ast_log(LOG_ERROR, "Failed to masquerade C into Replacecall\n");
- else if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replaces: Going to masquerade %s into %s\n", c->name, replacecall->name);
+ else
+ ast_debug(4, "Invite/Replaces: Going to masquerade %s into %s\n", c->name, replacecall->name);
/* The masquerade will happen as soon as someone reads a frame from the channel */
@@ -14096,8 +13953,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
if ((f = ast_read(replacecall))) { /* Force the masq to happen */
ast_frfree(f);
f = NULL;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replace: Could successfully read frame from RING channel!\n");
+ ast_debug(4, "Invite/Replace: Could successfully read frame from RING channel!\n");
} else {
ast_log(LOG_WARNING, "Invite/Replace: Could not read frame from RING channel \n");
}
@@ -14108,8 +13964,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
/* Masq ok */
ast_frfree(f);
f = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Invite/Replace: Could successfully read frame from channel! Masq done.\n");
+ ast_debug(3, "Invite/Replace: Could successfully read frame from channel! Masq done.\n");
} else {
ast_log(LOG_WARNING, "Invite/Replace: Could not read frame from channel. Transfer failed\n");
}
@@ -14118,23 +13973,21 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
sip_pvt_unlock(p->refer->refer_call);
ast_setstate(c, AST_STATE_DOWN);
- if (option_debug > 3) {
- struct ast_channel *test;
- ast_log(LOG_DEBUG, "After transfer:----------------------------\n");
- ast_log(LOG_DEBUG, " -- C: %s State %s\n", c->name, ast_state2str(c->_state));
- if (replacecall)
- ast_log(LOG_DEBUG, " -- replacecall: %s State %s\n", replacecall->name, ast_state2str(replacecall->_state));
- if (p->owner) {
- ast_log(LOG_DEBUG, " -- P->owner: %s State %s\n", p->owner->name, ast_state2str(p->owner->_state));
- test = ast_bridged_channel(p->owner);
- if (test)
- ast_log(LOG_DEBUG, " -- Call bridged to P->owner: %s State %s\n", test->name, ast_state2str(test->_state));
- else
- ast_log(LOG_DEBUG, " -- No call bridged to C->owner \n");
- } else
- ast_log(LOG_DEBUG, " -- No channel yet \n");
- ast_log(LOG_DEBUG, "End After transfer:----------------------------\n");
- }
+ struct ast_channel *test;
+ ast_debug(4, "After transfer:----------------------------\n");
+ ast_debug(4, " -- C: %s State %s\n", c->name, ast_state2str(c->_state));
+ if (replacecall)
+ ast_debug(4, " -- replacecall: %s State %s\n", replacecall->name, ast_state2str(replacecall->_state));
+ if (p->owner) {
+ ast_debug(4, " -- P->owner: %s State %s\n", p->owner->name, ast_state2str(p->owner->_state));
+ test = ast_bridged_channel(p->owner);
+ if (test)
+ ast_debug(4, " -- Call bridged to P->owner: %s State %s\n", test->name, ast_state2str(test->_state));
+ else
+ ast_debug(4, " -- No call bridged to C->owner \n");
+ } else
+ ast_debug(4, " -- No channel yet \n");
+ ast_debug(4, "End After transfer:----------------------------\n");
ast_channel_unlock(p->owner); /* Unlock new owner */
sip_pvt_unlock(p); /* Unlock SIP structure */
@@ -14201,8 +14054,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->pendinginvite) {
/* We already have a pending invite. Sorry. You are on hold. */
transmit_response(p, "491 Request Pending", req);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
+ ast_debug(1, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
/* Don't destroy dialog here */
return 0;
}
@@ -14217,15 +14069,14 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
int error = 0;
if (p->owner) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
+ ast_debug(3, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
transmit_response(p, "400 Bad request", req); /* The best way to not not accept the transfer */
/* Do not destroy existing call */
return -1;
}
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "INVITE part of call transfer. Replaces [%s]\n", p_replaces);
+ if (sipdebug)
+ ast_debug(3, "INVITE part of call transfer. Replaces [%s]\n", p_replaces);
/* Create a buffer we can manipulate */
replace_id = ast_strdupa(p_replaces);
ast_uri_decode(replace_id);
@@ -14260,8 +14111,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
}
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG,"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
+ if (sipdebug)
+ ast_debug(4,"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
/* Try to find call that we are replacing
@@ -14326,8 +14177,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
check_via(p, req);
copy_request(&p->initreq, req); /* Save this INVITE as the transaction basis */
- if (sipdebug && option_debug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
if (!p->owner) { /* Not a re-invite */
if (debug)
ast_verbose("Using INVITE request as basis request - %s\n", p->callid);
@@ -14346,8 +14197,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
} else {
p->jointcapability = p->capability;
- if (option_debug)
- ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
+ ast_debug(1, "Hm.... No sdp for the moment\n");
}
if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY)) /* This is a response, note what it was for */
append_history(p, "ReInv", "Re-invite received");
@@ -14385,14 +14235,12 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
transmit_response_reliable(p, "488 Not acceptable here", req);
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- if (option_debug)
- ast_log(LOG_DEBUG, "No compatible codecs for this SIP call.\n");
+ ast_debug(1, "No compatible codecs for this SIP call.\n");
return -1;
}
} else { /* No SDP in invite, call control session */
p->jointcapability = p->capability;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "No SDP in Invite, third party call control\n");
+ ast_debug(2, "No SDP in Invite, third party call control\n");
}
/* Queue NULL frame to prod ast_rtp_bridge if appropriate */
@@ -14407,8 +14255,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* Check number of concurrent calls -vs- incoming limit HERE */
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking SIP call limits for device %s\n", p->username);
+ ast_debug(1, "Checking SIP call limits for device %s\n", p->username);
if ((res = update_call_counter(p, INC_CALL_LIMIT))) {
if (res < 0) {
ast_log(LOG_NOTICE, "Failed to place call for user %s, too many calls\n", p->username);
@@ -14458,11 +14305,11 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
}
} else {
- if (option_debug > 1 && sipdebug) {
+ if (sipdebug) {
if (!ast_test_flag(req, SIP_PKT_IGNORE))
- ast_log(LOG_DEBUG, "Got a SIP re-invite for call %s\n", p->callid);
+ ast_debug(2, "Got a SIP re-invite for call %s\n", p->callid);
else
- ast_log(LOG_DEBUG, "Got a SIP re-transmit of INVITE for call %s\n", p->callid);
+ ast_debug(2, "Got a SIP re-transmit of INVITE for call %s\n", p->callid);
}
reinvite = 1;
c = p->owner;
@@ -14473,8 +14320,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (replace_id) { /* Attended transfer or call pickup - we're the target */
/* Go and take over the target call */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Sending this call to the invite/replcaes handler %s\n", p->callid);
+ if (sipdebug)
+ ast_debug(4, "Sending this call to the invite/replcaes handler %s\n", p->callid);
return handle_invite_replaces(p, req, debug, ast_test_flag(req, SIP_PKT_IGNORE), seqno, sin);
}
@@ -14482,8 +14329,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (c) { /* We have a call -either a new call or an old one (RE-INVITE) */
switch(c->_state) {
case AST_STATE_DOWN:
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s: New call is still down.... Trying... \n", c->name);
+ ast_debug(2, "%s: New call is still down.... Trying... \n", c->name);
transmit_response(p, "100 Trying", req);
p->invitestate = INV_PROCEEDING;
ast_setstate(c, AST_STATE_RING);
@@ -14556,8 +14402,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_PROCEEDING;
break;
case AST_STATE_UP:
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s: This call is UP.... \n", c->name);
+ ast_debug(2, "%s: This call is UP.... \n", c->name);
if (p->t38.state == T38_PEER_REINVITE) {
struct ast_channel *bridgepeer = NULL;
@@ -14577,8 +14422,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
sip_pvt_lock(bridgepvt);
bridgepvt->t38.state = T38_DISABLED;
sip_pvt_unlock(bridgepvt);
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
+ ast_debug(2,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
if (ast_test_flag(req, SIP_PKT_IGNORE))
transmit_response(p, "488 Not acceptable here", req);
else
@@ -14589,8 +14433,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* The other side is already setup for T.38 most likely so we need to acknowledge this too */
transmit_response_with_t38_sdp(p, "200 OK", req, XMIT_CRITICAL);
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else {
/* Other side is not a SIP channel */
@@ -14599,8 +14442,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
else
transmit_response_reliable(p, "488 Not acceptable here", req);
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
if (!p->lastinvite) /* Only destroy if this is *not* a re-invite */
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -14609,8 +14451,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* we are not bridged in a call */
transmit_response_with_t38_sdp(p, "200 OK", req, XMIT_CRITICAL);
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else if (p->t38.state == T38_DISABLED) { /* Channel doesn't have T38 offered or enabled */
int sendok = TRUE;
@@ -14692,8 +14533,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
return -1;
}
/* Fall through for remote transfers that we did not find locally */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP attended transfer: Not our call - generating INVITE with replaces\n");
+ ast_debug(3, "SIP attended transfer: Not our call - generating INVITE with replaces\n");
return 0;
}
@@ -14701,8 +14541,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
transmit_response(transferer, "202 Accepted", req);
append_history(transferer, "Xfer", "Refer accepted");
if (!targetcall_pvt->owner) { /* No active channel */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: No owner of target call\n");
+ ast_debug(4, "SIP attended transfer: Error: No owner of target call\n");
/* Cancel transfer */
transmit_notify_with_sipfrag(transferer, seqno, "503 Service Unavailable", TRUE);
append_history(transferer, "Xfer", "Refer failed");
@@ -14719,22 +14558,20 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
/* Wrong state of new channel */
- if (option_debug > 3) {
- if (target.chan2)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
- else if (target.chan1->_state != AST_STATE_RING)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: No target channel\n");
- else
- ast_log(LOG_DEBUG, "SIP attended transfer: Attempting transfer in ringing state\n");
- }
+ if (target.chan2)
+ ast_debug(4, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
+ else if (target.chan1->_state != AST_STATE_RING)
+ ast_debug(4, "SIP attended transfer: Error: No target channel\n");
+ else
+ ast_debug(4, "SIP attended transfer: Attempting transfer in ringing state\n");
}
/* Transfer */
- if (option_debug > 3 && sipdebug) {
+ if (sipdebug) {
if (current->chan2) /* We have two bridges */
- ast_log(LOG_DEBUG, "SIP attended transfer: trying to bridge %s and %s\n", target.chan1->name, current->chan2->name);
+ ast_debug(4, "SIP attended transfer: trying to bridge %s and %s\n", target.chan1->name, current->chan2->name);
else /* One bridge, propably transfer of IVR/voicemail etc */
- ast_log(LOG_DEBUG, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
+ ast_debug(4, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
}
ast_set_flag(&transferer->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Delay hangup */
@@ -14759,8 +14596,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
append_history(transferer, "Xfer", "Refer succeeded");
transferer->refer->status = REFER_200OK;
if (targetcall_pvt->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
+ ast_debug(1, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
ast_channel_unlock(targetcall_pvt->owner);
}
}
@@ -14844,8 +14680,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
if (!p->owner) {
/* This is a REFER outside of an existing SIP dialog */
/* We can't handle that, so decline it */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Call %s: Declined REFER, outside of dialog...\n", p->callid);
+ ast_debug(3, "Call %s: Declined REFER, outside of dialog...\n", p->callid);
transmit_response(p, "603 Declined (No dialog)", req);
if (!ast_test_flag(req, SIP_PKT_IGNORE)) {
append_history(p, "Xfer", "Refer failed. Outside of dialog.");
@@ -14888,14 +14723,14 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
case -2: /* Syntax error */
transmit_response(p, "400 Bad Request (Refer-to missing)", req);
append_history(p, "Xfer", "Refer failed. Refer-to missing.");
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to black hole can't be handled (no refer-to: )\n");
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to black hole can't be handled (no refer-to: )\n");
break;
case -3:
transmit_response(p, "603 Declined (Non sip: uri)", req);
append_history(p, "Xfer", "Refer failed. Non SIP uri");
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to non-SIP uri denied\n");
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to non-SIP uri denied\n");
break;
default:
/* Refer-to extension not found, fake a failed transfer */
@@ -14903,8 +14738,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
append_history(p, "Xfer", "Refer failed. Bad extension.");
transmit_notify_with_sipfrag(p, seqno, "404 Not found", TRUE);
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to bad extension: %s\n", p->refer->refer_to);
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to bad extension: %s\n", p->refer->refer_to);
break;
}
return 0;
@@ -14915,14 +14750,14 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
/* If we do not support SIP domains, all transfers are local */
if (allow_external_domains && check_sip_domain(p->refer->refer_to_domain, NULL, 0)) {
p->refer->localtransfer = 1;
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "This SIP transfer is local : %s\n", p->refer->refer_to_domain);
+ if (sipdebug)
+ ast_debug(3, "This SIP transfer is local : %s\n", p->refer->refer_to_domain);
} else if (AST_LIST_EMPTY(&domain_list)) {
/* This PBX don't bother with SIP domains, so all transfers are local */
p->refer->localtransfer = 1;
} else
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "This SIP transfer is to a remote SIP extension (remote domain %s)\n", p->refer->refer_to_domain);
+ if (sipdebug)
+ ast_debug(3, "This SIP transfer is to a remote SIP extension (remote domain %s)\n", p->refer->refer_to_domain);
/* Is this a repeat of a current request? Ignore it */
/* Don't know what else to do right now. */
@@ -14960,15 +14795,15 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
/* Find the other part of the bridge (2) - transferee */
current.chan2 = ast_bridged_channel(current.chan1);
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "SIP %s transfer: Transferer channel %s, transferee channel %s\n", p->refer->attendedtransfer ? "attended" : "blind", current.chan1->name, current.chan2 ? current.chan2->name : "<none>");
+ if (sipdebug)
+ ast_debug(3, "SIP %s transfer: Transferer channel %s, transferee channel %s\n", p->refer->attendedtransfer ? "attended" : "blind", current.chan1->name, current.chan2 ? current.chan2->name : "<none>");
if (!current.chan2 && !p->refer->attendedtransfer) {
/* No bridged channel, propably IVR or echo or similar... */
/* Guess we should masquerade or something here */
/* Until we figure it out, refuse transfer of such calls */
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG,"Refused SIP transfer on non-bridged channel.\n");
+ if (sipdebug)
+ ast_debug(3,"Refused SIP transfer on non-bridged channel.\n");
p->refer->status = REFER_FAILED;
append_history(p, "Xfer", "Refer failed. Non-bridged channel.");
transmit_response(p, "603 Declined", req);
@@ -14976,8 +14811,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
}
if (current.chan2) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Got SIP transfer, applying to bridged peer '%s'\n", current.chan2->name);
+ if (sipdebug)
+ ast_debug(4, "Got SIP transfer, applying to bridged peer '%s'\n", current.chan2->name);
ast_queue_control(current.chan1, AST_CONTROL_UNHOLD);
}
@@ -14989,8 +14824,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
if ((res = local_attended_transfer(p, &current, req, seqno)))
return res; /* We're done with the transfer */
/* Fall through for remote transfers that we did not find locally */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP attended transfer: Still not our call - generating INVITE with replaces\n");
+ if (sipdebug)
+ ast_debug(4, "SIP attended transfer: Still not our call - generating INVITE with replaces\n");
/* Fallthrough if we can't find the call leg internally */
}
@@ -15004,8 +14839,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
p->refer->status = REFER_200OK;
append_history(p, "Xfer", "REFER to call parking.");
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name);
+ if (sipdebug)
+ ast_debug(4, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name);
sip_park(current.chan2, current.chan1, req, seqno);
return res;
}
@@ -15014,8 +14849,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
transmit_response(p, "202 Accepted", req);
if (current.chan1 && current.chan2) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "chan1->name: %s\n", current.chan1->name);
+ ast_debug(3, "chan1->name: %s\n", current.chan1->name);
pbx_builtin_setvar_helper(current.chan1, "BLINDTRANSFER", current.chan2->name);
}
if (current.chan2) {
@@ -15077,8 +14911,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
if (!res) {
/* Success - we have a new channel */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_debug(3, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
transmit_notify_with_sipfrag(p, seqno, "200 Ok", TRUE);
if (p->refer->localtransfer)
p->refer->status = REFER_200OK;
@@ -15091,8 +14924,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
res = 0;
} else {
ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Don't delay hangup */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_debug(3, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
append_history(p, "Xfer", "Refer failed.");
/* Failure of some kind */
p->refer->status = REFER_FAILED;
@@ -15114,8 +14946,7 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req)
if (p->owner && p->owner->_state == AST_STATE_UP) {
/* This call is up, cancel is ignored, we need a bye */
transmit_response(p, "200 OK", req);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got CANCEL on an answered call. Ignoring... \n");
+ ast_debug(1, "Got CANCEL on an answered call. Ignoring... \n");
return 0;
}
@@ -15217,8 +15048,8 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
p->invitestate = INV_TERMINATED;
copy_request(&p->initreq, req);
- if (sipdebug && option_debug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
sip_alreadygone(p);
@@ -15274,12 +15105,10 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
}
} else if (p->owner) {
ast_queue_hangup(p->owner);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Received bye, issuing owner hangup\n");
+ ast_debug(3, "Received bye, issuing owner hangup\n");
} else {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Received bye, no owner, selfdestruct soon.\n");
+ ast_debug(3, "Received bye, no owner, selfdestruct soon.\n");
}
transmit_response(p, "200 OK", req);
@@ -15317,16 +15146,13 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* For transfers, this could happen, but since we haven't seen it happening, let us just refuse this */
transmit_response(p, "403 Forbidden (within dialog)", req);
/* Do not destroy session, since we will break the call if we do */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
+ ast_debug(1, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
return 0;
} else if (ast_test_flag(req, SIP_PKT_DEBUG)) {
- if (option_debug) {
- if (resubscribe)
- ast_log(LOG_DEBUG, "Got a re-subscribe on existing subscription %s\n", p->callid);
- else
- ast_log(LOG_DEBUG, "Got a new subscription %s (possibly with auth)\n", p->callid);
- }
+ if (resubscribe)
+ ast_debug(1, "Got a re-subscribe on existing subscription %s\n", p->callid);
+ else
+ ast_debug(1, "Got a new subscription %s (possibly with auth)\n", p->callid);
}
}
@@ -15345,8 +15171,8 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
ast_verbose("Creating new subscription\n");
copy_request(&p->initreq, req);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
} else if (ast_test_flag(req, SIP_PKT_DEBUG) && ast_test_flag(req, SIP_PKT_IGNORE))
ast_verbose("Ignoring this SUBSCRIBE request\n");
@@ -15354,8 +15180,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* Find parameters to Event: header value and remove them for now */
if (ast_strlen_zero(eventheader)) {
transmit_response(p, "489 Bad Event", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: <none>\n");
+ ast_debug(2, "Received SIP subscribe for unknown event package: <none>\n");
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
}
@@ -15468,8 +15293,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
if (!ast_strlen_zero(accept) && strcmp(accept, "application/simple-message-summary")) {
/* Format requested that we do not support */
transmit_response(p, "406 Not Acceptable", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP mailbox subscription for unknown format: %s\n", accept);
+ ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", accept);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (authpeer)
unref_peer(authpeer);
@@ -15503,8 +15327,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* Do not release authpeer here */
} else { /* At this point, Asterisk does not understand the specified event */
transmit_response(p, "489 Bad Event", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event);
+ ast_debug(2, "Received SIP subscribe for unknown event package: %s\n", event);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (authpeer)
unref_peer(authpeer);
@@ -15526,11 +15349,11 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
if (p->expiry < min_expiry && p->expiry > 0)
p->expiry = min_expiry;
- if (sipdebug || option_debug > 1) {
+ if (sipdebug) {
if (p->subscribed == MWI_NOTIFICATION && p->relatedpeer)
- ast_log(LOG_DEBUG, "Adding subscription for mailbox notification - peer %s Mailbox %s\n", p->relatedpeer->name, p->relatedpeer->mailbox);
+ ast_debug(2, "Adding subscription for mailbox notification - peer %s Mailbox %s\n", p->relatedpeer->name, p->relatedpeer->mailbox);
else
- ast_log(LOG_DEBUG, "Adding subscription for extension %s context %s for peer %s\n", p->exten, p->context, p->username);
+ ast_debug(2, "Adding subscription for extension %s context %s for peer %s\n", p->exten, p->context, p->username);
}
if (p->autokillid > -1)
sip_cancel_destroy(p); /* Remove subscription expiry for renewals */
@@ -15600,8 +15423,8 @@ static int handle_request_register(struct sip_pvt *p, struct sip_request *req, s
/* Use this as the basis */
copy_request(&p->initreq, req);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
if ((res = register_verify(p, sin, req, e)) < 0) {
const char *reason;
@@ -15697,8 +15520,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
within an existing dialog */
/* Response to our request -- Do some sanity checks */
if (p->ocseq < seqno) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
+ ast_debug(1, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
return -1;
} else if (p->ocseq != seqno) {
/* ignore means "don't do anything with it" but still have to
@@ -15728,12 +15550,10 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
*/
p->method = req->method; /* Find out which SIP method they are using */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
+ ast_debug(4, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
if (p->icseq && (p->icseq > seqno)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
+ ast_debug(1, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
if (req->method != SIP_ACK)
transmit_response(p, "503 Server error", req); /* We must respond according to RFC 3261 sec 12.2 */
return -1;
@@ -15745,8 +15565,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
respond appropriately. We do this if we receive a repeat of
the last sequence number */
ast_set_flag(req, SIP_PKT_IGNORE);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
+ ast_debug(3, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
}
if (seqno >= p->icseq)
@@ -15778,8 +15597,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
transmit_response(p, "481 Call/Transaction Does Not Exist", req);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got ACK for unknown dialog... strange.\n");
+ ast_debug(1, "Got ACK for unknown dialog... strange.\n");
}
return res;
}
@@ -15884,8 +15702,8 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
ast_log(LOG_WARNING, "Recv error: %s\n", strerror(errno));
return 1;
}
- if (option_debug && res == sizeof(req.data)) {
- ast_log(LOG_DEBUG, "Received packet exceeds buffer. Data is possibly lost\n");
+ if (res == sizeof(req.data)) {
+ ast_debug(1, "Received packet exceeds buffer. Data is possibly lost\n");
req.data[sizeof(req.data) - 1] = '\0';
} else
req.data[res] = '\0';
@@ -15913,8 +15731,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
/* Find the active SIP dialog or create a new one */
p = find_call(&req, &sin, req.method); /* returns p locked */
if (p == NULL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid SIP message - rejected , no callid, len %d\n", req.len);
+ ast_debug(1, "Invalid SIP message - rejected , no callid, len %d\n", req.len);
ast_mutex_unlock(&netlock);
return 1;
}
@@ -15922,8 +15739,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
/* becaues this is deadlock-prone, we need to try and unlock if failed */
if (!p->owner || !ast_channel_trylock(p->owner))
break; /* locking succeeded */
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
+ ast_debug(1, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
sip_pvt_unlock(p);
ast_mutex_unlock(&netlock);
/* Sleep for a very short amount of time */
@@ -15947,8 +15763,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
nounlock = 0;
if (handle_request(p, &req, &sin, &recount, &nounlock) == -1) {
/* Request failed */
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
+ ast_debug(1, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
}
if (p->owner && !nounlock)
@@ -16153,13 +15968,13 @@ restartsearch:
if ((res < 0) || (res > 1000))
res = 1000;
res = ast_io_wait(io, res);
- if (option_debug && res > 20)
- ast_log(LOG_DEBUG, "chan_sip: ast_io_wait ran %d all at once\n", res);
+ if (res > 20)
+ ast_debug(1, "chan_sip: ast_io_wait ran %d all at once\n", res);
ast_mutex_lock(&monlock);
if (res >= 0) {
res = ast_sched_runq(sched);
- if (option_debug && res >= 20)
- ast_log(LOG_DEBUG, "chan_sip: ast_sched_runq ran %d all at once\n", res);
+ if (res >= 20)
+ ast_debug(1, "chan_sip: ast_sched_runq ran %d all at once\n", res);
}
ast_mutex_unlock(&monlock);
}
@@ -16331,8 +16146,7 @@ static int sip_devicestate(void *data)
if ((tmp = strchr(host, '@')))
host = tmp + 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for peer %s\n", host);
+ ast_debug(3, "Checking device state for peer %s\n", host);
if ((p = find_peer(host, NULL, 1))) {
if (p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) {
@@ -16400,8 +16214,7 @@ static struct ast_channel *sip_request_call(const char *type, int format, void *
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; /* Can't find codec to connect to host */
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
+ ast_debug(1, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
if (!(p = sip_alloc(NULL, NULL, 0, SIP_INVITE))) {
ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", dest);
@@ -16432,8 +16245,7 @@ static struct ast_channel *sip_request_call(const char *type, int format, void *
if (create_addr(p, host)) {
*cause = AST_CAUSE_UNREGISTERED;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Cant create SIP call - target device not registred\n");
+ ast_debug(3, "Cant create SIP call - target device not registred\n");
sip_destroy(p);
return NULL;
}
@@ -16631,7 +16443,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
AST_LIST_UNLOCK(&domain_list);
if (sipdebug)
- ast_log(LOG_DEBUG, "Added local SIP domain '%s'\n", domain);
+ ast_debug(1, "Added local SIP domain '%s'\n", domain);
return 1;
}
@@ -16681,8 +16493,7 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
if (ast_strlen_zero(configuration))
return authlist;
- if (option_debug)
- ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
+ ast_debug(1, "Auth config :: %s\n", configuration);
ast_copy_string(authcopy, configuration, sizeof(authcopy));
stringp = authcopy;
@@ -16984,8 +16795,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if (realtime) {
rpeerobjs++;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
+ ast_debug(3,"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
} else
speerobjs++;
ASTOBJ_INIT(peer);
@@ -17193,8 +17003,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if ((nowtime - regseconds) > 0) {
destroy_association(peer);
memset(&peer->addr, 0, sizeof(peer->addr));
- if (option_debug)
- ast_log(LOG_DEBUG, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
@@ -17380,8 +17189,7 @@ static int reload_config(enum channelreloadreason reason)
ast_copy_string(global_realm, v->value, sizeof(global_realm));
} else if (!strcasecmp(v->name, "useragent")) {
ast_copy_string(global_useragent, v->value, sizeof(global_useragent));
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
+ ast_debug(1, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
} else if (!strcasecmp(v->name, "allowtransfer")) {
global_allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
} else if (!strcasecmp(v->name, "rtcachefriends")) {
@@ -17563,8 +17371,8 @@ static int reload_config(enum channelreloadreason reason)
if (context)
*context++ = '\0';
- if (option_debug && ast_strlen_zero(context))
- ast_log(LOG_DEBUG, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
+ if (ast_strlen_zero(context))
+ ast_debug(1, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
if (ast_strlen_zero(domain))
ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
else
@@ -17837,14 +17645,10 @@ static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
- }
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
transmit_reinvite_with_sdp(p, TRUE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
- }
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
@@ -17893,20 +17697,16 @@ static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt
}
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
transmit_reinvite_with_sdp(p, TRUE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
@@ -17921,18 +17721,14 @@ static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt
} else {
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
}
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
pvt->t38.state = T38_ENABLED;
p->t38.state = T38_ENABLED;
- if (option_debug > 1) {
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", pvt->t38.state, pvt->owner ? pvt->owner->name : "<none>");
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
- }
+ ast_debug(2, "T38 changed state to %d on channel %s\n", pvt->t38.state, pvt->owner ? pvt->owner->name : "<none>");
+ ast_debug(2, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
p->lastrtprx = p->lastrtptx = time(NULL);
sip_pvt_unlock(p);
@@ -18080,17 +17876,12 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struc
if (chan->_state != AST_STATE_UP) { /* We are in early state */
if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY))
append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
- if (option_debug)
- ast_log(LOG_DEBUG, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
+ ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
} else if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
- }
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
transmit_reinvite_with_sdp(p, FALSE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
- }
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
/* We have a pending Invite. Send re-invite when we're done with the invite */
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
@@ -18197,7 +17988,7 @@ static int sip_addheader(struct ast_channel *chan, void *data)
if (ok) {
pbx_builtin_setvar_helper (chan, varbuf, inbuf);
if (sipdebug)
- ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
+ ast_debug(1,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
} else {
ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n");
}
@@ -18318,8 +18109,7 @@ static void sip_send_all_registers(void)
/*! \brief Reload module */
static int sip_do_reload(enum channelreloadreason reason)
{
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- SIP reload started\n");
+ ast_debug(4, "--------------- SIP reload started\n");
clear_realm_authentication(authl);
clear_sip_domains();
@@ -18330,8 +18120,7 @@ static int sip_do_reload(enum channelreloadreason reason)
ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {
ASTOBJ_RDLOCK(iterator);
if (iterator->call) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
/* This will also remove references to the registry */
sip_destroy(iterator->call);
}
@@ -18341,18 +18130,15 @@ static int sip_do_reload(enum channelreloadreason reason)
/* Then, actually destroy users and registry */
ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying user list\n");
+ ast_debug(4, "--------------- Done destroying user list\n");
ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying registry list\n");
+ ast_debug(4, "--------------- Done destroying registry list\n");
ASTOBJ_CONTAINER_MARKALL(&peerl);
reload_config(reason);
/* Prune peers who still are supposed to be deleted */
ASTOBJ_CONTAINER_PRUNE_MARKED(&peerl, sip_destroy_peer);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying pruned peers\n");
+ ast_debug(4, "--------------- Done destroying pruned peers\n");
/* Send qualify (OPTIONS) to all peers */
sip_poke_all_peers();
@@ -18360,8 +18146,7 @@ static int sip_do_reload(enum channelreloadreason reason)
/* Register with all services */
sip_send_all_registers();
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- SIP reload done\n");
+ ast_debug(4, "--------------- SIP reload done\n");
return 0;
}
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 8bff31cb6..8ba5b0223 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -2462,8 +2462,7 @@ static void *skinny_ss(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
+ ast_debug(1, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
transmit_tone(s, SKINNY_REORDER);
if (sub->owner && sub->owner->_state != AST_STATE_UP) {
ast_indicate(c, -1);
@@ -2552,8 +2551,7 @@ static int skinny_hangup(struct ast_channel *ast)
struct skinnysession *s;
if (!sub) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ ast_debug(1, "Asked to hangup channel not connected\n");
return 0;
}
l = sub->parent;
@@ -2657,8 +2655,7 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != ast->nativeformats) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
ast->nativeformats = f->subclass;
ast_set_read_format(ast, ast->readformat);
ast_set_write_format(ast, ast->writeformat);
@@ -3383,8 +3380,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
+ ast_debug(1, "Current subchannel [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if (c) {
@@ -3463,8 +3459,7 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
+ ast_debug(1, "Current sub [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if (c) {
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index 748f58f7b..a89701a6a 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -536,7 +536,7 @@ static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_
res = AST_BRIDGE_RETRY;
break;
}
- ast_log(LOG_DEBUG, "%s: vpb_bridge: Empty frame read...\n",p0->dev);
+ ast_debug(1, "%s: vpb_bridge: Empty frame read...\n",p0->dev);
/* check for hangup / whentohangup */
if (ast_check_hangup(c0) || ast_check_hangup(c1))
break;
@@ -548,7 +548,7 @@ static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_
((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1))))) {
*fo = f;
*rc = who;
- ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
+ ast_debug(1, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
/*
if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) {
if (pr0->set_rtp_peer(c0, NULL, NULL, 0))
@@ -930,9 +930,9 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
} else
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
} else
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ ast_debug(1, "Fax already handled\n");
}
else if (e->data == VPB_GRUNT) {
@@ -1799,7 +1799,7 @@ static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
*/
ast_mutex_lock(&p->lock);
- ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name);
+ ast_debug(1, "New owner for channel %s is %s\n", p->dev, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
@@ -1957,7 +1957,7 @@ static int vpb_call(struct ast_channel *ast, char *dest, int timeout)
#endif
if (res != VPB_OK) {
- ast_log(LOG_DEBUG, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res));
+ ast_debug(1, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res));
res = -1;
} else
res = 0;
@@ -2278,7 +2278,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
/* ast_mutex_unlock(&p->lock); */
return 0;
}
-/* ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame type..\n", p->dev); */
+/* ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */
fmt = ast2vpbformat(frame->subclass);
@@ -2288,20 +2288,20 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
}
tdiff = ast_tvdiff_ms(ast_tvnow(), p->lastplay);
- ast_log(LOG_DEBUG, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff);
+ ast_debug(1, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff);
if (tdiff < (VPB_SAMPLES/8 - 1)){
- ast_log(LOG_DEBUG, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen);
+ ast_debug(1, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen);
// return 0;
}
p->lastplay = ast_tvnow();
/*
- ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame format..\n", p->dev);
+ ast_debug(1, "%s: vpb_write: Checked frame format..\n", p->dev);
*/
ast_mutex_lock(&p->play_lock);
/*
- ast_log(LOG_DEBUG, "%s: vpb_write: Got play lock..\n", p->dev);
+ ast_debug(1, "%s: vpb_write: Got play lock..\n", p->dev);
*/
/* Check if we have set up the play_buf */
@@ -2329,8 +2329,8 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
if( p->txswgain > MAX_VPB_GAIN )
a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen/sizeof(short));
-/* ast_log(LOG_DEBUG, "%s: vpb_write: Applied gain..\n", p->dev); */
-/* ast_log(LOG_DEBUG, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
+/* ast_debug(1, "%s: vpb_write: Applied gain..\n", p->dev); */
+/* ast_debug(1, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
if ((p->read_state == 1)&&(p->play_buf_time<5)){
play_buf_time_start = ast_tvnow();
@@ -2344,7 +2344,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
}
else {
p->chuck_count++;
- ast_log(LOG_DEBUG, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count);
+ ast_debug(1, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count);
p->play_buf_time=0;
}
@@ -2473,11 +2473,11 @@ static void *do_chanreads(void *pvt)
/* afmt = (p->owner) ? p->owner->rawreadformat : AST_FORMAT_SLINEAR; */
if (p->owner){
afmt = p->owner->rawreadformat;
-/* ast_log(LOG_DEBUG,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
+/* ast_debug(1,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
else {
afmt = AST_FORMAT_SLINEAR;
-/* ast_log(LOG_DEBUG,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
+/* ast_debug(1,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
fmt = ast2vpbformat(afmt);
if (fmt < 0) {
@@ -2525,7 +2525,7 @@ static void *do_chanreads(void *pvt)
if ((use_ast_dtmfdet)&&(p->vad)){
fr = ast_dsp_process(p->owner,p->vad,fr);
if (fr && (fr->frametype == AST_FRAME_DTMF))
- ast_log(LOG_DEBUG, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass);
+ ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass);
if (fr->subclass == 'm'){
/* conf mute request */
fr->frametype = AST_FRAME_NULL;
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 69d5aa297..918da3602 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -976,8 +976,7 @@ static void swap_subs(struct zt_pvt *p, int a, int b)
int tinthreeway;
struct ast_channel *towner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ ast_debug(1, "Swapping %d and %d\n", a, b);
tchan = p->subs[a].chan;
towner = p->subs[a].owner;
@@ -1080,8 +1079,7 @@ static int alloc_sub(struct zt_pvt *p, int x)
p->subs[x].zfd = -1;
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
+ ast_debug(1, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
return 0;
} else
ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
@@ -1097,8 +1095,7 @@ static int unalloc_sub(struct zt_pvt *p, int x)
ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel);
+ ast_debug(1, "Released sub %d of channel %d\n", x, p->channel);
if (p->subs[x].zfd > -1) {
zt_close(p->subs[x].zfd);
}
@@ -1153,8 +1150,7 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->span);
} else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) {
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
+ ast_debug(1, "Queueing digit '%c' since setup_ack not yet received\n", digit);
res = strlen(pvt->dialdest);
pvt->dialdest[res++] = digit;
pvt->dialdest[res] = '\0';
@@ -1179,8 +1175,7 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
else
pvt->dialing = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
+ ast_debug(1, "Started VLDTMF digit '%c'\n", digit);
pvt->dialing = 1;
pvt->begindigit = digit;
}
@@ -1215,8 +1210,7 @@ static int zt_digit_end(struct ast_channel *chan, char digit, unsigned int durat
if (pvt->begindigit) {
x = -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
+ ast_debug(1, "Ending VLDTMF digit '%c'\n", digit);
res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &x);
pvt->dialing = 0;
pvt->begindigit = 0;
@@ -1390,8 +1384,7 @@ static int conf_add(struct zt_pvt *p, struct zt_subchannel *c, int index, int sl
p->confno = zi.confno;
}
memcpy(&c->curconf, &zi, sizeof(c->curconf));
- if (option_debug)
- ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ ast_debug(1, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return 0;
}
@@ -1423,8 +1416,7 @@ static int conf_del(struct zt_pvt *p, struct zt_subchannel *c, int index)
ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ ast_debug(1, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
memcpy(&c->curconf, &zi, sizeof(c->curconf));
return 0;
}
@@ -1538,8 +1530,7 @@ static int update_conf(struct zt_pvt *p)
Kill it. */
p->confno = -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
+ ast_debug(1, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
return 0;
}
@@ -1550,13 +1541,11 @@ static void zt_enable_ec(struct zt_pvt *p)
if (!p)
return;
if (p->echocanon) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Echo cancellation already on\n");
+ ast_debug(1, "Echo cancellation already on\n");
return;
}
if (p->digital) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
+ ast_debug(1, "Echo cancellation isn't required on digital connection\n");
return;
}
if (p->echocancel) {
@@ -1572,11 +1561,10 @@ static void zt_enable_ec(struct zt_pvt *p)
ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d\n", p->channel);
else {
p->echocanon = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
+ ast_debug(1, "Enabled echo cancellation on channel %d\n", p->channel);
}
- } else if (option_debug)
- ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ } else
+ ast_debug(1, "No echo cancellation requested\n");
}
static void zt_train_ec(struct zt_pvt *p)
@@ -1588,14 +1576,10 @@ static void zt_train_ec(struct zt_pvt *p)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
if (res)
ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
- }
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No echo training requested\n");
- }
+ else
+ ast_debug(1, "Engaged echo training on channel %d\n", p->channel);
+ } else
+ ast_debug(1, "No echo training requested\n");
}
static void zt_disable_ec(struct zt_pvt *p)
@@ -1607,8 +1591,8 @@ static void zt_disable_ec(struct zt_pvt *p)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
if (res)
ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
- else if (option_debug)
- ast_log(LOG_DEBUG, "disabled echo cancellation on channel %d\n", p->channel);
+ else
+ ast_debug(1, "disabled echo cancellation on channel %d\n", p->channel);
}
p->echocanon = 0;
}
@@ -1690,8 +1674,7 @@ static int set_actual_txgain(int fd, int chan, float gain, int law)
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
return res;
}
@@ -1709,8 +1692,7 @@ static int set_actual_rxgain(int fd, int chan, float gain, int law)
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
return res;
}
@@ -1803,8 +1785,7 @@ static int save_conference(struct zt_pvt *p)
ast_log(LOG_WARNING, "Unable to set conference info: %s\n", strerror(errno));
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Disabled conferencing\n");
+ ast_debug(1, "Disabled conferencing\n");
return 0;
}
@@ -1819,8 +1800,7 @@ static int restore_conference(struct zt_pvt *p)
return -1;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Restored conferencing\n");
+ ast_debug(1, "Restored conferencing\n");
return 0;
}
@@ -2008,8 +1988,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
if (c) {
p->dop.op = ZT_DIAL_OP_REPLACE;
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
- if (option_debug)
- ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
+ ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
} else {
p->dop.dialstr[0] = '\0';
}
@@ -2101,8 +2080,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
#ifdef HAVE_PRI
}
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
+ ast_debug(1, "Dialing '%s'\n", c);
p->dop.op = ZT_DIAL_OP_REPLACE;
c += p->stripmsd;
@@ -2177,10 +2155,9 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
ast_mutex_unlock(&p->lock);
return -1;
}
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring dialing...\n");
- }
+ } else
+ ast_debug(1, "Deferring dialing...\n");
+
p->dialing = 1;
if (ast_strlen_zero(c))
p->dialednone = 1;
@@ -2196,8 +2173,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
p->dialdest[0] = '\0';
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "not yet implemented\n");
+ ast_debug(1, "not yet implemented\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2298,13 +2274,11 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
}
if (p->bearer || (mysig == SIG_FXSKS)) {
if (p->bearer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel);
+ ast_debug(1, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel);
p->bearer->call = p->call;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n");
- }
+ } else
+ ast_debug(1, "I'm being setup with no bearer right now...\n");
+
pri_set_crv(p->pri->pri, p->call, p->channel, 0);
}
p->digital = IS_DIGITAL(ast->transfercapability);
@@ -2495,24 +2469,21 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
char *digits = (char *) data;
if (ast_strlen_zero(digits)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No digit string sent to application!\n");
+ ast_debug(1, "No digit string sent to application!\n");
return -1;
}
p = (struct zt_pvt *)chan->tech_pvt;
if (!p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find technology private\n");
+ ast_debug(1, "Unable to find technology private\n");
return -1;
}
ast_mutex_lock(&p->lock);
if (!p->pri || !p->call) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n");
+ ast_debug(1, "Unable to find pri or call on channel!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2521,8 +2492,7 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
pri_keypad_facility(p->pri->pri, p->call, digits);
pri_rel(p->pri);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
+ ast_debug(1, "Unable to grab pri to send keypad facility!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2621,8 +2591,7 @@ static int zt_hangup(struct ast_channel *ast)
struct zt_pvt *prev = NULL;
ZT_PARAMS par;
- if (option_debug)
- ast_log(LOG_DEBUG, "zt_hangup(%s)\n", ast->name);
+ ast_debug(1, "zt_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -2655,9 +2624,8 @@ static int zt_hangup(struct ast_channel *ast)
if (p->exten)
p->exten[0] = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
- p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+ ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
+ p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->ignoredtmf = 0;
if (index > -1) {
@@ -2674,32 +2642,27 @@ static int zt_hangup(struct ast_channel *ast)
zt_setlinear(p->subs[index].zfd, 0);
if (index == SUB_REAL) {
if ((p->subs[SUB_CALLWAIT].zfd > -1) && (p->subs[SUB_THREEWAY].zfd > -1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n");
+ ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
if (p->subs[SUB_CALLWAIT].inthreeway) {
/* We had flipped over to answer a callwait and now it's gone */
- if (option_debug)
- ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n");
+ ast_debug(1, "We were flipped over to the callwait, moving back and unowning.\n");
/* Move to the call-wait, but un-own us until they flip back. */
swap_subs(p, SUB_CALLWAIT, SUB_REAL);
unalloc_sub(p, SUB_CALLWAIT);
p->owner = NULL;
} else {
/* The three way hung up, but we still have a call wait */
- if (option_debug)
- ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
+ ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
swap_subs(p, SUB_THREEWAY, SUB_REAL);
unalloc_sub(p, SUB_THREEWAY);
if (p->subs[SUB_REAL].inthreeway) {
/* This was part of a three way call. Immediately make way for
another call */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ ast_debug(1, "Call was complete, setting owner to former third call\n");
p->owner = p->subs[SUB_REAL].owner;
} else {
/* This call hasn't been completed yet... Set owner to NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ ast_debug(1, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
@@ -2719,13 +2682,11 @@ static int zt_hangup(struct ast_channel *ast)
if (p->subs[SUB_REAL].inthreeway) {
/* This was part of a three way call. Immediately make way for
another call */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ ast_debug(1, "Call was complete, setting owner to former third call\n");
p->owner = p->subs[SUB_REAL].owner;
} else {
/* This call hasn't been completed yet... Set owner to NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ ast_debug(1, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
@@ -2828,8 +2789,7 @@ static int zt_hangup(struct ast_channel *ast)
if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
if (!pri_grab(p, p->pri)) {
if (p->alreadyhungup) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
+ ast_debug(1, "Already hungup... Calling hangup once, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
@@ -2842,8 +2802,7 @@ static int zt_hangup(struct ast_channel *ast)
} else {
const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
int icause = ast->hangupcause ? ast->hangupcause : -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
+ ast_debug(1, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
@@ -2867,8 +2826,7 @@ static int zt_hangup(struct ast_channel *ast)
}
} else {
if (p->bearer)
- if (option_debug)
- ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
+ ast_debug(1, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
p->call = NULL;
res = 0;
}
@@ -2886,8 +2844,7 @@ static int zt_hangup(struct ast_channel *ast)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par);
if (!res) {
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
+ ast_debug(1, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
#endif
/* If they're off hook, try playing congestion */
if ((par.rxisoffhook) && (!(p->radio || (p->oprmode < 0))))
@@ -2932,8 +2889,7 @@ static int zt_hangup(struct ast_channel *ast)
}
#ifdef HAVE_PRI
if (p->bearer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel);
+ ast_debug(1, "Freeing up bearer channel %d\n", p->bearer->channel);
/* Free up the bearer channel as well, and
don't use its file descriptor anymore */
update_conf(p->bearer);
@@ -3016,8 +2972,7 @@ static int zt_answer(struct ast_channel *ast)
case SIG_FXOGS:
case SIG_FXOKS:
/* Pick up the line */
- if (option_debug)
- ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name);
+ ast_debug(1, "Took %s off hook\n", ast->name);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
@@ -3026,8 +2981,7 @@ static int zt_answer(struct ast_channel *ast)
p->dialing = 0;
if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) {
if (oldstate == AST_STATE_RINGING) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Finally swapping real and threeway\n");
+ ast_debug(1, "Finally swapping real and threeway\n");
tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, -1);
swap_subs(p, SUB_THREEWAY, SUB_REAL);
p->owner = p->subs[SUB_REAL].owner;
@@ -3098,8 +3052,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
ast_log(LOG_WARNING, "No index in TXGAIN?\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
+ ast_debug(1, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
return set_actual_txgain(p->subs[index].zfd, 0, p->txgain + (float) *scp, p->law);
case AST_OPTION_RXGAIN:
scp = (signed char *) data;
@@ -3108,8 +3061,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
ast_log(LOG_WARNING, "No index in RXGAIN?\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
+ ast_debug(1, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
return set_actual_rxgain(p->subs[index].zfd, 0, p->rxgain + (float) *scp, p->law);
case AST_OPTION_TONE_VERIFY:
if (!p->dsp)
@@ -3117,18 +3069,15 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
cp = (char *) data;
switch (*cp) {
case 1:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | p->dtmfrelax); /* set mute mode if desired */
break;
case 2:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX | p->dtmfrelax); /* set mute mode if desired */
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); /* set mute mode if desired */
break;
}
@@ -3138,16 +3087,14 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
cp = (char *) data;
p->mate = 0;
if (!*cp) { /* turn it off */
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
+ ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
if (p->tdd)
tdd_free(p->tdd);
p->tdd = 0;
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n",
- (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
+ ast_debug(1, "Set option TDD MODE, value: %s(%d) on %s\n",
+ (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
zt_disable_ec(p);
/* otherwise, turn it on */
if (!p->didtdd) { /* if havent done it yet */
@@ -3176,23 +3123,20 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
continue;
}
/* if got exception */
if (fds[0].revents & POLLPRI)
return -1;
if (!(fds[0].revents & POLLOUT)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ ast_debug(1, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
if (res != size) {
if (res == -1) return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
@@ -3215,21 +3159,18 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
if (!p->dsp)
break;
cp = (char *) data;
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n",
- *cp ? "ON" : "OFF", (int) *cp, chan->name);
+ ast_debug(1, "Set option RELAX DTMF, value: %s(%d) on %s\n",
+ *cp ? "ON" : "OFF", (int) *cp, chan->name);
ast_dsp_digitmode(p->dsp, ((*cp) ? DSP_DIGITMODE_RELAXDTMF : DSP_DIGITMODE_DTMF) | p->dtmfrelax);
break;
case AST_OPTION_AUDIO_MODE: /* Set AUDIO mode (or not) */
cp = (char *) data;
if (!*cp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
+ ast_debug(1, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
x = 0;
zt_disable_ec(p);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
+ ast_debug(1, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
x = 1;
}
if (ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x) == -1)
@@ -3248,19 +3189,16 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
pp->oprmode = oprmode->mode;
p->oprmode = -oprmode->mode;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n",
- oprmode->mode, chan->name,oprmode->peer->name);
+ ast_debug(1, "Set Operator Services mode, value: %d on %s/%s\n",
+ oprmode->mode, chan->name,oprmode->peer->name);
break;
case AST_OPTION_ECHOCAN:
cp = (char *) data;
if (*cp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
+ ast_debug(1, "Enabling echo cancelation on %s\n", chan->name);
zt_enable_ec(p);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name);
+ ast_debug(1, "Disabling echo cancelation on %s\n", chan->name);
zt_disable_ec(p);
}
break;
@@ -3311,8 +3249,7 @@ static void zt_unlink(struct zt_pvt *slave, struct zt_pvt *master, int needlock)
if (master->slaves[x]) {
if (!slave || (master->slaves[x] == slave)) {
/* Take slave out of the conference */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
+ ast_debug(1, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
conf_del(master, &master->slaves[x]->subs[SUB_REAL], SUB_REAL);
conf_del(master->slaves[x], &master->subs[SUB_REAL], SUB_REAL);
master->slaves[x]->master = NULL;
@@ -3368,8 +3305,7 @@ static void zt_link(struct zt_pvt *slave, struct zt_pvt *master) {
ast_log(LOG_WARNING, "Replacing master %d with new master, %d\n", slave->master->channel, master->channel);
slave->master = master;
- if (option_debug)
- ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
+ ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
}
static void disable_dtmf_detect(struct zt_pvt *p)
@@ -3532,9 +3468,8 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
nothingok = 0;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n",
- master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
+ ast_debug(1, "master: %d, slave: %d, nothingok: %d\n",
+ master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
if (master && slave) {
/* Stop any tones, or play ringtone as appropriate. If they're bridged
in an active threeway call with a channel that is ringing, we should
@@ -3544,13 +3479,11 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
p1->subs[SUB_REAL].owner &&
p1->subs[SUB_REAL].inthreeway &&
(p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
+ ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
tone_zone_play_tone(p0->subs[oi0].zfd, ZT_TONE_RINGTONE);
os1 = p1->subs[SUB_REAL].owner->_state;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
+ ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
tone_zone_play_tone(p0->subs[oi0].zfd, -1);
}
if ((oi0 == SUB_THREEWAY) &&
@@ -3558,13 +3491,11 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
p0->subs[SUB_REAL].owner &&
p0->subs[SUB_REAL].inthreeway &&
(p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
+ ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
tone_zone_play_tone(p1->subs[oi1].zfd, ZT_TONE_RINGTONE);
os0 = p0->subs[SUB_REAL].owner->_state;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
+ ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
tone_zone_play_tone(p1->subs[oi0].zfd, -1);
}
if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) {
@@ -3637,9 +3568,8 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
(t1 != p1->subs[SUB_REAL].inthreeway) ||
(oi0 != i0) ||
(oi1 != i1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
- op0->channel, oi0, op1->channel, oi1);
+ ast_debug(1, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
+ op0->channel, oi0, op1->channel, oi1);
res = AST_BRIDGE_RETRY;
goto return_from_bridge;
}
@@ -3657,8 +3587,7 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &timeoutms);
if (!who) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, empty read...\n");
+ ast_debug(1, "Ooh, empty read...\n");
continue;
}
f = ast_read(who);
@@ -3709,8 +3638,7 @@ static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
struct zt_pvt *p = newchan->tech_pvt;
int x;
ast_mutex_lock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
+ ast_debug(1, "New owner for channel %d is %s\n", p->channel, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
}
@@ -3829,9 +3757,8 @@ static int attempt_transfer(struct zt_pvt *p)
/* Tell the caller not to hangup */
return 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n",
- p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name);
+ ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
+ p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
return -1;
}
@@ -3879,12 +3806,10 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
struct zt_pvt *p = ast->tech_pvt;
struct ast_frame *f = *dest;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name);
+ ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name);
if (p->confirmanswer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Confirm answer on %s!\n", ast->name);
+ ast_debug(1, "Confirm answer on %s!\n", ast->name);
/* Upon receiving a DTMF digit, consider this an answer confirmation instead
of a DTMF digit */
p->subs[index].f.frametype = AST_FRAME_CONTROL;
@@ -3894,8 +3819,7 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
p->confirmanswer = 0;
} else if (p->callwaitcas) {
if ((f->subclass == 'A') || (f->subclass == 'D')) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n");
+ ast_debug(1, "Got some DTMF, but it's for the CAS\n");
if (p->cidspill)
ast_free(p->cidspill);
send_cwcidspill(p);
@@ -3921,10 +3845,10 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ } else
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
+ } else
+ ast_debug(1, "Fax already handled\n");
zt_confmute(p, 0);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
@@ -3977,13 +3901,11 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
} else
res = zt_get_event(p->subs[index].zfd);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
+ ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
if (res & (ZT_EVENT_PULSEDIGIT | ZT_EVENT_DTMFUP)) {
p->pulsedial = (res & ZT_EVENT_PULSEDIGIT) ? 1 : 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
+ ast_debug(1, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig == SIG_PRI && p->pri && (p->pri->overlapdial & ZAP_OVERLAPDIAL_INCOMING)) {
/* absorb event */
@@ -3999,8 +3921,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
}
if (res & ZT_EVENT_DTMFDOWN) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff);
+ ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
/* Mute conference */
zt_confmute(p, 1);
p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
@@ -4027,8 +3948,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (p->inalarm) break;
if ((p->radio || (p->oprmode < 0))) break;
if (ioctl(p->subs[index].zfd,ZT_DIALING,&x) == -1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name);
+ ast_debug(1, "ZT_DIALING ioctl failed on %s\n",ast->name);
return NULL;
}
if (!x) { /* if not still dialing in driver */
@@ -4055,8 +3975,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
}
if (ast->_state == AST_STATE_DIALING) {
if ((p->callprogress & 1) && CANPROGRESSDETECT(p) && p->dsp && p->outgoing) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n");
+ ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n");
} else if (p->confirmanswer || (!p->dialednone && ((mysig == SIG_EM) || (mysig == SIG_EM_E1) || (mysig == SIG_EMWINK) || (mysig == SIG_FEATD) || (mysig == SIG_FEATDMF_TA) || (mysig == SIG_FEATDMF) || (mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF) || (mysig == SIG_FEATB) || (mysig == SIG_SF) || (mysig == SIG_SFWINK) || (mysig == SIG_SF_FEATD) || (mysig == SIG_SF_FEATDMF) || (mysig == SIG_SF_FEATB)))) {
ast_setstate(ast, AST_STATE_RINGING);
} else if (!p->answeronpolarityswitch) {
@@ -4174,16 +4093,14 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
return NULL;
}
mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
- if (option_debug)
- ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
+ ast_debug(1, "Last flash was %d ms ago\n", mssinceflash);
if (mssinceflash < MIN_MS_SINCE_FLASH) {
/* It hasn't been long enough since the last flashook. This is probably a bounce on
hanging up. Hangup both channels now */
if (p->subs[SUB_THREEWAY].owner)
ast_queue_hangup(p->subs[SUB_THREEWAY].owner);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
- if (option_debug)
- ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
+ ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
} else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) {
if (p->transfer) {
@@ -4291,8 +4208,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
/* Make sure it stops ringing */
zt_set_hook(p->subs[index].zfd, ZT_OFFHOOK);
- if (option_debug)
- ast_log(LOG_DEBUG, "channel %d answered\n", p->channel);
+ ast_debug(1, "channel %d answered\n", p->channel);
if (p->cidspill) {
/* Cancel any running CallerID spill */
ast_free(p->cidspill);
@@ -4312,8 +4228,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->dop.dialstr[0] = '\0';
return NULL;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
+ ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
p->dialing = 1;
@@ -4328,8 +4243,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
ast->rings = 1;
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
- if (option_debug)
- ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel);
+ ast_debug(1, "channel %d picked up\n", p->channel);
return &p->subs[index].f;
case AST_STATE_UP:
/* Make sure it stops ringing */
@@ -4359,10 +4273,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
/* If we get a ring then we cannot be in
* reversed polarity. So we reset to idle */
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting IDLE polarity due "
- "to ring. Old polarity was %d\n",
- p->polarity);
+ ast_debug(1, "Setting IDLE polarity due "
+ "to ring. Old polarity was %d\n",
+ p->polarity);
p->polarity = POLARITY_IDLE;
/* Fall through */
@@ -4384,13 +4297,11 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (ast->_state == AST_STATE_PRERING)
ast_setstate(ast, AST_STATE_RING);
if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ring detected\n");
+ ast_debug(1, "Ring detected\n");
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RING;
} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Line answered\n");
+ ast_debug(1, "Line answered\n");
if (p->confirmanswer) {
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
@@ -4472,9 +4383,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FXOLS:
case SIG_FXOGS:
case SIG_FXOKS:
- if (option_debug)
- ast_log(LOG_DEBUG, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
- index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+ ast_debug(1, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
+ index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->callwaitcas = 0;
if (index != SUB_REAL) {
@@ -4487,8 +4397,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
swap_subs(p, SUB_REAL, SUB_CALLWAIT);
tone_zone_play_tone(p->subs[SUB_REAL].zfd, -1);
p->owner = p->subs[SUB_REAL].owner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name);
+ ast_debug(1, "Making %s the new owner\n", p->owner->name);
if (p->owner->_state == AST_STATE_RINGING) {
ast_setstate(p->owner, AST_STATE_UP);
p->subs[SUB_REAL].needanswer = 1;
@@ -4528,8 +4437,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (!((ast->pbx) ||
(ast->_state == AST_STATE_UP) ||
(ast->_state == AST_STATE_RING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Flash when call not up or ringing\n");
+ ast_debug(1, "Flash when call not up or ringing\n");
goto winkflashdone;
}
if (alloc_sub(p, SUB_THREEWAY)) {
@@ -4577,8 +4485,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
/* Already have a 3 way call */
if (p->subs[SUB_THREEWAY].inthreeway) {
/* Call is already up, drop the last person */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got flash with three way call up, dropping last call on %d\n", p->channel);
+ ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
/* If the primary call isn't answered yet, use it */
if ((p->subs[SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_UP)) {
/* Swap back -- we're dropping the real 3-way that isn't finished yet*/
@@ -4611,8 +4518,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->subs[otherindex].needunhold = 1;
p->owner = p->subs[SUB_REAL].owner;
if (ast->_state == AST_STATE_RINGING) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n");
+ ast_debug(1, "Enabling ringtone on real and threeway\n");
res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
res = tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE);
}
@@ -4644,16 +4550,15 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FXSGS:
if (option_debug) {
if (p->dialing)
- ast_log(LOG_DEBUG, "Ignoring wink on channel %d\n", p->channel);
+ ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
else
- ast_log(LOG_DEBUG, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
+ ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
}
break;
case SIG_FEATDMF_TA:
switch (p->whichwink) {
case 0:
- if (option_debug)
- ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+ ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
break;
case 1:
@@ -4679,10 +4584,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
return NULL;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr);
+
p->dop.dialstr[0] = '\0';
break;
default:
@@ -4709,10 +4613,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
return NULL;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr);
+
p->dop.dialstr[0] = '\0';
p->dop.op = ZT_DIAL_OP_REPLACE;
break;
@@ -4724,8 +4627,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FEATB:
case SIG_SF_FEATDMF:
case SIG_SF_FEATB:
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
+ ast_debug(1, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
break;
default:
break;
@@ -4743,16 +4645,14 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (p->answeronpolarityswitch &&
((ast->_state == AST_STATE_DIALING) ||
(ast->_state == AST_STATE_RINGING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
+ ast_debug(1, "Answering on polarity switch!\n");
ast_setstate(p->owner, AST_STATE_UP);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
- }
+ } else
+ ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+
}
/* Removed else statement from here as it was preventing hangups from ever happening*/
/* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */
@@ -4761,30 +4661,24 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
(p->polarity == POLARITY_REV) &&
((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
/* Added log_debug information below to provide a better indication of what is going on */
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+ ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
+ ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
p->polarity = POLARITY_IDLE;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
- }
+ } else
+ ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
+
} else {
p->polarity = POLARITY_IDLE;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
+ ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
}
/* Added more log_debug information below to provide a better indication of what is going on */
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+ ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
+ ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
}
return &p->subs[index].f;
}
@@ -4825,8 +4719,7 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast)
/* Switch to real if there is one and this isn't something really silly... */
if ((res != ZT_EVENT_RINGEROFF) && (res != ZT_EVENT_RINGERON) &&
(res != ZT_EVENT_HOOKCOMPLETE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res);
+ ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
p->owner = p->subs[SUB_REAL].owner;
if (p->owner && ast_bridged_channel(p->owner))
ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
@@ -4885,8 +4778,8 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast)
f = &p->subs[index].f;
return f;
}
- if (!(p->radio || (p->oprmode < 0)) && option_debug)
- ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+ if (!(p->radio || (p->oprmode < 0)))
+ ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
/* If it's not us, return NULL immediately */
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
@@ -5029,8 +4922,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_HOLD;
ast_mutex_unlock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name);
+ ast_debug(1, "Sending hold on '%s'\n", ast->name);
return &p->subs[index].f;
}
@@ -5040,8 +4932,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_UNHOLD;
ast_mutex_unlock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name);
+ ast_debug(1, "Sending unhold on '%s'\n", ast->name);
return &p->subs[index].f;
}
@@ -5086,8 +4977,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
return f;
}
if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
+ ast_debug(1, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
f = __zt_exception(ast);
ast_mutex_unlock(&p->lock);
return f;
@@ -5097,8 +4987,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
c = tdd_feed(p->tdd,readbuf,READ_SIZE);
if (c < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG,"tdd_feed failed\n");
+ ast_debug(1,"tdd_feed failed\n");
ast_mutex_unlock(&p->lock);
return NULL;
}
@@ -5146,8 +5035,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]);
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
+ ast_debug(1, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
#endif
if (p->dialing || /* Transmitting something */
(index && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
@@ -5214,8 +5102,7 @@ static int my_zt_write(struct zt_pvt *p, unsigned char *buf, int len, int index,
size = (linear ? READ_SIZE * 2 : READ_SIZE);
res = write(fd, buf, size);
if (res != size) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
return sent;
}
len -= size;
@@ -5265,18 +5152,15 @@ static int zt_write(struct ast_channel *ast, struct ast_frame *frame)
return -1;
}
if (p->dialing) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since I'm still dialing on %s...\n",ast->name);
+ ast_debug(1, "Dropping frame since I'm still dialing on %s...\n",ast->name);
return 0;
}
if (!p->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since there is no active owner on %s...\n",ast->name);
+ ast_debug(1, "Dropping frame since there is no active owner on %s...\n",ast->name);
return 0;
}
if (p->cidspill) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since I've still got a callerid spill\n");
+ ast_debug(1, "Dropping frame since I've still got a callerid spill\n");
return 0;
}
/* Return if it's not valid data */
@@ -5320,8 +5204,7 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
int func = ZT_FLASH;
ast_mutex_lock(&p->lock);
index = zt_get_index(chan, p, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
if (index == SUB_REAL) {
switch (condition) {
case AST_CONTROL_BUSY:
@@ -5381,8 +5264,7 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
}
break;
case AST_CONTROL_PROCEEDING:
- if (option_debug)
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
+ ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) {
if (p->pri->pri) {
@@ -5411,8 +5293,7 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
res = 0;
break;
case AST_CONTROL_PROGRESS:
- if (option_debug)
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
+ ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
#ifdef HAVE_PRI
p->digital = 0; /* Digital-only calls isn't allows any inband progress messages */
if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) {
@@ -5604,8 +5485,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
}
if (features) {
if (i->dsp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
+ ast_debug(1, "Already have a dsp on %s?\n", tmp->name);
} else {
if (i->channel != CHAN_PSEUDO)
i->dsp = ast_dsp_new();
@@ -5808,8 +5688,7 @@ static void *ss_thread(void *data)
timeout = gendigittimeout;
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
@@ -5837,8 +5716,7 @@ static void *ss_thread(void *data)
ast_log(LOG_WARNING, "PBX exited non-zero!\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
+ ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
chan->hangupcause = AST_CAUSE_UNALLOCATED;
ast_hangup(chan);
p->exten[0] = '\0';
@@ -5957,8 +5835,7 @@ static void *ss_thread(void *data)
}
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
@@ -5976,8 +5853,7 @@ static void *ss_thread(void *data)
ast_hangup(chan);
return NULL;
} else if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hung up before digits finished\n");
+ ast_debug(1, "Got hung up before digits finished\n");
ast_hangup(chan);
return NULL;
}
@@ -6134,8 +6010,7 @@ static void *ss_thread(void *data)
res = ast_waitfordigit(chan, timeout);
timeout = 0;
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
res = tone_zone_play_tone(p->subs[index].zfd, -1);
ast_hangup(chan);
return NULL;
@@ -6192,8 +6067,7 @@ static void *ss_thread(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ ast_debug(1, "not enough digits (and no ambiguous match)...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
ast_hangup(chan);
@@ -6229,8 +6103,7 @@ static void *ss_thread(void *data)
}
zt_enable_ec(p);
if (ast_pickup_call(chan)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
+ ast_debug(1, "No call pickup possible...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
}
@@ -6382,8 +6255,7 @@ static void *ss_thread(void *data)
}
} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
((exten[0] != '*') || (strlen(exten) > 2))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+ ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
break;
}
if (!timeout)
@@ -6418,8 +6290,7 @@ static void *ss_thread(void *data)
res = 0;
ast_frfree(f);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got ring!\n");
+ ast_debug(1, "Got ring!\n");
res = 0;
break;
}
@@ -6439,8 +6310,7 @@ static void *ss_thread(void *data)
else if (smdi_msg->type == 'N')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u");
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name);
+ ast_debug(1, "Recieved SMDI message on %s\n", chan->name);
} else {
ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n");
}
@@ -6457,9 +6327,8 @@ static void *ss_thread(void *data)
if (p->cid_signalling == CID_SIG_DTMF) {
int i = 0;
cs = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Receiving DTMF cid on "
- "channel %s\n", chan->name);
+ ast_debug(1, "Receiving DTMF cid on "
+ "channel %s\n", chan->name);
zt_setlinear(p->subs[index].zfd, 0);
res = 2000;
for (;;) {
@@ -6474,8 +6343,7 @@ static void *ss_thread(void *data)
f = ast_read(chan);
if (f->frametype == AST_FRAME_DTMF) {
dtmfbuf[i++] = f->subclass;
- if (option_debug)
- ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass);
+ ast_debug(1, "CID got digit '%c'\n", f->subclass);
res = 2000;
}
ast_frfree(f);
@@ -6486,12 +6354,10 @@ static void *ss_thread(void *data)
dtmfbuf[i] = '\0';
zt_setlinear(p->subs[index].zfd, p->subs[index].linear);
/* Got cid and ring. */
- if (option_debug)
- ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf);
+ ast_debug(1, "CID got string '%s'\n", dtmfbuf);
callerid_get_dtmf(dtmfbuf, dtmfcid, &flags);
- if (option_debug)
- ast_log(LOG_DEBUG, "CID is '%s', flags %d\n",
- dtmfcid, flags);
+ ast_debug(1, "CID is '%s', flags %d\n",
+ dtmfcid, flags);
/* If first byte is NULL, we have no cid */
if (!ast_strlen_zero(dtmfcid))
number = dtmfcid;
@@ -6777,8 +6643,7 @@ static void *ss_thread(void *data)
}
if (res == 1) {
callerid_get(cs, &name, &number, &flags);
- if (option_debug)
- ast_log(LOG_DEBUG, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
+ ast_debug(1, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
}
if (distinctiveringaftercid == 1) {
/* Clear the current ring data array so we dont have old data in it. */
@@ -7151,8 +7016,7 @@ static void *do_monitor(void *data)
ast_log(LOG_WARNING, "Unable to set cancel type to asynchronous\n");
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor starting...\n");
+ ast_debug(1, "Monitor starting...\n");
#endif
for (;;) {
/* Lock the interface list */
@@ -7218,8 +7082,7 @@ static void *do_monitor(void *data)
res = has_voicemail(last);
if (last->msgstate != res) {
int x;
- if (option_debug)
- ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
+ ast_debug(1, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
x = ZT_FLUSH_BOTH;
res2 = ioctl(last->subs[SUB_REAL].zfd, ZT_FLUSH, &x);
if (res2)
@@ -7246,8 +7109,7 @@ static void *do_monitor(void *data)
res = zt_get_event(i->subs[SUB_REAL].zfd);
if (res)
{
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
@@ -7292,8 +7154,7 @@ static void *do_monitor(void *data)
} else {
ast_log(LOG_WARNING, "Read failed with %d: %s\n", res, strerror(errno));
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events -- race with chlock */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
@@ -7309,8 +7170,7 @@ static void *do_monitor(void *data)
continue;
}
res = zt_get_event(i->subs[SUB_REAL].zfd);
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
@@ -8073,8 +7933,7 @@ static inline int available(struct zt_pvt *p, int channelmatch, int groupmatch,
return 1;
#endif
} else if (par.rxisoffhook) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel);
+ ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
/* Not available when the other end is off hook */
return 0;
}
@@ -8158,9 +8017,8 @@ static int pri_find_empty_chan(struct zt_pri *pri, int backwards)
if (!backwards && (x >= pri->numchans))
break;
if (pri->pvts[x] && !pri->pvts[x]->inalarm && !pri->pvts[x]->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n",
- pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
+ ast_debug(1, "Found empty available channel %d/%d\n",
+ pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
return x;
}
if (backwards)
@@ -8289,10 +8147,9 @@ static struct ast_channel *zt_request(const char *type, int format, void *data,
#endif
if (p && available(p, channelmatch, groupmatch, &busy, &channelmatched, &groupmatched)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using channel %d\n", p->channel);
- if (p->inalarm)
- goto next;
+ ast_debug(1, "Using channel %d\n", p->channel);
+ if (p->inalarm)
+ goto next;
callwait = (p->owner != NULL);
#ifdef HAVE_PRI
@@ -8312,10 +8169,9 @@ static struct ast_channel *zt_request(const char *type, int format, void *data,
ast_log(LOG_NOTICE, "Failed to allocate place holder pseudo channel!\n");
p = NULL;
break;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n");
- }
+ } else
+ ast_debug(1, "Allocated placeholder pseudo channel\n");
+
p->pri = pri;
}
}
@@ -8563,13 +8419,13 @@ static void *ss7_linkset(void *data)
}
switch (x) {
case ZT_EVENT_OVERRUN:
- ast_log(LOG_DEBUG, "Overrun detected!\n");
+ ast_debug(1, "Overrun detected!\n");
break;
case ZT_EVENT_BADFCS:
- ast_log(LOG_DEBUG, "Bad FCS\n");
+ ast_debug(1, "Bad FCS\n");
break;
case ZT_EVENT_ABORT:
- ast_log(LOG_DEBUG, "HDLC Abort\n");
+ ast_debug(1, "HDLC Abort\n");
break;
case ZT_EVENT_ALARM:
ast_log(LOG_ERROR, "Alarm on link!\n");
@@ -8623,7 +8479,7 @@ static void *ss7_linkset(void *data)
}
break;
case MTP2_LINK_UP:
- ast_log(LOG_DEBUG, "MTP2 link up\n");
+ ast_debug(1, "MTP2 link up\n");
break;
case ISUP_EVENT_CPG:
chanpos = ss7_find_cic(linkset, e->cpg.cic);
@@ -8642,13 +8498,13 @@ static void *ss7_linkset(void *data)
case CPG_EVENT_INBANDINFO:
{
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, };
- ast_log(LOG_DEBUG, "Queuing frame PROGRESS on CIC %d\n", p->cic);
+ ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic);
zap_queue_frame(p, &f, ss7);
p->progress = 1;
}
break;
default:
- ast_log(LOG_DEBUG, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
+ ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
}
ast_mutex_unlock(&p->lock);
@@ -8670,7 +8526,7 @@ static void *ss7_linkset(void *data)
isup_rlc(ss7, e->rsc.call);
break;
case ISUP_EVENT_GRS:
- ast_log(LOG_DEBUG, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
+ ast_debug(1, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
chanpos = ss7_find_cic(linkset, e->grs.startcic);
if (chanpos < 0) {
ast_log(LOG_WARNING, "GRS on unconfigured CIC %d\n", e->grs.startcic);
@@ -8686,7 +8542,7 @@ static void *ss7_linkset(void *data)
ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.status, 1);
break;
case ISUP_EVENT_IAM:
- ast_log(LOG_DEBUG, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num);
+ ast_debug(1, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num);
chanpos = ss7_find_cic(linkset, e->iam.cic);
if (chanpos < 0) {
ast_log(LOG_WARNING, "IAM on unconfigured CIC %d\n", e->iam.cic);
@@ -8743,7 +8599,7 @@ static void *ss7_linkset(void *data)
} else
ss7_start_call(p, linkset);
} else {
- ast_log(LOG_DEBUG, "Call on CIC for unconfigured extension %s\n", p->exten);
+ ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten);
isup_rel(ss7, e->iam.call, -1);
}
ast_mutex_unlock(&p->lock);
@@ -8791,7 +8647,7 @@ static void *ss7_linkset(void *data)
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
+ ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
ast_mutex_lock(&p->lock);
zap_queue_frame(p, &f, linkset);
@@ -8827,7 +8683,7 @@ static void *ss7_linkset(void *data)
break;
}
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Blocking CIC %d\n", e->blo.cic);
+ ast_debug(1, "Blocking CIC %d\n", e->blo.cic);
ast_mutex_lock(&p->lock);
p->remotelyblocked = 1;
ast_mutex_unlock(&p->lock);
@@ -8840,7 +8696,7 @@ static void *ss7_linkset(void *data)
break;
}
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Unblocking CIC %d\n", e->ubl.cic);
+ ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic);
ast_mutex_lock(&p->lock);
p->remotelyblocked = 0;
ast_mutex_unlock(&p->lock);
@@ -8879,7 +8735,7 @@ static void *ss7_linkset(void *data)
}
break;
default:
- ast_log(LOG_DEBUG, "Unknown event %s\n", ss7_event2str(e->e));
+ ast_debug(1, "Unknown event %s\n", ss7_event2str(e->e));
break;
}
}
@@ -9024,10 +8880,9 @@ static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
zt_close(crv->subs[SUB_REAL].zfd);
pri->pvts[principle]->call = crv->call;
pri_assign_bearer(crv, pri, pri->pvts[principle]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Assigning bearer %d/%d to CRV %d:%d\n",
- pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset,
- pri->trunkgroup, crv->channel);
+ ast_debug(1, "Assigning bearer %d/%d to CRV %d:%d\n",
+ pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset,
+ pri->trunkgroup, crv->channel);
wakeup_sub(crv, SUB_REAL, pri);
}
return principle;
@@ -9456,8 +9311,7 @@ static void *pri_dchannel(void *vpri)
pri_restart(pri->dchans[which]);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
+ ast_debug(1, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
} else if (fds[which].revents & POLLIN) {
e = pri_check_event(pri->dchans[which]);
}
@@ -9644,7 +9498,7 @@ static void *pri_dchannel(void *vpri)
break;
} else {
/* This is where we handle initial glare */
- ast_log(LOG_DEBUG, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n",
+ ast_debug(1, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n",
PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
chanpos = -1;
@@ -9767,8 +9621,7 @@ static void *pri_dchannel(void *vpri)
pri_assign_bearer(crv, pri, pri->pvts[chanpos]);
c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
pri->pvts[chanpos]->owner = &inuse;
- if (option_debug)
- ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
+ ast_debug(1, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
} else {
c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
}
@@ -9877,10 +9730,9 @@ static void *pri_dchannel(void *vpri)
zt_enable_ec(pri->pvts[chanpos]);
pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
pri->pvts[chanpos]->alerting = 1;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
- }
+ } else
+ ast_debug(1, "Deferring ringing notification because of extra digits to dial...\n");
+
#ifdef PRI_PROGRESS_MASK
if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) {
#else
@@ -9932,9 +9784,8 @@ static void *pri_dchannel(void *vpri)
}
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
+ ast_debug(1, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
@@ -9959,9 +9810,8 @@ static void *pri_dchannel(void *vpri)
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
+ ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
@@ -10025,8 +9875,7 @@ static void *pri_dchannel(void *vpri)
pri->pvts[chanpos]->dsp_features = 0;
}
if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n");
+ ast_debug(1, "Starting up GR-303 trunk now that we got CONNECT...\n");
x = ZT_START;
res = ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_HOOK, &x);
if (res < 0) {
@@ -10041,14 +9890,12 @@ static void *pri_dchannel(void *vpri)
if (res < 0) {
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", pri->pvts[chanpos]->channel);
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
+
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
} else if (pri->pvts[chanpos]->confirmanswer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
+ ast_debug(1, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
} else {
pri->pvts[chanpos]->subs[SUB_REAL].needanswer =1;
/* Enable echo cancellation if it's not on already */
@@ -10230,9 +10077,8 @@ static void *pri_dchannel(void *vpri)
if (pri->pvts[x] && pri->pvts[x]->resetting) {
chanpos = x;
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan,
- pri->pvts[chanpos]->prioffset, pri->span);
+ ast_debug(1, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan,
+ pri->pvts[chanpos]->prioffset, pri->span);
if (pri->pvts[chanpos]->realcall)
pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
else if (pri->pvts[chanpos]->owner) {
@@ -10287,8 +10133,7 @@ static void *pri_dchannel(void *vpri)
pri->pvts[chanpos]->setup_ack = 1;
/* Send any queued digits */
for (x = 0;x < strlen(pri->pvts[chanpos]->dialdest); x++) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
+ ast_debug(1, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
pri_information(pri->pri, pri->pvts[chanpos]->call,
pri->pvts[chanpos]->dialdest[x]);
}
@@ -10319,8 +10164,7 @@ static void *pri_dchannel(void *vpri)
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Event: %d\n", e->e);
+ ast_debug(1, "Event: %d\n", e->e);
}
}
ast_mutex_unlock(&pri->lock);
@@ -10744,13 +10588,11 @@ static int zap_restart(void)
if (option_verbose > 0)
ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading zaptel configuration.\n");
while (iflist) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying zaptel channel no. %d\n", iflist->channel);
+ ast_debug(1, "Destroying zaptel channel no. %d\n", iflist->channel);
/* Also updates iflist: */
destroy_channel(NULL, iflist, 1);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n");
+ ast_debug(1, "Channels destroyed. Now re-reading config.\n");
if (setup_zap(1) != 0) {
ast_log(LOG_WARNING, "Reload channels from zap config failed!\n");
return 1;
@@ -12916,16 +12758,14 @@ static int zt_sendtext(struct ast_channel *c, const char *text)
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
continue;
}
/* if got exception */
if (fds[0].revents & POLLPRI)
return -1;
if (!(fds[0].revents & POLLOUT)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ ast_debug(1, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
@@ -12934,8 +12774,7 @@ static int zt_sendtext(struct ast_channel *c, const char *text)
ast_free(mybuf);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index 31016b2ad..4c5727967 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -249,12 +249,12 @@ int iax_provision_version(unsigned int *version, const char *template, int force
if (sscanf(tmp, "v%x", version) != 1) {
if (strcmp(tmp, "u")) {
ret = iax_provision_build(&ied, version, template, force);
- if (ret && option_debug)
- ast_log(LOG_DEBUG, "Unable to create provisioning packet for '%s'\n", template);
+ if (ret)
+ ast_debug(1, "Unable to create provisioning packet for '%s'\n", template);
} else
ret = -1;
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
+ } else
+ ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
ast_mutex_unlock(&provlock);
return ret;
}