Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:01:29 2007

Asterisk developer's documentation :: Codename Pineapple


dial.c File Reference


Detailed Description

Dialing API.

Author:
Joshua Colp <jcolp@digium.com>

Definition in file dial.c.

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/dial.h"
#include "asterisk/pbx.h"

Include dependency graph for dial.c:

Go to the source code of this file.

Data Structures

struct  answer_exec_struct
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
 Options structure - maps options to respective handlers (enable/disable). This list MUST be perfectly kept in order, or else madness will happen. More...

Defines

#define AST_MAX_WATCHERS   256
 Maximum number of channels we can watch at a time.
#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.
#define IS_CALLER(chan, owner)   (chan == owner ? 1 : 0)
 Macro that determines whether a channel is the caller or not.
#define S_REPLACE(s, new_val)

Typedefs

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

Functions

static int answer_exec_disable (void *data)
static void * answer_exec_enable (void *data)
static void answer_exec_run (struct ast_channel *chan, char *app, char *args)
ast_channelast_dial_answered (struct ast_dial *dial)
 Return channel that answered.
int ast_dial_append (struct ast_dial *dial, const char *tech, const char *device)
 Append a channel.
ast_dialast_dial_create (void)
 New dialing structure.
int ast_dial_destroy (struct ast_dial *dial)
 Destroys a dialing structure.
void ast_dial_hangup (struct ast_dial *dial)
 Hangup channels.
enum ast_dial_result ast_dial_join (struct ast_dial *dial)
 Cancel async thread.
int ast_dial_option_disable (struct ast_dial *dial, int num, enum ast_dial_option option)
 Disables an option per channel.
int ast_dial_option_enable (struct ast_dial *dial, int num, enum ast_dial_option option, void *data)
 Enables an option per channel.
int ast_dial_option_global_disable (struct ast_dial *dial, enum ast_dial_option option)
 Disables an option globally.
int ast_dial_option_global_enable (struct ast_dial *dial, enum ast_dial_option option, void *data)
 Enables an option globally.
enum ast_dial_result ast_dial_run (struct ast_dial *dial, struct ast_channel *chan, int async)
 Execute dialing synchronously or asynchronously.
enum ast_dial_result ast_dial_status (struct ast_dial *dial)
 Return status of dial.
static void * async_dial (void *data)
 Dial async thread function.
static int begin_dial (struct ast_dial *dial, struct ast_channel *chan)
 Helper function that does the beginning dialing.
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.
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.
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.
static enum ast_dial_result monitor_dial (struct ast_dial *dial, struct ast_channel *chan)
 Helper function that basically keeps tabs on dialing attempts.

Variables

static const struct ast_option_types option_types []
 Options structure - maps options to respective handlers (enable/disable). This list MUST be perfectly kept in order, or else madness will happen.


Define Documentation

#define AST_MAX_WATCHERS   256
 

Maximum number of channels we can watch at a time.

Definition at line 159 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 162 of file dial.c.

Referenced by 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 165 of file dial.c.

Referenced by monitor_dial().

#define S_REPLACE s,
new_val   ) 
 

Value:

do {                            \
                if (s)                  \
                        free(s);        \
                s = (new_val);          \
        } while (0)

Definition at line 151 of file dial.c.

Referenced by begin_dial().


Typedef Documentation

typedef int(* ast_dial_option_cb_disable)(void *data)
 

Typedef for dial option disable.

Definition at line 71 of file dial.c.

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

Typedef for dial option enable.

Definition at line 68 of file dial.c.


Function Documentation

static int answer_exec_disable void *  data  )  [static]
 

Definition at line 106 of file dial.c.

References answer_exec_struct::args, and free.

00107 {
00108    struct answer_exec_struct *answer_exec = data;
00109 
00110    /* Make sure we have a value */
00111    if (!answer_exec)
00112       return -1;
00113 
00114    /* If arguments are present, free them too */
00115    if (answer_exec->args)
00116       free(answer_exec->args);
00117 
00118    /* This is simple - just free the structure */
00119    free(answer_exec);
00120 
00121    return 0;
00122 }

static void* answer_exec_enable void *  data  )  [static]
 

Definition at line 80 of file dial.c.

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

00081 {
00082    struct answer_exec_struct *answer_exec = NULL;
00083    char *app = ast_strdupa((char*)data), *args = NULL;
00084 
00085    /* Not giving any data to this option is bad, mmmk? */
00086    if (ast_strlen_zero(app))
00087       return NULL;
00088 
00089    /* Create new data structure */
00090    if (!(answer_exec = ast_calloc(1, sizeof(*answer_exec))))
00091       return NULL;
00092    
00093    /* Parse out application and arguments */
00094    if ((args = strchr(app, '|'))) {
00095       *args++ = '\0';
00096       answer_exec->args = ast_strdup(args);
00097    }
00098 
00099    /* Copy application name */
00100    ast_copy_string(answer_exec->app, app, sizeof(answer_exec->app));
00101 
00102    return answer_exec;
00103 }

static void answer_exec_run struct ast_channel chan,
char *  app,
char *  args
[static]
 

Definition at line 125 of file dial.c.

References pbx_exec(), and pbx_findapp().

Referenced by monitor_dial().

00126 {
00127    struct ast_app *ast_app = pbx_findapp(app);
00128 
00129    /* If the application was not found, return immediately */
00130    if (!ast_app)
00131       return;
00132 
00133    /* All is well... execute the application */
00134    pbx_exec(chan, ast_app, args);
00135 
00136    return;
00137 }

struct ast_channel* ast_dial_answered struct ast_dial dial  ) 
 

Return channel that answered.

Note:
Returns the Asterisk channel that answered
Parameters:
dial Dialing structure

Definition at line 563 of file dial.c.

References AST_DIAL_RESULT_ANSWERED, AST_LIST_FIRST, and ast_dial::status.

00564 {
00565    if (!dial)
00566       return NULL;
00567 
00568    return ((dial->status == AST_DIAL_RESULT_ANSWERED) ? AST_LIST_FIRST(&dial->channels)->owner : NULL);
00569 }

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 192 of file dial.c.

References ast_calloc, AST_LIST_INSERT_TAIL, and ast_dial::num.

00193 {
00194    struct ast_dial_channel *channel = NULL;
00195 
00196    /* Make sure we have required arguments */
00197    if (!dial || !tech || !device)
00198       return -1;
00199 
00200    /* Allocate new memory for dialed channel structure */
00201    if (!(channel = ast_calloc(1, sizeof(*channel))))
00202       return -1;
00203 
00204    /* Record technology and device for when we actually dial */
00205    channel->tech = tech;
00206    channel->device = device;
00207 
00208    /* Grab reference number from dial structure */
00209    channel->num = ast_atomic_fetchadd_int(&dial->num, +1);
00210 
00211    /* Insert into channels list */
00212    AST_LIST_INSERT_TAIL(&dial->channels, channel, list);
00213 
00214    return channel->num;
00215 }

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 171 of file dial.c.

References ast_calloc, AST_LIST_HEAD_INIT_NOLOCK, and AST_PTHREADT_NULL.

00172 {
00173    struct ast_dial *dial = NULL;
00174 
00175    /* Allocate new memory for structure */
00176    if (!(dial = ast_calloc(1, sizeof(*dial))))
00177       return NULL;
00178 
00179    /* Initialize list of channels */
00180    AST_LIST_HEAD_INIT_NOLOCK(&dial->channels);
00181 
00182    /* Initialize thread to NULL */
00183    dial->thread = AST_PTHREADT_NULL;
00184 
00185    return dial;
00186 }

int ast_dial_destroy struct ast_dial dial  ) 
 

Destroys a dialing structure.

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

Definition at line 636 of file dial.c.

References AST_DIAL_OPTION_MAX, ast_hangup(), AST_LIST_TRAVERSE, option_types, ast_dial_channel::options, and ast_dial_channel::owner.

00637 {
00638    int i = 0;
00639    struct ast_dial_channel *channel = NULL;
00640 
00641    if (!dial)
00642       return -1;
00643    
00644    /* Hangup and deallocate all the dialed channels */
00645    AST_LIST_TRAVERSE(&dial->channels, channel, list) {
00646       /* Disable any enabled options */
00647       for (i = 0; i < AST_DIAL_OPTION_MAX; i++) {
00648          if (!channel->options[i])
00649             continue;
00650          if (option_types[i].disable)
00651             option_types[i].disable(channel->options[i]);
00652          channel->options[i] = NULL;
00653       }
00654       /* Hang up channel if need be */
00655       if (channel->owner) {
00656          ast_hangup(channel->owner);
00657          channel->owner = NULL;
00658       }
00659       /* Free structure */
00660       free(channel);
00661    }
00662        
00663    /* Disable any enabled options globally */
00664    for (i = 0; i < AST_DIAL_OPTION_MAX; i++) {
00665       if (!dial->options[i])
00666          continue;
00667       if (option_types[i].disable)
00668          option_types[i].disable(dial->options[i]);
00669       dial->options[i] = NULL;
00670    }
00671 
00672    /* Free structure */
00673    free(dial);
00674 
00675    return 0;
00676 }

void ast_dial_hangup struct ast_dial dial  ) 
 

Hangup channels.

Note:
Hangup all active channels
Parameters:
dial Dialing structure

Definition at line 614 of file dial.c.

References ast_hangup(), AST_LIST_TRAVERSE, and ast_dial_channel::owner.

Referenced by ast_dial_run().

00615 {
00616    struct ast_dial_channel *channel = NULL;
00617 
00618    if (!dial)
00619       return;
00620    
00621    AST_LIST_TRAVERSE(&dial->channels, channel, list) {
00622       if (channel->owner) {
00623          ast_hangup(channel->owner);
00624          channel->owner = NULL;
00625       }
00626    }
00627 
00628    return;
00629 }

enum ast_dial_result ast_dial_join struct ast_dial dial  ) 
 

Cancel async thread.

Note:
Cancel a running async thread
Parameters:
dial Dialing structure

Definition at line 584 of file dial.c.

References AST_DIAL_RESULT_FAILED, AST_PTHREADT_NULL, AST_PTHREADT_STOP, and ast_dial::status.

00585 {
00586    pthread_t thread;
00587 
00588    /* If the dial structure is not running in async, return failed */
00589    if (dial->thread == AST_PTHREADT_NULL)
00590       return AST_DIAL_RESULT_FAILED;
00591 
00592    /* Record thread */
00593    thread = dial->thread;
00594 
00595    /* Stop the thread */
00596    dial->thread = AST_PTHREADT_STOP;
00597 
00598    /* Now we signal it with SIGURG so it will break out of it's waitfor */
00599    pthread_kill(thread, SIGURG);
00600 
00601    /* Finally wait for the thread to exit */
00602    pthread_join(thread, NULL);
00603 
00604    /* Yay thread is all gone */
00605    dial->thread = AST_PTHREADT_NULL;
00606 
00607    return dial->status;
00608 }

int ast_dial_option_disable struct ast_dial dial,
int  num,
enum ast_dial_option  option
 

Disables an option per channel.

Parameters:
dial Dial structure
num Channel number to disable option on
option Option to disable
Returns:
Returns 0 on success, -1 on failure

Definition at line 768 of file dial.c.

References AST_LIST_EMPTY, AST_LIST_LAST, AST_LIST_TRAVERSE, ast_option_types::disable, ast_dial_channel::num, option_types, and ast_dial_channel::options.

00769 {
00770    struct ast_dial_channel *channel = NULL;
00771 
00772    /* Ensure we have required arguments */
00773    if (!dial || AST_LIST_EMPTY(&dial->channels))
00774       return -1;
00775 
00776    /* Look for channel, we can sort of cheat and predict things - the last channel in the list will probably be what they want */
00777    if (AST_LIST_LAST(&dial->channels)->num != num) {
00778       AST_LIST_TRAVERSE(&dial->channels, channel, list) {
00779          if (channel->num == num)
00780             break;
00781       }
00782    } else {
00783       channel = AST_LIST_LAST(&dial->channels);
00784    }
00785 
00786    /* If none found, return failure */
00787    if (!channel)
00788       return -1;
00789 
00790    /* If the option is not enabled, return failure */
00791    if (!channel->options[option])
00792       return -1;
00793 
00794    /* Execute callback of option to disable it if it exists */
00795    if (option_types[option].disable)
00796       option_types[option].disable(channel->options[option]);
00797 
00798    /* Finally disable the option on the structure */
00799    channel->options[option] = NULL;
00800 
00801    return 0;
00802 }

int ast_dial_option_enable struct ast_dial dial,
int  num,
enum ast_dial_option  option,
void *  data
 

Enables an option per channel.

Parameters:
dial Dial structure
num Channel number to enable option on
option Option to enable
data Data to pass to this option (not always needed)
Returns:
Returns 0 on success, -1 on failure

Definition at line 706 of file dial.c.

References AST_LIST_EMPTY, AST_LIST_LAST, AST_LIST_TRAVERSE, ast_option_types::enable, ast_dial_channel::num, option_types, and ast_dial_channel::options.

00707 {
00708    struct ast_dial_channel *channel = NULL;
00709 
00710    /* Ensure we have required arguments */
00711    if (!dial || AST_LIST_EMPTY(&dial->channels))
00712       return -1;
00713    
00714    /* Look for channel, we can sort of cheat and predict things - the last channel in the list will probably be what they want */
00715    if (AST_LIST_LAST(&dial->channels)->num != num) {
00716       AST_LIST_TRAVERSE(&dial->channels, channel, list) {
00717          if (channel->num == num)
00718             break;
00719       }
00720    } else {
00721       channel = AST_LIST_LAST(&dial->channels);
00722    }
00723 
00724    /* If none found, return failure */
00725    if (!channel)
00726       return -1;
00727 
00728    /* If the option is already enabled, return failure */
00729    if (channel->options[option])
00730       return -1;
00731 
00732         /* Execute enable callback if it exists, if not simply make sure the value is set */
00733    if (option_types[option].enable)
00734       channel->options[option] = option_types[option].enable(data);
00735    else
00736       channel->options[option] = (void*)1;
00737 
00738    return 0;
00739 }

int ast_dial_option_global_disable struct ast_dial dial,
enum ast_dial_option  option
 

Disables an option globally.

Parameters:
dial Dial structure to disable option on
option Option to disable
Returns:
Returns 0 on success, -1 on failure

Definition at line 746 of file dial.c.

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

00747 {
00748         /* If the option is not enabled, return failure */
00749         if (!dial->options[option])
00750                 return -1;
00751 
00752    /* Execute callback of option to disable if it exists */
00753    if (option_types[option].disable)
00754       option_types[option].disable(dial->options[option]);
00755 
00756    /* Finally disable option on the structure */
00757    dial->options[option] = NULL;
00758 
00759         return 0;
00760 }

int ast_dial_option_global_enable struct ast_dial dial,
enum ast_dial_option  option,
void *  data
 

Enables an option globally.

Parameters:
dial Dial structure to enable option on
option Option to enable
data Data to pass to this option (not always needed)
Returns:
Returns 0 on success, -1 on failure

Definition at line 684 of file dial.c.

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

00685 {
00686    /* If the option is already enabled, return failure */
00687    if (dial->options[option])
00688       return -1;
00689 
00690    /* Execute enable callback if it exists, if not simply make sure the value is set */
00691    if (option_types[option].enable)
00692       dial->options[option] = option_types[option].enable(data);
00693    else
00694       dial->options[option] = (void*)1;
00695 
00696    return 0;
00697 }

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 528 of file dial.c.

References 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(), and monitor_dial().

00529 {
00530    enum ast_dial_result res = AST_DIAL_RESULT_TRYING;
00531 
00532    /* Ensure required arguments are passed */
00533    if (!dial || !chan)
00534       return AST_DIAL_RESULT_INVALID;
00535 
00536    /* If there are no channels to dial we can't very well try to dial them */
00537    if (AST_LIST_EMPTY(&dial->channels))
00538       return AST_DIAL_RESULT_INVALID;
00539 
00540    /* Dial each requested channel */
00541    if (!begin_dial(dial, chan))
00542       return AST_DIAL_RESULT_FAILED;
00543 
00544    /* If we are running async spawn a thread and send it away... otherwise block here */
00545    if (async) {
00546       /* Try to create a thread */
00547       if (ast_pthread_create(&dial->thread, NULL, async_dial, dial)) {
00548          /* Failed to create the thread - hangup all dialed channels and return failed */
00549          ast_dial_hangup(dial);
00550          res = AST_DIAL_RESULT_FAILED;
00551       }
00552    } else {
00553       res = monitor_dial(dial, chan);
00554    }
00555 
00556    return res;
00557 }

enum ast_dial_result ast_dial_status struct ast_dial dial  ) 
 

Return status of dial.

Note:
Returns the status of the dial attempt
Parameters:
dial Dialing structure

Definition at line 575 of file dial.c.

References ast_dial::status.

00576 {
00577    return dial->status;
00578 }

static void* async_dial void *  data  )  [static]
 

Dial async thread function.

Definition at line 514 of file dial.c.

References monitor_dial().

Referenced by ast_dial_run().

00515 {
00516    struct ast_dial *dial = data;
00517 
00518    /* This is really really simple... we basically pass monitor_dial a NULL owner and it changes it's behavior */
00519    monitor_dial(dial, NULL);
00520 
00521    return NULL;
00522 }

static int begin_dial struct ast_dial dial,
struct ast_channel chan
[static]
 

Helper function that does the beginning dialing.

Definition at line 218 of file dial.c.

References accountcode, ast_channel::adsicpe, ast_channel::appl, ast_call(), ast_channel_inherit_variables(), ast_hangup(), AST_LIST_TRAVERSE, AST_MAX_EXTENSION, ast_request(), ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_verbose(), ast_dial_channel::cause, ast_channel::cdrflags, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, ast_callerid::cid_tns, ast_callerid::cid_ton, ast_channel::data, ast_dial_channel::device, language, musicclass, ast_channel::nativeformats, option_verbose, ast_dial_channel::owner, S_REPLACE, ast_dial_channel::tech, ast_channel::transfercapability, VERBOSE_PREFIX_3, and ast_channel::whentohangup.

Referenced by ast_dial_run().

00219 {
00220    struct ast_dial_channel *channel = NULL;
00221    int success = 0, res = 0;
00222 
00223    /* Iterate through channel list, requesting and calling each one */
00224    AST_LIST_TRAVERSE(&dial->channels, channel, list) {
00225       char numsubst[AST_MAX_EXTENSION];
00226 
00227       /* Copy device string over */
00228       ast_copy_string(numsubst, channel->device, sizeof(numsubst));
00229 
00230       /* Request that the channel be created */
00231       if (!(channel->owner = ast_request(channel->tech, chan->nativeformats, numsubst, &channel->cause)))
00232          continue;
00233 
00234       channel->owner->appl = "AppDial2";
00235                 channel->owner->data = "(Outgoing Line)";
00236                 channel->owner->whentohangup = 0;
00237 
00238       /* Inherit everything from he who spawned this Dial */
00239       ast_channel_inherit_variables(chan, channel->owner);
00240 
00241       /* Copy over callerid information */
00242       S_REPLACE(channel->owner->cid.cid_num, ast_strdup(chan->cid.cid_num));
00243       S_REPLACE(channel->owner->cid.cid_name, ast_strdup(chan->cid.cid_name));
00244       S_REPLACE(channel->owner->cid.cid_ani, ast_strdup(chan->cid.cid_ani));
00245       S_REPLACE(channel->owner->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
00246 
00247       ast_string_field_set(channel->owner, language, chan->language);
00248       ast_string_field_set(channel->owner, accountcode, chan->accountcode);
00249       channel->owner->cdrflags = chan->cdrflags;
00250       if (ast_strlen_zero(channel->owner->musicclass))
00251          ast_string_field_set(channel->owner, musicclass, chan->musicclass);
00252 
00253       channel->owner->cid.cid_pres = chan->cid.cid_pres;
00254       channel->owner->cid.cid_ton = chan->cid.cid_ton;
00255       channel->owner->cid.cid_tns = chan->cid.cid_tns;
00256       channel->owner->adsicpe = chan->adsicpe;
00257       channel->owner->transfercapability = chan->transfercapability;
00258 
00259       /* Actually call the device */
00260       if ((res = ast_call(channel->owner, numsubst, 0))) {
00261          ast_hangup(channel->owner);
00262          channel->owner = NULL;
00263       } else {
00264          success++;
00265          if (option_verbose > 2)
00266             ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", numsubst);
00267       }
00268    }
00269 
00270    /* If number of failures matches the number of channels, then this truly failed */
00271    return success;
00272 }

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 275 of file dial.c.

References AST_LIST_TRAVERSE, and ast_dial_channel::owner.

Referenced by monitor_dial().

00276 {
00277    struct ast_dial_channel *channel = NULL;
00278 
00279    AST_LIST_TRAVERSE(&dial->channels, channel, list) {
00280       if (channel->owner == owner)
00281          break;
00282    }
00283 
00284    return channel;
00285 }

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 288 of file dial.c.

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_DIAL_RESULT_ANSWERED, AST_FRAME_CONTROL, ast_hangup(), ast_indicate(), AST_LIST_INSERT_HEAD, AST_LIST_REMOVE, ast_verbose(), ast_frame::frametype, option_verbose, ast_dial_channel::owner, ast_dial::status, ast_frame::subclass, and VERBOSE_PREFIX_3.

Referenced by monitor_dial(), and socket_read().

00289 {
00290    if (fr->frametype == AST_FRAME_CONTROL) {
00291       switch (fr->subclass) {
00292       case AST_CONTROL_ANSWER:
00293          if (option_verbose > 2)
00294             ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", channel->owner->name, chan->name);
00295          AST_LIST_REMOVE(&dial->channels, channel, list);
00296          AST_LIST_INSERT_HEAD(&dial->channels, channel, list);
00297          dial->status = AST_DIAL_RESULT_ANSWERED;
00298          break;
00299       case AST_CONTROL_BUSY:
00300          if (option_verbose > 2)
00301             ast_verbose(VERBOSE_PREFIX_3 "%s is busy\n", channel->owner->name);
00302          ast_hangup(channel->owner);
00303          channel->owner = NULL;
00304          break;
00305       case AST_CONTROL_CONGESTION:
00306          if (option_verbose > 2)
00307             ast_verbose(VERBOSE_PREFIX_3 "%s is circuit-busy\n", channel->owner->name);
00308          ast_hangup(channel->owner);
00309          channel->owner = NULL;
00310          break;
00311       case AST_CONTROL_RINGING:
00312          if (option_verbose > 2)
00313             ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", channel->owner->name);
00314          ast_indicate(chan, AST_CONTROL_RINGING);
00315          break;
00316       case AST_CONTROL_PROGRESS:
00317          if (option_verbose > 2)
00318             ast_verbose (VERBOSE_PREFIX_3 "%s is making progress, passing it to %s\n", channel->owner->name, chan->name);
00319          ast_indicate(chan, AST_CONTROL_PROGRESS);
00320          break;
00321       case AST_CONTROL_VIDUPDATE:
00322          if (option_verbose > 2)
00323             ast_verbose (VERBOSE_PREFIX_3 "%s requested a video update, passing it to %s\n", channel->owner->name, chan->name);
00324          ast_indicate(chan, AST_CONTROL_VIDUPDATE);
00325          break;
00326       case AST_CONTROL_PROCEEDING:
00327          if (option_verbose > 2)
00328             ast_verbose (VERBOSE_PREFIX_3 "%s is proceeding, passing it to %s\n", channel->owner->name, chan->name);
00329          ast_indicate(chan, AST_CONTROL_PROCEEDING);
00330          break;
00331       case AST_CONTROL_HOLD:
00332          if (option_verbose > 2)
00333             ast_verbose(VERBOSE_PREFIX_3 "Call on %s placed on hold\n", chan->name);
00334          ast_indicate(chan, AST_CONTROL_HOLD);
00335          break;
00336       case AST_CONTROL_UNHOLD:
00337          if (option_verbose > 2)
00338             ast_verbose(VERBOSE_PREFIX_3 "Call on %s left from hold\n", chan->name);
00339          ast_indicate(chan, AST_CONTROL_UNHOLD);
00340          break;
00341       case AST_CONTROL_OFFHOOK:
00342       case AST_CONTROL_FLASH:
00343          break;
00344       case -1:
00345          /* Prod the channel */
00346          ast_indicate(chan, -1);
00347          break;
00348       default:
00349          break;
00350       }
00351    }
00352 
00353    return;
00354 }

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 357 of file dial.c.

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_PROCEEDING,