78 typedef 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)
213 #define AST_MAX_WATCHERS 256 216 #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]) 219 #define IS_CALLER(chan, owner) (chan == owner ? 1 : 0) 250 const char *tech,
const char *device,
const struct ast_assigned_ids *assignedids)
287 if (!dial || !tech || !device)
291 if (!(channel =
ast_calloc(1,
sizeof(*channel))))
304 if (!dial || !chan) {
312 channel->
owner = chan;
316 device = strchr(tech,
'/');
323 dash = strrchr(device,
'-');
350 if (max_forwards <= 0) {
356 if (!channel->
owner) {
359 }
else if (requester_cap) {
360 cap_request = requester_cap;
364 cap_request = cap_all_audio;
461 if (forwarder_chan) {
505 char *
tech =
"Local", *device =
tmp, *stuff;
516 if ((stuff = strchr(tmp,
'/'))) {
521 const char *forward_context;
526 snprintf(destination,
sizeof(destination),
"%s@%s", tmp,
S_OR(forward_context,
ast_channel_context(original)));
565 if (channel->
owner == owner)
741 }
else if ((lowest_timeout == -1) || (lowest_timeout > channel->
timeout)) {
742 lowest_timeout = channel->
timeout;
747 if (lowest_timeout >= 0)
748 new_timeout = lowest_timeout - diff;
755 switch(hangup_cause) {
762 return "CHANUNAVAIL";
776 struct timeval start;
791 ast_channel_musicclass_set(chan, original_moh);
802 int pos = 0, count = 0;
813 if (channel->
owner) {
814 cs[pos++] = channel->
owner;
838 if (!timeout || !who) {
1049 pthread_kill(thread, SIGURG);
1057 pthread_join(thread,
NULL);
1106 if (option_types[i].disable)
1131 if (option_types[i].disable)
1158 if (option_types[option].enable)
1161 dial->
options[option] = (
void*)1;
1173 if (channel->
num == num)
1179 if (channel->
num == num)
1210 if (option_types[option].enable)
1211 channel->
options[option] = option_types[option].
enable(data);
1213 channel->
options[option] = (
void*)1;
1231 if (option_types[option].disable)
1258 if (!channel->
options[option])
1262 if (option_types[option].disable)
1279 return channel->
cause;
1290 return channel->
owner;
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
struct ast_party_caller * ast_channel_caller(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...
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.
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
int ast_dial_append_channel(struct ast_dial *dial, struct ast_channel *chan)
Append a channel using an actual channel object.
int ast_max_forwards_get(struct ast_channel *chan)
Get the current max forwards for a particular channel.
int ast_dial_reason(struct ast_dial *dial, int num)
Get the reason an outgoing channel has failed.
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int frame)
Run a connected line interception macro and update a channel's connected line information.
int(* ast_dial_option_cb_disable)(void *data)
Typedef for dial option disable.
unsigned int is_running_app
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
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_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Main dialing structure. Contains global options, channels being dialed, and more! ...
void ast_dial_hangup(struct ast_dial *dial)
Hangup channels.
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.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
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.
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_appl_set(struct ast_channel *chan, const char *value)
#define AST_CAUSE_UNALLOCATED
enum ast_dial_result state
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
struct ast_dial * ast_dial_create(void)
New dialing structure.
struct ast_channel * ast_dial_get_channel(struct ast_dial *dial, int num)
Get the dialing channel, if prerun has been executed.
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option)
Disables an option per channel.
const char * ast_hangup_cause_to_dial_status(int hangup_cause)
Convert a hangup cause to a publishable dial status.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Structure to pass both assignedid values to channel drivers.
void ast_dial_set_user_data(struct ast_dial *dial, void *user_data)
Set user data on a dial structure.
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int begin_dial(struct ast_dial *dial, struct ast_channel *chan, int async)
Helper function that does the beginning dialing per dial structure.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define FIND_RELATIVE_OPTION(dial, dial_channel, ast_dial_option)
Macro for finding the option structure to use on a dialed channel.
#define ast_mutex_lock(a)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
#define ast_strdup(str)
A wrapper for strdup()
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
const char * ast_channel_call_forward(const struct ast_channel *chan)
#define AST_MAX_WATCHERS
Maximum number of channels we can watch at a time.
#define ast_verb(level,...)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_frame_subclass subclass
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
struct ast_dial_channel::@382 list
#define ast_strlen_zero(foo)
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.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
const struct ast_channel_tech * tech
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
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.
#define ast_debug(level,...)
Log a DEBUG message.
void * options[AST_DIAL_OPTION_MAX]
ast_dial_result
List of return codes for dial run API calls.
General Asterisk PBX channel definitions.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
#define AST_PTHREADT_NULL
#define AST_CAUSE_ANSWERED_ELSEWHERE
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)
#define AST_MAX_EXTENSION
#define AST_CAUSE_NORMAL_CLEARING
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.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
#define ast_strdupa(s)
duplicate a string in memory from the stack
A set of macros to manage forward-linked lists.
#define AST_CAUSE_NO_ANSWER
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
int ast_pre_call(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel before a call is placed.
ast_dial_option
List of options that are applicable either globally or per dialed channel.
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().
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
const char * ast_channel_exten(const struct ast_channel *chan)
Core PBX routines and definitions.
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
static void * music_enable(void *data)
void * options[AST_DIAL_OPTION_MAX]
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
struct ast_channel * owner
ast_dial_option_cb_enable enable
void * ast_dial_get_user_data(struct ast_dial *dial)
Return the user data on a dial structure.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
static int answer_exec_disable(void *data)
Disable function for 'ANSWER_EXEC' option.
static int predial_disable(void *data)
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...
Channel datastore data for max forwards.
static int music_disable(void *data)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
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...
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
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.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
static void * async_dial(void *data)
Dial async thread function.
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
#define ast_channel_unlock(chan)
struct ast_dial::@381 channels
#define AST_CAUSE_UNREGISTERED
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_pthread_create(a, b, c, d)
static void * answer_exec_enable(void *data)
Enable function for 'ANSWER_EXEC' option.
static const struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
static void * predial_enable(void *data)
Structure for 'ANSWER_EXEC' option.
static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_channel *chan)
Helper function that basically keeps tabs on dialing attempts.
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
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...
enum ast_dial_result ast_dial_join(struct ast_dial *dial)
Cancel async thread.
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.
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
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.
int transit_network_select
Transit Network Select.
ast_dial_state_callback state_callback
#define AST_CAUSE_NO_ROUTE_DESTINATION
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.
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
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.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
ast_app: A registered application
const char * ast_channel_name(const struct ast_channel *chan)
#define AST_CAUSE_USER_BUSY
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
#define AST_PTHREADT_STOP
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.
Data structure associated with a single frame of data.
Internal Asterisk hangup causes.
const char * ast_channel_language(const struct ast_channel *chan)
int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option)
Disables an option globally.
ast_dial_option_cb_disable disable
int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
Enables an option per channel.
const char * ast_channel_context(const struct ast_channel *chan)
union ast_frame::@263 data
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
#define ast_mutex_init(pmutex)
void(* ast_dial_state_callback)(struct ast_dial *)
#define ast_mutex_destroy(a)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
#define IS_CALLER(chan, owner)
Macro that determines whether a channel is the caller or not.
void *(* ast_dial_option_cb_enable)(void *data)
Typedef for dial option enable.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define AST_CAUSE_CONGESTION
void ast_channel_data_set(struct ast_channel *chan, const char *value)
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.
Structure for mutex and tracking information.
static int handle_timeout_trip(struct ast_dial *dial, struct timeval start)
Helper function to handle when a timeout occurs on dialing attempt.
const char * ast_channel_musicclass(const struct ast_channel *chan)
int ast_channel_redirecting_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame)
Run a redirecting interception macro and update a channel's redirecting information.
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
#define ast_mutex_unlock(a)