Files
asterisk/include/asterisk/stasis_system.h

137 lines
3.7 KiB
C
Raw Normal View History

/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2013, Digium, Inc.
*
* Jason Parker <jparker@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
#ifndef _ASTERISK_STASIS_SYSTEM_H
#define _ASTERISK_STASIS_SYSTEM_H
#include "asterisk/stasis.h"
/*!
* \since 12
* \brief Publish a channel driver outgoing registration message
*
* \param channeltype The channel driver that published the message
* \param username The username that was used to register
* \param domain The domain that was used to register
* \param status The result of the registration
* \param cause The reason for the result
*/
void ast_system_publish_registry(const char *channeltype, const char *username, const char *domain, const char *status, const char *cause);
/*!
* \since 12
* \brief A \ref stasis topic which publishes messages regarding system changes
*
* \return \ref stasis_topic for system level changes
* \retval NULL on error
*/
struct stasis_topic *ast_system_topic(void);
/*!
* \since 12
* \brief A \ref stasis_message_type for network changes
*
* \retval NULL on error
* \return \ref stasis_message_type for network changes
*
* \note Messages of this type should always be issued on and expected from
* the \ref ast_system_topic \ref stasis topic
*/
struct stasis_message_type *ast_network_change_type(void);
/*!
* \brief A \ref stasis_message_type for outbound registration.
* \since 12
*/
struct stasis_message_type *ast_system_registry_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Available messages.
* \since 12
*/
struct stasis_message_type *ast_cc_available_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Offer Timer Start messages.
* \since 12
*/
struct stasis_message_type *ast_cc_offertimerstart_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Requested messages.
* \since 12
*/
struct stasis_message_type *ast_cc_requested_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Request Acknowledged messages.
* \since 12
*/
struct stasis_message_type *ast_cc_requestacknowledged_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Caller Stop Monitoring messages.
* \since 12
*/
struct stasis_message_type *ast_cc_callerstopmonitoring_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Caller Start Monitoring messages.
* \since 12
*/
struct stasis_message_type *ast_cc_callerstartmonitoring_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Caller Recalling messages.
* \since 12
*/
struct stasis_message_type *ast_cc_callerrecalling_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Recall Complete messages.
* \since 12
*/
struct stasis_message_type *ast_cc_recallcomplete_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Failure messages.
* \since 12
*/
struct stasis_message_type *ast_cc_failure_type(void);
/*!
* \brief A \ref stasis_message_type for CCSS Monitor Failed messages.
* \since 12
*/
struct stasis_message_type *ast_cc_monitorfailed_type(void);
res/res_corosync: Raise a Stasis message on node join/leave events When res_corosync detects that a node leaves or joins, it currently is informed of this via Corosync callbacks. However, there are a few limitations with the information presented: (1) While we have information that Corosync is aware of - such as the Corosync nodeid - that information is really only useful inside of Corosync or res_corosync. There's no way to translate a Corosync nodeid to some other internally useful unique identifier for the Asterisk instance that just joined or left the cluster. (2) While res_corosync is notified of the instance joining or leaving the cluster, it has no mechanism to inform the Asterisk core or other modules of this event. This limits the usefulness of res_corosync as a heartbeat mechanism for other modules. This patch addresses both issues. First, it adds the notion of a cluster discovery message both within the Stasis message bus, as well as the binary event messages that res_corosync uses to transmit data back and forth within the cluster. When Asterisk joins the cluster, it sends a discovery message to the other nodes in the cluster, which correlates the Corosync nodeid along with the Asterisk EID. res_corosync now maintains a hash of Corosync nodeids to Asterisk EIDs, such that it can map changes in cluster state with the Asterisk instance that has that nodeid. Likewise, when an Asterisk instance receives a discovery message from a node in the cluster, it now sends its own discovery message back to the originating node with the local Asterisk EID. This lets Asterisk instances within the cluster build a complete picture of the other Asterisk instances within the cluster. Second, it publishes the discovery messages onto the Stasis message bus. Said messages are published whenever a node joins or leaves the cluster. Interested modules can subscribe for the ast_cluster_discovery_type() message under the ast_system_topic() and be notified when changes in cluster state occur. Change-Id: I9015f418d6ae7f47e4994e04e18948df4d49b465
2015-10-19 18:55:33 -05:00
/*!
* \brief A \ref stasis_message_type for Cluster discovery
* \since 13.11.0
*/
struct stasis_message_type *ast_cluster_discovery_type(void);
/*!
* \brief Initialize the stasis system topic and message types
* \retval 0 on success
* \retval -1 on failure
*/
int ast_stasis_system_init(void);
#endif /* _ASTERISK_STASIS_SYSTEM_H */