Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Files | Functions
Dial plan applications

Applications support the dialplan. They register dynamically with. 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_amd.c
 Answering machine detection.
 
file  app_attended_transfer.c
 Attended transfer by caller channel.
 
file  app_audiosocket.c
 AudioSocket application – transmit and receive audio through a TCP socket.
 
file  app_authenticate.c
 Execute arbitrary authenticate commands.
 
file  app_blind_transfer.c
 Blind transfer by caller channel.
 
file  app_bridgeaddchan.c
 Application to place the channel into an existing Bridge.
 
file  app_bridgewait.c
 Application to place the channel into a holding Bridge.
 
file  app_cdr.c
 Applications connected with CDR engine.
 
file  app_celgenuserevent.c
 Generate User-Defined CEL event.
 
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_confbridge.c
 Conference Bridge application.
 
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 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_ivrdemo.c
 IVR Demo application.
 
file  app_jack.c
 Jack Application.
 
file  app_macro.c
 Dial plan macro Implementation.
 
file  app_meetme.c
 Meet me conference bridge and Shared Line Appearances.
 
file  app_mf.c
 MF sender and receiver applications.
 
file  app_milliwatt.c
 Digital Milliwatt Test.
 
file  app_minivm.c
 MiniVoiceMail - A Minimal Voicemail System for Asterisk.
 
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_originate.c
 Originate application.
 
file  app_osplookup.c
 Open Settlement Protocol (OSP) Applications.
 
file  app_page.c
 page() - Paging application
 
file  app_playback.c
 Trivial application to playback a sound file.
 
file  app_playtones.c
 Playtones application.
 
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_read.c
 Trivial application to read a variable.
 
file  app_readexten.c
 Trivial application to read an extension into a variable.
 
file  app_record.c
 Trivial application to record a sound file.
 
file  app_reload.c
 Reload Asterisk modules.
 
file  app_saycounted.c
 Applications to decline words according to current language.
 
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_sf.c
 SF sender and receiver applications.
 
file  app_skel.c
 Skeleton application.
 
file  app_sms.c
 SMS application - ETSI ES 201 912 protocol 1 implementation.
 
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_userevent.c
 UserEvent application – send manager event.
 
file  app_verbose.c
 Verbose logging application.
 
file  app_voicemail.c
 Comedian Mail - Voicemail System.
 
file  app_waitforcond.c
 Sleep until a condition is true.
 
file  app_waitforring.c
 Wait for Ring Application.
 
file  app_waitforsilence.c
 Wait for Silence.
 
file  app_waituntil.c
 Sleep until the given epoch.
 
file  app_while.c
 While Loop Implementation.
 
file  app_zapateller.c
 Playback the special information tone to get rid of telemarketers.
 
file  conf_state.c
 Confbridge state handling.
 
file  conf_state_empty.c
 Confbridge state handling for the EMPTY state.
 
file  conf_state_inactive.c
 Confbridge state handling for the INACTIVE state.
 
file  conf_state_multi.c
 Confbridge state handling for the MULTI state.
 
file  conf_state_multi_marked.c
 Confbridge state handling for the MULTI_MARKED state.
 
file  conf_state_single.c
 Confbridge state handling for the SINGLE state.
 
file  conf_state_single_marked.c
 Confbridge state handling for the SINGLE_MARKED state.
 
 
file  res_fax.c
 Generic FAX Resource for FAX technology resource modules.
 
file  res_format_attr_h263.c
 H.263 Format Attribute Module.
 
file  res_format_attr_h264.c
 H.264 Format Attribute Module.
 
file  res_realtime.c
 RealTime CLI.
 

Functions

static int iax2_prov_app (struct ast_channel *chan, const char *data)
 
int indicate_busy (struct ast_channel *chan, const char *data)
 
int indicate_congestion (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_answer (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_background (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_execiftime (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_goto (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_gotoiftime (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_hangup (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_proceeding (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_progress (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_ringing (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_setamaflags (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_wait (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_waitdigit (struct ast_channel *chan, const char *data)
 
static int pbx_builtin_waitexten (struct ast_channel *chan, const char *data)
 

Detailed Description

Applications support the dialplan. They register dynamically with.

Asterisk Dial Plan Applications

See also
ast_register_application() and unregister with
ast_unregister_application()
See also

Function Documentation

◆ iax2_prov_app()

static int iax2_prov_app ( struct ast_channel chan,
const char *  data 
)
static

iax2provision

Definition at line 12323 of file chan_iax2.c.

12324 {
12325  int res;
12326  char *sdata;
12327  char *opts;
12328  int force =0;
12329  unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));
12330  if (ast_strlen_zero(data))
12331  data = "default";
12332  sdata = ast_strdupa(data);
12333  opts = strchr(sdata, '|');
12334  if (opts)
12335  *opts='\0';
12336 
12337  if (ast_channel_tech(chan) != &iax2_tech) {
12338  ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
12339  return -1;
12340  }
12341  if (!callno || !iaxs[callno] || ast_sockaddr_isnull(&iaxs[callno]->addr)) {
12342  ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
12343  return -1;
12344  }
12345  res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
12346  ast_verb(3, "Provisioned IAXY at '%s' with '%s'= %d\n",
12347  ast_sockaddr_stringify(&iaxs[callno]->addr),
12348  sdata, res);
12349  return res;
12350 }
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
static struct ast_channel_tech iax2_tech
Definition: chan_iax2.c:1291
#define PTR_TO_CALLNO(a)
Definition: chan_iax2.c:285
static int iax2_provision(struct ast_sockaddr *end, int sockfd, const char *dest, const char *template, int force)
Definition: chan_iax2.c:12271
static struct chan_iax2_pvt * iaxs[IAX_MAX_CALLS]
an array of iax2 pvt structures
Definition: chan_iax2.c:1123
void * ast_channel_tech_pvt(const struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
#define ast_verb(level,...)
#define LOG_NOTICE
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
Definition: netsock2.h:127
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Definition: netsock2.h:256
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

References ast_channel_tech(), ast_channel_tech_pvt(), ast_log, ast_sockaddr_isnull(), ast_sockaddr_stringify(), ast_strdupa, ast_strlen_zero(), ast_verb, iax2_provision(), iax2_tech, iaxs, LOG_NOTICE, NULL, PTR_TO_CALLNO, and create_addr_info::sockfd.

◆ indicate_busy()

int indicate_busy ( struct ast_channel chan,
const char *  data 
)

Definition at line 779 of file pbx_builtins.c.

780 {
782  /* Don't change state of an UP channel, just indicate
783  busy in audio */
784  ast_channel_lock(chan);
785  if (ast_channel_state(chan) != AST_STATE_UP) {
788  }
789  ast_channel_unlock(chan);
790  wait_for_hangup(chan, data);
791  return -1;
792 }
#define AST_CAUSE_BUSY
Definition: causes.h:149
#define ast_channel_lock(chan)
Definition: channel.h:2922
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4312
#define ast_channel_unlock(chan)
Definition: channel.h:2923
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_BUSY
Definition: channelstate.h:43
@ AST_STATE_UP
Definition: channelstate.h:42
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7469
@ AST_CONTROL_BUSY
void wait_for_hangup(struct ast_channel *chan, const void *data)

References AST_CAUSE_BUSY, ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_unlock, AST_CONTROL_BUSY, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

◆ indicate_congestion()

int indicate_congestion ( struct ast_channel chan,
const char *  data 
)

pbx_builtins.c functions needed by pbx.c

Definition at line 797 of file pbx_builtins.c.

798 {
800  /* Don't change state of an UP channel, just indicate
801  congestion in audio */
802  ast_channel_lock(chan);
803  if (ast_channel_state(chan) != AST_STATE_UP) {
806  }
807  ast_channel_unlock(chan);
808  wait_for_hangup(chan, data);
809  return -1;
810 }
#define AST_CAUSE_CONGESTION
Definition: causes.h:153
@ AST_CONTROL_CONGESTION

References AST_CAUSE_CONGESTION, ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_unlock, AST_CONTROL_CONGESTION, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

◆ pbx_builtin_answer()

static int pbx_builtin_answer ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 815 of file pbx_builtins.c.

816 {
817  int delay = 0;
818  char *parse;
820  AST_APP_ARG(delay);
821  AST_APP_ARG(answer_cdr);
822  );
823 
824  if (ast_strlen_zero(data)) {
825  return __ast_answer(chan, 0);
826  }
827 
828  parse = ast_strdupa(data);
829 
831 
832  if (!ast_strlen_zero(args.delay) && (ast_channel_state(chan) != AST_STATE_UP))
833  delay = atoi(data);
834 
835  if (delay < 0) {
836  delay = 0;
837  }
838 
839  if (!ast_strlen_zero(args.answer_cdr) && !strcasecmp(args.answer_cdr, "nocdr")) {
840  ast_log(AST_LOG_WARNING, "The nocdr option for the Answer application has been removed and is no longer supported.\n");
841  }
842 
843  return __ast_answer(chan, delay);
844 }
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1844
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2696
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_LOG_WARNING
const char * args

References __ast_answer(), args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, AST_LOG_WARNING, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), and parse().

◆ pbx_builtin_background()

static int pbx_builtin_background ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1184 of file pbx_builtins.c.

1185 {
1186  int res = 0;
1187  int mres = 0;
1188  struct ast_flags flags = {0};
1189  char *parse, exten[2] = "";
1191  AST_APP_ARG(filename);
1193  AST_APP_ARG(lang);
1195  );
1196 
1197  if (ast_strlen_zero(data)) {
1198  ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
1199  return -1;
1200  }
1201 
1202  parse = ast_strdupa(data);
1203 
1205 
1206  if (ast_strlen_zero(args.lang))
1207  args.lang = (char *)ast_channel_language(chan); /* XXX this is const */
1208 
1209  if (ast_strlen_zero(args.context)) {
1210  const char *context;
1211  ast_channel_lock(chan);
1212  if ((context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"))) {
1213  args.context = ast_strdupa(context);
1214  } else {
1215  args.context = ast_strdupa(ast_channel_context(chan));
1216  }
1217  ast_channel_unlock(chan);
1218  }
1219 
1220  if (args.options) {
1221  if (!strcasecmp(args.options, "skip"))
1222  flags.flags = BACKGROUND_SKIP;
1223  else if (!strcasecmp(args.options, "noanswer"))
1224  flags.flags = BACKGROUND_NOANSWER;
1225  else
1227  }
1228 
1229  /* Answer if need be */
1230  if (ast_channel_state(chan) != AST_STATE_UP) {
1232  goto done;
1233  } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
1234  res = ast_answer(chan);
1235  }
1236  }
1237 
1238  if (!res) {
1239  char *back = ast_strip(args.filename);
1240  char *front;
1241 
1242  ast_stopstream(chan); /* Stop anything playing */
1243  /* Stream the list of files */
1244  while (!res && (front = strsep(&back, "&")) ) {
1245  if ( (res = ast_streamfile(chan, front, args.lang)) ) {
1246  ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", ast_channel_name(chan), (char*)data);
1247  res = 0;
1248  mres = 1;
1249  break;
1250  }
1252  res = ast_waitstream(chan, "");
1253  } else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
1254  res = ast_waitstream_exten(chan, args.context);
1255  } else {
1256  res = ast_waitstream(chan, AST_DIGIT_ANY);
1257  }
1258  ast_stopstream(chan);
1259  }
1260  }
1261 
1262  /* If ast_waitstream didn't give us back a digit, there is nothing else to do */
1263  if (res <= 0) {
1264  goto done;
1265  }
1266 
1267  exten[0] = res;
1268 
1269  /*
1270  * If the single digit DTMF is an extension in the specified context, then
1271  * go there and signal no DTMF. Otherwise, we should exit with that DTMF.
1272  * If we're in Macro, we'll exit and seek that DTMF as the beginning of an
1273  * extension in the Macro's calling context. If we're not in Macro, then
1274  * we'll simply seek that extension in the calling context. Previously,
1275  * someone complained about the behavior as it related to the interior of a
1276  * Gosub routine, and the fix (#14011) inadvertently broke FreePBX
1277  * (#14940). This change should fix both of these situations, but with the
1278  * possible incompatibility that if a single digit extension does not exist
1279  * (but a longer extension COULD have matched), it would have previously
1280  * gone immediately to the "i" extension, but will now need to wait for a
1281  * timeout.
1282  *
1283  * Later, we had to add a flag to disable this workaround, because AGI
1284  * users can EXEC Background and reasonably expect that the DTMF code will
1285  * be returned (see #16434).
1286  */
1288  && ast_canmatch_extension(chan, args.context, exten, 1,
1289  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))
1290  && !ast_matchmore_extension(chan, args.context, exten, 1,
1291  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1292  char buf[2] = { 0, };
1293  snprintf(buf, sizeof(buf), "%c", res);
1294  ast_channel_exten_set(chan, buf);
1295  ast_channel_context_set(chan, args.context);
1296  ast_channel_priority_set(chan, 0);
1297  res = 0;
1298  }
1299 done:
1300  pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", mres ? "FAILED" : "SUCCESS");
1301  return res;
1302 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:122
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_name(const struct ast_channel *chan)
@ AST_FLAG_DISABLE_WORKAROUNDS
Definition: channel.h:1022
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2806
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:222
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Definition: file.c:1291
int ast_waitstream_exten(struct ast_channel *c, const char *context)
Waits for a stream to stop or digit matching a valid one digit exten to be pressed.
Definition: file.c:1836
#define AST_DIGIT_ANY
Definition: file.h:48
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
Definition: file.c:1817
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:3126
char * strsep(char **str, const char *delims)
#define LOG_WARNING
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Definition: pbx.c:4197
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
Definition: pbx.c:4202
#define BACKGROUND_NOANSWER
Definition: pbx_builtins.c:724
#define BACKGROUND_PLAYBACK
Definition: pbx_builtins.c:726
#define BACKGROUND_SKIP
Definition: pbx_builtins.c:723
#define BACKGROUND_MATCHEXTEN
Definition: pbx_builtins.c:725
static const struct ast_app_option background_opts[128]
Definition: pbx_builtins.c:733
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223
Structure used to handle boolean flags.
Definition: utils.h:199
unsigned int flags
Definition: utils.h:200
Number structure.
Definition: app_followme.c:154
int done
Definition: test_amihooks.c:48
static struct test_options options
#define ast_test_flag(p, flag)
Definition: utils.h:63

References args, ast_answer(), AST_APP_ARG, ast_app_parse_options(), ast_canmatch_extension(), ast_channel_caller(), ast_channel_context(), ast_channel_context_set(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_language(), ast_channel_lock, ast_channel_name(), ast_channel_priority_set(), ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, AST_FLAG_DISABLE_WORKAROUNDS, ast_log, ast_matchmore_extension(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strip(), ast_strlen_zero(), ast_test_flag, ast_waitstream(), ast_waitstream_exten(), BACKGROUND_MATCHEXTEN, BACKGROUND_NOANSWER, background_opts, BACKGROUND_PLAYBACK, BACKGROUND_SKIP, buf, context, done, exten, ast_flags::flags, LOG_WARNING, NULL, options, parse(), pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), S_COR, and strsep().

◆ pbx_builtin_execiftime()

static int pbx_builtin_execiftime ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 999 of file pbx_builtins.c.

1000 {
1001  char *s, *appname;
1002  struct ast_timing timing;
1003  struct ast_app *app;
1004  static const char * const usage = "ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
1005 
1006  if (ast_strlen_zero(data)) {
1007  ast_log(LOG_WARNING, "%s\n", usage);
1008  return -1;
1009  }
1010 
1011  appname = ast_strdupa(data);
1012 
1013  s = strsep(&appname, "?"); /* Separate the timerange and application name/data */
1014  if (!appname) { /* missing application */
1015  ast_log(LOG_WARNING, "%s\n", usage);
1016  return -1;
1017  }
1018 
1019  if (!ast_build_timing(&timing, s)) {
1020  ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
1021  ast_destroy_timing(&timing);
1022  return -1;
1023  }
1024 
1025  if (!ast_check_timing(&timing)) { /* outside the valid time window, just return */
1026  ast_destroy_timing(&timing);
1027  return 0;
1028  }
1029  ast_destroy_timing(&timing);
1030 
1031  /* now split appname(appargs) */
1032  if ((s = strchr(appname, '('))) {
1033  char *e;
1034  *s++ = '\0';
1035  if ((e = strrchr(s, ')')))
1036  *e = '\0';
1037  else
1038  ast_log(LOG_WARNING, "Failed to find closing parenthesis\n");
1039  }
1040 
1041 
1042  if ((app = pbx_findapp(appname))) {
1043  return pbx_exec(chan, app, S_OR(s, ""));
1044  } else {
1045  ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
1046  return -1;
1047  }
1048 }
static const char app[]
Definition: app_adsiprog.c:56
int ast_build_timing(struct ast_timing *i, const char *info_in)
Construct a timing bitmap, for use in time-based conditionals.
Definition: extconf.c:3807
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified.
Definition: extconf.c:4001
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
Definition: pbx_timing.c:279
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Definition: pbx_app.c:471
struct ast_app * pbx_findapp(const char *app)
Look up an application.
Definition: ael_main.c:165
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
ast_app: A registered application
Definition: pbx_app.c:45
char * usage
Definition: utils/frame.c:37

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

◆ pbx_builtin_goto()

static int pbx_builtin_goto ( struct ast_channel chan,
const char *  data 
)
static

Goto

Definition at line 934 of file pbx_builtins.c.

935 {
936  int res = ast_parseable_goto(chan, data);
937  if (!res)
938  ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
939  return res;
940 }
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)

References ast_channel_context(), ast_channel_exten(), ast_channel_priority(), ast_parseable_goto(), and ast_verb.

Referenced by pbx_builtin_gotoif(), and pbx_builtin_gotoiftime().

◆ pbx_builtin_gotoiftime()

static int pbx_builtin_gotoiftime ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 945 of file pbx_builtins.c.

946 {
947  char *s, *ts, *branch1, *branch2, *branch;
948  struct ast_timing timing;
949  const char *ctime;
950  struct timeval tv = ast_tvnow();
951  long timesecs;
952 
953  if (!chan) {
954  ast_log(LOG_WARNING, "GotoIfTime requires a channel on which to operate\n");
955  return -1;
956  }
957 
958  if (ast_strlen_zero(data)) {
959  ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
960  return -1;
961  }
962 
963  ts = s = ast_strdupa(data);
964 
965  ast_channel_lock(chan);
966  if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%ld", &timesecs) == 1) {
967  tv.tv_sec = timesecs;
968  } else if (ctime) {
969  ast_log(LOG_WARNING, "Using current time to evaluate\n");
970  /* Reset when unparseable */
971  pbx_builtin_setvar_helper(chan, "TESTTIME", NULL);
972  }
973  ast_channel_unlock(chan);
974 
975  /* Separate the Goto path */
976  strsep(&ts, "?");
977  branch1 = strsep(&ts,":");
978  branch2 = strsep(&ts,"");
979 
980  /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
981  if (ast_build_timing(&timing, s) && ast_check_timing2(&timing, tv)) {
982  branch = branch1;
983  } else {
984  branch = branch2;
985  }
986  ast_destroy_timing(&timing);
987 
988  if (ast_strlen_zero(branch)) {
989  ast_debug(1, "Not taking any branch\n");
990  return 0;
991  }
992 
993  return pbx_builtin_goto(chan, branch);
994 }
static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
Definition: pbx_builtins.c:934
#define ast_debug(level,...)
Log a DEBUG message.
int ast_check_timing2(const struct ast_timing *i, const struct timeval tv)
Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified.
Definition: pbx_timing.c:245
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:157

References ast_build_timing(), ast_channel_lock, ast_channel_unlock, ast_check_timing2(), ast_debug, ast_destroy_timing(), ast_log, ast_strdupa, ast_strlen_zero(), ast_tvnow(), LOG_WARNING, NULL, pbx_builtin_getvar_helper(), pbx_builtin_goto(), pbx_builtin_setvar_helper(), and strsep().

◆ pbx_builtin_hangup()

static int pbx_builtin_hangup ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 899 of file pbx_builtins.c.

900 {
901  int cause;
902 
903  ast_set_hangupsource(chan, "dialplan/builtin", 0);
904 
905  if (!ast_strlen_zero(data)) {
906  cause = ast_str2cause(data);
907  if (cause <= 0) {
908  if (sscanf(data, "%30d", &cause) != 1 || cause <= 0) {
909  ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", data);
910  cause = 0;
911  }
912  }
913  } else {
914  cause = 0;
915  }
916 
917  ast_channel_lock(chan);
918  if (cause <= 0) {
919  cause = ast_channel_hangupcause(chan);
920  if (cause <= 0) {
922  }
923  }
924  ast_channel_hangupcause_set(chan, cause);
926  ast_channel_unlock(chan);
927 
928  return -1;
929 }
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:106
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
Definition: channel.c:625
@ AST_SOFTHANGUP_EXPLICIT
Definition: channel.h:1148
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Definition: channel.c:2498
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2457

References AST_CAUSE_NORMAL_CLEARING, ast_channel_hangupcause(), ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_unlock, ast_log, ast_set_hangupsource(), AST_SOFTHANGUP_EXPLICIT, ast_softhangup_nolock(), ast_str2cause(), ast_strlen_zero(), and LOG_WARNING.

◆ pbx_builtin_proceeding()

static int pbx_builtin_proceeding ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 752 of file pbx_builtins.c.

753 {
755  return 0;
756 }
@ AST_CONTROL_PROCEEDING

References AST_CONTROL_PROCEEDING, and ast_indicate().

◆ pbx_builtin_progress()

static int pbx_builtin_progress ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 761 of file pbx_builtins.c.

762 {
764  return 0;
765 }
@ AST_CONTROL_PROGRESS

References AST_CONTROL_PROGRESS, and ast_indicate().

◆ pbx_builtin_ringing()

static int pbx_builtin_ringing ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 770 of file pbx_builtins.c.

771 {
773  return 0;
774 }
@ AST_CONTROL_RINGING

References AST_CONTROL_RINGING, and ast_indicate().

◆ pbx_builtin_setamaflags()

static int pbx_builtin_setamaflags ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 871 of file pbx_builtins.c.

872 {
873  ast_log(AST_LOG_WARNING, "The SetAMAFlags application is deprecated. Please use the CHANNEL function instead.\n");
874 
875  if (ast_strlen_zero(data)) {
876  ast_log(AST_LOG_WARNING, "No parameter passed to SetAMAFlags\n");
877  return 0;
878  }
879  /* Copy the AMA Flags as specified */
880  ast_channel_lock(chan);
881  if (isdigit(data[0])) {
882  int amaflags;
883  if (sscanf(data, "%30d", &amaflags) != 1) {
884  ast_log(AST_LOG_WARNING, "Unable to set AMA flags on channel %s\n", ast_channel_name(chan));
885  ast_channel_unlock(chan);
886  return 0;
887  }
889  } else {
891  }
892  ast_channel_unlock(chan);
893  return 0;
894 }
static int amaflags
Definition: chan_iax2.c:428
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition: channel.c:4395

References amaflags, ast_channel_amaflags_set(), ast_channel_lock, ast_channel_name(), ast_channel_string2amaflag(), ast_channel_unlock, ast_log, AST_LOG_WARNING, and ast_strlen_zero().

◆ pbx_builtin_wait()

static int pbx_builtin_wait ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1053 of file pbx_builtins.c.

1054 {
1055  int ms;
1056 
1057  /* Wait for "n" seconds */
1058  if (!ast_app_parse_timelen(data, &ms, TIMELEN_SECONDS) && ms > 0) {
1059  return ast_safe_sleep(chan, ms);
1060  }
1061  return 0;
1062 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1568
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit)
Common routine to parse time lengths, with optional time unit specifier.
Definition: main/app.c:3333
@ TIMELEN_SECONDS

References ast_app_parse_timelen(), ast_safe_sleep(), and TIMELEN_SECONDS.

◆ pbx_builtin_waitdigit()

static int pbx_builtin_waitdigit ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1067 of file pbx_builtins.c.

1068 {
1069  int res;
1070  int ms;
1071  char *parse;
1073  AST_APP_ARG(timeout);
1074  AST_APP_ARG(digits);
1075  );
1076 
1077  parse = ast_strdupa(data);
1079 
1080  if (ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) || ms < 0) {
1081  pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "ERROR");
1082  return 0;
1083  }
1084 
1085  /* Wait for "n" seconds */
1086  res = ast_waitfordigit_full(chan, ms, S_OR(args.digits, AST_DIGIT_ANY), -1, -1);
1087  if (res < 0) {
1088  pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "CANCEL");
1089  return -1;
1090  }
1091 
1092  if (res == 0) {
1093  pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "TIMEOUT");
1094  } else {
1095  char key[2];
1096 
1097  snprintf(key, sizeof(key), "%c", res);
1098  pbx_builtin_setvar_helper(chan, "WAITDIGITRESULT", key);
1099  pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "DTMF");
1100  }
1101 
1102  return 0;
1103 }
int ast_waitfordigit_full(struct ast_channel *c, int ms, const char *breakon, int audiofd, int ctrlfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
Definition: channel.c:3240

References args, AST_APP_ARG, ast_app_parse_timelen(), AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, AST_STANDARD_APP_ARGS, ast_strdupa, ast_waitfordigit_full(), parse(), pbx_builtin_setvar_helper(), S_OR, and TIMELEN_SECONDS.

◆ pbx_builtin_waitexten()

static int pbx_builtin_waitexten ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 1108 of file pbx_builtins.c.

1109 {
1110  int ms, res;
1111  struct ast_flags flags = {0};
1112  char *opts[1] = { NULL };
1113  char *parse;
1115  AST_APP_ARG(timeout);
1117  );
1118 
1119  if (!ast_strlen_zero(data)) {
1120  parse = ast_strdupa(data);
1122  } else
1123  memset(&args, 0, sizeof(args));
1124 
1125  if (args.options)
1126  ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
1127 
1128  if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
1129  ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
1130  } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
1131  ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL),
1132  !ast_strlen_zero(opts[0]) ? strlen(opts[0]) + 1 : 0);
1133  } else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
1134  struct ast_tone_zone_sound *ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
1135  if (ts) {
1136  ast_playtones_start(chan, 0, ts->data, 0);
1137  ts = ast_tone_zone_sound_unref(ts);
1138  } else {
1139  ast_tonepair_start(chan, 350, 440, 0, 0);
1140  }
1141  }
1142  /* Wait for "n" seconds */
1143  if (!ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) && ms > 0) {
1144  /* Yay! */
1145  } else if (ast_channel_pbx(chan)) {
1146  ms = ast_channel_pbx(chan)->rtimeoutms;
1147  } else {
1148  ms = 10000;
1149  }
1150 
1151  res = ast_waitfordigit(chan, ms);
1152  if (!res) {
1153  if (ast_check_hangup(chan)) {
1154  /* Call is hungup for some reason. */
1155  res = -1;
1156  } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1,
1157  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1158  ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
1159  } else if (ast_exists_extension(chan, ast_channel_context(chan), "t", 1,
1160  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1161  ast_verb(3, "Timeout on %s, going to 't'\n", ast_channel_name(chan));
1162  set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
1163  } else if (ast_exists_extension(chan, ast_channel_context(chan), "e", 1,
1164  S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1165  raise_exception(chan, "RESPONSETIMEOUT", 0); /* 0 will become 1, next time through the loop */
1166  } else {
1167  ast_log(LOG_WARNING, "Timeout but no rule 't' or 'e' in context '%s'\n",
1168  ast_channel_context(chan));
1169  res = -1;
1170  }
1171  }
1172 
1173  if (ast_test_flag(&flags, WAITEXTEN_MOH))
1175  else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE))
1176  ast_playtones_stop(chan);
1177 
1178  return res;
1179 }
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3176
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7665
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4688
@ AST_CONTROL_UNHOLD
@ AST_CONTROL_HOLD
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:455
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:227
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
int raise_exception(struct ast_channel *chan, const char *reason, int priority)
Definition: pbx.c:2813
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
Definition: pbx.c:4271
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4182
#define WAITEXTEN_MOH
Definition: pbx_builtins.c:735
#define WAITEXTEN_DIALTONE
Definition: pbx_builtins.c:736
static const struct ast_app_option waitexten_opts[128]
Definition: pbx_builtins.c:741
int rtimeoutms
Definition: pbx.h:216
Description of a tone.
Definition: indications.h:35
const char * data
Description of a tone.
Definition: indications.h:52

References args, AST_APP_ARG, ast_app_parse_options(), ast_app_parse_timelen(), ast_channel_caller(), ast_channel_context(), ast_channel_exten(), ast_channel_name(), ast_channel_pbx(), ast_channel_priority(), ast_channel_zone(), ast_check_hangup(), AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_get_indication_tone(), ast_indicate(), ast_indicate_data(), ast_log, ast_playtones_start(), ast_playtones_stop(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_tone_zone_sound_unref(), ast_tonepair_start(), ast_verb, ast_waitfordigit(), ast_tone_zone_sound::data, ast_flags::flags, LOG_WARNING, NULL, options, parse(), raise_exception(), ast_pbx::rtimeoutms, S_COR, S_OR, set_ext_pri(), TIMELEN_SECONDS, WAITEXTEN_DIALTONE, WAITEXTEN_MOH, and waitexten_opts.