[asterisk-users] how to match "no callerid" in 1.6 ?

Philipp Kempgen philipp.kempgen at amooma.de
Sat Jul 25 08:14:37 CDT 2009


Leif Madsen schrieb:

> I don't see how using the 
> exten[/callerid] notation is really better than the GotoIf()
> 
> Personally, the GotoIf() makes much more sense to me, because you're placing the 
> matching logic in a single place,

True.

> as opposed to an error prone method of adding 
> an ending / at the end of every line of that extension.

> exten => _[A-Za-z0-9].,1,Set(EXTENSION=${EXTEN})
> exten => _[A-Za-z0-9].,n,Goto(start,1)
>
> exten => start,1,Verbose(2,Incoming call from ${CALLERID(num)} to extension 
> ${EXTENSION})
> exten => start,n,GotoIf($[${CALLERID(num)} = 5551212]?bad_callerid,1)
> exten => start,n,...
> 
> exten => bad_callerid,1,Verbose(2,A very bad man!)
> exten => bad_callerid,n,Hangup()

> I think that is a better method than constantly typing a complex pattern match, 

BTW: If you hate having to type the same "exten => ...." stuff over
and over for each priority: use AEL and let the AEL compiler do the
work. :-)

_[A-Za-z0-9]. => {
    Verbose(2,Incoming call from ${CALLERID(num)} to extension ${EXTEN});
    if ("${CALLERID(num)}" = "5551212") {
        Verbose(2,A very bad man!);
        Hangup();
    }
    ...
}

And while we're at it: In many cases database lookups by means of
DB() or AGI() or a custom ODBC_*() function make even more sense
than a hard-coded list of GotoIf()s resp. if clauses.


    Philipp Kempgen
-- 
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
Videos of the AMOOCON VoIP conference 2009 ->  http://www.amoocon.de
-- 



More information about the asterisk-users mailing list