Asterisk - The Open Source Telephony Project GIT-master-d5a0626
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_broadcast.c
 Channel audio broadcasting.
 
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_if.c
 If Branch Implementation.
 
file  app_ivrdemo.c
 IVR Demo application.
 
file  app_jack.c
 Jack Application.
 
file  app_meetme.c
 Meet me conference bridge.
 
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_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_signal.c
 Channel signaling applications.
 
file  app_skel.c
 Skeleton application.
 
file  app_sla.c
 Shared Line Appearances.
 
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_voicemail_imap.c
 Comedian Mail - Voicemail System.
 
file  app_voicemail_odbc.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_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 12417 of file chan_iax2.c.

12418{
12419 int res;
12420 char *sdata;
12421 char *opts;
12422 int force =0;
12423 unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));
12424 if (ast_strlen_zero(data))
12425 data = "default";
12426 sdata = ast_strdupa(data);
12427 opts = strchr(sdata, '|');
12428 if (opts)
12429 *opts='\0';
12430
12431 if (ast_channel_tech(chan) != &iax2_tech) {
12432 ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
12433 return -1;
12434 }
12435 if (!callno || !iaxs[callno] || ast_sockaddr_isnull(&iaxs[callno]->addr)) {
12436 ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
12437 return -1;
12438 }
12439 res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
12440 ast_verb(3, "Provisioned IAXY at '%s' with '%s'= %d\n",
12441 ast_sockaddr_stringify(&iaxs[callno]->addr),
12442 sdata, res);
12443 return res;
12444}
#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:1341
#define PTR_TO_CALLNO(a)
Definition: chan_iax2.c:292
static int iax2_provision(struct ast_sockaddr *end, int sockfd, const char *dest, const char *template, int force)
Definition: chan_iax2.c:12365
static struct chan_iax2_pvt * iaxs[IAX_MAX_CALLS]
an array of iax2 pvt structures
Definition: chan_iax2.c:1173
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 char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Definition: netsock2.h:256
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
#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.

Referenced by load_module().

◆ indicate_busy()

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

Definition at line 757 of file pbx_builtins.c.

758{
760 /* Don't change state of an UP channel, just indicate
761 busy in audio */
762 ast_channel_lock(chan);
763 if (ast_channel_state(chan) != AST_STATE_UP) {
766 }
767 ast_channel_unlock(chan);
768 wait_for_hangup(chan, data);
769 return -1;
770}
#define AST_CAUSE_BUSY
Definition: causes.h:149
#define ast_channel_lock(chan)
Definition: channel.h:2968
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:4296
#define ast_channel_unlock(chan)
Definition: channel.h:2969
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:7408
@ AST_CONTROL_BUSY
void wait_for_hangup(struct ast_channel *chan, const void *data)
Definition: pbx.c:8228

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

Referenced by __ast_pbx_run().

◆ indicate_congestion()

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

pbx_builtins.c functions needed by pbx.c

Definition at line 775 of file pbx_builtins.c.

776{
778 /* Don't change state of an UP channel, just indicate
779 congestion in audio */
780 ast_channel_lock(chan);
781 if (ast_channel_state(chan) != AST_STATE_UP) {
784 }
785 ast_channel_unlock(chan);
786 wait_for_hangup(chan, data);
787 return -1;
788}
#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().

Referenced by __ast_pbx_run().

◆ pbx_builtin_answer()

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

Definition at line 793 of file pbx_builtins.c.

794{
795 int delay = 0;
796 char *parse;
798 AST_APP_ARG(delay);
800 );
801
802 if (ast_strlen_zero(data)) {
803 return __ast_answer(chan, 0);
804 }
805
806 parse = ast_strdupa(data);
807
809
810 if (!ast_strlen_zero(args.delay) && (ast_channel_state(chan) != AST_STATE_UP))
811 delay = atoi(data);
812
813 if (delay < 0) {
814 delay = 0;
815 }
816
817 if (!ast_strlen_zero(args.options) && !strcmp(args.options, "i")) {
818 return ast_raw_answer(chan);
819 }
820
821 return __ast_answer(chan, delay);
822}
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2714
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2709
#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.
const char * args
static struct test_options options

References __ast_answer(), args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_raw_answer(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), and options.

◆ pbx_builtin_background()

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

Definition at line 1127 of file pbx_builtins.c.

1128{
1129 int res = 0;
1130 int mres = 0;
1131 struct ast_flags flags = {0};
1132 char *parse, exten[2] = "";
1134 AST_APP_ARG(filename);
1136 AST_APP_ARG(lang);
1138 );
1139
1140 if (ast_strlen_zero(data)) {
1141 ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
1142 return -1;
1143 }
1144
1145 parse = ast_strdupa(data);
1146
1148
1149 if (ast_strlen_zero(args.lang))
1150 args.lang = (char *)ast_channel_language(chan); /* XXX this is const */
1151
1152 if (ast_strlen_zero(args.context)) {
1153 ast_channel_lock(chan);
1154 args.context = ast_strdupa(ast_channel_context(chan));
1155 ast_channel_unlock(chan);
1156 }
1157
1158 if (args.options) {
1159 if (!strcasecmp(args.options, "skip"))
1160 flags.flags = BACKGROUND_SKIP;
1161 else if (!strcasecmp(args.options, "noanswer"))
1162 flags.flags = BACKGROUND_NOANSWER;
1163 else
1165 }
1166
1167 /* Answer if need be */
1168 if (ast_channel_state(chan) != AST_STATE_UP) {
1170 goto done;
1171 } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
1172 res = ast_answer(chan);
1173 }
1174 }
1175
1176 if (!res) {
1177 char *back = ast_strip(args.filename);
1178 char *front;
1179
1180 ast_stopstream(chan); /* Stop anything playing */
1181 /* Stream the list of files */
1182 while (!res && (front = ast_strsep(&back, '&', AST_STRSEP_STRIP | AST_STRSEP_TRIM))) {
1183 if ( (res = ast_streamfile(chan, front, args.lang)) ) {
1184 ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", ast_channel_name(chan), (char*)data);
1185 res = 0;
1186 mres = 1;
1187 break;
1188 }
1190 res = ast_waitstream(chan, "");
1192 res = ast_waitstream_exten(chan, args.context);
1193 } else {
1194 res = ast_waitstream(chan, AST_DIGIT_ANY);
1195 }
1196 ast_stopstream(chan);
1197 }
1198 }
1199
1200 /* If ast_waitstream didn't give us back a digit, there is nothing else to do */
1201 if (res <= 0) {
1202 goto done;
1203 }
1204
1205 exten[0] = res;
1206
1207 /*
1208 * If the single digit DTMF is an extension in the specified context, then
1209 * go there and signal no DTMF. Otherwise, we should exit with that DTMF.
1210 * We'll simply seek that extension in the calling context. Previously,
1211 * someone complained about the behavior as it related to the interior of a
1212 * Gosub routine, and the fix (#14011) inadvertently broke FreePBX
1213 * (#14940). This change should fix both of these situations, but with the
1214 * possible incompatibility that if a single digit extension does not exist
1215 * (but a longer extension COULD have matched), it would have previously
1216 * gone immediately to the "i" extension, but will now need to wait for a
1217 * timeout.
1218 *
1219 * Later, we had to add a flag to disable this workaround, because AGI
1220 * users can EXEC Background and reasonably expect that the DTMF code will
1221 * be returned (see #16434).
1222 */
1224 && ast_canmatch_extension(chan, args.context, exten, 1,
1225 S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))
1226 && !ast_matchmore_extension(chan, args.context, exten, 1,
1227 S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1228 char buf[2] = { 0, };
1229 snprintf(buf, sizeof(buf), "%c", res);
1231 ast_channel_context_set(chan, args.context);
1232 ast_channel_priority_set(chan, 0);
1233 res = 0;
1234 }
1235done:
1236 pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", mres ? "FAILED" : "SUCCESS");
1237 return res;
1238}
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
@ AST_FLAG_DISABLE_WORKAROUNDS
Definition: channel.h:1042
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2824
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:1293
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:1859
#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:1840
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:3066
#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:4190
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:4195
#define BACKGROUND_NOANSWER
Definition: pbx_builtins.c:702
#define BACKGROUND_PLAYBACK
Definition: pbx_builtins.c:704
#define BACKGROUND_SKIP
Definition: pbx_builtins.c:701
#define BACKGROUND_MATCHEXTEN
Definition: pbx_builtins.c:703
static const struct ast_app_option background_opts[128]
Definition: pbx_builtins.c:711
#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
@ AST_STRSEP_TRIM
Definition: strings.h:256
@ AST_STRSEP_STRIP
Definition: strings.h:255
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
Definition: utils.c:1835
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
#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_strsep(), AST_STRSEP_STRIP, AST_STRSEP_TRIM, ast_test_flag, ast_waitstream(), ast_waitstream_exten(), BACKGROUND_MATCHEXTEN, BACKGROUND_NOANSWER, background_opts, BACKGROUND_PLAYBACK, BACKGROUND_SKIP, buf, voicemailpwcheck::context, done, ast_flags::flags, LOG_WARNING, NULL, options, pbx_builtin_setvar_helper(), and S_COR.

◆ pbx_builtin_execiftime()

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

Definition at line 949 of file pbx_builtins.c.

950{
951 char *s, *appname;
952 struct ast_timing timing;
953 static const char * const usage = "ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
954
955 if (ast_strlen_zero(data)) {
956 ast_log(LOG_WARNING, "%s\n", usage);
957 return -1;
958 }
959
960 appname = ast_strdupa(data);
961
962 s = strsep(&appname, "?"); /* Separate the timerange and application name/data */
963 if (!appname) { /* missing application */
964 ast_log(LOG_WARNING, "%s\n", usage);
965 return -1;
966 }
967
968 if (!ast_build_timing(&timing, s)) {
969 ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
970 ast_destroy_timing(&timing);
971 return -1;
972 }
973
974 if (!ast_check_timing(&timing)) { /* outside the valid time window, just return */
975 ast_destroy_timing(&timing);
976 return 0;
977 }
978 ast_destroy_timing(&timing);
979
980 /* now split appname(appargs) */
981 if ((s = strchr(appname, '('))) {
982 char *e;
983 *s++ = '\0';
984 if ((e = strrchr(s, ')')))
985 *e = '\0';
986 else
987 ast_log(LOG_WARNING, "Failed to find closing parenthesis\n");
988 }
989
990 return ast_pbx_exec_application(chan, appname, S_OR(s, ""));
991}
char * strsep(char **str, const char *delims)
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:3806
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:4000
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
Definition: pbx_timing.c:279
int ast_pbx_exec_application(struct ast_channel *chan, const char *app_name, const char *app_args)
Execute an application.
Definition: pbx_app.c:501
#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
char * usage
Definition: utils/frame.c:37

References ast_build_timing(), ast_check_timing(), ast_destroy_timing(), ast_log, ast_pbx_exec_application(), ast_strdupa, ast_strlen_zero(), LOG_WARNING, 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 884 of file pbx_builtins.c.

885{
886 int res = ast_parseable_goto(chan, data);
887 if (!res)
888 ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
889 return res;
890}
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)
Definition: pbx.c:8866

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 895 of file pbx_builtins.c.

896{
897 char *s, *ts, *branch1, *branch2, *branch;
898 struct ast_timing timing;
899 const char *ctime;
900 struct timeval tv = ast_tvnow();
901 long timesecs;
902
903 if (!chan) {
904 ast_log(LOG_WARNING, "GotoIfTime requires a channel on which to operate\n");
905 return -1;
906 }
907
908 if (ast_strlen_zero(data)) {
909 ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
910 return -1;
911 }
912
913 ts = s = ast_strdupa(data);
914
915 ast_channel_lock(chan);
916 if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%ld", &timesecs) == 1) {
917 tv.tv_sec = timesecs;
918 } else if (ctime) {
919 ast_log(LOG_WARNING, "Using current time to evaluate\n");
920 /* Reset when unparseable */
921 pbx_builtin_setvar_helper(chan, "TESTTIME", NULL);
922 }
923 ast_channel_unlock(chan);
924
925 /* Separate the Goto path */
926 strsep(&ts, "?");
927 branch1 = strsep(&ts,":");
928 branch2 = strsep(&ts,"");
929
930 /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
931 if (ast_build_timing(&timing, s) && ast_check_timing2(&timing, tv)) {
932 branch = branch1;
933 } else {
934 branch = branch2;
935 }
936 ast_destroy_timing(&timing);
937
938 if (ast_strlen_zero(branch)) {
939 ast_debug(1, "Not taking any branch\n");
940 return 0;
941 }
942
943 return pbx_builtin_goto(chan, branch);
944}
static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
Definition: pbx_builtins.c:884
#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
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159

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 849 of file pbx_builtins.c.

850{
851 int cause;
852
853 ast_set_hangupsource(chan, "dialplan/builtin", 0);
854
855 if (!ast_strlen_zero(data)) {
856 cause = ast_str2cause(data);
857 if (cause <= 0) {
858 if (sscanf(data, "%30d", &cause) != 1 || cause <= 0) {
859 ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", data);
860 cause = 0;
861 }
862 }
863 } else {
864 cause = 0;
865 }
866
867 ast_channel_lock(chan);
868 if (cause <= 0) {
869 cause = ast_channel_hangupcause(chan);
870 if (cause <= 0) {
872 }
873 }
874 ast_channel_hangupcause_set(chan, cause);
876 ast_channel_unlock(chan);
877
878 return -1;
879}
#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
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:2518
@ AST_SOFTHANGUP_EXPLICIT
Definition: channel.h:1168
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2477

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 730 of file pbx_builtins.c.

731{
733 return 0;
734}
@ 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 739 of file pbx_builtins.c.

740{
742 return 0;
743}
@ 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 748 of file pbx_builtins.c.

749{
751 return 0;
752}
@ AST_CONTROL_RINGING

References AST_CONTROL_RINGING, and ast_indicate().

◆ pbx_builtin_wait()

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

Definition at line 996 of file pbx_builtins.c.

997{
998 int ms;
999
1000 /* Wait for "n" seconds */
1001 if (!ast_app_parse_timelen(data, &ms, TIMELEN_SECONDS) && ms > 0) {
1002 return ast_safe_sleep(chan, ms);
1003 }
1004 return 0;
1005}
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1593
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:3273
@ 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 1010 of file pbx_builtins.c.

1011{
1012 int res;
1013 int ms;
1014 char *parse;
1016 AST_APP_ARG(timeout);
1017 AST_APP_ARG(digits);
1018 );
1019
1020 parse = ast_strdupa(data);
1022
1023 if (ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) || ms < 0) {
1024 pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "ERROR");
1025 return 0;
1026 }
1027
1028 /* Wait for "n" seconds */
1029 res = ast_waitfordigit_full(chan, ms, S_OR(args.digits, AST_DIGIT_ANY), -1, -1);
1030 if (res < 0) {
1031 pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "CANCEL");
1032 return -1;
1033 }
1034
1035 if (res == 0) {
1036 pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "TIMEOUT");
1037 } else {
1038 char key[2];
1039
1040 snprintf(key, sizeof(key), "%c", res);
1041 pbx_builtin_setvar_helper(chan, "WAITDIGITRESULT", key);
1042 pbx_builtin_setvar_helper(chan, "WAITDIGITSTATUS", "DTMF");
1043 }
1044
1045 return 0;
1046}
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:3258

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(), 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 1051 of file pbx_builtins.c.

1052{
1053 int ms, res;
1054 struct ast_flags flags = {0};
1055 char *opts[1] = { NULL };
1056 char *parse;
1058 AST_APP_ARG(timeout);
1060 );
1061
1062 if (!ast_strlen_zero(data)) {
1063 parse = ast_strdupa(data);
1065 } else
1066 memset(&args, 0, sizeof(args));
1067
1068 if (args.options)
1070
1071 if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
1072 ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n");
1073 } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
1075 !ast_strlen_zero(opts[0]) ? strlen(opts[0]) + 1 : 0);
1076 } else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
1078 if (ts) {
1079 ast_playtones_start(chan, 0, ts->data, 0);
1081 } else {
1082 ast_tonepair_start(chan, 350, 440, 0, 0);
1083 }
1084 }
1085 /* Wait for "n" seconds */
1086 if (!ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) && ms > 0) {
1087 /* Yay! */
1088 } else if (ast_channel_pbx(chan)) {
1089 ms = ast_channel_pbx(chan)->rtimeoutms;
1090 } else {
1091 ms = 10000;
1092 }
1093
1094 res = ast_waitfordigit(chan, ms);
1095 if (!res) {
1096 if (ast_check_hangup(chan)) {
1097 /* Call is hungup for some reason. */
1098 res = -1;
1099 } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1,
1100 S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1101 ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
1102 } else if (ast_exists_extension(chan, ast_channel_context(chan), "t", 1,
1103 S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1104 ast_verb(3, "Timeout on %s, going to 't'\n", ast_channel_name(chan));
1105 set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
1106 } else if (ast_exists_extension(chan, ast_channel_context(chan), "e", 1,
1107 S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
1108 raise_exception(chan, "RESPONSETIMEOUT", 0); /* 0 will become 1, next time through the loop */
1109 } else {
1110 ast_log(LOG_WARNING, "Timeout but no rule 't' or 'e' in context '%s'\n",
1111 ast_channel_context(chan));
1112 res = -1;
1113 }
1114 }
1115
1116 if (ast_test_flag(&flags, WAITEXTEN_MOH))
1118 else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE))
1119 ast_playtones_stop(chan);
1120
1121 return res;
1122}
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3194
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7604
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:4672
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
@ AST_CONTROL_UNHOLD
@ AST_CONTROL_HOLD
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
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
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:393
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:461
int raise_exception(struct ast_channel *chan, const char *reason, int priority)
Definition: pbx.c:2806
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
Definition: pbx.c:4264
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:4175
#define WAITEXTEN_MOH
Definition: pbx_builtins.c:713
#define WAITEXTEN_DIALTONE
Definition: pbx_builtins.c:714
static const struct ast_app_option waitexten_opts[128]
Definition: pbx_builtins.c:719
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, raise_exception(), ast_pbx::rtimeoutms, S_COR, S_OR, set_ext_pri(), TIMELEN_SECONDS, WAITEXTEN_DIALTONE, WAITEXTEN_MOH, and waitexten_opts.