Another typical approach would be the “Best-Fit-Algorythm”. Let’s illustrate this:
MySQL-Table BLOCKED_NUMBERS
Number Block
123 1
456100 1
Asterisk func_odbc.conf Select
[GET_BLOCKED]
readsql=SELECT Block from BLOCKED_NUMBERS WHERE number='${SQL_ESC(${ARG1})}'
Asterisk Dialplan (AEL-example)
for (x=${LEN(${CALLERID(num)})}; ${x}>=1;x=${x}-1) {
Set(temp=${CALLERID(num):0:${x}});
Set(BLOCKED=${ODBC_GET_BLOCKED(${temp})});
if (! ${ISNULL(${BLOCKED})} ) {
Set(x=0);
Hangup(16); This is a blocked number calling us
}
}
In this example every CALLERID starting with either 123 or 456100 will get blocked (e.g. 123; 1234; 4561000 will be blocked but 456101 won’t)
The minimum match-lentgth ist herby defined with 1 Digit (${x}>=1), this may be changed when convenient.