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

Stasis Messages and Data Types for System events. More...

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

Go to the source code of this file.

Functions

int ast_stasis_system_init (void)
 Initialize the system level items for Stasis Message Bus API. 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_topicast_system_topic (void)
 A Stasis Message Bus API topic which publishes messages regarding system changes. More...
 
static struct ast_manager_event_blobcc_available_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_callerrecalling_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_callerstartmonitoring_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_callerstopmonitoring_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_failure_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_monitorfailed_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_offertimerstart_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_recallcomplete_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_requestacknowledged_to_ami (struct stasis_message *message)
 
static struct ast_manager_event_blobcc_requested_to_ami (struct stasis_message *message)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_network_change_type)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_system_registry_type,.to_ami=system_registry_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_available_type,.to_ami=cc_available_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_offertimerstart_type,.to_ami=cc_offertimerstart_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_requested_type,.to_ami=cc_requested_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_requestacknowledged_type,.to_ami=cc_requestacknowledged_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_callerstopmonitoring_type,.to_ami=cc_callerstopmonitoring_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_callerstartmonitoring_type,.to_ami=cc_callerstartmonitoring_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_callerrecalling_type,.to_ami=cc_callerrecalling_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_recallcomplete_type,.to_ami=cc_recallcomplete_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_failure_type,.to_ami=cc_failure_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cc_monitorfailed_type,.to_ami=cc_monitorfailed_to_ami,)
 
 STASIS_MESSAGE_TYPE_DEFN (ast_cluster_discovery_type)
 
static void stasis_system_cleanup (void)
 Cleanup the Stasis Message Bus API system level items. More...
 
static struct ast_manager_event_blobsystem_registry_to_ami (struct stasis_message *message)
 

Variables

static struct stasis_topicsystem_topic
 The Stasis Message Bus API topic for system level changes. More...
 

Detailed Description

Stasis Messages and Data Types for System events.

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

Definition in file stasis_system.c.

Function Documentation

◆ ast_stasis_system_init()

int ast_stasis_system_init ( void  )

Initialize the system level items for Stasis Message Bus API.

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_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

◆ cc_available_to_ami()

static struct ast_manager_event_blob * cc_available_to_ami ( struct stasis_message message)
static

Definition at line 185 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, service, and stasis_message_data().

186 {
187  struct ast_json_payload *payload = stasis_message_data(message);
188  int core_id;
189  const char *callee;
190  const char *service;
191 
192  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
193  callee = ast_json_string_get(ast_json_object_get(payload->json, "callee"));
194  service = ast_json_string_get(ast_json_object_get(payload->json, "service"));
195 
196  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCAvailable",
197  "CoreID: %d\r\n"
198  "Callee: %s\r\n"
199  "Service: %s\r\n",
200  core_id, callee, service);
201 }
struct ast_json * json
Definition: json.h:1025
enum ast_cc_service_type service
Definition: chan_sip.c:949
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_callerrecalling_to_ami()

static struct ast_manager_event_blob * cc_callerrecalling_to_ami ( struct stasis_message message)
static

Definition at line 284 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

285 {
286  struct ast_json_payload *payload = stasis_message_data(message);
287  int core_id;
288  const char *caller;
289 
290  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
291  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
292 
293  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCCallerRecalling",
294  "CoreID: %d\r\n"
295  "Caller: %s\r\n",
296  core_id, caller);
297 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_callerstartmonitoring_to_ami()

static struct ast_manager_event_blob * cc_callerstartmonitoring_to_ami ( struct stasis_message message)
static

Definition at line 269 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

270 {
271  struct ast_json_payload *payload = stasis_message_data(message);
272  int core_id;
273  const char *caller;
274 
275  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
276  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
277 
278  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCCallerStartMonitoring",
279  "CoreID: %d\r\n"
280  "Caller: %s\r\n",
281  core_id, caller);
282 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_callerstopmonitoring_to_ami()

static struct ast_manager_event_blob * cc_callerstopmonitoring_to_ami ( struct stasis_message message)
static

Definition at line 254 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

255 {
256  struct ast_json_payload *payload = stasis_message_data(message);
257  int core_id;
258  const char *caller;
259 
260  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
261  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
262 
263  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCCallerStopMonitoring",
264  "CoreID: %d\r\n"
265  "Caller: %s\r\n",
266  core_id, caller);
267 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_failure_to_ami()

static struct ast_manager_event_blob * cc_failure_to_ami ( struct stasis_message message)
static

Definition at line 314 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

315 {
316  struct ast_json_payload *payload = stasis_message_data(message);
317  int core_id;
318  const char *caller;
319  const char *reason;
320 
321  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
322  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
323  reason = ast_json_string_get(ast_json_object_get(payload->json, "reason"));
324 
325  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCFailure",
326  "CoreID: %d\r\n"
327  "Caller: %s\r\n"
328  "Reason: %s\r\n",
329  core_id, caller, reason);
330 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_monitorfailed_to_ami()

static struct ast_manager_event_blob * cc_monitorfailed_to_ami ( struct stasis_message message)
static

Definition at line 332 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

333 {
334  struct ast_json_payload *payload = stasis_message_data(message);
335  int core_id;
336  const char *callee;
337 
338  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
339  callee = ast_json_string_get(ast_json_object_get(payload->json, "callee"));
340 
341  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCMonitorFailed",
342  "CoreID: %d\r\n"
343  "Callee: %s\r\n",
344  core_id, callee);
345 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_offertimerstart_to_ami()

static struct ast_manager_event_blob * cc_offertimerstart_to_ami ( struct stasis_message message)
static

Definition at line 203 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

204 {
205  struct ast_json_payload *payload = stasis_message_data(message);
206  int core_id;
207  const char *caller;
208  unsigned int expires;
209 
210  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
211  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
212  expires = ast_json_integer_get(ast_json_object_get(payload->json, "expires"));
213 
214  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCOfferTimerStart",
215  "CoreID: %d\r\n"
216  "Caller: %s\r\n"
217  "Expires: %u\r\n",
218  core_id, caller, expires);
219 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_recallcomplete_to_ami()

static struct ast_manager_event_blob * cc_recallcomplete_to_ami ( struct stasis_message message)
static

Definition at line 299 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

300 {
301  struct ast_json_payload *payload = stasis_message_data(message);
302  int core_id;
303  const char *caller;
304 
305  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
306  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
307 
308  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCRecallComplete",
309  "CoreID: %d\r\n"
310  "Caller: %s\r\n",
311  core_id, caller);
312 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_requestacknowledged_to_ami()

static struct ast_manager_event_blob * cc_requestacknowledged_to_ami ( struct stasis_message message)
static

Definition at line 239 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

240 {
241  struct ast_json_payload *payload = stasis_message_data(message);
242  int core_id;
243  const char *caller;
244 
245  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
246  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
247 
248  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCRequestAcknowledged",
249  "CoreID: %d\r\n"
250  "Caller: %s\r\n",
251  core_id, caller);
252 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ cc_requested_to_ami()

static struct ast_manager_event_blob * cc_requested_to_ami ( struct stasis_message message)
static

Definition at line 221 of file stasis_system.c.

References ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), EVENT_FLAG_CC, ast_json_payload::json, and stasis_message_data().

222 {
223  struct ast_json_payload *payload = stasis_message_data(message);
224  int core_id;
225  const char *caller;
226  const char *callee;
227 
228  core_id = ast_json_integer_get(ast_json_object_get(payload->json, "core_id"));
229  caller = ast_json_string_get(ast_json_object_get(payload->json, "caller"));
230  callee = ast_json_string_get(ast_json_object_get(payload->json, "callee"));
231 
232  return ast_manager_event_blob_create(EVENT_FLAG_CC, "CCRequested",
233  "CoreID: %d\r\n"
234  "Caller: %s\r\n"
235  "Callee: %s\r\n",
236  core_id, caller, callee);
237 }
struct ast_json * json
Definition: json.h:1025
#define EVENT_FLAG_CC
Definition: manager.h:86
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Definition: json.c:322

◆ STASIS_MESSAGE_TYPE_DEFN() [1/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_network_change_type  )

◆ STASIS_MESSAGE_TYPE_DEFN() [2/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_system_registry_type  ,
to_ami = system_registry_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [3/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_available_type  ,
to_ami = cc_available_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [4/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_offertimerstart_type  ,
to_ami = cc_offertimerstart_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [5/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_requested_type  ,
to_ami = cc_requested_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [6/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_requestacknowledged_type  ,
to_ami = cc_requestacknowledged_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [7/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_callerstopmonitoring_type  ,
to_ami = cc_callerstopmonitoring_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [8/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_callerstartmonitoring_type  ,
to_ami = cc_callerstartmonitoring_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [9/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_callerrecalling_type  ,
to_ami = cc_callerrecalling_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [10/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_recallcomplete_type  ,
to_ami = cc_recallcomplete_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [11/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_failure_type  ,
to_ami = cc_failure_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [12/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cc_monitorfailed_type  ,
to_ami = cc_monitorfailed_to_ami 
)

◆ STASIS_MESSAGE_TYPE_DEFN() [13/13]

STASIS_MESSAGE_TYPE_DEFN ( ast_cluster_discovery_type  )

◆ stasis_system_cleanup()

static void stasis_system_cleanup ( void  )
static

Cleanup the Stasis Message Bus API system level items.

Definition at line 353 of file stasis_system.c.

References ao2_cleanup, 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_system_registry_type(), NULL, and STASIS_MESSAGE_TYPE_CLEANUP.

Referenced by ast_stasis_system_init().

354 {
356  system_topic = NULL;
370 }
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
struct stasis_message_type * ast_network_change_type(void)
A stasis_message_type for network changes.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
Definition: stasis.h:1523
struct stasis_message_type * ast_cc_callerrecalling_type(void)
A stasis_message_type for CCSS Caller Recalling messages.
#define NULL
Definition: resample.c:96
struct stasis_message_type * ast_cc_failure_type(void)
A stasis_message_type for CCSS Failure messages.
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.
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.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
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.

◆ system_registry_to_ami()

static struct ast_manager_event_blob * system_registry_to_ami ( struct stasis_message message)
static

Definition at line 152 of file stasis_system.c.

References ast_free, ast_json_object_get(), ast_json_string_get(), ast_manager_event_blob_create(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_strlen_zero, EVENT_FLAG_SYSTEM, ast_json_payload::json, NULL, RAII_VAR, stasis_message_data(), and status.

153 {
154  struct ast_json_payload *payload = stasis_message_data(message);
155  const char *channeltype;
156  const char *username;
157  const char *domain;
158  const char *status;
159  const char *cause;
160  RAII_VAR(struct ast_str *, cause_string, ast_str_create(32), ast_free);
161 
162  if (!cause_string) {
163  return NULL;
164  }
165 
166  channeltype = ast_json_string_get(ast_json_object_get(payload->json, "channeltype"));
167  username = ast_json_string_get(ast_json_object_get(payload->json, "username"));
168  domain = ast_json_string_get(ast_json_object_get(payload->json, "domain"));
169  status = ast_json_string_get(ast_json_object_get(payload->json, "status"));
170  cause = ast_json_string_get(ast_json_object_get(payload->json, "cause"));
171 
172  if (!ast_strlen_zero(cause)) {
173  ast_str_set(&cause_string, 0, "Cause: %s\r\n", cause);
174  }
175 
177  "ChannelType: %s\r\n"
178  "Username: %s\r\n"
179  "Domain: %s\r\n"
180  "Status: %s\r\n"
181  "%s",
182  channeltype, username, domain, status, ast_str_buffer(cause_string));
183 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
struct ast_json * json
Definition: json.h:1025
#define NULL
Definition: resample.c:96
Domain data structure.
Definition: sip.h:888
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
Definition: manager.c:9727
#define ast_strlen_zero(foo)
Definition: strings.h:52
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1065
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition: json.c:273
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
#define ast_free(a)
Definition: astmm.h:182
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition: json.c:397
jack_status_t status
Definition: app_jack.c:146
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:620

Variable Documentation

◆ system_topic

struct stasis_topic* system_topic
static

The Stasis Message Bus API topic for system level changes.

Definition at line 68 of file stasis_system.c.

Referenced by ast_system_topic(), and manager_system_init().