App-blacklist-check context question

Hi,

I found that setting ‘Blacklist Module - Settings - Block Unknown/Blocked Caller ID’ to Yes, adds additional lines (I commented the lines) to the /etc/asterisk/extensions_additional.conf file
Here is a snippet from that file.

[app-blacklist-check]
include => app-blacklist-check-custom
exten => s,1,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "unknown"]?check-blocked)     ; 1 added
exten => s,n,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "unavailable"]?check-blocked) ; 2 added
exten => s,n,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "anonymous"]?check-blocked)   ; 3 added
exten => s,n,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "private"]?check-blocked)     ; 4 added
exten => s,n,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "restricted"]?check-blocked)  ; 5 added
exten => s,n,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "blocked"]?check-blocked)     ; 6 added
exten => s,n,GotoIf($["foo${CALLERID(number)}" = "foo"]?check-blocked:check)            ; 7 added
exten => s,n(check-blocked),GotoIf($["${DB(blacklist/blocked)}" = "1"]?blacklisted)     ; 8 added
exten => s,n(check),GotoIf($["${BLACKLIST()}"="1"]?blacklisted)
exten => s,n,Set(CALLED_BLACKLIST=1)
exten => s,n,Return()
exten => s,n(blacklisted),Answer
exten => s,n,Set(BLDEST=${DB(blacklist/dest)})
exten => s,n,ExecIf($["${BLDEST}"=""]?Set(BLDEST=app-blackhole,hangup,1))
exten => s,n,GotoIf($["${returnhere}"="1"]?returnto)
exten => s,n,GotoIf(${LEN(${BLDEST})}?${BLDEST}:app-blackhole,zapateller,1)
exten => s,n(returnto),Return()

;--== end of [app-blacklist-check] ==--;

I understand the purpose of those line are to check for common CID names like ‘unknown’ and block them.

My question is about the lines with “CALLERID(number)” function.
I understand that ‘number’ returns the number (3334445555) and ‘name’ returns the text (unknown) of the CID.

If this is correct, then
exten => s,1,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "unknown"]?check-blocked)
will fail to match because ‘number’ will never be ‘unknown’.

I think the line(s) should be
exten => s,1,GotoIf($["${TOLOWER(${CALLERID(name)})}" = "unknown"]?check-blocked)

Q1 Is this a bug or do I misunderstand what the lines are doing?

I have follow up questions, but first I need to understand if the number vs name is a bug.

Thank you,

Not quite. If the From header is
"Foo Bar" <sip:[email protected]>
then CALLERID(name) is set to Foo Bar and CALLERID(number) is set to 1234.
But on some anonymous calls or those with technical troubles, you may see
<sip:[email protected]>
in which case CALLERID(number) is set to Anonymous, even though it’s not a number.

If I understand correctly,
The line
exten => s,1,GotoIf($["${TOLOWER(${CALLERID(number)})}" = "unknown"]?check-blocked)
would block
From: "" <sip:[email protected]>

but would not block
From: "unknown" <sip:[email protected]>

I am confused, how often does “some anonymous calls or those with technical troubles” occur?

Thank you,

How frequent would depend on your environment, e.g. provider and sources of typical calls, but the SIP RFC contains an example of its use (page 212).

Asterisk’s use of the term number is misleading, as the field is a SIP user name which is not restricted to numbers. It probably comes about because Asterisk was initially implemented for ISDN, where it would be a number, and the most common use of SIP is to emualate phones systems which are restricted to the use of numbers.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.