Sat Mar 26 11:19:57 2011

Asterisk developer's documentation


features.h File Reference

Call Parking and Pickup API Includes code and algorithms from the Zapata library. More...

#include "asterisk/pbx.h"
#include "asterisk/linkedlists.h"

Include dependency graph for features.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_call_feature

Defines

#define AST_FEATURE_RETURN_HANGUP   -1
#define AST_FEATURE_RETURN_KEEPTRYING   24
#define AST_FEATURE_RETURN_NO_HANGUP_PEER   AST_PBX_NO_HANGUP_PEER
#define AST_FEATURE_RETURN_PARKFAILED   25
#define AST_FEATURE_RETURN_PASSDIGITS   21
#define AST_FEATURE_RETURN_PBX_KEEPALIVE   AST_PBX_KEEPALIVE
#define AST_FEATURE_RETURN_STOREDIGITS   22
#define AST_FEATURE_RETURN_SUCCESS   23
#define AST_FEATURE_RETURN_SUCCESSBREAK   0
#define DEFAULT_PARKINGLOT   "default"
#define FEATURE_APP_ARGS_LEN   256
#define FEATURE_APP_LEN   64
#define FEATURE_EXTEN_LEN   32
#define FEATURE_MAX_LEN   11
#define FEATURE_MOH_LEN   80
#define FEATURE_SENSE_CHAN   (1 << 0)
#define FEATURE_SENSE_PEER   (1 << 1)
#define FEATURE_SNAME_LEN   32
#define PARK_APP_NAME   "Park"

Typedefs

typedef int(* ast_feature_operation )(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data)

Enumerations

enum  {
  AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0), AST_FEATURE_FLAG_ONPEER = (1 << 1), AST_FEATURE_FLAG_ONSELF = (1 << 2), AST_FEATURE_FLAG_BYCALLEE = (1 << 3),
  AST_FEATURE_FLAG_BYCALLER = (1 << 4), AST_FEATURE_FLAG_BYBOTH = (3 << 3)
}
 main call feature structure More...

Functions

int ast_bridge_call (struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config)
 Bridge a call, optionally allowing redirection.
int ast_bridge_timelimit (struct ast_channel *chan, struct ast_bridge_config *config, char *parse, struct timeval *calldurationlimit)
 parse L option and read associated channel variables to set warning, warning frequency, and timelimit
int ast_feature_detect (struct ast_channel *chan, struct ast_flags *features, const char *code, struct ast_call_feature *feature)
 detect a feature before bridging
int ast_features_reload (void)
 Reload call features from features.conf.
struct ast_call_feature * ast_find_call_feature (const char *name)
 look for a call feature entry by its sname
int ast_masq_park_call (struct ast_channel *rchan, struct ast_channel *host, int timeout, int *extout)
 Park a call via a masqueraded channel.
int ast_park_call (struct ast_channel *chan, struct ast_channel *host, int timeout, const char *parkexten, int *extout)
 Park a call and read back parked location.
int ast_parking_ext_valid (const char *exten_str, struct ast_channel *chan, const char *context)
 Determine if parking extension exists in a given context.
int ast_pickup_call (struct ast_channel *chan)
 Pickup a call.
const char * ast_pickup_ext (void)
 Determine system call pickup extension.
void ast_rdlock_call_features (void)
void ast_register_feature (struct ast_call_feature *feature)
 register new feature into feature_set
void ast_unlock_call_features (void)
void ast_unregister_feature (struct ast_call_feature *feature)
 unregister feature from feature_set


Detailed Description

Call Parking and Pickup API Includes code and algorithms from the Zapata library.

Definition in file features.h.


Define Documentation

#define AST_FEATURE_RETURN_HANGUP   -1

Definition at line 40 of file features.h.

Referenced by builtin_disconnect().

#define AST_FEATURE_RETURN_KEEPTRYING   24

Definition at line 47 of file features.h.

Referenced by feature_exec_app(), and feature_interpret_helper().

#define AST_FEATURE_RETURN_NO_HANGUP_PEER   AST_PBX_NO_HANGUP_PEER

Definition at line 43 of file features.h.

#define AST_FEATURE_RETURN_PARKFAILED   25

Definition at line 48 of file features.h.

Referenced by builtin_blindtransfer(), and masq_park_call().

#define AST_FEATURE_RETURN_PASSDIGITS   21

Definition at line 44 of file features.h.

Referenced by ast_bridge_call(), and feature_interpret_helper().

#define AST_FEATURE_RETURN_PBX_KEEPALIVE   AST_PBX_KEEPALIVE

Definition at line 42 of file features.h.

#define AST_FEATURE_RETURN_STOREDIGITS   22

Definition at line 45 of file features.h.

Referenced by detect_disconnect(), and feature_interpret_helper().

#define AST_FEATURE_RETURN_SUCCESS   23

#define AST_FEATURE_RETURN_SUCCESSBREAK   0

Definition at line 41 of file features.h.

Referenced by feature_exec_app().

#define DEFAULT_PARKINGLOT   "default"

Default parking lot

Definition at line 38 of file features.h.

Referenced by load_config(), and reload_config().

#define FEATURE_APP_ARGS_LEN   256

Definition at line 32 of file features.h.

Referenced by load_config().

#define FEATURE_APP_LEN   64

Definition at line 31 of file features.h.

Referenced by load_config().

#define FEATURE_EXTEN_LEN   32

Definition at line 34 of file features.h.

Referenced by load_config().

#define FEATURE_MAX_LEN   11

Definition at line 30 of file features.h.

Referenced by ast_bridge_call(), and wait_for_answer().

#define FEATURE_MOH_LEN   80

Definition at line 35 of file features.h.

Referenced by load_config().

#define FEATURE_SENSE_CHAN   (1 << 0)

Definition at line 50 of file features.h.

Referenced by ast_bridge_call(), feature_exec_app(), and feature_interpret().

#define FEATURE_SENSE_PEER   (1 << 1)

Definition at line 51 of file features.h.

Referenced by ast_bridge_call(), and set_peers().

#define FEATURE_SNAME_LEN   32

Definition at line 33 of file features.h.

Referenced by load_config().

#define PARK_APP_NAME   "Park"

Definition at line 37 of file features.h.

Referenced by ast_parking_ext_valid(), and handle_exec().


Typedef Documentation

typedef int(* ast_feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data)

Definition at line 53 of file features.h.


Enumeration Type Documentation

anonymous enum

main call feature structure

Enumerator:
AST_FEATURE_FLAG_NEEDSDTMF 
AST_FEATURE_FLAG_ONPEER 
AST_FEATURE_FLAG_ONSELF 
AST_FEATURE_FLAG_BYCALLEE 
AST_FEATURE_FLAG_BYCALLER 
AST_FEATURE_FLAG_BYBOTH 

Definition at line 57 of file features.h.

00057      {
00058    AST_FEATURE_FLAG_NEEDSDTMF = (1 << 0),
00059    AST_FEATURE_FLAG_ONPEER =    (1 << 1),
00060    AST_FEATURE_FLAG_ONSELF =    (1 << 2),
00061    AST_FEATURE_FLAG_BYCALLEE =  (1 << 3),
00062    AST_FEATURE_FLAG_BYCALLER =  (1 << 4),
00063    AST_FEATURE_FLAG_BYBOTH  =   (3 << 3),
00064 };


Function Documentation

int ast_bridge_call ( struct ast_channel *  chan,
struct ast_channel *  peer,
struct ast_bridge_config *  config 
)

Bridge a call, optionally allowing redirection.

Bridge a call, optionally allowing redirection.

Parameters:
chan,peer,config Set start time, check for two channels,check if monitor on check for feature activation, create new CDR
Return values:
res on success.
-1 on failure to bridge.

append the event to featurecode. we rely on the string being zero-filled, and not overflowing it.

Todo:
XXX how do we guarantee the latter ?

Definition at line 3079 of file features.c.

References ast_channel::_state, ast_cdr::accountcode, ast_channel::accountcode, add_features_datastores(), ast_channel::amaflags, ast_cdr::amaflags, ast_cdr::answer, ast_channel::appl, AST_BRIDGE_RETRY, ast_bridged_channel(), ast_cdr_alloc(), ast_cdr_answer(), AST_CDR_ANSWERED, ast_cdr_appenduserfield(), ast_cdr_detach(), ast_cdr_discard(), ast_cdr_dup_unique_swap(), ast_cdr_end(), AST_CDR_FLAG_BRIDGED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_MAIN, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, ast_cdr_setaccount(), ast_cdr_setanswer(), ast_cdr_setcid(), ast_cdr_setdisposition(), ast_cdr_setuserfield(), ast_cdr_specialized_reset(), ast_cdr_start(), ast_cdr_update(), AST_CEL_BRIDGE_END, AST_CEL_BRIDGE_START, ast_cel_report_event(), ast_channel_bridge(), ast_channel_connected_line_macro(), ast_channel_get_by_name(), ast_channel_lock, ast_channel_log(), ast_channel_redirecting_macro(), ast_channel_set_linkgroup(), ast_channel_setoption(), ast_channel_unlock, ast_channel_unref, ast_check_hangup(), ast_clear_flag, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OPTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_copy_string(), ast_debug, ast_default_amaflags, ast_dtmf_stream(), ast_exists_extension(), AST_FEATURE_NO_H_EXTEN, AST_FEATURE_RETURN_PASSDIGITS, AST_FEATURE_RETURN_SUCCESS, AST_FEATURE_WARNING_ACTIVE, AST_FLAG_BRIDGE_HANGUP_DONT, AST_FLAG_BRIDGE_HANGUP_RUN, AST_FLAG_IN_AUTOLOOP, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_free, ast_frfree, ast_indicate(), ast_indicate_data(), ast_log(), ast_opt_end_cdr_before_h_exten, AST_OPTION_FLAG_REQUEST, ast_raw_answer(), ast_set2_flag, ast_set_flag, ast_spawn_extension(), AST_STATE_RINGING, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_verb, ast_channel::caller, ast_channel::cdr, ast_cdr::channel, ast_channel::context, ast_option_header::data, ast_frame::data, ast_channel::data, ast_frame::datalen, ast_cdr::dcontext, ast_cdr::disposition, ast_cdr::dst, ast_cdr::dstchannel, ast_bridge_config::end_bridge_callback, ast_bridge_config::end_bridge_callback_data, ast_channel::exten, f, feature_interpret(), FEATURE_MAX_LEN, FEATURE_SENSE_CHAN, FEATURE_SENSE_PEER, ast_bridge_config::feature_start_time, ast_bridge_config::feature_timer, featuredigittimeout, ast_bridge_config::features_caller, ast_frame::frametype, ast_party_caller::id, ast_frame_subclass::integer, ast_cdr::lastapp, ast_cdr::lastdata, LOG_WARNING, monitor_app, monitor_ok, ast_channel::name, ast_cdr::next, ast_party_id::number, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), pbx_exec(), pbx_findapp(), pick_unlocked_cdr(), ast_channel::priority, ast_frame::ptr, S_COR, S_OR, set_bridge_features_on_config(), set_config_flags(), ast_cdr::start, ast_party_number::str, ast_frame::subclass, ast_bridge_config::timelimit, ast_channel::uniqueid, ast_cdr::uniqueid, ast_cdr::userfield, ast_party_number::valid, and ast_channel::visible_indication.

Referenced by app_exec(), bridge_call_thread(), bridge_exec(), builtin_atxfer(), dial_exec_full(), park_exec_full(), and try_calling().

03080 {
03081    /* Copy voice back and forth between the two channels.  Give the peer
03082       the ability to transfer calls with '#<extension' syntax. */
03083    struct ast_frame *f;
03084    struct ast_channel *who;
03085    char chan_featurecode[FEATURE_MAX_LEN + 1]="";
03086    char peer_featurecode[FEATURE_MAX_LEN + 1]="";
03087    char orig_channame[AST_MAX_EXTENSION];
03088    char orig_peername[AST_MAX_EXTENSION];
03089    int res;
03090    int diff;
03091    int hasfeatures=0;
03092    int hadfeatures=0;
03093    int autoloopflag;
03094    struct ast_option_header *aoh;
03095    struct ast_cdr *bridge_cdr = NULL;
03096    struct ast_cdr *orig_peer_cdr = NULL;
03097    struct ast_cdr *chan_cdr = chan->cdr; /* the proper chan cdr, if there are forked cdrs */
03098    struct ast_cdr *peer_cdr = peer->cdr; /* the proper chan cdr, if there are forked cdrs */
03099    struct ast_cdr *new_chan_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */
03100    struct ast_cdr *new_peer_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */
03101 
03102    if (chan && peer) {
03103       pbx_builtin_setvar_helper(chan, "BRIDGEPEER", peer->name);
03104       pbx_builtin_setvar_helper(peer, "BRIDGEPEER", chan->name);
03105    } else if (chan) {
03106       pbx_builtin_setvar_helper(chan, "BLINDTRANSFER", NULL);
03107    }
03108 
03109    set_bridge_features_on_config(config, pbx_builtin_getvar_helper(chan, "BRIDGE_FEATURES"));
03110    add_features_datastores(chan, peer, config);
03111 
03112    /* This is an interesting case.  One example is if a ringing channel gets redirected to
03113     * an extension that picks up a parked call.  This will make sure that the call taken
03114     * out of parking gets told that the channel it just got bridged to is still ringing. */
03115    if (chan->_state == AST_STATE_RINGING && peer->visible_indication != AST_CONTROL_RINGING) {
03116       ast_indicate(peer, AST_CONTROL_RINGING);
03117    }
03118 
03119    if (monitor_ok) {
03120       const char *monitor_exec;
03121       struct ast_channel *src = NULL;
03122       if (!monitor_app) {
03123          if (!(monitor_app = pbx_findapp("Monitor")))
03124             monitor_ok=0;
03125       }
03126       if ((monitor_exec = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR"))) 
03127          src = chan;
03128       else if ((monitor_exec = pbx_builtin_getvar_helper(peer, "AUTO_MONITOR")))
03129          src = peer;
03130       if (monitor_app && src) {
03131          char *tmp = ast_strdupa(monitor_exec);
03132          pbx_exec(src, monitor_app, tmp);
03133       }
03134    }
03135 
03136    set_config_flags(chan, peer, config);
03137 
03138    /* Answer if need be */
03139    if (chan->_state != AST_STATE_UP) {
03140       if (ast_raw_answer(chan, 1)) {
03141          return -1;
03142       }
03143    }
03144 
03145 #ifdef FOR_DEBUG
03146    /* show the two channels and cdrs involved in the bridge for debug & devel purposes */
03147    ast_channel_log("Pre-bridge CHAN Channel info", chan);
03148    ast_channel_log("Pre-bridge PEER Channel info", peer);
03149 #endif
03150    /* two channels are being marked as linked here */
03151    ast_channel_set_linkgroup(chan,peer);
03152 
03153    /* copy the userfield from the B-leg to A-leg if applicable */
03154    if (chan->cdr && peer->cdr && !ast_strlen_zero(peer->cdr->userfield)) {
03155       char tmp[256];
03156       if (!ast_strlen_zero(chan->cdr->userfield)) {
03157          snprintf(tmp, sizeof(tmp), "%s;%s", chan->cdr->userfield, peer->cdr->userfield);
03158          ast_cdr_appenduserfield(chan, tmp);
03159       } else
03160          ast_cdr_setuserfield(chan, peer->cdr->userfield);
03161       /* free the peer's cdr without ast_cdr_free complaining */
03162       ast_free(peer->cdr);
03163       peer->cdr = NULL;
03164    }
03165    ast_copy_string(orig_channame,chan->name,sizeof(orig_channame));
03166    ast_copy_string(orig_peername,peer->name,sizeof(orig_peername));
03167    orig_peer_cdr = peer_cdr;
03168    
03169    if (!chan_cdr || (chan_cdr && !ast_test_flag(chan_cdr, AST_CDR_FLAG_POST_DISABLED))) {
03170       
03171       if (chan_cdr) {
03172          ast_set_flag(chan_cdr, AST_CDR_FLAG_MAIN);
03173          ast_cdr_update(chan);
03174          bridge_cdr = ast_cdr_dup_unique_swap(chan_cdr);
03175          /* rip any forked CDR's off of the chan_cdr and attach
03176           * them to the bridge_cdr instead */
03177          bridge_cdr->next = chan_cdr->next;
03178          chan_cdr->next = NULL;
03179          ast_copy_string(bridge_cdr->lastapp, S_OR(chan->appl, ""), sizeof(bridge_cdr->lastapp));
03180          ast_copy_string(bridge_cdr->lastdata, S_OR(chan->data, ""), sizeof(bridge_cdr->lastdata));
03181          if (peer_cdr && !ast_strlen_zero(peer_cdr->userfield)) {
03182             ast_copy_string(bridge_cdr->userfield, peer_cdr->userfield, sizeof(bridge_cdr->userfield));
03183          }
03184          ast_cdr_setaccount(peer, chan->accountcode);
03185 
03186       } else {
03187          /* better yet, in a xfer situation, find out why the chan cdr got zapped (pun unintentional) */
03188          bridge_cdr = ast_cdr_alloc(); /* this should be really, really rare/impossible? */
03189          ast_copy_string(bridge_cdr->channel, chan->name, sizeof(bridge_cdr->channel));
03190          ast_copy_string(bridge_cdr->dstchannel, peer->name, sizeof(bridge_cdr->dstchannel));
03191          ast_copy_string(bridge_cdr->uniqueid, chan->uniqueid, sizeof(bridge_cdr->uniqueid));
03192          ast_copy_string(bridge_cdr->lastapp, S_OR(chan->appl, ""), sizeof(bridge_cdr->lastapp));
03193          ast_copy_string(bridge_cdr->lastdata, S_OR(chan->data, ""), sizeof(bridge_cdr->lastdata));
03194          ast_cdr_setcid(bridge_cdr, chan);
03195          bridge_cdr->disposition = (chan->_state == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NULL;
03196          bridge_cdr->amaflags = chan->amaflags ? chan->amaflags :  ast_default_amaflags;
03197          ast_copy_string(bridge_cdr->accountcode, chan->accountcode, sizeof(bridge_cdr->accountcode));
03198          /* Destination information */
03199          ast_copy_string(bridge_cdr->dst, chan->exten, sizeof(bridge_cdr->dst));
03200          ast_copy_string(bridge_cdr->dcontext, chan->context, sizeof(bridge_cdr->dcontext));
03201          if (peer_cdr) {
03202             bridge_cdr->start = peer_cdr->start;
03203             ast_copy_string(bridge_cdr->userfield, peer_cdr->userfield, sizeof(bridge_cdr->userfield));
03204          } else {
03205             ast_cdr_start(bridge_cdr);
03206          }
03207       }
03208       ast_debug(4,"bridge answer set, chan answer set\n");
03209       /* peer_cdr->answer will be set when a macro runs on the peer;
03210          in that case, the bridge answer will be delayed while the
03211          macro plays on the peer channel. The peer answered the call
03212          before the macro started playing. To the phone system,
03213          this is billable time for the call, even tho the caller
03214          hears nothing but ringing while the macro does its thing. */
03215 
03216       /* Another case where the peer cdr's time will be set, is when
03217          A self-parks by pickup up phone and dialing 700, then B
03218          picks up A by dialing its parking slot; there may be more 
03219          practical paths that get the same result, tho... in which
03220          case you get the previous answer time from the Park... which
03221          is before the bridge's start time, so I added in the 
03222          tvcmp check to the if below */
03223 
03224       if (peer_cdr && !ast_tvzero(peer_cdr->answer) && ast_tvcmp(peer_cdr->answer, bridge_cdr->start) >= 0) {
03225          ast_cdr_setanswer(bridge_cdr, peer_cdr->answer);
03226          ast_cdr_setdisposition(bridge_cdr, peer_cdr->disposition);
03227          if (chan_cdr) {
03228             ast_cdr_setanswer(chan_cdr, peer_cdr->answer);
03229             ast_cdr_setdisposition(chan_cdr, peer_cdr->disposition);
03230          }
03231       } else {
03232          ast_cdr_answer(bridge_cdr);
03233          if (chan_cdr) {
03234             ast_cdr_answer(chan_cdr); /* for the sake of cli status checks */
03235          }
03236       }
03237       if (ast_test_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT) && (chan_cdr || peer_cdr)) {
03238          if (chan_cdr) {
03239             ast_set_flag(chan_cdr, AST_CDR_FLAG_BRIDGED);
03240          }
03241          if (peer_cdr) {
03242             ast_set_flag(peer_cdr, AST_CDR_FLAG_BRIDGED);
03243          }
03244       }
03245       /* the DIALED flag may be set if a dialed channel is transfered
03246        * and then bridged to another channel.  In order for the
03247        * bridge CDR to be written, the DIALED flag must not be
03248        * present. */
03249       ast_clear_flag(bridge_cdr, AST_CDR_FLAG_DIALED);
03250    }
03251    ast_cel_report_event(chan, AST_CEL_BRIDGE_START, NULL, NULL, NULL);
03252    for (;;) {
03253       struct ast_channel *other; /* used later */
03254    
03255       res = ast_channel_bridge(chan, peer, config, &f, &who);
03256       
03257       /* When frame is not set, we are probably involved in a situation
03258          where we've timed out.
03259          When frame is set, we'll come this code twice; once for DTMF_BEGIN
03260          and also for DTMF_END. If we flow into the following 'if' for both, then 
03261          our wait times are cut in half, as both will subtract from the
03262          feature_timer. Not good!
03263       */
03264       if (config->feature_timer && (!f || f->frametype == AST_FRAME_DTMF_END)) {
03265          /* Update feature timer for next pass */
03266          diff = ast_tvdiff_ms(ast_tvnow(), config->feature_start_time);
03267          if (res == AST_BRIDGE_RETRY) {
03268             /* The feature fully timed out but has not been updated. Skip
03269              * the potential round error from the diff calculation and
03270              * explicitly set to expired. */
03271             config->feature_timer = -1;
03272          } else {
03273             config->feature_timer -= diff;
03274          }
03275 
03276          if (hasfeatures) {
03277             if (config->feature_timer <= 0) {
03278                /* Not *really* out of time, just out of time for
03279                   digits to come in for features. */
03280                ast_debug(1, "Timed out for feature!\n");
03281                if (!ast_strlen_zero(peer_featurecode)) {
03282                   ast_dtmf_stream(chan, peer, peer_featurecode, 0, 0);
03283                   memset(peer_featurecode, 0, sizeof(peer_featurecode));
03284                }
03285                if (!ast_strlen_zero(chan_featurecode)) {
03286                   ast_dtmf_stream(peer, chan, chan_featurecode, 0, 0);
03287                   memset(chan_featurecode, 0, sizeof(chan_featurecode));
03288                }
03289                if (f)
03290                   ast_frfree(f);
03291                hasfeatures = !ast_strlen_zero(chan_featurecode) || !ast_strlen_zero(peer_featurecode);
03292                if (!hasfeatures) {
03293                   /* No more digits expected - reset the timer */
03294                   config->feature_timer = 0;
03295                }
03296                hadfeatures = hasfeatures;
03297                /* Continue as we were */
03298                continue;
03299             } else if (!f) {
03300                /* The bridge returned without a frame and there is a feature in progress.
03301                 * However, we don't think the feature has quite yet timed out, so just
03302                 * go back into the bridge. */
03303                continue;
03304             }
03305          } else {
03306             if (config->feature_timer <=0) {
03307                /* We ran out of time */
03308                config->feature_timer = 0;
03309                who = chan;
03310                if (f)
03311                   ast_frfree(f);
03312                f = NULL;
03313                res = 0;
03314             }
03315          }
03316       }
03317       if (res < 0) {
03318          if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_test_flag(peer, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan) && !ast_check_hangup(peer)) {
03319             ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", chan->name, peer->name);
03320          }
03321          goto before_you_go;
03322       }
03323       
03324       if (!f || (f->frametype == AST_FRAME_CONTROL &&
03325             (f->subclass.integer == AST_CONTROL_HANGUP || f->subclass.integer == AST_CONTROL_BUSY ||
03326                f->subclass.integer == AST_CONTROL_CONGESTION))) {
03327          res = -1;
03328          break;
03329       }
03330       /* many things should be sent to the 'other' channel */
03331       other = (who == chan) ? peer : chan;
03332       if (f->frametype == AST_FRAME_CONTROL) {
03333          switch (f->subclass.integer) {
03334          case AST_CONTROL_RINGING:
03335          case AST_CONTROL_FLASH:
03336          case -1:
03337             ast_indicate(other, f->subclass.integer);
03338             break;
03339          case AST_CONTROL_CONNECTED_LINE:
03340             if (!ast_channel_connected_line_macro(who, other, f, who != chan, 1)) {
03341                break;
03342             }
03343             ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
03344             break;
03345          case AST_CONTROL_REDIRECTING:
03346             if (!ast_channel_redirecting_macro(who, other, f, who != chan, 1)) {
03347                break;
03348             }
03349             ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
03350             break;
03351          case AST_CONTROL_AOC:
03352          case AST_CONTROL_HOLD:
03353          case AST_CONTROL_UNHOLD:
03354             ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
03355             break;
03356          case AST_CONTROL_OPTION:
03357             aoh = f->data.ptr;
03358             /* Forward option Requests */
03359             if (aoh && aoh->flag == AST_OPTION_FLAG_REQUEST) {
03360                ast_channel_setoption(other, ntohs(aoh->option), aoh->data, 
03361                   f->datalen - sizeof(struct ast_option_header), 0);
03362             }
03363             break;
03364          }
03365       } else if (f->frametype == AST_FRAME_DTMF_BEGIN) {
03366          /* eat it */
03367       } else if (f->frametype == AST_FRAME_DTMF) {
03368          char *featurecode;
03369          int sense;
03370 
03371          hadfeatures = hasfeatures;
03372          /* This cannot overrun because the longest feature is one shorter than our buffer */
03373          if (who == chan) {
03374             sense = FEATURE_SENSE_CHAN;
03375             featurecode = chan_featurecode;
03376          } else  {
03377             sense = FEATURE_SENSE_PEER;
03378             featurecode = peer_featurecode;
03379          }
03380          /*! append the event to featurecode. we rely on the string being zero-filled, and
03381           * not overflowing it. 
03382           * \todo XXX how do we guarantee the latter ?
03383           */
03384          featurecode[strlen(featurecode)] = f->subclass.integer;
03385          /* Get rid of the frame before we start doing "stuff" with the channels */
03386          ast_frfree(f);
03387          f = NULL;
03388          config->feature_timer = 0;
03389          res = feature_interpret(chan, peer, config, featurecode, sense);
03390          switch(res) {
03391          case AST_FEATURE_RETURN_PASSDIGITS:
03392             ast_dtmf_stream(other, who, featurecode, 0, 0);
03393             /* Fall through */
03394          case AST_FEATURE_RETURN_SUCCESS:
03395             memset(featurecode, 0, sizeof(chan_featurecode));
03396             break;
03397          }
03398          if (res >= AST_FEATURE_RETURN_PASSDIGITS) {
03399             res = 0;
03400          } else {
03401             break;
03402          }
03403          hasfeatures = !ast_strlen_zero(chan_featurecode) || !ast_strlen_zero(peer_featurecode);
03404          if (hadfeatures && !hasfeatures) {
03405             /* Feature completed or timed out */
03406             config->feature_timer = 0;
03407          } else if (hasfeatures) {
03408             if (config->timelimit) {
03409                /* No warning next time - we are waiting for future */
03410                ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE);
03411             }
03412             config->feature_start_time = ast_tvnow();
03413             config->feature_timer = featuredigittimeout;
03414             ast_debug(1, "Set feature timer to %ld\n", config->feature_timer);
03415          }
03416       }
03417       if (f)
03418          ast_frfree(f);
03419 
03420    }
03421    ast_cel_report_event(chan, AST_CEL_BRIDGE_END, NULL, NULL, NULL);
03422    before_you_go:
03423 
03424    if (ast_test_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT)) {
03425       ast_clear_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT); /* its job is done */
03426       if (bridge_cdr) {
03427          ast_cdr_discard(bridge_cdr);
03428          /* QUESTION: should we copy bridge_cdr fields to the peer before we throw it away? */
03429       }
03430       return res; /* if we shouldn't do the h-exten, we shouldn't do the bridge cdr, either! */
03431    }
03432 
03433    if (config->end_bridge_callback) {
03434       config->end_bridge_callback(config->end_bridge_callback_data);
03435    }
03436 
03437    /* run the hangup exten on the chan object IFF it was NOT involved in a parking situation 
03438     * if it were, then chan belongs to a different thread now, and might have been hung up long
03439      * ago.
03440     */
03441    if (!ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN)
03442       && ast_exists_extension(chan, chan->context, "h", 1,
03443          S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
03444       struct ast_cdr *swapper = NULL;
03445       char savelastapp[AST_MAX_EXTENSION];
03446       char savelastdata[AST_MAX_EXTENSION];
03447       char save_exten[AST_MAX_EXTENSION];
03448       int  save_prio;
03449       int  found = 0;   /* set if we find at least one match */
03450       int  spawn_error = 0;
03451       
03452       autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
03453       ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
03454       if (bridge_cdr && ast_opt_end_cdr_before_h_exten) {
03455          ast_cdr_end(bridge_cdr);
03456       }
03457       /* swap the bridge cdr and the chan cdr for a moment, and let the endbridge
03458          dialplan code operate on it */
03459       ast_channel_lock(chan);
03460       if (bridge_cdr) {
03461          swapper = chan->cdr;
03462          ast_copy_string(savelastapp, bridge_cdr->lastapp, sizeof(bridge_cdr->lastapp));
03463          ast_copy_string(savelastdata, bridge_cdr->lastdata, sizeof(bridge_cdr->lastdata));
03464          chan->cdr = bridge_cdr;
03465       }
03466       ast_copy_string(save_exten, chan->exten, sizeof(save_exten));
03467       save_prio = chan->priority;
03468       ast_copy_string(chan->exten, "h", sizeof(chan->exten));
03469       chan->priority = 1;
03470       ast_channel_unlock(chan);
03471       while ((spawn_error = ast_spawn_extension(chan, chan->context, chan->exten,
03472          chan->priority,
03473          S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
03474          &found, 1)) == 0) {
03475          chan->priority++;
03476       }
03477       if (spawn_error
03478          && (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority,
03479             S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))
03480             || ast_check_hangup(chan))) {
03481          /* if the extension doesn't exist or a hangup occurred, this isn't really a spawn error */
03482          spawn_error = 0;
03483       }
03484       if (found && spawn_error) {
03485          /* Something bad happened, or a hangup has been requested. */
03486          ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
03487          ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
03488       }
03489       /* swap it back */
03490       ast_channel_lock(chan);
03491       ast_copy_string(chan->exten, save_exten, sizeof(chan->exten));
03492       chan->priority = save_prio;
03493       if (bridge_cdr) {
03494          if (chan->cdr == bridge_cdr) {
03495             chan->cdr = swapper;
03496          } else {
03497             bridge_cdr = NULL;
03498          }
03499       }
03500       if (!spawn_error) {
03501          ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN);
03502       }
03503       ast_channel_unlock(chan);
03504       /* protect the lastapp/lastdata against the effects of the hangup/dialplan code */
03505       if (bridge_cdr) {
03506          ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp));
03507          ast_copy_string(bridge_cdr->lastdata, savelastdata, sizeof(bridge_cdr->lastdata));
03508       }
03509       ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
03510    }
03511    
03512    /* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
03513    new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
03514    if (bridge_cdr && new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
03515       ast_set_flag(bridge_cdr, AST_CDR_FLAG_POST_DISABLED);
03516 
03517    /* we can post the bridge CDR at this point */
03518    if (bridge_cdr) {
03519       ast_cdr_end(bridge_cdr);
03520       ast_cdr_detach(bridge_cdr);
03521    }
03522    
03523    /* do a specialized reset on the beginning channel
03524       CDR's, if they still exist, so as not to mess up
03525       issues in future bridges;
03526       
03527       Here are the rules of the game:
03528       1. The chan and peer channel pointers will not change
03529          during the life of the bridge.
03530       2. But, in transfers, the channel names will change.
03531          between the time the bridge is started, and the
03532          time the channel ends. 
03533          Usually, when a channel changes names, it will
03534          also change CDR pointers.
03535       3. Usually, only one of the two channels (chan or peer)
03536          will change names.
03537       4. Usually, if a channel changes names during a bridge,
03538          it is because of a transfer. Usually, in these situations,
03539          it is normal to see 2 bridges running simultaneously, and
03540          it is not unusual to see the two channels that change
03541          swapped between bridges.
03542       5. After a bridge occurs, we have 2 or 3 channels' CDRs
03543          to attend to; if the chan or peer changed names,
03544          we have the before and after attached CDR's.
03545    */
03546 
03547    if (new_chan_cdr) {
03548       struct ast_channel *chan_ptr = NULL;
03549 
03550       if (strcasecmp(orig_channame, chan->name) != 0) { 
03551          /* old channel */
03552          if ((chan_ptr = ast_channel_get_by_name(orig_channame))) {
03553             ast_channel_lock(chan_ptr);
03554             if (!ast_bridged_channel(chan_ptr)) {
03555                struct ast_cdr *cur;
03556                for (cur = chan_ptr->cdr; cur; cur = cur->next) {
03557                   if (cur == chan_cdr) {
03558                      break;
03559                   }
03560                }
03561                if (cur) {
03562                   ast_cdr_specialized_reset(chan_cdr, 0);
03563                }
03564             }
03565             ast_channel_unlock(chan_ptr);
03566             chan_ptr = ast_channel_unref(chan_ptr);
03567          }
03568          /* new channel */
03569          ast_cdr_specialized_reset(new_chan_cdr, 0);
03570       } else {
03571          ast_cdr_specialized_reset(chan->cdr, 0); /* nothing changed, reset the chan cdr  */
03572       }
03573    }
03574 
03575    {
03576       struct ast_channel *chan_ptr = NULL;
03577       new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
03578       if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
03579          ast_set_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED); /* DISABLED is viral-- it will propagate across a bridge */
03580       if (strcasecmp(orig_peername, peer->name) != 0) { 
03581          /* old channel */
03582          if ((chan_ptr = ast_channel_get_by_name(orig_peername))) {
03583             ast_channel_lock(chan_ptr);
03584             if (!ast_bridged_channel(chan_ptr)) {
03585                struct ast_cdr *cur;
03586                for (cur = chan_ptr->cdr; cur; cur = cur->next) {
03587                   if (cur == peer_cdr) {
03588                      break;
03589                   }
03590                }
03591                if (cur) {
03592                   ast_cdr_specialized_reset(peer_cdr, 0);
03593                }
03594             }
03595             ast_channel_unlock(chan_ptr);
03596             chan_ptr = ast_channel_unref(chan_ptr);
03597          }
03598          /* new channel */
03599          if (new_peer_cdr) {
03600             ast_cdr_specialized_reset(new_peer_cdr, 0);
03601          }
03602       } else {
03603          ast_cdr_specialized_reset(peer->cdr, 0); /* nothing changed, reset the peer cdr  */
03604       }
03605    }
03606    
03607    return res;
03608 }

int ast_bridge_timelimit ( struct ast_channel *  chan,
struct ast_bridge_config *  config,
char *  parse,
struct timeval *  calldurationlimit 
)

parse L option and read associated channel variables to set warning, warning frequency, and timelimit

Note:
caller must be aware of freeing memory for warning_sound, end_sound, and start_sound

Definition at line 5368 of file features.c.

References ast_channel_lock, ast_channel_unlock, AST_FEATURE_PLAY_WARNING, ast_log(), ast_set_flag, ast_strdup, ast_strdupa, ast_strlen_zero(), ast_true(), ast_verb, ast_bridge_config::end_sound, ast_bridge_config::features_callee, ast_bridge_config::features_caller, LOG_WARNING, pbx_builtin_getvar_helper(), ast_bridge_config::play_warning, S_OR, ast_bridge_config::start_sound, strsep(), ast_bridge_config::timelimit, var, ast_bridge_config::warning_freq, and ast_bridge_config::warning_sound.

Referenced by bridge_exec(), and dial_exec_full().

05370 {
05371    char *stringp = ast_strdupa(parse);
05372    char *limit_str, *warning_str, *warnfreq_str;
05373    const char *var;
05374    int play_to_caller = 0, play_to_callee = 0;
05375    int delta;
05376 
05377    limit_str = strsep(&stringp, ":");
05378    warning_str = strsep(&stringp, ":");
05379    warnfreq_str = strsep(&stringp, ":");
05380 
05381    config->timelimit = atol(limit_str);
05382    if (warning_str)
05383       config->play_warning = atol(warning_str);
05384    if (warnfreq_str)
05385       config->warning_freq = atol(warnfreq_str);
05386 
05387    if (!config->timelimit) {
05388       ast_log(LOG_WARNING, "Bridge does not accept L(%s), hanging up.\n", limit_str);
05389       config->timelimit = config->play_warning = config->warning_freq = 0;
05390       config->warning_sound = NULL;
05391       return -1; /* error */
05392    } else if ( (delta = config->play_warning - config->timelimit) > 0) {
05393       int w = config->warning_freq;
05394 
05395       /* If the first warning is requested _after_ the entire call would end,
05396          and no warning frequency is requested, then turn off the warning. If
05397          a warning frequency is requested, reduce the 'first warning' time by
05398          that frequency until it falls within the call's total time limit.
05399          Graphically:
05400               timelim->|    delta        |<-playwarning
05401          0__________________|_________________|
05402                 | w  |    |    |    |
05403 
05404          so the number of intervals to cut is 1+(delta-1)/w
05405       */
05406 
05407       if (w == 0) {
05408          config->play_warning = 0;
05409       } else {
05410          config->play_warning -= w * ( 1 + (delta-1)/w );
05411          if (config->play_warning < 1)
05412             config->play_warning = config->warning_freq = 0;
05413       }
05414    }
05415    
05416    ast_channel_lock(chan);
05417 
05418    var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLER");
05419    play_to_caller = var ? ast_true(var) : 1;
05420 
05421    var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLEE");
05422    play_to_callee = var ? ast_true(var) : 0;
05423 
05424    if (!play_to_caller && !play_to_callee)
05425       play_to_caller = 1;
05426 
05427    var = pbx_builtin_getvar_helper(chan, "LIMIT_WARNING_FILE");
05428    config->warning_sound = !ast_strlen_zero(var) ? ast_strdup(var) : ast_strdup("timeleft");
05429 
05430    /* The code looking at config wants a NULL, not just "", to decide
05431     * that the message should not be played, so we replace "" with NULL.
05432     * Note, pbx_builtin_getvar_helper _can_ return NULL if the variable is
05433     * not found.
05434     */
05435 
05436    var = pbx_builtin_getvar_helper(chan, "LIMIT_TIMEOUT_FILE");
05437    config->end_sound = !ast_strlen_zero(var) ? ast_strdup(var) : NULL;
05438 
05439    var = pbx_builtin_getvar_helper(chan, "LIMIT_CONNECT_FILE");
05440    config->start_sound = !ast_strlen_zero(var) ? ast_strdup(var) : NULL;
05441 
05442    ast_channel_unlock(chan);
05443 
05444    /* undo effect of S(x) in case they are both used */
05445    calldurationlimit->tv_sec = 0;
05446    calldurationlimit->tv_usec = 0;
05447 
05448    /* more efficient to do it like S(x) does since no advanced opts */
05449    if (!config->play_warning && !config->start_sound && !config->end_sound && config->timelimit) {
05450       calldurationlimit->tv_sec = config->timelimit / 1000;
05451       calldurationlimit->tv_usec = (config->timelimit % 1000) * 1000;
05452       ast_verb(3, "Setting call duration limit to %.3lf seconds.\n",
05453          calldurationlimit->tv_sec + calldurationlimit->tv_usec / 1000000.0);
05454       config->timelimit = play_to_caller = play_to_callee =
05455       config->play_warning = config->warning_freq = 0;
05456    } else {
05457       ast_verb(4, "Limit Data for this call:\n");
05458       ast_verb(4, "timelimit      = %ld ms (%.3lf s)\n", config->timelimit, config->timelimit / 1000.0);
05459       ast_verb(4, "play_warning   = %ld ms (%.3lf s)\n", config->play_warning, config->play_warning / 1000.0);
05460       ast_verb(4, "play_to_caller = %s\n", play_to_caller ? "yes" : "no");
05461       ast_verb(4, "play_to_callee = %s\n", play_to_callee ? "yes" : "no");
05462       ast_verb(4, "warning_freq   = %ld ms (%.3lf s)\n", config->warning_freq, config->warning_freq / 1000.0);
05463       ast_verb(4, "start_sound    = %s\n", S_OR(config->start_sound, ""));
05464       ast_verb(4, "warning_sound  = %s\n", config->warning_sound);
05465       ast_verb(4, "end_sound      = %s\n", S_OR(config->end_sound, ""));
05466    }
05467    if (play_to_caller)
05468       ast_set_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING);
05469    if (play_to_callee)
05470       ast_set_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING);
05471    return 0;
05472 }

int ast_feature_detect ( struct ast_channel *  chan,
struct ast_flags *  features,
const char *  code,
struct ast_call_feature *  feature 
)

detect a feature before bridging

Parameters:
chan 
features an ast_flags ptr
code ptr of input code
feature 
Return values:
ast_call_feature ptr to be set if found

Definition at line 2680 of file features.c.

References feature_interpret_helper().

Referenced by detect_disconnect().

02680                                                                                                                                  {
02681 
02682    return feature_interpret_helper(chan, NULL, NULL, code, 0, NULL, features, 0, feature);
02683 }

int ast_features_reload ( void   ) 

Reload call features from features.conf.

Definition at line 4867 of file features.c.

References ao2_t_callback, load_config(), OBJ_NODATA, OBJ_UNLINK, parkinglot_is_marked_cb(), parkinglot_markall_cb(), and parkinglots.

Referenced by handle_features_reload().

04868 {
04869    int res;
04870 
04871    ao2_t_callback(parkinglots, OBJ_NODATA, parkinglot_markall_cb, NULL, "callback to mark all parkinglots");
04872    res = load_config(); /* Reload configuration */
04873    ao2_t_callback(parkinglots, OBJ_NODATA | OBJ_UNLINK, parkinglot_is_marked_cb, NULL, "callback to remove all marked parkinglots");
04874    
04875    return res;
04876 }

struct ast_call_feature* ast_find_call_feature ( const char *  name  )  [read]

look for a call feature entry by its sname

Parameters:
name a string ptr, should match "automon", "blindxfer", "atxfer", etc.

Definition at line 2422 of file features.c.

References FEATURES_COUNT, and ast_call_feature::sname.

Referenced by action_atxfer(), handle_request_info(), and load_config().

02423 {
02424    int x;
02425    for (x = 0; x < FEATURES_COUNT; x++) {
02426       if (!strcasecmp(name, builtin_features[x].sname))
02427          return &builtin_features[x];
02428    }
02429    return NULL;
02430 }

int ast_masq_park_call ( struct ast_channel *  rchan,
struct ast_channel *  host,
int  timeout,
int *  extout 
)

Park a call via a masqueraded channel.

Parameters:
rchan the real channel to be parked
host the channel to have the parking read to.
timeout is a timeout in milliseconds
extout is a parameter to an int that will hold the parked location, or NULL if you want.
Masquerade the channel rchan into a new, empty channel which is then parked with ast_park_call
Return values:
0 on success.
-1 on failure.

Definition at line 1128 of file features.c.

References masq_park_call().

Referenced by __analog_ss_thread(), analog_ss_thread(), handle_exec(), handle_soft_key_event_message(), handle_stimulus_message(), mgcp_ss(), parkandannounce_exec(), and rpt_exec().

01129 {
01130    return masq_park_call(rchan, peer, timeout, extout, 0, NULL);
01131 }

int ast_park_call ( struct ast_channel *  chan,
struct ast_channel *  peer,
int  timeout,
const char *  parkexten,
int *  extout 
)

Park a call and read back parked location.

Parameters:
chan the channel to actually be parked
host the channel which will have the parked location read to.
timeout is a timeout in milliseconds
extout is a parameter to an int that will hold the parked location, or NULL if you want.
Park the channel chan, and read back the parked location to the host. If the call is not picked up within a specified period of time, then the call will return to the last step that it was in (in terms of exten, priority and context)
Return values:
0 on success.
-1 on failure.

Definition at line 1054 of file features.c.

References ao2_callback, find_parkinglot_by_exten_cb(), park_call_full(), parkinglots, and ast_park_call_args::timeout.

Referenced by iax_park_thread(), and sip_park_thread().

01055 {
01056    struct ast_parkinglot *found_lot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, (void *) parkexten);
01057 
01058    struct ast_park_call_args args = {
01059       .timeout = timeout,
01060       .extout = extout,
01061       .parkinglot = found_lot,
01062    };
01063 
01064    return park_call_full(chan, peer, &args);
01065 }

int ast_parking_ext_valid ( const char *  exten_str,
struct ast_channel *  chan,
const char *  context 
)

Determine if parking extension exists in a given context.

Return values:
0 if extension does not exist
1 if extension does exist

Definition at line 475 of file features.c.

References ast_get_extension_app(), E_MATCH, PARK_APP_NAME, pbx_find_extension(), and pbx_find_info::stacklen.

Referenced by __analog_ss_thread(), analog_ss_thread(), dp_lookup(), handle_request_refer(), mgcp_ss(), and socket_process().

00476 {
00477    struct ast_exten *exten;
00478    struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
00479    const char *app_at_exten;
00480 
00481    exten = pbx_find_extension(chan, NULL, &q, context, exten_str, 1, NULL, NULL, E_MATCH);
00482    if (!exten) {
00483       return 0;
00484    }
00485 
00486    app_at_exten = ast_get_extension_app(exten);
00487    if (!app_at_exten || strcmp(PARK_APP_NAME, app_at_exten)) {
00488       return 0;
00489    }
00490 
00491    return 1;
00492 }

int ast_pickup_call ( struct ast_channel *  chan  ) 

Pickup a call.

Parameters:
chan channel that initiated pickup.
Walk list of channels, checking it is not itself, channel is pbx one, check that the callgroup for both channels are the same and the channel is ringing. Answer calling channel, flag channel as answered on queue, masq channels together.

Definition at line 5266 of file features.c.

References ast_answer(), ast_channel_callback(), ast_channel_connected_line_macro(), ast_channel_lock_both, ast_channel_masquerade(), ast_channel_queue_connected_line_update(), ast_channel_unlock, ast_channel_unref, ast_channel_update_connected_line(), AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, AST_CONTROL_ANSWER, ast_debug, ast_log(), ast_manager_event_multichan, ast_party_connected_line_collect_caller(), ast_queue_control(), ast_strdupa, ast_stream_and_wait(), ast_strlen_zero(), ast_channel::caller, ast_channel::connected, EVENT_FLAG_CALL, find_channel_by_group(), LOG_WARNING, ast_channel::name, pickupfailsound, pickupsound, and ast_party_connected_line::source.

Referenced by __analog_ss_thread(), analog_ss_thread(), cb_events(), handle_request_invite(), mgcp_ss(), and pickup_exec().

05267 {
05268    struct ast_channel *cur, *chans[2] = { chan, };
05269    struct ast_party_connected_line connected_caller;
05270    int res;
05271    const char *chan_name;
05272    const char *cur_name;
05273 
05274    if (!(cur = ast_channel_callback(find_channel_by_group, NULL, chan, 0))) {
05275       ast_debug(1, "No call pickup possible...\n");
05276       if (!ast_strlen_zero(pickupfailsound)) {
05277          ast_stream_and_wait(chan, pickupfailsound, "");
05278       }
05279       return -1;
05280    }
05281 
05282    chans[1] = cur;
05283 
05284    ast_channel_lock_both(cur, chan);
05285 
05286    cur_name = ast_strdupa(cur->name);
05287    chan_name = ast_strdupa(chan->name);
05288 
05289    ast_debug(1, "Call pickup on chan '%s' by '%s'\n", cur_name, chan_name);
05290 
05291    connected_caller = cur->connected;
05292    connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
05293    if (ast_channel_connected_line_macro(NULL, chan, &connected_caller, 0, 0)) {
05294       ast_channel_update_connected_line(chan, &connected_caller, NULL);
05295    }
05296 
05297    ast_party_connected_line_collect_caller(&connected_caller, &chan->caller);
05298    connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
05299    ast_channel_queue_connected_line_update(chan, &connected_caller, NULL);
05300 
05301    ast_channel_unlock(cur);
05302    ast_channel_unlock(chan);
05303 
05304    if (ast_answer(chan)) {
05305       ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan_name);
05306    }
05307 
05308    if (ast_queue_control(chan, AST_CONTROL_ANSWER)) {
05309       ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan_name);
05310    }
05311 
05312    if ((res = ast_channel_masquerade(cur, chan))) {
05313       ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan_name, cur_name);
05314    }
05315 
05316    if (!ast_strlen_zero(pickupsound)) {
05317       ast_stream_and_wait(cur, pickupsound, "");
05318    }
05319 
05320    /* If you want UniqueIDs, set channelvars in manager.conf to CHANNEL(uniqueid) */
05321    ast_manager_event_multichan(EVENT_FLAG_CALL, "Pickup", 2, chans,
05322       "Channel: %s\r\nTargetChannel: %s\r\n", chan->name, cur->name);
05323 
05324    cur = ast_channel_unref(cur);
05325 
05326    return res;
05327 }

const char* ast_pickup_ext ( void   ) 

Determine system call pickup extension.

Definition at line 494 of file features.c.

References pickup_ext.

Referenced by __analog_ss_thread(), analog_ss_thread(), cb_events(), get_destination(), handle_feature_show(), handle_request_invite(), and mgcp_ss().

00495 {
00496    return pickup_ext;
00497 }

void ast_rdlock_call_features ( void   ) 

Definition at line 2412 of file features.c.

References ast_rwlock_rdlock, and features_lock.

Referenced by handle_request_info().

02413 {
02414    ast_rwlock_rdlock(&features_lock);
02415 }

void ast_register_feature ( struct ast_call_feature *  feature  ) 

register new feature into feature_set

Parameters:
feature an ast_call_feature object which contains a keysequence and a callback function which is called when this keysequence is pressed during a call.

Definition at line 2256 of file features.c.

References ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_call_feature::feature_entry, LOG_NOTICE, and ast_call_feature::sname.

Referenced by load_config().

02257 {
02258    if (!feature) {
02259       ast_log(LOG_NOTICE,"You didn't pass a feature!\n");
02260       return;
02261    }
02262   
02263    AST_RWLIST_WRLOCK(&feature_list);
02264    AST_RWLIST_INSERT_HEAD(&feature_list,feature,feature_entry);
02265    AST_RWLIST_UNLOCK(&feature_list);
02266 
02267    ast_verb(2, "Registered Feature '%s'\n",feature->sname);
02268 }

void ast_unlock_call_features ( void   ) 

Definition at line 2417 of file features.c.

References ast_rwlock_unlock, and features_lock.

Referenced by handle_request_info().

02418 {
02419    ast_rwlock_unlock(&features_lock);
02420 }

void ast_unregister_feature ( struct ast_call_feature *  feature  ) 

unregister feature from feature_set

Parameters:
feature the ast_call_feature object which was registered before

Definition at line 2336 of file features.c.

References ast_free, AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.

02337 {
02338    if (!feature) {
02339       return;
02340    }
02341 
02342    AST_RWLIST_WRLOCK(&feature_list);
02343    AST_RWLIST_REMOVE(&feature_list, feature, feature_entry);
02344    AST_RWLIST_UNLOCK(&feature_list);
02345 
02346    ast_free(feature);
02347 }


Generated on Sat Mar 26 11:20:01 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.9