|
Asterisk - The Open Source Telephony Project GIT-master-6144b6b
|
#include "asterisk.h"#include "asterisk/_private.h"#include "asterisk/module.h"#include "asterisk/extension_state.h"#include "asterisk/pbx.h"#include "asterisk/stasis.h"#include "asterisk/stasis_message_router.h"#include "asterisk/astobj2.h"#include "asterisk/cli.h"#include "pbx_private.h"
Go to the source code of this file.
Data Structures | |
| struct | cfextension_states |
| struct | device_state_sources_vector |
| struct | extension_state |
| Extension state information. More... | |
| struct | extension_state_device_source |
| Device state source feeding an extension state. More... | |
Macros | |
| #define | DEVICE_SOURCE_ELEM_VERSION_CMP(elem, value) ((elem)->version != (value)) |
| device source non-matching version comparator for AST_VECTOR_REMOVE_CMP_UNORDERED() | |
| #define | EXTENSION_STATE_BUCKETS 563 |
| Number of buckets for extension states. | |
| #define | HINTDEVICE_DATA_LENGTH 16 |
Variables | |
| static struct ast_cli_entry | extension_state_cli [] |
| static const struct cfextension_states | extension_state_mappings [] |
| static struct stasis_topic * | extension_state_topic_all |
| Topic which receives all extension state updates. | |
| static struct ao2_container * | extension_states |
| The global container of extension states. | |
| static struct stasis_subscription * | presence_state_sub |
| Single presence state subscription, for all extension states. | |
device source non-matching version comparator for AST_VECTOR_REMOVE_CMP_UNORDERED()
| elem | Element to compare against |
| value | Value to compare with the vector element. |
Definition at line 567 of file extension_state.c.
| #define EXTENSION_STATE_BUCKETS 563 |
Number of buckets for extension states.
Definition at line 125 of file extension_state.c.
| #define HINTDEVICE_DATA_LENGTH 16 |
Definition at line 82 of file extension_state.c.
|
static |
Definition at line 1184 of file extension_state.c.
References ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_extension_state2str(), ast_get_extension_app(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), astman_send_list_complete_end(), astman_send_list_complete_start(), astman_send_listack(), and extension_states.
Referenced by ast_extension_state_init().
| enum ast_extension_states ast_devstate_to_extenstate | ( | enum ast_device_state | devstate | ) |
Map devstate to an extension state.
| [in] | devstate | device state |
Definition at line 1136 of file extension_state.c.
References AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_TOTAL, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, AST_EXTENSION_BUSY, AST_EXTENSION_INUSE, AST_EXTENSION_NOT_INUSE, AST_EXTENSION_ONHOLD, AST_EXTENSION_RINGING, and AST_EXTENSION_UNAVAILABLE.
Referenced by AST_TEST_DEFINE(), extension_state_device_state_cb(), and extension_state_update_sources().
| const char * ast_extension_state2str | ( | int | extension_state | ) |
Return string representation of the state of an extension.
| extension_state | is the numerical state delivered by ast_extension_state |
Definition at line 1163 of file extension_state.c.
References ARRAY_LEN, extension_state_mappings, and cfextension_states::text.
Referenced by action_extensionstate(), action_extensionstatelist(), AST_TEST_DEFINE(), exten_state_publisher_state_cb(), handle_show_hint(), handle_show_hints(), manager_state_cb(), and to_ami().
| struct ast_channel * ast_extension_state_get_device_causing_channel | ( | const char * | device, |
| enum ast_device_state | device_state | ||
| ) |
Get the channel that is causing the device to be in the given state, if any.
| device | The device itself |
| device_state | The state of the device |
| NULL | if there is no channel causing the device to be in the given state |
Definition at line 1070 of file extension_state.c.
References ast_channel_creationtime(), ast_channel_iterator_by_name_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_ref, ast_channel_unlock, ast_channel_unref, AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_TOTAL, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, AST_STATE_BUSY, AST_STATE_RINGING, AST_STATE_UP, ast_tvcmp(), match(), and NULL.
Referenced by extension_state_legacy_create_device_state_info().
| struct ast_extension_state_device_snapshot * ast_extension_state_get_latest_device_snapshot | ( | struct ast_channel * | chan, |
| const char * | exten, | ||
| const char * | context | ||
| ) |
Get the latest device state message for an extension.
| chan | The optional channel to get the underlying hint from, if it needs to be created |
| exten | The extension to get the device state message for |
| context | The context of the extension |
| NULL | if the extension does not have a configured hint |
Definition at line 1317 of file extension_state.c.
References ao2_bump, ao2_lock, ao2_ref, ao2_unlock, extension_state_get(), and NULL.
Referenced by ast_extension_state(), and ast_extension_state_extended().
| struct ast_extension_state_presence_snapshot * ast_extension_state_get_latest_presence_snapshot | ( | struct ast_channel * | chan, |
| const char * | exten, | ||
| const char * | context | ||
| ) |
Get the latest presence state message for an extension.
| chan | The optional channel to get the underlying hint from, if it needs to be created |
| exten | The extension to get the presence state message for |
| context | The context of the extension |
| NULL | if the extension does not have a configured hint |
Definition at line 1336 of file extension_state.c.
References ao2_bump, ao2_lock, ao2_ref, ao2_unlock, extension_state_get(), and NULL.
Referenced by ast_hint_presence_state().
| int ast_extension_state_init | ( | void | ) |
Provided by extension_state.c
Definition at line 1560 of file extension_state.c.
References action_extensionstatelist(), AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_rbtree, ARRAY_LEN, ast_cli_register_multiple, ast_extension_state_remove_message_type(), ast_extension_state_update_message_type(), ast_log, ast_manager_register_xml_core, ast_presence_state_message_type(), ast_presence_state_topic_all(), ast_register_cleanup(), EVENT_FLAG_CALL, EVENT_FLAG_REPORTING, extension_state_cleanup(), extension_state_cli, extension_state_presence_state_cb(), extension_state_topic_all, extension_states, LOG_ERROR, NULL, presence_state_sub, STASIS_MESSAGE_TYPE_INIT, stasis_subscribe, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), and stasis_topic_create().
Referenced by asterisk_daemon().
| struct stasis_topic * ast_extension_state_topic | ( | const char * | exten, |
| const char * | context | ||
| ) |
Get the Stasis topic to receive extension state messages for a specific extension.
| exten | The extension to receive extension state messages for |
| context | The context of the extension |
| NULL | if it has not been allocated |
Definition at line 1299 of file extension_state.c.
References ao2_bump, ao2_lock, ao2_ref, ao2_unlock, extension_state_get(), and NULL.
Referenced by extension_state_legacy_add_destroy().
| struct stasis_topic * ast_extension_state_topic_all | ( | void | ) |
Get the Stasis topic to receive all extension state messages.
| NULL | if it has not been allocated |
Definition at line 1294 of file extension_state.c.
References extension_state_topic_all.
Referenced by extension_state_legacy_add_destroy().
| AST_THREADSTORAGE_CUSTOM_SCOPE | ( | hintdevice_data | , |
| NULL | , | ||
| ast_free_ptr | , | ||
| static | |||
| ) |
|
static |
Definition at line 1426 of file extension_state.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_strdup, extension_state::dialplan_extension, extension_states, and NULL.
Referenced by handle_show_hint().
|
static |
Definition at line 925 of file extension_state.c.
References ao2_alloc, ao2_ref, ast_asprintf, ast_copy_string(), AST_EXTENSION_UNAVAILABLE, ast_free, ast_get_context_name(), ast_get_extension_name(), AST_MAX_CONTEXT, AST_MAX_EXTENSION, AST_PRESENCE_NOT_SET, AST_VECTOR_INIT, extension_state_destroy(), extension_state_device_snapshot_create(), extension_state_presence_snapshot_create(), extension_state_topic_all, NULL, stasis_forward_all(), and stasis_topic_create().
Referenced by pbx_extension_state_hint_set().
|
static |
Definition at line 1547 of file extension_state.c.
References ao2_callback, ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_extension_state_remove_message_type(), ast_extension_state_update_message_type(), ast_manager_unregister(), extension_state_cleanup_individual(), extension_state_cli, extension_states, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, presence_state_sub, STASIS_MESSAGE_TYPE_CLEANUP, and stasis_unsubscribe_and_join().
Referenced by ast_extension_state_init().
|
static |
Definition at line 1534 of file extension_state.c.
References CMP_MATCH, and extension_state_shutdown().
Referenced by extension_state_cleanup().
|
static |
Definition at line 727 of file extension_state.c.
References ao2_cleanup, and ast_free.
Referenced by extension_state_alloc().
|
static |
Definition at line 290 of file extension_state.c.
References ast_extension_state_device_snapshot::additional_devices, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ao2_ref, AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_INIT, AST_VECTOR_SIZE, ast_extension_state_device_snapshot::causing_device, extension_state_device_snapshot_destroy(), extension_state_device_source::info, NULL, and ast_extension_state_device_snapshot::state.
Referenced by extension_state_alloc(), extension_state_device_state_cb(), and extension_state_update_sources().
|
static |
Definition at line 269 of file extension_state.c.
References ast_extension_state_device_snapshot::additional_devices, ao2_cleanup, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_FREE, and ast_extension_state_device_snapshot::causing_device.
Referenced by extension_state_device_snapshot_create().
|
static |
Definition at line 452 of file extension_state.c.
References ast_calloc, ast_device_state_message_type(), ast_device_state_topic(), extension_state_device_source::device_state_subscription, extension_state_device_source_destroy(), extension_state_device_state_cb(), extension_state_device_state_info_alloc(), extension_state_device_source::info, NULL, stasis_subscribe_synchronous, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, and stasis_subscription_set_filter().
Referenced by extension_state_update_sources().
|
static |
Definition at line 225 of file extension_state.c.
References ao2_cleanup, ast_free, extension_state_device_source::device_state_subscription, extension_state_device_source::info, and stasis_unsubscribe().
Referenced by extension_state_device_source_alloc(), extension_state_shutdown(), and extension_state_update_sources().
|
static |
Definition at line 334 of file extension_state.c.
References ao2_lock, ao2_ref, ao2_replace, ao2_unlock, ast_device_state_message_type(), ast_devstate_aggregate_add(), ast_devstate_aggregate_init(), ast_devstate_aggregate_result(), ast_devstate_to_extenstate(), AST_EXTENSION_RINGING, ast_extension_state_update_message_type(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_device_state_message::device, ast_extension_state_device_state_info::device, ast_device_state_message::eid, extension_state_device_snapshot_create(), extension_state_device_state_info_alloc(), extension_state_update_message_create(), extension_state_device_source::info, stasis_message_create(), stasis_message_data(), stasis_publish(), ast_device_state_message::state, and ast_extension_state_device_state_info::state.
Referenced by extension_state_device_source_alloc().
|
static |
Definition at line 244 of file extension_state.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ast_extension_state_device_state_info::device, NULL, and ast_extension_state_device_state_info::state.
Referenced by extension_state_device_source_alloc(), and extension_state_device_state_cb().
|
static |
Definition at line 1007 of file extension_state.c.
References ao2_find, ast_add_extension(), ast_free_ptr(), ast_get_extension_app(), ast_get_extension_app_data(), ast_get_extension_cidmatch(), ast_get_extension_label(), ast_get_extension_matchcid(), ast_get_extension_name(), ast_get_extension_registrar(), AST_MAX_CONTEXT, AST_MAX_EXTENSION, ast_strdup, ast_unlock_contexts(), ast_wrlock_contexts(), E_MATCH, extension_states, pbx_find_info::foundcontext, NULL, OBJ_SEARCH_KEY, pbx_find_extension(), PRIORITY_HINT, and pbx_find_info::stacklen.
Referenced by ast_extension_state_get_latest_device_snapshot(), ast_extension_state_get_latest_presence_snapshot(), and ast_extension_state_topic().
|
static |
Definition at line 527 of file extension_state.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_strdup, extension_state_presence_snapshot_destroy(), NULL, ast_extension_state_presence_snapshot::presence_message, ast_extension_state_presence_snapshot::presence_state, and ast_extension_state_presence_snapshot::presence_subtype.
Referenced by extension_state_alloc(), extension_state_presence_state_cb(), and extension_state_update_sources().
|
static |
Definition at line 507 of file extension_state.c.
References ast_free, ast_extension_state_presence_snapshot::presence_message, and ast_extension_state_presence_snapshot::presence_subtype.
Referenced by extension_state_presence_snapshot_create().
|
static |
Definition at line 822 of file extension_state.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_replace, ao2_unlock, ast_extension_state_update_message_type(), ast_free, AST_PRESENCE_INVALID, ast_presence_state_message_type(), extension_state_presence_snapshot_create(), extension_state_update_message_create(), extension_states, stasis_message_create(), stasis_message_data(), stasis_publish(), and strcasestr().
Referenced by ast_extension_state_init().
|
static |
Definition at line 751 of file extension_state.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, ast_copy_string(), ast_extension_state_remove_message_type(), ast_extension_state_remove_message::context, ast_extension_state_remove_message::extension, NULL, and stasis_message_create().
Referenced by extension_state_shutdown().
|
static |
Definition at line 783 of file extension_state.c.
References ao2_ref, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_FREE, extension_state_device_source_destroy(), extension_state_remove_message_create(), stasis_forward_cancel(), and stasis_publish().
Referenced by extension_state_cleanup_individual(), and pbx_extension_state_hint_remove().
|
static |
Definition at line 190 of file extension_state.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ast_copy_string(), ast_extension_state_update_message::context, ast_extension_state_update_message::extension, extension_state_update_message_destroy(), ast_extension_state_update_message::new_device_snapshot, ast_extension_state_update_message::new_presence_snapshot, NULL, ast_extension_state_update_message::old_device_snapshot, and ast_extension_state_update_message::old_presence_snapshot.
Referenced by extension_state_device_state_cb(), extension_state_presence_state_cb(), and extension_state_update_sources().
|
static |
Definition at line 165 of file extension_state.c.
References ao2_cleanup, ast_extension_state_update_message::new_device_snapshot, ast_extension_state_update_message::new_presence_snapshot, ast_extension_state_update_message::old_device_snapshot, and ast_extension_state_update_message::old_presence_snapshot.
Referenced by extension_state_update_message_create().
|
static |
Definition at line 580 of file extension_state.c.
References ao2_lock, ao2_ref, ao2_replace, ao2_unlock, ast_devstate_aggregate_add(), ast_devstate_aggregate_init(), ast_devstate_aggregate_result(), ast_devstate_to_extenstate(), ast_extension_state_update_message_type(), AST_EXTENSION_UNAVAILABLE, ast_free, ast_get_extension_app(), AST_PRESENCE_NOT_SET, ast_random(), ast_str_buffer(), ast_str_set(), ast_str_thread_get(), ast_strdup, ast_strlen_zero(), AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_REMOVE_ALL_CMP_UNORDERED, AST_VECTOR_SIZE, ast_extension_state_device_state_info::device, DEVICE_SOURCE_ELEM_VERSION_CMP, extension_state_device_snapshot_create(), extension_state_device_source_alloc(), extension_state_device_source_destroy(), extension_state_presence_snapshot_create(), extension_state_update_message_create(), HINTDEVICE_DATA_LENGTH, extension_state_device_source::info, NULL, stasis_message_create(), stasis_publish(), ast_extension_state_device_state_info::state, str, strsep(), version, and extension_state_device_source::version.
Referenced by pbx_extension_state_hint_set().
|
static |
Definition at line 1466 of file extension_state.c.
References a, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_cli(), ast_extension_state2str(), ast_get_extension_app(), ast_presence_state2str(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_core_show_hint(), extension_state::device_snapshot, extension_state::extension, extension_state::extension_state_topic, extension_states, extension_state::hint_extension, NULL, extension_state::presence_snapshot, ast_extension_state_presence_snapshot::presence_state, stasis_topic_subscribers(), ast_extension_state_device_snapshot::state, and ast_cli_entry::usage.
|
static |
Definition at line 1365 of file extension_state.c.
References a, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_cli(), ast_extension_state2str(), ast_get_extension_app(), ast_presence_state2str(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, extension_states, NULL, stasis_topic_subscribers(), and ast_cli_entry::usage.
| void pbx_extension_state_hint_remove | ( | struct ast_exten * | exten, |
| struct ast_context * | context | ||
| ) |
Definition at line 1269 of file extension_state.c.
References ao2_cleanup, ao2_find, ao2_lock, ao2_ref, ao2_unlink_flags, ao2_unlock, ast_get_context_name(), ast_get_extension_name(), AST_MAX_CONTEXT, AST_MAX_EXTENSION, extension_state_shutdown(), extension_states, OBJ_NOLOCK, and OBJ_SEARCH_KEY.
Referenced by ast_change_hint(), and ast_remove_hint().
| void pbx_extension_state_hint_set | ( | struct ast_exten * | exten, |
| struct ast_context * | context | ||
| ) |
extension_state.c functions needed by pbx.c
Definition at line 1239 of file extension_state.c.
References ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_get_context_name(), ast_get_extension_name(), ast_log, AST_MAX_CONTEXT, AST_MAX_EXTENSION, extension_state_alloc(), extension_state_update_sources(), extension_states, LOG_WARNING, OBJ_NOLOCK, and OBJ_SEARCH_KEY.
Referenced by ast_add_hint(), ast_change_hint(), and context_promote().
| STASIS_MESSAGE_TYPE_DEFN | ( | ast_extension_state_remove_message_type | ) |
Stasis message type for extension state remove messages.
| STASIS_MESSAGE_TYPE_DEFN | ( | ast_extension_state_update_message_type | ) |
Sort function for extension states.
Compare function for extension states
Message type for extension state updates
|
static |
Definition at line 1520 of file extension_state.c.
Referenced by ast_extension_state_init(), and extension_state_cleanup().
|
static |
Referenced by ast_extension_state2str().
|
static |
Topic which receives all extension state updates.
Definition at line 146 of file extension_state.c.
Referenced by ast_extension_state_init(), ast_extension_state_topic_all(), and extension_state_alloc().
|
static |
The global container of extension states.
Definition at line 143 of file extension_state.c.
Referenced by action_extensionstatelist(), ast_extension_state_init(), complete_core_show_hint(), extension_state_cleanup(), extension_state_get(), extension_state_presence_state_cb(), handle_show_hint(), handle_show_hints(), pbx_extension_state_hint_remove(), and pbx_extension_state_hint_set().
|
static |
Single presence state subscription, for all extension states.
Definition at line 149 of file extension_state.c.
Referenced by ast_extension_state_init(), and extension_state_cleanup().