Wed Jan 8 2020 09:50:11

Asterisk developer's documentation


dial.c File Reference

Dialing API. More...

#include "asterisk.h"
#include <sys/time.h>
#include <signal.h>
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/dial.h"
#include "asterisk/pbx.h"
#include "asterisk/musiconhold.h"
#include "asterisk/app.h"

Go to the source code of this file.

Data Structures

struct  answer_exec_struct
 Structure for 'ANSWER_EXEC' option. More...
 
struct  ast_dial
 Main dialing structure. Contains global options, channels being dialed, and more! More...
 
struct  ast_dial_channel
 Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more! More...
 
struct  ast_option_types
 

Macros

#define AST_MAX_WATCHERS   256
 Maximum number of channels we can watch at a time. More...
 
#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])
 Macro for finding the option structure to use on a dialed channel. More...
 
#define IS_CALLER(chan, owner)   (chan == owner ? 1 : 0)
 Macro that determines whether a channel is the caller or not. More...
 

Typedefs

typedef int(* ast_dial_option_cb_disable )(void *data)
 Typedef for dial option disable. More...
 
typedef void *(* ast_dial_option_cb_enable )(void *data)
 Typedef for dial option enable. More...
 

Functions

static int answer_exec_disable (void *data)
 Disable function for 'ANSWER_EXEC' option. More...
 
static void * answer_exec_enable (void *data)
 Enable function for 'ANSWER_EXEC' option. More...
 
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. More...
 
struct ast_channelast_dial_answered (struct ast_dial *dial)
 Return channel that answered. More...
 
struct ast_channelast_dial_answered_steal (struct ast_dial *dial)
 Steal the channel that answered. More...
 
int ast_dial_append (struct ast_dial *dial, const char *tech, const char *device)
 Append a channel. More...
 
struct ast_dialast_dial_create (void)
 New dialing structure. More...
 
int ast_dial_destroy (struct ast_dial *dial)
 Destroys a dialing structure. More...
 
void ast_dial_hangup (struct ast_dial *dial)
 Hangup channels. More...
 
enum ast_dial_result ast_dial_join (struct ast_dial *dial)
 Cancel async thread. More...
 
int ast_dial_option_disable (struct ast_dial *dial, int num, enum ast_dial_option option)
 Disables an option per channel. More...
 
int ast_dial_option_enable (struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
 Enables an option per channel. More...
 
int ast_dial_option_global_disable (struct ast_dial *dial, enum ast_dial_option option)
 Disables an option globally. More...
 
int ast_dial_option_global_enable (struct ast_dial *dial, enum ast_dial_option option, void *data)
 Enables an option globally. More...
 
enum ast_dial_result ast_dial_run (struct ast_dial *dial, struct ast_channel *chan, int async)
 Execute dialing synchronously or asynchronously. More...
 
void ast_dial_set_global_timeout (struct ast_dial *dial, int timeout)
 Set the maximum time (globally) allowed for trying to ring phones. More...
 
void ast_dial_set_state_callback (struct ast_dial *dial, ast_dial_state_callback callback)
 Set a callback for state changes. More...
 
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. More...
 
enum ast_dial_result ast_dial_state (struct ast_dial *dial)
 Return state of dial. More...
 
static void * async_dial (void *data)
 Dial async thread function. More...
 
static int begin_dial (struct ast_dial *dial, struct ast_channel *chan)
 Helper function that does the beginning dialing per dial structure. More...
 
static int begin_dial_channel (struct ast_dial_channel *channel, struct ast_channel *chan)
 Helper function that does the beginning dialing per-appended channel. More...
 
static struct ast_dial_channelfind_dial_channel (struct ast_dial *dial, int num)
 Helper function for finding a channel in a dial structure based on number. More...
 
static struct ast_dial_channelfind_relative_dial_channel (struct ast_dial *dial, struct ast_channel *owner)
 Helper function that finds the dialed channel based on owner. More...
 
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. More...
 
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. More...
 
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. More...
 
static int handle_timeout_trip (struct ast_dial *dial, struct timeval start)
 Helper function to handle when a timeout occurs on dialing attempt. More...
 
static enum ast_dial_result monitor_dial (struct ast_dial *dial, struct ast_channel *chan)
 Helper function that basically keeps tabs on dialing attempts. More...
 
static int music_disable (void *data)
 
static void * music_enable (void *data)
 
static void set_state (struct ast_dial *dial, enum ast_dial_result state)
 

Variables

static struct ast_option_types option_types []
 Map options to respective handlers (enable/disable). More...
 

Detailed Description

Dialing API.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file dial.c.

Macro Definition Documentation

#define AST_MAX_WATCHERS   256

Maximum number of channels we can watch at a time.

Definition at line 189 of file dial.c.

Referenced by monitor_dial().

#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])

Macro for finding the option structure to use on a dialed channel.

Definition at line 192 of file dial.c.

Referenced by handle_call_forward(), and monitor_dial().

#define IS_CALLER (   chan,
  owner 
)    (chan == owner ? 1 : 0)

Macro that determines whether a channel is the caller or not.

Definition at line 195 of file dial.c.

Referenced by monitor_dial().

Typedef Documentation

typedef int(* ast_dial_option_cb_disable)(void *data)

Typedef for dial option disable.

Definition at line 76 of file dial.c.

typedef void*(* ast_dial_option_cb_enable)(void *data)

Typedef for dial option enable.

Definition at line 73 of file dial.c.

Function Documentation

static int answer_exec_disable ( void *  data)
static

Disable function for 'ANSWER_EXEC' option.

Definition at line 111 of file dial.c.

References answer_exec_struct::args, and ast_free.

112 {
113  struct answer_exec_struct *answer_exec = data;
114 
115  /* Make sure we have a value */
116  if (!answer_exec)
117  return -1;
118 
119  /* If arguments are present, free them too */
120  if (answer_exec->args)
121  ast_free(answer_exec->args);
122 
123  /* This is simple - just free the structure */
124  ast_free(answer_exec);
125 
126  return 0;
127 }
char * args
Definition: dial.c:81
#define ast_free(a)
Definition: astmm.h:97
Structure for &#39;ANSWER_EXEC&#39; option.
Definition: dial.c:79
static void* answer_exec_enable ( void *  data)
static

Enable function for 'ANSWER_EXEC' option.

Definition at line 85 of file dial.c.

References app, answer_exec_struct::app, args, answer_exec_struct::args, ast_calloc, ast_copy_string(), ast_strdup, ast_strdupa, and ast_strlen_zero().

86 {
87  struct answer_exec_struct *answer_exec = NULL;
88  char *app = ast_strdupa((char*)data), *args = NULL;
89 
90  /* Not giving any data to this option is bad, mmmk? */
91  if (ast_strlen_zero(app))
92  return NULL;
93 
94  /* Create new data structure */
95  if (!(answer_exec = ast_calloc(1, sizeof(*answer_exec))))
96  return NULL;
97 
98  /* Parse out application and arguments */
99  if ((args = strchr(app, ','))) {
100  *args++ = '\0';
101  answer_exec->args = ast_strdup(args);
102  }
103 
104  /* Copy application name */
105  ast_copy_string(answer_exec->app, app, sizeof(answer_exec->app));
106 
107  return answer_exec;
108 }
char * args
Definition: dial.c:81
#define ast_strdup(a)
Definition: astmm.h:109
static const char app[]
Definition: app_adsiprog.c:49
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
Structure for &#39;ANSWER_EXEC&#39; option.
Definition: dial.c:79
#define ast_calloc(a, b)
Definition: astmm.h:82
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char app[AST_MAX_APP]
Definition: dial.c:80
static void answer_exec_run ( struct ast_dial dial,
struct ast_dial_channel dial_channel,
char *  app,
char *  args 
)
static

Application execution function for 'ANSWER_EXEC' option.

Definition at line 145 of file dial.c.

References ast_hangup(), ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_STOP, ast_dial::lock, ast_dial_channel::owner, pbx_exec(), pbx_findapp(), and ast_dial::thread.

Referenced by monitor_dial().

146 {
147  struct ast_channel *chan = dial_channel->owner;
148  struct ast_app *ast_app = pbx_findapp(app);
149 
150  /* If the application was not found, return immediately */
151  if (!ast_app)
152  return;
153 
154  /* All is well... execute the application */
155  pbx_exec(chan, ast_app, args);
156 
157  /* If another thread is not taking over hang up the channel */
158  ast_mutex_lock(&dial->lock);
159  if (dial->thread != AST_PTHREADT_STOP) {
160  ast_hangup(chan);
161  dial_channel->owner = NULL;
162  }
163  ast_mutex_unlock(&dial->lock);
164 
165  return;
166 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
Main Channel structure associated with a channel.
Definition: channel.h:742
struct ast_app * pbx_findapp(const char *app)
Look up an application.
Definition: pbx.c:1537
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Definition: pbx.c:1497
#define ast_mutex_lock(a)
Definition: lock.h:155
pthread_t thread
Definition: dial.c:55
static const char app[]
Definition: app_adsiprog.c:49
struct ast_channel * owner
Definition: dial.c:68
static struct @350 args
ast_mutex_t lock
Definition: dial.c:54
ast_app: A registered application
Definition: pbx.c:971
#define AST_PTHREADT_STOP
Definition: lock.h:66
#define ast_mutex_unlock(a)
Definition: lock.h:156
struct ast_channel* ast_dial_answered ( struct ast_dial dial)

Return channel that answered.

Note
Returns the Asterisk channel that answered
Parameters
dialDialing structure

Definition at line 754 of file dial.c.

References AST_DIAL_RESULT_ANSWERED, AST_LIST_FIRST, ast_dial::channels, and ast_dial::state.

Referenced by dial_trunk(), and sla_handle_dial_state_event().

755 {
756  if (!dial)
757  return NULL;
758 
759  return ((dial->state == AST_DIAL_RESULT_ANSWERED) ? AST_LIST_FIRST(&dial->channels)->owner : NULL);
760 }
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
struct ast_dial::@252 channels
enum ast_dial_result state
Definition: dial.c:51
struct ast_channel* ast_dial_answered_steal ( struct ast_dial dial)

Steal the channel that answered.

Note
Returns the Asterisk channel that answered and removes it from the dialing structure
Parameters
dialDialing structure

Definition at line 766 of file dial.c.

References AST_DIAL_RESULT_ANSWERED, AST_LIST_FIRST, ast_dial::channels, and ast_dial::state.

Referenced by do_notify().

767 {
768  struct ast_channel *chan = NULL;
769 
770  if (!dial)
771  return NULL;
772 
773  if (dial->state == AST_DIAL_RESULT_ANSWERED) {
774  chan = AST_LIST_FIRST(&dial->channels)->owner;
775  AST_LIST_FIRST(&dial->channels)->owner = NULL;
776  }
777 
778  return chan;
779 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
struct ast_dial::@252 channels
enum ast_dial_result state
Definition: dial.c:51
int ast_dial_append ( struct ast_dial dial,
const char *  tech,
const char *  device 
)

Append a channel.

Note
Appends a channel to a dialing structure
Returns
Returns channel reference number on success, -1 on failure

Definition at line 229 of file dial.c.

References ast_atomic_fetchadd_int(), ast_calloc, AST_LIST_INSERT_TAIL, ast_strdup, ast_dial::channels, ast_dial_channel::device, ast_dial_channel::list, ast_dial::num, ast_dial_channel::num, ast_dial_channel::tech, and ast_dial_channel::timeout.

Referenced by dial_trunk(), do_notify(), page_exec(), and sla_ring_station().

230 {
231  struct ast_dial_channel *channel = NULL;
232 
233  /* Make sure we have required arguments */
234  if (!dial || !tech || !device)
235  return -1;
236 
237  /* Allocate new memory for dialed channel structure */
238  if (!(channel = ast_calloc(1, sizeof(*channel))))
239  return -1;
240 
241  /* Record technology and device for when we actually dial */
242  channel->tech = ast_strdup(tech);
243  channel->device = ast_strdup(device);
244 
245  /* Grab reference number from dial structure */
246  channel->num = ast_atomic_fetchadd_int(&dial->num, +1);
247 
248  /* No timeout exists... yet */
249  channel->timeout = -1;
250 
251  /* Insert into channels list */
252  AST_LIST_INSERT_TAIL(&dial->channels, channel, list);
253 
254  return channel->num;
255 }
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_dial::@252 channels
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...
Definition: lock.h:603
int num
Definition: dial.c:48
char * tech
Definition: dial.c:63
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:716
struct ast_dial_channel::@253 list
#define ast_calloc(a, b)
Definition: astmm.h:82
char * device
Definition: dial.c:64
int timeout
Definition: dial.c:62
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
struct ast_dial* ast_dial_create ( void  )

New dialing structure.

Note
Create a dialing structure
Returns
Returns a calloc'd ast_dial structure, NULL on failure

Definition at line 201 of file dial.c.

References ast_dial::actual_timeout, ast_calloc, AST_LIST_HEAD_INIT, ast_mutex_init, AST_PTHREADT_NULL, ast_dial::channels, ast_dial::lock, ast_dial::thread, and ast_dial::timeout.

Referenced by dial_trunk(), do_notify(), page_exec(), and sla_ring_station().

202 {
203  struct ast_dial *dial = NULL;
204 
205  /* Allocate new memory for structure */
206  if (!(dial = ast_calloc(1, sizeof(*dial))))
207  return NULL;
208 
209  /* Initialize list of channels */
211 
212  /* Initialize thread to NULL */
213  dial->thread = AST_PTHREADT_NULL;
214 
215  /* No timeout exists... yet */
216  dial->timeout = -1;
217  dial->actual_timeout = -1;
218 
219  /* Can't forget about the lock */
220  ast_mutex_init(&dial->lock);
221 
222  return dial;
223 }
Main dialing structure. Contains global options, channels being dialed, and more! ...
Definition: dial.c:47
struct ast_dial::@252 channels
pthread_t thread
Definition: dial.c:55
#define AST_PTHREADT_NULL
Definition: lock.h:65
ast_mutex_t lock
Definition: dial.c:54
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
Definition: linkedlists.h:611
#define ast_calloc(a, b)
Definition: astmm.h:82
int timeout
Definition: dial.c:49
int actual_timeout
Definition: dial.c:50
#define ast_mutex_init(pmutex)
Definition: lock.h:152
int ast_dial_destroy ( struct ast_dial dial)

Destroys a dialing structure.

Note
Destroys (free's) the given ast_dial structure
Parameters
dialDialing structure to free
Returns
Returns 0 on success, -1 on failure

Definition at line 866 of file dial.c.

References AST_DIAL_OPTION_MAX, ast_free, ast_hangup(), AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_mutex_destroy, ast_dial::channels, ast_dial_channel::device, ast_option_types::disable, ast_dial_channel::list, ast_dial::lock, ast_dial::options, ast_dial_channel::options, ast_dial_channel::owner, and ast_dial_channel::tech.

Referenced by dial_trunk(), do_notify(), page_exec(), run_station(), sla_handle_dial_state_event(), sla_hangup_stations(), sla_ring_station(), and sla_stop_ringing_station().

867 {
868  int i = 0;
869  struct ast_dial_channel *channel = NULL;
870 
871  if (!dial)
872  return -1;
873 
874  /* Hangup and deallocate all the dialed channels */
875  AST_LIST_LOCK(&dial->channels);
876  AST_LIST_TRAVERSE_SAFE_BEGIN(&dial->channels, channel, list) {
877  /* Disable any enabled options */
878  for (i = 0; i < AST_DIAL_OPTION_MAX; i++) {
879  if (!channel->options[i])
880  continue;
881  if (option_types[i].disable)
882  option_types[i].disable(channel->options[i]);
883  channel->options[i] = NULL;
884  }
885  /* Hang up channel if need be */
886  if (channel->owner) {
887  ast_hangup(channel->owner);
888  channel->owner = NULL;
889  }
890  /* Free structure */
891  ast_free(channel->tech);
892  ast_free(channel->device);
894  ast_free(channel);
895  }
897  AST_LIST_UNLOCK(&dial->channels);
898 
899  /* Disable any enabled options globally */
900  for (i = 0; i < AST_DIAL_OPTION_MAX; i++) {
901  if (!dial->options[i])
902  continue;
903  if (option_types[i].disable)
904  option_types[i].disable(dial->options[i]);
905  dial->options[i] = NULL;
906  }
907 
908  /* Lock be gone! */
909  ast_mutex_destroy(&dial->lock);
910 
911  /* Free structure */
912  ast_free(dial);
913 
914  return 0;
915 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:600
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:52
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:554
char * tech
Definition: dial.c:63
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:65
struct ast_channel * owner
Definition: dial.c:68
ast_mutex_t lock
Definition: dial.c:54
#define ast_free(a)
Definition: astmm.h:97
struct ast_dial_channel::@253 list
static struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
Definition: dial.c:180
ast_dial_option_cb_disable disable
Definition: dial.c:171
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
#define ast_mutex_destroy(a)
Definition: lock.h:154
char * device
Definition: dial.c:64
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
void ast_dial_hangup ( struct ast_dial dial)

Hangup channels.

Note
Hangup all active channels
Parameters
dialDialing structure

Definition at line 842 of file dial.c.

References ast_hangup(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_dial::channels, ast_dial_channel::list, and ast_dial_channel::owner.

Referenced by ast_dial_run(), and page_exec().

843 {
844  struct ast_dial_channel *channel = NULL;
845 
846  if (!dial)
847  return;
848 
849  AST_LIST_LOCK(&dial->channels);
850  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
851  if (channel->owner) {
852  ast_hangup(channel->owner);
853  channel->owner = NULL;
854  }
855  }
856  AST_LIST_UNLOCK(&dial->channels);
857 
858  return;
859 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct ast_channel * owner
Definition: dial.c:68
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_dial_channel::@253 list
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
enum ast_dial_result ast_dial_join ( struct ast_dial dial)

Cancel async thread.

Note
Cancel a running async thread
Parameters
dialDialing structure

Definition at line 794 of file dial.c.

References ast_channel_lock, ast_channel_unlock, AST_DIAL_RESULT_FAILED, AST_LIST_FIRST, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, ast_dial::channels, ast_dial::lock, ast_dial::state, and ast_dial::thread.

Referenced by dial_trunk(), page_exec(), run_station(), sla_handle_dial_state_event(), sla_hangup_stations(), sla_ring_station(), and sla_stop_ringing_station().

795 {
796  pthread_t thread;
797 
798  /* If the dial structure is not running in async, return failed */
799  if (dial->thread == AST_PTHREADT_NULL)
800  return AST_DIAL_RESULT_FAILED;
801 
802  /* Record thread */
803  thread = dial->thread;
804 
805  /* Boom, commence locking */
806  ast_mutex_lock(&dial->lock);
807 
808  /* Stop the thread */
809  dial->thread = AST_PTHREADT_STOP;
810 
811  /* If the answered channel is running an application we have to soft hangup it, can't just poke the thread */
812  AST_LIST_LOCK(&dial->channels);
813  if (AST_LIST_FIRST(&dial->channels)->is_running_app) {
814  struct ast_channel *chan = AST_LIST_FIRST(&dial->channels)->owner;
815  if (chan) {
816  ast_channel_lock(chan);
818  ast_channel_unlock(chan);
819  }
820  } else {
821  /* Now we signal it with SIGURG so it will break out of it's waitfor */
822  pthread_kill(thread, SIGURG);
823  }
824  AST_LIST_UNLOCK(&dial->channels);
825 
826  /* Yay done with it */
827  ast_mutex_unlock(&dial->lock);
828 
829  /* Finally wait for the thread to exit */
830  pthread_join(thread, NULL);
831 
832  /* Yay thread is all gone */
833  dial->thread = AST_PTHREADT_NULL;
834 
835  return dial->state;
836 }
pthread_t thread
Definition: app_meetme.c:962
#define ast_channel_lock(chan)
Definition: channel.h:2466
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
struct ast_dial::@252 channels
enum ast_dial_result state
Definition: dial.c:51
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define ast_mutex_lock(a)
Definition: lock.h:155
pthread_t thread
Definition: dial.c:55
#define AST_PTHREADT_NULL
Definition: lock.h:65
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
Definition: channel.c:2746
ast_mutex_t lock
Definition: dial.c:54
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define AST_PTHREADT_STOP
Definition: lock.h:66
#define ast_mutex_unlock(a)
Definition: lock.h:156
int ast_dial_option_disable ( struct ast_dial dial,
int  num,
enum ast_dial_option  option 
)

Disables an option per channel.

Parameters
dialDial structure
numChannel number to disable option on
optionOption to disable
Returns
Returns 0 on success, -1 on failure

Definition at line 1018 of file dial.c.

References AST_LIST_EMPTY, ast_dial::channels, ast_option_types::disable, find_dial_channel(), and ast_dial_channel::options.

1019 {
1020  struct ast_dial_channel *channel = NULL;
1021 
1022  /* Ensure we have required arguments */
1023  if (!dial || AST_LIST_EMPTY(&dial->channels))
1024  return -1;
1025 
1026  if (!(channel = find_dial_channel(dial, num)))
1027  return -1;
1028 
1029  /* If the option is not enabled, return failure */
1030  if (!channel->options[option])
1031  return -1;
1032 
1033  /* Execute callback of option to disable it if it exists */
1034  if (option_types[option].disable)
1035  option_types[option].disable(channel->options[option]);
1036 
1037  /* Finally disable the option on the structure */
1038  channel->options[option] = NULL;
1039 
1040  return 0;
1041 }
struct ast_dial::@252 channels
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:449
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:65
static struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
Definition: dial.c:180
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.
Definition: dial.c:940
ast_dial_option_cb_disable disable
Definition: dial.c:171
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
int ast_dial_option_enable ( struct ast_dial dial,
int  num,
enum ast_dial_option  option,
void *  data 
)

Enables an option per channel.

Parameters
dialDial structure
numChannel number to enable option on
optionOption to enable
dataData to pass to this option (not always needed)
Returns
Returns 0 on success, -1 on failure

Definition at line 966 of file dial.c.

References AST_LIST_EMPTY, ast_dial::channels, ast_option_types::enable, find_dial_channel(), and ast_dial_channel::options.

967 {
968  struct ast_dial_channel *channel = NULL;
969 
970  /* Ensure we have required arguments */
971  if (!dial || AST_LIST_EMPTY(&dial->channels))
972  return -1;
973 
974  if (!(channel = find_dial_channel(dial, num)))
975  return -1;
976 
977  /* If the option is already enabled, return failure */
978  if (channel->options[option])
979  return -1;
980 
981  /* Execute enable callback if it exists, if not simply make sure the value is set */
982  if (option_types[option].enable)
983  channel->options[option] = option_types[option].enable(data);
984  else
985  channel->options[option] = (void*)1;
986 
987  return 0;
988 }
struct ast_dial::@252 channels
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:449
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:65
ast_dial_option_cb_enable enable
Definition: dial.c:170
static struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
Definition: dial.c:180
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.
Definition: dial.c:940
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
int ast_dial_option_global_disable ( struct ast_dial dial,
enum ast_dial_option  option 
)

Disables an option globally.

Parameters
dialDial structure to disable option on
optionOption to disable
Returns
Returns 0 on success, -1 on failure

Definition at line 995 of file dial.c.

References ast_option_types::disable, and ast_dial::options.

996 {
997  /* If the option is not enabled, return failure */
998  if (!dial->options[option]) {
999  return -1;
1000  }
1001 
1002  /* Execute callback of option to disable if it exists */
1003  if (option_types[option].disable)
1004  option_types[option].disable(dial->options[option]);
1005 
1006  /* Finally disable option on the structure */
1007  dial->options[option] = NULL;
1008 
1009  return 0;
1010 }
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:52
static struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
Definition: dial.c:180
ast_dial_option_cb_disable disable
Definition: dial.c:171
int ast_dial_option_global_enable ( struct ast_dial dial,
enum ast_dial_option  option,
void *  data 
)

Enables an option globally.

Parameters
dialDial structure to enable option on
optionOption to enable
dataData to pass to this option (not always needed)
Returns
Returns 0 on success, -1 on failure

Definition at line 923 of file dial.c.

References ast_option_types::enable, and ast_dial::options.

Referenced by do_notify(), and page_exec().

924 {
925  /* If the option is already enabled, return failure */
926  if (dial->options[option])
927  return -1;
928 
929  /* Execute enable callback if it exists, if not simply make sure the value is set */
930  if (option_types[option].enable)
931  dial->options[option] = option_types[option].enable(data);
932  else
933  dial->options[option] = (void*)1;
934 
935  return 0;
936 }
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:52
ast_dial_option_cb_enable enable
Definition: dial.c:170
static struct ast_option_types option_types[]
Map options to respective handlers (enable/disable).
Definition: dial.c:180
enum ast_dial_result ast_dial_run ( struct ast_dial dial,
struct ast_channel chan,
int  async 
)

Execute dialing synchronously or asynchronously.

Note
Dials channels in a dial structure.
Returns
Returns dial result code. (TRYING/INVALID/FAILED/ANSWERED/TIMEOUT/UNANSWERED).

Definition at line 714 of file dial.c.

References ast_debug, ast_dial_hangup(), AST_DIAL_RESULT_FAILED, AST_DIAL_RESULT_INVALID, AST_DIAL_RESULT_TRYING, AST_LIST_EMPTY, ast_pthread_create, async_dial(), begin_dial(), ast_dial::channels, monitor_dial(), ast_dial::state, and ast_dial::thread.

Referenced by dial_trunk(), do_notify(), page_exec(), and sla_ring_station().

715 {
717 
718  /* Ensure required arguments are passed */
719  if (!dial || (!chan && !async)) {
720  ast_debug(1, "invalid #1\n");
722  }
723 
724  /* If there are no channels to dial we can't very well try to dial them */
725  if (AST_LIST_EMPTY(&dial->channels)) {
726  ast_debug(1, "invalid #2\n");
728  }
729 
730  /* Dial each requested channel */
731  if (!begin_dial(dial, chan))
732  return AST_DIAL_RESULT_FAILED;
733 
734  /* If we are running async spawn a thread and send it away... otherwise block here */
735  if (async) {
737  /* Try to create a thread */
738  if (ast_pthread_create(&dial->thread, NULL, async_dial, dial)) {
739  /* Failed to create the thread - hangup all dialed channels and return failed */
740  ast_dial_hangup(dial);
742  }
743  } else {
744  res = monitor_dial(dial, chan);
745  }
746 
747  return res;
748 }
static int begin_dial(struct ast_dial *dial, struct ast_channel *chan)
Helper function that does the beginning dialing per dial structure.
Definition: dial.c:311
struct ast_dial::@252 channels
void ast_dial_hangup(struct ast_dial *dial)
Hangup channels.
Definition: dial.c:842
enum ast_dial_result state
Definition: dial.c:51
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:449
pthread_t thread
Definition: dial.c:55
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
ast_dial_result
List of return codes for dial run API calls.
Definition: dial.h:48
static void * async_dial(void *data)
Dial async thread function.
Definition: dial.c:700
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:418
static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_channel *chan)
Helper function that basically keeps tabs on dialing attempts.
Definition: dial.c:551
void ast_dial_set_global_timeout ( struct ast_dial dial,
int  timeout 
)

Set the maximum time (globally) allowed for trying to ring phones.

Parameters
dialThe dial structure to apply the time limit to
timeoutMaximum time allowed
Returns
nothing

Definition at line 1053 of file dial.c.

References ast_dial::actual_timeout, and ast_dial::timeout.

Referenced by do_notify(), and page_exec().

1054 {
1055  dial->timeout = timeout;
1056 
1057  if (dial->timeout > 0 && (dial->actual_timeout > dial->timeout || dial->actual_timeout == -1))
1058  dial->actual_timeout = dial->timeout;
1059 
1060  return;
1061 }
int timeout
Definition: dial.c:49
int actual_timeout
Definition: dial.c:50
int timeout
Definition: dial.c:62
void ast_dial_set_state_callback ( struct ast_dial dial,
ast_dial_state_callback  callback 
)

Set a callback for state changes.

Parameters
dialThe dial structure to watch for state changes
callbackthe callback
Returns
nothing

Definition at line 1043 of file dial.c.

References ast_dial::state_callback.

Referenced by sla_ring_station().

1044 {
1045  dial->state_callback = callback;
1046 }
ast_dial_state_callback state_callback
Definition: dial.c:53
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.

Parameters
dialThe dial structure the channel belongs to
numChannel number to set timeout on
timeoutMaximum time allowed
Returns
nothing

Definition at line 1069 of file dial.c.

References ast_dial::actual_timeout, find_dial_channel(), ast_dial::timeout, and ast_dial_channel::timeout.

1070 {
1071  struct ast_dial_channel *channel = NULL;
1072 
1073  if (!(channel = find_dial_channel(dial, num)))
1074  return;
1075 
1076  channel->timeout = timeout;
1077 
1078  if (channel->timeout > 0 && (dial->actual_timeout > channel->timeout || dial->actual_timeout == -1))
1079  dial->actual_timeout = channel->timeout;
1080 
1081  return;
1082 }
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.
Definition: dial.c:940
int actual_timeout
Definition: dial.c:50
int timeout
Definition: dial.c:62
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
enum ast_dial_result ast_dial_state ( struct ast_dial dial)

Return state of dial.

Note
Returns the state of the dial attempt
Parameters
dialDialing structure

Definition at line 785 of file dial.c.

References ast_dial::state.

Referenced by dial_trunk(), and sla_handle_dial_state_event().

786 {
787  return dial->state;
788 }
enum ast_dial_result state
Definition: dial.c:51
static void* async_dial ( void *  data)
static

Dial async thread function.

Definition at line 700 of file dial.c.

References monitor_dial().

Referenced by ast_dial_run().

701 {
702  struct ast_dial *dial = data;
703 
704  /* This is really really simple... we basically pass monitor_dial a NULL owner and it changes it's behavior */
705  monitor_dial(dial, NULL);
706 
707  return NULL;
708 }
Main dialing structure. Contains global options, channels being dialed, and more! ...
Definition: dial.c:47
static enum ast_dial_result monitor_dial(struct ast_dial *dial, struct ast_channel *chan)
Helper function that basically keeps tabs on dialing attempts.
Definition: dial.c:551
static int begin_dial ( struct ast_dial dial,
struct ast_channel chan 
)
static

Helper function that does the beginning dialing per dial structure.

Definition at line 311 of file dial.c.

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, begin_dial_channel(), ast_dial::channels, and ast_dial_channel::list.

Referenced by ast_dial_run().

312 {
313  struct ast_dial_channel *channel = NULL;
314  int success = 0;
315 
316  /* Iterate through channel list, requesting and calling each one */
317  AST_LIST_LOCK(&dial->channels);
318  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
319  success += begin_dial_channel(channel, chan);
320  }
321  AST_LIST_UNLOCK(&dial->channels);
322 
323  /* If number of failures matches the number of channels, then this truly failed */
324  return success;
325 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_channel *chan)
Helper function that does the beginning dialing per-appended channel.
Definition: dial.c:258
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_dial_channel::@253 list
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
static int begin_dial_channel ( struct ast_dial_channel channel,
struct ast_channel chan 
)
static

Helper function that does the beginning dialing per-appended channel.

Definition at line 258 of file dial.c.

References accountcode, ast_channel::accountcode, ast_channel::adsicpe, ast_channel::appl, ast_call(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_connected_line_copy_from_caller(), ast_copy_string(), AST_FORMAT_AUDIO_MASK, ast_hangup(), AST_MAX_EXTENSION, ast_party_redirecting_copy(), ast_poll_channel_add(), ast_request(), ast_string_field_set, ast_strlen_zero(), ast_verb, ast_channel::caller, ast_dial_channel::cause, ast_channel::connected, ast_channel::data, ast_dial_channel::device, ast_channel::dialed, language, ast_channel::language, musicclass, ast_channel::musicclass, ast_channel::nativeformats, ast_dial_channel::owner, ast_channel::redirecting, ast_dial_channel::tech, ast_channel::transfercapability, ast_party_dialed::transit_network_select, and ast_channel::whentohangup.

Referenced by begin_dial(), and handle_call_forward().

259 {
260  char numsubst[AST_MAX_EXTENSION];
261  int res = 1;
262 
263  /* Copy device string over */
264  ast_copy_string(numsubst, channel->device, sizeof(numsubst));
265 
266  /* If we fail to create our owner channel bail out */
267  if (!(channel->owner = ast_request(channel->tech, chan ? chan->nativeformats : AST_FORMAT_AUDIO_MASK, chan, numsubst, &channel->cause)))
268  return -1;
269 
270  channel->owner->appl = "AppDial2";
271  channel->owner->data = "(Outgoing Line)";
272  memset(&channel->owner->whentohangup, 0, sizeof(channel->owner->whentohangup));
273 
274  /* Inherit everything from he who spawned this dial */
275  if (chan) {
276  ast_channel_inherit_variables(chan, channel->owner);
277  ast_channel_datastore_inherit(chan, channel->owner);
278 
279  /* Copy over callerid information */
281 
283 
285 
286  ast_string_field_set(channel->owner, language, chan->language);
288  if (ast_strlen_zero(channel->owner->musicclass))
290 
291  channel->owner->adsicpe = chan->adsicpe;
292  channel->owner->transfercapability = chan->transfercapability;
293  }
294 
295  /* Attempt to actually call this device */
296  if ((res = ast_call(channel->owner, numsubst, 0))) {
297  res = 0;
298  ast_hangup(channel->owner);
299  channel->owner = NULL;
300  } else {
301  if (chan)
302  ast_poll_channel_add(chan, channel->owner);
303  res = 1;
304  ast_verb(3, "Called %s\n", numsubst);
305  }
306 
307  return res;
308 }
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:155
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_iax2.c:383
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
Definition: channel.c:2665
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
Definition: channel.h:814
unsigned short transfercapability
Definition: channel.h:863
format_t nativeformats
Definition: channel.h:852
const char * data
Definition: channel.h:755
enum ast_channel_adsicpe adsicpe
Definition: channel.h:844
#define ast_verb(level,...)
Definition: logger.h:243
const char * appl
Definition: channel.h:754
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2573
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define AST_MAX_EXTENSION
Definition: channel.h:135
char * tech
Definition: dial.c:63
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
struct ast_party_dialed dialed
Dialed/Called information.
Definition: channel.h:797
struct ast_channel * owner
Definition: dial.c:68
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
Definition: channel.c:6241
#define AST_FORMAT_AUDIO_MASK
Definition: frame.h:274
int ast_call(struct ast_channel *chan, char *addr, int timeout)
Make a call.
Definition: channel.c:5761
int transit_network_select
Transit Network Select.
Definition: channel.h:347
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
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.
Definition: channel.c:8443
const ast_string_field musicclass
Definition: channel.h:787
const ast_string_field accountcode
Definition: channel.h:787
struct timeval whentohangup
Definition: channel.h:789
struct ast_channel * ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status)
Requests a channel.
Definition: channel.c:5695
char * device
Definition: dial.c:64
const ast_string_field language
Definition: channel.h:787
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.
Definition: channel.c:2367
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
static struct ast_dial_channel* find_dial_channel ( struct ast_dial dial,
int  num 
)
static

Helper function for finding a channel in a dial structure based on number.

Definition at line 940 of file dial.c.

References AST_LIST_LAST, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_dial::channels, ast_dial_channel::list, and ast_dial_channel::num.

Referenced by ast_dial_option_disable(), ast_dial_option_enable(), and ast_dial_set_timeout().

941 {
942  struct ast_dial_channel *channel = AST_LIST_LAST(&dial->channels);
943 
944  /* We can try to predict programmer behavior, the last channel they added is probably the one they wanted to modify */
945  if (channel->num == num)
946  return channel;
947 
948  /* Hrm not at the end... looking through the list it is! */
949  AST_LIST_LOCK(&dial->channels);
950  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
951  if (channel->num == num)
952  break;
953  }
954  AST_LIST_UNLOCK(&dial->channels);
955 
956  return channel;
957 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_dial_channel::@253 list
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
static struct ast_dial_channel* find_relative_dial_channel ( struct ast_dial dial,
struct ast_channel owner 
)
static

Helper function that finds the dialed channel based on owner.

Definition at line 367 of file dial.c.

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_dial::channels, ast_dial_channel::list, and ast_dial_channel::owner.

Referenced by monitor_dial().

368 {
369  struct ast_dial_channel *channel = NULL;
370 
371  AST_LIST_LOCK(&dial->channels);
372  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
373  if (channel->owner == owner)
374  break;
375  }
376  AST_LIST_UNLOCK(&dial->channels);
377 
378  return channel;
379 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct ast_channel * owner
Definition: dial.c:68
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_dial_channel::@253 list
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
static int handle_call_forward ( struct ast_dial dial,
struct ast_dial_channel channel,
struct ast_channel chan 
)
static

Helper function to handle channels that have been call forwarded.

Definition at line 328 of file dial.c.

References AST_DIAL_OPTION_DISABLE_CALL_FORWARDING, ast_free, ast_hangup(), AST_LIST_UNLOCK, ast_strdup, ast_strdupa, begin_dial_channel(), ast_channel::call_forward, ast_dial::channels, ast_dial_channel::device, FIND_RELATIVE_OPTION, ast_dial_channel::owner, and ast_dial_channel::tech.

Referenced by monitor_dial().

329 {
330  struct ast_channel *original = channel->owner;
331  char *tmp = ast_strdupa(channel->owner->call_forward);
332  char *tech = "Local", *device = tmp, *stuff;
333 
334  /* If call forwarding is disabled just drop the original channel and don't attempt to dial the new one */
336  ast_hangup(original);
337  channel->owner = NULL;
338  return 0;
339  }
340 
341  /* Figure out the new destination */
342  if ((stuff = strchr(tmp, '/'))) {
343  *stuff++ = '\0';
344  tech = tmp;
345  device = stuff;
346  }
347 
348  /* Drop old destination information */
349  ast_free(channel->tech);
350  ast_free(channel->device);
351 
352  /* Update the dial channel with the new destination information */
353  channel->tech = ast_strdup(tech);
354  channel->device = ast_strdup(device);
355  AST_LIST_UNLOCK(&dial->channels);
356 
357  /* Finally give it a go... send it out into the world */
358  begin_dial_channel(channel, chan);
359 
360  /* Drop the original channel */
361  ast_hangup(original);
362 
363  return 0;
364 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
Main Channel structure associated with a channel.
Definition: channel.h:742
#define ast_strdup(a)
Definition: astmm.h:109
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_channel *chan)
Helper function that does the beginning dialing per-appended channel.
Definition: dial.c:258
#define FIND_RELATIVE_OPTION(dial, dial_channel, ast_dial_option)
Macro for finding the option structure to use on a dialed channel.
Definition: dial.c:192
char * tech
Definition: dial.c:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
struct ast_channel * owner
Definition: dial.c:68
const ast_string_field call_forward
Definition: channel.h:787
#define ast_free(a)
Definition: astmm.h:97
struct ast_channel_tech * tech
Definition: channel.h:743
char * device
Definition: dial.c:64
static void handle_frame ( struct ast_dial dial,
struct ast_dial_channel channel,
struct ast_frame fr,
struct ast_channel chan 
)
static

Helper function that handles control frames WITH owner.

Definition at line 390 of file dial.c.

References ast_channel_connected_line_macro(), ast_channel_redirecting_macro(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_OFFHOOK, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_DIAL_OPTION_MUSIC, AST_DIAL_RESULT_ANSWERED, AST_DIAL_RESULT_PROCEEDING, AST_DIAL_RESULT_PROGRESS, AST_DIAL_RESULT_RINGING, AST_FRAME_CONTROL, ast_hangup(), ast_indicate(), ast_indicate_data(), AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_verb, ast_verbose(), ast_dial::channels, ast_frame::data, ast_frame::datalen, ast_channel::exten, ast_frame::frametype, ast_frame_subclass::integer, ast_dial_channel::list, ast_channel::name, option_verbose, ast_dial::options, ast_dial_channel::owner, ast_frame::ptr, set_state(), ast_frame::subclass, and VERBOSE_PREFIX_3.

Referenced by monitor_dial().

391 {
392  if (fr->frametype == AST_FRAME_CONTROL) {
393  switch (fr->subclass.integer) {
394  case AST_CONTROL_ANSWER:
395  ast_verb(3, "%s answered %s\n", channel->owner->name, chan->name);
396  AST_LIST_LOCK(&dial->channels);
397  AST_LIST_REMOVE(&dial->channels, channel, list);
398  AST_LIST_INSERT_HEAD(&dial->channels, channel, list);
399  AST_LIST_UNLOCK(&dial->channels);
401  break;
402  case AST_CONTROL_BUSY:
403  ast_verb(3, "%s is busy\n", channel->owner->name);
404  ast_hangup(channel->owner);
405  channel->owner = NULL;
406  break;
408  ast_verb(3, "%s is circuit-busy\n", channel->owner->name);
409  ast_hangup(channel->owner);
410  channel->owner = NULL;
411  break;
413  ast_verb(3, "%s dialed Incomplete extension %s\n", channel->owner->name, channel->owner->exten);
415  break;
416  case AST_CONTROL_RINGING:
417  ast_verb(3, "%s is ringing\n", channel->owner->name);
418  if (!dial->options[AST_DIAL_OPTION_MUSIC])
421  break;
423  ast_verb(3, "%s is making progress, passing it to %s\n", channel->owner->name, chan->name);
426  break;
428  ast_verb(3, "%s requested a video update, passing it to %s\n", channel->owner->name, chan->name);
430  break;
432  if (option_verbose > 2)
433  ast_verbose (VERBOSE_PREFIX_3 "%s requested a source update, passing it to %s\n", channel->owner->name, chan->name);
435  break;
437  ast_verb(3, "%s connected line has changed, passing it to %s\n", channel->owner->name, chan->name);
438  if (ast_channel_connected_line_macro(channel->owner, chan, fr, 1, 1)) {
440  }
441  break;
443  ast_verb(3, "%s redirecting info has changed, passing it to %s\n", channel->owner->name, chan->name);
444  if (ast_channel_redirecting_macro(channel->owner, chan, fr, 1, 1)) {
446  }
447  break;
449  ast_verb(3, "%s is proceeding, passing it to %s\n", channel->owner->name, chan->name);
452  break;
453  case AST_CONTROL_HOLD:
454  ast_verb(3, "Call on %s placed on hold\n", chan->name);
456  break;
457  case AST_CONTROL_UNHOLD:
458  ast_verb(3, "Call on %s left from hold\n", chan->name);
460  break;
461  case AST_CONTROL_OFFHOOK:
462  case AST_CONTROL_FLASH:
463  break;
464  case -1:
465  /* Prod the channel */
466  ast_indicate(chan, -1);
467  break;
468  default:
469  break;
470  }
471  }
472 
473  return;
474 }
union ast_frame_subclass subclass
Definition: frame.h:146
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
Definition: dial.c:381
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
void * ptr
Definition: frame.h:160
#define VERBOSE_PREFIX_3
Definition: logger.h:43
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
int option_verbose
Definition: asterisk.c:181
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4447
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&#39;s connected line information.
Definition: channel.c:9618
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
#define ast_verb(level,...)
Definition: logger.h:243
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:52
int datalen
Definition: frame.h:148
struct ast_channel * owner
Definition: dial.c:68
const ast_string_field name
Definition: channel.h:787
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
enum ast_frame_type frametype
Definition: frame.h:144
union ast_frame::@172 data
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
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&#39;s redirecting information.
Definition: channel.c:9663
static void handle_frame_ownerless ( struct ast_dial dial,
struct ast_dial_channel channel,
struct ast_frame fr 
)
static

Helper function that handles control frames WITHOUT owner.

Definition at line 477 of file dial.c.

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_DIAL_RESULT_ANSWERED, AST_DIAL_RESULT_PROCEEDING, AST_DIAL_RESULT_PROGRESS, AST_DIAL_RESULT_RINGING, AST_FRAME_CONTROL, ast_hangup(), AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_verb, ast_dial::channels, ast_frame::frametype, ast_frame_subclass::integer, ast_dial_channel::list, ast_channel::name, ast_dial_channel::owner, set_state(), and ast_frame::subclass.

Referenced by monitor_dial().

478 {
479  /* If we have no owner we can only update the state of the dial structure, so only look at control frames */
480  if (fr->frametype != AST_FRAME_CONTROL)
481  return;
482 
483  switch (fr->subclass.integer) {
484  case AST_CONTROL_ANSWER:
485  ast_verb(3, "%s answered\n", channel->owner->name);
486  AST_LIST_LOCK(&dial->channels);
487  AST_LIST_REMOVE(&dial->channels, channel, list);
488  AST_LIST_INSERT_HEAD(&dial->channels, channel, list);
489  AST_LIST_UNLOCK(&dial->channels);
491  break;
492  case AST_CONTROL_BUSY:
493  ast_verb(3, "%s is busy\n", channel->owner->name);
494  ast_hangup(channel->owner);
495  channel->owner = NULL;
496  break;
498  ast_verb(3, "%s is circuit-busy\n", channel->owner->name);
499  ast_hangup(channel->owner);
500  channel->owner = NULL;
501  break;
502  case AST_CONTROL_RINGING:
503  ast_verb(3, "%s is ringing\n", channel->owner->name);
505  break;
507  ast_verb(3, "%s is making progress\n", channel->owner->name);
509  break;
511  ast_verb(3, "%s is proceeding\n", channel->owner->name);
513  break;
514  default:
515  break;
516  }
517 
518  return;
519 }
union ast_frame_subclass subclass
Definition: frame.h:146
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
Definition: dial.c:381
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_dial::@252 channels
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:841
#define ast_verb(level,...)
Definition: logger.h:243
struct ast_channel * owner
Definition: dial.c:68
const ast_string_field name
Definition: channel.h:787
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:696
enum ast_frame_type frametype
Definition: frame.h:144
static int handle_timeout_trip ( struct ast_dial dial,
struct timeval  start 
)
static

Helper function to handle when a timeout occurs on dialing attempt.

Definition at line 522 of file dial.c.

References AST_DIAL_RESULT_TIMEOUT, ast_hangup(), AST_LIST_TRAVERSE, ast_tvdiff_ms(), ast_tvnow(), ast_dial::channels, ast_dial_channel::list, ast_dial_channel::owner, set_state(), ast_dial::state, ast_dial::timeout, and ast_dial_channel::timeout.

Referenced by monitor_dial().

523 {
524  struct ast_dial_channel *channel = NULL;
525  int diff = ast_tvdiff_ms(ast_tvnow(), start), lowest_timeout = -1, new_timeout = -1;
526 
527  /* If the global dial timeout tripped switch the state to timeout so our channel loop will drop every channel */
528  if (diff >= dial->timeout) {
530  new_timeout = 0;
531  }
532 
533  /* Go through dropping out channels that have met their timeout */
534  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
535  if (dial->state == AST_DIAL_RESULT_TIMEOUT || diff >= channel->timeout) {
536  ast_hangup(channel->owner);
537  channel->owner = NULL;
538  } else if ((lowest_timeout == -1) || (lowest_timeout > channel->timeout)) {
539  lowest_timeout = channel->timeout;
540  }
541  }
542 
543  /* Calculate the new timeout using the lowest timeout found */
544  if (lowest_timeout >= 0)
545  new_timeout = lowest_timeout - diff;
546 
547  return new_timeout;
548 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
Definition: dial.c:381
struct ast_dial::@252 channels
enum ast_dial_result state
Definition: dial.c:51
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:90
struct ast_channel * owner
Definition: dial.c:68
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct ast_dial_channel::@253 list
int timeout
Definition: dial.c:49
int timeout
Definition: dial.c:62
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
static enum ast_dial_result monitor_dial ( struct ast_dial dial,
struct ast_channel chan 
)
static

Helper function that basically keeps tabs on dialing attempts.

Definition at line 551 of file dial.c.

References ast_dial::actual_timeout, answer_exec_run(), answer_exec_struct::app, answer_exec_struct::args, AST_CONTROL_RINGING, AST_DIAL_OPTION_ANSWER_EXEC, AST_DIAL_OPTION_MUSIC, AST_DIAL_OPTION_RINGING, AST_DIAL_RESULT_ANSWERED, AST_DIAL_RESULT_HANGUP, AST_DIAL_RESULT_RINGING, AST_DIAL_RESULT_TIMEOUT, AST_DIAL_RESULT_TRYING, AST_DIAL_RESULT_UNANSWERED, ast_frfree, ast_hangup(), ast_indicate(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, AST_MAX_WATCHERS, ast_moh_start(), ast_moh_stop(), ast_poll_channel_del(), AST_PTHREADT_STOP, ast_read(), ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_tvnow(), ast_waitfor_n(), ast_channel::call_forward, ast_dial::channels, find_relative_dial_channel(), FIND_RELATIVE_OPTION, handle_call_forward(), handle_frame(), handle_frame_ownerless(), handle_timeout_trip(), IS_CALLER, ast_dial_channel::is_running_app, musicclass, ast_channel::musicclass, ast_dial::options, ast_dial_channel::owner, set_state(), ast_dial::state, and ast_dial::thread.

Referenced by ast_dial_run(), and async_dial().

552 {
553  int timeout = -1;
554  struct ast_channel *cs[AST_MAX_WATCHERS], *who = NULL;
555  struct ast_dial_channel *channel = NULL;
556  struct answer_exec_struct *answer_exec = NULL;
557  struct timeval start;
558 
560 
561  /* If the "always indicate ringing" option is set, change state to ringing and indicate to the owner if present */
562  if (dial->options[AST_DIAL_OPTION_RINGING]) {
564  if (chan)
566  } else if (chan && dial->options[AST_DIAL_OPTION_MUSIC] &&
568  char *original_moh = ast_strdupa(chan->musicclass);
569  ast_indicate(chan, -1);
571  ast_moh_start(chan, dial->options[AST_DIAL_OPTION_MUSIC], NULL);
572  ast_string_field_set(chan, musicclass, original_moh);
573  }
574 
575  /* Record start time for timeout purposes */
576  start = ast_tvnow();
577 
578  /* We actually figured out the maximum timeout we can do as they were added, so we can directly access the info */
579  timeout = dial->actual_timeout;
580 
581  /* Go into an infinite loop while we are trying */
582  while ((dial->state != AST_DIAL_RESULT_UNANSWERED) && (dial->state != AST_DIAL_RESULT_ANSWERED) && (dial->state != AST_DIAL_RESULT_HANGUP) && (dial->state != AST_DIAL_RESULT_TIMEOUT)) {
583  int pos = 0, count = 0;
584  struct ast_frame *fr = NULL;
585 
586  /* Set up channel structure array */
587  pos = count = 0;
588  if (chan)
589  cs[pos++] = chan;
590 
591  /* Add channels we are attempting to dial */
592  AST_LIST_LOCK(&dial->channels);
593  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
594  if (channel->owner) {
595  cs[pos++] = channel->owner;
596  count++;
597  }
598  }
599  AST_LIST_UNLOCK(&dial->channels);
600 
601  /* If we have no outbound channels in progress, switch state to unanswered and stop */
602  if (!count) {
604  break;
605  }
606 
607  /* Just to be safe... */
608  if (dial->thread == AST_PTHREADT_STOP)
609  break;
610 
611  /* Wait for frames from channels */
612  who = ast_waitfor_n(cs, pos, &timeout);
613 
614  /* Check to see if our thread is being cancelled */
615  if (dial->thread == AST_PTHREADT_STOP)
616  break;
617 
618  /* If the timeout no longer exists OR if we got no channel it basically means the timeout was tripped, so handle it */
619  if (!timeout || !who) {
620  timeout = handle_timeout_trip(dial, start);
621  continue;
622  }
623 
624  /* Find relative dial channel */
625  if (!chan || !IS_CALLER(chan, who))
626  channel = find_relative_dial_channel(dial, who);
627 
628  /* See if this channel has been forwarded elsewhere */
629  if (!ast_strlen_zero(who->call_forward)) {
630  handle_call_forward(dial, channel, chan);
631  continue;
632  }
633 
634  /* Attempt to read in a frame */
635  if (!(fr = ast_read(who))) {
636  /* If this is the caller then we switch state to hangup and stop */
637  if (chan && IS_CALLER(chan, who)) {
639  break;
640  }
641  if (chan)
642  ast_poll_channel_del(chan, channel->owner);
643  ast_hangup(who);
644  channel->owner = NULL;
645  continue;
646  }
647 
648  /* Process the frame */
649  if (chan)
650  handle_frame(dial, channel, fr, chan);
651  else
652  handle_frame_ownerless(dial, channel, fr);
653 
654  /* Free the received frame and start all over */
655  ast_frfree(fr);
656  }
657 
658  /* Do post-processing from loop */
659  if (dial->state == AST_DIAL_RESULT_ANSWERED) {
660  /* Hangup everything except that which answered */
661  AST_LIST_LOCK(&dial->channels);
662  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
663  if (!channel->owner || channel->owner == who)
664  continue;
665  if (chan)
666  ast_poll_channel_del(chan, channel->owner);
667  ast_hangup(channel->owner);
668  channel->owner = NULL;
669  }
670  AST_LIST_UNLOCK(&dial->channels);
671  /* If ANSWER_EXEC is enabled as an option, execute application on answered channel */
672  if ((channel = find_relative_dial_channel(dial, who)) && (answer_exec = FIND_RELATIVE_OPTION(dial, channel, AST_DIAL_OPTION_ANSWER_EXEC))) {
673  channel->is_running_app = 1;
674  answer_exec_run(dial, channel, answer_exec->app, answer_exec->args);
675  channel->is_running_app = 0;
676  }
677 
678  if (chan && dial->options[AST_DIAL_OPTION_MUSIC] &&
680  ast_moh_stop(chan);
681  }
682  } else if (dial->state == AST_DIAL_RESULT_HANGUP) {
683  /* Hangup everything */
684  AST_LIST_LOCK(&dial->channels);
685  AST_LIST_TRAVERSE(&dial->channels, channel, list) {
686  if (!channel->owner)
687  continue;
688  if (chan)
689  ast_poll_channel_del(chan, channel->owner);
690  ast_hangup(channel->owner);
691  channel->owner = NULL;
692  }
693  AST_LIST_UNLOCK(&dial->channels);
694  }
695 
696  return dial->state;
697 }
char * args
Definition: dial.c:81
static char musicclass[MAX_MUSICCLASS]
Definition: chan_mgcp.c:155
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...
Definition: channel.c:3534
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static void answer_exec_run(struct ast_dial *dial, struct ast_dial_channel *dial_channel, char *app, char *args)
Application execution function for &#39;ANSWER_EXEC&#39; option.
Definition: dial.c:145
Main Channel structure associated with a channel.
Definition: channel.h:742
static void set_state(struct ast_dial *dial, enum ast_dial_result state)
Definition: dial.c:381
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
unsigned int is_running_app
Definition: dial.c:67
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.
Definition: dial.c:477
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.
Definition: dial.c:367
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4393
enum ast_dial_result state
Definition: dial.c:51
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define FIND_RELATIVE_OPTION(dial, dial_channel, ast_dial_option)
Macro for finding the option structure to use on a dialed channel.
Definition: dial.c:192
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
#define AST_MAX_WATCHERS
Maximum number of channels we can watch at a time.
Definition: dial.c:189
pthread_t thread
Definition: dial.c:55
void * options[AST_DIAL_OPTION_MAX]
Definition: dial.c:52
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
struct ast_channel * owner
Definition: dial.c:68
const ast_string_field call_forward
Definition: channel.h:787
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
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.
Definition: dial.c:328
Structure for &#39;ANSWER_EXEC&#39; option.
Definition: dial.c:79
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.
Definition: dial.c:390
void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
Definition: channel.c:2688
#define AST_PTHREADT_STOP
Definition: lock.h:66
const ast_string_field musicclass
Definition: channel.h:787
Data structure associated with a single frame of data.
Definition: frame.h:142
int actual_timeout
Definition: dial.c:50
#define ast_frfree(fr)
Definition: frame.h:583
char app[AST_MAX_APP]
Definition: dial.c:80
#define IS_CALLER(chan, owner)
Macro that determines whether a channel is the caller or not.
Definition: dial.c:195
static int handle_timeout_trip(struct ast_dial *dial, struct timeval start)
Helper function to handle when a timeout occurs on dialing attempt.
Definition: dial.c:522
int timeout
Definition: dial.c:62
Dialing channel structure. Contains per-channel dialing options, asterisk channel, and more!
Definition: dial.c:60
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
static int music_disable ( void *  data)
static

Definition at line 134 of file dial.c.

References ast_free.

135 {
136  if (!data)
137  return -1;
138 
139  ast_free(data);
140 
141  return 0;
142 }
#define ast_free(a)
Definition: astmm.h:97
union ast_frame::@172 data
static void* music_enable ( void *  data)
static

Definition at line 129 of file dial.c.

References ast_strdup.

130 {
131  return ast_strdup(data);
132 }
#define ast_strdup(a)
Definition: astmm.h:109
union ast_frame::@172 data
static void set_state ( struct ast_dial dial,
enum ast_dial_result  state 
)
static

Definition at line 381 of file dial.c.

References ast_dial::state, and ast_dial::state_callback.

Referenced by handle_frame(), handle_frame_ownerless(), handle_timeout_trip(), and monitor_dial().

382 {
383  dial->state = state;
384 
385  if (dial->state_callback)
386  dial->state_callback(dial);
387 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
enum ast_dial_result state
Definition: dial.c:51
ast_dial_state_callback state_callback
Definition: dial.c:53

Variable Documentation

struct ast_option_types option_types[]
static

Map options to respective handlers (enable/disable).

Note
This list MUST be perfectly kept in order with enum ast_dial_option, or else madness will happen.

Definition at line 180 of file dial.c.