[RESOLVED] Help with a line in my dialplan

My system consists of: Asterisk 11.8.1, Dahdi 2.9.1, Ubuntu Server 12.04
I have PSTN service with a 4 port Digium analog card configured as follows:
DAHDI/1 FXO connected to my provider
DAHDI/2 FXS connected to my home phones
DAHDI/3 connected to a hardware answering machine. This is where I send blocked calls

This is a cut/paste from my cdr-custom Master.csv log. I would like to block the following type of call where the first entry CDR(clid) is the same as the second entry CDR(src)

“8187896539”,“8187896539”,“s”,“DAHDI/1-1”,“DAHDI/2-1”,“Dial”,“DAHDI/2”,“2014-08-12 08:41:46”,“2014-08-12 08:42:02”,“2014-08-12 08:42:10”,“24”,“ANSWERED”

I have the following line in my dialplan. The objective is if the values of CDR(clid) is the same as CDR(src), then I want to block it (send it to DAHDI/3)

same => n,GotoIf($["${CDR(clid)}"="${CDR(src)}"]?blocked,1)

The problem I am having is that calls where it seems CDR(clid) is not the same as CDR(src) are also getting blocked. The following is an example from my log (with name and number changed) of a call that was blocked by this dialplan code.

“”“SMITH RICHARD “” <5555555555>”,“5555555555”,“blocked”,“DAHDI/1-1”,“DAHDI/3-1”,“Dial”,“DAHDI/3”,“2014-08-12 09:36:49”,“2014-08-12 09:36:59”,“2014-08-12 09:37:12”,“23”,“ANSWERED”

If I comment out the 1 line on the dial plan, then the call is no longer blocked

“”“SMITH RICHARD “” <5555555555>”,“5555555555”,“s”,“DAHDI/1-1”,“DAHDI/2-1”,“Dial”,“DAHDI/2”,“2014-08-12 09:41:53”,"",“2014-08-12 09:42:11”,“18”,“NO ANSWER”

Any ideas on how to fix this? Thanks in advance for any help.

I wouldn’t use the CDR fields; some may be set quite late.

What is the goal? (What is happening in the real world that you want to reject?)

David55,
I am getting on average 8 telemarketing calls per day. Blacklisting the numbers is of limited value because the spammers are spoofing unused numbers in local area codes and new numbers are constantly being used. The one thing that is unique about the spam calls is that the CDR(clid) and the CDR(src) are the same. I have gone back through my archived logs and I see no legitimate calls that have this characteristic, so it seems this would be an effective way to filter these calls if I can make it work.

Do you actually mean that “${CALLERID(name)}” = “”?

I’m not aware of any analogue caller ID system that provides ANI.

Hi guys,

Pilot, can you post complete dialplan here? it will help to diagnose the issue.

Below is the dialplan. Most of the pertinent information is in my first post of this subject. I am using Asterisk’s ASTdb with whitelist, blacklist, and cidname families to either accept (route to DAHDI/2) or block (route to DAHDI/3) incoming calls. The line that is commented out is the one that fails. It blocks calls when the log indicates that CDR(clid) and CDR(src) are not the same. Again, see my first post for further information and log entries.

[globals]
OUT=DAHDI/1

[from-pstn]
exten => s,1,NoOp()
same => n,GotoIf($["${DB_EXISTS(whitelist/${CALLERID(number)})}"=“1”]?passed)
same => n,GotoIf($["${CALLERID(number)}"=""]?blocked,1)
; same => n,GotoIf($["${CDR(clid)}"="${CDR(src)}"]?blocked,1)
same => n,GotoIf($[${BLACKLIST()}]?blocked,1)
same => n,GotoIf($["${DB_EXISTS(cidname/${TOUPPER(${CALLERID(name)})})}"=“1”]?blocked,1)
same => n(passed),Dial(DAHDI/2)
same => n,Hangup()

exten => blocked,1,Dial(DAHDI/3)
same => n,Hangup()

[outgoing]
exten => _NXXNXXXXXX,1,Dial(${OUT}/${EXTEN})
exten => _NXXXXXX,1,Dial(${OUT}/${EXTEN})
exten => _1NXXNXXXXXX,1,Dial(${OUT}/${EXTEN})
exten => _911,1,Dial(${OUT}/${EXTEN})
exten => _411,1,Dial(${OUT}/${EXTEN})

[localsets]
include => outgoing
exten => 101,1,Dial(DAHDI/2)
exten => 102,1,Dial(DAHDI/3)
exten => 103,1,Dial(DAHDI/4)

After thinking about this some more, I may be able to accomplish the same thing by identifying CALLERID(name) that is made up of only digits from 0-9. Any help with crafting a dialplan statement that does that is appreciated.

hi

same => n,GotoIf($["${DB_EXISTS(whitelist/${CALLERID(number)})}"=“1”]?passed)

what does =“1” mean here?

Sohaib Khan

I think it is a contorted way of saying if true.

However, that line is after his problem line (and I still think he is really intending to check for an empty caller name).

Here are replies to the 2 previous posts:

To S. Kahn:
The 1 is a return code from the DB_EXISTS() function which I use twice in the dialplan. It returns a 1 if it finds what is within the ( ) and a 0 (zero) if it does not. The 2 dialplan entries are:
same => n,GotoIf($["${DB_EXISTS(whitelist/${CALLERID(number)})}"=“1”]?passed)
same => n,GotoIf($["${DB_EXISTS(cidname/${TOUPPER(${CALLERID(name)})})}"=“1”]?blocked,1)
In the first use, if the function finds the match of a callerid number in the whitelist family in the ASTdb, then the call is accepted. (routed to passed)
In the second use, if the function finds a match for a callerid name in the cidname family in the ASTdb, then the call is routed to an answering machine. (routed to blocked)

To David55 :
I am willing to see if checking for an empty caller id name works. I did not try that because in the logs it appears the caller ID is the same as the originating caller number. In the following log entry from my logs the first field is CDR(clid) and the second is CDR(src). Both are 8187896539. Am I interpreting this log entry wrong?
“8187896539”,“8187896539”,“s”,“DAHDI/1-1”,“DAHDI/2-1”,“Dial”,“DAHDI/2”,“2014-08-12 08:41:46”,“2014-08-12 08:42:02”,“2014-08-12 08:42:10”,“24”,“ANSWERED”

Do you see any issues with this line added to the dialplan to do check for an empty caller id name?
same => n,GotoIf($["${CALLERID(name)}"=""]?blocked,1)
Thanks for any help you can provide

It is the normal purpose of the caller ID to represent the caller number! The reason for two fields is ifthe network, or dialplan, supports the concept of an accounting number, different from the presentation number. End users generally don’t get to see the accounting number, so Asterisk will set it to ${CALLERID(num)}.

David55,
You were correct that looking for an empty caller ID name is what I needed to do.
Adding the following line to the dialplan solved the problem
same => n,GotoIf($["${CALLERID(name)}"=""]?blocked,1)
With the logs in debug (which I should have done sooner) I see that the caller id name for these telemarketing calls is (NULL) and the CDR values are set too late to be of any use in the dialplan. At the end of the call when the CDR values are set, if a callerid name is not present the CDR(clid) seems to be set to the source number as you said.

Thanks for your help