545    char *connected_name;
 
  562        "%sChannelState: %u\r\n" 
  563        "%sChannelStateDesc: %s\r\n" 
  564        "%sCallerIDNum: %s\r\n" 
  565        "%sCallerIDName: %s\r\n" 
  566        "%sConnectedLineNum: %s\r\n" 
  567        "%sConnectedLineName: %s\r\n" 
  569        "%sAccountCode: %s\r\n" 
  574        "%sLinkedid: %s\r\n",
 
 
  633    int is_hungup, was_hungup;
 
  648    if (!was_hungup && is_hungup) {
 
  668    if (old_snapshot->
state != new_snapshot->
state) {
 
 
  700        "Application: %s\r\n" 
 
  730        "CID-CallingPres: %d (%s)\r\n",
 
 
  798        if (!channel_event_string) {
 
  799            channel_event_string =
 
  801            if (!channel_event_string) {
 
 
  817    if (!channel_event_string) {
 
 
  832    struct ast_str *channel_event_string;
 
  849    if (!channel_event_string) {
 
  864            "TechCause: %jd\r\n",
 
 
  889    const char *spyee_info = 
"";
 
  899    if (!spyer_channel_string) {
 
  906        if (spyee_channel_string) {
 
 
  938    if (!spyer_channel_string) {
 
  942    if (!spyee_channel_string) {
 
 
  964    if (!channel_event_string) {
 
 
 1017    if (!channel_event_string) {
 
 1054        "DurationMs: %ld\r\n" 
 1055        "Direction: %s\r\n",
 
 
 1064    struct ast_str *channel_event_string;
 
 1067    if (!channel_event_string) {
 
 
 1097    struct ast_str *channel_event_string;
 
 1100    if (!channel_event_string) {
 
 
 1137    if (!channel_event_string) {
 
 1141    if (!strcmp(action, 
"run")) {
 
 1142        event = 
"HangupHandlerRun";
 
 1143    } 
else if (!strcmp(action, 
"pop")) {
 
 1144        event = 
"HangupHandlerPop";
 
 1145    } 
else if (!strcmp(action, 
"push")) {
 
 1146        event = 
"HangupHandlerPush";
 
 
 1176    if (!event_buffer) {
 
 1181    if (!channel_event_string) {
 
 1185    if (!strcmp(
type, 
"status")) {
 
 1186        event = 
"FAXStatus";
 
 1187    } 
else if (!strcmp(
type, 
"receive")) {
 
 1188        event = 
"ReceiveFAX";
 
 1189    } 
else if (!strcmp(
type, 
"send")) {
 
 1201    if (local_station_id) {
 
 1204    if (remote_station_id) {
 
 1210    if (fax_resolution) {
 
 1218        for (i = 0; i < array_len; i++) {
 
 
 1238    if (!channel_event_string) {
 
 
 1283    if (!event_buffer) {
 
 1288    if (!channel_event_string) {
 
 
 1307    return (strcmp(dialstatus, 
"RINGING") &&
 
 1308            strcmp(dialstatus, 
"PROCEEDING") &&
 
 1309            strcmp(dialstatus, 
"PROGRESS"));
 
 
 1319    const char *dialstatus;
 
 1320    const char *dialstring;
 
 1321    const char *forward;
 
 1333    if (!peer_event_string) {
 
 1348                "DialString: %s\r\n",
 
 1351                S_OR(dialstring, 
"unknown"));
 
 1359                "DialStatus: %s\r\n",
 
 1362                forwarded ? 
"Forward: " : 
"", 
S_OR(forward, 
""), forwarded ? 
"\r\n" : 
"",
 
 1363                S_OR(dialstatus, 
"unknown"));
 
 
 1373    struct ast_str *channel_event_string;
 
 1375    if (!musicclass_string) {
 
 1380    if (!channel_event_string) {
 
 1386        const char *musicclass;
 
 1391            ast_str_set(&musicclass_string, 0, 
"MusicClass: %s\r\n", musicclass);
 
 
 1409    struct ast_str *channel_event_string;
 
 1412    if (!channel_event_string) {
 
 
 1441    if (!message_router) {
 
 1445    if (!channel_topic) {
 
 
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.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
const char * ast_describe_caller_presentation(int data)
Convert caller ID pres value to explanatory string.
General Asterisk PBX channel definitions.
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
struct stasis_message_router * ast_manager_get_message_router(void)
Get the stasis_message_router for AMI.
struct stasis_topic * ast_manager_get_topic(void)
Get the Stasis Message Bus API topic for AMI.
static struct stasis_topic * manager_topic
A stasis_topic that all topics AMI cares about will be forwarded to.
struct stasis_message_type * ast_channel_mixmonitor_mute_type(void)
Message type for muting or unmuting mixmonitor on a channel.
struct stasis_topic * ast_channel_topic_all(void)
A topic which publishes the events for all channels.
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
struct ast_channel_snapshot * ast_multi_channel_blob_get_channel(struct ast_multi_channel_blob *obj, const char *role)
Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob.
struct stasis_message_type * ast_channel_chanspy_start_type(void)
Message type for when a channel starts spying on another channel.
struct stasis_message_type * ast_channel_chanspy_stop_type(void)
Message type for when a channel stops spying on another channel.
struct stasis_message_type * ast_channel_dtmf_begin_type(void)
Message type for when DTMF begins on a channel.
struct stasis_message_type * ast_channel_mixmonitor_stop_type(void)
Message type for stopping mixmonitor on a channel.
struct stasis_message_type * ast_channel_hangup_handler_type(void)
Message type for hangup handler related actions.
struct stasis_message_type * ast_channel_dial_type(void)
Message type for when a channel dials another channel.
struct stasis_message_type * ast_channel_moh_stop_type(void)
Message type for stopping music on hold on a channel.
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.
struct stasis_message_type * ast_channel_flash_type(void)
Message type for when a hook flash occurs on a channel.
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
struct stasis_message_type * ast_channel_fax_type(void)
Message type for a fax operation.
struct stasis_message_type * ast_channel_dtmf_end_type(void)
Message type for when DTMF ends on a channel.
struct stasis_message_type * ast_channel_wink_type(void)
Message type for when a wink occurs on a channel.
struct ast_json * ast_multi_channel_blob_get_json(struct ast_multi_channel_blob *obj)
Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj.
struct stasis_message_type * ast_channel_moh_start_type(void)
Message type for starting music on hold on a channel.
struct stasis_message_type * ast_channel_mixmonitor_start_type(void)
Message type for starting mixmonitor on a channel.
static char prefix[MAX_PREFIX]
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
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.
#define EVENT_FLAG_DIALPLAN
static void channel_flash_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_hangup_handler_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
static void channel_chanspy_stop_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_snapshot_update(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_mixmonitor_start_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_dtmf_end_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_manager_event_blob *(* channel_snapshot_monitor)(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
Typedef for callbacks that get called on channel snapshot updates.
static void channel_mixmonitor_stop_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct ast_manager_event_blob * channel_state_change(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
Handle channel state changes.
static void channel_dial_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Callback processing messages for channel dialing.
static int dial_status_end(const char *dialstatus)
static void channel_hold_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_moh_start_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_wink_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void publish_basic_channel_event(const char *event, int class, struct ast_channel_snapshot *snapshot)
static void channel_fax_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_chanspy_start_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_hangup_request_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void channel_dtmf_begin_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct ast_manager_event_blob * channel_new_callerid(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
static struct ast_manager_event_blob * channel_newexten(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
int manager_channels_init(void)
Initialize support for AMI channel events.
static struct ast_manager_event_blob * channel_new_connected_line(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
static struct ast_manager_event_blob * channel_new_accountcode(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
channel_snapshot_monitor channel_monitors[]
static void channel_moh_stop_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
static void channel_mixmonitor_mute_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void manager_channels_shutdown(void)
static struct stasis_forward * topic_forwarder
The Stasis Message Bus API subscription returned by the forwarding of the channel topic to the manage...
static void channel_unhold_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Core PBX routines and definitions.
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.
struct stasis_forward * stasis_forward_cancel(struct stasis_forward *forward)
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_forward * stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
Create a subscription which forwards all messages from one topic to another.
int ast_channel_snapshot_connected_line_equal(const struct ast_channel_snapshot *old_snapshot, const struct ast_channel_snapshot *new_snapshot)
Compares the connected line info of two snapshots.
int ast_channel_snapshot_caller_id_equal(const struct ast_channel_snapshot *old_snapshot, const struct ast_channel_snapshot *new_snapshot)
Compares the callerid info of two snapshots.
int ast_channel_snapshot_cep_equal(const struct ast_channel_snapshot *old_snapshot, const struct ast_channel_snapshot *new_snapshot)
Compares the context, exten and priority of two snapshots.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#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)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
char * ast_escape_c_alloc(const char *s)
Escape standard 'C' sequences in the given string.
Blob of data associated with a channel.
struct ast_channel_snapshot * snapshot
const ast_string_field language
const ast_string_field tenantid
const ast_string_field accountcode
const ast_string_field uniqueid
const ast_string_field name
const ast_string_field number
const ast_string_field name
const ast_string_field data
const ast_string_field context
const ast_string_field exten
const ast_string_field appl
Structure representing a change of snapshot of channel state.
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_connected * connected
struct varshead * manager_vars
struct ast_channel_snapshot_dialplan * dialplan
struct ast_channel_snapshot_peer * peer
struct ast_channel_snapshot_base * base
enum ast_channel_state state
struct ast_channel_snapshot_caller * caller
struct ast_channel_snapshot_hangup * hangup
Abstract JSON element (object, array, string, int, ...).
Struct containing info for an AMI event to send out.
A multi channel blob data structure for multi_channel_blob stasis messages.
Support for dynamic strings.
struct ast_var_t::@224 entries
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_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.