Wed Jan 8 2020 09:49:53

Asterisk developer's documentation


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"

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static const char app [] = "DumpChan"
 
static 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

static void __reg_module ( void  )
static

Definition at line 214 of file app_dumpchan.c.

static void __unreg_module ( void  )
static

Definition at line 214 of file app_dumpchan.c.

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

Definition at line 179 of file app_dumpchan.c.

References ast_str_buffer(), ast_str_thread_get(), ast_strlen_zero(), ast_verbose(), ast_channel::name, option_verbose, pbx_builtin_serialize_variables(), and serialize_showchan().

Referenced by load_module().

180 {
181  struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
182  char info[2048];
183  int level = 0;
184  static char *line = "================================================================================";
185 
186  if (!ast_strlen_zero(data))
187  level = atoi(data);
188 
189  if (option_verbose >= level) {
190  serialize_showchan(chan, info, sizeof(info));
191  pbx_builtin_serialize_variables(chan, &vars);
192  ast_verbose("\n"
193  "Dumping Info For Channel: %s:\n"
194  "%s\n"
195  "Info:\n"
196  "%s\n"
197  "Variables:\n"
198  "%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
199  }
200 
201  return 0;
202 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
int option_verbose
Definition: asterisk.c:181
static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
Definition: app_dumpchan.c:70
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
const ast_string_field name
Definition: channel.h:787
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:669
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.
Definition: pbx.c:10444
static int load_module ( void  )
static

Definition at line 209 of file app_dumpchan.c.

References ast_register_application_xml, and dumpchan_exec().

210 {
212 }
static int dumpchan_exec(struct ast_channel *chan, const char *data)
Definition: app_dumpchan.c:179
static const char app[]
Definition: app_dumpchan.c:68
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int serialize_showchan ( struct ast_channel c,
char *  buf,
size_t  size 
)
static

Definition at line 70 of file app_dumpchan.c.

References ast_channel::_bridge, ast_channel::_state, ast_channel::appl, ast_bridged_channel(), AST_FLAG_BLOCKING, ast_getformatname_multiple(), ast_print_group(), ast_state2str(), ast_str_alloca, ast_test_flag, ast_translate_path_to_str(), ast_tvnow(), ast_channel::blockproc, ast_channel::caller, ast_channel::callgroup, ast_channel::cdr, ast_channel::connected, ast_channel::context, ast_channel::data, DEBUGCHAN_FLAG, ast_channel::dialed, ast_channel::exten, ast_channel::fds, ast_channel::fin, ast_channel::fout, ast_party_redirecting::from, ast_party_caller::id, ast_party_connected_line::id, ast_channel::language, ast_channel::linkedid, name, ast_party_id::name, ast_channel::name, ast_channel::nativeformats, ast_party_id::number, ast_party_dialed::number, 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, S_COR, S_OR, ast_cdr::start, ast_party_name::str, ast_party_number::str, ast_party_dialed::str, ast_channel::tech, ast_channel_tech::type, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, ast_channel::whentohangup, ast_channel::writeformat, and ast_channel::writetrans.

Referenced by dumpchan_exec().

71 {
72  struct timeval now;
73  long elapsed_seconds = 0;
74  int hour = 0, min = 0, sec = 0;
75  char nf[256];
76  char wf[256];
77  char rf[256];
78  char rwf[256];
79  char rrf[256];
80  char cgrp[256];
81  char pgrp[256];
82  struct ast_str *write_transpath = ast_str_alloca(256);
83  struct ast_str *read_transpath = ast_str_alloca(256);
84 
85  now = ast_tvnow();
86  memset(buf, 0, size);
87  if (!c)
88  return 0;
89 
90  if (c->cdr) {
91  elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
92  hour = elapsed_seconds / 3600;
93  min = (elapsed_seconds % 3600) / 60;
94  sec = elapsed_seconds % 60;
95  }
96 
97  snprintf(buf,size,
98  "Name= %s\n"
99  "Type= %s\n"
100  "UniqueID= %s\n"
101  "LinkedID= %s\n"
102  "CallerIDNum= %s\n"
103  "CallerIDName= %s\n"
104  "ConnectedLineIDNum= %s\n"
105  "ConnectedLineIDName=%s\n"
106  "DNIDDigits= %s\n"
107  "RDNIS= %s\n"
108  "Parkinglot= %s\n"
109  "Language= %s\n"
110  "State= %s (%u)\n"
111  "Rings= %d\n"
112  "NativeFormat= %s\n"
113  "WriteFormat= %s\n"
114  "ReadFormat= %s\n"
115  "RawWriteFormat= %s\n"
116  "RawReadFormat= %s\n"
117  "WriteTranscode= %s %s\n"
118  "ReadTranscode= %s %s\n"
119  "1stFileDescriptor= %d\n"
120  "Framesin= %u %s\n"
121  "Framesout= %u %s\n"
122  "TimetoHangup= %ld\n"
123  "ElapsedTime= %dh%dm%ds\n"
124  "DirectBridge= %s\n"
125  "IndirectBridge= %s\n"
126  "Context= %s\n"
127  "Extension= %s\n"
128  "Priority= %d\n"
129  "CallGroup= %s\n"
130  "PickupGroup= %s\n"
131  "Application= %s\n"
132  "Data= %s\n"
133  "Blocking_in= %s\n",
134  c->name,
135  c->tech->type,
136  c->uniqueid,
137  c->linkedid,
138  S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
139  S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
140  S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
141  S_COR(c->connected.id.name.valid, c->connected.id.name.str, "(N/A)"),
142  S_OR(c->dialed.number.str, "(N/A)"),
144  c->parkinglot,
145  c->language,
146  ast_state2str(c->_state),
147  c->_state,
148  c->rings,
149  ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
150  ast_getformatname_multiple(wf, sizeof(wf), c->writeformat),
151  ast_getformatname_multiple(rf, sizeof(rf), c->readformat),
152  ast_getformatname_multiple(rwf, sizeof(rwf), c->rawwriteformat),
153  ast_getformatname_multiple(rrf, sizeof(rrf), c->rawreadformat),
154  c->writetrans ? "Yes" : "No",
155  ast_translate_path_to_str(c->writetrans, &write_transpath),
156  c->readtrans ? "Yes" : "No",
157  ast_translate_path_to_str(c->readtrans, &read_transpath),
158  c->fds[0],
159  c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
160  c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
161  (long)c->whentohangup.tv_sec,
162  hour,
163  min,
164  sec,
165  c->_bridge ? c->_bridge->name : "<none>",
166  ast_bridged_channel(c) ? ast_bridged_channel(c)->name : "<none>",
167  c->context,
168  c->exten,
169  c->priority,
170  ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
171  ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
172  c->appl ? c->appl : "(N/A)",
173  c->data ? S_OR(c->data, "(Empty)") : "(None)",
174  (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
175 
176  return 0;
177 }
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
const char *const type
Definition: channel.h:508
int rings
Definition: channel.h:840
char * str
Subscriber phone number (Malloced)
Definition: channel.h:336
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int priority
Definition: channel.h:841
const ast_string_field uniqueid
Definition: channel.h:787
#define DEBUGCHAN_FLAG
Definition: channel.h:648
format_t writeformat
Definition: channel.h:854
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
#define ast_test_flag(p, flag)
Definition: utils.h:63
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:449
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
unsigned int fout
Definition: channel.h:847
const char * blockproc
Definition: channel.h:753
format_t rawwriteformat
Definition: channel.h:856
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
struct ast_cdr * cdr
Definition: channel.h:766
format_t nativeformats
Definition: channel.h:852
#define ast_str_alloca(init_len)
Definition: strings.h:608
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
const char * data
Definition: channel.h:755
const ast_string_field linkedid
Definition: channel.h:787
format_t rawreadformat
Definition: channel.h:855
ast_group_t pickupgroup
Definition: channel.h:819
const char * appl
Definition: channel.h:754
ast_group_t callgroup
Definition: channel.h:818
char * ast_print_group(char *buf, int buflen, ast_group_t group)
print call- and pickup groups into buffer
Definition: channel.c:8236
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
struct ast_party_dialed::@155 number
Dialed/Called number.
#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:83
const ast_string_field parkinglot
Definition: channel.h:787
struct ast_channel * _bridge
Definition: channel.h:748
int fds[AST_MAX_FDS]
Definition: channel.h:829
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
struct ast_trans_pvt * writetrans
Definition: channel.h:762
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
unsigned int fin
Definition: channel.h:845
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
struct timeval start
Definition: cdr.h:100
static const char name[]
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:630
format_t readformat
Definition: channel.h:853
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
struct timeval whentohangup
Definition: channel.h:789
struct ast_trans_pvt * readtrans
Definition: channel.h:763
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
struct ast_channel_tech * tech
Definition: channel.h:743
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
const ast_string_field language
Definition: channel.h:787
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int unload_module ( void  )
static

Definition at line 204 of file app_dumpchan.c.

References ast_unregister_application().

205 {
207 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static const char app[]
Definition: app_dumpchan.c:68

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 214 of file app_dumpchan.c.

const char app[] = "DumpChan"
static

Definition at line 68 of file app_dumpchan.c.

Definition at line 214 of file app_dumpchan.c.