382 static const struct {
392 static const struct {
401 {
CC_CALLER_BUSY,
"Callee was ready, but caller is now unavailable"},
461 "Calling provided agent callback function"))) {
463 cc_unref(core_instance,
"agent callback done with the core_instance");
495 const char *
name = arg;
496 unsigned long match_flags = *(
unsigned long *)data;
497 int possible_match = 0;
507 if (!possible_match) {
533 const char *
name = arg;
549 #define CC_AVAILABLE_DEVSTATE_DEFAULT AST_DEVICE_NOT_INUSE 550 #define CC_CALLER_OFFERED_DEVSTATE_DEFAULT AST_DEVICE_NOT_INUSE 551 #define CC_CALLER_REQUESTED_DEVSTATE_DEFAULT AST_DEVICE_NOT_INUSE 552 #define CC_ACTIVE_DEVSTATE_DEFAULT AST_DEVICE_INUSE 553 #define CC_CALLEE_READY_DEVSTATE_DEFAULT AST_DEVICE_RINGING 554 #define CC_CALLER_BUSY_DEVSTATE_DEFAULT AST_DEVICE_ONHOLD 555 #define CC_RECALLING_DEVSTATE_DEFAULT AST_DEVICE_RINGING 556 #define CC_COMPLETE_DEVSTATE_DEFAULT AST_DEVICE_NOT_INUSE 557 #define CC_FAILED_DEVSTATE_DEFAULT AST_DEVICE_NOT_INUSE 586 return cc_state_to_devstate_map[
state];
608 (
char *) device_name, &match_flags,
609 "Find Core Instance for ccss_device_state reqeust.");
610 if (!core_instance) {
612 "Couldn't find a core instance for caller %s\n", device_name);
617 "Core %d: Found core_instance for caller %s in state %s\n",
622 "Core %d: Device State is only for generic agent types.\n",
624 cc_unref(core_instance,
"Unref core_instance since ccss_device_state was called with native agent");
628 cc_unref(core_instance,
"Unref core_instance done with ccss_device_state");
629 return cc_current_state;
648 "Notification of CCSS state change to '%s', device state '%s' for device '%s'\n",
654 #define CC_OFFER_TIMER_DEFAULT 20 655 #define CCNR_AVAILABLE_TIMER_DEFAULT 7200 656 #define CCBS_AVAILABLE_TIMER_DEFAULT 4800 657 #define CC_RECALL_TIMER_DEFAULT 20 658 #define CC_MAX_AGENTS_DEFAULT 5 659 #define CC_MAX_MONITORS_DEFAULT 5 660 #define GLOBAL_CC_MAX_REQUESTS_DEFAULT 20 671 .cc_callback_macro =
"",
672 .cc_callback_sub =
"",
673 .cc_agent_dialstring =
"",
700 if (!strcasecmp(value,
"never")) {
702 }
else if (!strcasecmp(value,
"native")) {
704 }
else if (!strcasecmp(value,
"generic")) {
707 ast_log(
LOG_WARNING,
"%s is an invalid value for cc_agent_policy. Switching to 'never'\n", value);
714 if (!strcasecmp(value,
"never")) {
716 }
else if (!strcasecmp(value,
"native")) {
718 }
else if (!strcasecmp(value,
"generic")) {
720 }
else if (!strcasecmp(value,
"always")) {
723 ast_log(
LOG_WARNING,
"%s is an invalid value for cc_monitor_policy. Switching to 'never'\n", value);
760 char *
buf,
size_t buf_len)
764 if (!strcasecmp(name,
"cc_callback_macro")) {
766 }
else if (!strcasecmp(name,
"cc_callback_sub")) {
768 }
else if (!strcasecmp(name,
"cc_agent_policy")) {
770 }
else if (!strcasecmp(name,
"cc_monitor_policy")) {
772 }
else if (!strcasecmp(name,
"cc_agent_dialstring")) {
784 if (!strcasecmp(name,
"cc_offer_timer")) {
786 }
else if (!strcasecmp(name,
"ccnr_available_timer")) {
788 }
else if (!strcasecmp(name,
"ccbs_available_timer")) {
790 }
else if (!strcasecmp(name,
"cc_max_agents")) {
792 }
else if (!strcasecmp(name,
"cc_max_monitors")) {
794 }
else if (!strcasecmp(name,
"cc_recall_timer")) {
805 const char *
const value)
807 unsigned int value_as_uint;
808 if (!strcasecmp(name,
"cc_agent_policy")) {
810 }
else if (!strcasecmp(name,
"cc_monitor_policy")) {
812 }
else if (!strcasecmp(name,
"cc_agent_dialstring")) {
814 }
else if (!strcasecmp(name,
"cc_callback_macro")) {
817 }
else if (!strcasecmp(name,
"cc_callback_sub")) {
822 if (sscanf(value,
"%30u", &value_as_uint) != 1) {
826 if (!strcasecmp(name,
"cc_offer_timer")) {
828 }
else if (!strcasecmp(name,
"ccnr_available_timer")) {
830 }
else if (!strcasecmp(name,
"ccbs_available_timer")) {
832 }
else if (!strcasecmp(name,
"cc_max_agents")) {
834 }
else if (!strcasecmp(name,
"cc_max_monitors")) {
836 }
else if (!strcasecmp(name,
"cc_recall_timer")) {
848 return (!strcasecmp(name,
"cc_agent_policy") ||
849 !strcasecmp(name,
"cc_monitor_policy") ||
850 !strcasecmp(name,
"cc_offer_timer") ||
851 !strcasecmp(name,
"ccnr_available_timer") ||
852 !strcasecmp(name,
"ccbs_available_timer") ||
853 !strcasecmp(name,
"cc_max_agents") ||
854 !strcasecmp(name,
"cc_max_monitors") ||
855 !strcasecmp(name,
"cc_callback_macro") ||
856 !strcasecmp(name,
"cc_callback_sub") ||
857 !strcasecmp(name,
"cc_agent_dialstring") ||
858 !strcasecmp(name,
"cc_recall_timer"));
1006 ast_log(
LOG_WARNING,
"Usage of cc_callback_macro is deprecated. Please use cc_callback_sub instead.\n");
1029 if (!message_type) {
1034 "core_id", core_id);
1069 "service", service);
1416 if (!generic_list) {
1421 cc_unref(generic_list,
"Failed to strdup the monitor's device name");
1428 if (!device_specific_topic) {
1433 cc_unref(generic_list,
"Failed to subscribe to device state");
1439 ao2_t_link(generic_monitors, generic_list,
"linking new generic monitor instance list");
1440 return generic_list;
1461 cc_unref(generic_list,
"Kill reference of generic list in devstate taskprocessor callback");
1480 cc_unref(generic_list,
"Kill reference of generic list in devstate taskprocessor callback");
1497 if (dev_state->
eid) {
1502 ao2_t_ref(dev_state, +1,
"Bumping dev_state ref for cc_core_taskprocessor");
1515 cc_unref(monitor,
"Unref reference from scheduler\n");
1531 if (!(gen_mon_pvt =
ast_calloc(1,
sizeof(*gen_mon_pvt)))) {
1550 if (!(generic_instance =
ast_calloc(1,
sizeof(*generic_instance)))) {
1554 cc_unref(generic_list,
"Generic monitor instance failed to allocate");
1563 *available_timer_id =
ast_sched_add(cc_sched_context, when * 1000,
1565 if (*available_timer_id == -1) {
1566 cc_unref(monitor,
"Failed to schedule available timer. (monitor)");
1567 cc_unref(generic_list,
"Failed to schedule available timer. (generic_list)");
1578 cc_unref(generic_list,
"Finished with monitor instance reference in request cc callback");
1604 cc_unref(generic_list,
"Device is in use. Nothing to do. Unref generic list.");
1619 cc_unref(generic_list,
"Done with generic list in suspend callback");
1629 if (!generic_list) {
1647 cc_unref(generic_list,
"Done with generic list in cc_generic_monitor_unsuspend");
1655 if (*sched_id == -1) {
1662 cc_unref(monitor,
"Remove scheduler's reference to the monitor");
1674 if (!private_data) {
1709 ao2_t_unlink(generic_monitors, generic_list,
"Generic list is empty. Unlink it from the container");
1726 "availability due to other instance's failure.");
1732 cc_unref(generic_list,
"Done with generic list in generic monitor destructor");
1827 if (!extension_pvt) {
1866 cc_unref(monitor,
"Destroying all monitors");
1968 if (!new_cc_interfaces) {
1977 return new_cc_interfaces;
1990 .
type =
"Dial CC Interfaces",
2021 cc_interfaces = cc_datastore->
data;
2028 if (monitor->
id ==
id) {
2039 if (!(child_dialstring =
ast_calloc(1,
sizeof(*child_dialstring)))) {
2057 if (monitor_iter->
id == parent_id) {
2062 if (!monitor_iter) {
2068 if (!strcmp(child_dialstring->
device_name, device_name)) {
2098 "Allocating new ast_cc_interface"))) {
2103 cc_unref(cc_interface,
"failed to allocate the monitor, so unref the interface");
2108 cc_unref(monitor,
"Failed to initialize extension monitor private data. uref monitor");
2109 cc_unref(cc_interface,
"Failed to initialize extension monitor private data. unref cc_interface");
2154 if (!(interfaces =
ast_calloc(1,
sizeof(*interfaces)))) {
2164 cc_unref(monitor,
"Could not allocate the dialed interfaces datastore. Unreffing monitor");
2170 "Allocate monitor tree"))) {
2172 cc_unref(monitor,
"Could not allocate monitor tree on dialed interfaces datastore. Unreffing monitor");
2180 cc_ref(monitor,
"List's reference to extension monitor");
2189 cc_unref(monitor,
"Unreffing allocation's reference");
2220 if (!monitor_callbacks) {
2254 size_t device_name_len = strlen(device_name);
2258 "Allocating new ast_cc_interface"))) {
2263 cc_unref(cc_interface,
"Failed to allocate config params, unref interface");
2268 cc_unref(cc_interface,
"Failed to allocate monitor, unref interface");
2273 cc_unref(monitor,
"Failed to copy dialable name. Unref monitor");
2274 cc_unref(cc_interface,
"Failed to copy dialable name");
2279 cc_unref(monitor,
"Failed to find monitor callbacks. Unref monitor");
2280 cc_unref(cc_interface,
"Failed to find monitor callbacks");
2331 ast_log(
LOG_WARNING,
"Unable to retrieve CC datastore while processing CC frame from '%s'. CC services will be unavailable.\n", device_name);
2337 cc_interfaces = cc_datastore->
data;
2339 if (cc_interfaces->
ignore) {
2357 if (!core_instance) {
2359 cc_interfaces->
core_id, cc_data);
2360 if (!core_instance) {
2361 cc_interfaces->
ignore = 1;
2380 core_instance->
core_id, device_name);
2382 cc_unref(core_instance,
"Returning early from ast_handle_cc_control_frame. Unref core_instance");
2390 ast_log(
LOG_WARNING,
"Unable to create CC device interface for '%s'. CC services will be unavailable on this interface.\n", device_name);
2391 cc_unref(core_instance,
"Returning early from ast_handle_cc_control_frame. Unref core_instance");
2397 cc_ref(monitor,
"monitor tree's reference to the monitor");
2405 cc_unref(core_instance,
"Done with core_instance after handling CC control frame");
2406 cc_unref(monitor,
"Unref reference from allocating monitor");
2457 interfaces = cc_interfaces_datastore->
data;
2460 if (interfaces->
ignore) {
2474 cc_ref(monitor,
"monitor tree's reference to the monitor");
2478 cc_unref(monitor,
"Unref monitor's allocation reference");
2499 cc_interfaces = datastore->
data;
2500 core_id_return = cc_interfaces->
ignore ? -1 : cc_interfaces->
core_id;
2502 return core_id_return;
2506 static long count_agents(
const char *
const caller,
const int core_id_exception)
2525 match_agent, caller, &match_flags,
"Killing duplicate offers");
2555 const char *
const caller_name,
const int core_id,
2562 "Allocating new ast_cc_agent"))) {
2571 cc_unref(agent,
"Could not get channel config params.");
2575 cc_unref(agent,
"Could not init agent config params.");
2581 cc_unref(agent,
"Could not find agent callbacks.");
2587 cc_unref(agent,
"Agent init callback failed.");
2699 cc_unref(agent,
"Remove scheduler's reference to the agent");
2728 cc_unref(agent,
"Remove scheduler's reference to the agent");
2769 cc_unref(agent,
"Done holding ref for subscription");
2776 if (dev_state->
eid) {
2781 new_state = dev_state->
state;
2798 ast_str_set(&str, 0,
"Agent monitoring %s device state since it is busy\n",
2802 if (!device_specific_topic) {
2812 cc_ref(agent,
"Ref agent for subscription");
2820 const char *
interface =
S_OR(ast_get_cc_agent_dialstring(agent->cc_params), ast_strdupa(agent->device_name));
2835 if ((target = strchr(interface,
'/'))) {
2844 agent->core_id, agent->device_name, reason);
2845 ast_cc_failed(agent->core_id,
"Failed to call back device %s/%s", tech, target);
2868 agent->core_id, agent->device_name);
2870 ast_cc_failed(agent->core_id,
"Callback macro to %s failed. Maybe a hangup?", agent->device_name);
2878 agent->core_id, agent->device_name);
2880 ast_cc_failed(agent->core_id,
"Callback subroutine to %s failed. Maybe a hangup?", agent->device_name);
2886 ast_cc_failed(agent->core_id,
"PBX failed to start for %s.", agent->device_name);
2891 agent->device_name);
2921 if (agent_pvt->
sub) {
2932 if (core_instance->
agent) {
2933 cc_unref(core_instance->
agent,
"Core instance is done with the agent now");
2981 core_instance->
core_id = core_id;
2983 cc_unref(core_instance,
"Couldn't allocate agent, unref core_instance");
2987 core_instance->
monitors =
cc_ref(called_tree,
"Core instance getting ref to monitor tree");
2989 ao2_t_link(cc_core_instances, core_instance,
"Link core instance into container");
2991 return core_instance;
3004 switch (new_state) {
3118 cc_unref(monitor_iter,
"request_cc failed. Unref list's reference to monitor");
3135 ast_log(
LOG_WARNING,
"Cannot request CC since there is no more room for requests\n");
3156 cc_unref(monitor_iter,
"unsuspend failed. Unref list's reference to monitor");
3203 cc_unref(monitor_iter,
"suspend failed. Unref list's reference to monitor");
3236 cc_unref(monitor_iter,
"cancel_available_timer failed. Unref list's reference to monitor");
3243 ast_cc_failed(core_instance->
core_id,
"All device monitors failed to cancel their available timers");
3262 ao2_t_unlink(cc_core_instances, core_instance,
"Unlink core instance since CC recall has completed");
3269 ao2_t_unlink(cc_core_instances, core_instance,
"Unlink core instance since CC failed");
3309 cc_unref(core_instance,
"Unref core instance from when it was found earlier");
3319 if (!res && !strcmp(core_instance->agent->callbacks->type,
"generic")) {
3324 cc_unref(core_instance,
"Unref since state change has completed");
3343 debuglen = vsnprintf(dummy,
sizeof(dummy), debug, aq) + 1;
3346 if (!(args =
ast_calloc(1,
sizeof(*args) + debuglen))) {
3351 if (!core_instance) {
3361 vsnprintf(args->
debug, debuglen, debug, ap);
3365 cc_unref(core_instance,
"Unref core instance. ast_taskprocessor_push failed");
3400 .
type =
"cc_recall",
3411 if (!recall_datastore) {
3415 if (!(recall_data =
ast_calloc(1,
sizeof(*recall_data)))) {
3427 "Bump refcount for monitor tree for recall datastore");
3429 recall_datastore->
data = recall_data;
3434 cc_unref(core_instance,
"Recall datastore set up. No need for core_instance ref");
3445 int core_id_candidate;
3458 recall_data = recall_datastore->
data;
3460 if (recall_data->
ignore) {
3469 if (!recall_data->
nested) {
3476 *core_id = recall_data->
core_id;
3498 core_id_candidate = recall_data->
core_id;
3510 *core_id = core_id_candidate;
3524 if (!core_instance) {
3532 cc_ref(monitor_iter,
"Hand the requester of the monitor a reference");
3537 cc_unref(core_instance,
"Done with core instance ref in ast_cc_get_monitor_by_recall_core_id");
3538 return monitor_iter;
3566 snprintf(dialstring_search,
sizeof(dialstring_search),
"%s%c", dialstring,
'&');
3593 int top_level_id = starting_point->
id;
3612 if (monitor_iter->
parent_id == top_level_id) {
3650 recall_data = recall_datastore->
data;
3652 core_id = recall_data->
core_id;
3687 recall_data = recall_datastore->
data;
3689 core_id = recall_data->
core_id;
3699 if (!monitor_iter) {
3729 cc_interfaces = cc_datastore->
data;
3730 cc_interfaces->
ignore = 1;
3734 recall_cc_data = cc_recall_datastore->
data;
3735 recall_cc_data->
ignore = 1;
3745 va_start(ap, debug);
3757 char cc_is_offerable;
3765 cc_interfaces = datastore->
data;
3767 core_id = cc_interfaces->
core_id;
3770 if (cc_is_offerable) {
3781 va_start(ap, debug);
3792 va_start(ap, debug);
3803 va_start(ap, debug);
3814 va_start(ap, debug);
3825 va_start(ap, debug);
3836 va_start(ap, debug);
3856 recall_data = recall_datastore->
data;
3871 core_id = recall_data->
core_id;
3873 va_start(ap, debug);
3884 va_start(ap, debug);
3903 if (!core_instance) {
3906 "Core %d: Could not find core instance for device %s '%s'\n",
3923 cc_unref(monitor_iter,
"Monitor reported failure. Unref list's reference.");
3933 cc_unref(core_instance,
"Finished with core_instance in cc_monitor_failed\n");
3947 if (!(failure_data =
ast_calloc(1,
sizeof(*failure_data)))) {
3956 va_start(ap, debug);
3982 cc_unref(core_instance,
"Status request finished. Unref core instance");
3991 if (!core_instance) {
3997 cc_unref(core_instance,
"Unref core instance. ast_taskprocessor_push failed");
4019 cc_unref(core_instance,
"Stop ringing finished. Unref core_instance");
4028 if (!core_instance) {
4034 cc_unref(core_instance,
"Unref core instance. ast_taskprocessor_push failed");
4047 cc_unref(core_instance,
"Party B free finished. Unref core_instance");
4056 if (!core_instance) {
4062 cc_unref(core_instance,
"Unref core instance. ast_taskprocessor_push failed");
4089 cc_unref(core_instance,
"Status response finished. Unref core instance");
4105 if (!core_instance) {
4115 cc_unref(core_instance,
"Unref core instance. ast_taskprocessor_push failed");
4122 const char *monitor_type,
const char *
const device_name,
const char * dialstring,
4135 cc_interfaces = datastore->
data;
4163 ast_log(
LOG_NOTICE,
"Not queuing a CC frame for device %s since it already has its maximum monitors allocated\n", device_name);
4167 if (
ast_cc_build_frame(chan, cc_params, monitor_type, device_name, dialstring, service, private_data, &frame)) {
4177 const char *monitor_type,
const char *
const device_name,
4186 if (
cc_build_payload(chan, cc_params, monitor_type, device_name, dialstring, service, private_data, payload)) {
4194 frame->
datalen =
sizeof(*payload);
4233 const char *monitor_type,
const char *
const device_name,
const char *
const dialstring,
void *private_data)
4267 if (!(core_instance =
ao2_t_callback_data(cc_core_instances, 0,
match_agent, device_name, &match_flags,
"Find core instance for CallCompletionRequest"))) {
4275 core_instance->
core_id, device_name);
4282 cc_unref(core_instance,
"Unref core_instance since CallCompletionRequest was called with native agent");
4292 cc_unref(core_instance,
"Unref core_instance since too many CC requests");
4302 cc_unref(core_instance,
"Done with CallCompletionRequest");
4318 if (!(core_instance =
ao2_t_callback_data(cc_core_instances, 0,
match_agent, device_name, &match_flags,
"Find core instance for CallCompletionCancel"))) {
4326 ast_log(
LOG_WARNING,
"CallCompletionCancel may only be used for calles with a generic agent\n");
4327 cc_unref(core_instance,
"Unref core instance found during CallCompletionCancel");
4332 res =
ast_cc_failed(core_instance->
core_id,
"Call completion request Cancelled for core ID %d by caller %s",
4333 core_instance->
core_id, device_name);
4334 cc_unref(core_instance,
"Unref core instance found during CallCompletionCancel");
4380 const char *cc_max_requests_str;
4386 ast_log(
LOG_WARNING,
"Could not find valid ccss.conf file. Using cc_max_requests default\n");
4414 const char *cc_devstate_str;
4420 cc_state_to_devstate_map[
state] = this_devstate;
4444 "Could not find valid ccss.conf file. Using cc_[state]_devstate defaults\n");
4475 if (child_monitor_iter->
parent_id == monitor->
id) {
4500 ast_cli(*cli_fd,
"There are currently no active call completion transactions\n");
4502 ast_cli(*cli_fd,
"%d Call completion transactions\n", count);
4503 ast_cli(*cli_fd,
"Core ID\t\tCaller\t\t\t\tStatus\n");
4504 ast_cli(*cli_fd,
"----------------------------------------------------------------------------\n");
4517 e->
command =
"cc report status";
4519 "Usage: cc report status\n" 4520 " Report the current status of any ongoing CC transactions\n";
4549 if (!core_id || (core_instance->
core_id == *core_id)) {
4557 int wordlen = strlen(word);
4562 cc_unref(core_instance,
"CLI tab completion iteration")) {
4563 char core_id_str[20];
4564 snprintf(core_id_str,
sizeof(core_id_str),
"%d", core_instance->
core_id);
4565 if (!strncmp(word, core_id_str, wordlen)) {
4567 cc_unref(core_instance,
"Found a matching core ID for CLI tab-completion");
4581 e->
command =
"cc cancel [core|all]";
4583 "Usage: cc cancel can be used in two ways.\n" 4584 " 1. 'cc cancel core [core ID]' will cancel the CC transaction with\n" 4585 " core ID equal to the specified core ID.\n" 4586 " 2. 'cc cancel all' will cancel all active CC transactions.\n";
4589 if (a->
pos == 3 && !strcasecmp(a->
argv[2],
"core")) {
4598 if (strcasecmp(a->
argv[2],
"core")) {
4601 core_id = strtol(a->
argv[3], &endptr, 10);
4602 if ((
errno != 0 && core_id == 0) || (endptr == a->
argv[3])) {
4606 }
else if (a->
argc == 3) {
4607 if (strcasecmp(a->
argv[2],
"all")) {
4633 if (cc_sched_context) {
4635 cc_sched_context =
NULL;
4637 if (cc_core_taskprocessor) {
4641 if (cc_core_instances) {
4642 ao2_t_ref(cc_core_instances, -1,
"Unref cc_core_instances container in cc_shutdown");
4643 cc_core_instances =
NULL;
4645 if (generic_monitors) {
4646 ao2_t_ref(generic_monitors, -1,
"Unref generic_monitor container in cc_shutdown");
4647 generic_monitors =
NULL;
4660 "Create core instance container");
4661 if (!cc_core_instances) {
4667 generic_monitor_instance_list_hash_fn,
NULL, generic_monitor_instance_list_cmp_fn,
4668 "Create generic monitor container");
4669 if (!generic_monitors) {
4688 dialed_cc_interface_counter = 1;
static void cc_unique_append(struct ast_str **str, const char *dialstring)
struct stasis_topic * ast_device_state_topic(const char *device)
Get the Stasis topic for device state messages for a specific device.
struct ast_cc_config_params * __ast_cc_config_params_init(const char *file, int line, const char *function)
Allocate and initialize an ast_cc_config_params structure.
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
void ast_cc_extension_monitor_add_dialstring(struct ast_channel *incoming, const char *const dialstring, const char *const device_name)
Add a child dialstring to an extension monitor.
void(* ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, void *private_data)
Callback made from ast_cc_callback for certain channel types.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define CC_FAILED_DEVSTATE_DEFAULT
int ast_cc_monitor_callee_available(const int core_id, const char *const debug,...)
Alert the core that a device being monitored has become available.
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
static const struct ast_cc_monitor_callbacks * find_monitor_callbacks(const char *const type)
static int load_module(void)
unsigned int ast_get_ccnr_available_timer(struct ast_cc_config_params *config)
Get the ccnr_available_timer.
struct cc_monitor_tree * monitors
struct stasis_message_type * ast_cc_callerstartmonitoring_type(void)
A stasis_message_type for CCSS Caller Start Monitoring messages.
static const char * cc_service_to_string(enum ast_cc_service_type service)
static int cc_generic_agent_status_request(struct ast_cc_agent *agent)
const char * ast_devstate2str(enum ast_device_state devstate) attribute_pure
Convert device state to text string for output.
#define ast_channel_lock(chan)
static int cc_generic_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
struct ast_cc_monitor * next
The payload for an AST_CONTROL_CC frame.
#define AST_CLI_DEFINE(fn, txt,...)
ast_device_state
Device States.
void ast_set_cc_callback_sub(struct ast_cc_config_params *config, const char *const value)
Set the callback subroutine name.
#define CC_OFFER_TIMER_DEFAULT
const char * type
Type of monitor the callbacks belong to.
static int cc_generic_agent_start_monitoring(struct ast_cc_agent *agent)
void ast_set_cc_agent_dialstring(struct ast_cc_config_params *config, const char *const value)
Set the cc_agent_dialstring.
static void cc_publish_recallcomplete(int core_id, const char *caller)
static void cc_recall_ds_destroy(void *data)
#define AST_LIST_LOCK(head)
Locks a list.
static char * handle_cc_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void * generic_recall(void *data)
Asterisk main include file. File version handling, generic pbx functions.
void * private_data
Private data allocated by the callee.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
static int cc_generic_monitor_suspend(struct ast_cc_monitor *monitor)
static unsigned int global_cc_max_requests
static enum ast_cc_monitor_policies str_to_monitor_policy(const char *const value)
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
static const struct @360 cc_state_to_string_map[]
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int ast_queue_cc_frame(struct ast_channel *chan, const char *monitor_type, const char *const dialstring, enum ast_cc_service_type service, void *private_data)
Queue an AST_CONTROL_CC frame.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
String manipulation functions.
static struct extension_monitor_pvt * extension_monitor_pvt_init(void)
struct ast_datastore * next
char cid_num[AST_CHANNEL_NAME]
static void unsuspend(struct cc_core_instance *core_instance)
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char *const extension)
Set the CC_INTERFACES channel variable for a channel using an.
#define AO2_STRING_FIELD_HASH_FN(stype, field)
Creates a hash function for a structure string field.
static int count_agents_cb(void *obj, void *arg, void *data, int flags)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
int ast_cc_is_config_param(const char *const name)
Is this a CCSS configuration parameter?
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
#define ast_test_flag(p, flag)
static void cc_generic_monitor_destructor(void *private_data)
static int cc_caller_requested(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
struct ast_channel * ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name)
Request a channel of a given type, with data as optional information used by the low level module and...
unsigned int ast_get_cc_recall_timer(struct ast_cc_config_params *config)
Get the cc_recall_timer.
int is_valid
Is this structure valid for use in CC_INTERFACES?
static void generic_monitor_devstate_cb(void *userdata, struct stasis_subscription *sub, struct stasis_message *msg)
static void cc_publish_requestacknowledged(int core_id, const char *caller)
int ast_cc_failed(int core_id, const char *const debug,...)
Indicate failure has occurred.
static char * complete_core_id(const char *word)
static int dialed_cc_interface_counter
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
static const int CC_CORE_INSTANCES_BUCKETS
static void * cc_unref(void *obj, const char *debug)
static void cc_interface_destroy(void *data)
enum ast_cc_agent_policies cc_agent_policy
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
void ast_set_ccbs_available_timer(struct ast_cc_config_params *config, unsigned int value)
Set the ccbs_available_timer.
#define ast_set_flag(p, flag)
int ast_json_object_update(struct ast_json *object, struct ast_json *other)
Update object with all of the fields of other.
static struct cc_core_instance * find_cc_core_instance(const int core_id)
int ast_cc_monitor_request_acked(int core_id, const char *const debug,...)
Indicate that an outbound entity has accepted our CC request.
int ast_cc_agent_accept_request(int core_id, const char *const debug,...)
Accept inbound CC request.
descriptor for a cli entry.
void ast_cc_busy_interface(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, void *private_data)
Callback made from ast_cc_callback for certain channel types.
int(* party_b_free)(struct ast_cc_agent *agent)
Let the caller know that the callee has become free but that the caller cannot attempt to call back b...
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
struct ast_cc_config_params * cc_params
static void * cc_ref(void *obj, const char *debug)
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static const struct ast_datastore_info dialed_cc_interfaces_info
const char * service_string
static int debug
Global debug status.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
char context[AST_CHANNEL_NAME]
static void dummy(char *unused,...)
static void call_destructor_with_no_monitor(const char *const monitor_type, void *private_data)
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary...
#define CONFIG_STATUS_FILEINVALID
int parent_interface_id
ID of parent extension.
int ast_set_cc_monitor_policy(struct ast_cc_config_params *config, enum ast_cc_monitor_policies value)
Set the cc_monitor_policy.
static int cc_recalling(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
enum ast_device_state state
void ast_set_cc_max_monitors(struct ast_cc_config_params *config, unsigned int value)
Set the cc_max_monitors.
int(* cancel_available_timer)(struct ast_cc_monitor *monitor, int *sched_id)
Cancel the running available timer.
int(* status_request)(struct ast_cc_agent *agent)
Request the status of the agent's device.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
static void generic_monitor_instance_list_destructor(void *obj)
static struct ast_cc_monitor * cc_extension_monitor_init(const char *const exten, const char *const context, const unsigned int parent_id)
void(* destructor)(void *private_data)
Destroy private data on the monitor.
struct extension_child_dialstring * next
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
static const struct ast_datastore_info recall_ds_info
#define CC_RECALL_TIMER_DEFAULT
#define CC_COMPLETE_DEVSTATE_DEFAULT
return a reference to a taskprocessor, create one if it does not exist
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
int ast_setup_cc_recall_datastore(struct ast_channel *chan, const int core_id)
Set up a CC recall datastore on a channel.
int ast_devstate_prov_del(const char *label)
Remove device state provider.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
unsigned int cc_recall_timer
Structure for a data store type.
#define ao2_t_link(container, obj, tag)
Add an object to a container.
const char * monitor_type
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
int(* start_offer_timer)(struct ast_cc_agent *agent)
Start the offer timer.
char exten[AST_CHANNEL_NAME]
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
static void build_cc_interfaces_chanvar(struct ast_cc_monitor *starting_point, struct ast_str **str)
ao2_callback_fn * function
static int count_monitors_cb(void *obj, void *arg, int flags)
struct stasis_message_type * ast_cc_callerrecalling_type(void)
A stasis_message_type for CCSS Caller Recalling messages.
static void cc_publish_callerstopmonitoring(int core_id, const char *caller)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define ao2_t_unlink(container, obj, tag)
Remove an object from a container.
static void cc_publish_available(int core_id, const char *callee, const char *service)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
unsigned int ccnr_available_timer
int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
Add device state provider.
int ast_cc_monitor_party_b_free(int core_id)
Alert a caller that though the callee has become free, the caller himself is not and may not call bac...
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define ast_str_alloca(init_len)
static void cc_extension_monitor_destructor(void *private_data)
#define ast_vasprintf(ret, fmt, ap)
A wrapper for vasprintf()
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
static void cc_extension_monitor_change_is_valid(struct cc_core_instance *core_instance, unsigned int parent_id, const char *const device_name, int is_valid)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
const struct ast_cc_monitor_callbacks * callbacks
ast_cc_agent_response_reason
static const char * monitor_policy_to_str(enum ast_cc_monitor_policies policy)
static int cc_generic_agent_stop_offer_timer(struct ast_cc_agent *agent)
#define CC_AVAILABLE_DEVSTATE_DEFAULT
static const char * ccreq_app
static int core_id_counter
static const struct ast_cc_config_params cc_default_params
static void cc_publish_callerrecalling(int core_id, const char *caller)
void ast_cli(int fd, const char *fmt,...)
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
static enum ast_device_state cc_state_to_devstate_map[]
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
struct cc_core_instance * core_instance
int ast_unregister_application(const char *app)
Unregister an application.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
static char cid_num[AST_MAX_EXTENSION]
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
int ast_cc_call_init(struct ast_channel *chan, int *ignore_cc)
Start the CC process on a call.
#define ast_pthread_create_detached_background(a, b, c, d)
static const char * CC_LOGGER_LEVEL_NAME
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
ast_cc_monitor_policies
The various possibilities for cc_monitor_policy values.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
int ast_cc_agent_status_response(int core_id, enum ast_device_state devstate)
Response with a caller's current status.
struct ast_frame_subclass subclass
static int cc_build_payload(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *dialstring, enum ast_cc_service_type service, void *private_data, struct cc_control_payload *payload)
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
static void cc_generic_agent_respond(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason)
static void cc_publish_callerstartmonitoring(int core_id, const char *caller)
int(* unsuspend)(struct ast_cc_monitor *monitor)
Unsuspend monitoring.
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
void ast_ignore_cc(struct ast_channel *chan)
Mark the channel to ignore further CC activity.
struct stasis_message_type * ast_cc_failure_type(void)
A stasis_message_type for CCSS Failure messages.
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
static int cc_caller_offered(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
static int generic_monitor_devstate_tp_cb(void *data)
#define ast_strlen_zero(foo)
int ast_cc_agent_recalling(int core_id, const char *const debug,...)
Tell the CC core that a caller is currently recalling.
struct cc_agent_backend * next
static enum ast_device_state cc_state_to_devstate(enum cc_state state)
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
char cc_callback_sub[AST_MAX_EXTENSION]
static struct ast_sched_context * cc_sched_context
const struct ast_cc_monitor_callbacks * callbacks
void ast_set_cc_offer_timer(struct ast_cc_config_params *config, unsigned int value)
Set the cc_offer_timer.
static const struct @359 cc_service_to_string_map[]
static struct ast_cc_monitor * cc_device_monitor_init(const char *const device_name, const char *const dialstring, const struct cc_control_payload *cc_data, int core_id)
static void cc_interface_tree_destroy(void *data)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
static int cc_generic_monitor_request_cc(struct ast_cc_monitor *monitor, int *available_timer_id)
struct stasis_message_type * ast_device_state_message_type(void)
Get the Stasis message type for device state messages.
int ast_cc_callback(struct ast_channel *inbound, const char *const tech, const char *const dest, ast_cc_callback_fn callback)
Run a callback for potential matching destinations.
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
#define CC_ACTIVE_DEVSTATE_DEFAULT
const struct ast_cc_agent_callbacks * callbacks
int ast_cc_monitor_failed(int core_id, const char *const monitor_name, const char *const debug,...)
Indicate that a failure has occurred on a specific monitor.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
static int cccancel_exec(struct ast_channel *chan, const char *data)
int(* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
Call a function with cc parameters as a function parameter.
static struct cc_core_instance * cc_core_init_instance(struct ast_channel *caller_chan, struct cc_monitor_tree *called_tree, const int core_id, struct cc_control_payload *cc_data)
char device_name[AST_CHANNEL_NAME]
Name of device to be monitored.
enum ast_device_state ast_devstate_val(const char *val)
Convert device state from text to integer value.
General Asterisk PBX channel definitions.
char cc_callback_macro[AST_MAX_EXTENSION]
struct stasis_subscription * sub
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
static const char * cc_state_to_string(enum cc_state state)
const struct ast_eid * eid
The EID of the server where this message originated.
static void request_cc(struct cc_core_instance *core_instance)
static int cc_generic_agent_recall(struct ast_cc_agent *agent)
char dialstring[AST_CHANNEL_NAME]
Recall dialstring.
static int cc_failed(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
const char * ast_get_cc_agent_dialstring(struct ast_cc_config_params *config)
Get the cc_agent_dialstring.
static int offer_timer_expire(const void *data)
int ast_cc_available_timer_expire(const void *data)
Scheduler callback for available timer expiration.
static void cc_publish_offertimerstart(int core_id, const char *caller, unsigned int expires)
Structure with information about an outbound interface.
struct stasis_message_type * ast_cc_monitorfailed_type(void)
A stasis_message_type for CCSS Monitor Failed messages.
static struct generic_monitor_instance_list * create_new_generic_list(struct ast_cc_monitor *monitor)
#define AST_MAX_EXTENSION
#define AST_RWLIST_TRAVERSE
int ast_cc_is_recall(struct ast_channel *chan, int *core_id, const char *const monitor_type)
Decide if a call to a particular channel is a CC recall.
void ast_handle_cc_control_frame(struct ast_channel *inbound, struct ast_channel *outbound, void *frame_data)
Properly react to a CC control frame.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
static int cc_do_state_change(void *datap)
structure to hold extensions
int(* stop_ringing)(struct ast_cc_agent *agent)
Request for an agent's phone to stop ringing.
#define ao2_ref(o, delta)
int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan)
Set the first level CC_INTERFACES channel variable for a channel.
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
struct stasis_message_type * ast_cc_offertimerstart_type(void)
A stasis_message_type for CCSS Offer Timer Start messages.
static void cc_publish_monitorfailed(int core_id, const char *callee)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
struct ast_cc_agent * ast_cc_agent_callback(int flags, ao2_callback_fn *function, void *args, const char *const type)
Call a callback on all agents of a specific type.
static int cc_stop_ringing(void *data)
void ast_cc_call_failed(struct ast_channel *incoming, struct ast_channel *outgoing, const char *const dialstring)
Make CCBS available in the case that ast_call fails.
#define AST_RWLIST_REMOVE_CURRENT
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_cc_request_is_within_limits(void)
Check if the incoming CC request is within the bounds set by the cc_max_requests configuration option...
int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size)
Find the appropriate CC agent type to use given a channel.
static int cc_monitor_failed(void *data)
unsigned int cc_max_agents
static int cc_caller_busy(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
int(* start_monitoring)(struct ast_cc_agent *agent)
Begin monitoring a busy device.
int ast_cc_completed(struct ast_channel *chan, const char *const debug,...)
Indicate recall has been acknowledged.
#define ast_malloc(len)
A wrapper for malloc()
cc_state
The states used in the CCSS core state machine.
static struct ast_cli_entry cc_cli[]
static enum ast_cc_agent_policies str_to_agent_policy(const char *const value)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
void ast_set_ccnr_available_timer(struct ast_cc_config_params *config, unsigned int value)
Set the ccnr_available_timer.
struct stasis_message_type * ast_cc_callerstopmonitoring_type(void)
A stasis_message_type for CCSS Caller Stop Monitoring messages.
int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
const char * ast_get_cc_callback_macro(struct ast_cc_config_params *config)
Get the name of the callback_macro.
struct stasis_subscription * sub
void(* respond)(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason)
Respond to a CC request.
int ast_logger_register_level(const char *name)
Register a new logger level.
#define CC_CALLER_BUSY_DEVSTATE_DEFAULT
static void initialize_cc_devstate_map(void)
Structure to describe a channel "technology", ie a channel driver See for examples: ...
const char * ast_channel_exten(const struct ast_channel *chan)
Core PBX routines and definitions.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static int cc_active(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
int ast_cc_monitor_status_request(int core_id)
Request the status of a caller or callers.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_CC_GENERIC_MONITOR_TYPE
static int cc_request_state_change(enum cc_state state, const int core_id, const char *debug, va_list ap)
#define stasis_subscribe(topic, callback, data)
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
struct generic_monitor_instance_list::@364 list
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
static int cc_status_response(void *data)
static int cc_generic_monitor_unsuspend(struct ast_cc_monitor *monitor)
static int ccreq_exec(struct ast_channel *chan, const char *data)
struct ast_cc_config_params * config_params
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
static int cc_interfaces_datastore_init(struct ast_channel *chan)
static void check_callback_sanity(const struct ast_cc_agent_callbacks *callbacks)
const char * type
Type of agent the callbacks belong to.
static const struct ast_cc_agent_callbacks * find_agent_callbacks(struct ast_channel *chan)
struct ao2_container * generic_monitors
static struct ast_cc_agent_callbacks generic_agent_callbacks
int(* status_response)(struct ast_cc_monitor *monitor, enum ast_device_state devstate)
Status response to an ast_cc_monitor_status_request().
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
struct extension_monitor_pvt::@366 child_dialstrings
char * ast_tech_to_upper(char *dev_str)
Convert the tech portion of a device string to upper case.
static int(*const state_change_funcs[])(struct cc_core_instance *, struct cc_state_change_args *, enum cc_state previous_state)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
char device_name[AST_CHANNEL_NAME]
The name of the device being dialed.
Structure representing an agent.
#define ao2_t_iterator_next(iter, tag)
static void cc_monitor_destroy(void *data)
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.
#define CCNR_AVAILABLE_TIMER_DEFAULT
int ast_cc_build_frame(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, enum ast_cc_service_type service, void *private_data, struct ast_frame *frame)
Create a CC Control frame.
static unsigned int monitor
static int cc_generic_agent_start_offer_timer(struct ast_cc_agent *agent)
static int cc_available(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
static struct generic_monitor_instance_list * find_generic_monitor_instance_list(const char *const device_name)
static int cc_core_instance_cmp_fn(void *obj, void *arg, int flags)
int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
Register a set of monitor callbacks with the core.
#define CC_MAX_AGENTS_DEFAULT
static int kill_cores(void *obj, void *arg, int flags)
#define ao2_t_callback(c, flags, cb_fn, arg, tag)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
enum ast_cc_service_type service
Service offered by the endpoint.
static void cc_publish_requested(int core_id, const char *caller, const char *callee)
void ast_cc_agent_unregister(const struct ast_cc_agent_callbacks *callbacks)
Unregister a set of agent callbacks with the core.
static int cc_status_request(void *data)
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
The "tree" of interfaces that is dialed.
enum cc_state current_state
static int unload_module(void)
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes. ...
struct stasis_message_type * ast_cc_recallcomplete_type(void)
A stasis_message_type for CCSS Recall Complete messages.
int(* callee_available)(struct ast_cc_agent *agent)
Alert the caller that it is time to try recalling.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
int stasis_subscription_final_message(struct stasis_subscription *sub, struct stasis_message *msg)
Determine whether a message is the final message to be received on a subscription.
#define ast_channel_unlock(chan)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
struct cc_core_instance * core_instance
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
static void cancel_available_timer(struct cc_core_instance *core_instance)
#define ast_calloc(num, len)
A wrapper for calloc()
int(* request_cc)(struct ast_cc_monitor *monitor, int *available_timer_id)
Request CCSS.
char * dialstring
Name that should be used to recall specified interface.
const char * monitor_type
The type of monitor that should be used for this interface.
#define CC_CALLEE_READY_DEVSTATE_DEFAULT
Call Completion Supplementary Services API.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Module could not be loaded properly.
int ast_cc_get_current_core_id(struct ast_channel *chan)
Get the core id for the current call.
#define ao2_t_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn, tag)
Allocate and initialize a hash container with the desired number of buckets.
int ast_cc_get_param(struct ast_cc_config_params *params, const char *const name, char *buf, size_t buf_len)
get a CCSS configuration parameter, given its name
#define CC_MAX_MONITORS_DEFAULT
static void suspend(struct cc_core_instance *core_instance)
static const char * agent_policy_to_str(enum ast_cc_agent_policies policy)
static int match_agent(void *obj, void *arg, void *data, int flags)
int ast_sched_del(struct ast_sched_context *con, int id) attribute_warn_unused_result
Deletes a scheduled event.
static void dialed_cc_interfaces_destroy(void *data)
#define DATASTORE_INHERIT_FOREVER
int ast_cc_agent_caller_available(int core_id, const char *const debug,...)
Indicate that a previously unavailable caller has become available.
struct cc_monitor_backend * next
An API for managing task processing threads that can be shared across modules.
struct ast_cc_interface * interface
static int is_state_change_valid(enum cc_state current_state, const enum cc_state new_state, struct ast_cc_agent *agent)
int ast_sched_add(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data) attribute_warn_unused_result
Adds a scheduled event.
static void kill_duplicate_offers(char *caller)
Structure used to handle boolean flags.
private data for generic device monitor
struct cc_monitor_tree * interface_tree
int(* suspend)(struct ast_cc_monitor *monitor)
Suspend monitoring.
static char cid_name[AST_MAX_EXTENSION]
static struct ast_cc_agent * cc_agent_init(struct ast_channel *caller_chan, const char *const caller_name, const int core_id, struct cc_monitor_tree *interface_tree)
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",)
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
unsigned int ast_get_cc_max_agents(struct ast_cc_config_params *config)
Get the cc_max_agents.
void ast_set_cc_recall_timer(struct ast_cc_config_params *config, unsigned int value)
Set the cc_recall_timer.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
unsigned int ast_get_cc_max_monitors(struct ast_cc_config_params *config)
Get the cc_max_monitors.
static void initialize_cc_max_requests(void)
static void cc_cli_print_monitor_stats(struct ast_cc_monitor *monitor, int fd, int parent_id)
static int cc_generic_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
#define CC_CALLER_REQUESTED_DEVSTATE_DEFAULT
static int cc_offer(const int core_id, const char *const debug,...)
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
struct stasis_message_type * ast_cc_requested_type(void)
A stasis_message_type for CCSS Requested messages.
#define AST_RWLIST_INSERT_TAIL
const struct ast_cc_agent_callbacks * callbacks
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AO2_STRING_FIELD_CMP_FN(stype, field)
Creates a compare function for a structure string field.
A ast_taskprocessor structure is a singleton by name.
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
char original_dialstring[AST_CHANNEL_NAME]
the original dialstring used to call a particular device
static void generic_agent_devstate_cb(void *userdata, struct stasis_subscription *sub, struct stasis_message *msg)
static enum ast_device_state ccss_device_state(const char *device_name)
#define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag)
ao2_callback_data() is a generic function that applies cb_fn() to all objects in a container...
struct ast_cc_config_params config_params
Configuration parameters used by this endpoint.
void ast_cc_default_config_params(struct ast_cc_config_params *params)
Set the specified CC config params to default values.
int ast_cc_monitor_stop_ringing(int core_id)
Alert a caller to stop ringing.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
enum ast_cc_agent_policies ast_get_cc_agent_policy(struct ast_cc_config_params *config)
Get the cc_agent_policy.
Standard Command Line Interface.
int ast_channel_hangupcause(const struct ast_channel *chan)
#define CC_RECALLING_DEVSTATE_DEFAULT
unsigned int cc_max_monitors
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int cc_cli_output_status(void *data)
static void * dialed_cc_interfaces_duplicate(void *data)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
const char * ast_channel_name(const struct ast_channel *chan)
static int cc_agent_callback_helper(void *obj, void *args, int flags)
Data regarding an extension monitor's child's dialstrings.
struct stasis_message_type * ast_cc_requestacknowledged_type(void)
A stasis_message_type for CCSS Request Acknowledged messages.
void ast_cc_monitor_unregister(const struct ast_cc_monitor_callbacks *callbacks)
Unregister a set of monitor callbacks with the core.
Private data for an extension monitor.
struct stasis_message_type * ast_cc_available_type(void)
A stasis_message_type for CCSS Available messages.
static void ccss_notify_device_state_change(const char *device, enum cc_state state)
static void cc_core_instance_destructor(void *data)
static struct ao2_container * cc_core_instances
#define ao2_t_find(container, arg, flags, tag)
int(* init)(struct ast_cc_agent *agent, struct ast_channel *chan)
CC agent initialization.
const char * state_string
char cid_name[AST_CHANNEL_NAME]
unsigned int flags
Flags for agent operation.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
struct stasis_forward * sub
Data structure associated with a single frame of data.
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Internal Asterisk hangup causes.
struct cc_monitor_tree * interface_tree
static int has_device_monitors(struct cc_core_instance *core_instance)
check if the core instance has any device monitors
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
Abstract JSON element (object, array, string, int, ...).
static int print_stats_cb(void *obj, void *arg, int flags)
static struct ast_cc_monitor_callbacks generic_monitor_cbs
static int cc_generic_agent_stop_ringing(struct ast_cc_agent *agent)
The structure that contains device state.
const char * ast_channel_context(const struct ast_channel *chan)
struct stasis_message_type * stasis_subscription_change_type(void)
Gets the message type for subscription change notices.
ast_cc_agent_policies
The various possibilities for cc_agent_policy values.
static int cc_generic_is_device_available(enum ast_device_state state)
#define ast_datastore_alloc(info, uid)
union ast_frame::@263 data
const char * monitor_type
The type of monitor to allocate.
struct ast_cc_monitor * ast_cc_get_monitor_by_recall_core_id(const int core_id, const char *const device_name)
Get the associated monitor given the device name and core_id.
static long count_agents(const char *const caller, const int core_id_exception)
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
struct ast_cc_agent * agent
void * private_data
Data that is private to a monitor technology.
static const char * cccancel_app
int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
Register a set of agent callbacks with the core.
int ast_cc_set_param(struct ast_cc_config_params *params, const char *const name, const char *const value)
set a CCSS configuration parameter, given its name
static void cc_generic_agent_destructor(struct ast_cc_agent *agent)
Callbacks defined by CC monitors.
void ast_set_cc_max_agents(struct ast_cc_config_params *config, unsigned int value)
Set the cc_max_agents.
unsigned int dial_parent_id
static char context[AST_MAX_CONTEXT]
int ast_set_cc_agent_policy(struct ast_cc_config_params *config, enum ast_cc_agent_policies value)
Set the cc_agent_policy.
void(* destructor)(struct ast_cc_agent *agent)
Destroy private data on the agent.
const char * ast_get_cc_callback_sub(struct ast_cc_config_params *config)
Get the name of the callback subroutine.
#define CCBS_AVAILABLE_TIMER_DEFAULT
int ast_cc_agent_caller_busy(int core_id, const char *debug,...)
Indicate that the caller is busy.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
const char * ast_channel_macrocontext(const struct ast_channel *chan)
static int cc_logger_level
enum ast_device_state current_state
static char * handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
enum ast_cc_service_type service_offered
#define ASTERISK_GPL_KEY
The text the key() function should return.
void ast_channel_priority_set(struct ast_channel *chan, int value)
static int cc_publish(struct stasis_message_type *message_type, int core_id, struct ast_json *extras)
Asterisk module definitions.
#define CC_CALLER_OFFERED_DEVSTATE_DEFAULT
int(* stop_offer_timer)(struct ast_cc_agent *agent)
Stop the offer timer.
static void cc_publish_failure(int core_id, const char *caller, const char *reason)
unsigned int ast_get_cc_offer_timer(struct ast_cc_config_params *config)
Get the cc_offer_timer.
static snd_pcm_format_t format
unsigned int ccbs_available_timer
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
static int cc_core_instance_hash_fn(const void *obj, const int flags)
#define GLOBAL_CC_MAX_REQUESTS_DEFAULT
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static void initialize_cc_devstate_map_helper(struct ast_config *cc_config, enum cc_state state, const char *cc_setting)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
enum ast_device_state devstate
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
static int cc_request_count
#define AST_RWLIST_TRAVERSE_SAFE_END
struct generic_monitor_instance * next
static int cc_callee_ready(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
#define AST_CAUSE_CONGESTION
const char * ast_channel_macroexten(const struct ast_channel *chan)
enum ast_cc_service_type service
enum ast_cc_monitor_class monitor_class
void ast_set_cc_callback_macro(struct ast_cc_config_params *config, const char *const value)
Set the callback_macro name.
unsigned int ast_get_ccbs_available_timer(struct ast_cc_config_params *config)
Get the ccbs_available_timer.
char cc_agent_dialstring[AST_MAX_EXTENSION]
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
enum ast_cc_monitor_policies cc_monitor_policy
unsigned int cc_offer_timer
static int cc_party_b_free(void *data)
void * __ast_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc
static struct ast_taskprocessor * cc_core_taskprocessor
static void * cc_recall_ds_duplicate(void *data)
int ast_cc_monitor_count(const char *const name, const char *const type)
Return the number of outstanding CC requests to a specific device.
static int cc_complete(struct cc_core_instance *core_instance, struct cc_state_change_args *args, enum cc_state previous_state)
static void agent_destroy(void *data)