189 #define DEFAULT_ENABLED "1" 190 #define DEFAULT_BATCHMODE "0" 191 #define DEFAULT_UNANSWERED "0" 192 #define DEFAULT_CONGESTION "0" 193 #define DEFAULT_END_BEFORE_H_EXTEN "1" 194 #define DEFAULT_INITIATED_SECONDS "0" 196 #define DEFAULT_BATCH_SIZE "100" 197 #define MAX_BATCH_SIZE 1000 198 #define DEFAULT_BATCH_TIME "300" 199 #define MAX_BATCH_TIME 86400 200 #define DEFAULT_BATCH_SCHEDULER_ONLY "0" 201 #define DEFAULT_BATCH_SAFE_SHUTDOWN "1" 203 #define cdr_set_debug_mode(mod_cfg) \ 205 cdr_debug_enabled = ast_test_flag(&(mod_cfg)->general->settings, CDR_DEBUG); \ 210 #define CDR_DEBUG(fmt, ...) \ 212 if (cdr_debug_enabled) { \ 213 ast_verbose((fmt), ##__VA_ARGS__); \ 234 .category =
"general",
266 .types =
ACO_TYPES(&general_option, &ignore_option),
483 const char *dial_status);
519 int (*
const process_parking_bridge_enter)(
struct cdr_object *cdr,
638 .
name =
"DialedPending",
718 struct timeval start;
721 struct timeval lastevent;
806 CDR_DEBUG(
"%p - Transitioning CDR for %s from state %s to %s\n",
858 const char *right_key = arg;
866 cmp = strcmp(left->
uniqueid, right_key);
873 cmp = strncmp(left->
uniqueid, right_key, strlen(right_key));
916 const char *right_key = arg;
931 cmp = strncasecmp(left->
party_b_name, right_key, strlen(right_key));
982 for (cur = cdr; cur; cur =
next) {
1081 cdr_last = cdr->
last;
1107 for (it_cdr = cdr; it_cdr->
next; it_cdr = it_cdr->
next) {
1108 it_cdr->
last = new_cdr;
1110 it_cdr->
last = new_cdr;
1111 it_cdr->
next = new_cdr;
1162 && strncasecmp(new_snapshot->
dialplan->
appl,
"appdial", 7)
1244 if (ms % 1000 >= 500
1246 ms = (ms / 1000) + 1;
1295 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
1300 ast_debug(1,
"CDR for %s is dialed and has no Party B; discarding\n",
1342 cdr_copy->
end = it_cdr->
end;
1372 cdr_prev->
next = cdr_copy;
1373 cdr_prev = cdr_copy;
1390 CDR_DEBUG(
"%p - Dispatching CDR for Party A %s, Party B %s\n", cdr,
1405 switch (hangupcause) {
1460 ast_debug(1,
"Finalized CDR for %s - start %ld.%06ld answer %ld.%06ld end %ld.%06ld dur %.3f bill %.3f dispo %s\n",
1462 (
long)cdr->
start.tv_sec,
1463 (
long)cdr->
start.tv_usec,
1464 (
long)cdr->
answer.tv_sec,
1465 (
long)cdr->
answer.tv_usec,
1466 (
long)cdr->
end.tv_sec,
1467 (
long)cdr->
end.tv_usec,
1485 && cdr->
fn_table != &finalized_state_fn_table) {
1499 CDR_DEBUG(
"%p - Set answered time to %ld.%06ld\n", cdr,
1500 (
long)cdr->
answer.tv_sec,
1501 (
long)cdr->
answer.tv_usec);
1619 char park_info[128];
1657 CDR_DEBUG(
"%p - Updated Party A %s snapshot\n", cdr,
1661 CDR_DEBUG(
"%p - Updated Party B %s snapshot\n", cdr,
1672 CDR_DEBUG(
"%p - Updated Party A %s snapshot\n", cdr,
1705 CDR_DEBUG(
"%p - Party A %s has new Party B %s\n",
1726 CDR_DEBUG(
"%p - Party A %s has new Party B %s\n",
1757 if (!cand_cdr_master) {
1762 for (cand_cdr = cand_cdr_master; cand_cdr; cand_cdr = cand_cdr->
next) {
1765 if (cand_cdr->
fn_table != &bridge_state_fn_table ||
1830 if (!strcmp(dial_status,
"ANSWER")) {
1832 }
else if (!strcmp(dial_status,
"BUSY")) {
1834 }
else if (!strcmp(dial_status,
"CANCEL") || !strcmp(dial_status,
"NOANSWER")) {
1836 }
else if (!strcmp(dial_status,
"CONGESTION")) {
1842 }
else if (!strcmp(dial_status,
"FAILED")) {
1905 if (!cand_cdr_master) {
1910 for (cand_cdr = cand_cdr_master; cand_cdr; cand_cdr = cand_cdr->
next) {
1913 if (cand_cdr->
fn_table != &bridge_state_fn_table
2091 return (strcmp(dialstatus,
"RINGING") &&
2092 strcmp(dialstatus,
"PROCEEDING") &&
2093 strcmp(dialstatus,
"PROGRESS"));
2113 const char *dial_status =
NULL;
2118 if (!peer && !caller) {
2131 if (dial_status_blob) {
2135 CDR_DEBUG(
"Dial %s message for %s, %s: %u.%08u\n",
2137 caller ? caller->
base->
name :
"(none)",
2138 peer ? peer->
base->
name :
"(none)",
2155 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2161 CDR_DEBUG(
"%p - Processing Dial Begin message for channel %s, peer %s\n",
2163 caller ? caller->
base->
name :
"(none)",
2164 peer ? peer->
base->
name :
"(none)");
2172 CDR_DEBUG(
"%p - Processing Dial End message for channel %s, peer %s\n",
2174 caller ? caller->
base->
name :
"(none)",
2175 peer ? peer->
base->
name :
"(none)");
2236 "CDR for Party A %s(%s) has inconsistent Party B %s name. Message can be ignored but this shouldn't happen.\n",
2307 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2329 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2366 if (cdr->
fn_table == &bridge_state_fn_table
2391 if (!strcmp(bridge->
technology,
"holding_bridge") && strcmp(bridge->
subclass,
"parking")) {
2417 int left_bridge = 0;
2427 CDR_DEBUG(
"Bridge Leave message for %s: %u.%08u\n",
2429 (
unsigned int)leave_data.
lastevent->tv_sec,
2430 (
unsigned int)leave_data.
lastevent->tv_usec);
2441 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2446 CDR_DEBUG(
"%p - Processing Bridge Leave for %s\n",
2457 && strcmp(bridge->
subclass,
"parking")) {
2486 CDR_DEBUG(
"%p - Party A %s has new Party B %s\n",
2510 for (cand_cdr = base_cand_cdr; cand_cdr; cand_cdr = cand_cdr->
next) {
2537 CDR_DEBUG(
"%p - Party A %s has new Party B %s\n",
2546 memset(&cand_cdr->
end, 0,
sizeof(cand_cdr->
end));
2589 const struct timeval *event_time)
2597 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2604 CDR_DEBUG(
"%p - Updating Party A %s snapshot\n", it_cdr,
2630 const struct timeval *event_time)
2640 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2644 CDR_DEBUG(
"%p - Updating Party A %s snapshot\n", it_cdr,
2651 CDR_DEBUG(
"%p - Processing bridge enter for %s\n", it_cdr,
2659 handled_cdr = it_cdr;
2670 handled_cdr = it_cdr;
2724 CDR_DEBUG(
"Bridge Enter message for channel %s: %u.%08u\n",
2736 if (!strcmp(bridge->
subclass,
"parking")) {
2774 CDR_DEBUG(
"Parked Call message for channel %s: %u.%08u\n",
2788 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
2873 if (!strcasecmp(name, i->
name)) {
2891 if (!strcasecmp(name, i->
name)) {
2928 if (!strcasecmp(name, cur->
name)) {
2960 if (!strcasecmp(name, match->
name)) {
2972 if (!match->suspended && active_count != 0) {
2975 name, active_count);
2982 ast_verb(2,
"Unregistered '%s' CDR backend\n", name);
3035 static void cdr_get_tv(
struct timeval when,
const char *fmt,
char *
buf,
int bufsize)
3038 snprintf(buf, bufsize,
"%ld.%06ld", (
long)when.tv_sec, (
long)when.tv_usec);
3052 const char *fmt =
"%Y-%m-%d %T";
3061 if (!strcasecmp(name,
"clid")) {
3063 }
else if (!strcasecmp(name,
"src")) {
3065 }
else if (!strcasecmp(name,
"dst")) {
3067 }
else if (!strcasecmp(name,
"dcontext")) {
3069 }
else if (!strcasecmp(name,
"channel")) {
3071 }
else if (!strcasecmp(name,
"dstchannel")) {
3073 }
else if (!strcasecmp(name,
"lastapp")) {
3075 }
else if (!strcasecmp(name,
"lastdata")) {
3077 }
else if (!strcasecmp(name,
"start")) {
3079 }
else if (!strcasecmp(name,
"answer")) {
3081 }
else if (!strcasecmp(name,
"end")) {
3083 }
else if (!strcasecmp(name,
"duration")) {
3085 }
else if (!strcasecmp(name,
"billsec")) {
3087 }
else if (!strcasecmp(name,
"disposition")) {
3089 snprintf(workspace, workspacelen,
"%ld", cdr->
disposition);
3093 }
else if (!strcasecmp(name,
"amaflags")) {
3095 snprintf(workspace, workspacelen,
"%ld", cdr->
amaflags);
3099 }
else if (!strcasecmp(name,
"accountcode")) {
3101 }
else if (!strcasecmp(name,
"peeraccount")) {
3103 }
else if (!strcasecmp(name,
"uniqueid")) {
3105 }
else if (!strcasecmp(name,
"linkedid")) {
3107 }
else if (!strcasecmp(name,
"userfield")) {
3109 }
else if (!strcasecmp(name,
"sequence")) {
3110 snprintf(workspace, workspacelen,
"%d", cdr->
sequence);
3114 workspace[0] =
'\0';
3129 const char *
name = arg;
3145 const char *
name = arg;
3186 for (x = 0; cdr_readonly_vars[x]; x++) {
3187 if (!strcasecmp(name, cdr_readonly_vars[x])) {
3201 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
3204 if (it_cdr->
fn_table == &finalized_state_fn_table && it_cdr->
next !=
NULL) {
3248 if (!strcasecmp(name,
"clid")) {
3250 }
else if (!strcasecmp(name,
"src")) {
3252 }
else if (!strcasecmp(name,
"dst")) {
3254 }
else if (!strcasecmp(name,
"dcontext")) {
3256 }
else if (!strcasecmp(name,
"channel")) {
3258 }
else if (!strcasecmp(name,
"dstchannel")) {
3264 }
else if (!strcasecmp(name,
"lastapp")) {
3266 }
else if (!strcasecmp(name,
"lastdata")) {
3268 }
else if (!strcasecmp(name,
"start")) {
3270 }
else if (!strcasecmp(name,
"answer")) {
3272 }
else if (!strcasecmp(name,
"end")) {
3274 }
else if (!strcasecmp(name,
"duration")) {
3276 }
else if (!strcasecmp(name,
"billsec")) {
3278 }
else if (!strcasecmp(name,
"disposition")) {
3279 snprintf(value, length,
"%u", cdr_obj->
disposition);
3280 }
else if (!strcasecmp(name,
"amaflags")) {
3281 snprintf(value, length,
"%d", party_a->
amaflags);
3282 }
else if (!strcasecmp(name,
"accountcode")) {
3284 }
else if (!strcasecmp(name,
"peeraccount")) {
3290 }
else if (!strcasecmp(name,
"uniqueid")) {
3292 }
else if (!strcasecmp(name,
"linkedid")) {
3294 }
else if (!strcasecmp(name,
"userfield")) {
3296 }
else if (!strcasecmp(name,
"sequence")) {
3297 snprintf(value, length,
"%u", cdr_obj->
sequence);
3341 cdr_obj = cdr->
last;
3359 char workspace[256];
3360 int total = 0, x = 0, i;
3373 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
3391 for (i = 0; cdr_readonly_vars[i]; i++) {
3399 &&
ast_str_append(buf, 0,
"level %d: %s%c%s%c", x, cdr_readonly_vars[i], delim, workspace, sep) < 0) {
3432 switch (disposition) {
3444 return "CONGESTION";
3459 if ((cdr->
fn_table != &finalized_state_fn_table || !cdr->
next)
3490 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
3491 if (it_cdr->
fn_table == &finalized_state_fn_table && it_cdr->
next !=
NULL) {
3518 for (; cdr ; cdr = cdr->
next) {
3523 ast_debug(1,
"Skipping CDR for %s since we weren't answered\n", cdr->
channel);
3539 if (!i->suspended) {
3559 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
3560 if (it_cdr->
fn_table == &finalized_state_fn_table) {
3586 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
3587 if (it_cdr->
fn_table == &finalized_state_fn_table) {
3610 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
3612 if (!keep_variables) {
3624 memset(&it_cdr->
start, 0,
sizeof(it_cdr->
start));
3625 memset(&it_cdr->
end, 0,
sizeof(it_cdr->
end));
3652 cdr_obj = cdr->
last;
3653 if (cdr_obj->
fn_table == &finalized_state_fn_table) {
3713 for (it_cdr = cdr; it_cdr != new_cdr; it_cdr = it_cdr->
next) {
3714 if (it_cdr->
fn_table == &finalized_state_fn_table) {
3758 processeditem = batchitem;
3759 batchitem = batchitem->
next;
3790 ast_debug(1,
"CDR single-threaded batch processing begins now\n");
3794 ast_log(
LOG_WARNING,
"CDR processing thread could not detach, now trying in this thread\n");
3797 ast_debug(1,
"CDR multi-threaded batch processing begins now\n");
3846 int submit_batch = 0;
3867 ast_debug(1,
"CDR detaching from this thread\n");
3870 if (!(newtail =
ast_calloc(1,
sizeof(*newtail)))) {
3892 if (curr >= (mod_cfg->general->batch_settings.size - 1)) {
3905 struct timespec timeout;
3916 timeout.tv_sec = now.tv_sec;
3917 timeout.tv_nsec = now.tv_usec * 1000;
3923 ast_debug(2,
"Processed %d CDR batches from the run queue\n", numevents);
3935 e->
command =
"cdr set debug [on|off]";
3936 e->
usage =
"Enable or disable extra debugging in the CDR Engine. Note\n" 3937 "that this will dump debug information to the VERBOSE setting\n" 3938 "and should only be used when debugging information from the\n" 3939 "CDR engine is needed.\n";
3951 ast_cli(a->
fd,
"Could not set CDR debugging mode\n");
3954 if (!strcasecmp(a->
argv[3],
"on")
3957 ast_cli(a->
fd,
"CDR debugging enabled\n");
3958 }
else if (!strcasecmp(a->
argv[3],
"off")
3961 ast_cli(a->
fd,
"CDR debugging disabled\n");
3972 int wordlen = strlen(a->
word);
3995 char start_time_buffer[64];
3996 char answer_time_buffer[64];
3997 char end_time_buffer[64];
3999 #define TITLE_STRING "%-25.25s %-25.25s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8s %-8.8s\n" 4000 #define FORMAT_STRING "%-25.25s %-25.25s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8ld %-8.8ld\n" 4003 ast_cli(a->
fd,
"Channels with Call Detail Record (CDR) Information\n");
4004 ast_cli(a->
fd,
"--------------------------------------------------\n");
4005 ast_cli(a->
fd,
TITLE_STRING,
"Channel",
"Dst. Channel",
"LastApp",
"Start",
"Answer",
"End",
"Billsec",
"Duration");
4010 struct timeval start_time = { 0, };
4011 struct timeval answer_time = { 0, };
4012 struct timeval end_time = { 0, };
4019 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
4024 start_time = it_cdr->
start;
4027 answer_time = it_cdr->
answer;
4038 cdr_get_tv(start_time,
"%T", start_time_buffer,
sizeof(start_time_buffer));
4039 cdr_get_tv(answer_time,
"%T", answer_time_buffer,
sizeof(answer_time_buffer));
4040 cdr_get_tv(end_time,
"%T", end_time_buffer,
sizeof(end_time_buffer));
4051 #undef FORMAT_STRING 4059 char start_time_buffer[64];
4060 char answer_time_buffer[64];
4061 char end_time_buffer[64];
4062 const char *channel_name = a->
argv[3];
4065 #define TITLE_STRING "%-10.10s %-20.20s %-25.25s %-15.15s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8s %-8.8s\n" 4066 #define FORMAT_STRING "%-10.10s %-20.20s %-25.25s %-15.15s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8ld %-8.8ld\n" 4070 ast_cli(a->
fd,
"Unknown channel: %s\n", channel_name);
4075 ast_cli(a->
fd,
"Call Detail Record (CDR) Information for %s\n", channel_name);
4076 ast_cli(a->
fd,
"--------------------------------------------------\n");
4077 ast_cli(a->
fd,
TITLE_STRING,
"AccountCode",
"CallerID",
"Dst. Channel",
"LastApp",
"Data",
"Start",
"Answer",
"End",
"Billsec",
"Duration");
4080 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
4092 cdr_get_tv(it_cdr->
start,
"%T", start_time_buffer,
sizeof(start_time_buffer));
4093 cdr_get_tv(it_cdr->
answer,
"%T", answer_time_buffer,
sizeof(answer_time_buffer));
4094 cdr_get_tv(end,
"%T", end_time_buffer,
sizeof(end_time_buffer));
4111 #undef FORMAT_STRING 4119 e->
command =
"cdr show active";
4121 "Usage: cdr show active [channel]\n" 4122 " Displays a summary of all Call Detail Records when [channel]\n" 4123 " is omitted; displays all of the Call Detail Records\n" 4124 " currently in flight for a given [channel] when [channel] is\n" 4126 " Note that this will not display Call Detail Records that\n" 4127 " have already been dispatched to a backend storage, nor for\n" 4128 " channels that are no longer active.\n";
4136 }
else if (a->
argc < 4) {
4150 long nextbatchtime = 0;
4154 e->
command =
"cdr show status";
4156 "Usage: cdr show status\n" 4157 " Displays the Call Detail Record engine system status.\n";
4173 ast_cli(a->
fd,
"Call Detail Record (CDR) settings\n");
4174 ast_cli(a->
fd,
"----------------------------------\n");
4181 ast_cli(a->
fd,
"* Batch Mode Settings\n");
4182 ast_cli(a->
fd,
" -------------------\n");
4189 ast_cli(a->
fd,
" Current batch size: %d record%s\n", cnt,
ESS(cnt));
4192 ast_cli(a->
fd,
" Next batch processing time: %ld second%s\n\n", nextbatchtime,
ESS(nextbatchtime));
4194 ast_cli(a->
fd,
"* Registered Backends\n");
4195 ast_cli(a->
fd,
" -------------------\n");
4201 ast_cli(a->
fd,
" %s%s\n", beitem->
name, beitem->suspended ?
" (suspended) " :
"");
4220 "Usage: cdr submit\n" 4221 "Posts all pending batched CDR data to the configured CDR\n" 4222 "backend engine modules.\n";
4237 ast_cli(a->
fd,
"Cannot submit CDR batch: CDR engine disabled.\n");
4239 ast_cli(a->
fd,
"Cannot submit CDR batch: batch mode not enabled.\n");
4242 ast_cli(a->
fd,
"Submitted CDRs to backend engines for processing. This may take a while.\n");
4266 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
4293 if (!stasis_router) {
4320 if (channel_subscription || bridge_subscription || parking_subscription) {
4325 if (!channel_subscription) {
4329 if (!bridge_subscription) {
4333 if (!parking_subscription) {
4356 aco_option_register(&cfg_info,
"size",
ACO_EXACT, general_options,
DEFAULT_BATCH_SIZE,
OPT_UINT_T,
PARSE_IN_RANGE,
FLDSET(
struct ast_cdr_config, batch_settings.size), 0,
MAX_BATCH_SIZE);
4357 aco_option_register(&cfg_info,
"time",
ACO_EXACT, general_options,
DEFAULT_BATCH_TIME,
OPT_UINT_T,
PARSE_IN_RANGE,
FLDSET(
struct ast_cdr_config, batch_settings.time), 1,
MAX_BATCH_TIME);
4388 stasis_router =
NULL;
4409 active_cdrs_master =
NULL;
4413 active_cdrs_all =
NULL;
4430 ast_log(
LOG_NOTICE,
"CDR batch mode logging enabled, first of either size %u or time %u seconds.\n",
4453 for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->
next) {
4454 prnt(where,
"Party A: %s; Party B: %s; Bridge %s\n",
4479 prnt(where,
"Party A: %s; Party B: %s; Bridge %s",
4512 return mod_cfg ? 0 : -1;
4534 if (!stasis_router) {
4553 if (!active_cdrs_master) {
4560 if (!active_cdrs_all) {
4588 if (cdr_sync_message_type()) {
4592 if (!stasis_router) {
4602 ast_debug(1,
"CDR Engine termination request received; waiting on messages...\n");
4650 .requires =
"extconfig",
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
static int base_process_party_a(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
static enum process_bridge_enter_results dialed_pending_state_process_bridge_enter(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
static struct stasis_message_router * stasis_router
Message router for stasis messages regarding channel state.
const ast_string_field data
static int cdr_object_get_by_name_cb(void *obj, void *arg, int flags)
static long cdr_object_get_billsec(struct cdr_object *cdr)
Compute the billsec for a cdr_object.
struct ao2_container * channels
static char exten[AST_MAX_EXTENSION]
char accountcode[AST_MAX_ACCOUNT_CODE]
#define AST_CLI_DEFINE(fn, txt,...)
struct ast_bridge_snapshot * bridge
static int cdr_object_update_party_b_userfield_cb(void *obj, void *arg, void *data, int flags)
Callback used to update the userfield on Party B on all CDRs.
struct ast_channel_snapshot_base * base
Asterisk locking-related definitions:
static void * module_config_alloc(void)
Create a new module config object.
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct cdr_batch_item * tail
struct varshead variables
int ast_cdr_reset(const char *channel_name, int keep_variables)
Reset the detail record.
static int cdr_master_cmp_fn(void *obj, void *arg, int flags)
static void reset_batch(void)
static void * do_batch_backend_process(void *data)
static int bridge_state_process_bridge_leave(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
struct ast_cdr_config * ast_cdr_get_config(void)
Obtain the current CDR configuration.
struct stasis_message_type * ast_channel_entered_bridge_type(void)
Message type for channel enter bridge blob messages.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
struct ast_channel_snapshot * channel
char dstchannel[AST_MAX_EXTENSION]
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
int(*const process_parked_channel)(struct cdr_object *cdr, struct ast_parked_call_payload *parking_info)
Process an update informing us that the channel got itself parked.
static void cdr_all_unlink(struct cdr_object *cdr)
#define cdr_set_debug_mode(mod_cfg)
const ast_string_field name
static void * do_cdr(void *data)
static void bridge_candidate_process(struct cdr_object *cdr, struct cdr_object *base_cand_cdr)
Process a single bridge_candidate.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
The arg parameter is a search key, but is not an object.
struct ast_flags settings
#define ast_test_flag(p, flag)
static void cdr_object_format_var_internal(struct cdr_object *cdr, const char *name, char *value, size_t length)
Format a variable on a cdr_object.
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
struct ast_channel_snapshot * snapshot
const char * ast_var_value(const struct ast_var_t *var)
static const char * ignore_categories[]
static void handle_bridge_leave_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Handler for when a channel leaves a bridge.
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.
static int is_cdr_flag_set(unsigned int cdr_flag)
int ast_cdr_set_property(const char *channel_name, enum ast_cdr_options option)
Set a property on a CDR for a channel.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
const char * ast_var_name(const struct ast_var_t *var)
struct stasis_message_type * ast_channel_left_bridge_type(void)
Message type for channel leave bridge blob messages.
#define ast_set_flag(p, flag)
static void handle_parking_bridge_enter_message(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel, const struct timeval *event_time)
Handle entering into a parking bridge.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
descriptor for a cli entry.
static void post_cdr(struct ast_cdr *cdr)
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
static void cdr_object_dtor(void *obj)
cdr_object Destructor
#define ao2_callback(c, flags, cb_fn, arg)
static int single_state_process_dial_begin(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer)
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
Structure that contains a snapshot of information about a bridge.
#define aco_option_register(info, name, matchtype, types, default_val, opt_type, flags,...)
Register a config option.
static int cdr_master_hash_fn(const void *obj, const int flags)
char dcontext[AST_MAX_EXTENSION]
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
static void destroy_subscriptions(void)
Destroy the active Stasis subscriptions.
void stasis_message_router_unsubscribe_and_join(struct stasis_message_router *router)
Unsubscribe the router from the upstream topic, blocking until the final message has been processed...
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.
#define DEFAULT_BATCH_SIZE
struct cdr_object_snapshot party_b
Structure representing a snapshot of channel state.
static char * handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int(*const process_party_a)(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
Process a Party A update for the cdr_object.
static void module_config_post_apply(void)
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
#define DEFAULT_BATCH_TIME
A wrapper object around a snapshot. Fields that are mutable by the CDR engine are replicated here...
static ast_mutex_t cdr_sched_lock
static void cdr_engine_shutdown(void)
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
#define ao2_t_replace(dst, src, tag)
Replace one object reference with another cleaning up the original.
static int cdr_debug_enabled
Assume that the ao2_container is already locked.
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
static int base_process_parked_channel(struct cdr_object *cdr, struct ast_parked_call_payload *parking_info)
static struct stasis_topic * cdr_topic
The parent topic for all topics we want to aggregate for CDRs.
static int dial_state_process_dial_end(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer, const char *dial_status)
const ast_string_field accountcode
const ast_string_field exten
static struct cdr_object * cdr_object_alloc(struct ast_channel_snapshot *chan, const struct timeval *event_time)
cdr_object constructor
#define AST_NUM_CHANNEL_BUCKETS
int(* ast_cdrbe)(struct ast_cdr *cdr)
CDR backend callback.
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
const ast_string_field uniqueid
static void set_variable(struct varshead *headp, const char *name, const char *value)
static void handle_bridge_enter_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cond_init(cond, attr)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
enum aco_process_status aco_process_config(struct aco_info *info, int reload)
Process a config info via the options registered with an aco_info.
static void handle_dial_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Handler for Stasis-Core dial messages.
#define ao2_global_obj_ref(holder)
static int submit_scheduled_batch(const void *data)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
static void bridge_state_process_party_b(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
static void cdr_object_set_disposition(struct cdr_object *cdr, int hangupcause)
Set the disposition on a cdr_object based on a hangupcause code.
static void cdr_submit_batch(int shutdown)
#define ao2_link_flags(container, obj, flags)
#define ast_mutex_lock(a)
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Type for default option handler for bools (ast_true/ast_false) that are stored in a flag...
#define ast_copy_flags(dest, src, flagz)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
A parked call message payload.
#define ast_strdup(str)
A wrapper for strdup()
static int filter_channel_snapshot(struct ast_channel_snapshot *snapshot)
static int base_process_bridge_leave(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
static int copy_variables(struct varshead *to_list, struct varshead *from_list)
Copy variables from one list to another.
static int cdr_object_select_all_by_name_cb(void *obj, void *arg, int flags)
static long cdr_object_get_duration(struct cdr_object *cdr)
The representation of a single configuration file to be processed.
void ast_cli(int fd, const char *fmt,...)
ast_cdr_options
CDR manipulation options. Certain function calls will manipulate the state of a CDR object based on t...
Structure representing a change of snapshot of channel state.
static const char cdr_config[]
struct ast_channel_snapshot * channel
enum ast_parked_call_event_type event_type
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
static int ast_cdr_generic_unregister(struct be_list *generic_list, const char *name)
#define ast_cond_signal(cond)
#define ACO_TYPES(...)
A helper macro to ensure that aco_info types always have a sentinel.
static void handle_channel_snapshot_update_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Handler for channel snapshot update messages.
struct ast_channel_snapshot_dialplan * dialplan
#define ast_pthread_create_detached_background(a, b, c, d)
#define ast_verb(level,...)
Registration object for CDR backends.
struct cdr_object_snapshot party_a
void(*const init_function)(struct cdr_object *cdr)
An initialization function. This will be called automatically when a cdr_object is switched to this t...
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
void ast_cdr_engine_term(void)
struct ast_json * ast_multi_channel_blob_get_json(struct ast_multi_channel_blob *obj)
Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj...
enum process_bridge_enter_results(*const process_bridge_enter)(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
Process the entering of a bridge by this CDR. The purpose of this callback is to have the CDR prepare...
void() ao2_prnt_fn(void *where, const char *fmt,...)
Print output.
pthread_cond_t ast_cond_t
A virtual table used for cdr_object.
static struct stasis_forward * bridge_subscription
Our subscription for bridges.
#define ast_strlen_zero(foo)
#define DEFAULT_BATCH_SAFE_SHUTDOWN
const ast_string_field appl
#define ast_pthread_create_background(a, b, c, d)
const ast_string_field context
static int cdr_object_dispatch_all_cb(void *obj, void *arg, int flags)
This dispatches all cdr_objects. It should only be used during shutdown, so that we get billing recor...
const ast_string_field dialed_subaddr
char lastdata[AST_MAX_EXTENSION]
const ast_string_field context
Configuration File Parser.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
void ao2_container_unregister(const char *name)
Unregister a container for CLI stats and integrity check.
#define AST_RWLIST_INSERT_HEAD
struct ast_bridge_snapshot * bridge
static int global_cdr_sequence
The global sequence counter used for CDRs.
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj)
Register a container for CLI stats and integrity check.
#define ast_debug(level,...)
Log a DEBUG message.
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
char userfield[AST_MAX_USER_FIELD]
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
const ast_string_field technology
#define CDR_DEBUG(fmt,...)
void ast_cdr_free(struct ast_cdr *cdr)
Free a CDR record.
char * ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
static char * handle_cli_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int cdr_all_hash_fn(const void *obj, const int flags)
struct ast_channel_snapshot * parkee
General Asterisk PBX channel definitions.
Asterisk JSON abstraction layer.
static void bridge_candidate_add_to_cdr(struct cdr_object *cdr, struct cdr_object_snapshot *party_b)
static int create_subscriptions(void)
Create the Stasis subcriptions for CDRs.
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
int(*const process_dial_begin)(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer)
Process the beginning of a dial. A dial message implies one of two things: The cdr_object's Party A h...
#define DEFAULT_UNANSWERED
static int load_module(void)
const ast_string_field appl
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Type for default option handler for unsigned integers.
static int cdr_object_format_property(struct cdr_object *cdr_obj, const char *name, char *value, size_t length)
Format one of the standard properties on a cdr_object.
static int dialed_pending_state_process_parking_bridge_enter(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
static void single_state_process_party_b(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
static int process_config(int reload)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
static void single_state_init_function(struct cdr_object *cdr)
#define AST_PTHREADT_NULL
struct cdr_batch_item * next
struct ast_cdr_config::batch_settings batch_settings
static int parked_state_process_bridge_leave(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
static void cdr_object_dispatch(struct cdr_object *cdr)
Dispatch a CDR.
const struct timeval * stasis_message_timestamp(const struct stasis_message *msg)
Get the time when a message was created.
#define DEFAULT_END_BEFORE_H_EXTEN
#define AST_RWLIST_TRAVERSE
process_bridge_enter_results
Return types for process_bridge_enter functions.
#define AST_CAUSE_NORMAL_CLEARING
Scheduler Routines (derived from cheops)
char linkedid[AST_MAX_UNIQUEID]
static struct ast_cli_entry cli_commands[]
#define AST_STRING_FIELD(name)
Declare a string field.
const ast_string_field linkedid
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
static ast_mutex_t cdr_pending_lock
These are used to wake up the CDR thread when there's work to do.
static void module_config_destructor(void *obj)
Dispose of a module config object.
#define ao2_ref(o, delta)
static struct aco_file module_file_conf
The file definition.
const ast_string_field subaddr
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
static int base_process_dial_end(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer, const char *dial_status)
struct cdr_object_fn_table parked_state_fn_table
The virtual table for the Parked state.
const ast_string_field exten
struct timeval creationtime
#define ast_strdupa(s)
duplicate a string in memory from the stack
static int filter_bridge_messages(struct ast_bridge_snapshot *bridge)
Filter bridge messages based on bridge technology.
static const char *const cdr_readonly_vars[]
static void handle_bridge_pairings(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge)
Handle creating bridge pairings for the cdr_object that just entered a bridge.
static enum process_bridge_enter_results dial_state_process_bridge_enter(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
char uniqueid[AST_MAX_UNIQUEID]
struct ast_channel_snapshot_hangup * hangup
static void cdr_get_tv(struct timeval when, const char *fmt, char *buf, int bufsize)
char dst[AST_MAX_EXTENSION]
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
static int init_batch(void)
struct cdr_object_fn_table dialed_pending_state_fn_table
The virtual table for the Dialed Pending state.
A set of macros to manage forward-linked lists.
#define ast_malloc(len)
A wrapper for malloc()
The configuration settings for this module.
static struct cdr_object * cdr_object_get_by_name(const char *name)
static void cdr_detach(struct ast_cdr *cdr)
void ast_cdr_setuserfield(const char *channel_name, const char *userfield)
Set CDR user field for channel (stored in CDR)
char channel[AST_MAX_EXTENSION]
static int cdr_generic_register(struct be_list *generic_list, const char *name, const char *desc, ast_cdrbe be)
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_CAUSE_NO_ANSWER
static char * handle_cli_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Blob of data associated with a bridge.
static int answer(void *data)
Channels with this particular technology are an implementation detail of Asterisk and should generall...
enum aco_category_op category_match
static AO2_GLOBAL_OBJ_STATIC(module_configs)
The container for the module configuration.
static void dial_state_process_party_b(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
static const char * cdr_format_var_internal(struct ast_cdr *cdr, const char *name)
#define stasis_message_router_create(topic)
static struct cdr_batch * batch
static void free_variables(struct varshead *headp)
Delete all variables from a variable list.
static int snapshot_cep_changed(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
Return whether or not a channel has changed its state in the dialplan, subject to endbeforehexten log...
struct cdr_object_fn_table * fn_table
Their was an error and no changes were applied.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
enum ast_cdr_disposition disposition
const char * channel_name
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.
struct ast_channel_snapshot_caller * caller
List of registered modifiers.
static struct cdr_object_snapshot * cdr_object_pick_party_a(struct cdr_object_snapshot *left, struct cdr_object_snapshot *right)
Given two CDR snapshots, figure out who should be Party A for the resulting CDR.
An in-memory representation of an active CDR.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
static void cdr_object_transition_state_init(struct cdr_object *cdr, struct cdr_object_fn_table *fn_table, int do_init)
Transition a cdr_object to a new state with initiation flag.
Queued CDR waiting to be batched.
struct ast_flags softhangup_flags
Responsible for call detail data.
Configuration option-handling.
char lastapp[AST_MAX_EXTENSION]
const ast_string_field data
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
int ast_cdr_backend_unsuspend(const char *name)
Unsuspend a CDR backend.
struct cdr_object_fn_table single_state_fn_table
The virtual table for the Single state.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
const ast_string_field dnid
static enum process_bridge_enter_results single_state_process_bridge_enter(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
#define ao2_unlink(container, obj)
static struct ast_cdr * cdr_object_create_public_records(struct cdr_object *cdr)
Create a chain of ast_cdr objects from a chain of cdr_object suitable for consumption by the register...
static ast_cond_t cdr_pending_cond
static ast_mutex_t cdr_batch_lock
Lock protecting modifications to the batch queue.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
int ast_cdr_fork(const char *channel_name, struct ast_flags *options)
Fork a CDR.
int ast_cdr_serialize_variables(const char *channel_name, struct ast_str **buf, char delim, char sep)
Serializes all the data and variables for a current CDR record.
unsigned int parkingspace
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
#define ao2_global_obj_release(holder)
static void cdr_object_check_party_a_hangup(struct cdr_object *cdr)
Check to see if a CDR needs to move to the finalized state because its Party A hungup.
int ast_cdr_clear_property(const char *channel_name, enum ast_cdr_options option)
Clear a property on a CDR for a channel.
CONFIG_INFO_CORE("cdr", cfg_info, module_configs, module_config_alloc,.files=ACO_FILES(&module_file_conf),.post_apply_config=module_config_post_apply,)
void ast_var_delete(struct ast_var_t *var)
const char * name
Name of the subclass.
static struct ao2_container * active_cdrs_master
A container of the active master CDRs indexed by Party A channel uniqueid.
#define ao2_callback_data(container, flags, cb_fn, arg, data)
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
void(*const process_party_b)(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
Process a Party B update for the cdr_object.
static int single_state_bridge_enter_comparison(struct cdr_object *cdr, struct cdr_object *cand_cdr)
Handle a comparison between our cdr_object and a cdr_object already in the bridge while in the Single...
#define ao2_iterator_next(iter)
#define ast_cond_destroy(cond)
#define ao2_alloc(data_size, destructor_fn)
struct stasis_message_router * ast_cdr_message_router(void)
Return the message router for the CDR engine.
static struct aco_type * general_options[]
const ast_string_field party_b_name
long ast_sched_when(struct ast_sched_context *con, int id)
Returns the number of seconds before an event takes place.
static int snapshot_is_dialed(struct ast_channel_snapshot *snapshot)
Return whether or not a ast_channel_snapshot is for a channel that was created as the result of a dia...
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
#define AST_CAUSE_UNREGISTERED
static int finalized_state_process_party_a(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
#define ast_calloc(num, len)
A wrapper for calloc()
static int cdr_object_update_party_b(void *obj, void *arg, void *data, int flags)
struct ast_var_t::@249 entries
static void start_batch_mode(void)
#define ast_var_assign(name, value)
int aco_set_defaults(struct aco_type *type, const char *category, void *obj)
Set all default options of obj.
Module could not be loaded properly.
static int dialed_pending_state_process_dial_begin(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer)
static int unload_module(void)
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
struct ast_channel_snapshot * new_snapshot
static void cdr_object_snapshot_copy(struct cdr_object_snapshot *dst, struct cdr_object_snapshot *src)
Copy a snapshot and its details.
enum ast_channel_state 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...
static int cdr_all_cmp_fn(void *obj, void *arg, int flags)
#define ao2_find(container, arg, flags)
const ast_string_field uniqueid
An API for managing task processing threads that can be shared across modules.
const ast_string_field parkinglot
static enum ast_cdr_disposition dial_status_to_disposition(const char *dial_status)
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
int(*const process_parking_bridge_enter)(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
Process entering into a parking bridge.
int ast_cdr_modifier_unregister(const char *name)
Unregister a CDR modifier.
struct ast_channel_snapshot * old_snapshot
Structure used to handle boolean flags.
#define ast_clear_flag(p, flag)
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",)
struct stasis_topic * ast_bridge_topic_all(void)
A topic which publishes the events for all bridges.
char src[AST_MAX_EXTENSION]
char peeraccount[AST_MAX_ACCOUNT_CODE]
void ast_cdr_set_config(struct ast_cdr_config *config)
Set the current CDR configuration.
struct cdr_object_fn_table finalized_state_fn_table
The virtual table for the finalized state.
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
static int dial_status_end(const char *dialstatus)
#define ao2_global_obj_replace_unref(holder, obj)
STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_sync_message_type)
A message type used to synchronize with the CDR topic.
The arg parameter is an object of the same type.
struct stasis_topic * ast_parking_topic(void)
accessor for the parking stasis topic
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
static int cdr_object_party_b_left_bridge_cb(void *obj, void *arg, void *data, int flags)
Callback used to notify CDRs of a Party B leaving the bridge.
const struct timeval * lastevent
#define AST_CAUSE_NO_ROUTE_DESTINATION
struct ast_flags settings
#define ao2_replace(dst, src)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
int ast_cdr_is_enabled(void)
Return TRUE if CDR subsystem is enabled.
Standard Command Line Interface.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
ast_cdr_disposition
CDR Flags - Disposition.
Type information about a category-level configurable object.
const ast_string_field number
int ast_cdr_modifier_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR modifier.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
int ast_cdr_backend_suspend(const char *name)
Suspend a CDR backend temporarily.
static void cdr_enable_batch_mode(struct ast_cdr_config *config)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static void handle_parked_call_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Handler for when a channel is parked.
static void cli_show_channel(struct ast_cli_args *a)
struct ast_channel_snapshot * ast_multi_channel_blob_get_channel(struct ast_multi_channel_blob *obj, const char *role)
Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob.
static struct aco_type general_option
The type definition for general options.
A multi channel blob data structure for multi_channel_blob stasis messages.
int ast_cdr_setvar(const char *channel_name, const char *name, const char *value)
Set a variable on a CDR.
#define DEFAULT_BATCHMODE
static int single_state_process_parking_bridge_enter(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
static void handle_standard_bridge_enter_message(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel, const struct timeval *event_time)
Handle a bridge enter message for a 'normal' bridge.
static char * cli_complete_show(struct ast_cli_args *a)
Complete user input for 'cdr show'.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
static void cdr_all_print_fn(void *v_obj, void *where, ao2_prnt_fn *prnt)
static struct ao2_container * active_cdrs_all
A container of all active CDRs with a Party B indexed by Party B channel name.
struct stasis_forward * sub
#define ao2_unlink_flags(container, obj, flags)
static void cdr_object_check_party_a_answer(struct cdr_object *cdr)
Check to see if a CDR needs to be answered based on its Party A. Note that this is safe to call as mu...
Internal Asterisk hangup causes.
Abstract JSON element (object, array, string, int, ...).
struct cdr_batch_item * head
int(*const process_bridge_leave)(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
Process the leaving of a bridge by this CDR.
#define AST_RWLIST_REMOVE
static void cdr_object_swap_snapshot(struct cdr_object_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
Swap an old cdr_object_snapshot's ast_channel_snapshot for a new ast_channel_snapshot.
The global options available for CDRs.
struct stasis_message_type * ast_channel_dial_type(void)
Message type for when a channel dials another channel.
static void cdr_object_update_cid(struct cdr_object_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
static struct stasis_forward * channel_subscription
Our subscription for channels.
struct cdr_object_fn_table bridge_state_fn_table
The virtual table for the Bridged state.
static void finalized_state_init_function(struct cdr_object *cdr)
char clid[AST_MAX_EXTENSION]
Search option field mask.
static char context[AST_MAX_CONTEXT]
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
const ast_string_field uniqueid
struct cdr_object_fn_table dial_state_fn_table
The virtual table for the Dial state.
static struct aco_type ignore_option
int stasis_message_router_set_congestion_limits(struct stasis_message_router *router, long low_water, long high_water)
Set the high and low alert water marks of the stasis message router.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
struct ast_channel_snapshot_peer * peer
static struct cdr_object * cdr_object_create_and_append(struct cdr_object *cdr, const struct timeval *event_time)
Create a new cdr_object and append it to an existing chain.
static int dialed_pending_state_process_party_a(struct cdr_object *cdr, struct ast_channel_snapshot *snapshot)
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_cdr_config * general
int(*const process_dial_end)(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer, const char *dial_status)
Process the end of a dial. At the end of a dial, a CDR can be transitioned into one of two states - D...
static int check_new_cdr_needed(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
Determine if we need to add a new CDR based on snapshots.
Asterisk module definitions.
static void cdr_object_finalize(struct cdr_object *cdr)
Finalize a CDR.
static void cdr_master_print_fn(void *v_obj, void *where, ao2_prnt_fn *prnt)
const ast_string_field subclass
static int cdr_object_finalize_party_b(void *obj, void *arg, void *data, int flags)
static struct stasis_forward * parking_subscription
Our subscription for parking.
static void handle_cdr_sync_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Handler for a synchronization message.
static struct cdr_tds_config * settings
static char * handle_cli_submit(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
#define DEFAULT_BATCH_SCHEDULER_ONLY
static enum process_bridge_enter_results base_process_bridge_enter(struct cdr_object *cdr, struct ast_bridge_snapshot *bridge, struct ast_channel_snapshot *channel)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ast_cond_timedwait(cond, mutex, time)
static int cdr_toggle_runtime_options(void)
Checks if CDRs are enabled and enables/disables the necessary options.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
#define AST_CAUSE_CONGESTION
#define AST_MUTEX_DEFINE_STATIC(mutex)
static pthread_t cdr_thread
List of registered backends.
#define DEFAULT_INITIATED_SECONDS
static void finalize_batch_mode(void)
static int dial_state_process_dial_begin(struct cdr_object *cdr, struct ast_channel_snapshot *caller, struct ast_channel_snapshot *peer)
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
const ast_string_field bridge
static int reload_module(void)
const ast_string_field name
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.
char userfield[AST_MAX_USER_FIELD]
#define ast_mutex_unlock(a)
static void cdr_all_relink(struct cdr_object *cdr)
static void cdr_object_transition_state(struct cdr_object *cdr, struct cdr_object_fn_table *fn_table)
Transition a cdr_object to a new state.
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
static int filter_channel_snapshot_message(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
static struct ast_sched_context * sched
Scheduler items.
struct ast_cdr * ast_cdr_dup(struct ast_cdr *cdr)
Duplicate a public CDR.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define AST_MAX_USER_FIELD
#define ao2_link(container, obj)
static void cli_show_channels(struct ast_cli_args *a)