Wed Feb 11 12:00:35 2009

Asterisk developer's documentation


Module: Dial plan applications

Applications support the dialplan. They register dynamically with ast_register_application() and unregister with ast_unregister_application(). More...


Files

file  app_adsiprog.c
 Program Asterisk ADSI Scripts into phone.
file  app_alarmreceiver.c
 Central Station Alarm receiver for Ademco Contact ID.
file  app_authenticate.c
 Execute arbitrary authenticate commands.
file  app_cdr.c
 Applications connected with CDR engine.
file  app_chanisavail.c
 Check if Channel is Available.
file  app_channelredirect.c
 ChannelRedirect application.
file  app_chanspy.c
 ChanSpy: Listen in on any channel.
file  app_controlplayback.c
 Trivial application to control playback of a sound file.
file  app_dahdibarge.c
 Zap Barge support.
file  app_dahdiras.c
 Execute an ISDN RAS.
file  app_dahdiscan.c
 Zap Scanner.
file  app_db.c
 Database access functions.
file  app_dial.c
 dial() & retrydial() - Trivial application to dial a channel and send an URL on answer
file  app_dictate.c
 Virtual Dictation Machine Application For Asterisk.
file  app_directed_pickup.c
 Directed Call Pickup Support.
file  app_directory.c
 Provide a directory of extensions.
file  app_disa.c
 DISA -- Direct Inward System Access Application.
file  app_dumpchan.c
 Application to dump channel variables.
file  app_echo.c
 Echo application -- play back what you hear to evaluate latency.
file  app_exec.c
 Exec application.
file  app_externalivr.c
 External IVR application interface.
file  app_festival.c
 Connect to festival.
file  app_flash.c
 App to flash a DAHDI trunk.
file  app_followme.c
 Find-Me Follow-Me application.
file  app_forkcdr.c
 Fork CDR application.
file  app_getcpeid.c
 Get ADSI CPE ID.
file  app_hasnewvoicemail.c
 HasVoicemail application.
file  app_ices.c
 Stream to an icecast server via ICES (see contrib/asterisk-ices.xml).
file  app_image.c
 App to transmit an image.
file  app_ivrdemo.c
 IVR Demo application.
file  app_lookupblacklist.c
 App to lookup the callerid number, and see if it is blacklisted.
file  app_lookupcidname.c
 App to set callerid name from database, based on directory number.
file  app_macro.c
 Dial plan macro Implementation.
file  app_meetme.c
 Meet me conference bridge and Shared Line Appearances.
file  app_milliwatt.c
 Digital Milliwatt Test.
file  app_mixmonitor.c
 MixMonitor() - Record a call and mix the audio during the recording.
file  app_morsecode.c
 Morsecode application.
file  app_mp3.c
 Silly application to play an MP3 file -- uses mpg123.
file  app_nbscat.c
 Silly application to play an NBScat file -- uses nbscat8k.
file  app_osplookup.c
 Open Settlement Protocol (OSP) Applications.
file  app_page.c
 page() - Paging application
file  app_parkandannounce.c
 ParkAndAnnounce application for Asterisk.
file  app_playback.c
 Trivial application to playback a sound file.
file  app_privacy.c
 Block all calls without Caller*ID, require phone # to be entered.
file  app_queue.c
 True call queues with optional send URL on answer.
file  app_random.c
 Random application.
file  app_read.c
 Trivial application to read a variable.
file  app_readfile.c
 ReadFile application -- Reads in a File for you.
file  app_realtime.c
 RealTime App.
file  app_record.c
 Trivial application to record a sound file.
file  app_sayunixtime.c
 SayUnixTime application.
file  app_senddtmf.c
 App to send DTMF digits.
file  app_sendtext.c
 App to transmit a text message.
file  app_setcallerid.c
 App to set callerid.
file  app_setcdruserfield.c
 Applictions connected with CDR engine.
file  app_settransfercapability.c
 App to set the ISDN Transfer Capability.
file  app_skel.c
 Skeleton application.
file  app_sms.c
 SMS application - ETSI ES 201 912 protocol 1 implimentation.
file  app_softhangup.c
 SoftHangup application.
file  app_speech_utils.c
 Speech Recognition Utility Applications.
file  app_stack.c
 Stack applications Gosub, Return, etc.
file  app_system.c
 Execute arbitrary system commands.
file  app_talkdetect.c
 Playback a file with audio detect.
file  app_test.c
 Applications to test connection and produce report in text file.
file  app_transfer.c
 Transfer a caller.
file  app_url.c
 App to transmit a URL.
file  app_userevent.c
 UserEvent application -- send manager event.
file  app_verbose.c
 Verbose logging application.
file  app_voicemail.c
 Comedian Mail - Voicemail System.
file  app_waitforring.c
 Wait for Ring Application.
file  app_waitforsilence.c
 Wait for Silence
  • Waits for up to 'x' milliseconds of silence, 'y' times
  • WaitForSilence(500,2) will wait for 1/2 second of silence, twice
  • WaitForSilence(1000,1) will wait for 1 second of silence, once
  • WaitForSilence(300,3,10) will wait for 300ms of silence, 3 times, and return after 10sec
    .

file  app_while.c
 While Loop Implementation.
file  app_zapateller.c
 Playback the special information tone to get rid of telemarketers.

Functions

static int iax2_prov_app (struct ast_channel *chan, void *data)
static int pbx_builtin_answer (struct ast_channel *, void *)
static int pbx_builtin_background (struct ast_channel *, void *)
static int pbx_builtin_busy (struct ast_channel *, void *)
static int pbx_builtin_congestion (struct ast_channel *, void *)
static int pbx_builtin_execiftime (struct ast_channel *, void *)
static int pbx_builtin_goto (struct ast_channel *, void *)
static int pbx_builtin_gotoiftime (struct ast_channel *, void *)
static int pbx_builtin_hangup (struct ast_channel *, void *)
static int pbx_builtin_progress (struct ast_channel *, void *)
static int pbx_builtin_resetcdr (struct ast_channel *, void *)
static int pbx_builtin_ringing (struct ast_channel *, void *)
static int pbx_builtin_setamaflags (struct ast_channel *, void *)
static int pbx_builtin_wait (struct ast_channel *, void *)
static int pbx_builtin_waitexten (struct ast_channel *, void *)

Detailed Description

Applications support the dialplan. They register dynamically with ast_register_application() and unregister with ast_unregister_application().

Asterisk Dial Plan Applications

See also

Function Documentation

static int iax2_prov_app ( struct ast_channel chan,
void *  data 
) [static]

iax2provision

Definition at line 8916 of file chan_iax2.c.

References ast_inet_ntoa(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_verbose(), iax2_provision(), iax2_tech, iaxs, LOG_NOTICE, option_verbose, PTR_TO_CALLNO, create_addr_info::sockfd, ast_channel::tech, ast_channel::tech_pvt, and VERBOSE_PREFIX_3.

Referenced by load_module().

08917 {
08918    int res;
08919    char *sdata;
08920    char *opts;
08921    int force =0;
08922    unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
08923    if (ast_strlen_zero(data))
08924       data = "default";
08925    sdata = ast_strdupa(data);
08926    opts = strchr(sdata, '|');
08927    if (opts)
08928       *opts='\0';
08929 
08930    if (chan->tech != &iax2_tech) {
08931       ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
08932       return -1;
08933    } 
08934    if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) {
08935       ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
08936       return -1;
08937    }
08938    res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
08939    if (option_verbose > 2)
08940       ast_verbose(VERBOSE_PREFIX_3 "Provisioned IAXY at '%s' with '%s'= %d\n", 
08941       ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
08942       sdata, res);
08943    return res;
08944 }

static int pbx_builtin_answer ( struct ast_channel ,
void *   
) [static]

Definition at line 5449 of file pbx.c.

References ast_channel::_state, ast_answer(), ast_safe_sleep(), AST_STATE_UP, and ast_strlen_zero().

05450 {
05451    int delay = 0;
05452    int res;
05453 
05454    if (chan->_state == AST_STATE_UP)
05455       delay = 0;
05456    else if (!ast_strlen_zero(data))
05457       delay = atoi(data);
05458 
05459    res = ast_answer(chan);
05460    if (res)
05461       return res;
05462 
05463    if (delay)
05464       res = ast_safe_sleep(chan, delay);
05465 
05466    return res;
05467 }

static int pbx_builtin_background ( struct ast_channel ,
void *   
) [static]

Definition at line 5682 of file pbx.c.

References ast_channel::_state, ast_answer(), AST_APP_ARG, ast_app_parse_options(), ast_copy_string(), AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, ast_log(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_waitstream(), ast_waitstream_exten(), BACKGROUND_MATCHEXTEN, BACKGROUND_NOANSWER, background_opts, BACKGROUND_PLAYBACK, BACKGROUND_SKIP, ast_channel::context, ast_channel::exten, ast_flags::flags, ast_channel::language, LOG_WARNING, ast_channel::name, parse(), and ast_channel::priority.

05683 {
05684    int res = 0;
05685    struct ast_flags flags = {0};
05686    char *parse;
05687    AST_DECLARE_APP_ARGS(args,
05688       AST_APP_ARG(filename);
05689       AST_APP_ARG(options);
05690       AST_APP_ARG(lang);
05691       AST_APP_ARG(context);
05692    );
05693 
05694    if (ast_strlen_zero(data)) {
05695       ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
05696       return -1;
05697    }
05698 
05699    parse = ast_strdupa(data);
05700 
05701    AST_STANDARD_APP_ARGS(args, parse);
05702 
05703    if (ast_strlen_zero(args.lang))
05704       args.lang = (char *)chan->language; /* XXX this is const */
05705 
05706    if (ast_strlen_zero(args.context))
05707       args.context = chan->context;
05708 
05709    if (args.options) {
05710       if (!strcasecmp(args.options, "skip"))
05711          flags.flags = BACKGROUND_SKIP;
05712       else if (!strcasecmp(args.options, "noanswer"))
05713          flags.flags = BACKGROUND_NOANSWER;
05714       else
05715          ast_app_parse_options(background_opts, &flags, NULL, args.options);
05716    }
05717 
05718    /* Answer if need be */
05719    if (chan->_state != AST_STATE_UP) {
05720       if (ast_test_flag(&flags, BACKGROUND_SKIP)) {
05721          return 0;
05722       } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
05723          res = ast_answer(chan);
05724       }
05725    }
05726 
05727    if (!res) {
05728       char *back = args.filename;
05729       char *front;
05730       ast_stopstream(chan);      /* Stop anything playing */
05731       /* Stream the list of files */
05732       while (!res && (front = strsep(&back, "&")) ) {
05733          if ( (res = ast_streamfile(chan, front, args.lang)) ) {
05734             ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
05735             res = 0;
05736             break;
05737          }
05738          if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) {
05739             res = ast_waitstream(chan, "");
05740          } else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
05741             res = ast_waitstream_exten(chan, args.context);
05742          } else {
05743             res = ast_waitstream(chan, AST_DIGIT_ANY);
05744          }
05745          ast_stopstream(chan);
05746       }
05747    }
05748    if (args.context != chan->context && res) {
05749       snprintf(chan->exten, sizeof(chan->exten), "%c", res);
05750       ast_copy_string(chan->context, args.context, sizeof(chan->context));
05751       chan->priority = 0;
05752       res = 0;
05753    }
05754    return res;
05755 }

static int pbx_builtin_busy ( struct ast_channel ,
void *   
) [static]

Definition at line 5421 of file pbx.c.

References ast_channel::_state, AST_CONTROL_BUSY, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

05422 {
05423    ast_indicate(chan, AST_CONTROL_BUSY);
05424    /* Don't change state of an UP channel, just indicate
05425       busy in audio */
05426    if (chan->_state != AST_STATE_UP)
05427       ast_setstate(chan, AST_STATE_BUSY);
05428    wait_for_hangup(chan, data);
05429    return -1;
05430 }

static int pbx_builtin_congestion ( struct ast_channel ,
void *   
) [static]

Definition at line 5435 of file pbx.c.

References ast_channel::_state, AST_CONTROL_CONGESTION, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

05436 {
05437    ast_indicate(chan, AST_CONTROL_CONGESTION);
05438    /* Don't change state of an UP channel, just indicate
05439       congestion in audio */
05440    if (chan->_state != AST_STATE_UP)
05441       ast_setstate(chan, AST_STATE_BUSY);
05442    wait_for_hangup(chan, data);
05443    return -1;
05444 }

static int pbx_builtin_execiftime ( struct ast_channel ,
void *   
) [static]

Definition at line 5562 of file pbx.c.

References app, ast_build_timing(), ast_check_timing(), ast_log(), ast_strdupa, ast_strlen_zero(), LOG_WARNING, pbx_exec(), pbx_findapp(), s, and S_OR.

05563 {
05564    char *s, *appname;
05565    struct ast_timing timing;
05566    struct ast_app *app;
05567    static const char *usage = "ExecIfTime requires an argument:\n  <time range>|<days of week>|<days of month>|<months>?<appname>[|<appargs>]";
05568 
05569    if (ast_strlen_zero(data)) {
05570       ast_log(LOG_WARNING, "%s\n", usage);
05571       return -1;
05572    }
05573 
05574    appname = ast_strdupa(data);
05575 
05576    s = strsep(&appname,"?");  /* Separate the timerange and application name/data */
05577    if (!appname) {   /* missing application */
05578       ast_log(LOG_WARNING, "%s\n", usage);
05579       return -1;
05580    }
05581 
05582    if (!ast_build_timing(&timing, s)) {
05583       ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
05584       return -1;
05585    }
05586 
05587    if (!ast_check_timing(&timing))  /* outside the valid time window, just return */
05588       return 0;
05589 
05590    /* now split appname|appargs */
05591    if ((s = strchr(appname, '|')))
05592       *s++ = '\0';
05593 
05594    if ((app = pbx_findapp(appname))) {
05595       return pbx_exec(chan, app, S_OR(s, ""));
05596    } else {
05597       ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
05598       return -1;
05599    }
05600 }

static int pbx_builtin_goto ( struct ast_channel chan,
void *  data 
) [static]

Goto

Definition at line 5760 of file pbx.c.

References ast_parseable_goto(), ast_verbose(), ast_channel::context, ast_channel::exten, option_verbose, ast_channel::priority, and VERBOSE_PREFIX_3.

Referenced by pbx_builtin_gotoif(), and pbx_builtin_gotoiftime().

05761 {
05762    int res = ast_parseable_goto(chan, data);
05763    if (!res && (option_verbose > 2))
05764       ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1);
05765    return res;
05766 }

static int pbx_builtin_gotoiftime ( struct ast_channel ,
void *   
) [static]

Definition at line 5536 of file pbx.c.

References ast_build_timing(), ast_check_timing(), ast_log(), ast_strdupa, ast_strlen_zero(), LOG_WARNING, pbx_builtin_goto(), and s.

05537 {
05538    int res=0;
05539    char *s, *ts;
05540    struct ast_timing timing;
05541 
05542    if (ast_strlen_zero(data)) {
05543       ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n  <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n");
05544       return -1;
05545    }
05546 
05547    ts = s = ast_strdupa(data);
05548 
05549    /* Separate the Goto path */
05550    strsep(&ts,"?");
05551 
05552    /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
05553    if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
05554       res = pbx_builtin_goto(chan, ts);
05555    
05556    return res;
05557 }

static int pbx_builtin_hangup ( struct ast_channel ,
void *   
) [static]

Definition at line 5506 of file pbx.c.

References AST_CAUSE_NORMAL_CLEARING, ast_log(), ast_str2cause(), ast_strlen_zero(), ast_channel::hangupcause, and LOG_NOTICE.

05507 {
05508    if (!ast_strlen_zero(data)) {
05509       int cause;
05510       char *endptr;
05511 
05512       if ((cause = ast_str2cause(data)) > -1) {
05513          chan->hangupcause = cause;
05514          return -1;
05515       }
05516       
05517       cause = strtol((const char *) data, &endptr, 10);
05518       if (cause != 0 || (data != endptr)) {
05519          chan->hangupcause = cause;
05520          return -1;
05521       }
05522          
05523       ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
05524    }
05525 
05526    if (!chan->hangupcause) {
05527       chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
05528    }
05529 
05530    return -1;
05531 }

static int pbx_builtin_progress ( struct ast_channel ,
void *   
) [static]

Definition at line 5403 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

05404 {
05405    ast_indicate(chan, AST_CONTROL_PROGRESS);
05406    return 0;
05407 }

static int pbx_builtin_resetcdr ( struct ast_channel ,
void *   
) [static]

Definition at line 5478 of file pbx.c.

References ast_app_parse_options(), ast_cdr_reset(), ast_strdupa, ast_strlen_zero(), ast_channel::cdr, ast_flags::flags, and resetcdr_opts.

05479 {
05480    char *args;
05481    struct ast_flags flags = { 0 };
05482 
05483    if (!ast_strlen_zero(data)) {
05484       args = ast_strdupa(data);
05485       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
05486    }
05487 
05488    ast_cdr_reset(chan->cdr, &flags);
05489 
05490    return 0;
05491 }

static int pbx_builtin_ringing ( struct ast_channel ,
void *   
) [static]

Definition at line 5412 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

05413 {
05414    ast_indicate(chan, AST_CONTROL_RINGING);
05415    return 0;
05416 }

static int pbx_builtin_setamaflags ( struct ast_channel ,
void *   
) [static]

Definition at line 5496 of file pbx.c.

References ast_cdr_setamaflags().

05497 {
05498    /* Copy the AMA Flags as specified */
05499    ast_cdr_setamaflags(chan, data ? data : "");
05500    return 0;
05501 }

static int pbx_builtin_wait ( struct ast_channel ,
void *   
) [static]

Definition at line 5605 of file pbx.c.

References ast_safe_sleep(), and s.

05606 {
05607    double s;
05608    int ms;
05609 
05610    /* Wait for "n" seconds */
05611    if (data && (s = atof(data)) > 0) {
05612       ms = s * 1000.0;
05613       return ast_safe_sleep(chan, ms);
05614    }
05615    return 0;
05616 }

static int pbx_builtin_waitexten ( struct ast_channel ,
void *   
) [static]

Definition at line 5621 of file pbx.c.

References AST_APP_ARG, ast_app_parse_options(), AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_indicate(), ast_indicate_data(), ast_log(), AST_SOFTHANGUP_TIMEOUT, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verbose(), ast_waitfordigit(), ast_flags::flags, LOG_WARNING, option_verbose, parse(), set_ext_pri(), VERBOSE_PREFIX_3, WAITEXTEN_MOH, and waitexten_opts.

05622 {
05623    int ms, res;
05624    double sec;
05625    struct ast_flags flags = {0};
05626    char *opts[1] = { NULL };
05627    char *parse;
05628    AST_DECLARE_APP_ARGS(args,
05629       AST_APP_ARG(timeout);
05630       AST_APP_ARG(options);
05631    );
05632 
05633    if (!ast_strlen_zero(data)) {
05634       parse = ast_strdupa(data);
05635       AST_STANDARD_APP_ARGS(args, parse);
05636    } else
05637       memset(&args, 0, sizeof(args));
05638 
05639    if (args.options)
05640       ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
05641    
05642    if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
05643       ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n"); 
05644    } else if (ast_test_flag(&flags, WAITEXTEN_MOH))
05645       ast_indicate_data(chan, AST_CONTROL_HOLD, opts[0], strlen(opts[0]));
05646 
05647    /* Wait for "n" seconds */
05648    if (args.timeout && (sec = atof(args.timeout)) > 0.0)
05649       ms = 1000 * sec;
05650    else if (chan->pbx)
05651       ms = chan->pbx->rtimeout * 1000;
05652    else
05653       ms = 10000;
05654    res = ast_waitfordigit(chan, ms);
05655    if (!res) {
05656       if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {
05657          if (option_verbose > 2)
05658             ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, continuing...\n", chan->name);
05659       } else if (chan->_softhangup == AST_SOFTHANGUP_TIMEOUT) {
05660          if (option_verbose > 2)
05661             ast_verbose(VERBOSE_PREFIX_3 "Call timeout on %s, checking for 'T'\n", chan->name);
05662          res = -1;
05663       } else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) {
05664          if (option_verbose > 2)
05665             ast_verbose(VERBOSE_PREFIX_3 "Timeout on %s, going to 't'\n", chan->name);
05666          set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
05667       } else {
05668          ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context);
05669          res = -1;
05670       }
05671    }
05672 
05673    if (ast_test_flag(&flags, WAITEXTEN_MOH))
05674       ast_indicate(chan, AST_CONTROL_UNHOLD);
05675 
05676    return res;
05677 }


Generated on Wed Feb 11 12:00:35 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7