[asterisk-users] howto store local exchange prefixes ?
Barry L. Kline
blkline at attglobal.net
Tue May 26 09:14:35 CDT 2009
sean darcy wrote:
> Maybe I've not explained this correctly. I know, or can look up, the 40+
> local exchanges that are local. I can parse the dial EXTEN to determine
> the exchange. I can check the exchange against a DB. I want to determine
> which exchanges are "local". I do not want to store an exchange dialed
> by a user.
I didn't explain myself very well.
My Asterisk system sits between the PSTN and a legacy PBX. Asterisk
answers the call and among other things, prompts for an extension
number. I needed to know if the extension entered is valid before
sending the call on to the old PBX. I simply have a lookup subroutine
to validate the extension.
My code for looking up the validity of their entry is:
exten => _[123]XX,1,Verbose(1,${CALLERID(all)} requested extension
${EXTEN});
exten => _[123]XX,n,Gosub(validate-extension,s,1(${EXTEN}));
exten => _[123]XX,n,Goto(extension-${GOSUB_RETVAL});
exten => _[123]XX,n(extension-FOUND),Verbose(1,${CALLERID(all)} xfer to
${DB(${DB_IWATSU_EXTENSIONS}/${EXTEN})} at extension ${EXTEN});
exten => _[123]XX,n,macro(bridge-to-iwatsu,7${EXTEN});
exten => _[123]XX,n(extension-NOTFOUND),background(pbx-invalid);
exten => _[123]XX,n,WaitExten(5);
The lookup, which will initialize the AsteriskDB if necessary, is:
;
; This subroutine's purpose is to check the validity of an extension.
;
; Parameters:
; ARG1 = Extension to check
; Returns:
; FOUND or NOTFOUND
;
[validate-extension]
exten => s,1,Verbose(1,Checking validity of extension ${ARG1});
;
; Let's check to ensure that the database is loaded. We'll do
; that by looking for extension 399, the Iwatsu master phone.
;
exten => s,n,GotoIf(${DB_EXISTS(${DB_IWATSU_EXTENSIONS}/399)}?search:load)
exten => s,n(load),DBdeltree(${DB_IWATSU_EXTENSIONS}); Clear all
existing entries
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/120)='Rikki')
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/121)='Terri')
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/122)='CorpConf')
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/123)='Linda')
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/124)='Kim')
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/125)='Nancy B')
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/126)='Wayne')
...
;
; Extension 399 is the master extension for the Iwatsu
; and should always show up. It is used for testing
; the validity of the database in the dialplan.
;
exten => s,n,Set(DB(${DB_IWATSU_EXTENSIONS}/399)='MASTER')
;
; Search here
;
exten =>
s,n(search),GotoIf(${DB_EXISTS(${DB_IWATSU_EXTENSIONS}/${ARG1})}?found:notfound)
exten => s,n(found),Return(FOUND);
exten => s,n(notfound),Return(NOTFOUND);
More information about the asterisk-users
mailing list