Asterisk - The Open Source Telephony Project  21.4.1
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"

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

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.

References ast_endpoint_contact_state_type(), ast_endpoint_state_type(), ast_endpoint_topic_all_cached(), ast_register_cleanup(), and stasis_message_router_add().

53 {
54  struct stasis_topic *endpoint_topic;
55  int ret = 0;
56 
57  if (endpoint_router) {
58  /* Already initialized */
59  return 0;
60  }
61 
62  ast_register_cleanup(manager_endpoints_shutdown);
63 
64  endpoint_topic = ast_endpoint_topic_all_cached();
65  if (!endpoint_topic) {
66  return -1;
67  }
68 
69  endpoint_router = stasis_message_router_create(endpoint_topic);
70 
71  if (!endpoint_router) {
72  return -1;
73  }
74 
75  ret |= stasis_message_router_add(endpoint_router, ast_endpoint_state_type(), endpoint_state_cb, NULL);
76  ret |= stasis_message_router_add(endpoint_router, ast_endpoint_contact_state_type(), endpoint_state_cb, NULL);
77 
78  /* If somehow we failed to add any routes, just shut down the whole
79  * thing and fail it.
80  */
81  if (ret) {
82  manager_endpoints_shutdown();
83  return -1;
84  }
85 
86  return 0;
87 }
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.
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
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_state_type(void)
Message type for endpoint state changes.
struct stasis_message_type * ast_endpoint_contact_state_type(void)
Message type for endpoint contact state changes.