[asterisk-commits] rmudgett: trunk r313527 - in /trunk: ./ apps/app_dumpchan.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 13 10:23:27 CDT 2011


Author: rmudgett
Date: Wed Apr 13 10:23:23 2011
New Revision: 313527

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=313527
Log:
Merged revisions 313517 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r313517 | rmudgett | 2011-04-12 17:35:53 -0500 (Tue, 12 Apr 2011) | 12 lines
  
  Bring the dumpchan application inline with "core show channel".
  
  * Added fields that are in "core show channel" to dumpchan output.
  
  * Fixed reuse of formatbuf before the previous string stored there was
  used by snprintf.  All output strings now have their own buffer.
  
  * Adjusted the buffer sizes to not be so abusive of the stack now that
  there are more buffers.
  
  Change requested by oej.
........

Modified:
    trunk/   (props changed)
    trunk/apps/app_dumpchan.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/apps/app_dumpchan.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_dumpchan.c?view=diff&rev=313527&r1=313526&r2=313527
==============================================================================
--- trunk/apps/app_dumpchan.c (original)
+++ trunk/apps/app_dumpchan.c Wed Apr 13 10:23:23 2011
@@ -36,6 +36,7 @@
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
+#include "asterisk/translate.h"
 
 /*** DOCUMENTATION
 	<application name="DumpChan" language="en_US">
@@ -67,9 +68,11 @@
 	struct timeval now;
 	long elapsed_seconds = 0;
 	int hour = 0, min = 0, sec = 0;
-	char cgrp[BUFSIZ/2];
-	char pgrp[BUFSIZ/2];
-	char formatbuf[BUFSIZ/2];
+	char nf[256];
+	char cgrp[256];
+	char pgrp[256];
+	struct ast_str *write_transpath = ast_str_alloca(256);
+	struct ast_str *read_transpath = ast_str_alloca(256);
 
 	now = ast_tvnow();
 	memset(buf, 0, size);
@@ -84,65 +87,83 @@
 	}
 
 	snprintf(buf,size,
-			"Name=               %s\n"
-			"Type=               %s\n"
-			"UniqueID=           %s\n"
-			"CallerIDNum=        %s\n"
-			"CallerIDName=       %s\n"
-			"DNIDDigits=         %s\n"
-			"RDNIS=              %s\n"
-			"Parkinglot=         %s\n"
-			"Language=           %s\n"
-			"State=              %s (%d)\n"
-			"Rings=              %d\n"
-			"NativeFormat=       %s\n"
-			"WriteFormat=        %s\n"
-			"ReadFormat=         %s\n"
-			"RawWriteFormat=     %s\n"
-			"RawReadFormat=      %s\n"
-			"1stFileDescriptor=  %d\n"
-			"Framesin=           %d %s\n"
-			"Framesout=          %d %s\n"
-			"TimetoHangup=       %ld\n"
-			"ElapsedTime=        %dh%dm%ds\n"
-			"Context=            %s\n"
-			"Extension=          %s\n"
-			"Priority=           %d\n"
-			"CallGroup=          %s\n"
-			"PickupGroup=        %s\n"
-			"Application=        %s\n"
-			"Data=               %s\n"
-			"Blocking_in=        %s\n",
-			c->name,
-			c->tech->type,
-			c->uniqueid,
-			S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
-			S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
-			S_OR(c->dialed.number.str, "(N/A)"),
-			S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
-			c->parkinglot,
-			c->language,
-			ast_state2str(c->_state),
-			c->_state,
-			c->rings,
-			ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
-			ast_getformatname(&c->writeformat),
-			ast_getformatname(&c->readformat),
-			ast_getformatname(&c->rawwriteformat),
-			ast_getformatname(&c->rawreadformat),
-			c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
-			c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup.tv_sec,
-			hour,
-			min,
-			sec,
-			c->context,
-			c->exten,
-			c->priority,
-			ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
-			ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
-			( c->appl ? c->appl : "(N/A)" ),
-			( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
-			(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
+		"Name=               %s\n"
+		"Type=               %s\n"
+		"UniqueID=           %s\n"
+		"LinkedID=           %s\n"
+		"CallerIDNum=        %s\n"
+		"CallerIDName=       %s\n"
+		"ConnectedLineIDNum= %s\n"
+		"ConnectedLineIDName=%s\n"
+		"DNIDDigits=         %s\n"
+		"RDNIS=              %s\n"
+		"Parkinglot=         %s\n"
+		"Language=           %s\n"
+		"State=              %s (%d)\n"
+		"Rings=              %d\n"
+		"NativeFormat=       %s\n"
+		"WriteFormat=        %s\n"
+		"ReadFormat=         %s\n"
+		"RawWriteFormat=     %s\n"
+		"RawReadFormat=      %s\n"
+		"WriteTranscode=     %s %s\n"
+		"ReadTranscode=      %s %s\n"
+		"1stFileDescriptor=  %d\n"
+		"Framesin=           %d %s\n"
+		"Framesout=          %d %s\n"
+		"TimetoHangup=       %ld\n"
+		"ElapsedTime=        %dh%dm%ds\n"
+		"DirectBridge=       %s\n"
+		"IndirectBridge=     %s\n"
+		"Context=            %s\n"
+		"Extension=          %s\n"
+		"Priority=           %d\n"
+		"CallGroup=          %s\n"
+		"PickupGroup=        %s\n"
+		"Application=        %s\n"
+		"Data=               %s\n"
+		"Blocking_in=        %s\n",
+		c->name,
+		c->tech->type,
+		c->uniqueid,
+		c->linkedid,
+		S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
+		S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
+		S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
+		S_COR(c->connected.id.name.valid, c->connected.id.name.str, "(N/A)"),
+		S_OR(c->dialed.number.str, "(N/A)"),
+		S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
+		c->parkinglot,
+		c->language,	
+		ast_state2str(c->_state),
+		c->_state,
+		c->rings, 
+		ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
+		ast_getformatname(&c->writeformat),
+		ast_getformatname(&c->readformat),
+		ast_getformatname(&c->rawwriteformat),
+		ast_getformatname(&c->rawreadformat),
+		c->writetrans ? "Yes" : "No",
+		ast_translate_path_to_str(c->writetrans, &write_transpath),
+		c->readtrans ? "Yes" : "No",
+		ast_translate_path_to_str(c->readtrans, &read_transpath),
+		c->fds[0],
+		c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+		c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+		(long)c->whentohangup.tv_sec,
+		hour,
+		min,
+		sec,
+		c->_bridge ? c->_bridge->name : "<none>",
+		ast_bridged_channel(c) ? ast_bridged_channel(c)->name : "<none>", 
+		c->context,
+		c->exten,
+		c->priority,
+		ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
+		ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
+		c->appl ? c->appl : "(N/A)",
+		c->data ? S_OR(c->data, "(Empty)") : "(None)",
+		(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
 
 	return 0;
 }
@@ -150,7 +171,7 @@
 static int dumpchan_exec(struct ast_channel *chan, const char *data)
 {
 	struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
-	char info[1024];
+	char info[2048];
 	int level = 0;
 	static char *line = "================================================================================";
 
@@ -160,7 +181,13 @@
 	if (option_verbose >= level) {
 		serialize_showchan(chan, info, sizeof(info));
 		pbx_builtin_serialize_variables(chan, &vars);
-		ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
+		ast_verbose("\n"
+			"Dumping Info For Channel: %s:\n"
+			"%s\n"
+			"Info:\n"
+			"%s\n"
+			"Variables:\n"
+			"%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
 	}
 
 	return 0;




More information about the asterisk-commits mailing list