Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
Functions | Variables
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"

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Application to dump channel variables.

Author
Anthony Minessale anthm.nosp@m.ct@y.nosp@m.ahoo..nosp@m.com

Definition in file app_dumpchan.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 207 of file app_dumpchan.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 207 of file app_dumpchan.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 207 of file app_dumpchan.c.

◆ dumpchan_exec()

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

Definition at line 172 of file app_dumpchan.c.

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

Referenced by load_module().

173 {
174  struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
175  char info[2048];
176  int level = 0;
177  static char *line = "================================================================================";
178 
179  if (!ast_strlen_zero(data))
180  level = atoi(data);
181 
182  if (VERBOSITY_ATLEAST(level)) {
183  serialize_showchan(chan, info, sizeof(info));
184  pbx_builtin_serialize_variables(chan, &vars);
185  ast_verb(level, "\n"
186  "Dumping Info For Channel: %s:\n"
187  "%s\n"
188  "Info:\n"
189  "%s\n"
190  "Variables:\n"
191  "%s%s\n", ast_channel_name(chan), line, info, ast_str_buffer(vars), line);
192  }
193 
194  return 0;
195 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
#define VERBOSITY_ATLEAST(level)
Definition: logger.h:453
static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
Definition: app_dumpchan.c:69
#define ast_verb(level,...)
Definition: logger.h:455
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
def info(msg)
#define ast_strlen_zero(a)
Definition: muted.c:73
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Definition: strings.h:861
int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf)
Create a human-readable string, specifying all variables and their corresponding values.

◆ load_module()

static int load_module ( void  )
static

Definition at line 202 of file app_dumpchan.c.

References app, ast_register_application_xml, and dumpchan_exec().

203 {
205 }
static int dumpchan_exec(struct ast_channel *chan, const char *data)
Definition: app_dumpchan.c:172
static const char app[]
Definition: app_dumpchan.c:67
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ serialize_showchan()

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

Definition at line 69 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_CAP_NAMES_LEN, 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, type, and ast_bridge::uniqueid.

Referenced by dumpchan_exec().

70 {
71  long elapsed_seconds = 0;
72  int hour = 0, min = 0, sec = 0;
73  struct ast_str *format_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
74  char cgrp[256];
75  char pgrp[256];
76  struct ast_str *write_transpath = ast_str_alloca(256);
77  struct ast_str *read_transpath = ast_str_alloca(256);
78  struct ast_bridge *bridge;
79 
80  memset(buf, 0, size);
81  if (!c)
82  return 0;
83 
84  elapsed_seconds = ast_channel_get_duration(c);
85  hour = elapsed_seconds / 3600;
86  min = (elapsed_seconds % 3600) / 60;
87  sec = elapsed_seconds % 60;
88 
90  bridge = ast_channel_get_bridge(c);
91  snprintf(buf,size,
92  "Name= %s\n"
93  "Type= %s\n"
94  "UniqueID= %s\n"
95  "LinkedID= %s\n"
96  "CallerIDNum= %s\n"
97  "CallerIDName= %s\n"
98  "ConnectedLineIDNum= %s\n"
99  "ConnectedLineIDName=%s\n"
100  "DNIDDigits= %s\n"
101  "RDNIS= %s\n"
102  "Parkinglot= %s\n"
103  "Language= %s\n"
104  "State= %s (%u)\n"
105  "Rings= %d\n"
106  "NativeFormat= %s\n"
107  "WriteFormat= %s\n"
108  "ReadFormat= %s\n"
109  "RawWriteFormat= %s\n"
110  "RawReadFormat= %s\n"
111  "WriteTranscode= %s %s\n"
112  "ReadTranscode= %s %s\n"
113  "1stFileDescriptor= %d\n"
114  "Framesin= %u %s\n"
115  "Framesout= %u %s\n"
116  "TimetoHangup= %ld\n"
117  "ElapsedTime= %dh%dm%ds\n"
118  "BridgeID= %s\n"
119  "Context= %s\n"
120  "Extension= %s\n"
121  "Priority= %d\n"
122  "CallGroup= %s\n"
123  "PickupGroup= %s\n"
124  "Application= %s\n"
125  "Data= %s\n"
126  "Blocking_in= %s\n",
127  ast_channel_name(c),
131  S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "(N/A)"),
132  S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "(N/A)"),
133  S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "(N/A)"),
134  S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "(N/A)"),
135  S_OR(ast_channel_dialed(c)->number.str, "(N/A)"),
136  S_COR(ast_channel_redirecting(c)->from.number.valid, ast_channel_redirecting(c)->from.number.str, "(N/A)"),
147  ast_channel_writetrans(c) ? "Yes" : "No",
149  ast_channel_readtrans(c) ? "Yes" : "No",
151  ast_channel_fd(c, 0),
152  ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
153  ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
154  (long)ast_channel_whentohangup(c)->tv_sec,
155  hour,
156  min,
157  sec,
158  bridge ? bridge->uniqueid : "(Not bridged)",
162  ast_print_group(cgrp, sizeof(cgrp), ast_channel_callgroup(c)),
163  ast_print_group(pgrp, sizeof(pgrp), ast_channel_pickupgroup(c)),
164  ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)",
165  ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)",
168  ao2_cleanup(bridge);
169  return 0;
170 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
static const char type[]
Definition: chan_ooh323.c:109
const char * ast_channel_blockproc(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2837
const ast_string_field uniqueid
Definition: bridge.h:405
#define DEBUGCHAN_FLAG
Definition: channel.h:845
#define ast_test_flag(p, flag)
Definition: utils.h:63
unsigned int ast_channel_fout(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_FORMAT_CAP_NAMES_LEN
Definition: format_cap.h:326
ast_channel_state
ast_channel states
Definition: channelstate.h:35
#define ast_str_alloca(init_len)
Definition: strings.h:800
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:638
int ast_channel_priority(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
const char * ast_channel_linkedid(const struct ast_channel *chan)
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
Definition: channel.c:7972
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
Number structure.
Definition: app_followme.c:154
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10568
unsigned int ast_channel_fin(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:85
const char * ast_channel_exten(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
Structure that contains information about a bridge.
Definition: bridge.h:353
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition: format_cap.c:736
const char * ast_channel_appl(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2838
static const char name[]
Definition: cdr_mysql.c:74
int ast_channel_get_duration(struct ast_channel *chan)
Obtain how long the channel since the channel was created.
Definition: channel.c:2805
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
const char * ast_channel_data(const struct ast_channel *chan)
int ast_channel_fd(const struct ast_channel *chan, int which)
const char * ast_translate_path_to_str(struct ast_trans_pvt *t, struct ast_str **str)
Puts a string representation of the translation path into outbuf.
Definition: translate.c:922
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_channel_rings(const struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
#define min(a, b)
Definition: f2c.h:197
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
const char * ast_channel_parkinglot(const struct ast_channel *chan)

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 197 of file app_dumpchan.c.

References app, and ast_unregister_application().

198 {
200 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static const char app[]
Definition: app_dumpchan.c:67

Variable Documentation

◆ __mod_info

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 207 of file app_dumpchan.c.

◆ app

const char app[] = "DumpChan"
static

Definition at line 67 of file app_dumpchan.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 207 of file app_dumpchan.c.