Asterisk - The Open Source Telephony Project GIT-master-7e7a603
manager_endpoints.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Digium, Inc.
5 *
6 * Joshua Colp <jcolp@digium.com>
7 * David M. Lee, II <dlee@digium.com>
8 *
9 * See http://www.asterisk.org for more information about
10 * the Asterisk project. Please do not directly contact
11 * any of the maintainers of this project for assistance;
12 * the project provides a web site, mailing lists and IRC
13 * channels for your use.
14 *
15 * This program is free software, distributed under the terms of
16 * the GNU General Public License Version 2. See the LICENSE file
17 * at the top of the source tree.
18 */
19
20/*! \file
21 *
22 * \brief The Asterisk Management Interface - AMI (endpoint handling)
23 *
24 * \author Joshua Colp <jcolp@digium.com>
25 * \author David M. Lee, II <dlee@digium.com>
26 *
27 */
28
29#include "asterisk.h"
30
31#include "asterisk/callerid.h"
32#include "asterisk/channel.h"
33#include "asterisk/manager.h"
35#include "asterisk/pbx.h"
37
39
41{
44}
45
46static void endpoint_state_cb(void *data, struct stasis_subscription *sub,
47 struct stasis_message *message)
48{
50}
51
53{
54 struct stasis_topic *endpoint_topic;
55 int ret = 0;
56
57 if (endpoint_router) {
58 /* Already initialized */
59 return 0;
60 }
61
63
64 endpoint_topic = ast_endpoint_topic_all_cached();
65 if (!endpoint_topic) {
66 return -1;
67 }
68
70
71 if (!endpoint_router) {
72 return -1;
73 }
74
77
78 /* If somehow we failed to add any routes, just shut down the whole
79 * thing and fail it.
80 */
81 if (ret) {
83 return -1;
84 }
85
86 return 0;
87}
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
General Asterisk PBX channel definitions.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition: manager.c:1872
struct stasis_message_type * ast_endpoint_contact_state_type(void)
Message type for endpoint contact state changes.
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
static void manager_endpoints_shutdown(void)
int manager_endpoints_init(void)
Initialize support for AMI endpoint events.
static void endpoint_state_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct stasis_message_router * endpoint_router
Core PBX routines and definitions.
struct stasis_forward * sub
Definition: res_corosync.c:240
#define NULL
Definition: resample.c:96
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
Endpoint abstractions.
#define stasis_message_router_create(topic)
Create a new message router object.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
void stasis_message_router_unsubscribe_and_join(struct stasis_message_router *router)
Unsubscribe the router from the upstream topic, blocking until the final message has been processed.