Asterisk - The Open Source Telephony Project
18.5.0
|
Local proxy channel driver. More...
#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/cli.h"
#include "asterisk/manager.h"
#include "asterisk/devicestate.h"
#include "asterisk/astobj2.h"
#include "asterisk/bridge.h"
#include "asterisk/core_unreal.h"
#include "asterisk/core_local.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/_private.h"
#include "asterisk/stream.h"
#include "asterisk/translate.h"
Go to the source code of this file.
Data Structures | |
struct | local_bridge |
struct | local_pvt |
the local pvt structure for all channels More... | |
Enumerations | |
enum | local_call_action { LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_MASQUERADE } |
Functions | |
struct ast_channel * | ast_local_get_peer (struct ast_channel *ast) |
Get the other local channel in the pair. More... | |
int | ast_local_init (void) |
Initialize the local proxy channel. More... | |
void | ast_local_lock_all (struct ast_channel *chan, void **tech_pvt, struct ast_channel **base_chan, struct ast_channel **base_owner) |
Add a reference to the local channel's private tech, lock the local channel's private base, and add references and lock both sides of the local channel. More... | |
int | ast_local_setup_bridge (struct ast_channel *ast, struct ast_bridge *bridge, struct ast_channel *swap, struct ast_bridge_features *features) |
Setup the outgoing local channel to join a bridge on ast_call(). More... | |
int | ast_local_setup_masquerade (struct ast_channel *ast, struct ast_channel *masq) |
Setup the outgoing local channel to masquerade into a channel on ast_call(). More... | |
void | ast_local_unlock_all (void *tech_pvt, struct ast_channel *base_chan, struct ast_channel *base_owner) |
Remove a reference to the given local channel's private tech, unlock the given local channel's private base, and remove references and unlock both sides of given the local channel. More... | |
static struct local_pvt * | local_alloc (const char *data, struct ast_stream_topology *topology) |
Create a call structure. More... | |
static int | local_call (struct ast_channel *ast, const char *dest, int timeout) |
Initiate new call, part of PBX interface dest is the dial string. More... | |
static struct ast_multi_channel_blob * | local_channel_optimization_blob (struct local_pvt *p, struct ast_json *json_object) |
static int | local_devicestate (const char *data) |
Adds devicestate to local channels. More... | |
static int | local_hangup (struct ast_channel *ast) |
Hangup a call through the local proxy channel. More... | |
static struct ast_manager_event_blob * | local_message_to_ami (struct stasis_message *msg) |
static void | local_optimization_finished_cb (struct ast_unreal_pvt *base, int success, unsigned int id) |
Callback for ast_unreal_pvt_callbacks optimization_finished_cb. More... | |
static void | local_optimization_started_cb (struct ast_unreal_pvt *base, struct ast_channel *source, enum ast_unreal_channel_indicator dest, unsigned int id) |
Callback for ast_unreal_pvt_callbacks optimization_started_cb. More... | |
static void | local_pvt_destructor (void *vdoomed) |
static struct ast_channel * | local_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause) |
Part of PBX interface. More... | |
static struct ast_channel * | local_request_with_stream_topology (const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause) |
Part of PBX interface. More... | |
static int | local_setoption (struct ast_channel *chan, int option, void *data, int datalen) |
static void | local_shutdown (void) |
static int | locals_cmp_cb (void *obj, void *arg, int flags) |
static char * | locals_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command "local show channels". More... | |
static int | manager_optimize_away (struct mansession *s, const struct message *m) |
static void | publish_local_bridge_message (struct local_pvt *p) |
STASIS_MESSAGE_TYPE_DEFN (ast_local_bridge_type,.to_ami=local_message_to_ami,) | |
Define local channel message types. More... | |
STASIS_MESSAGE_TYPE_DEFN (ast_local_optimization_begin_type,.to_ami=local_message_to_ami,) | |
STASIS_MESSAGE_TYPE_DEFN (ast_local_optimization_end_type,.to_ami=local_message_to_ami,) | |
Variables | |
static struct ast_cli_entry | cli_local [] |
static struct ast_channel_tech | local_tech |
struct ast_unreal_pvt_callbacks | local_unreal_callbacks |
Callbacks from the unreal core when channel optimization occurs. More... | |
static struct ao2_container * | locals |
static const char | tdesc [] = "Local Proxy Channel Driver" |
enum local_call_action |
What to do with the ;2 channel when ast_call() happens.
Enumerator | |
---|---|
LOCAL_CALL_ACTION_DIALPLAN | |
LOCAL_CALL_ACTION_BRIDGE | |
LOCAL_CALL_ACTION_MASQUERADE |
Definition at line 197 of file core_local.c.
struct ast_channel* ast_local_get_peer | ( | struct ast_channel * | ast | ) |
Get the other local channel in the pair.
ast | Local channel to get peer. |
peer | reffed on success. |
NULL | if no peer or error. |
Definition at line 276 of file core_local.c.
References ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_channel_ref, ast_channel_tech_pvt(), local_pvt::base, ast_unreal_pvt::chan, NULL, and ast_unreal_pvt::owner.
Referenced by ari_channels_handle_originate_with_id(), and park_local_transfer().
int ast_local_init | ( | void | ) |
Initialize the local proxy channel.
0 | on success. |
-1 | on error. |
Definition at line 1140 of file core_local.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, ARRAY_LEN, ast_channel_register(), ast_cli_register_multiple, ast_format_cap_alloc, ast_format_cap_append_by_type(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_log, ast_manager_register_xml_core, AST_MEDIA_TYPE_UNKNOWN, ast_register_cleanup(), ast_channel_tech::capabilities, EVENT_FLAG_CALL, EVENT_FLAG_SYSTEM, local_shutdown(), locals_cmp_cb(), LOG_ERROR, manager_optimize_away(), NULL, and STASIS_MESSAGE_TYPE_INIT.
Referenced by asterisk_daemon().
void ast_local_lock_all | ( | struct ast_channel * | chan, |
void ** | tech_pvt, | ||
struct ast_channel ** | base_chan, | ||
struct ast_channel ** | base_owner | ||
) |
Add a reference to the local channel's private tech, lock the local channel's private base, and add references and lock both sides of the local channel.
chan | Must be a local channel |
tech_pvt | [out] channel's private tech (ref and lock added) |
base_chan | [out] One side of the local channel (ref and lock added) |
base_owner | [out] Other side of the local channel (ref and lock added) |
Definition at line 241 of file core_local.c.
References ao2_bump, ast_channel_tech_pvt(), ast_unreal_lock_all(), local_pvt::base, and NULL.
Referenced by attended_transfer_bridge().
int ast_local_setup_bridge | ( | struct ast_channel * | ast, |
struct ast_bridge * | bridge, | ||
struct ast_channel * | swap, | ||
struct ast_bridge_features * | features | ||
) |
Setup the outgoing local channel to join a bridge on ast_call().
ast | Either channel of a local channel pair. |
bridge | Bridge to join. |
swap | Channel to swap with when joining. |
features | Bridge features structure. |
0 | on success. |
-1 | on error. |
Definition at line 599 of file core_local.c.
References local_pvt::action, ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_bridge_features_destroy(), ast_channel_lock, ast_channel_ref, ast_channel_tech_pvt(), ast_channel_unlock, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, local_pvt::base, local_pvt::bridge, ast_unreal_pvt::chan, local_bridge::features, local_bridge::join, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_DIALPLAN, NULL, ast_unreal_pvt::owner, local_bridge::swap, and local_pvt::type.
Referenced by attended_transfer_bridge().
int ast_local_setup_masquerade | ( | struct ast_channel * | ast, |
struct ast_channel * | masq | ||
) |
Setup the outgoing local channel to masquerade into a channel on ast_call().
ast | Either channel of a local channel pair. |
masq | Channel to masquerade into. |
0 | on success. |
-1 | on error. |
Definition at line 641 of file core_local.c.
References local_pvt::action, ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_channel_lock, ast_channel_ref, ast_channel_tech_pvt(), ast_channel_unlock, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, local_pvt::base, ast_unreal_pvt::chan, LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_MASQUERADE, local_pvt::masq, NULL, ast_unreal_pvt::owner, and local_pvt::type.
Referenced by attended_transfer_bridge().
void ast_local_unlock_all | ( | void * | tech_pvt, |
struct ast_channel * | base_chan, | ||
struct ast_channel * | base_owner | ||
) |
Remove a reference to the given local channel's private tech, unlock the given local channel's private base, and remove references and unlock both sides of given the local channel.
tech_pvt | channel's private tech (ref and lock removed) |
base_chan | One side of the local channel (ref and lock removed) |
base_owner | Other side of the local channel (ref and lock removed) |
Definition at line 256 of file core_local.c.
References ao2_ref, ao2_unlock, ast_channel_unlock, ast_channel_unref, and local_pvt::base.
Referenced by attended_transfer_bridge().
|
static |
Create a call structure.
Definition at line 866 of file core_local.c.
References ast_clear_flag, ast_copy_string(), AST_JB_ENABLED, ast_log, ast_set_flag, ast_strdupa, ast_test_flag, ast_unreal_alloc_stream_topology(), AST_UNREAL_MOH_INTERCEPT, AST_UNREAL_NO_OPTIMIZATION, local_pvt::base, ast_unreal_pvt::callbacks, context, local_pvt::context, local_pvt::exten, ast_unreal_pvt::jb_conf, local_pvt_destructor(), local_unreal_callbacks, LOG_ERROR, ast_unreal_pvt::name, NULL, parse(), and S_OR.
Referenced by local_request_with_stream_topology().
|
static |
Initiate new call, part of PBX interface dest is the dial string.
Definition at line 677 of file core_local.c.
References local_pvt::action, ao2_cleanup, ao2_lock, ao2_ref, ao2_unlock, ast_answer(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_INDEPENDENT, ast_channel_caller(), ast_channel_lock, ast_channel_move(), ast_channel_tech_pvt(), ast_channel_unlock, ast_channel_unref, ast_exists_extension(), ast_hangup(), ast_log, ast_pbx_start(), ast_set_cc_interfaces_chanvar(), ast_set_flag, ast_strdupa, ast_unreal_call_setup(), AST_UNREAL_CARETAKER_THREAD, ast_unreal_lock_all(), local_pvt::base, local_pvt::bridge, local_pvt::context, local_pvt::exten, local_bridge::features, local_bridge::join, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_MASQUERADE, LOG_NOTICE, local_pvt::masq, NULL, publish_local_bridge_message(), S_COR, local_bridge::swap, and local_pvt::type.
|
static |
Definition at line 362 of file core_local.c.
References ao2_cleanup, ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_create(), local_pvt::base, ast_unreal_pvt::chan, NULL, ast_unreal_pvt::owner, and RAII_VAR.
Referenced by local_optimization_finished_cb(), and local_optimization_started_cb().
|
static |
Adds devicestate to local channels.
Definition at line 308 of file core_local.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_debug, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, ast_exists_extension(), ast_log, ast_strdupa, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, local_pvt::base, context, local_pvt::context, exten, local_pvt::exten, LOG_WARNING, NULL, and ast_unreal_pvt::owner.
|
static |
Hangup a call through the local proxy channel.
Definition at line 811 of file core_local.c.
References ao2_lock, ao2_ref, ao2_unlink, ao2_unlock, ast_channel_tech_pvt(), ast_unreal_hangup(), local_pvt::base, ast_unreal_pvt::chan, and ast_unreal_pvt::owner.
|
static |
Definition at line 463 of file core_local.c.
References ast_free, ast_json_integer_get(), ast_json_is_true(), ast_json_object_get(), ast_json_string_get(), ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_manager_build_channel_state_string_prefix(), ast_manager_event_blob_create(), ast_multi_channel_blob_get_channel(), ast_multi_channel_blob_get_json(), ast_str_append(), ast_str_buffer(), ast_str_create, AST_UNREAL_OWNER, ast_channel_snapshot::base, EVENT_FLAG_CALL, NULL, RAII_VAR, stasis_message_data(), stasis_message_type(), and ast_channel_snapshot_base::uniqueid.
|
static |
Callback for ast_unreal_pvt_callbacks optimization_finished_cb.
Definition at line 433 of file core_local.c.
References ao2_cleanup, ast_channel_topic(), ast_json_null(), ast_json_pack(), ast_json_unref(), ast_local_optimization_end_type(), local_pvt::base, local_channel_optimization_blob(), NULL, ast_unreal_pvt::owner, RAII_VAR, stasis_message_create(), and stasis_publish().
|
static |
Callback for ast_unreal_pvt_callbacks optimization_started_cb.
Definition at line 390 of file core_local.c.
References ao2_cleanup, ast_channel_snapshot_get_latest(), ast_channel_topic(), ast_channel_uniqueid(), ast_json_null(), ast_json_pack(), ast_json_unref(), ast_local_optimization_begin_type(), ast_multi_channel_blob_add_channel(), local_pvt::base, local_channel_optimization_blob(), NULL, ast_unreal_pvt::owner, RAII_VAR, stasis_message_create(), and stasis_publish().
|
static |
Definition at line 846 of file core_local.c.
References local_pvt::action, ao2_cleanup, ast_bridge_features_destroy(), ast_unreal_destructor(), local_pvt::base, local_pvt::bridge, local_bridge::features, local_bridge::join, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_MASQUERADE, local_pvt::masq, local_bridge::swap, and local_pvt::type.
Referenced by local_alloc().
|
static |
Part of PBX interface.
Definition at line 922 of file core_local.c.
References ast_stream_topology_create_from_format_cap(), ast_stream_topology_free(), local_request_with_stream_topology(), and NULL.
|
static |
Part of PBX interface.
Definition at line 940 of file core_local.c.
References ao2_link, ao2_ref, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_log, AST_MEDIA_TYPE_AUDIO, ast_read_threadstorage_callid(), AST_STATE_DOWN, AST_STATE_RING, ast_str_alloca, ast_stream_get_formats(), ast_stream_get_state(), ast_stream_get_type(), ast_stream_set_formats(), AST_STREAM_STATE_REMOVED, ast_stream_topology_clone(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_translator_best_choice(), ast_unreal_new_channels(), local_pvt::base, ast_channel::callid, ast_channel_tech::capabilities, local_pvt::context, local_pvt::exten, local_alloc(), LOG_WARNING, and NULL.
Referenced by local_request().
|
static |
Definition at line 1177 of file core_local.c.
References AST_OPTION_SECURE_MEDIA, AST_OPTION_SECURE_SIGNALING, and ast_unreal_setoption().
|
static |
Definition at line 1122 of file core_local.c.
References ao2_cleanup, ao2_ref, ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_manager_unregister(), ast_channel_tech::capabilities, NULL, and STASIS_MESSAGE_TYPE_CLEANUP.
Referenced by ast_local_init().
|
static |
|
static |
CLI command "local show channels".
Definition at line 1030 of file core_local.c.
References ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_cli_args::argc, ast_channel_name(), ast_cli(), local_pvt::base, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, ast_unreal_pvt::name, NULL, ast_unreal_pvt::owner, RESULT_SUCCESS, and ast_cli_entry::usage.
|
static |
Definition at line 1073 of file core_local.c.
References ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_channel_get_by_name(), ast_channel_tech_pvt(), ast_channel_unref, ast_clear_flag, ast_strlen_zero, AST_UNREAL_NO_OPTIMIZATION, astman_get_header(), astman_send_ack(), astman_send_error(), local_pvt::base, and NULL.
Referenced by ast_local_init().
|
static |
Definition at line 540 of file core_local.c.
References ao2_cleanup, ao2_unlock, ast_channel_snapshot_get_latest(), ast_channel_topic(), ast_channel_uniqueid(), ast_channel_unlock, ast_channel_unref, ast_json_pack(), ast_json_unref(), ast_local_bridge_type(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_create(), ast_test_flag, ast_unreal_lock_all(), AST_UNREAL_NO_OPTIMIZATION, local_pvt::base, local_pvt::context, end, local_pvt::exten, NULL, RAII_VAR, stasis_message_create(), and stasis_publish().
Referenced by local_call().
STASIS_MESSAGE_TYPE_DEFN | ( | ast_local_bridge_type | , |
. | to_ami = local_message_to_ami |
||
) |
Define local channel message types.
STASIS_MESSAGE_TYPE_DEFN | ( | ast_local_optimization_begin_type | , |
. | to_ami = local_message_to_ami |
||
) |
STASIS_MESSAGE_TYPE_DEFN | ( | ast_local_optimization_end_type | , |
. | to_ami = local_message_to_ami |
||
) |
|
static |
Definition at line 1069 of file core_local.c.
|
static |
Definition at line 173 of file core_local.c.
struct ast_unreal_pvt_callbacks local_unreal_callbacks |
Callbacks from the unreal core when channel optimization occurs.
Definition at line 167 of file core_local.c.
Referenced by local_alloc().
|
static |
Definition at line 138 of file core_local.c.
Referenced by attended_transfer_bridge().
|
static |
Definition at line 136 of file core_local.c.