#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/framehook.h"
Go to the source code of this file.
Data Structures | |
struct | frame_trace_data |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static void | datastore_destroy_cb (void *data) |
static int | frame_trace_helper (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
static void | hook_destroy_cb (void *framedata) |
static struct ast_frame * | hook_event_cb (struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data) |
static int | load_module (void) |
static void | print_frame (struct ast_frame *frame) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Frame Trace for internal ast_frame debugging." , .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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_datastore_info | frame_trace_datastore |
static struct ast_custom_function | frame_trace_function |
struct { | |
const char * str | |
enum ast_frame_type type | |
} | frametype2str [] |
Definition in file func_frame_trace.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 364 of file func_frame_trace.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 364 of file func_frame_trace.c.
static void datastore_destroy_cb | ( | void * | data | ) | [static] |
Definition at line 100 of file func_frame_trace.c.
References ast_free.
00100 { 00101 ast_free(data); 00102 }
static int frame_trace_helper | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 145 of file func_frame_trace.c.
References ARRAY_LEN, ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), ast_framehook_attach(), ast_framehook_detach(), AST_FRAMEHOOK_INTERFACE_VERSION, ast_datastore::data, ast_framehook_interface::data, frame_trace_datastore, frametype2str, hook_destroy_cb(), hook_event_cb(), id, str, strcasestr(), and ast_framehook_interface::version.
00146 { 00147 struct frame_trace_data *framedata; 00148 struct ast_datastore *datastore = NULL; 00149 struct ast_framehook_interface interface = { 00150 .version = AST_FRAMEHOOK_INTERFACE_VERSION, 00151 .event_cb = hook_event_cb, 00152 .destroy_cb = hook_destroy_cb, 00153 }; 00154 int i = 0; 00155 00156 if (!(framedata = ast_calloc(1, sizeof(*framedata)))) { 00157 return 0; 00158 } 00159 00160 interface.data = framedata; 00161 00162 if (!strcasecmp(data, "black")) { 00163 framedata->list_type = 1; 00164 } 00165 for (i = 0; i < ARRAY_LEN(frametype2str); i++) { 00166 if (strcasestr(value, frametype2str[i].str)) { 00167 framedata->values[i] = 1; 00168 } 00169 } 00170 00171 ast_channel_lock(chan); 00172 i = ast_framehook_attach(chan, &interface); 00173 if (i >= 0) { 00174 int *id; 00175 if ((datastore = ast_channel_datastore_find(chan, &frame_trace_datastore, NULL))) { 00176 id = datastore->data; 00177 ast_framehook_detach(chan, *id); 00178 ast_channel_datastore_remove(chan, datastore); 00179 } 00180 00181 if (!(datastore = ast_datastore_alloc(&frame_trace_datastore, NULL))) { 00182 ast_framehook_detach(chan, i); 00183 ast_channel_unlock(chan); 00184 return 0; 00185 } 00186 00187 if (!(id = ast_calloc(1, sizeof(int)))) { 00188 ast_datastore_free(datastore); 00189 ast_framehook_detach(chan, i); 00190 ast_channel_unlock(chan); 00191 return 0; 00192 } 00193 00194 *id = i; /* Store off the id. The channel is still locked so it is safe to access this ptr. */ 00195 datastore->data = id; 00196 ast_channel_datastore_add(chan, datastore); 00197 } 00198 ast_channel_unlock(chan); 00199 00200 return 0; 00201 }
static void hook_destroy_cb | ( | void * | framedata | ) | [static] |
Definition at line 109 of file func_frame_trace.c.
References ast_free.
Referenced by frame_trace_helper().
00110 { 00111 ast_free(framedata); 00112 }
static struct ast_frame* hook_event_cb | ( | struct ast_channel * | chan, | |
struct ast_frame * | frame, | |||
enum ast_framehook_event | event, | |||
void * | data | |||
) | [static] |
Definition at line 114 of file func_frame_trace.c.
References ARRAY_LEN, AST_FRAMEHOOK_EVENT_READ, AST_FRAMEHOOK_EVENT_WRITE, ast_verbose, ast_frame::frametype, frametype2str, frame_trace_data::list_type, ast_channel::name, print_frame(), show_frame(), and frame_trace_data::values.
Referenced by frame_trace_helper().
00115 { 00116 int i; 00117 int show_frame = 0; 00118 struct frame_trace_data *framedata = data; 00119 if (!frame) { 00120 return frame; 00121 } 00122 00123 if ((event != AST_FRAMEHOOK_EVENT_WRITE) && (event != AST_FRAMEHOOK_EVENT_READ)) { 00124 return frame; 00125 } 00126 00127 for (i = 0; i < ARRAY_LEN(frametype2str); i++) { 00128 if (frame->frametype == frametype2str[i].type) { 00129 if ((framedata->list_type == 0) && (framedata->values[i])) { /* white list */ 00130 show_frame = 1; 00131 } else if ((framedata->list_type == 1) && (!framedata->values[i])){ /* black list */ 00132 show_frame = 1; 00133 } 00134 break; 00135 } 00136 } 00137 00138 if (show_frame) { 00139 ast_verbose("%s on Channel %s\n", event == AST_FRAMEHOOK_EVENT_READ ? "<--Read" : "--> Write", chan->name); 00140 print_frame(frame); 00141 } 00142 return frame; 00143 }
static int load_module | ( | void | ) | [static] |
Definition at line 358 of file func_frame_trace.c.
References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and frame_trace_function.
00359 { 00360 int res = ast_custom_function_register(&frame_trace_function); 00361 return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; 00362 }
static void print_frame | ( | struct ast_frame * | frame | ) | [static] |
Definition at line 203 of file func_frame_trace.c.
References _XXX_AST_CONTROL_T38, AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_getformatname(), ast_strlen_zero(), ast_verbose, ast_frame_subclass::codec, ast_frame::datalen, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, ast_frame::samples, ast_frame::src, and ast_frame::subclass.
Referenced by hook_event_cb().
00204 { 00205 switch (frame->frametype) { 00206 case AST_FRAME_DTMF_END: 00207 ast_verbose("FrameType: DTMF END\n"); 00208 ast_verbose("Digit: %d\n", frame->subclass.integer); 00209 break; 00210 case AST_FRAME_VOICE: 00211 ast_verbose("FrameType: VOICE\n"); 00212 ast_verbose("Codec: %s\n", ast_getformatname(frame->subclass.codec)); 00213 ast_verbose("MS: %ld\n", frame->len); 00214 ast_verbose("Samples: %d\n", frame->samples); 00215 ast_verbose("Bytes: %d\n", frame->datalen); 00216 break; 00217 case AST_FRAME_VIDEO: 00218 ast_verbose("FrameType: VIDEO\n"); 00219 ast_verbose("Codec: %s\n", ast_getformatname(frame->subclass.codec)); 00220 ast_verbose("MS: %ld\n", frame->len); 00221 ast_verbose("Samples: %d\n", frame->samples); 00222 ast_verbose("Bytes: %d\n", frame->datalen); 00223 break; 00224 case AST_FRAME_CONTROL: 00225 ast_verbose("FrameType: CONTROL\n"); 00226 switch (frame->subclass.integer) { 00227 case AST_CONTROL_HANGUP: 00228 ast_verbose("SubClass: HANGUP\n"); 00229 break; 00230 case AST_CONTROL_RING: 00231 ast_verbose("SubClass: RING\n"); 00232 break; 00233 case AST_CONTROL_RINGING: 00234 ast_verbose("SubClass: RINGING\n"); 00235 break; 00236 case AST_CONTROL_ANSWER: 00237 ast_verbose("SubClass: ANSWER\n"); 00238 break; 00239 case AST_CONTROL_BUSY: 00240 ast_verbose("SubClass: BUSY\n"); 00241 break; 00242 case AST_CONTROL_TAKEOFFHOOK: 00243 ast_verbose("SubClass: TAKEOFFHOOK\n"); 00244 break; 00245 case AST_CONTROL_OFFHOOK: 00246 ast_verbose("SubClass: OFFHOOK\n"); 00247 break; 00248 case AST_CONTROL_CONGESTION: 00249 ast_verbose("SubClass: CONGESTION\n"); 00250 break; 00251 case AST_CONTROL_FLASH: 00252 ast_verbose("SubClass: FLASH\n"); 00253 break; 00254 case AST_CONTROL_WINK: 00255 ast_verbose("SubClass: WINK\n"); 00256 break; 00257 case AST_CONTROL_OPTION: 00258 ast_verbose("SubClass: OPTION\n"); 00259 break; 00260 case AST_CONTROL_RADIO_KEY: 00261 ast_verbose("SubClass: RADIO KEY\n"); 00262 break; 00263 case AST_CONTROL_RADIO_UNKEY: 00264 ast_verbose("SubClass: RADIO UNKEY\n"); 00265 break; 00266 case AST_CONTROL_PROGRESS: 00267 ast_verbose("SubClass: PROGRESS\n"); 00268 break; 00269 case AST_CONTROL_PROCEEDING: 00270 ast_verbose("SubClass: PROCEEDING\n"); 00271 break; 00272 case AST_CONTROL_HOLD: 00273 ast_verbose("SubClass: HOLD\n"); 00274 break; 00275 case AST_CONTROL_UNHOLD: 00276 ast_verbose("SubClass: UNHOLD\n"); 00277 break; 00278 case AST_CONTROL_VIDUPDATE: 00279 ast_verbose("SubClass: VIDUPDATE\n"); 00280 break; 00281 case _XXX_AST_CONTROL_T38: 00282 ast_verbose("SubClass: XXX T38\n"); 00283 break; 00284 case AST_CONTROL_SRCUPDATE: 00285 ast_verbose("SubClass: SRCUPDATE\n"); 00286 break; 00287 case AST_CONTROL_TRANSFER: 00288 ast_verbose("SubClass: TRANSFER\n"); 00289 break; 00290 case AST_CONTROL_CONNECTED_LINE: 00291 ast_verbose("SubClass: CONNECTED LINE\n"); 00292 break; 00293 case AST_CONTROL_REDIRECTING: 00294 ast_verbose("SubClass: REDIRECTING\n"); 00295 break; 00296 case AST_CONTROL_T38_PARAMETERS: 00297 ast_verbose("SubClass: T38 PARAMETERS\n"); 00298 break; 00299 case AST_CONTROL_CC: 00300 ast_verbose("SubClass: CC\n"); 00301 break; 00302 case AST_CONTROL_SRCCHANGE: 00303 ast_verbose("SubClass: SRCCHANGE\n"); 00304 break; 00305 case AST_CONTROL_READ_ACTION: 00306 ast_verbose("SubClass: READ ACTION\n"); 00307 break; 00308 case AST_CONTROL_AOC: 00309 ast_verbose("SubClass: AOC\n"); 00310 break; 00311 } 00312 if (frame->subclass.integer == -1) { 00313 ast_verbose("SubClass: %d\n", frame->subclass.integer); 00314 } 00315 ast_verbose("Bytes: %d\n", frame->datalen); 00316 break; 00317 case AST_FRAME_NULL: 00318 ast_verbose("FrameType: NULL\n"); 00319 break; 00320 case AST_FRAME_IAX: 00321 ast_verbose("FrameType: IAX\n"); 00322 break; 00323 case AST_FRAME_TEXT: 00324 ast_verbose("FrameType: TXT\n"); 00325 break; 00326 case AST_FRAME_IMAGE: 00327 ast_verbose("FrameType: IMAGE\n"); 00328 break; 00329 case AST_FRAME_HTML: 00330 ast_verbose("FrameType: HTML\n"); 00331 break; 00332 case AST_FRAME_CNG: 00333 ast_verbose("FrameType: CNG\n"); 00334 break; 00335 case AST_FRAME_MODEM: 00336 ast_verbose("FrameType: MODEM\n"); 00337 break; 00338 case AST_FRAME_DTMF_BEGIN: 00339 ast_verbose("FrameType: DTMF BEGIN\n"); 00340 ast_verbose("Digit: %d\n", frame->subclass.integer); 00341 break; 00342 } 00343 00344 ast_verbose("Src: %s\n", ast_strlen_zero(frame->src) ? "NOT PRESENT" : frame->src); 00345 ast_verbose("\n"); 00346 }
static int unload_module | ( | void | ) | [static] |
Definition at line 353 of file func_frame_trace.c.
References ast_custom_function_unregister(), and frame_trace_function.
00354 { 00355 return ast_custom_function_unregister(&frame_trace_function); 00356 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Frame Trace for internal ast_frame debugging." , .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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 364 of file func_frame_trace.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 364 of file func_frame_trace.c.
struct ast_datastore_info frame_trace_datastore [static] |
Initial value:
{ .type = "frametrace", .destroy = datastore_destroy_cb }
Definition at line 104 of file func_frame_trace.c.
Referenced by frame_trace_helper().
struct ast_custom_function frame_trace_function [static] |
Initial value:
{ .name = "FRAME_TRACE", .write = frame_trace_helper, }
Definition at line 348 of file func_frame_trace.c.
Referenced by load_module(), and unload_module().
struct { ... } frametype2str[] [static] |
Referenced by frame_trace_helper(), and hook_event_cb().
const char* str |
Definition at line 79 of file func_frame_trace.c.
enum ast_frame_type type |
Definition at line 78 of file func_frame_trace.c.