292 char *data,
char *
buf,
size_t len);
294 char *data,
const char *
value);
303 char *data,
char *
buf,
size_t len);
305 char *data,
const char *
value);
308 .
name =
"MESSAGE_DATA",
319 unsigned int duration);
330 .description =
"Internal Text Message Processing",
400 unsigned int duration)
414 const struct msg_data *one = obj, *two = arg;
608 data->
send = outbound;
615 data->
send = outbound;
737 "%s",
"Message/ast_msg_queue");
776 memset(&pbx_args, 0,
sizeof(pbx_args));
931 if (!
handler->has_destination(msg)) {
932 ast_debug(5,
"Handler %s doesn't want message, moving on\n",
handler->name);
937 res &=
handler->handle_msg(msg);
961 if (
handler->has_destination(msg)) {
1041 if (!strcasecmp(data,
"to")) {
1043 }
else if (!strcasecmp(data,
"from")) {
1045 }
else if (!strcasecmp(data,
"body")) {
1058 char *data,
const char *
value)
1081 if (!strcasecmp(data,
"to")) {
1083 }
else if (!strcasecmp(data,
"from")) {
1085 }
else if (!strcasecmp(data,
"body")) {
1087 }
else if (!strcasecmp(data,
"custom_data")) {
1089 if (!strcasecmp(
value,
"mark_all_outbound")) {
1091 }
else if (!strcasecmp(
value,
"clear_all_outbound")) {
1097 if (outbound != -1) {
1102 hdr_data->
send = outbound;
1118 char *data,
char *
buf,
size_t len)
1154 char *data,
const char *
value)
1203 if (!strcmp(
current->name, tech_name)) {
1229 if (!strcmp(
current->name, tech_name)) {
1284 tech_name =
strsep(&tech_name,
":");
1328 const char *to_override =
NULL;
1329 char base64decoded[1301] = { 0, };
1330 char *tech_name =
NULL;
1350 ast_base64decode((
unsigned char *) base64decoded, base64body,
sizeof(base64decoded) - 1);
1351 body = base64decoded;
1355 tech_name =
strsep(&tech_name,
":");
1399 char *tech_name =
NULL;
1409 tech_name =
strsep(&tech_name,
":");
1444#define ATTRIBUTE_UNSET -1
1450 size_t len =
sizeof(*msg);
1452 size_t current_offset = 0;
1466 for (i=0; i < count; i++) {
1467 if (!attributes[i].
value) {
1471 len += (strlen(attributes[i].
value) + 1);
1487 for (i=0; i < count; i++) {
1488 len = (strlen(attributes[i].
value) + 1);
1491 current_offset +=
len;
1498 const char *to,
const char *from,
const char *content_type,
const char *body)
1504 .value = (
char *)
S_OR(to,
""),
1508 .value = (
char *)
S_OR(from,
""),
1512 .value = (
char *)
S_OR(content_type,
""),
1516 .value = (
char *)
S_OR(body,
""),
1536 memcpy(dest, msg, msg->
length);
1590 memset(&f, 0,
sizeof(f));
1617 ast_verb(5,
"Message technology '%s' registered.\n", tech->
name);
1635 return !strcmp(vec_elem->
name, srch->
name);
1652 ast_verb(5,
"Message technology '%s' unregistered.\n", tech->
name);
1696 return !strcmp(vec_elem->
name, srch->
name);
Prototypes for public functions only of internal interest,.
Asterisk main include file. File version handling, generic pbx functions.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_iterator_next(iter)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
#define ao2_alloc(data_size, destructor_fn)
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
#define ast_channel_lock(chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
@ AST_SOFTHANGUP_ALL
All softhangup flags.
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
#define ast_channel_unlock(chan)
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.
void ast_var_delete(struct ast_var_t *var)
Asterisk datastore objects.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
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.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
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.
enum ast_msg_data_source_type ast_msg_data_get_source_type(struct ast_msg_data *msg)
Get "source type" from ast_msg_data.
ast_msg_data_attribute_type
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.
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.
struct ast_msg_data * ast_msg_data_dup(struct ast_msg_data *msg)
Clone an ast_msg_data structure.
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.
size_t ast_msg_data_get_length(struct ast_msg_data *msg)
Get length of the structure.
@ __AST_MSG_DATA_ATTR_LAST
@ AST_MSG_DATA_ATTR_CONTENT_TYPE
@ AST_MSG_DATA_SOURCE_TYPE_UNKNOWN
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * strsep(char **str, const char *delims)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
struct ast_frame ast_null_frame
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#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)
int ast_msg_set_from(struct ast_msg *msg, const char *fmt,...)
Set the 'from' URI of a message.
static void msg_destructor(void *obj)
static void chan_cleanup(struct ast_channel *chan)
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.
static int msg_set_var_full(struct ast_msg *msg, const char *name, const char *value, unsigned int outbound)
int ast_msg_send(struct ast_msg *msg, const char *to, const char *from)
Send a msg directly to an endpoint.
const char * ast_msg_get_var(struct ast_msg *msg, const char *name)
Get the specified variable on the message.
void ast_msg_shutdown(void)
static int msg_q_cb(void *data)
static int msg_data_cmp_fn(void *obj, void *arg, int flags)
static int chan_msg_send_digit_begin(struct ast_channel *chan, char digit)
static const char app_msg_send[]
static ast_rwlock_t msg_techs_lock
Lock for msg_techs vector.
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.
static int chan_msg_write(struct ast_channel *chan, struct ast_frame *fr)
static const struct ast_datastore_info msg_datastore
static struct ast_msg_handler dialplan_msg_handler
void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *iter)
Destroy a message variable iterator.
struct ast_msg * ast_msg_destroy(struct ast_msg *msg)
Destroy an ast_msg.
struct @373 msg_techs
Vector of message technologies.
static int msg_data_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
static struct ast_custom_function msg_function
int ast_msg_set_endpoint(struct ast_msg *msg, const char *fmt,...)
Set the technology's endpoint associated with this message.
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)
static struct msg_data * msg_data_alloc(void)
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.
const char * ast_msg_get_endpoint(const struct ast_msg *msg)
Retrieve the endpoint associated with this message.
static struct ast_frame * chan_msg_read(struct ast_channel *chan)
int ast_msg_set_exten(struct ast_msg *msg, const char *fmt,...)
Set the dialplan extension for this message.
int ast_msg_set_tech(struct ast_msg *msg, const char *fmt,...)
Set the technology associated with this message.
int ast_msg_has_destination(const struct ast_msg *msg)
Determine if a particular message has a destination via some handler.
static int chan_msg_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
static struct ast_channel * create_msg_q_chan(void)
static const struct ast_msg_handler * msg_handler_find_by_tech_name(const char *tech_name)
static int msg_func_write(struct ast_channel *chan, const char *function, char *data, const char *value)
struct ast_msg * ast_msg_alloc(void)
Allocate a message.
static int msg_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
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.
static int chan_msg_send_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
static struct ast_taskprocessor * msg_q_tp
int ast_msg_tech_unregister(const struct ast_msg_tech *tech)
Unregister a message technology.
static void msg_ds_destroy(void *data)
static struct ast_threadstorage msg_q_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 void msg_data_destructor(void *obj)
const char * ast_msg_get_to(const struct ast_msg *msg)
Retrieve the destination of this message.
static void message_shutdown(void)
const char * ast_msg_get_tech(const struct ast_msg *msg)
Retrieve the technology associated with this message.
int ast_msg_tech_register(const struct ast_msg_tech *tech)
Register a message technology.
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_set_context(struct ast_msg *msg, const char *fmt,...)
Set the dialplan context for this message.
static int msg_send_exec(struct ast_channel *chan, const char *data)
static struct msg_data * msg_data_find(struct ao2_container *vars, const char *name)
int ast_msg_set_body(struct ast_msg *msg, const char *fmt,...)
Set the 'body' text of a message (in UTF-8)
static const struct ast_msg_tech * msg_find_by_tech_name(const char *tech_name)
static int msg_data_func_write(struct ast_channel *chan, const char *function, char *data, const char *value)
static void msg_route(struct ast_channel *chan, struct ast_msg *msg)
static ast_rwlock_t msg_handlers_lock
Lock for msg_handlers vector.
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.
struct @374 msg_handlers
Vector of received message handlers.
int ast_msg_set_to(struct ast_msg *msg, const char *fmt,...)
Set the 'to' URI of a message.
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter)
Unref a message var from inside an iterator loop.
static int action_messagesend(struct mansession *s, const struct message *m)
struct ast_msg_var_iterator * ast_msg_var_iterator_init(const struct ast_msg *msg)
Create a new message variable iterator.
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.
int ast_msg_queue(struct ast_msg *msg)
Queue a message for routing through the dialplan.
static int dialplan_handle_msg_cb(struct ast_msg *msg)
static int dialplan_has_destination_cb(const struct ast_msg *msg)
static void destroy_msg_q_chan(void *data)
static struct ast_custom_function msg_data_function
struct ast_msg * ast_msg_ref(struct ast_msg *msg)
Bump a msg's ref count.
static struct ast_datastore * msg_datastore_find_or_create(struct ast_channel *chan)
static struct ast_channel_tech msg_chan_tech_hack
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define EVENT_FLAG_MESSAGE
Out-of-call text message support.
Asterisk module definitions.
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.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_opt_hide_messaging_ami_events
Core PBX routines and definitions.
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
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.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
static const struct ast_msg_tech msg_tech
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_build_va(x, field, fmt, args)
Set a field to a complex (built) value.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
String manipulation functions.
#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_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure to describe a channel "technology", ie a channel driver See for examples:
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
Data structure associated with a single frame of data.
union ast_frame::@226 data
enum ast_frame_type frametype
enum ast_msg_data_attribute_type type
Structure used to transport a message through the frame core.
enum ast_msg_data_source_type source
int attribute_value_offsets[__AST_MSG_DATA_ATTR_LAST]
An external processor of received messages.
const char * name
Name of the message handler.
int(*const msg_send)(const struct ast_msg *msg, const char *to, const char *from)
Send a message.
const char *const name
Name of this message technology.
struct msg_data * current_used
struct ao2_container * vars
const ast_string_field tech
const ast_string_field context
const ast_string_field from
const ast_string_field endpoint
const ast_string_field to
const ast_string_field exten
const ast_string_field body
Options for ast_pbx_run()
unsigned int no_hangup_chan
Structure for rwlock and tracking information.
A ast_taskprocessor structure is a singleton by name.
Structure for variables, used for configurations and for channel variables.
In case you didn't read that giant block of text above the mansession_session struct,...
const ast_string_field value
const ast_string_field name
An API for managing task processing threads that can be shared across modules.
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.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
@ TPS_REF_DEFAULT
return a reference to a taskprocessor, create one if it does not exist
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 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)
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
int ast_base64decode(unsigned char *dst, const char *src, int max)
Decode data from base64.
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.