Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
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"
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)
 
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 = ASTERISK_GPL_KEY , .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 210 of file app_dumpchan.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 210 of file app_dumpchan.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 210 of file app_dumpchan.c.

◆ dumpchan_exec()

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

Definition at line 175 of file app_dumpchan.c.

176{
177 struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
178 char info[2048];
179 int level = 0;
180 static char *line = "================================================================================";
181
182 if (!ast_strlen_zero(data))
183 level = atoi(data);
184
185 if (VERBOSITY_ATLEAST(level)) {
186 serialize_showchan(chan, info, sizeof(info));
188 ast_verb(level, "\n"
189 "Dumping Info For Channel: %s:\n"
190 "%s\n"
191 "Info:\n"
192 "%s\n"
193 "Variables:\n"
194 "%s%s\n", ast_channel_name(chan), line, info, ast_str_buffer(vars), line);
195 }
196
197 return 0;
198}
static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
const char * ast_channel_name(const struct ast_channel *chan)
#define VERBOSITY_ATLEAST(level)
#define ast_verb(level,...)
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.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
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:909
Support for dynamic strings.
Definition strings.h:623

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().

◆ load_module()

static int load_module ( void  )
static

Definition at line 205 of file app_dumpchan.c.

206{
208}
static const char app[]
static int dumpchan_exec(struct ast_channel *chan, const char *data)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition module.h:640

References app, ast_register_application_xml, and dumpchan_exec().

◆ serialize_showchan()

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

Definition at line 72 of file app_dumpchan.c.

73{
74 long elapsed_seconds = 0;
75 int hour = 0, min = 0, sec = 0;
77 char cgrp[256];
78 char pgrp[256];
79 struct ast_str *write_transpath = ast_str_alloca(256);
80 struct ast_str *read_transpath = ast_str_alloca(256);
81 struct ast_bridge *bridge;
82
83 memset(buf, 0, size);
84 if (!c)
85 return 0;
86
87 elapsed_seconds = ast_channel_get_duration(c);
88 hour = elapsed_seconds / 3600;
89 min = (elapsed_seconds % 3600) / 60;
90 sec = elapsed_seconds % 60;
91
93 bridge = ast_channel_get_bridge(c);
94 snprintf(buf,size,
95 "Name= %s\n"
96 "Type= %s\n"
97 "UniqueID= %s\n"
98 "LinkedID= %s\n"
99 "CallerIDNum= %s\n"
100 "CallerIDName= %s\n"
101 "ConnectedLineIDNum= %s\n"
102 "ConnectedLineIDName=%s\n"
103 "DNIDDigits= %s\n"
104 "RDNIS= %s\n"
105 "Parkinglot= %s\n"
106 "Language= %s\n"
107 "State= %s (%u)\n"
108 "Rings= %d\n"
109 "NativeFormat= %s\n"
110 "WriteFormat= %s\n"
111 "ReadFormat= %s\n"
112 "RawWriteFormat= %s\n"
113 "RawReadFormat= %s\n"
114 "WriteTranscode= %s %s\n"
115 "ReadTranscode= %s %s\n"
116 "1stFileDescriptor= %d\n"
117 "Framesin= %u %s\n"
118 "Framesout= %u %s\n"
119 "TimetoHangup= %ld\n"
120 "ElapsedTime= %dh%dm%ds\n"
121 "BridgeID= %s\n"
122 "Context= %s\n"
123 "Extension= %s\n"
124 "Priority= %d\n"
125 "CallGroup= %s\n"
126 "PickupGroup= %s\n"
127 "Application= %s\n"
128 "Data= %s\n"
129 "Blocking_in= %s\n",
134 S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, "(N/A)"),
135 S_COR(ast_channel_caller(c)->id.name.valid, ast_channel_caller(c)->id.name.str, "(N/A)"),
136 S_COR(ast_channel_connected(c)->id.number.valid, ast_channel_connected(c)->id.number.str, "(N/A)"),
137 S_COR(ast_channel_connected(c)->id.name.valid, ast_channel_connected(c)->id.name.str, "(N/A)"),
138 S_OR(ast_channel_dialed(c)->number.str, "(N/A)"),
139 S_COR(ast_channel_redirecting(c)->from.number.valid, ast_channel_redirecting(c)->from.number.str, "(N/A)"),
150 ast_channel_writetrans(c) ? "Yes" : "No",
152 ast_channel_readtrans(c) ? "Yes" : "No",
154 ast_channel_fd(c, 0),
155 ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
156 ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
157 (long)ast_channel_whentohangup(c)->tv_sec,
158 hour,
159 min,
160 sec,
161 bridge ? bridge->uniqueid : "(Not bridged)",
165 ast_print_group(cgrp, sizeof(cgrp), ast_channel_callgroup(c)),
166 ast_print_group(pgrp, sizeof(pgrp), ast_channel_pickupgroup(c)),
167 ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)",
168 ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)",
171 ao2_cleanup(bridge);
172 return 0;
173}
#define ao2_cleanup(obj)
Definition astobj2.h:1934
static const char type[]
const char * ast_channel_linkedid(const struct ast_channel *chan)
const char * ast_channel_blockproc(const struct ast_channel *chan)
const char * ast_channel_data(const struct ast_channel *chan)
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
#define DEBUGCHAN_FLAG
Definition channel.h:877
unsigned int ast_channel_fin(const struct ast_channel *chan)
int ast_channel_rings(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition channel.h:2982
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_channel_priority(const struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_context(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:8075
const char * ast_channel_parkinglot(const struct ast_channel *chan)
const char * ast_channel_appl(const struct ast_channel *chan)
int ast_channel_fd(const struct ast_channel *chan, int which)
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
unsigned int ast_channel_fout(const struct ast_channel *chan)
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition channel.c:10578
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition channel.c:636
int ast_channel_get_duration(struct ast_channel *chan)
Obtain how long the channel since the channel was created.
Definition channel.c:2828
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
@ AST_FLAG_BLOCKING
Definition channel.h:1005
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition channel.h:2983
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
char buf[BUFSIZE]
Definition eagi_proxy.c:66
#define min(a, b)
Definition f2c.h:197
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition format.c:334
#define AST_FORMAT_CAP_NAMES_LEN
Definition format_cap.h:324
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:734
static const char name[]
Definition format_mp3.c:68
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
#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:87
#define ast_str_alloca(init_len)
Definition strings.h:848
Structure that contains information about a bridge.
Definition bridge.h:353
const ast_string_field uniqueid
Definition bridge.h:405
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
Number structure.
static struct test_val c
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:930
#define ast_test_flag(p, flag)
Definition utils.h:64

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_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(), buf, c, DEBUGCHAN_FLAG, min, name, S_COR, S_OR, type, and ast_bridge::uniqueid.

Referenced by dumpchan_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 200 of file app_dumpchan.c.

201{
203}
int ast_unregister_application(const char *app)
Unregister an application.
Definition pbx_app.c:392

References app, and ast_unregister_application().

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 = ASTERISK_GPL_KEY , .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 210 of file app_dumpchan.c.

◆ app

const char app[] = "DumpChan"
static

Definition at line 70 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 210 of file app_dumpchan.c.