138 ast_str_append(&peerstatus_event_string, 0,
"PeerStatus: %s\r\n", value);
141 ast_str_append(&peerstatus_event_string, 0,
"Cause: %s\r\n", value);
144 ast_str_append(&peerstatus_event_string, 0,
"Address: %s\r\n", value);
147 ast_str_append(&peerstatus_event_string, 0,
"Port: %s\r\n", value);
150 ast_str_append(&peerstatus_event_string, 0,
"Time: %s\r\n", value);
154 "ChannelType: %s\r\n" 172 if (!json_endpoint) {
186 "type",
"PeerStatusChange",
188 "endpoint", json_endpoint,
212 ast_str_append(&contactstatus_event_string, 0,
"URI: %s\r\n", value);
217 ast_str_append(&contactstatus_event_string, 0,
"ContactStatus: %s\r\n", value);
222 ast_str_append(&contactstatus_event_string, 0,
"AOR: %s\r\n", value);
227 ast_str_append(&contactstatus_event_string, 0,
"EndpointName: %s\r\n", value);
230 ast_str_append(&contactstatus_event_string, 0,
"RoundtripUsec: %s\r\n", value);
246 if (!json_endpoint) {
253 json_final =
ast_json_pack(
"{s: s, s: o, s: o, s: { s: s, s: s, s: s, s: s } } ",
254 "type",
"ContactStatusChange",
256 "endpoint", json_endpoint,
262 "roundtrip_usec", rtt);
264 json_final =
ast_json_pack(
"{s: s, s: o, s: o, s: { s: s, s: s, s: s } } ",
265 "type",
"ContactStatusChange",
267 "endpoint", json_endpoint,
407 "technology", snapshot->
tech,
455 endpoint_cache_all =
NULL;
465 if (!endpoint_cache_all) {
Struct containing info for an AMI event to send out.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Asterisk main include file. File version handling, generic pbx functions.
struct stasis_topic * stasis_cp_all_topic_cached(struct stasis_cp_all *all)
Get the caching topic.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_endpoint_snapshot * ast_endpoint_snapshot_create(struct ast_endpoint *endpoint)
Create a snapshot of an endpoint.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
int(* channel_id)(const char *channel_id)
Callback which determines whether a channel should be sanitized from a message based on the channel's...
struct stasis_cp_all * ast_endpoint_cache_all(void)
int ast_json_object_update(struct ast_json *object, struct ast_json *other)
Update object with all of the fields of other.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
struct stasis_message * ast_endpoint_blob_create(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates a ast_endpoint_blob message.
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot(const char *tech, const char *name)
Retrieve the most recent snapshot for the endpoint with the given name.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
const ast_string_field id
static const char * endpoint_snapshot_get_id(struct stasis_message *message)
Callback extract a unique identity from a snapshot message.
STASIS_MESSAGE_TYPE_DEFN(ast_endpoint_snapshot_type)
Blob of data associated with an endpoint.
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.
Structure containing callbacks for Stasis message sanitization.
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
static struct ast_json * peerstatus_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_strlen_zero(foo)
struct ast_json * ast_json_null(void)
Get the JSON null value.
static struct ast_manager_event_blob * contactstatus_to_ami(struct stasis_message *msg)
#define EVENT_FLAG_SYSTEM
struct stasis_cache * stasis_cp_all_cache(struct stasis_cp_all *all)
Get the cache.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
const struct timeval * stasis_message_timestamp(const struct stasis_message *msg)
Get the time when a message was created.
const ast_string_field resource
#define ao2_ref(o, delta)
int ast_endpoint_stasis_init(void)
Initialization function for endpoint stasis support.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
A snapshot of an endpoint's state.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
struct ast_json * ast_endpoint_snapshot_to_json(const struct ast_endpoint_snapshot *snapshot, const struct stasis_message_sanitizer *sanitize)
Build a JSON object from a ast_endpoint_snapshot.
char * ast_tech_to_upper(char *dev_str)
Convert the tech portion of a device string to upper case.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
const ast_string_field tech
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
static struct stasis_cp_all * endpoint_cache_all
#define ao2_alloc(data_size, destructor_fn)
static void endpoints_stasis_cleanup(void)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
struct stasis_topic * ast_endpoint_topic_all(void)
Topic for all endpoint releated messages.
static struct ast_manager_event_blob * peerstatus_to_ami(struct stasis_message *msg)
const char * ast_endpoint_state_to_string(enum ast_endpoint_state state)
Returns a string representation of the given endpoint state.
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
struct ast_endpoint_snapshot * snapshot
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
struct stasis_message_type * ast_endpoint_contact_state_type(void)
Message type for endpoint contact state changes.
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
Abstract JSON element (object, array, string, int, ...).
static struct ast_json * contactstatus_to_json(struct stasis_message *msg, const struct stasis_message_sanitizer *sanitize)
struct stasis_topic * stasis_cp_all_topic(struct stasis_cp_all *all)
Get the aggregate topic.
static void endpoint_blob_dtor(void *obj)
enum ast_endpoint_state state
struct stasis_cp_all * stasis_cp_all_create(const char *name, snapshot_get_id id_fn)
Create an all instance of the cache pattern.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().