Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
manager_system.c File Reference

System AMI event handling. More...

#include "asterisk.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/stasis_system.h"
Include dependency graph for manager_system.c:

Go to the source code of this file.

Functions

int manager_system_init (void)
 Initialize support for AMI system events. More...
 
static void manager_system_shutdown (void)
 

Variables

static struct stasis_forwardtopic_forwarder
 The Stasis Message Bus API subscription returned by the forwarding of the system topic to the manager topic. More...
 

Detailed Description

System AMI event handling.

Author
Jason Parker jpark.nosp@m.er@d.nosp@m.igium.nosp@m..com

Definition in file manager_system.c.

Function Documentation

◆ manager_system_init()

int manager_system_init ( void  )

Initialize support for AMI system events.

Since
12
Return values
0on success
non-zeroon error

Definition at line 43 of file manager_system.c.

References ast_manager_get_message_router(), ast_manager_get_topic(), ast_register_cleanup(), ast_system_topic(), manager_system_shutdown(), manager_topic, stasis_forward_all(), and system_topic.

Referenced by subscribe_all().

44 {
46  struct stasis_topic *system_topic;
47  struct stasis_message_router *message_router;
48 
49  manager_topic = ast_manager_get_topic();
50  if (!manager_topic) {
51  return -1;
52  }
53  message_router = ast_manager_get_message_router();
54  if (!message_router) {
55  return -1;
56  }
57  system_topic = ast_system_topic();
58  if (!system_topic) {
59  return -1;
60  }
61 
62  topic_forwarder = stasis_forward_all(system_topic, manager_topic);
63  if (!topic_forwarder) {
64  return -1;
65  }
66 
68 
69  return 0;
70 }
static struct stasis_topic * system_topic
The Stasis Message Bus API topic for system level changes.
Definition: stasis_system.c:68
static void manager_system_shutdown(void)
static struct stasis_forward * topic_forwarder
The Stasis Message Bus API subscription returned by the forwarding of the system topic to the manager...
static struct stasis_topic * manager_topic
A stasis_topic that all topics AMI cares about will be forwarded to.
Definition: manager.c:1490
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
Definition: manager.c:1725
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes. ...
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
Definition: manager.c:1720
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
Definition: stasis.c:1578

◆ manager_system_shutdown()

static void manager_system_shutdown ( void  )
static

Definition at line 37 of file manager_system.c.

References NULL, and stasis_forward_cancel().

Referenced by manager_system_init().

38 {
41 }
static struct stasis_forward * topic_forwarder
The Stasis Message Bus API subscription returned by the forwarding of the system topic to the manager...
#define NULL
Definition: resample.c:96
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
Definition: stasis.c:1548

Variable Documentation

◆ topic_forwarder

struct stasis_forward* topic_forwarder
static

The Stasis Message Bus API subscription returned by the forwarding of the system topic to the manager topic.

Definition at line 35 of file manager_system.c.