Sun Sep 7 06:29:42 2008

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 8829 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().

08830 {
08831    int res;
08832    char *sdata;
08833    char *opts;
08834    int force =0;
08835    unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
08836    if (ast_strlen_zero(data))
08837       data = "default";
08838    sdata = ast_strdupa(data);
08839    opts = strchr(sdata, '|');
08840    if (opts)
08841       *opts='\0';
08842 
08843    if (chan->tech != &iax2_tech) {
08844       ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
08845       return -1;
08846    } 
08847    if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) {
08848       ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
08849       return -1;
08850    }
08851    res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
08852    if (option_verbose > 2)
08853       ast_verbose(VERBOSE_PREFIX_3 "Provisioned IAXY at '%s' with '%s'= %d\n", 
08854       ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
08855       sdata, res);
08856    return res;
08857 }

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

Definition at line 5411 of file pbx.c.

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

05412 {
05413    int delay = 0;
05414    int res;
05415 
05416    if (chan->_state == AST_STATE_UP)
05417       delay = 0;
05418    else if (!ast_strlen_zero(data))
05419       delay = atoi(data);
05420 
05421    res = ast_answer(chan);
05422    if (res)
05423       return res;
05424 
05425    if (delay)
05426       res = ast_safe_sleep(chan, delay);
05427 
05428    return res;
05429 }

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

Definition at line 5644 of file pbx.c.

References ast_channel::_state, ast_answer(), AST_APP_ARG, ast_app_parse_options(), 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_PLAYBACK, BACKGROUND_SKIP, ast_channel::context, ast_channel::exten, ast_flags::flags, LOG_WARNING, parse(), ast_channel::priority, and strsep().

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

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

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

05384 {
05385    ast_indicate(chan, AST_CONTROL_BUSY);
05386    /* Don't change state of an UP channel, just indicate
05387       busy in audio */
05388    if (chan->_state != AST_STATE_UP)
05389       ast_setstate(chan, AST_STATE_BUSY);
05390    wait_for_hangup(chan, data);
05391    return -1;
05392 }

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

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

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

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

Definition at line 5524 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, S_OR, and strsep().

05525 {
05526    char *s, *appname;
05527    struct ast_timing timing;
05528    struct ast_app *app;
05529    static const char *usage = "ExecIfTime requires an argument:\n  <time range>|<days of week>|<days of month>|<months>?<appname>[|<appargs>]";
05530 
05531    if (ast_strlen_zero(data)) {
05532       ast_log(LOG_WARNING, "%s\n", usage);
05533       return -1;
05534    }
05535 
05536    appname = ast_strdupa(data);
05537 
05538    s = strsep(&appname,"?");  /* Separate the timerange and application name/data */
05539    if (!appname) {   /* missing application */
05540       ast_log(LOG_WARNING, "%s\n", usage);
05541       return -1;
05542    }
05543 
05544    if (!ast_build_timing(&timing, s)) {
05545       ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
05546       return -1;
05547    }
05548 
05549    if (!ast_check_timing(&timing))  /* outside the valid time window, just return */
05550       return 0;
05551 
05552    /* now split appname|appargs */
05553    if ((s = strchr(appname, '|')))
05554       *s++ = '\0';
05555 
05556    if ((app = pbx_findapp(appname))) {
05557       return pbx_exec(chan, app, S_OR(s, ""));
05558    } else {
05559       ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
05560       return -1;
05561    }
05562 }

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

Goto

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

05723 {
05724    int res = ast_parseable_goto(chan, data);
05725    if (!res && (option_verbose > 2))
05726       ast_verbose( VERBOSE_PREFIX_3 "Goto (%s,%s,%d)\n", chan->context,chan->exten, chan->priority+1);
05727    return res;
05728 }

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

Definition at line 5498 of file pbx.c.

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

05499 {
05500    int res=0;
05501    char *s, *ts;
05502    struct ast_timing timing;
05503 
05504    if (ast_strlen_zero(data)) {
05505       ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n  <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n");
05506       return -1;
05507    }
05508 
05509    ts = s = ast_strdupa(data);
05510 
05511    /* Separate the Goto path */
05512    strsep(&ts,"?");
05513 
05514    /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
05515    if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
05516       res = pbx_builtin_goto(chan, ts);
05517    
05518    return res;
05519 }

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

Definition at line 5468 of file pbx.c.

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

05469 {
05470    if (!ast_strlen_zero(data)) {
05471       int cause;
05472       char *endptr;
05473 
05474       if ((cause = ast_str2cause(data)) > -1) {
05475          chan->hangupcause = cause;
05476          return -1;
05477       }
05478       
05479       cause = strtol((const char *) data, &endptr, 10);
05480       if (cause != 0 || (data != endptr)) {
05481          chan->hangupcause = cause;
05482          return -1;
05483       }
05484          
05485       ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
05486    }
05487 
05488    if (!chan->hangupcause) {
05489       chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
05490    }
05491 
05492    return -1;
05493 }

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

Definition at line 5365 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

05366 {
05367    ast_indicate(chan, AST_CONTROL_PROGRESS);
05368    return 0;
05369 }

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

Definition at line 5440 of file pbx.c.

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

05441 {
05442    char *args;
05443    struct ast_flags flags = { 0 };
05444 
05445    if (!ast_strlen_zero(data)) {
05446       args = ast_strdupa(data);
05447       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
05448    }
05449 
05450    ast_cdr_reset(chan->cdr, &flags);
05451 
05452    return 0;
05453 }

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

Definition at line 5374 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

05375 {
05376    ast_indicate(chan, AST_CONTROL_RINGING);
05377    return 0;
05378 }

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

Definition at line 5458 of file pbx.c.

References ast_cdr_setamaflags().

05459 {
05460    /* Copy the AMA Flags as specified */
05461    ast_cdr_setamaflags(chan, data ? data : "");
05462    return 0;
05463 }

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

Definition at line 5567 of file pbx.c.

References ast_safe_sleep(), and s.

05568 {
05569    double s;
05570    int ms;
05571 
05572    /* Wait for "n" seconds */
05573    if (data && (s = atof(data)) > 0) {
05574       ms = s * 1000.0;
05575       return ast_safe_sleep(chan, ms);
05576    }
05577    return 0;
05578 }

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

Definition at line 5583 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, and WAITEXTEN_MOH.

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


Generated on Sun Sep 7 06:29:42 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1