224 struct timeval time = { 0 };
238 if (sscanf(tempbuf,
"%ld.%ld", &tv_sec, &tv_usec) == 2) {
239 time.tv_sec = tv_sec;
240 time.tv_usec = tv_usec;
266 output = payload->
data;
271 payload->
cmd, payload->
cmd);
294 && (!strcasecmp(
"billsec",
args.variable) || !strcasecmp(
"duration",
args.variable))) {
308 snprintf(tempbuf,
sizeof(tempbuf),
"%lf", delta);
311 if (!strcasecmp(
"start",
args.variable)
312 || !strcasecmp(
"end",
args.variable)
313 || !strcasecmp(
"answer",
args.variable)) {
314 struct timeval fmt_time;
320 if (sscanf(tempbuf,
"%ld.%ld", &tv_sec, &tv_usec) != 2) {
326 fmt_time.tv_sec = tv_sec;
327 fmt_time.tv_usec = tv_usec;
329 ast_strftime(tempbuf,
sizeof(tempbuf),
"%Y-%m-%d %T", &tm);
333 }
else if (!strcasecmp(
"disposition",
args.variable)) {
336 if (sscanf(tempbuf,
"%8d", &disposition) != 1) {
342 }
else if (!strcasecmp(
"amaflags",
args.variable)) {
345 if (sscanf(tempbuf,
"%8d", &amaflags) != 1) {
375 || !payload->
value) {
390 && strcasecmp(
args.variable,
"peeraccount")
391 && strcasecmp(
args.variable,
"amaflags"));
393 if (!strcasecmp(
args.variable,
"userfield")) {
420 payload->
cmd, payload->
cmd);
425 payload->
cmd, payload->
cmd);
431 if (!strcasecmp(
"party_a",
args.variable)) {
433 }
else if (!strcasecmp(
"disable",
args.variable)) {
460 if (!cdr_read_message_type()) {
470 payload->chan =
chan;
472 payload->arguments =
parse;
473 payload->data = &output;
537 if (!strcasecmp(
args.variable,
"accountcode")) {
538 ast_log(
LOG_WARNING,
"Using the %s function to set 'accountcode' is deprecated. Please use the CHANNEL function instead.\n",
541 ast_channel_accountcode_set(chan, value);
545 if (!strcasecmp(
args.variable,
"amaflags")) {
548 ast_log(
LOG_WARNING,
"Using the %s function to set 'amaflags' is deprecated. Please use the CHANNEL function instead.\n",
550 if (isdigit(*value)) {
551 if (sscanf(value,
"%30d", &amaflags) != 1) {
562 if (!strcasecmp(
args.variable,
"peeraccount")) {
563 ast_log(
LOG_WARNING,
"The 'peeraccount' setting is not supported. Please set the 'accountcode' on the appropriate channel using the CHANNEL function.\n");
568 if (!cdr_write_message_type()) {
569 ast_log(
LOG_WARNING,
"Failed to manipulate CDR for channel %s: message type not available\n",
586 ast_log(
LOG_WARNING,
"Failed to manipulate CDR for channel %s: unable to create message\n",
622 if (!cdr_prop_write_message_type()) {
632 payload->chan =
chan;
634 payload->arguments =
parse;
635 payload->value =
value;
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
int ast_cdr_setvar(const char *channel_name, const char *name, const char *value)
Set a variable on a CDR.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
static struct timeval cdr_retrieve_time(struct ast_channel *chan, const char *time_name)
static int cdr_write(struct ast_channel *chan, const char *cmd, char *arguments, const char *value)
#define ast_test_flag(p, flag)
static int unload_module(void)
static struct stasis_message_router * router
static struct ast_custom_function cdr_prop_function
int ast_cdr_getvar(const char *channel_name, const char *name, char *value, size_t length)
Retrieve a CDR variable from a channel's current CDR.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
#define ast_set_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
static const struct ast_app_option cdr_func_options[128]
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
void stasis_message_router_publish_sync(struct stasis_message_router *router, struct stasis_message *message)
Publish a message to a message router's subscription synchronously.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
ast_cdr_options
CDR manipulation options. Certain function calls will manipulate the state of a CDR object based on t...
static int cdr_prop_write(struct ast_channel *chan, const char *cmd, char *parse, const char *value)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define ast_strlen_zero(foo)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
static void cdr_prop_write_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
void ast_cdr_format_var(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int raw)
Format a CDR variable from an already posted CDR.
struct stasis_message_router * ast_cdr_message_router(void)
Return the message router for the CDR engine.
General Asterisk PBX channel definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Data structure associated with a custom dialplan function.
#define ao2_ref(o, delta)
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Core PBX routines and definitions.
int ast_cdr_set_property(const char *channel_name, enum ast_cdr_options option)
Set a property on a CDR for a channel.
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_message_router_remove(struct stasis_message_router *router, struct stasis_message_type *message_type)
Remove a route from a message router.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ao2_alloc(data_size, destructor_fn)
STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_read_message_type)
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
struct ast_channel * chan
Module has failed to load, may be in an inconsistent state.
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
void ast_cdr_setuserfield(const char *channel_name, const char *userfield)
Set CDR user field for channel (stored in CDR)
Structure used to handle boolean flags.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static void cdr_read_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
const char * ast_channel_name(const struct ast_channel *chan)
struct stasis_forward * sub
int ast_cdr_clear_property(const char *channel_name, enum ast_cdr_options option)
Clear a property on a CDR for a channel.
static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
static void cdr_write_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
static int load_module(void)
static struct ast_custom_function cdr_function
#define AST_APP_ARG(name)
Define an application argument.