67 unsigned int is_running_app:1;
95 if (!(answer_exec =
ast_calloc(1,
sizeof(*answer_exec))))
99 if ((
args = strchr(app,
','))) {
120 if (answer_exec->
args)
161 dial_channel->
owner = NULL;
189 #define AST_MAX_WATCHERS 256
192 #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])
195 #define IS_CALLER(chan, owner) (chan == owner ? 1 : 0)
231 struct ast_dial_channel *channel = NULL;
234 if (!dial || !tech || !device)
238 if (!(channel =
ast_calloc(1,
sizeof(*channel))))
271 channel->
owner->
data =
"(Outgoing Line)";
299 channel->
owner = NULL;
304 ast_verb(3,
"Called %s\n", numsubst);
313 struct ast_dial_channel *channel = NULL;
332 char *tech =
"Local", *device = tmp, *stuff;
337 channel->
owner = NULL;
342 if ((stuff = strchr(tmp,
'/'))) {
369 struct ast_dial_channel *channel = NULL;
373 if (channel->
owner == owner)
405 channel->
owner = NULL;
410 channel->
owner = NULL;
443 ast_verb(3,
"%s redirecting info has changed, passing it to %s\n", channel->
owner->
name, chan->
name);
495 channel->
owner = NULL;
500 channel->
owner = NULL;
524 struct ast_dial_channel *channel = NULL;
537 channel->
owner = NULL;
538 }
else if ((lowest_timeout == -1) || (lowest_timeout > channel->
timeout)) {
539 lowest_timeout = channel->
timeout;
544 if (lowest_timeout >= 0)
545 new_timeout = lowest_timeout - diff;
555 struct ast_dial_channel *channel = NULL;
557 struct timeval start;
583 int pos = 0, count = 0;
594 if (channel->
owner) {
595 cs[pos++] = channel->
owner;
619 if (!timeout || !who) {
644 channel->
owner = NULL;
668 channel->
owner = NULL;
691 channel->
owner = NULL;
719 if (!dial || (!chan && !async)) {
822 pthread_kill(thread, SIGURG);
830 pthread_join(thread, NULL);
844 struct ast_dial_channel *channel = NULL;
851 if (channel->
owner) {
853 channel->
owner = NULL;
869 struct ast_dial_channel *channel = NULL;
881 if (option_types[i].disable)
886 if (channel->
owner) {
888 channel->
owner = NULL;
903 if (option_types[i].disable)
930 if (option_types[option].enable)
933 dial->
options[option] = (
void*)1;
945 if (channel->
num == num)
951 if (channel->
num == num)
968 struct ast_dial_channel *channel = NULL;
982 if (option_types[option].enable)
983 channel->
options[option] = option_types[option].
enable(data);
985 channel->
options[option] = (
void*)1;
1003 if (option_types[option].disable)
1020 struct ast_dial_channel *channel = NULL;
1030 if (!channel->
options[option])
1034 if (option_types[option].disable)
1038 channel->
options[option] = NULL;
1071 struct ast_dial_channel *channel = NULL;
static char musicclass[MAX_MUSICCLASS]
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...
union ast_frame_subclass subclass
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
static char accountcode[AST_MAX_ACCOUNT_CODE]
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_destroy(struct ast_dial *dial)
Destroys a dialing structure.
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
struct ast_party_connected_line connected
Channel Connected Line ID information.
static int begin_dial(struct ast_dial *dial, struct ast_channel *chan)
Helper function that does the beginning dialing per dial structure.
#define AST_LIST_LOCK(head)
Locks a list.
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
unsigned int is_running_app
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
struct ast_party_caller caller
Channel Caller ID information.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
static void handle_frame_ownerless(struct ast_dial *dial, struct ast_dial_channel *channel, struct ast_frame *fr)
Helper function that handles control frames WITHOUT owner.
Main dialing structure. Contains global options, channels being dialed, and more! ...
struct ast_dial::@252 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.
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
void ast_dial_hangup(struct ast_dial *dial)
Hangup channels.
enum ast_dial_result state
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device)
Append a channel.
void ast_verbose(const char *fmt,...)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_channel *chan)
Helper function that does the beginning dialing per-appended channel.
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#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)
unsigned short transfercapability
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame)
Run a connected line interception macro and update a channel's connected line information.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
enum ast_channel_adsicpe adsicpe
#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.
#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. This can be used to handle reference co...
int ast_dial_option_enable(struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
Enables an option per channel.
void *(* ast_dial_option_cb_enable)(void *data)
Typedef for dial option enable.
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
#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.
enum ast_dial_result ast_dial_join(struct ast_dial *dial)
Cancel async thread.
#define AST_PTHREADT_NULL
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define AST_MAX_EXTENSION
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
int(* ast_dial_option_cb_disable)(void *data)
Typedef for dial option disable.
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
A set of macros to manage forward-linked lists.
static char language[MAX_LANGUAGE]
int ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option)
Disables an option globally.
ast_dial_option
List of options that are applicable either globally or per dialed channel.
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
Core PBX routines and definitions.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
struct ast_party_dialed dialed
Dialed/Called information.
static void * music_enable(void *data)
#define ast_strdupa(s)
duplicate a string in memory from the stack
void * options[AST_DIAL_OPTION_MAX]
struct ast_channel * owner
ast_dial_option_cb_enable enable
#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.
const ast_string_field call_forward
static int music_disable(void *data)
const ast_string_field name
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.
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
#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.
#define ast_channel_unlock(chan)
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_pthread_create(a, b, c, d)
struct ast_dial * ast_dial_create(void)
New dialing structure.
static void * answer_exec_enable(void *data)
Enable function for 'ANSWER_EXEC' option.
#define AST_FORMAT_AUDIO_MASK
struct ast_dial_channel::@253 list
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
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.
static struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
void(* ast_dial_state_callback)(struct ast_dial *)
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 control frames WITH owner.
void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
int transit_network_select
Transit Network Select.
ast_dial_state_callback state_callback
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.
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.
ast_app: A registered application
#define AST_PTHREADT_STOP
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
const ast_string_field musicclass
const ast_string_field accountcode
Data structure associated with a single frame of data.
ast_dial_option_cb_disable disable
struct timeval whentohangup
#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)
int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option)
Disables an option per channel.
#define ast_mutex_destroy(a)
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.
#define IS_CALLER(chan, owner)
Macro that determines whether a channel is the caller or not.
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
union ast_frame::@172 data
const ast_string_field language
char exten[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.
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.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
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)
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.