mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
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. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@313527 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -36,6 +36,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
|
#include "asterisk/translate.h"
|
||||||
|
|
||||||
/*** DOCUMENTATION
|
/*** DOCUMENTATION
|
||||||
<application name="DumpChan" language="en_US">
|
<application name="DumpChan" language="en_US">
|
||||||
@@ -67,9 +68,11 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
|
|||||||
struct timeval now;
|
struct timeval now;
|
||||||
long elapsed_seconds = 0;
|
long elapsed_seconds = 0;
|
||||||
int hour = 0, min = 0, sec = 0;
|
int hour = 0, min = 0, sec = 0;
|
||||||
char cgrp[BUFSIZ/2];
|
char nf[256];
|
||||||
char pgrp[BUFSIZ/2];
|
char cgrp[256];
|
||||||
char formatbuf[BUFSIZ/2];
|
char pgrp[256];
|
||||||
|
struct ast_str *write_transpath = ast_str_alloca(256);
|
||||||
|
struct ast_str *read_transpath = ast_str_alloca(256);
|
||||||
|
|
||||||
now = ast_tvnow();
|
now = ast_tvnow();
|
||||||
memset(buf, 0, size);
|
memset(buf, 0, size);
|
||||||
@@ -84,65 +87,83 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buf,size,
|
snprintf(buf,size,
|
||||||
"Name= %s\n"
|
"Name= %s\n"
|
||||||
"Type= %s\n"
|
"Type= %s\n"
|
||||||
"UniqueID= %s\n"
|
"UniqueID= %s\n"
|
||||||
"CallerIDNum= %s\n"
|
"LinkedID= %s\n"
|
||||||
"CallerIDName= %s\n"
|
"CallerIDNum= %s\n"
|
||||||
"DNIDDigits= %s\n"
|
"CallerIDName= %s\n"
|
||||||
"RDNIS= %s\n"
|
"ConnectedLineIDNum= %s\n"
|
||||||
"Parkinglot= %s\n"
|
"ConnectedLineIDName=%s\n"
|
||||||
"Language= %s\n"
|
"DNIDDigits= %s\n"
|
||||||
"State= %s (%d)\n"
|
"RDNIS= %s\n"
|
||||||
"Rings= %d\n"
|
"Parkinglot= %s\n"
|
||||||
"NativeFormat= %s\n"
|
"Language= %s\n"
|
||||||
"WriteFormat= %s\n"
|
"State= %s (%d)\n"
|
||||||
"ReadFormat= %s\n"
|
"Rings= %d\n"
|
||||||
"RawWriteFormat= %s\n"
|
"NativeFormat= %s\n"
|
||||||
"RawReadFormat= %s\n"
|
"WriteFormat= %s\n"
|
||||||
"1stFileDescriptor= %d\n"
|
"ReadFormat= %s\n"
|
||||||
"Framesin= %d %s\n"
|
"RawWriteFormat= %s\n"
|
||||||
"Framesout= %d %s\n"
|
"RawReadFormat= %s\n"
|
||||||
"TimetoHangup= %ld\n"
|
"WriteTranscode= %s %s\n"
|
||||||
"ElapsedTime= %dh%dm%ds\n"
|
"ReadTranscode= %s %s\n"
|
||||||
"Context= %s\n"
|
"1stFileDescriptor= %d\n"
|
||||||
"Extension= %s\n"
|
"Framesin= %d %s\n"
|
||||||
"Priority= %d\n"
|
"Framesout= %d %s\n"
|
||||||
"CallGroup= %s\n"
|
"TimetoHangup= %ld\n"
|
||||||
"PickupGroup= %s\n"
|
"ElapsedTime= %dh%dm%ds\n"
|
||||||
"Application= %s\n"
|
"DirectBridge= %s\n"
|
||||||
"Data= %s\n"
|
"IndirectBridge= %s\n"
|
||||||
"Blocking_in= %s\n",
|
"Context= %s\n"
|
||||||
c->name,
|
"Extension= %s\n"
|
||||||
c->tech->type,
|
"Priority= %d\n"
|
||||||
c->uniqueid,
|
"CallGroup= %s\n"
|
||||||
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
|
"PickupGroup= %s\n"
|
||||||
S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
|
"Application= %s\n"
|
||||||
S_OR(c->dialed.number.str, "(N/A)"),
|
"Data= %s\n"
|
||||||
S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
|
"Blocking_in= %s\n",
|
||||||
c->parkinglot,
|
c->name,
|
||||||
c->language,
|
c->tech->type,
|
||||||
ast_state2str(c->_state),
|
c->uniqueid,
|
||||||
c->_state,
|
c->linkedid,
|
||||||
c->rings,
|
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
|
||||||
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
|
S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
|
||||||
ast_getformatname(&c->writeformat),
|
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
|
||||||
ast_getformatname(&c->readformat),
|
S_COR(c->connected.id.name.valid, c->connected.id.name.str, "(N/A)"),
|
||||||
ast_getformatname(&c->rawwriteformat),
|
S_OR(c->dialed.number.str, "(N/A)"),
|
||||||
ast_getformatname(&c->rawreadformat),
|
S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
|
||||||
c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
|
c->parkinglot,
|
||||||
c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup.tv_sec,
|
c->language,
|
||||||
hour,
|
ast_state2str(c->_state),
|
||||||
min,
|
c->_state,
|
||||||
sec,
|
c->rings,
|
||||||
c->context,
|
ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
|
||||||
c->exten,
|
ast_getformatname(&c->writeformat),
|
||||||
c->priority,
|
ast_getformatname(&c->readformat),
|
||||||
ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
|
ast_getformatname(&c->rawwriteformat),
|
||||||
ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
|
ast_getformatname(&c->rawreadformat),
|
||||||
( c->appl ? c->appl : "(N/A)" ),
|
c->writetrans ? "Yes" : "No",
|
||||||
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
|
ast_translate_path_to_str(c->writetrans, &write_transpath),
|
||||||
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -150,7 +171,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
|
|||||||
static int dumpchan_exec(struct ast_channel *chan, const char *data)
|
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);
|
struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
|
||||||
char info[1024];
|
char info[2048];
|
||||||
int level = 0;
|
int level = 0;
|
||||||
static char *line = "================================================================================";
|
static char *line = "================================================================================";
|
||||||
|
|
||||||
@@ -160,7 +181,13 @@ static int dumpchan_exec(struct ast_channel *chan, const char *data)
|
|||||||
if (option_verbose >= level) {
|
if (option_verbose >= level) {
|
||||||
serialize_showchan(chan, info, sizeof(info));
|
serialize_showchan(chan, info, sizeof(info));
|
||||||
pbx_builtin_serialize_variables(chan, &vars);
|
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;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user