app_dumpchan.c File Reference

Application to dump channel variables. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"
#include "asterisk/translate.h"
#include "asterisk/bridge.h"

Include dependency graph for app_dumpchan.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int dumpchan_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
static int serialize_showchan (struct ast_channel *c, char *buf, size_t size)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Dump Info About The Calling Channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static const char app [] = "DumpChan"
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

Application to dump channel variables.

Author:
Anthony Minessale <anthmct@yahoo.com>

Definition in file app_dumpchan.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 211 of file app_dumpchan.c.

static void __unreg_module ( void   )  [static]

Definition at line 211 of file app_dumpchan.c.

static int dumpchan_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 176 of file app_dumpchan.c.

References ast_channel_name(), ast_str_buffer(), ast_str_thread_get(), ast_strlen_zero, ast_verb, pbx_builtin_serialize_variables(), serialize_showchan(), and VERBOSITY_ATLEAST.

Referenced by load_module().

00177 {
00178    struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
00179    char info[2048];
00180    int level = 0;
00181    static char *line = "================================================================================";
00182 
00183    if (!ast_strlen_zero(data))
00184       level = atoi(data);
00185 
00186    if (VERBOSITY_ATLEAST(level)) {
00187       serialize_showchan(chan, info, sizeof(info));
00188       pbx_builtin_serialize_variables(chan, &vars);
00189       ast_verb(level, "\n"
00190          "Dumping Info For Channel: %s:\n"
00191          "%s\n"
00192          "Info:\n"
00193          "%s\n"
00194          "Variables:\n"
00195          "%s%s\n", ast_channel_name(chan), line, info, ast_str_buffer(vars), line);
00196    }
00197 
00198    return 0;
00199 }

static int load_module ( void   )  [static]

Definition at line 206 of file app_dumpchan.c.

References ast_register_application_xml, and dumpchan_exec().

00207 {
00208    return ast_register_application_xml(app, dumpchan_exec);
00209 }

static int serialize_showchan ( struct ast_channel c,
char *  buf,
size_t  size 
) [static]

Definition at line 71 of file app_dumpchan.c.

References ao2_cleanup, ast_channel_appl(), ast_channel_blockproc(), ast_channel_caller(), ast_channel_callgroup(), ast_channel_connected(), ast_channel_context(), ast_channel_data(), ast_channel_dialed(), ast_channel_exten(), ast_channel_fd(), ast_channel_fin(), ast_channel_flags(), ast_channel_fout(), ast_channel_get_bridge(), ast_channel_get_duration(), ast_channel_language(), ast_channel_linkedid(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats(), ast_channel_parkinglot(), ast_channel_pickupgroup(), ast_channel_priority(), ast_channel_rawreadformat(), ast_channel_rawwriteformat(), ast_channel_readformat(), ast_channel_readtrans(), ast_channel_redirecting(), ast_channel_rings(), ast_channel_tech(), ast_channel_uniqueid(), ast_channel_unlock, ast_channel_whentohangup(), ast_channel_writeformat(), ast_channel_writetrans(), AST_FLAG_BLOCKING, ast_format_cap_get_names(), ast_format_get_name(), ast_print_group(), ast_state2str(), ast_str_alloca, ast_test_flag, ast_translate_path_to_str(), DEBUGCHAN_FLAG, min, name, S_COR, S_OR, ast_party_dialed::str, type, and ast_bridge::uniqueid.

Referenced by dumpchan_exec().

00072 {
00073    long elapsed_seconds = 0;
00074    int hour = 0, min = 0, sec = 0;
00075    struct ast_str *format_buf = ast_str_alloca(64);
00076    char cgrp[256];
00077    char pgrp[256];
00078    struct ast_str *write_transpath = ast_str_alloca(256);
00079    struct ast_str *read_transpath = ast_str_alloca(256);
00080    struct ast_bridge *bridge;
00081 
00082    memset(buf, 0, size);
00083    if (!c)
00084       return 0;
00085 
00086    elapsed_seconds = ast_channel_get_duration(c);
00087    hour = elapsed_seconds / 3600;
00088    min = (elapsed_seconds % 3600) / 60;
00089    sec = elapsed_seconds % 60;
00090 
00091    ast_channel_lock(c);
00092    bridge = ast_channel_get_bridge(c);
00093    ast_channel_unlock(c);
00094 
00095    snprintf(buf,size,
00096       "Name=               %s\n"
00097       "Type=               %s\n"
00098       "UniqueID=           %s\n"
00099       "LinkedID=           %s\n"
00100       "CallerIDNum=        %s\n"
00101       "CallerIDName=       %s\n"
00102       "ConnectedLineIDNum= %s\n"
00103       "ConnectedLineIDName=%s\n"
00104       "DNIDDigits=         %s\n"
00105       "RDNIS=              %s\n"
00106       "Parkinglot=         %s\n"
00107       "Language=           %s\n"
00108       "State=              %s (%u)\n"
00109       "Rings=              %d\n"
00110       "NativeFormat=       %s\n"
00111       "WriteFormat=        %s\n"
00112       "ReadFormat=         %s\n"
00113       "RawWriteFormat=     %s\n"
00114       "RawReadFormat=      %s\n"
00115       "WriteTranscode=     %s %s\n"
00116       "ReadTranscode=      %s %s\n"
00117       "1stFileDescriptor=  %d\n"
00118       "Framesin=           %u %s\n"
00119       "Framesout=          %u %s\n"
00120       "TimetoHangup=       %ld\n"
00121       "ElapsedTime=        %dh%dm%ds\n"
00122       "BridgeID=           %s\n"
00123       "Context=            %s\n"
00124       "Extension=          %s\n"
00125       "Priority=           %d\n"
00126       "CallGroup=          %s\n"
00127       "PickupGroup=        %s\n"
00128       "Application=        %s\n"
00129       "Data=               %s\n"
00130       "Blocking_in=        %s\n",
00131       ast_channel_name(c),
00132       ast_channel_tech(c)->type,
00133       ast_channel_uniqueid(c),
00134       ast_channel_linkedid(c),
00135       S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "(N/A)"),
00136       S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "(N/A)"),
00137       S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "(N/A)"),
00138       S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "(N/A)"),
00139       S_OR(ast_channel_dialed(c)->number.str, "(N/A)"),
00140       S_COR(ast_channel_redirecting(c)->from.number.valid, ast_channel_redirecting(c)->from.number.str, "(N/A)"),
00141       ast_channel_parkinglot(c),
00142       ast_channel_language(c),
00143       ast_state2str(ast_channel_state(c)),
00144       ast_channel_state(c),
00145       ast_channel_rings(c),
00146       ast_format_cap_get_names(ast_channel_nativeformats(c), &format_buf),
00147       ast_format_get_name(ast_channel_writeformat(c)),
00148       ast_format_get_name(ast_channel_readformat(c)),
00149       ast_format_get_name(ast_channel_rawwriteformat(c)),
00150       ast_format_get_name(ast_channel_rawreadformat(c)),
00151       ast_channel_writetrans(c) ? "Yes" : "No",
00152       ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
00153       ast_channel_readtrans(c) ? "Yes" : "No",
00154       ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath),
00155       ast_channel_fd(c, 0),
00156       ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
00157       ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
00158       (long)ast_channel_whentohangup(c)->tv_sec,
00159       hour,
00160       min,
00161       sec,
00162       bridge ? bridge->uniqueid : "(Not bridged)",
00163       ast_channel_context(c),
00164       ast_channel_exten(c),
00165       ast_channel_priority(c),
00166       ast_print_group(cgrp, sizeof(cgrp), ast_channel_callgroup(c)),
00167       ast_print_group(pgrp, sizeof(pgrp), ast_channel_pickupgroup(c)),
00168       ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)",
00169       ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)",
00170       (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
00171 
00172    ao2_cleanup(bridge);
00173    return 0;
00174 }

static int unload_module ( void   )  [static]

Definition at line 201 of file app_dumpchan.c.

References ast_unregister_application().

00202 {
00203    return ast_unregister_application(app);
00204 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Dump Info About The Calling Channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 211 of file app_dumpchan.c.

const char app[] = "DumpChan" [static]

Definition at line 69 of file app_dumpchan.c.

Definition at line 211 of file app_dumpchan.c.


Generated on Thu Apr 16 06:28:26 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6