Issue 8971 - Allow DISA input to be ended with a '#'.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@68854 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2007-06-11 22:21:28 +00:00
parent bd3de6d0f1
commit f314fa039b
2 changed files with 62 additions and 43 deletions

View File

@@ -47,6 +47,9 @@ Applications:
performs mostly a 'ChanExists' sort of function. performs mostly a 'ChanExists' sort of function.
* SetCallerPres() has been replaced with the CALLERPRES() dialplan function * SetCallerPres() has been replaced with the CALLERPRES() dialplan function
and is now deprecated. and is now deprecated.
* DISA()'s fifth argument is now an options argument. If you have previously
used 'NOANSWER' in this argument, you'll need to convert that to the new
option 'n'.
CDR: CDR:

View File

@@ -55,47 +55,55 @@ static char *app = "DISA";
static char *synopsis = "DISA (Direct Inward System Access)"; static char *synopsis = "DISA (Direct Inward System Access)";
static char *descrip = static char *descrip =
"DISA(<numeric passcode>[|<context>]) or DISA(<filename>)\n" "DISA(<numeric passcode>[|<context>[|<cid>[|mailbox[|options]]]]) or\n"
"DISA(<filename>[||||options])\n"
"The DISA, Direct Inward System Access, application allows someone from \n" "The DISA, Direct Inward System Access, application allows someone from \n"
"outside the telephone switch (PBX) to obtain an \"internal\" system \n" "outside the telephone switch (PBX) to obtain an \"internal\" system \n"
"dialtone and to place calls from it as if they were placing a call from \n" "dialtone and to place calls from it as if they were placing a call from \n"
"within the switch.\n" "within the switch.\n"
"DISA plays a dialtone. The user enters their numeric passcode, followed by\n" "DISA plays a dialtone. The user enters their numeric passcode, followed by\n"
"the pound sign (#). If the passcode is correct, the user is then given\n" "the pound sign (#). If the passcode is correct, the user is then given\n"
"system dialtone on which a call may be placed. Obviously, this type\n" "system dialtone within <context> on which a call may be placed. If the user\n"
"of access has SERIOUS security implications, and GREAT care must be\n" "enters an invalid extension and extension \"i\" exists in the specified\n"
"taken NOT to compromise your security.\n\n" "context, it will be used.\n"
"There is a possibility of accessing DISA without password. Simply\n" "\n"
"exchange your password with \"no-password\".\n\n" "If you need to present a DISA dialtone without entering a password, simply\n"
" Example: exten => s,1,DISA(no-password|local)\n\n" "set <passcode> to \"no-password\".\n"
"Be aware that using this compromises the security of your PBX.\n\n" "\n"
"Be aware that using this may compromise the security of your PBX.\n"
"\n"
"The arguments to this application (in extensions.conf) allow either\n" "The arguments to this application (in extensions.conf) allow either\n"
"specification of a single global passcode (that everyone uses), or\n" "specification of a single global passcode (that everyone uses), or\n"
"individual passcodes contained in a file. It also allows specification\n" "individual passcodes contained in a file.\n"
"of the context on which the user will be dialing. If no context is\n" "\n"
"specified, the DISA application defaults the context to \"disa\".\n" "The file that contains the passcodes (if used) allows a complete\n"
"Presumably a normal system will have a special context set up\n" "specification of all of the same arguments available on the command\n"
"for DISA use with some or a lot of restrictions. \n\n" "line, with the sole exception of the options. The file may contain blank\n"
"The file that contains the passcodes (if used) allows specification\n" "lines, or comments starting with \"#\" or \";\".\n"
"of either just a passcode (defaulting to the \"disa\" context, or\n" "\n"
"passcode|context on each line of the file. The file may contain blank\n" "<context> specifies the dialplan context in which the user-entered extension\n"
"lines, or comments starting with \"#\" or \";\". In addition, the\n" "will be matched. If no context is specified, the DISA application defaults\n"
"above arguments may have |new-callerid-string appended to them, to\n" "the context to \"disa\". Presumably a normal system will have a special\n"
"specify a new (different) callerid to be used for this call, for\n" "context set up for DISA use with some or a lot of restrictions.\n"
"example: numeric-passcode|context|\"My Phone\" <(234) 123-4567> or \n" "\n"
"full-pathname-of-passcode-file|\"My Phone\" <(234) 123-4567>. Last\n" "<cid> specifies a new (different) callerid to be used for this call.\n"
"but not least, |mailbox[@context] may be appended, which will cause\n" "\n"
"a stutter-dialtone (indication \"dialrecall\") to be used, if the\n" "<mailbox[@context]> will cause a stutter-dialtone (indication \"dialrecall\")\n"
"specified mailbox contains any new messages, for example:\n" "to be used, if the specified mailbox contains any new messages.\n"
"numeric-passcode|context||1234 (w/a changing callerid). Note that\n" "\n"
"in the case of specifying the numeric-passcode, the context must be\n" "The following options are available:\n"
"specified if the callerid is specified also.\n\n" " n - the DISA application will not answer initially.\n"
"If login is successful, the application looks up the dialed number in\n" " p - the extension entered will be considered complete when a '#' is entered.\n";
"the specified (or default) context, and executes it if found.\n"
"If the user enters an invalid extension and extension \"i\" (invalid) \n"
"exists in the context, it will be used. Also, if you set the 5th argument\n"
"to 'NOANSWER', the DISA application will not answer initially.\n";
enum {
NOANSWER_FLAG = (1 << 0),
POUND_TO_END_FLAG = (1 << 1),
} option_flags;
AST_APP_OPTIONS(app_opts, {
AST_APP_OPTION('n', NOANSWER_FLAG),
AST_APP_OPTION('p', POUND_TO_END_FLAG),
});
static void play_dialtone(struct ast_channel *chan, char *mailbox) static void play_dialtone(struct ast_channel *chan, char *mailbox)
{ {
@@ -116,6 +124,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
int firstdigittimeout = 20000; int firstdigittimeout = 20000;
int digittimeout = 10000; int digittimeout = 10000;
struct ast_module_user *u; struct ast_module_user *u;
struct ast_flags flags;
char *tmp, exten[AST_MAX_EXTENSION],acctcode[20]=""; char *tmp, exten[AST_MAX_EXTENSION],acctcode[20]="";
char pwline[256]; char pwline[256];
char ourcidname[256],ourcidnum[256]; char ourcidname[256],ourcidnum[256];
@@ -129,7 +138,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
AST_APP_ARG(context); AST_APP_ARG(context);
AST_APP_ARG(cid); AST_APP_ARG(cid);
AST_APP_ARG(mailbox); AST_APP_ARG(mailbox);
AST_APP_ARG(noanswer); AST_APP_ARG(options);
); );
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
@@ -168,13 +177,14 @@ static int disa_exec(struct ast_channel *chan, void *data)
args.context = "disa"; args.context = "disa";
if (ast_strlen_zero(args.mailbox)) if (ast_strlen_zero(args.mailbox))
args.mailbox = ""; args.mailbox = "";
if (!ast_strlen_zero(args.options))
ast_app_parse_options(app_opts, &flags, NULL, args.options);
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox); ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
special_noanswer = 0; special_noanswer = 0;
if ((!args.noanswer) || strcmp(args.noanswer,"NOANSWER")) if (ast_test_flag(&flags, NOANSWER_FLAG)) {
{
if (chan->_state != AST_STATE_UP) { if (chan->_state != AST_STATE_UP) {
/* answer */ /* answer */
ast_answer(chan); ast_answer(chan);
@@ -315,6 +325,12 @@ static int disa_exec(struct ast_channel *chan, void *data)
continue; /* if getting password, continue doing it */ continue; /* if getting password, continue doing it */
/* if this exists */ /* if this exists */
/* user wants end of number, remove # */
if (ast_test_flag(&flags, POUND_TO_END_FLAG) && j == '#') {
exten[--i] = 0;
break;
}
if (ast_ignore_pattern(args.context, exten)) { if (ast_ignore_pattern(args.context, exten)) {
play_dialtone(chan, ""); play_dialtone(chan, "");
did_ignore = 1; did_ignore = 1;