Asterisk - The Open Source Telephony Project  18.5.0
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.

References ast_manager_get_topic(), and stasis_publish().

Referenced by manager_endpoints_init().

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

◆ manager_endpoints_init()

int manager_endpoints_init ( void  )

Initialize support for AMI endpoint events.

Returns
0 on success.
non-zero on 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(), endpoint_state_cb(), manager_endpoints_shutdown(), NULL, stasis_message_router_add(), and stasis_message_router_create.

Referenced by subscribe_all().

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 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.
#define NULL
Definition: resample.c:96
static void endpoint_state_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
static struct stasis_message_router * endpoint_router
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define stasis_message_router_create(topic)
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
static void manager_endpoints_shutdown(void)
struct stasis_message_type * ast_endpoint_contact_state_type(void)
Message type for endpoint contact state changes.

◆ manager_endpoints_shutdown()

static void manager_endpoints_shutdown ( void  )
static

Definition at line 40 of file manager_endpoints.c.

References NULL, and stasis_message_router_unsubscribe_and_join().

Referenced by manager_endpoints_init().

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...
#define NULL
Definition: resample.c:96
static struct stasis_message_router * endpoint_router

Variable Documentation

◆ endpoint_router

struct stasis_message_router* endpoint_router
static

Definition at line 38 of file manager_endpoints.c.