Fri Jul 3 20:39:31 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_cycle.c
 Trivial application to cycle over some users.
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 8917 of file chan_iax2.c.

References iax2_registry::addr, ast_inet_ntoa(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_verbose(), iax2_registry::callno, iax2_provision(), 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().

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

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

Definition at line 5430 of file pbx.c.

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

05431 {
05432    int delay = 0;
05433    int res;
05434 
05435    if (chan->_state == AST_STATE_UP)
05436       delay = 0;
05437    else if (!ast_strlen_zero(data))
05438       delay = atoi(data);
05439 
05440    res = ast_answer(chan);
05441    if (res)
05442       return res;
05443 
05444    if (delay)
05445       res = ast_safe_sleep(chan, delay);
05446 
05447    return res;
05448 }

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

Definition at line 5663 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.

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

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

Definition at line 5396 of file pbx.c.

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

Referenced by __ast_pbx_run().

05397 {
05398    ast_indicate(chan, AST_CONTROL_BUSY);
05399    /* Don't change state of an UP channel, just indicate
05400       busy in audio */
05401    if (chan->_state != AST_STATE_UP)
05402       ast_setstate(chan, AST_STATE_BUSY);
05403    if( ast_strlen_zero(data) )
05404       wait_for_hangup(chan, "10");
05405    else
05406       wait_for_hangup(chan, data);
05407    return -1;
05408 }

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

Definition at line 5413 of file pbx.c.

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

Referenced by __ast_pbx_run().

05414 {
05415    ast_indicate(chan, AST_CONTROL_CONGESTION);
05416    /* Don't change state of an UP channel, just indicate
05417       congestion in audio */
05418    if (chan->_state != AST_STATE_UP)
05419       ast_setstate(chan, AST_STATE_BUSY);
05420    if( ast_strlen_zero(data) )
05421       wait_for_hangup(chan, "10");
05422    else
05423       wait_for_hangup(chan, data);
05424    return -1;
05425 }

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

Definition at line 5543 of file pbx.c.

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

05544 {
05545    char *s, *appname;
05546    struct ast_timing timing;
05547    struct ast_app *app;
05548    static const char *usage = "ExecIfTime requires an argument:\n  <time range>|<days of week>|<days of month>|<months>?<appname>[|<appargs>]";
05549 
05550    if (ast_strlen_zero(data)) {
05551       ast_log(LOG_WARNING, "%s\n", usage);
05552       return -1;
05553    }
05554 
05555    appname = ast_strdupa(data);
05556 
05557    s = strsep(&appname,"?");  /* Separate the timerange and application name/data */
05558    if (!appname) {   /* missing application */
05559       ast_log(LOG_WARNING, "%s\n", usage);
05560       return -1;
05561    }
05562 
05563    if (!ast_build_timing(&timing, s)) {
05564       ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
05565       return -1;
05566    }
05567 
05568    if (!ast_check_timing(&timing))  /* outside the valid time window, just return */
05569       return 0;
05570 
05571    /* now split appname|appargs */
05572    if ((s = strchr(appname, '|')))
05573       *s++ = '\0';
05574 
05575    if ((app = pbx_findapp(appname))) {
05576       return pbx_exec(chan, app, S_OR(s, ""));
05577    } else {
05578       ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
05579       return -1;
05580    }
05581 }

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

Goto

Definition at line 5741 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().

05742 {
05743    int res = ast_parseable_goto(chan, data);
05744    if (!res && (option_verbose > 2))
05745       ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1);
05746    return res;
05747 }

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

Definition at line 5517 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.

05518 {
05519    int res=0;
05520    char *s, *ts;
05521    struct ast_timing timing;
05522 
05523    if (ast_strlen_zero(data)) {
05524       ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n  <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n");
05525       return -1;
05526    }
05527 
05528    ts = s = ast_strdupa(data);
05529 
05530    /* Separate the Goto path */
05531    strsep(&ts,"?");
05532 
05533    /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
05534    if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
05535       res = pbx_builtin_goto(chan, ts);
05536    
05537    return res;
05538 }

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

Definition at line 5487 of file pbx.c.

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

05488 {
05489    if (!ast_strlen_zero(data)) {
05490       int cause;
05491       char *endptr;
05492 
05493       if ((cause = ast_str2cause(data)) > -1) {
05494          chan->hangupcause = cause;
05495          return -1;
05496       }
05497       
05498       cause = strtol((const char *) data, &endptr, 10);
05499       if (cause != 0 || (data != endptr)) {
05500          chan->hangupcause = cause;
05501          return -1;
05502       }
05503          
05504       ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
05505    }
05506 
05507    if (!chan->hangupcause) {
05508       chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
05509    }
05510 
05511    return -1;
05512 }

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

Definition at line 5378 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

05379 {
05380    ast_indicate(chan, AST_CONTROL_PROGRESS);
05381    return 0;
05382 }

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

Definition at line 5459 of file pbx.c.

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

05460 {
05461    char *args;
05462    struct ast_flags flags = { 0 };
05463 
05464    if (!ast_strlen_zero(data)) {
05465       args = ast_strdupa(data);
05466       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
05467    }
05468 
05469    ast_cdr_reset(chan->cdr, &flags);
05470 
05471    return 0;
05472 }

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

Definition at line 5387 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

05388 {
05389    ast_indicate(chan, AST_CONTROL_RINGING);
05390    return 0;
05391 }

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

Definition at line 5477 of file pbx.c.

References ast_cdr_setamaflags().

05478 {
05479    /* Copy the AMA Flags as specified */
05480    ast_cdr_setamaflags(chan, data ? data : "");
05481    return 0;
05482 }

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

Definition at line 5586 of file pbx.c.

References ast_safe_sleep(), and s.

05587 {
05588    double s;
05589    int ms;
05590 
05591    /* Wait for "n" seconds */
05592    if (data && (s = atof(data)) > 0) {
05593       ms = s * 1000.0;
05594       return ast_safe_sleep(chan, ms);
05595    }
05596    return 0;
05597 }

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

Definition at line 5602 of file pbx.c.

References ast_channel::_softhangup, 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_channel::cid, ast_callerid::cid_num, ast_channel::context, ast_channel::exten, LOG_WARNING, ast_channel::name, option_verbose, parse(), ast_channel::pbx, ast_channel::priority, ast_pbx::rtimeout, set_ext_pri(), timeout, VERBOSE_PREFIX_3, WAITEXTEN_MOH, and waitexten_opts.

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


Generated on Fri Jul 3 20:39:31 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.9