#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "asterisk.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 | |
static int | ast_serialize_showchan (struct ast_channel *c, char *buf, size_t size) |
char * | description (void) |
Provides a description of the module. | |
static int | dumpchan_exec (struct ast_channel *chan, void *data) |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app = "DumpChan" |
static char * | desc |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Dump Info About The Calling Channel" |
static char * | tdesc = "Dump Info About The Calling Channel" |
Definition in file app_dumpchan.c.
|
Definition at line 61 of file app_dumpchan.c. References ast_channel::_state, ast_channel::appl, AST_FLAG_BLOCKING, ast_print_group(), ast_state2str(), ast_strlen_zero(), 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_channel::context, ast_channel::data, ast_channel::exten, ast_channel::fds, ast_channel::fin, ast_channel::fout, ast_channel::name, ast_channel::nativeformats, ast_channel::pickupgroup, ast_channel::priority, ast_channel::readformat, ast_channel::rings, ast_cdr::start, ast_channel::type, ast_channel::uniqueid, ast_channel::whentohangup, and ast_channel::writeformat. Referenced by dumpchan_exec(). 00062 { 00063 struct timeval now; 00064 long elapsed_seconds=0; 00065 int hour=0, min=0, sec=0; 00066 char cgrp[256]; 00067 char pgrp[256]; 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 "State= %s (%d)\n" 00089 "Rings= %d\n" 00090 "NativeFormat= %d\n" 00091 "WriteFormat= %d\n" 00092 "ReadFormat= %d\n" 00093 "1stFileDescriptor= %d\n" 00094 "Framesin= %d %s\n" 00095 "Framesout= %d %s\n" 00096 "TimetoHangup= %ld\n" 00097 "ElapsedTime= %dh%dm%ds\n" 00098 "Context= %s\n" 00099 "Extension= %s\n" 00100 "Priority= %d\n" 00101 "CallGroup= %s\n" 00102 "PickupGroup= %s\n" 00103 "Application= %s\n" 00104 "Data= %s\n" 00105 "Blocking_in= %s\n", 00106 c->name, 00107 c->type, 00108 c->uniqueid, 00109 (c->cid.cid_num ? c->cid.cid_num : "(N/A)"), 00110 (c->cid.cid_name ? c->cid.cid_name : "(N/A)"), 00111 (c->cid.cid_dnid ? c->cid.cid_dnid : "(N/A)" ), 00112 ast_state2str(c->_state), 00113 c->_state, 00114 c->rings, 00115 c->nativeformats, 00116 c->writeformat, 00117 c->readformat, 00118 c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "", 00119 c->fout & 0x7fffffff, (c->fout & 0x80000000) ? " (DEBUGGED)" : "", (long)c->whentohangup, 00120 hour, 00121 min, 00122 sec, 00123 c->context, 00124 c->exten, 00125 c->priority, 00126 ast_print_group(cgrp, sizeof(cgrp), c->callgroup), 00127 ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup), 00128 ( c->appl ? c->appl : "(N/A)" ), 00129 ( c-> data ? (!ast_strlen_zero(c->data) ? c->data : "(Empty)") : "(None)"), 00130 (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)")); 00131 00132 return 0; 00133 }
|
|
Provides a description of the module.
Definition at line 176 of file app_dumpchan.c. 00177 { 00178 return tdesc; 00179 }
|
|
Definition at line 135 of file app_dumpchan.c. References ast_serialize_showchan(), ast_strlen_zero(), ast_verbose(), localuser::chan, LOCAL_USER_ADD, LOCAL_USER_REMOVE, ast_channel::name, option_verbose, and pbx_builtin_serialize_variables(). Referenced by load_module(). 00136 { 00137 int res=0; 00138 struct localuser *u; 00139 char vars[1024]; 00140 char info[1024]; 00141 int level = 0; 00142 static char *line = "================================================================================"; 00143 00144 LOCAL_USER_ADD(u); 00145 00146 if (!ast_strlen_zero(data)) { 00147 level = atoi(data); 00148 } 00149 00150 pbx_builtin_serialize_variables(chan, vars, sizeof(vars)); 00151 ast_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 LOCAL_USER_REMOVE(u); 00156 00157 return res; 00158 }
|
|
Returns the ASTERISK_GPL_KEY. This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 188 of file app_dumpchan.c. References ASTERISK_GPL_KEY. 00189 { 00190 return ASTERISK_GPL_KEY; 00191 }
|
|
Initialize the module. Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
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 }
|
|
Cleanup all module structures, sockets, etc. This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 160 of file app_dumpchan.c. References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS. 00161 { 00162 int res; 00163 00164 res = ast_unregister_application(app); 00165 00166 STANDARD_HANGUP_LOCALUSERS; 00167 00168 return res; 00169 }
|
|
Provides a usecount. This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 181 of file app_dumpchan.c. References STANDARD_USECOUNT. 00182 { 00183 int res; 00184 STANDARD_USECOUNT(res); 00185 return res; 00186 }
|
|
Definition at line 48 of file app_dumpchan.c. |
|
Definition at line 50 of file app_dumpchan.c. |
|
Definition at line 59 of file app_dumpchan.c. |
|
Definition at line 57 of file app_dumpchan.c. |
|
Definition at line 49 of file app_dumpchan.c. |
|
Definition at line 47 of file app_dumpchan.c. |