116 static const char app[] =
"DISA";
119 NOANSWER_FLAG = (1 << 0),
120 POUND_TO_END_FLAG = (1 << 1),
128 static void play_dialtone(
struct ast_channel *chan,
char *mailbox)
148 int i = 0, j, k = 0, did_ignore = 0, special_noanswer = 0;
149 int firstdigittimeout = (ast_channel_pbx(chan) ? ast_channel_pbx(chan)->
rtimeoutms : 20000);
150 int digittimeout = (ast_channel_pbx(chan) ? ast_channel_pbx(chan)->
dtimeoutms : 10000);
154 char ourcidname[256],ourcidnum[256];
156 struct timeval lastdigittime;
167 if (ast_strlen_zero(data)) {
168 ast_log(LOG_WARNING,
"DISA requires an argument (passcode/passcode file)\n");
172 ast_debug(1,
"Digittimeout: %d\n", digittimeout);
173 ast_debug(1,
"Responsetimeout: %d\n", firstdigittimeout);
179 if (ast_strlen_zero(args.context))
180 args.context =
"disa";
181 if (ast_strlen_zero(args.mailbox))
183 if (!ast_strlen_zero(args.options)) {
187 ast_clear_flag(&flags, AST_FLAGS_ALL);
191 ast_debug(1,
"Mailbox: %s\n",args.mailbox);
193 if (!ast_test_flag(&flags, NOANSWER_FLAG)) {
198 }
else special_noanswer = 1;
200 ast_debug(1,
"Context: %s\n",args.context);
202 if (!strcasecmp(args.passcode,
"no-password")) {
204 ast_debug(1,
"DISA no-password login success\n");
209 play_dialtone(chan, args.mailbox);
216 ast_debug(1,
"DISA %s entry timeout on chan %s\n",
217 ((k&1) ?
"extension" :
"password"),ast_channel_name(chan));
222 ast_debug(1,
"Waitfor returned %d\n", res);
233 ast_channel_hangupcause_set(chan, f->
data.uint32);
260 if (sscanf(args.passcode,
"%30d",&j) < 1) {
261 fp = fopen(args.passcode,
"r");
263 ast_log(LOG_WARNING,
"DISA password file %s not found on chan %s\n",args.passcode,ast_channel_name(chan));
268 while(fgets(pwline,
sizeof(pwline) - 1,fp)) {
271 if (pwline[strlen(pwline) - 1] ==
'\n')
272 pwline[strlen(pwline) - 1] = 0;
276 if (pwline[0] ==
'#')
278 if (pwline[0] ==
';')
283 ast_debug(1,
"Mailbox: %s\n",args.mailbox);
286 if (sscanf(args.passcode,
"%30d", &j) < 1)
289 if (!strcmp(exten,args.passcode)) {
290 if (ast_strlen_zero(args.context))
291 args.context =
"disa";
292 if (ast_strlen_zero(args.mailbox))
300 if (strcmp(exten,args.passcode)) {
301 ast_log(LOG_WARNING,
"DISA on chan %s got bad password %s\n",ast_channel_name(chan),exten);
306 ast_debug(1,
"DISA on chan %s password is good\n",ast_channel_name(chan));
307 play_dialtone(chan, args.mailbox);
311 exten[
sizeof(acctcode)] = 0;
314 ast_debug(1,
"Successful DISA log-in on chan %s\n", ast_channel_name(chan));
321 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL))
323 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL))) ) {
338 if (ast_test_flag(&flags, POUND_TO_END_FLAG) && j ==
'#') {
344 play_dialtone(chan,
"");
354 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL))) {
366 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL))) {
374 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL))) {
377 if (!ast_strlen_zero(args.cid)) {
378 ast_callerid_split(args.cid, ourcidname,
sizeof(ourcidname), ourcidnum,
sizeof(ourcidnum));
382 if (!ast_strlen_zero(acctcode)) {
383 ast_channel_lock(chan);
384 ast_channel_accountcode_set(chan, acctcode);
385 ast_channel_unlock(chan);
389 ast_log(AST_LOG_NOTICE,
"ResetCDR application not found; CDR will not be reset\n");
408 static int unload_module(
void)
413 static int load_module(
void)
419 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"DISA (Direct Inward System Access) Application");
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
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) ...
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
Support for translation of data formats. translate.c.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
ast_channel_state
ast_channel states
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
int ast_unregister_application(const char *app)
Unregister an application.
struct ast_frame_subclass subclass
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
u-Law to Signed linear conversion
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define AST_MAX_EXTENSION
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
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.
#define ast_debug(level,...)
Log a DEBUG message.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
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.
Core PBX routines and definitions.
int ast_pbx_exec_application(struct ast_channel *chan, const char *app_name, const char *app_args)
Execute an application.
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
union ast_frame::@224 data
Module has failed to load, may be in an inconsistent state.
Structure used to handle boolean flags.
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
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_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Data structure associated with a single frame of data.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
const char * data
Description of a tone.
enum ast_frame_type frametype
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.