Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
stasis_channels.c File Reference

Stasis Messages and Data Types for Channel Objects. More...

#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/json.h"
#include "asterisk/pbx.h"
#include "asterisk/bridge.h"
#include "asterisk/translate.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/dial.h"
#include "asterisk/linkedlists.h"
#include "asterisk/utf8.h"

Go to the source code of this file.

Data Structures

struct  ast_multi_channel_blob
 A multi channel blob data structure for multi_channel_blob stasis messages. More...
 
struct  channel_role_snapshot
 A channel snapshot wrapper object used in ast_multi_channel_blob objects. More...
 
struct  dial_masquerade_datastore
 
struct  dial_target
 

Macros

#define NUM_MULTI_CHANNEL_BLOB_BUCKETS   7
 

Functions

static struct ast_manager_event_blobagent_login_to_ami (struct stasis_message *msg)
 
static struct ast_manager_event_blobagent_logoff_to_ami (struct stasis_message *msg)
 
struct stasis_messageast_channel_blob_create (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Creates a ast_channel_blob message. More...
 
struct stasis_messageast_channel_blob_create_from_cache (const char *channel_id, struct stasis_message_type *type, struct ast_json *blob)
 Create a ast_channel_blob message, pulling channel state from the cache. More...
 
struct ao2_containerast_channel_cache_all (void)
 
struct ao2_containerast_channel_cache_by_name (void)
 Secondary channel cache, indexed by name. More...
 
void ast_channel_publish_blob (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Publish a channel blob message. More...
 
void ast_channel_publish_cached_blob (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Publish a channel blob message using the latest snapshot from the cache. More...
 
void ast_channel_publish_dial (struct ast_channel *caller, struct ast_channel *peer, const char *dialstring, const char *dialstatus)
 Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels involved in a dial operation. More...
 
void ast_channel_publish_dial_forward (struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
 Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels involved in a dial operation that is forwarded. More...
 
static void ast_channel_publish_dial_internal (struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
 
void ast_channel_publish_final_snapshot (struct ast_channel *chan)
 Send the final channel snapshot for a channel, thus removing it from cache. More...
 
void ast_channel_publish_snapshot (struct ast_channel *chan)
 Publish a ast_channel_snapshot for a channel. More...
 
void ast_channel_publish_varset (struct ast_channel *chan, const char *name, const char *value)
 Publish a ast_channel_publish_varset for a channel. More...
 
int ast_channel_snapshot_caller_id_equal (const struct ast_channel_snapshot *old_snapshot, const struct ast_channel_snapshot *new_snapshot)
 Compares the callerid info of two snapshots. More...
 
int ast_channel_snapshot_cep_equal (const struct ast_channel_snapshot *old_snapshot, const struct ast_channel_snapshot *new_snapshot)
 Compares the context, exten and priority of two snapshots. More...
 
int ast_channel_snapshot_connected_line_equal (const struct ast_channel_snapshot *old_snapshot, const struct ast_channel_snapshot *new_snapshot)
 Compares the connected line info of two snapshots. More...
 
struct ast_channel_snapshotast_channel_snapshot_create (struct ast_channel *chan)
 Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate. More...
 
struct ast_channel_snapshotast_channel_snapshot_get_latest (const char *uniqueid)
 Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object, so use ao2_cleanup() to deallocate. More...
 
struct ast_channel_snapshotast_channel_snapshot_get_latest_by_name (const char *name)
 Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object, so use ao2_cleanup() to deallocate. More...
 
void ast_channel_snapshot_invalidate_segment (struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
 Invalidate a channel snapshot segment from being reused. More...
 
struct ast_jsonast_channel_snapshot_to_json (const struct ast_channel_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
 Build a JSON object from a ast_channel_snapshot. More...
 
void ast_channel_stage_snapshot (struct ast_channel *chan)
 Set flag to indicate channel snapshot is being staged. More...
 
void ast_channel_stage_snapshot_done (struct ast_channel *chan)
 Clear flag to indicate channel snapshot is being staged, and publish snapshot. More...
 
struct stasis_topicast_channel_topic_all (void)
 A topic which publishes the events for all channels. More...
 
void ast_multi_channel_blob_add_channel (struct ast_multi_channel_blob *obj, const char *role, struct ast_channel_snapshot *snapshot)
 Add a ast_channel_snapshot to a ast_multi_channel_blob object. More...
 
struct ast_multi_channel_blobast_multi_channel_blob_create (struct ast_json *blob)
 Create a ast_multi_channel_blob suitable for a stasis_message. More...
 
struct ast_channel_snapshotast_multi_channel_blob_get_channel (struct ast_multi_channel_blob *obj, const char *role)
 Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob. More...
 
struct ao2_containerast_multi_channel_blob_get_channels (struct ast_multi_channel_blob *obj, const char *role)
 Retrieve all channel snapshots associated with a specific role from a ast_multi_channel_blob. More...
 
struct ast_jsonast_multi_channel_blob_get_json (struct ast_multi_channel_blob *obj)
 Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj. More...
 
int ast_stasis_channels_init (void)
 Initialize the stasis channel topic and message types. More...
 
static void channel_blob_dtor (void *obj)
 
static struct ast_jsonchannel_blob_to_json (struct stasis_message *message, const char *type, const struct stasis_message_sanitizer *sanitize)
 
static int channel_role_cmp_cb (void *obj, void *arg, int flags)
 
static int channel_role_hash_cb (const void *obj, const int flags)
 
static void channel_role_snapshot_dtor (void *obj)
 
static struct ast_channel_snapshot_basechannel_snapshot_base_create (struct ast_channel *chan)
 
static void channel_snapshot_base_dtor (void *obj)
 
static struct ast_channel_snapshot_bridgechannel_snapshot_bridge_create (struct ast_channel *chan)
 
static struct ast_channel_snapshot_callerchannel_snapshot_caller_create (struct ast_channel *chan)
 
static void channel_snapshot_caller_dtor (void *obj)
 
static int channel_snapshot_cmp_cb (void *obj, void *arg, int flags)
 
static struct ast_channel_snapshot_connectedchannel_snapshot_connected_create (struct ast_channel *chan)
 
static struct ast_channel_snapshot_dialplanchannel_snapshot_dialplan_create (struct ast_channel *chan)
 
static void channel_snapshot_dialplan_dtor (void *obj)
 
static void channel_snapshot_dtor (void *obj)
 
static struct ast_channel_snapshot_hangupchannel_snapshot_hangup_create (struct ast_channel *chan)
 
static int channel_snapshot_hash_cb (const void *obj, const int flags)
 
static struct ast_channel_snapshot_peerchannel_snapshot_peer_create (struct ast_channel *chan)
 
static int channel_snapshot_uniqueid_cmp_cb (void *obj, void *arg, int flags)
 
static int channel_snapshot_uniqueid_hash_cb (const void *obj, const int flags)
 
static struct ast_channel_snapshot_updatechannel_snapshot_update_create (struct ast_channel *chan)
 
static void channel_snapshot_update_dtor (void *obj)
 
static struct stasis_messagecreate_channel_blob_message (struct ast_channel_snapshot *snapshot, struct stasis_message_type *type, struct ast_json *blob)
 
static void dial_masquerade_breakdown (void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
 
static void dial_masquerade_caller_datastore_destroy (void *data)
 
static struct dial_masquerade_datastoredial_masquerade_datastore_add (struct ast_channel *chan, struct dial_masquerade_datastore *masq_data)
 
static struct dial_masquerade_datastoredial_masquerade_datastore_alloc (void)
 
static void dial_masquerade_datastore_cleanup (struct dial_masquerade_datastore *masq_data)
 
static void dial_masquerade_datastore_destroy (void *data)
 
static void dial_masquerade_datastore_dtor (void *vdoomed)
 
static struct ast_datastoredial_masquerade_datastore_find (struct ast_channel *chan)
 
static void dial_masquerade_datastore_remove_chan (struct dial_masquerade_datastore *masq_data, struct ast_channel *chan)
 
static void dial_masquerade_fixup (void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
 
static void dial_target_free (struct dial_target *doomed)
 
static struct ast_jsondial_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_jsondtmf_end_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_jsonhangup_request_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_jsonhold_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static void multi_channel_blob_dtor (void *obj)
 
static void publish_message_for_channel_topics (struct stasis_message *message, struct ast_channel *chan)
 
static void remove_dial_masquerade (struct ast_channel *peer)
 
static void remove_dial_masquerade_caller (struct ast_channel *caller)
 
static int set_dial_masquerade (struct ast_channel *caller, struct ast_channel *peer, const char *dialstring)
 
static void stasis_channels_cleanup (void)
 
static struct ast_manager_event_blobtalking_start_to_ami (struct stasis_message *msg)
 
static struct ast_jsontalking_start_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_manager_event_blobtalking_stop_to_ami (struct stasis_message *msg)
 
static struct ast_jsontalking_stop_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_jsonunhold_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
static struct ast_manager_event_blobvarset_to_ami (struct stasis_message *msg)
 
static struct ast_jsonvarset_to_json (struct stasis_message *message, const struct stasis_message_sanitizer *sanitize)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_snapshot_type)
 Define channel message types.
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_dial_type,.to_json=dial_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_varset_type,.to_ami=varset_to_ami,.to_json=varset_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_hangup_request_type,.to_json=hangup_request_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_masquerade_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_dtmf_begin_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_dtmf_end_type,.to_json=dtmf_end_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_hold_type,.to_json=hold_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_unhold_type,.to_json=unhold_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_flash_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_wink_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_chanspy_start_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_chanspy_stop_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_fax_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_hangup_handler_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_moh_start_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_moh_stop_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_mixmonitor_start_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_mixmonitor_stop_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_mixmonitor_mute_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_agent_login_type,.to_ami=agent_login_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_agent_logoff_type,.to_ami=agent_logoff_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_talking_start,.to_ami=talking_start_to_ami,.to_json=talking_start_to_json,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_channel_talking_stop,.to_ami=talking_stop_to_ami,.to_json=talking_stop_to_json,)
 

Variables

static struct ao2_containerchannel_cache
 
static struct ao2_containerchannel_cache_by_name
 
static struct stasis_topicchannel_topic_all
 
static const struct ast_datastore_info dial_masquerade_caller_info
 
static const struct ast_datastore_info dial_masquerade_info
 

Detailed Description

Stasis Messages and Data Types for Channel Objects.

Author
Matt Jordan <mjordan@digium.com> 

Definition in file stasis_channels.c.

Function Documentation

int ast_channel_snapshot_caller_id_equal ( const struct ast_channel_snapshot old_snapshot,
const struct ast_channel_snapshot new_snapshot 
)

Compares the callerid info of two snapshots.

Since
12
Parameters
old_snapshotOld snapshot
new_snapshotNew snapshot
Return values
True(non-zero) if callerid are identical.
False(zero) if callerid changed.

Definition at line 1356 of file stasis_channels.c.

References ast_channel_snapshot::caller, ast_channel_snapshot_caller::name, and ast_channel_snapshot_caller::number.

1359 {
1360  ast_assert(old_snapshot != NULL);
1361  ast_assert(new_snapshot != NULL);
1362  return strcmp(old_snapshot->caller->number, new_snapshot->caller->number) == 0 &&
1363  strcmp(old_snapshot->caller->name, new_snapshot->caller->name) == 0;
1364 }
const ast_string_field name
struct ast_channel_snapshot_caller * caller
const ast_string_field number
int ast_channel_snapshot_cep_equal ( const struct ast_channel_snapshot old_snapshot,
const struct ast_channel_snapshot new_snapshot 
)

Compares the context, exten and priority of two snapshots.

Since
12
Parameters
old_snapshotOld snapshot
new_snapshotNew snapshot
Return values
True(non-zero) if context, exten or priority are identical.
False(zero) if context, exten and priority changed.

Definition at line 1335 of file stasis_channels.c.

References ast_channel_snapshot_dialplan::appl, ast_channel_snapshot_dialplan::context, ast_channel_snapshot::dialplan, ast_channel_snapshot_dialplan::exten, and ast_channel_snapshot_dialplan::priority.

1338 {
1339  ast_assert(old_snapshot != NULL);
1340  ast_assert(new_snapshot != NULL);
1341 
1342  /* We actually get some snapshots with CEP set, but before the
1343  * application is set. Since empty application is invalid, we treat
1344  * setting the application from nothing as a CEP change.
1345  */
1346  if (ast_strlen_zero(old_snapshot->dialplan->appl) &&
1347  !ast_strlen_zero(new_snapshot->dialplan->appl)) {
1348  return 0;
1349  }
1350 
1351  return old_snapshot->dialplan->priority == new_snapshot->dialplan->priority &&
1352  strcmp(old_snapshot->dialplan->context, new_snapshot->dialplan->context) == 0 &&
1353  strcmp(old_snapshot->dialplan->exten, new_snapshot->dialplan->exten) == 0;
1354 }
struct ast_channel_snapshot_dialplan * dialplan
const ast_string_field context
const ast_string_field appl
const ast_string_field exten
int ast_channel_snapshot_connected_line_equal ( const struct ast_channel_snapshot old_snapshot,
const struct ast_channel_snapshot new_snapshot 
)

Compares the connected line info of two snapshots.

Since
13.1.0
Parameters
old_snapshotOld snapshot
new_snapshotNew snapshot
Return values
True(non-zero) if callerid are identical.
False(zero) if callerid changed.

Definition at line 1366 of file stasis_channels.c.

References ast_channel_snapshot::connected, ast_channel_snapshot_connected::name, and ast_channel_snapshot_connected::number.

1369 {
1370  ast_assert(old_snapshot != NULL);
1371  ast_assert(new_snapshot != NULL);
1372  return strcmp(old_snapshot->connected->number, new_snapshot->connected->number) == 0 &&
1373  strcmp(old_snapshot->connected->name, new_snapshot->connected->name) == 0;
1374 }
struct ast_channel_snapshot_connected * connected
struct ast_json* ast_channel_snapshot_to_json ( const struct ast_channel_snapshot snapshot,
const struct stasis_message_sanitizer sanitize 
)

Build a JSON object from a ast_channel_snapshot.

Parameters
snapshotThe snapshot to convert to JSON
sanitizeThe message sanitizer to use on the snapshot
Returns
JSON object representing channel snapshot.
Return values
NULLon error

Definition at line 1288 of file stasis_channels.c.

References ast_channel_snapshot_base::accountcode, ast_channel_snapshot_dialplan::appl, ast_channel_snapshot::ari_vars, ast_json_channel_vars(), ast_json_dialplan_cep_app(), ast_json_name_number(), ast_json_object_set(), ast_json_pack(), ast_json_string_create(), ast_json_timeval(), AST_LIST_EMPTY, ast_state2str(), ast_channel_snapshot::base, ast_channel_snapshot::caller, stasis_message_sanitizer::channel_snapshot, ast_channel_snapshot::connected, ast_channel_snapshot_dialplan::context, ast_channel_snapshot_base::creationtime, ast_channel_snapshot_dialplan::data, ast_channel_snapshot::dialplan, ast_channel_snapshot_dialplan::exten, ast_channel_snapshot_base::language, ast_channel_snapshot_caller::name, ast_channel_snapshot_connected::name, ast_channel_snapshot_base::name, ast_channel_snapshot_caller::number, ast_channel_snapshot_connected::number, ast_channel_snapshot_dialplan::priority, ast_channel_snapshot_caller::rdnis, ast_channel_snapshot::state, and ast_channel_snapshot_base::uniqueid.

Referenced by ast_ari_channels_create(), ast_ari_channels_get(), ast_ari_channels_list(), and stasis_app_exec().

1291 {
1292  struct ast_json *json_chan;
1293 
1294  if (snapshot == NULL
1295  || (sanitize
1296  && sanitize->channel_snapshot
1297  && sanitize->channel_snapshot(snapshot))) {
1298  return NULL;
1299  }
1300 
1301  json_chan = ast_json_pack(
1302  /* Broken up into groups for readability */
1303  "{ s: s, s: s, s: s, s: s,"
1304  " s: o, s: o, s: s,"
1305  " s: o, s: o, s: s }",
1306  /* First line */
1307  "id", snapshot->base->uniqueid,
1308  "name", snapshot->base->name,
1309  "state", ast_state2str(snapshot->state),
1310  "protocol_id", snapshot->base->protocol_id,
1311  /* Second line */
1312  "caller", ast_json_name_number(
1313  snapshot->caller->name, snapshot->caller->number),
1314  "connected", ast_json_name_number(
1315  snapshot->connected->name, snapshot->connected->number),
1316  "accountcode", snapshot->base->accountcode,
1317  /* Third line */
1318  "dialplan", ast_json_dialplan_cep_app(
1319  snapshot->dialplan->context, snapshot->dialplan->exten, snapshot->dialplan->priority,
1320  snapshot->dialplan->appl, snapshot->dialplan->data),
1321  "creationtime", ast_json_timeval(snapshot->base->creationtime, NULL),
1322  "language", snapshot->base->language);
1323 
1324  if (!ast_strlen_zero(snapshot->caller->rdnis)) {
1325  ast_json_object_set(json_chan, "caller_rdnis", ast_json_string_create(snapshot->caller->rdnis));
1326  }
1327 
1328  if (snapshot->ari_vars && !AST_LIST_EMPTY(snapshot->ari_vars)) {
1329  ast_json_object_set(json_chan, "channelvars", ast_json_channel_vars(snapshot->ari_vars));
1330  }
1331 
1332  return json_chan;
1333 }
const ast_string_field data
struct ast_channel_snapshot_base * base
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
const ast_string_field name
int(* channel_snapshot)(const struct ast_channel_snapshot *snapshot)
Callback which determines whether a channel should be sanitized from a message based on the channel's...
Definition: stasis.h:221
const ast_string_field rdnis
const ast_string_field accountcode
const ast_string_field uniqueid
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:450
struct ast_channel_snapshot_dialplan * dialplan
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition: json.c:414
struct ast_json * ast_json_dialplan_cep_app(const char *context, const char *exten, int priority, const char *app_name, const char *app_data)
Construct a context/exten/priority/application/application_data as JSON.
Definition: json.c:653
struct ast_json * ast_json_channel_vars(struct varshead *channelvars)
Construct a JSON object from a ast_var_t list.
Definition: json.c:864
const ast_string_field context
struct varshead * ari_vars
struct ast_json * ast_json_name_number(const char *name, const char *number)
Common JSON rendering functions for common 'objects'.
Definition: json.c:646
const ast_string_field appl
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition: json.c:278
const ast_string_field exten
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
Definition: json.c:670
struct ast_channel_snapshot_caller * caller
enum ast_channel_state state
const ast_string_field language
const ast_string_field number
Abstract JSON element (object, array, string, int, ...).
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Definition: channel.c:636
struct ast_channel_snapshot_connected * connected
const ast_string_field name
int ast_stasis_channels_init ( void  )

Initialize the stasis channel topic and message types.

Return values
0on success
Non-zeroon error

Definition at line 1702 of file stasis_channels.c.

References AO2_ALLOC_OPT_LOCK_RWLOCK, ao2_container_alloc_hash, ast_channel_agent_login_type(), ast_channel_agent_logoff_type(), ast_channel_chanspy_start_type(), ast_channel_chanspy_stop_type(), ast_channel_dial_type(), ast_channel_dtmf_begin_type(), ast_channel_dtmf_end_type(), ast_channel_fax_type(), ast_channel_flash_type(), ast_channel_hangup_handler_type(), ast_channel_hangup_request_type(), ast_channel_hold_type(), ast_channel_masquerade_type(), ast_channel_mixmonitor_mute_type(), ast_channel_mixmonitor_start_type(), ast_channel_mixmonitor_stop_type(), ast_channel_moh_start_type(), ast_channel_moh_stop_type(), ast_channel_snapshot_type(), ast_channel_talking_start(), ast_channel_talking_stop(), ast_channel_unhold_type(), ast_channel_varset_type(), ast_channel_wink_type(), AST_NUM_CHANNEL_BUCKETS, ast_register_cleanup(), STASIS_MESSAGE_TYPE_INIT, and stasis_topic_create().

Referenced by ast_channels_init().

1703 {
1704  int res = 0;
1705 
1706  ast_register_cleanup(stasis_channels_cleanup);
1707 
1708  channel_topic_all = stasis_topic_create("channel:all");
1709  if (!channel_topic_all) {
1710  return -1;
1711  }
1712 
1714  0, AST_NUM_CHANNEL_BUCKETS, channel_snapshot_uniqueid_hash_cb,
1715  NULL, channel_snapshot_uniqueid_cmp_cb);
1716  if (!channel_cache) {
1717  return -1;
1718  }
1719 
1720  channel_cache_by_name = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK,
1721  0, AST_NUM_CHANNEL_BUCKETS, channel_snapshot_hash_cb,
1722  NULL, channel_snapshot_cmp_cb);
1723  if (!channel_cache_by_name) {
1724  return -1;
1725  }
1726 
1751 
1752  return res;
1753 }
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
struct stasis_message_type * ast_channel_talking_stop(void)
Message type for a channel stopping talking.
struct stasis_message_type * ast_channel_dtmf_end_type(void)
Message type for when DTMF ends on a channel.
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
struct stasis_message_type * ast_channel_moh_start_type(void)
Message type for starting music on hold on a channel.
struct stasis_message_type * ast_channel_wink_type(void)
Message type for when a wink occurs on a channel.
struct stasis_message_type * ast_channel_flash_type(void)
Message type for when a hook flash occurs on a channel.
#define AST_NUM_CHANNEL_BUCKETS
Definition: channel.h:155
struct stasis_message_type * ast_channel_varset_type(void)
Message type for when a variable is set on a channel.
struct stasis_message_type * ast_channel_chanspy_start_type(void)
Message type for when a channel starts spying on another channel.
struct stasis_message_type * ast_channel_talking_start(void)
Message type for a channel starting talking.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_message_type * ast_channel_agent_login_type(void)
Message type for agent login on a channel.
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:617
struct stasis_message_type * ast_channel_agent_logoff_type(void)
Message type for agent logoff on a channel.
struct stasis_message_type * ast_channel_mixmonitor_start_type(void)
Message type for starting mixmonitor on a channel.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
struct stasis_message_type * ast_channel_mixmonitor_stop_type(void)
Message type for stopping mixmonitor on a channel.
struct stasis_message_type * ast_channel_hangup_handler_type(void)
Message type for hangup handler related actions.
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
struct stasis_message_type * ast_channel_dtmf_begin_type(void)
Message type for when DTMF begins on a channel.
struct stasis_message_type * ast_channel_dial_type(void)
Message type for when a channel dials another channel.
struct stasis_message_type * ast_channel_moh_stop_type(void)
Message type for stopping music on hold on a channel.
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.
struct stasis_message_type * ast_channel_masquerade_type(void)
Message type for when a channel is being masqueraded.
struct stasis_message_type * ast_channel_fax_type(void)
Message type for a fax operation.
struct stasis_message_type * ast_channel_chanspy_stop_type(void)
Message type for when a channel stops spying on another channel.
struct stasis_message_type * ast_channel_mixmonitor_mute_type(void)
Message type for muting or unmuting mixmonitor on a channel.