[asterisk-commits] oej: trunk r93167 - /trunk/pbx/pbx_dundi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Dec 16 07:38:25 CST 2007
Author: oej
Date: Sun Dec 16 07:38:25 2007
New Revision: 93167
URL: http://svn.digium.com/view/asterisk?view=rev&rev=93167
Log:
Convert from LOG_DEBUG etc to ast_debug. Thanks, dimas!
(closes issue #11572)
Reported by: dimas
Patches:
dundilog-trunk.patch uploaded by dimas (license 88)
Modified:
trunk/pbx/pbx_dundi.c
Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=93167&r1=93166&r2=93167
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Sun Dec 16 07:38:25 2007
@@ -399,10 +399,8 @@
if (ioctl(s, SIOCGIFHWADDR, &ifr))
continue;
memcpy(&global_eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(global_eid));
- if (option_debug) {
- ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n",
+ ast_debug(1, "Seeding global EID '%s' from '%s'\n",
dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name);
- }
close(s);
return;
}
@@ -420,8 +418,7 @@
memcpy(
&(global_eid.eid),
sdp->sdl_data + sdp->sdl_nlen, 6);
- if (option_debug)
- ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name);
+ ast_debug(1, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name);
freeifaddrs(ifap);
return;
}
@@ -611,8 +608,7 @@
int max = 999999;
int expiration = dundi_cache_time;
- if (option_debug)
- ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
+ ast_debug(1, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
memset(&ied, 0, sizeof(ied));
memset(&dr, 0, sizeof(dr));
@@ -644,8 +640,7 @@
if (!ast_test_flag_nonstd(&hmd, DUNDI_HINT_DONT_ASK))
hmd.exten[0] = '\0';
if (ast_test_flag(st->trans, FLAG_DEAD)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ ast_debug(1, "Our transaction went away!\n");
st->trans->thread = 0;
destroy_trans(st->trans, 0);
} else {
@@ -672,9 +667,8 @@
struct dundi_hint_metadata hmd;
char eid_str[20];
- if (option_debug)
- ast_log(LOG_DEBUG, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context,
- st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
+ ast_debug(1, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context,
+ st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
memset(&ied, 0, sizeof(ied));
/* Now produce precache */
@@ -685,8 +679,7 @@
if (!ast_test_flag_nonstd(&hmd, DUNDI_HINT_DONT_ASK))
hmd.exten[0] = '\0';
if (ast_test_flag(st->trans, FLAG_DEAD)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ ast_debug(1, "Our transaction went away!\n");
st->trans->thread = 0;
destroy_trans(st->trans, 0);
} else {
@@ -709,16 +702,14 @@
char eid_str[20];
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
- st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
+ ast_debug(1, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
+ st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
memset(&ied, 0, sizeof(ied));
memset(&dei, 0, sizeof(dei));
memset(&hmd, 0, sizeof(hmd));
if (!dundi_eid_cmp(&st->trans->us_eid, &st->reqeid)) {
/* Ooh, it's us! */
- if (option_debug)
- ast_log(LOG_DEBUG, "Neat, someone look for us!\n");
+ ast_debug(1, "Neat, someone look for us!\n");
ast_copy_string(dei.orgunit, dept, sizeof(dei.orgunit));
ast_copy_string(dei.org, org, sizeof(dei.org));
ast_copy_string(dei.locality, locality, sizeof(dei.locality));
@@ -733,8 +724,7 @@
}
AST_LIST_LOCK(&peers);
if (ast_test_flag(st->trans, FLAG_DEAD)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ ast_debug(1, "Our transaction went away!\n");
st->trans->thread = 0;
destroy_trans(st->trans, 0);
} else {
@@ -792,8 +782,7 @@
*st->eids[x-skipfirst] = *ies->eids[x];
s += sizeof(dundi_eid);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context);
+ ast_debug(1, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context);
trans->thread = 1;
if (ast_pthread_create_detached(&lookupthread, NULL, dundi_query_thread, st)) {
@@ -843,11 +832,9 @@
snprintf(data, sizeof(data), "%ld|", (long)(timeout));
ast_db_put("dundi/cache", key1, data);
- if (option_debug)
- ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key1);
+ ast_debug(1, "Caching hint at '%s'\n", key1);
ast_db_put("dundi/cache", key2, data);
- if (option_debug)
- ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key2);
+ ast_debug(1, "Caching hint at '%s'\n", key2);
return 0;
}
@@ -1018,8 +1005,7 @@
}
}
st->nummaps = mapcount;
- if (option_debug)
- ast_log(LOG_DEBUG, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context);
+ ast_debug(1, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context);
trans->thread = 1;
if (ast_pthread_create_detached(&lookupthread, NULL, dundi_precache_thread, st)) {
trans->thread = 0;
@@ -1102,8 +1088,7 @@
}
}
st->nummaps = mapcount;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context);
+ ast_debug(1, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context);
trans->thread = 1;
if (ast_pthread_create_detached(&lookupthread, NULL, dundi_lookup_thread, st)) {
trans->thread = 0;
@@ -1142,8 +1127,7 @@
if (!ast_get_time_t(ptr, &timeout, 0, &length)) {
int expiration = timeout - now;
if (expiration > 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", expiration);
+ ast_debug(1, "Found cache expiring in %d seconds!\n", expiration);
ptr += length + 1;
while((sscanf(ptr, "%d/%d/%d/%n", &(flags.flags), &weight, &tech, &length) == 3)) {
ptr += length;
@@ -1156,9 +1140,8 @@
src++;
} else
src = "";
- if (option_debug)
- ast_log(LOG_DEBUG, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n",
- tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full);
+ ast_debug(1, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n",
+ tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full);
/* Make sure it's not already there */
for (z=0;z<req->respcount;z++) {
if ((req->dr[z].techint == tech) &&
@@ -1279,8 +1262,7 @@
{
struct dundi_peer *peer = (struct dundi_peer *)data;
char eid_str[20];
- if (option_debug)
- ast_log(LOG_DEBUG, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+ ast_debug(1, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
peer->registerexpire = -1;
peer->lastms = 0;
memset(&peer->addr, 0, sizeof(peer->addr));
@@ -1374,8 +1356,7 @@
*h = *ohdr;
bytes = space - 6;
if (uncompress(dst + 6, &bytes, decrypt_space, srclen) != Z_OK) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ouch, uncompress failed :(\n");
+ ast_debug(1, "Ouch, uncompress failed :(\n");
return NULL;
}
/* Update length */
@@ -1401,8 +1382,7 @@
bytes = len;
res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6);
if (res != Z_OK) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ouch, compression failed!\n");
+ ast_debug(1, "Ouch, compression failed!\n");
return -1;
}
memset(&ied, 0, sizeof(ied));
@@ -1458,8 +1438,7 @@
int res;
struct ast_key *key, *skey;
char eid_str[20];
- if (option_debug)
- ast_log(LOG_DEBUG, "Expected '%08lx' got '%08lx'\n", peer->them_keycrc32, keycrc32);
+ ast_debug(1, "Expected '%08lx' got '%08lx'\n", peer->them_keycrc32, keycrc32);
if (peer->them_keycrc32 && (peer->them_keycrc32 == keycrc32)) {
/* A match */
return 1;
@@ -1497,8 +1476,7 @@
return 0;
}
/* Decrypted, passes signature */
- if (option_debug)
- ast_log(LOG_DEBUG, "Wow, new key combo passed signature and decrypt!\n");
+ ast_debug(1, "Wow, new key combo passed signature and decrypt!\n");
memcpy(peer->rxenckey, newkey, 128);
memcpy(peer->rxenckey + 128, newsig, 128);
peer->them_keycrc32 = crc32(0L, peer->rxenckey, 128);
@@ -1560,8 +1538,7 @@
return -1;
/* Make a copy for parsing */
memcpy(bufcpy, hdr->ies, datalen);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : "");
+ ast_debug(1, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : "");
if (dundi_parse_ies(&ies, bufcpy, datalen) < 0) {
ast_log(LOG_WARNING, "Failed to parse DUNDI information elements!\n");
return -1;
@@ -1690,8 +1667,7 @@
/* A dialplan response, lets see what we got... */
if (ies.cause < 1) {
/* Success of some sort */
- if (option_debug)
- ast_log(LOG_DEBUG, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount);
+ ast_debug(1, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount);
if (ast_test_flag(trans, FLAG_ENCRYPT)) {
authpass = encrypted;
} else
@@ -1775,8 +1751,7 @@
/* A dialplan response, lets see what we got... */
if (ies.cause < 1) {
/* Success of some sort */
- if (option_debug)
- ast_log(LOG_DEBUG, "Looks like success of some sort (%d)\n", ies.cause);
+ ast_debug(1, "Looks like success of some sort (%d)\n", ies.cause);
if (ast_test_flag(trans, FLAG_ENCRYPT)) {
authpass = encrypted;
} else
@@ -1842,9 +1817,8 @@
dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, &ied);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid),
- dundi_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid));
+ ast_debug(1, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid),
+ dundi_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid));
/* Close connection if not final */
if (!final)
dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL);
@@ -1927,8 +1901,7 @@
hdr->cmdresp |= dhdr->cmdresp & 0x80;
break;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ouch, decrypt failed :(\n");
+ ast_debug(1, "Ouch, decrypt failed :(\n");
}
}
}
@@ -2021,8 +1994,7 @@
dundi_ack(trans, 0);
} else {
/* Out of window -- simply drop */
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping packet out of window!\n");
+ ast_debug(1, "Dropping packet out of window!\n");
}
return 0;
}
@@ -3280,8 +3252,7 @@
AST_LIST_TRAVERSE_SAFE_BEGIN(&dr->trans, trans, parentlist) {
trans->thread = 0;
if (ast_test_flag(trans, FLAG_DEAD)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ ast_debug(1, "Our transaction went away!\n");
/* This is going to remove the transaction from the dundi_request's list, as well
* as the global transactions list */
destroy_trans(trans, 0);
@@ -3375,12 +3346,10 @@
if (p->maxms && ((p->lastms < 0) || (p->lastms >= p->maxms)))
return 0;
- if (option_debug) {
- if (ast_strlen_zero(dr->number))
- ast_log(LOG_DEBUG, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext);
- else
- ast_log(LOG_DEBUG, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext);
- }
+ if (ast_strlen_zero(dr->number))
+ ast_debug(1, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext);
+ else
+ ast_debug(1, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext);
trans = create_transaction(p);
if (!trans)
@@ -3467,8 +3436,7 @@
/* Check for a matching or 0 cache entry */
append_transaction(dr, p, ttl, avoid);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Avoiding '%s' in transaction\n", dundi_eid_to_str(eid_str, sizeof(eid_str), avoid[x]));
+ ast_debug(1, "Avoiding '%s' in transaction\n", dundi_eid_to_str(eid_str, sizeof(eid_str), avoid[x]));
}
}
}
@@ -3487,24 +3455,21 @@
char eid_str[20];
AST_LIST_LOCK(&peers);
AST_LIST_TRAVERSE(&requests, cur, list) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking '%s@%s' vs '%s@%s'\n", cur->dcontext, cur->number,
- dr->dcontext, dr->number);
+ ast_debug(1, "Checking '%s@%s' vs '%s@%s'\n", cur->dcontext, cur->number,
+ dr->dcontext, dr->number);
if (!strcasecmp(cur->dcontext, dr->dcontext) &&
!strcasecmp(cur->number, dr->number) &&
(!dundi_eid_cmp(&cur->root_eid, &dr->root_eid) || (cur->crc32 == dr->crc32))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found existing query for '%s@%s' for '%s' crc '%08lx'\n",
- cur->dcontext, cur->number, dundi_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
+ ast_debug(1, "Found existing query for '%s@%s' for '%s' crc '%08lx'\n",
+ cur->dcontext, cur->number, dundi_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
*pending = cur;
res = 1;
break;
}
}
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n",
- dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
+ ast_debug(1, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n",
+ dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
/* Go ahead and link us in since nobody else is searching for this */
AST_LIST_INSERT_HEAD(&requests, dr, list);
*pending = NULL;
@@ -3593,17 +3558,15 @@
if (rooteid && !dundi_eid_cmp(&dr.root_eid, &pending->root_eid)) {
/* This is on behalf of someone else. Go ahead and close this out since
they'll get their answer anyway. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, duplicate request for '%s@%s' for '%s'\n",
- dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid));
+ ast_debug(1, "Oooh, duplicate request for '%s@%s' for '%s'\n",
+ dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid));
close(dr.pfds[0]);
close(dr.pfds[1]);
return -2;
} else {
/* Wait for the cache to populate */
- if (option_debug)
- ast_log(LOG_DEBUG, "Waiting for similar request for '%s@%s' for '%s'\n",
- dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid));
+ ast_debug(1, "Waiting for similar request for '%s@%s' for '%s'\n",
+ dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid));
start = ast_tvnow();
while(check_request(pending) && (ast_tvdiff_ms(ast_tvnow(), start) < ttlms) && (!chan || !ast_check_hangup(chan))) {
/* XXX Would be nice to have a way to poll/select here XXX */
@@ -3642,8 +3605,8 @@
ms = 100;
ast_waitfor_n_fd(dr.pfds, 1, &ms, NULL);
}
- if (chan && ast_check_hangup(chan) && option_debug)
- ast_log(LOG_DEBUG, "Hrm, '%s' hungup before their query for %s@%s finished\n", chan->name, dr.number, dr.dcontext);
+ if (chan && ast_check_hangup(chan))
+ ast_debug(1, "Hrm, '%s' hungup before their query for %s@%s finished\n", chan->name, dr.number, dr.dcontext);
cancel_request(&dr);
unregister_request(&dr);
res = dr.respcount;
@@ -3736,8 +3699,7 @@
int foundcache, skipped, ttlms, ms;
if (!context)
context = "e164";
- if (option_debug)
- ast_log(LOG_DEBUG, "Precache internal (%s@%s)!\n", number, context);
+ ast_debug(1, "Precache internal (%s@%s)!\n", number, context);
AST_LIST_LOCK(&peers);
AST_LIST_TRAVERSE(&mappings, cur, list) {
@@ -4295,8 +4257,7 @@
struct dundi_peer *peer = (struct dundi_peer *)data;
char eid_str[20];
char eid_str2[20];
- if (option_debug)
- ast_log(LOG_DEBUG, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid));
+ ast_debug(1, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid));
peer->registerid = ast_sched_add(sched, default_expiration * 1000, do_register, data);
/* Destroy old transaction if there is one */
if (peer->regtrans)
More information about the asterisk-commits
mailing list