78typedef void *(*ast_dial_option_cb_enable)(
void *
data);
100 if (!(answer_exec =
ast_calloc(1,
sizeof(*answer_exec))))
104 if ((
args = strchr(
app,
','))) {
125 if (answer_exec->
args)
211#define AST_MAX_WATCHERS 256
214#define FIND_RELATIVE_OPTION(dial, dial_channel, ast_dial_option) (dial_channel->options[ast_dial_option] ? dial_channel->options[ast_dial_option] : dial->options[ast_dial_option])
217#define IS_CALLER(chan, owner) (chan == owner ? 1 : 0)
248 const char *tech,
const char *device,
const struct ast_assigned_ids *assignedids)
289 if (!(channel =
ast_calloc(1,
sizeof(*channel))))
302 if (!dial || !chan) {
310 channel->
owner = chan;
321 dash = strrchr(
device,
'-');
354 if (!channel->
owner) {
357 }
else if (requester_cap) {
358 cap_request = requester_cap;
362 cap_request = cap_all_audio;
459 if (forwarder_chan) {
503 char *
tech =
"Local", *device =
tmp, *stuff;
514 if ((stuff = strchr(
tmp,
'/'))) {
519 const char *forward_context;
737 }
else if ((lowest_timeout == -1) || (lowest_timeout > channel->
timeout)) {
738 lowest_timeout = channel->
timeout;
743 if (lowest_timeout >= 0)
744 new_timeout = lowest_timeout - diff;
751 switch(hangup_cause) {
758 return "CHANUNAVAIL";
772 struct timeval start;
787 ast_channel_musicclass_set(chan, original_moh);
798 int pos = 0, count = 0;
809 if (channel->
owner) {
810 cs[pos++] = channel->
owner;
834 if (!timeout || !who) {
1047 pthread_kill(
thread, SIGURG);
1051 if (channel->
owner) {
1155 dial->
options[option] = (
void*)1;
1200 channel->
options[option] = (
void*)1;
1234 if (!channel->
options[option])
1255 return channel->
cause;
1266 return channel->
owner;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Internal Asterisk hangup causes.
#define AST_CAUSE_CONGESTION
#define AST_CAUSE_UNALLOCATED
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
#define AST_CAUSE_ANSWERED_ELSEWHERE
#define AST_CAUSE_NO_ROUTE_DESTINATION
#define AST_CAUSE_UNREGISTERED
#define AST_CAUSE_NO_ANSWER
#define AST_CAUSE_NORMAL_CLEARING
#define AST_CAUSE_USER_BUSY
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame)
Run a connected line interception subroutine and update a channel's connected line information.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
@ AST_CHANNEL_REQUESTOR_REPLACEMENT
const char * ast_channel_musicclass(const struct ast_channel *chan)
struct ast_channel * ast_waitfor_n(struct ast_channel **chan, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
void ast_channel_data_set(struct ast_channel *chan, const char *value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
const char * ast_channel_context(const struct ast_channel *chan)
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
int ast_channel_hangupcause(const struct ast_channel *chan)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
@ AST_SOFTHANGUP_EXPLICIT
const char * ast_channel_language(const struct ast_channel *chan)
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
const char * ast_channel_call_forward(const struct ast_channel *chan)
int ast_pre_call(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel before a call is placed.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
#define FIND_RELATIVE_OPTION(dial, dial_channel, ast_dial_option)
Macro for finding the option structure to use on a dialed channel.
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
static int answer_exec_disable(void *data)
Disable function for 'ANSWER_EXEC' option.
static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channel *chan, struct ast_format_cap *cap, const char *predial_string)
Helper function that requests all channels.
static int predial_disable(void *data)
static int dial_append_common(struct ast_dial *dial, struct ast_dial_channel *channel, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
static void * async_dial(void *data)
Dial async thread function.
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option)
Disables an option globally.
struct ast_dial * ast_dial_create(void)
New dialing structure.
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
void ast_dial_set_user_data(struct ast_dial *dial, void *user_data)
Set user data on a dial structure.
int ast_dial_prerun(struct ast_dial *dial, struct ast_channel *chan, struct ast_format_cap *cap)
Request all appended channels, but do not dial.
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
void ast_dial_hangup(struct ast_dial *dial)
Hangup channels.
static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_channel *chan)
Helper function that basically keeps tabs on dialing attempts.
int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option)
Disables an option per channel.
#define IS_CALLER(chan, owner)
Macro that determines whether a channel is the caller or not.
const char * ast_hangup_cause_to_dial_status(int hangup_cause)
Convert a hangup cause to a publishable dial status.
#define AST_MAX_WATCHERS
Maximum number of channels we can watch at a time.
static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *channel, struct ast_channel *chan)
Helper function to handle channels that have been call forwarded.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
Enables an option per channel.
enum ast_dial_result ast_dial_join(struct ast_dial *dial)
Cancel async thread.
void *(* ast_dial_option_cb_enable)(void *data)
Typedef for dial option enable.
static void * answer_exec_enable(void *data)
Enable function for 'ANSWER_EXEC' option.
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_channel *chan, int async, const char *predial_string, struct ast_channel *forwarder_chan)
Helper function that does the beginning dialing per-appended channel.
static struct ast_dial_channel * find_relative_dial_channel(struct ast_dial *dial, struct ast_channel *owner)
Helper function that finds the dialed channel based on owner.
void * ast_dial_get_user_data(struct ast_dial *dial)
Return the user data on a dial structure.
int ast_dial_reason(struct ast_dial *dial, int num)
Get the reason an outgoing channel has failed.
static void answer_exec_run(struct ast_dial *dial, struct ast_dial_channel *dial_channel, char *app, char *args)
Application execution function for 'ANSWER_EXEC' option.
static int handle_timeout_trip(struct ast_dial *dial, struct timeval start)
Helper function to handle when a timeout occurs on dialing attempt.
void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout)
Set the maximum time (per channel) allowed for trying to ring the phone.
static struct ast_dial_channel * find_dial_channel(struct ast_dial *dial, int num)
Helper function for finding a channel in a dial structure based on number.
static int begin_dial(struct ast_dial *dial, struct ast_channel *chan, int async)
Helper function that does the beginning dialing per dial structure.
struct ast_channel * ast_dial_get_channel(struct ast_dial *dial, int num)
Get the dialing channel, if prerun has been executed.
static void * predial_enable(void *data)
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
static void * music_enable(void *data)
static int music_disable(void *data)
int(* ast_dial_option_cb_disable)(void *data)
Typedef for dial option disable.
int ast_dial_append_channel(struct ast_dial *dial, struct ast_channel *chan)
Append a channel using an actual channel object.
static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel, struct ast_frame *fr, struct ast_channel *chan)
Helper function that handles frames.
static const struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
ast_dial_result
List of return codes for dial run API calls.
@ AST_DIAL_RESULT_INVALID
@ AST_DIAL_RESULT_ANSWERED
@ AST_DIAL_RESULT_TIMEOUT
@ AST_DIAL_RESULT_PROGRESS
@ AST_DIAL_RESULT_RINGING
@ AST_DIAL_RESULT_PROCEEDING
@ AST_DIAL_RESULT_UNANSWERED
void(* ast_dial_state_callback)(struct ast_dial *)
ast_dial_option
List of options that are applicable either globally or per dialed channel.
@ AST_DIAL_OPTION_DIAL_REPLACES_SELF
@ AST_DIAL_OPTION_ANSWER_EXEC
@ AST_DIAL_OPTION_RINGING
@ AST_DIAL_OPTION_PREDIAL
@ AST_DIAL_OPTION_DISABLE_CALL_FORWARDING
@ AST_DIAL_OPTION_SELF_DESTROY
void ast_channel_publish_dial(struct ast_channel *caller, struct ast_channel *peer, const char *dialstring, const char *dialstatus)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
void ast_channel_publish_dial_forward(struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_PVT_CAUSE_CODE
#define ast_debug(level,...)
Log a DEBUG message.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
#define ast_verb(level,...)
A set of macros to manage forward-linked lists.
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Asterisk locking-related definitions:
#define AST_PTHREADT_NULL
#define ast_mutex_init(pmutex)
#define AST_PTHREADT_STOP
#define ast_mutex_unlock(a)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
int ast_max_forwards_get(struct ast_channel *chan)
Get the current max forwards for a particular channel.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Core PBX routines and definitions.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
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_pbx_exec_application(struct ast_channel *chan, const char *app_name, const char *app_args)
Execute an application.
#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.
Structure for 'ANSWER_EXEC' option.
Structure to pass both assignedid values to channel drivers.
Main Channel structure associated with a channel.
const struct ast_channel_tech * tech
Dialing channel structure. Contains per-channel dialing options, asterisk channel,...
unsigned int is_running_app
struct ast_channel * owner
void * options[AST_DIAL_OPTION_MAX]
struct ast_dial_channel::@344 list
Main dialing structure. Contains global options, channels being dialed, and more!
enum ast_dial_result state
struct ast_dial::@343 channels
ast_dial_state_callback state_callback
void * options[AST_DIAL_OPTION_MAX]
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
Structure for mutex and tracking information.
enum ast_dial_option option
ast_dial_option_cb_enable enable
ast_dial_option_cb_disable disable
int transit_network_select
Transit Network Select.
Channel datastore data for max forwards.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_pthread_create(a, b, c, d)