#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
Include dependency graph for app_dumpchan.c:
Go to the source code of this file.
Functions | |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Dump Info About The Calling Channel") | |
static int | dumpchan_exec (struct ast_channel *chan, void *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 char * | app = "DumpChan" |
static char * | desc |
static char * | synopsis = "Dump Info About The Calling Channel" |
Definition in file app_dumpchan.c.
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"Dump Info About The Calling Channel" | ||||
) |
static int dumpchan_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 137 of file app_dumpchan.c.
References ast_module_user_add, ast_module_user_remove, ast_strlen_zero(), ast_verbose(), ast_module_user::chan, option_verbose, pbx_builtin_serialize_variables(), and serialize_showchan().
Referenced by load_module().
00138 { 00139 struct ast_module_user *u; 00140 char vars[BUFSIZ * 4]; 00141 char info[1024]; 00142 int level = 0; 00143 static char *line = "================================================================================"; 00144 00145 u = ast_module_user_add(chan); 00146 00147 if (!ast_strlen_zero(data)) 00148 level = atoi(data); 00149 00150 pbx_builtin_serialize_variables(chan, vars, sizeof(vars)); 00151 serialize_showchan(chan, info, sizeof(info)); 00152 if (option_verbose >= level) 00153 ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars, line); 00154 00155 ast_module_user_remove(u); 00156 00157 return 0; 00158 }
static int load_module | ( | void | ) | [static] |
Definition at line 171 of file app_dumpchan.c.
References ast_register_application(), and dumpchan_exec().
00172 { 00173 return ast_register_application(app, dumpchan_exec, synopsis, desc); 00174 }
static int serialize_showchan | ( | struct ast_channel * | c, | |
char * | buf, | |||
size_t | size | |||
) | [static] |
Definition at line 60 of file app_dumpchan.c.
References ast_channel::_state, ast_channel::appl, AST_FLAG_BLOCKING, ast_getformatname_multiple(), ast_print_group(), ast_state2str(), ast_test_flag, ast_channel::blockproc, ast_channel::callgroup, ast_channel::cdr, ast_channel::cid, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_rdnis, ast_channel::context, ast_channel::data, DEBUGCHAN_FLAG, ast_channel::exten, ast_channel::fds, ast_channel::fin, ast_channel::fout, ast_channel::nativeformats, ast_channel::pickupgroup, ast_channel::priority, ast_channel::readformat, ast_channel::rings, S_OR, ast_cdr::start, ast_channel::tech, ast_channel_tech::type, ast_channel::whentohangup, and ast_channel::writeformat.
Referenced by dumpchan_exec().
00061 { 00062 struct timeval now; 00063 long elapsed_seconds = 0; 00064 int hour = 0, min = 0, sec = 0; 00065 char cgrp[BUFSIZ/2]; 00066 char pgrp[BUFSIZ/2]; 00067 char formatbuf[BUFSIZ/2]; 00068 00069 now = ast_tvnow(); 00070 memset(buf, 0, size); 00071 if (!c) 00072 return 0; 00073 00074 if (c->cdr) { 00075 elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec; 00076 hour = elapsed_seconds / 3600; 00077 min = (elapsed_seconds % 3600) / 60; 00078 sec = elapsed_seconds % 60; 00079 } 00080 00081 snprintf(buf,size, 00082 "Name= %s\n" 00083 "Type= %s\n" 00084 "UniqueID= %s\n" 00085 "CallerID= %s\n" 00086 "CallerIDName= %s\n" 00087 "DNIDDigits= %s\n" 00088 "RDNIS= %s\n" 00089 "State= %s (%d)\n" 00090 "Rings= %d\n" 00091 "NativeFormat= %s\n" 00092 "WriteFormat= %s\n" 00093 "ReadFormat= %s\n" 00094 "1stFileDescriptor= %d\n" 00095 "Framesin= %d %s\n" 00096 "Framesout= %d %s\n" 00097 "TimetoHangup= %ld\n" 00098 "ElapsedTime= %dh%dm%ds\n" 00099 "Context= %s\n" 00100 "Extension= %s\n" 00101 "Priority= %d\n" 00102 "CallGroup= %s\n" 00103 "PickupGroup= %s\n" 00104 "Application= %s\n" 00105 "Data= %s\n" 00106 "Blocking_in= %s\n", 00107 c->name, 00108 c->tech->type, 00109 c->uniqueid, 00110 S_OR(c->cid.cid_num, "(N/A)"), 00111 S_OR(c->cid.cid_name, "(N/A)"), 00112 S_OR(c->cid.cid_dnid, "(N/A)"), 00113 S_OR(c->cid.cid_rdnis, "(N/A)"), 00114 ast_state2str(c->_state), 00115 c->_state, 00116 c->rings, 00117 ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats), 00118 ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->writeformat), 00119 ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->readformat), 00120 c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", 00121 c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup, 00122 hour, 00123 min, 00124 sec, 00125 c->context, 00126 c->exten, 00127 c->priority, 00128 ast_print_group(cgrp, sizeof(cgrp), c->callgroup), 00129 ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup), 00130 ( c->appl ? c->appl : "(N/A)" ), 00131 ( c-> data ? S_OR(c->data, "(Empty)") : "(None)"), 00132 (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)")); 00133 00134 return 0; 00135 }
static int unload_module | ( | void | ) | [static] |
Definition at line 160 of file app_dumpchan.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00161 { 00162 int res; 00163 00164 res = ast_unregister_application(app); 00165 00166 ast_module_user_hangup_all(); 00167 00168 return res; 00169 }
char* app = "DumpChan" [static] |
Definition at line 50 of file app_dumpchan.c.
char* desc [static] |
Definition at line 52 of file app_dumpchan.c.
char* synopsis = "Dump Info About The Calling Channel" [static] |
Definition at line 51 of file app_dumpchan.c.