268 static const char app_msg_send[] =
"MessageSend";
278 char *data,
char *
buf,
size_t len);
280 char *data,
const char *
value);
289 char *data,
char *
buf,
size_t len);
291 char *data,
const char *
value);
294 .
name =
"MESSAGE_DATA",
305 unsigned int duration);
316 .description =
"Internal Text Message Processing",
386 unsigned int duration)
400 const struct msg_data *one = obj, *two = arg;
594 data->
send = outbound;
601 data->
send = outbound;
677 if (data->
send == send) {
679 *value = data->
value;
723 "%s",
"Message/ast_msg_queue");
762 memset(&pbx_args, 0,
sizeof(pbx_args));
918 ast_debug(5,
"Handler %s doesn't want message, moving on\n", handler->
name);
922 ast_debug(5,
"Dispatching message to %s handler\n", handler->
name);
946 ast_debug(5,
"Seeing if %s can handle message\n", handler->
name);
1026 if (!strcasecmp(data,
"to")) {
1028 }
else if (!strcasecmp(data,
"from")) {
1030 }
else if (!strcasecmp(data,
"body")) {
1043 char *data,
const char *
value)
1066 if (!strcasecmp(data,
"to")) {
1068 }
else if (!strcasecmp(data,
"from")) {
1070 }
else if (!strcasecmp(data,
"body")) {
1072 }
else if (!strcasecmp(data,
"custom_data")) {
1074 if (!strcasecmp(value,
"mark_all_outbound")) {
1076 }
else if (!strcasecmp(value,
"clear_all_outbound")) {
1082 if (outbound != -1) {
1087 hdr_data->
send = outbound;
1103 char *data,
char *
buf,
size_t len)
1139 char *data,
const char *
value)
1188 if (!strcmp(current->
name, tech_name)) {
1214 if (!strcmp(current->
name, tech_name)) {
1269 tech_name =
strsep(&tech_name,
":");
1312 char base64decoded[1301] = { 0, };
1313 char *tech_name =
NULL;
1326 ast_base64decode((
unsigned char *) base64decoded, base64body,
sizeof(base64decoded) - 1);
1327 body = base64decoded;
1331 tech_name =
strsep(&tech_name,
":");
1348 for (vars = data;
vars; vars = vars->
next) {
1371 char *tech_name =
NULL;
1381 tech_name =
strsep(&tech_name,
":");
1416 #define ATTRIBUTE_UNSET -1 1422 size_t len =
sizeof(*msg);
1424 size_t current_offset = 0;
1438 for (i=0; i < count; i++) {
1439 if (!attributes[i].
value) {
1443 len += (strlen(attributes[i].value) + 1);
1459 for (i=0; i < count; i++) {
1460 len = (strlen(attributes[i].
value) + 1);
1463 current_offset +=
len;
1470 const char *to,
const char *
from,
const char *content_type,
const char *body)
1476 .value = (
char *)
S_OR(to,
""),
1480 .value = (
char *)
S_OR(from,
""),
1484 .value = (
char *)
S_OR(content_type,
""),
1488 .value = (
char *)
S_OR(body,
""),
1508 memcpy(dest, msg, msg->
length);
1562 memset(&f, 0,
sizeof(f));
1589 ast_verb(3,
"Message technology '%s' registered.\n", tech->
name);
1607 return !strcmp(vec_elem->
name, srch->
name);
1624 ast_verb(2,
"Message technology '%s' unregistered.\n", tech->
name);
1649 ast_verb(2,
"Message handler '%s' registered.\n", handler->
name);
1668 return !strcmp(vec_elem->
name, srch->
name);
1685 ast_verb(3,
"Message handler '%s' unregistered.\n", handler->
name);
size_t ast_msg_data_get_length(struct ast_msg_data *msg)
Get length of the structure.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
struct ast_variable * next
AST_VECTOR(const struct ast_msg_tech *)
Vector of message technologies.
Options for ast_pbx_run()
#define ast_rwlock_rdlock(a)
#define ast_channel_lock(chan)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
static int dialplan_has_destination_cb(const struct ast_msg *msg)
Asterisk main include file. File version handling, generic pbx functions.
int ast_msg_set_context(struct ast_msg *msg, const char *fmt,...)
Set the dialplan context for this message.
enum ast_msg_data_source_type ast_msg_data_get_source_type(struct ast_msg_data *msg)
Get "source type" from ast_msg_data.
void ast_msg_shutdown(void)
static struct ast_channel_tech msg_chan_tech_hack
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
int(*const handle_msg)(struct ast_msg *msg)
The function callback that will handle the message.
String manipulation functions.
enum ast_msg_data_attribute_type type
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_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_msg_data * ast_msg_data_dup(struct ast_msg_data *msg)
Clone an ast_msg_data structure.
#define AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison.
static void msg_route(struct ast_channel *chan, struct ast_msg *msg)
static int msg_data_cmp_fn(void *obj, void *arg, int flags)
#define ast_rwlock_destroy(rwlock)
An external processor of received messages.
struct ast_msg * ast_msg_alloc(void)
Allocate a message.
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary...
static void msg_data_destructor(void *obj)
const char * ast_msg_get_body(const struct ast_msg *msg)
Get the body of a message.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
const ast_string_field to
int ast_msg_handler_register(const struct ast_msg_handler *handler)
Register a ast_msg_handler.
Structure for variables, used for configurations and for channel variables.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
static struct ast_threadstorage msg_q_chan
return a reference to a taskprocessor, create one if it does not exist
const char *const name
Name of this message technology.
Structure for a data store type.
Structure used to transport a message through the frame core.
int ast_msg_handler_unregister(const struct ast_msg_handler *handler)
Unregister a ast_msg_handler.
static void destroy_msg_q_chan(void *data)
static void message_shutdown(void)
static const struct ast_msg_tech * msg_find_by_tech_name(const char *tech_name)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
const ast_string_field endpoint
static struct msg_data * msg_data_alloc(void)
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
struct ast_msg_data * ast_msg_data_alloc(enum ast_msg_data_source_type source, struct ast_msg_data_attribute attributes[], size_t count)
Allocates an ast_msg_data structure.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
static const struct ast_msg_tech msg_tech
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
const char * ast_msg_get_var(struct ast_msg *msg, const char *name)
Get the specified variable on the message.
struct varshead * ast_channel_varshead(struct ast_channel *chan)
static struct ast_custom_function msg_function
int(*const has_destination)(const struct ast_msg *msg)
Return whether or not the message has a valid destination.
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Out-of-call text message support.
#define ast_rwlock_unlock(a)
static int msg_data_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
int ast_unregister_application(const char *app)
Unregister an application.
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter)
Unref a message var from inside an iterator loop.
static struct ast_custom_function msg_data_function
#define ast_verb(level,...)
struct ast_msg * ast_msg_ref(struct ast_msg *msg)
Bump a msg's ref count.
const char * ast_msg_get_endpoint(const struct ast_msg *msg)
Retrieve the endpoint associated with this message.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
const ast_string_field exten
int ast_msg_var_iterator_next(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 is set for sending outbound.
static int msg_data_func_write(struct ast_channel *chan, const char *function, char *data, const char *value)
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
static void msg_destructor(void *obj)
Asterisk datastore objects.
static int msg_func_write(struct ast_channel *chan, const char *function, char *data, const char *value)
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
int ast_base64decode(unsigned char *dst, const char *src, int max)
Decode data from base64.
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
int ast_msg_send(struct ast_msg *msg, const char *to, const char *from)
Send a msg directly to an endpoint.
#define ast_opt_hide_messaging_ami_events
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
static int msg_q_cb(void *data)
enum ast_msg_data_source_type source
struct ao2_container * vars
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
static void msg_ds_destroy(void *data)
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Data structure associated with a custom dialplan function.
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
const ast_string_field body
static struct msg_data * msg_data_find(struct ao2_container *vars, const char *name)
#define AST_STRING_FIELD(name)
Declare a string field.
#define ao2_ref(o, delta)
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
static int chan_msg_write(struct ast_channel *chan, struct ast_frame *fr)
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_msg_set_exten(struct ast_msg *msg, const char *fmt,...)
Set the dialplan extension for this message.
#define ast_malloc(len)
A wrapper for malloc()
int ast_msg_queue(struct ast_msg *msg)
Queue a message for routing through the dialplan.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static struct ast_datastore * msg_datastore_find_or_create(struct ast_channel *chan)
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static int msg_set_var_full(struct ast_msg *msg, const char *name, const char *value, unsigned int outbound)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *iter)
Destroy a message variable iterator.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
int ast_msg_data_queue_frame(struct ast_channel *channel, struct ast_msg_data *msg)
Queue an AST_FRAME_TEXT_DATA frame containing an ast_msg_data structure.
const ast_string_field name
struct ast_msg_var_iterator * ast_msg_var_iterator_init(const struct ast_msg *msg)
Create a new message variable iterator.
const char * ast_msg_get_to(const struct ast_msg *msg)
Retrieve the destination of this message.
int attribute_value_offsets[__AST_MSG_DATA_ATTR_LAST]
#define ao2_unlink(container, obj)
static int dialplan_handle_msg_cb(struct ast_msg *msg)
int ast_msg_set_from(struct ast_msg *msg, const char *fmt,...)
Set the 'from' URI of a message.
static int chan_msg_send_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
void ast_var_delete(struct ast_var_t *var)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const char * ast_msg_data_get_attribute(struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type)
Get attribute from ast_msg_data.
#define ao2_iterator_next(iter)
#define ao2_alloc(data_size, destructor_fn)
int ast_msg_set_endpoint(struct ast_msg *msg, const char *fmt,...)
Set the technology's endpoint associated with this message.
const char * ast_msg_get_from(const struct ast_msg *msg)
Retrieve the source of this message.
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
#define ast_calloc(num, len)
A wrapper for calloc()
const ast_string_field from
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Prototypes for public functions only of internal interest,.
static int msg_send_exec(struct ast_channel *chan, const char *data)
static int msg_handler_cmp(const struct ast_msg_handler *vec_elem, const struct ast_msg_handler *srch)
Comparison callback for ast_msg_handler vector removal.
Vector container support.
static struct ast_msg_handler dialplan_msg_handler
#define ao2_find(container, arg, flags)
An API for managing task processing threads that can be shared across modules.
ast_msg_data_attribute_type
static struct ast_channel * create_msg_q_chan(void)
int ast_msg_tech_unregister(const struct ast_msg_tech *tech)
Unregister a message technology.
static struct ast_frame * chan_msg_read(struct ast_channel *chan)
int ast_msg_set_var(struct ast_msg *msg, const char *name, const char *value)
Set a variable on the message going to the dialplan.
static int chan_msg_send_digit_begin(struct ast_channel *chan, char digit)
static ast_rwlock_t msg_techs_lock
Lock for msg_techs vector.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
struct ast_msg * ast_msg_destroy(struct ast_msg *msg)
Destroy an ast_msg.
#define ast_rwlock_wrlock(a)
const char * name
Name of the message handler.
struct ast_frame ast_null_frame
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
char * strsep(char **str, const char *delims)
A ast_taskprocessor structure is a singleton by name.
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap) attribute_warn_unused_result
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
static void chan_cleanup(struct ast_channel *chan)
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
static int msg_tech_cmp(const struct ast_msg_tech *vec_elem, const struct ast_msg_tech *srch)
Comparison callback for ast_msg_tech vector removal.
Structure for rwlock and tracking information.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
struct ast_msg_data * ast_msg_data_alloc2(enum ast_msg_data_source_type source_type, const char *to, const char *from, const char *content_type, const char *body)
Allocates an ast_msg_data structure.
static int msg_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
struct msg_data * current_used
const char * ast_msg_get_tech(const struct ast_msg *msg)
Retrieve the technology associated with this message.
Data structure associated with a single frame of data.
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
int ast_msg_tech_register(const struct ast_msg_tech *tech)
Register a message technology.
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
const ast_string_field context
#define ast_datastore_alloc(info, uid)
union ast_frame::@263 data
enum ast_frame_type frametype
int(*const msg_send)(const struct ast_msg *msg, const char *to, const char *from)
Send a message.
static char context[AST_MAX_CONTEXT]
int ast_msg_set_body(struct ast_msg *msg, const char *fmt,...)
Set the 'body' text of a message (in UTF-8)
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
unsigned int no_hangup_chan
static const struct ast_msg_handler * msg_handler_find_by_tech_name(const char *tech_name)
static int chan_msg_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_msg_set_to(struct ast_msg *msg, const char *fmt,...)
Set the 'to' URI of a message.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
const ast_string_field tech
int ast_msg_has_destination(const struct ast_msg *msg)
Determine if a particular message has a destination via some handler.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
static int action_messagesend(struct mansession *s, const struct message *m)
int ast_msg_set_var_outbound(struct ast_msg *msg, const char *name, const char *value)
Set a variable on the message being sent to a message tech directly.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
static int ast_msg_var_iterator_get_next(const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value, unsigned int send)
const ast_string_field value
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
#define ast_string_field_build_va(x, field, fmt, args)
Set a field to a complex (built) value.
#define AST_APP_ARG(name)
Define an application argument.
#define EVENT_FLAG_MESSAGE
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
int ast_msg_set_tech(struct ast_msg *msg, const char *fmt,...)
Set the technology associated with this message.
#define ao2_link(container, obj)