[asterisk-commits] rizzo: branch rizzo/astobj2 r76212 - /team/rizzo/astobj2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 20 16:40:07 CDT 2007


Author: rizzo
Date: Fri Jul 20 16:40:06 2007
New Revision: 76212

URL: http://svn.digium.com/view/asterisk?view=rev&rev=76212
Log:
more ast_log --> ast_debug replacements, to reduce diff with trunk.

These actually change the original behaviour (e.g.
"option_debug || foo" becomes "option_debug && foo")
but it does not make a lot of difference in practice.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=76212&r1=76211&r2=76212
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Jul 20 16:40:06 2007
@@ -2150,6 +2150,7 @@
 {
 	if (p->outboundproxy)
 		return &p->outboundproxy->ip;
+
 	return ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_ROUTE ? &p->recv : &p->sa;
 }
 
@@ -3705,8 +3706,7 @@
 		/* 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);
+		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:
@@ -3731,8 +3731,8 @@
 		/* 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;
 
@@ -5715,11 +5715,11 @@
 			sin.sin_port = htons(udptlportno);
 			ast_udptl_set_peer(p->udptl, &sin);
 			if (debug) /* XXX really ? */
-				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");
 		}
 	}
 
@@ -5946,7 +5946,7 @@
 			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);
@@ -6031,6 +6031,7 @@
 		if (debug) 
 			ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(vsin.sin_addr), ntohs(vsin.sin_port));
 	}
+
 	/* Setup text port number */
 	if (p->trtp && tsin.sin_port) {
 		ast_rtp_set_peer(p->trtp, &tsin);
@@ -6470,7 +6471,7 @@
 	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)
@@ -6529,9 +6530,10 @@
 		add_header(req, "From", ot);
 		add_header(req, "To", of);
 	}
-	/* Do not add Contact for BYE and Cancel requests */
+	/* Do not add Contact for MESSAGE, BYE and Cancel requests */
 	if (sipmethod != SIP_BYE && sipmethod != SIP_CANCEL && sipmethod != SIP_MESSAGE)
 		add_header(req, "Contact", p->our_contact);
+
 	copy_header(req, orig, "Call-ID");
 	add_header(req, "CSeq", tmp);
 
@@ -6898,13 +6900,13 @@
 	}
 	
 	if (debug)  /* XXX is the message correct ? */
-		ast_log(LOG_DEBUG, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), ntohs(udptlsin.sin_port));
+		ast_debug(1, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), 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);
@@ -7735,7 +7737,7 @@
 						
 							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);
 						}
 					}
 				}
@@ -8260,7 +8262,7 @@
 		 * do not like the old nonce (for good reasons) and challenge us again.
 		 */
 		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);
@@ -8340,8 +8342,8 @@
 	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))  {
@@ -11991,17 +11993,17 @@
 		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);
 }
 
 
@@ -12453,7 +12455,7 @@
  		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 credentials in the dialog
 		 * (coming from user/peer/registration)
@@ -13835,7 +13837,7 @@
 			} else if (sipmethod == SIP_BYE) {
 				set_destroy(p);
 			} 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 */
@@ -14118,7 +14120,7 @@
 			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");
@@ -14126,7 +14128,7 @@
 			ast_softhangup_nolock(transferer->chan1, AST_SOFTHANGUP_DEV);
 		if (target->chan1)
 			ast_softhangup_nolock(target->chan1, AST_SOFTHANGUP_DEV);
-		return -1;
+		return -1;	/* XXX -2 in trunk ? */
 	}
 	return 0;
 }
@@ -14378,6 +14380,7 @@
 
 	/* Answer the incoming call and set channel to UP state */
 	transmit_response_with_sdp(p, "200 OK", req, XMIT_RELIABLE);
+
 	ast_setstate(c, AST_STATE_UP);
 	
 	/* Stop music on hold and other generators */
@@ -15025,22 +15028,20 @@
 
 	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 */
@@ -15807,11 +15808,11 @@
 		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 */
@@ -17038,7 +17039,7 @@
 	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;
 }
@@ -18161,10 +18162,8 @@
 			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.sin_addr));
 		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);
@@ -18414,7 +18413,7 @@
 	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");
 	}




More information about the asterisk-commits mailing list