Mon May 14 04:54:00 2007

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_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 zap 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.
file  app_zapbarge.c
 Zap Barge support.
file  app_zapras.c
 Execute an ISDN RAS.
file  app_zapscan.c
 Zap Scanner.

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 7908 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, ast_channel::tech, ast_channel::tech_pvt, and VERBOSE_PREFIX_3.

Referenced by load_module().

07909 {
07910    int res;
07911    char *sdata;
07912    char *opts;
07913    int force =0;
07914    unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
07915    if (ast_strlen_zero(data))
07916       data = "default";
07917    sdata = ast_strdupa(data);
07918    opts = strchr(sdata, '|');
07919    if (opts)
07920       *opts='\0';
07921 
07922    if (chan->tech != &iax2_tech) {
07923       ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
07924       return -1;
07925    } 
07926    if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) {
07927       ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
07928       return -1;
07929    }
07930    res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
07931    if (option_verbose > 2)
07932       ast_verbose(VERBOSE_PREFIX_3 "Provisioned IAXY at '%s' with '%s'= %d\n", 
07933       ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
07934       sdata, res);
07935    return res;
07936 }

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

Definition at line 5418 of file pbx.c.

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

05419 {
05420    int delay = 0;
05421    int res;
05422 
05423    if (chan->_state == AST_STATE_UP)
05424       delay = 0;
05425    else if (!ast_strlen_zero(data))
05426       delay = atoi(data);
05427 
05428    res = ast_answer(chan);
05429    if (res)
05430       return res;
05431 
05432    if (delay)
05433       res = ast_safe_sleep(chan, delay);
05434 
05435    return res;
05436 }

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

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

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

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

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

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

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

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

05402 {
05403    ast_indicate(chan, AST_CONTROL_CONGESTION);
05404    /* Don't change state of an UP channel, just indicate
05405       congestion in audio */
05406    if (chan->_state != AST_STATE_UP)
05407       ast_setstate(chan, AST_STATE_BUSY);
05408    if( ast_strlen_zero(data) )
05409       wait_for_hangup(chan, "10");
05410    else
05411       wait_for_hangup(chan, data);
05412    return -1;
05413 }

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

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

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

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

Goto

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

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

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

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

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

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

Definition at line 5475 of file pbx.c.

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

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

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

Definition at line 5366 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

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

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

Definition at line 5447 of file pbx.c.

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

05448 {
05449    char *args;
05450    struct ast_flags flags = { 0 };
05451 
05452    if (!ast_strlen_zero(data)) {
05453       args = ast_strdupa(data);
05454       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
05455    }
05456 
05457    ast_cdr_reset(chan->cdr, &flags);
05458 
05459    return 0;
05460 }

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

Definition at line 5375 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

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

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

Definition at line 5465 of file pbx.c.

References ast_cdr_setamaflags().

05466 {
05467    /* Copy the AMA Flags as specified */
05468    ast_cdr_setamaflags(chan, data ? data : "");
05469    return 0;
05470 }

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

Definition at line 5574 of file pbx.c.

References ast_safe_sleep(), and s.

05575 {
05576    double s;
05577    int ms;
05578 
05579    /* Wait for "n" seconds */
05580    if (data && (s = atof(data)) > 0) {
05581       ms = s * 1000.0;
05582       return ast_safe_sleep(chan, ms);
05583    }
05584    return 0;
05585 }

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

Definition at line 5590 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_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(), timeout, VERBOSE_PREFIX_3, and WAITEXTEN_MOH.

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


Generated on Mon May 14 04:54:00 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1