Asterisk - The Open Source Telephony Project GIT-master-0644429
Functions | Variables
manager_endpoints.c File Reference

The Asterisk Management Interface - AMI (endpoint handling) More...

#include "asterisk.h"
#include "asterisk/callerid.h"
#include "asterisk/channel.h"
#include "asterisk/manager.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/pbx.h"
#include "asterisk/stasis_endpoints.h"
Include dependency graph for manager_endpoints.c:

Go to the source code of this file.

Functions

static void endpoint_state_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
 
int manager_endpoints_init (void)
 Initialize support for AMI endpoint events. More...
 
static void manager_endpoints_shutdown (void)
 

Variables

static struct stasis_message_routerendpoint_router
 

Detailed Description

The Asterisk Management Interface - AMI (endpoint handling)

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file manager_endpoints.c.

Function Documentation

◆ endpoint_state_cb()

static void endpoint_state_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
)
static

Definition at line 46 of file manager_endpoints.c.

48{
50}
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition: manager.c:453
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1512

References ast_manager_get_topic(), and stasis_publish().

Referenced by manager_endpoints_init().

◆ manager_endpoints_init()

int manager_endpoints_init ( void  )

Initialize support for AMI endpoint events.

Return values
0on success.
non-zeroon error.
Since
12

Definition at line 52 of file manager_endpoints.c.

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}
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_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.
static void manager_endpoints_shutdown(void)
static void endpoint_state_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct stasis_message_router * endpoint_router
#define NULL
Definition: resample.c:96
#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.

References ast_endpoint_contact_state_type(), ast_endpoint_state_type(), ast_endpoint_topic_all_cached(), ast_register_cleanup(), endpoint_router, endpoint_state_cb(), manager_endpoints_shutdown(), NULL, stasis_message_router_add(), and stasis_message_router_create.

Referenced by subscribe_all().

◆ manager_endpoints_shutdown()

static void manager_endpoints_shutdown ( void  )
static

Definition at line 40 of file manager_endpoints.c.

41{
44}
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.

References endpoint_router, NULL, and stasis_message_router_unsubscribe_and_join().

Referenced by manager_endpoints_init().

Variable Documentation

◆ endpoint_router

struct stasis_message_router* endpoint_router
static

Definition at line 38 of file manager_endpoints.c.

Referenced by manager_endpoints_init(), and manager_endpoints_shutdown().