41#define TECH_WILDCARD "__AST_ALL_TECH"
46#define ENDPOINTS_NUM_BUCKETS 127
92 size_t size =
sizeof(*tuple) + strlen(
app_name) + 1;
126 size_t size =
sizeof(*sub) + strlen(
token) + 1;
164 const char *right_key = arg;
169 right_key = object_right->
token;
172 cmp = strcmp(object_left->
token, right_key);
179 cmp = strncmp(object_left->
token, right_key, strlen(right_key));
230 || !strncasecmp(
sub->token,
buf, strlen(
sub->token))
231 || !strncasecmp(
sub->token,
buf, strlen(
sub->token))) {
287 "variables", json_vars);
296 ast_debug(3,
"Dispatching message to subscription %s for endpoint %s\n",
302 tuple->
callback(endpoint_name, json_msg, tuple->
pvt);
314 const char *endpoint_name;
335 || !strncasecmp(
sub->token,
buf, strlen(
sub->token))) {
337 matching_subscriptions[j++] =
sub;
345 matching_subscriptions[j++] =
sub;
349 for (i = 0; i < j; i++) {
350 sub = matching_subscriptions[i];
370 return !strcmp(
sub->token, key) ? 1 : 0;
375 return !strcmp(
item->app_name, key) ? 1 : 0;
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
@ AO2_ALLOC_OPT_LOCK_RWLOCK
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ao2_t_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn, tag)
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
@ OBJ_SEARCH_PARTIAL_KEY
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
@ OBJ_SEARCH_OBJECT
The arg parameter is an object of the same type.
@ OBJ_SEARCH_MASK
Search option field mask.
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
struct ast_endpoint * ast_endpoint_find_by_id(const char *id)
Finds the endpoint with the given tech[/resource] id.
const char * ast_endpoint_get_tech(const struct ast_endpoint *endpoint)
Gets the technology of the given endpoint.
const char * ast_endpoint_get_resource(const struct ast_endpoint *endpoint)
Gets the resource name of the given endpoint.
const char * ast_endpoint_get_id(const struct ast_endpoint *endpoint)
Gets the tech/resource id of the given endpoint.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_debug(level,...)
Log a DEBUG message.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Asterisk locking-related definitions:
#define ast_rwlock_wrlock(a)
#define ast_rwlock_rdlock(a)
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
#define ast_rwlock_destroy(rwlock)
#define ast_rwlock_unlock(a)
Out-of-call text message support.
int ast_msg_handler_unregister(const struct ast_msg_handler *handler)
Unregister a ast_msg_handler.
const char * ast_msg_get_from(const struct ast_msg *msg)
Retrieve the source of this message.
void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *iter)
Destroy a message variable iterator.
const char * ast_msg_get_endpoint(const struct ast_msg *msg)
Retrieve the endpoint associated with this message.
const char * ast_msg_get_to(const struct ast_msg *msg)
Retrieve the destination of this message.
const char * ast_msg_get_tech(const struct ast_msg *msg)
Retrieve the technology associated with this message.
const char * ast_msg_get_body(const struct ast_msg *msg)
Get the body of a message.
int ast_msg_handler_register(const struct ast_msg_handler *handler)
Register a ast_msg_handler.
int ast_msg_var_iterator_next_received(const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value)
Get the next variable name and value that was set on a received message.
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter)
Unref a message var from inside an iterator loop.
struct ast_msg_var_iterator * ast_msg_var_iterator_init(const struct ast_msg *msg)
Create a new message variable iterator.
int messaging_app_subscribe_endpoint(const char *app_name, struct ast_endpoint *endpoint, message_received_cb callback, void *pvt)
Subscribe an application to an endpoint for messages.
struct ast_msg_handler ari_msg_handler
static int messaging_subscription_cmp(struct message_subscription *sub, const char *key)
#define ENDPOINTS_NUM_BUCKETS
Number of buckets for the endpoint_subscriptions container.
static struct ao2_container * endpoint_subscriptions
The subscriptions to endpoints.
static void application_tuple_dtor(void *obj)
static void message_subscription_dtor(void *obj)
#define TECH_WILDCARD
Subscription to all technologies.
int messaging_init(void)
Initialize the messaging layer.
static struct @490 tech_subscriptions
The subscriptions to technologies.
static int message_subscription_hash_cb(const void *obj, const int flags)
static void dispatch_message(struct message_subscription *sub, const char *endpoint_name, struct ast_json *json_msg)
static int application_tuple_cmp(struct application_tuple *item, const char *key)
static struct application_tuple * application_tuple_alloc(const char *app_name, message_received_cb callback, void *pvt)
static struct message_subscription * message_subscription_alloc(const char *token)
static void msg_to_endpoint(const struct ast_msg *msg, char *buf, size_t len)
static struct message_subscription * get_subscription(struct ast_endpoint *endpoint)
static int handle_msg_cb(struct ast_msg *msg)
static int message_subscription_compare_cb(void *obj, void *arg, int flags)
void messaging_app_unsubscribe_endpoint(const char *app_name, const char *endpoint_id)
Subscribe for messages from a particular endpoint.
static int has_destination_cb(const struct ast_msg *msg)
static struct message_subscription * get_or_create_subscription(struct ast_endpoint *endpoint)
int messaging_cleanup(void)
Tidy up the messaging layer.
static ast_rwlock_t tech_subscriptions_lock
RWLock for tech_subscriptions.
static struct ast_json * msg_to_json(struct ast_msg *msg)
static int is_app_subscribed(struct message_subscription *sub, const char *app_name)
Stasis out-of-call text message support.
int(* message_received_cb)(const char *endpoint_id, struct ast_json *json_msg, void *pvt)
Callback handler for when a message is received from the core.
const char * app_name(struct ast_app *app)
struct stasis_forward * sub
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Storage object for an application.
message_received_cb callback
Abstract JSON element (object, array, string, int, ...).
An external processor of received messages.
const char * name
Name of the message handler.
Structure for rwlock and tracking information.
A subscription to some endpoint or technology.
struct message_subscription::@491 applications
#define ast_test_suite_event_notify(s, f,...)
static struct aco_type item
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Vector container support.
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.