Asterisk - The Open Source Telephony Project  18.5.0
Functions
stasis_system.h File Reference
#include "asterisk/stasis.h"
Include dependency graph for stasis_system.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct stasis_message_typeast_cc_available_type (void)
 A stasis_message_type for CCSS Available messages. More...
 
struct stasis_message_typeast_cc_callerrecalling_type (void)
 A stasis_message_type for CCSS Caller Recalling messages. More...
 
struct stasis_message_typeast_cc_callerstartmonitoring_type (void)
 A stasis_message_type for CCSS Caller Start Monitoring messages. More...
 
struct stasis_message_typeast_cc_callerstopmonitoring_type (void)
 A stasis_message_type for CCSS Caller Stop Monitoring messages. More...
 
struct stasis_message_typeast_cc_failure_type (void)
 A stasis_message_type for CCSS Failure messages. More...
 
struct stasis_message_typeast_cc_monitorfailed_type (void)
 A stasis_message_type for CCSS Monitor Failed messages. More...
 
struct stasis_message_typeast_cc_offertimerstart_type (void)
 A stasis_message_type for CCSS Offer Timer Start messages. More...
 
struct stasis_message_typeast_cc_recallcomplete_type (void)
 A stasis_message_type for CCSS Recall Complete messages. More...
 
struct stasis_message_typeast_cc_requestacknowledged_type (void)
 A stasis_message_type for CCSS Request Acknowledged messages. More...
 
struct stasis_message_typeast_cc_requested_type (void)
 A stasis_message_type for CCSS Requested messages. More...
 
struct stasis_message_typeast_cluster_discovery_type (void)
 A stasis_message_type for Cluster discovery. More...
 
struct stasis_message_typeast_network_change_type (void)
 A stasis_message_type for network changes. More...
 
int ast_stasis_system_init (void)
 Initialize the stasis system topic and message types. More...
 
void ast_system_publish_registry (const char *channeltype, const char *username, const char *domain, const char *status, const char *cause)
 Publish a channel driver outgoing registration message. More...
 
struct stasis_message_typeast_system_registry_type (void)
 A stasis_message_type for outbound registration. More...
 
struct stasis_topicast_system_topic (void)
 A Stasis Message Bus API topic which publishes messages regarding system changes. More...
 

Function Documentation

◆ ast_cc_available_type()

struct stasis_message_type* ast_cc_available_type ( void  )

A stasis_message_type for CCSS Available messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_available(), and stasis_system_cleanup().

◆ ast_cc_callerrecalling_type()

struct stasis_message_type* ast_cc_callerrecalling_type ( void  )

A stasis_message_type for CCSS Caller Recalling messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_callerrecalling(), and stasis_system_cleanup().

◆ ast_cc_callerstartmonitoring_type()

struct stasis_message_type* ast_cc_callerstartmonitoring_type ( void  )

A stasis_message_type for CCSS Caller Start Monitoring messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_callerstartmonitoring(), and stasis_system_cleanup().

◆ ast_cc_callerstopmonitoring_type()

struct stasis_message_type* ast_cc_callerstopmonitoring_type ( void  )

A stasis_message_type for CCSS Caller Stop Monitoring messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_callerstopmonitoring(), and stasis_system_cleanup().

◆ ast_cc_failure_type()

struct stasis_message_type* ast_cc_failure_type ( void  )

A stasis_message_type for CCSS Failure messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_failure(), and stasis_system_cleanup().

◆ ast_cc_monitorfailed_type()

struct stasis_message_type* ast_cc_monitorfailed_type ( void  )

A stasis_message_type for CCSS Monitor Failed messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_monitorfailed(), and stasis_system_cleanup().

◆ ast_cc_offertimerstart_type()

struct stasis_message_type* ast_cc_offertimerstart_type ( void  )

A stasis_message_type for CCSS Offer Timer Start messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_offertimerstart(), and stasis_system_cleanup().

◆ ast_cc_recallcomplete_type()

struct stasis_message_type* ast_cc_recallcomplete_type ( void  )

A stasis_message_type for CCSS Recall Complete messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_recallcomplete(), and stasis_system_cleanup().

◆ ast_cc_requestacknowledged_type()

struct stasis_message_type* ast_cc_requestacknowledged_type ( void  )

A stasis_message_type for CCSS Request Acknowledged messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_requestacknowledged(), and stasis_system_cleanup().

◆ ast_cc_requested_type()

struct stasis_message_type* ast_cc_requested_type ( void  )

A stasis_message_type for CCSS Requested messages.

Since
12

Referenced by ast_stasis_system_init(), cc_publish_requested(), and stasis_system_cleanup().

◆ ast_cluster_discovery_type()

struct stasis_message_type* ast_cluster_discovery_type ( void  )

◆ ast_network_change_type()

struct stasis_message_type* ast_network_change_type ( void  )

◆ ast_stasis_system_init()

int ast_stasis_system_init ( void  )

Initialize the stasis system topic and message types.

Return values
0on success
-1on failure

Initialize the stasis system topic and message types.

Definition at line 373 of file stasis_system.c.

References ast_cc_available_type(), ast_cc_callerrecalling_type(), ast_cc_callerstartmonitoring_type(), ast_cc_callerstopmonitoring_type(), ast_cc_failure_type(), ast_cc_monitorfailed_type(), ast_cc_offertimerstart_type(), ast_cc_recallcomplete_type(), ast_cc_requestacknowledged_type(), ast_cc_requested_type(), ast_cluster_discovery_type(), ast_network_change_type(), ast_register_cleanup(), ast_system_registry_type(), STASIS_MESSAGE_TYPE_INIT, stasis_system_cleanup(), and stasis_topic_create().

Referenced by asterisk_daemon().

374 {
376 
377  system_topic = stasis_topic_create("system:all");
378  if (!system_topic) {
379  return 1;
380  }
381 
383  return -1;
384  }
385 
387  return -1;
388  }
389 
391  return -1;
392  }
393 
395  return -1;
396  }
397 
399  return -1;
400  }
401 
403  return -1;
404  }
405 
407  return -1;
408  }
409 
411  return -1;
412  }
413 
415  return -1;
416  }
417 
419  return -1;
420  }
421 
423  return -1;
424  }
425 
427  return -1;
428  }
429 
431  return -1;
432  }
433 
434  return 0;
435 }
struct stasis_message_type * ast_cc_callerstartmonitoring_type(void)
A stasis_message_type for CCSS Caller Start Monitoring messages.
static struct stasis_topic * system_topic
The Stasis Message Bus API topic for system level changes.
Definition: stasis_system.c:68
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1501
struct stasis_message_type * ast_network_change_type(void)
A stasis_message_type for network changes.
struct stasis_message_type * ast_cc_callerrecalling_type(void)
A stasis_message_type for CCSS Caller Recalling messages.
struct stasis_message_type * ast_cc_failure_type(void)
A stasis_message_type for CCSS Failure 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_cc_monitorfailed_type(void)
A stasis_message_type for CCSS Monitor Failed messages.
struct stasis_message_type * ast_cc_offertimerstart_type(void)
A stasis_message_type for CCSS Offer Timer Start messages.
static void stasis_system_cleanup(void)
Cleanup the Stasis Message Bus API system level items.
struct stasis_topic * stasis_topic_create(const char *name)
Create a new topic.
Definition: stasis.c:618
struct stasis_message_type * ast_cc_callerstopmonitoring_type(void)
A stasis_message_type for CCSS Caller Stop Monitoring messages.
struct stasis_message_type * ast_system_registry_type(void)
A stasis_message_type for outbound registration.
struct stasis_message_type * ast_cc_recallcomplete_type(void)
A stasis_message_type for CCSS Recall Complete messages.
struct stasis_message_type * ast_cluster_discovery_type(void)
A stasis_message_type for Cluster discovery.
struct stasis_message_type * ast_cc_requested_type(void)
A stasis_message_type for CCSS Requested messages.
struct stasis_message_type * ast_cc_requestacknowledged_type(void)
A stasis_message_type for CCSS Request Acknowledged messages.
struct stasis_message_type * ast_cc_available_type(void)
A stasis_message_type for CCSS Available messages.

◆ ast_system_publish_registry()

void ast_system_publish_registry ( const char *  channeltype,
const char *  username,
const char *  domain,
const char *  status,
const char *  cause 
)

Publish a channel driver outgoing registration message.

Since
12
Parameters
channeltypeThe channel driver that published the message
usernameThe username that was used to register
domainThe domain that was used to register
statusThe result of the registration
causeThe reason for the result

Definition at line 118 of file stasis_system.c.

References ao2_ref, ast_json_pack(), ast_json_payload_create(), ast_json_unref(), ast_system_registry_type(), ast_system_topic(), S_OR, stasis_message_create(), and stasis_publish().

Referenced by handle_registration_response(), iax2_publish_registry(), and sip_publish_registry().

119 {
120  struct ast_json *registry;
121  struct ast_json_payload *payload;
122  struct stasis_message *message;
123 
124  if (!ast_system_registry_type()) {
125  return;
126  }
127 
128  registry = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s}",
129  "type", "registry",
130  "channeltype", channeltype,
131  "username", username,
132  "domain", domain,
133  "status", status,
134  "cause", S_OR(cause, ""));
135 
136  payload = ast_json_payload_create(registry);
137  ast_json_unref(registry);
138  if (!payload) {
139  return;
140  }
141 
142  message = stasis_message_create(ast_system_registry_type(), payload);
143  ao2_ref(payload, -1);
144  if (!message) {
145  return;
146  }
147 
148  stasis_publish(ast_system_topic(), message);
149  ao2_ref(message, -1);
150 }
struct stasis_topic * ast_system_topic(void)
A Stasis Message Bus API topic which publishes messages regarding system changes. ...
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
Definition: json.c:735
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
Domain data structure.
Definition: sip.h:888
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
struct stasis_message_type * ast_system_registry_type(void)
A stasis_message_type for outbound registration.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
Abstract JSON element (object, array, string, int, ...).
jack_status_t status
Definition: app_jack.c:146

◆ ast_system_registry_type()

struct stasis_message_type* ast_system_registry_type ( void  )

◆ ast_system_topic()

struct stasis_topic* ast_system_topic ( void  )

A Stasis Message Bus API topic which publishes messages regarding system changes.

Since
12
Return values

Definition at line 347 of file stasis_system.c.

References system_topic.

Referenced by ast_system_publish_registry(), cc_publish(), load_module(), manager_system_init(), network_change_stasis_subscribe(), pjsip_outbound_registration_metrics_init(), publish_cluster_discovery_to_stasis_full(), publish_format_update(), and stun_monitor_request().

348 {
349  return system_topic;
350 }
static struct stasis_topic * system_topic
The Stasis Message Bus API topic for system level changes.
Definition: stasis_system.c:68