#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/cdr.h"
Go to the source code of this file.
Enumerations | |
enum | cdr_option_flags { OPT_RECURSIVE = (1 << 0), OPT_UNPARSED = (1 << 1), OPT_LAST = (1 << 2), OPT_SKIPLOCKED = (1 << 3), OPT_FLOAT = (1 << 4) } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | cdr_read (struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len) |
static int | cdr_write (struct ast_channel *chan, const char *cmd, char *parse, const char *value) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Call Detail Record (CDR) dialplan function" , .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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_app_option | cdr_func_options [128] = { [ 'f' ] = { .flag = OPT_FLOAT }, [ 'l' ] = { .flag = OPT_LAST }, [ 'r' ] = { .flag = OPT_RECURSIVE }, [ 's' ] = { .flag = OPT_SKIPLOCKED }, [ 'u' ] = { .flag = OPT_UNPARSED },} |
static struct ast_custom_function | cdr_function |
Definition in file func_cdr.c.
enum cdr_option_flags |
Definition at line 179 of file func_cdr.c.
00179 { 00180 OPT_RECURSIVE = (1 << 0), 00181 OPT_UNPARSED = (1 << 1), 00182 OPT_LAST = (1 << 2), 00183 OPT_SKIPLOCKED = (1 << 3), 00184 OPT_FLOAT = (1 << 4), 00185 };
static void __reg_module | ( | void | ) | [static] |
Definition at line 328 of file func_cdr.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 328 of file func_cdr.c.
static int cdr_read | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | parse, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 195 of file func_cdr.c.
References args, AST_APP_ARG, ast_app_parse_options(), AST_CDR_FLAG_LOCKED, ast_cdr_getvar(), ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_test_flag, ast_tvdiff_us(), ast_tvnow(), ast_tvzero(), ast_channel::cdr, cdr_func_options, ast_cdr::flags, ast_flags::flags, ast_cdr::next, OPT_FLOAT, OPT_LAST, OPT_RECURSIVE, OPT_SKIPLOCKED, and OPT_UNPARSED.
00197 { 00198 char *ret; 00199 struct ast_flags flags = { 0 }; 00200 struct ast_cdr *cdr; 00201 AST_DECLARE_APP_ARGS(args, 00202 AST_APP_ARG(variable); 00203 AST_APP_ARG(options); 00204 ); 00205 00206 if (ast_strlen_zero(parse) || !chan) 00207 return -1; 00208 00209 ast_channel_lock(chan); 00210 cdr = chan->cdr; 00211 if (!cdr) { 00212 ast_channel_unlock(chan); 00213 return -1; 00214 } 00215 00216 AST_STANDARD_APP_ARGS(args, parse); 00217 00218 if (!ast_strlen_zero(args.options)) 00219 ast_app_parse_options(cdr_func_options, &flags, NULL, args.options); 00220 00221 if (ast_test_flag(&flags, OPT_LAST)) 00222 while (cdr->next) 00223 cdr = cdr->next; 00224 00225 if (ast_test_flag(&flags, OPT_SKIPLOCKED)) 00226 while (ast_test_flag(cdr, AST_CDR_FLAG_LOCKED) && cdr->next) 00227 cdr = cdr->next; 00228 00229 if (!strcasecmp("billsec", args.variable) && ast_test_flag(&flags, OPT_FLOAT)) { 00230 if (!ast_tvzero(cdr->answer)) { 00231 double hrtime; 00232 00233 if(!ast_tvzero(cdr->end)) 00234 hrtime = (double)(ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0); 00235 else 00236 hrtime = (double)(ast_tvdiff_us(ast_tvnow(), cdr->answer) / 1000000.0); 00237 00238 snprintf(buf, len, "%lf", hrtime); 00239 } else { 00240 snprintf(buf, len, "%lf", 0.0); 00241 } 00242 ret = buf; 00243 } else if (!strcasecmp("duration", args.variable) && ast_test_flag(&flags, OPT_FLOAT)) { 00244 double hrtime; 00245 00246 if(!ast_tvzero(cdr->end)) 00247 hrtime = (double)(ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0); 00248 else 00249 hrtime = (double)(ast_tvdiff_us(ast_tvnow(), cdr->start) / 1000000.0); 00250 00251 snprintf(buf, len, "%lf", hrtime); 00252 00253 if (!ast_strlen_zero(buf)) { 00254 ret = buf; 00255 } 00256 } else { 00257 ast_cdr_getvar(cdr, args.variable, &ret, buf, len, 00258 ast_test_flag(&flags, OPT_RECURSIVE), 00259 ast_test_flag(&flags, OPT_UNPARSED)); 00260 } 00261 00262 ast_channel_unlock(chan); 00263 return ret ? 0 : -1; 00264 }
static int cdr_write | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | parse, | |||
const char * | value | |||
) | [static] |
Definition at line 266 of file func_cdr.c.
References args, AST_APP_ARG, ast_app_parse_options(), ast_cdr_setaccount(), ast_cdr_setamaflags(), ast_cdr_setpeeraccount(), ast_cdr_setuserfield(), ast_cdr_setvar(), ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_test_flag, ast_channel::cdr, cdr_func_options, ast_flags::flags, ast_cdr::next, OPT_LAST, and OPT_RECURSIVE.
00268 { 00269 struct ast_cdr *cdr; 00270 struct ast_flags flags = { 0 }; 00271 AST_DECLARE_APP_ARGS(args, 00272 AST_APP_ARG(variable); 00273 AST_APP_ARG(options); 00274 ); 00275 00276 if (ast_strlen_zero(parse) || !value || !chan) 00277 return -1; 00278 00279 ast_channel_lock(chan); 00280 cdr = chan->cdr; 00281 if (!cdr) { 00282 ast_channel_unlock(chan); 00283 return -1; 00284 } 00285 00286 AST_STANDARD_APP_ARGS(args, parse); 00287 00288 if (!ast_strlen_zero(args.options)) 00289 ast_app_parse_options(cdr_func_options, &flags, NULL, args.options); 00290 00291 if (ast_test_flag(&flags, OPT_LAST)) 00292 while (cdr->next) 00293 cdr = cdr->next; 00294 00295 if (!strcasecmp(args.variable, "accountcode")) /* the 'l' flag doesn't apply to setting the accountcode, userfield, or amaflags */ 00296 ast_cdr_setaccount(chan, value); 00297 else if (!strcasecmp(args.variable, "peeraccount")) 00298 ast_cdr_setpeeraccount(chan, value); 00299 else if (!strcasecmp(args.variable, "userfield")) 00300 ast_cdr_setuserfield(chan, value); 00301 else if (!strcasecmp(args.variable, "amaflags")) 00302 ast_cdr_setamaflags(chan, value); 00303 else 00304 ast_cdr_setvar(cdr, args.variable, value, ast_test_flag(&flags, OPT_RECURSIVE)); 00305 /* No need to worry about the u flag, as all fields for which setting 00306 * 'u' would do anything are marked as readonly. */ 00307 00308 ast_channel_unlock(chan); 00309 return 0; 00310 }
static int load_module | ( | void | ) | [static] |
Definition at line 323 of file func_cdr.c.
References ast_custom_function_register, and cdr_function.
00324 { 00325 return ast_custom_function_register(&cdr_function); 00326 }
static int unload_module | ( | void | ) | [static] |
Definition at line 318 of file func_cdr.c.
References ast_custom_function_unregister(), and cdr_function.
00319 { 00320 return ast_custom_function_unregister(&cdr_function); 00321 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Call Detail Record (CDR) dialplan function" , .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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 328 of file func_cdr.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 328 of file func_cdr.c.
struct ast_app_option cdr_func_options[128] = { [ 'f' ] = { .flag = OPT_FLOAT }, [ 'l' ] = { .flag = OPT_LAST }, [ 'r' ] = { .flag = OPT_RECURSIVE }, [ 's' ] = { .flag = OPT_SKIPLOCKED }, [ 'u' ] = { .flag = OPT_UNPARSED },} [static] |
struct ast_custom_function cdr_function [static] |
Initial value:
Definition at line 312 of file func_cdr.c.
Referenced by load_module(), and unload_module().