[asterisk-commits] branch russell/config-macros - r7300
/team/russell/config-macros/channels/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Dec 2 19:25:38 CST 2005
Author: russell
Date: Fri Dec 2 19:25:36 2005
New Revision: 7300
URL: http://svn.digium.com/view/asterisk?rev=7300&view=rev
Log:
add 'sip debug' options to global_flags_page2
Modified:
team/russell/config-macros/channels/chan_sip.c
Modified: team/russell/config-macros/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/config-macros/channels/chan_sip.c?rev=7300&r1=7299&r2=7300&view=diff
==============================================================================
--- team/russell/config-macros/channels/chan_sip.c (original)
+++ team/russell/config-macros/channels/chan_sip.c Fri Dec 2 19:25:36 2005
@@ -409,9 +409,6 @@
static struct sockaddr_in outboundproxyip;
static int ourport;
-#define SIP_DEBUG_CONFIG 1 << 0
-#define SIP_DEBUG_CONSOLE 1 << 1
-static int sipdebug = 0;
static struct sockaddr_in debugaddr;
static int tos = 0;
@@ -572,10 +569,17 @@
#define SIP_PAGE2_RTAUTOCLEAR (1 << 2)
#define SIP_PAGE2_IGNOREREGEXPIRE (1 << 3)
#define SIP_PAGE2_RT_FROMCONTACT (1 << 4)
+#define SIP_PAGE2_DEBUG (3 << 5)
+#define SIP_PAGE2_DEBUG_CONFIG (1 << 5)
+#define SIP_PAGE2_DEBUG_CONSOLE (1 << 6)
/* SIP packet flags */
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
#define SIP_PKT_WITH_TOTAG (1 << 1) /*!< This packet has a to-tag */
+
+#define SIP_DEBUG ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG)
+#define SIP_DEBUG_CONFIG ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONFIG)
+#define SIP_DEBUG_CONSOLE ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE)
#ifdef OSP_SUPPORT
#define OSP_ALLOWGUEST_OPTION AST_CONFIG_VAL_CUSTOM("osp", global_allowguest = 2)
@@ -1048,7 +1052,7 @@
if (ast_strlen_zero(supported) )
return 0;
- if (option_debug > 2 && sipdebug)
+ if (option_debug > 2 && SIP_DEBUG)
ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
next = temp;
@@ -1060,18 +1064,18 @@
}
while (*next == ' ') /* Skip spaces */
next++;
- if (option_debug > 2 && sipdebug)
+ if (option_debug > 2 && SIP_DEBUG)
ast_log(LOG_DEBUG, "Found SIP option: -%s-\n", next);
for (i=0; (i < (sizeof(sip_options) / sizeof(sip_options[0]))) && !res; i++) {
if (!strcasecmp(next, sip_options[i].text)) {
profile |= sip_options[i].id;
res = 1;
- if (option_debug > 2 && sipdebug)
+ if (option_debug > 2 && SIP_DEBUG)
ast_log(LOG_DEBUG, "Matched SIP option: %s\n", next);
}
}
if (!res)
- if (option_debug > 2 && sipdebug)
+ if (option_debug > 2 && SIP_DEBUG)
ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
next = sep;
}
@@ -1086,7 +1090,7 @@
/*! \brief sip_debug_test_addr: See if we pass debug IP filter */
static inline int sip_debug_test_addr(struct sockaddr_in *addr)
{
- if (sipdebug == 0)
+ if (!SIP_DEBUG)
return 0;
if (debugaddr.sin_addr.s_addr) {
if (((ntohs(debugaddr.sin_port) != 0)
@@ -1100,7 +1104,7 @@
/*! \brief sip_debug_test_pvt: Test PVT for debugging output */
static inline int sip_debug_test_pvt(struct sip_pvt *p)
{
- if (sipdebug == 0)
+ if (!SIP_DEBUG)
return 0;
return sip_debug_test_addr(((ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE) ? &p->recv : &p->sa));
}
@@ -1223,12 +1227,12 @@
pkt->retrans++;
if (!pkt->timer_t1) { /* Re-schedule using timer_a and timer_t1 */
- if (sipdebug && option_debug > 3)
+ if (SIP_DEBUG && 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);
} else {
int siptimer_a;
- if (sipdebug && option_debug > 3)
+ if (SIP_DEBUG && 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 (!pkt->timer_a)
pkt->timer_a = 2 ;
@@ -1261,10 +1265,8 @@
}
/* Too many retries */
if (pkt->owner && pkt->method != SIP_OPTIONS) {
- if (ast_test_flag(pkt, FLAG_FATAL) || sipdebug) /* Tell us if it's critical or if we're debugging */
- ast_log(LOG_WARNING, "Maximum retries exceeded on transmission %s for seqno %d (%s %s)\n", pkt->owner->callid, pkt->seqno, (ast_test_flag(pkt, FLAG_FATAL)) ? "Critical" : "Non-critical", (ast_test_flag(pkt, FLAG_RESPONSE)) ? "Response" : "Request");
- } else {
- if (pkt->method == SIP_OPTIONS && sipdebug)
+ if (ast_test_flag(pkt, FLAG_FATAL) || SIP_DEBUG) /* Tell us if it's critical or if we're debugging */ ast_log(LOG_WARNING, "Maximum retries exceeded on transmission %s for seqno %d (%s %s)\n", pkt->owner->callid, pkt->seqno, (ast_test_flag(pkt, FLAG_FATAL)) ? "Critical" : "Non-critical", (ast_test_flag(pkt, FLAG_RESPONSE)) ? "Response" : "Request"); } else {
+ if (pkt->method == SIP_OPTIONS && SIP_DEBUG)
ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
}
append_history(pkt->owner, "MaxRetries", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
@@ -1337,7 +1339,7 @@
/* Schedule retransmission */
pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
- if (option_debug > 3 && sipdebug)
+ if (option_debug > 3 && SIP_DEBUG)
ast_log(LOG_DEBUG, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
pkt->next = p->packets;
p->packets = pkt;
@@ -1431,7 +1433,7 @@
else
p->packets = cur->next;
if (cur->retransid > -1) {
- if (sipdebug && option_debug > 3)
+ if (SIP_DEBUG && option_debug > 3)
ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
ast_sched_del(sched, cur->retransid);
}
@@ -1486,7 +1488,7 @@
(!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
/* this is our baby */
if (cur->retransid > -1) {
- if (option_debug > 3 && sipdebug)
+ if (option_debug > 3 && SIP_DEBUG)
ast_log(LOG_DEBUG, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, msg);
ast_sched_del(sched, cur->retransid);
}
@@ -2283,7 +2285,7 @@
} else {
*inuse = 0;
}
- if (option_debug > 1 || sipdebug) {
+ if (option_debug > 1 || SIP_DEBUG) {
ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
}
break;
@@ -2299,7 +2301,7 @@
}
}
(*inuse)++;
- if (option_debug > 1 || sipdebug) {
+ if (option_debug > 1 || SIP_DEBUG) {
ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
}
break;
@@ -2731,12 +2733,12 @@
res = -1;
break;
case AST_CONTROL_HOLD: /* The other part of the bridge are put on hold */
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG, "Bridged channel now on hold%s\n", p->callid);
res = -1;
break;
case AST_CONTROL_UNHOLD: /* The other part of the bridge are back from hold */
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG, "Bridged channel is back from hold, let's talk! : %s\n", p->callid);
res = -1;
break;
@@ -3368,7 +3370,7 @@
/* We've got a new header */
*c = 0;
- if (sipdebug && option_debug > 3)
+ if (SIP_DEBUG && option_debug > 3)
ast_log(LOG_DEBUG, "Header %d: %s (%d)\n", f, req->header[f], (int) strlen(req->header[f]));
if (ast_strlen_zero(req->header[f])) {
/* Line by itself means we're now in content */
@@ -3388,7 +3390,7 @@
}
/* Check for last header */
if (!ast_strlen_zero(req->header[f])) {
- if (sipdebug && option_debug > 3)
+ if (SIP_DEBUG && option_debug > 3)
ast_log(LOG_DEBUG, "Header %d: %s (%d)\n", f, req->header[f], (int) strlen(req->header[f]));
f++;
}
@@ -3400,7 +3402,7 @@
if (*c == '\n') {
/* We've got a new line */
*c = 0;
- if (sipdebug && option_debug > 3)
+ if (SIP_DEBUG && option_debug > 3)
ast_log(LOG_DEBUG, "Line: %s (%d)\n", req->line[f], (int) strlen(req->line[f]));
if (f >= SIP_MAX_LINES - 1) {
ast_log(LOG_WARNING, "Too many SDP lines. Ignoring.\n");
@@ -4633,7 +4635,7 @@
reqprep(&req, p, SIP_INVITE, 0, 1);
add_header(&req, "Allow", ALLOWED_METHODS);
- if (sipdebug)
+ if (SIP_DEBUG)
add_header(&req, "X-asterisk-info", "SIP re-invite (RTP bridge)");
ast_rtp_offered_from_local(p->rtp, 1);
add_sdp(&req, p);
@@ -4967,7 +4969,7 @@
*end = '\0';
add_header(&req, headdup, content);
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
}
}
@@ -5288,7 +5290,7 @@
}
/* Since registry's are only added/removed by the the monitor thread, this
may be overkill to reference/dereference at all here */
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_NOTICE, " -- Re-registration for %s@%s\n", r->username, r->hostname);
r->expire = -1;
@@ -5502,7 +5504,7 @@
char digest[1024];
/* We have auth data to reuse, build a digest header! */
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
ast_copy_string(p->realm, r->realm, sizeof(p->realm));
ast_copy_string(p->nonce, r->nonce, sizeof(p->nonce));
@@ -6326,13 +6328,13 @@
snprintf(randdata, randlen, "%08x", thread_safe_rand());
if (ua_hash && !strncasecmp(ua_hash, resp_hash, strlen(resp_hash))) {
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_NOTICE, "stale nonce received from '%s'\n", get_header(req, "To"));
/* We got working auth token, based on stale nonce . */
transmit_response_with_auth(p, response, req, randdata, reliable, respheader, 1);
} else {
/* Everything was wrong, so give the device one more try with a new challenge */
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_NOTICE, "Bad authentication received from '%s'\n", get_header(req, "To"));
transmit_response_with_auth(p, response, req, randdata, reliable, respheader, 0);
}
@@ -8671,7 +8673,7 @@
/* send a FLASH event */
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH, };
ast_queue_frame(p->owner, &f);
- if (sipdebug)
+ if (SIP_DEBUG)
ast_verbose("* DTMF-relay event received: FLASH\n");
} else {
/* send a DTMF event */
@@ -8686,7 +8688,7 @@
f.subclass = 'A' + (event - 12);
}
ast_queue_frame(p->owner, &f);
- if (sipdebug)
+ if (SIP_DEBUG)
ast_verbose("* DTMF-relay event received: %c\n", f.subclass);
}
transmit_response(p, "200 OK", req);
@@ -8747,7 +8749,9 @@
ast_cli(fd, "SIP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr));
else
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), port);
- sipdebug |= SIP_DEBUG_CONSOLE;
+
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE);
+
return RESULT_SUCCESS;
}
@@ -8765,7 +8769,7 @@
memcpy(&debugaddr.sin_addr, &peer->addr.sin_addr, sizeof(debugaddr.sin_addr));
debugaddr.sin_port = peer->addr.sin_port;
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), ntohs(debugaddr.sin_port));
- sipdebug |= SIP_DEBUG_CONSOLE;
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE);
} else
ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]);
ASTOBJ_UNREF(peer,sip_destroy_peer);
@@ -8777,7 +8781,7 @@
/*! \brief sip_do_debug: Turn on SIP debugging (CLI command) */
static int sip_do_debug(int fd, int argc, char *argv[])
{
- int oldsipdebug = sipdebug & SIP_DEBUG_CONSOLE;
+ int oldsipdebug = SIP_DEBUG_CONSOLE;
if (argc != 2) {
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -8787,7 +8791,7 @@
return sip_do_debug_peer(fd, argc, argv);
else return RESULT_SHOWUSAGE;
}
- sipdebug |= SIP_DEBUG_CONSOLE;
+ ast_set_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE);
memset(&debugaddr, 0, sizeof(debugaddr));
if (oldsipdebug)
ast_cli(fd, "SIP Debugging re-enabled\n");
@@ -8881,7 +8885,7 @@
{
if (argc != 3)
return RESULT_SHOWUSAGE;
- sipdebug &= ~SIP_DEBUG_CONSOLE;
+ ast_clear_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE);
ast_cli(fd, "SIP Debugging Disabled\n");
return RESULT_SUCCESS;
}
@@ -9050,7 +9054,7 @@
username = auth->username;
secret = auth->secret;
md5secret = auth->md5secret;
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG,"Using realm %s authentication for call %s\n", p->realm, p->callid);
} else {
/* No authentication, use peer or register= config */
@@ -9712,7 +9716,7 @@
expires_ms -= MAX((expires_ms * EXPIRY_GUARD_PCT),EXPIRY_GUARD_MIN);
else
expires_ms -= EXPIRY_GUARD_SECS * 1000;
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_NOTICE, "Outbound Registration: Expiry for %s is %d sec (Scheduling reregistration in %d s)\n", r->hostname, expires, expires_ms/1000);
r->refresh= (int) expires_ms / 1000;
@@ -10427,7 +10431,7 @@
}
} else {
- if (option_debug > 1 && sipdebug)
+ if (option_debug > 1 && SIP_DEBUG)
ast_log(LOG_DEBUG, "Got a SIP re-invite for call %s\n", p->callid);
c = p->owner;
}
@@ -10835,7 +10839,7 @@
if (p->expiry > max_expiry)
p->expiry = max_expiry;
}
- if (sipdebug || option_debug > 1)
+ if (SIP_DEBUG || option_debug > 1)
ast_log(LOG_DEBUG, "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 */
@@ -11410,7 +11414,7 @@
return 0;
}
if (peer->call > 0) {
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_NOTICE, "Still have a QUALIFY dialog active, deleting\n");
sip_destroy(peer->call);
}
@@ -11737,7 +11741,7 @@
AST_LIST_INSERT_TAIL(&domain_list, d, list);
AST_LIST_UNLOCK(&domain_list);
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG, "Added local SIP domain '%s'\n", domain);
return 1;
@@ -12421,7 +12425,7 @@
memset(&localaddr, 0, sizeof(localaddr));
memset(&externip, 0, sizeof(externip));
memset(&prefs, 0 , sizeof(prefs));
- sipdebug &= ~SIP_DEBUG_CONFIG;
+ ast_clear_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONFIG);
/* Initialize some reasonable defaults at SIP reload */
ast_copy_string(default_context, DEFAULT_CONTEXT, sizeof(default_context));
@@ -12504,7 +12508,7 @@
AST_CONFIG_INT("maxexpiry", &max_expiry, 1, DEFAULT_MAX_EXPIRY)
AST_CONFIG_INT("defaultexpirey", &default_expiry, 1, DEFAULT_DEFAULT_EXPIRY)
AST_CONFIG_INT("defaultexpiry", &default_expiry, 1, DEFAULT_DEFAULT_EXPIRY)
- AST_CONFIG_CUSTOM("sipdebug", if (ast_true(value)) sipdebug |= SIP_DEBUG_CONFIG)
+ AST_CONFIG_FLAG("sipdebug", &global_flags_page2, SIP_PAGE2_DEBUG_CONFIG)
AST_CONFIG_BOOL("dumphistory", dumphistory)
AST_CONFIG_BOOL("recordhistory", recordhistory)
AST_CONFIG_INT("registertimeout", &global_reg_timeout, 1, DEFAULT_REGISTRATION_TIMEOUT)
@@ -12824,7 +12828,7 @@
}
if (ok) {
pbx_builtin_setvar_helper (chan, varbuf, data);
- if (sipdebug)
+ if (SIP_DEBUG)
ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", (char *) data, varbuf);
} else {
ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n");
More information about the asterisk-commits
mailing list