Allow 11 digit CID

Dear All,
Still newbie on FreePBX. This might have been discussed before with no specific answer.
Am using FreePBX 13.0.124 I want to allow ONLY CIDs with 11 digits

Thanks
IPservices

Do you want to block calls with CID <> 11 or do you want evaluate the incoming CID and convert it to 11 digits if need be? Where is the server located? What is a typical CID there?

Thanks for your response
Basically we doing call termination and we need to ALLOW USA CIDs with 11 digits and DROP any other CID that comes with more or less than 11 digits.
Key thing inbound CID ALLOW 11 digits {1-9} on GUI FreePBX 13.0.124

Thanks

PSTN wise US numbers have only 10 digits sent in the CID , some VSP’s add the initial 1 , just write a custom context [from-pstn-ipserviceskenya] (and send your calls there) that parses the CALLERID(num) by length

http://www.voip-info.org/wiki/view/Asterisk+func+len

and hangsup if it is not 11 digits long, otherwise send it to from-pstn,${EXTEN},1 example in /etc/asterisk/extensions.conf in the [from-pstn-e164-us] context

dicko, dcitelecom
Having gone through the wiki to my understanding this will work well with CLI asterisk. As mentioned before mine is GUI where is this injected on the system

Thanks

Sorry you can’t do it with the GUI add something like:-

[from-pstn-ipserviceskenya]
exten => _.,n,Set(CURRENT_CID_LENGTH=${LEN(${CALLERID(num)})})
exten => _.,n,GotoIf($[${CURRENT_CID_LENGTH} = 11]?continue)
exten => _.,n,Playback(sorry-cant-let-you-do-that&goodbye)
exten => _.,n,Hangup()
exten => _.,n(continue),goto(from-pstn,${EXTEN},1)

to /etc/asterisk/extensions_custom.conf

In the GUI you would create 2 inbound Routes.

  1. CID = _NXXNXXXXXX
    DID = ANY
    Destination = your application

  2. CID = ANY, DID = ANY (leave blank to match all)
    Destination = terminate call.
    This will drop everything that doesn’t fit the first inbound route.

dcitelecom
Tried as per your instructions gives an error Call Rejected: 603 Declined to talk

Logs from the box
pbxCLI>
– Executing [[email protected]:1] NoOp(“PJSIP/Workstation-0000000d”, “Catch-All DID Match - Found 254721983216 - You probably want a DID for this.”) in new stack
[2016-06-11 00:12:08] WARNING[7797][C-0000000b]: chan_sip.c:22323 func_header_read: This function can only be used on SIP channels.
– Executing [[email protected]:2] Log(“PJSIP/Workstation-0000000d”, "WARNING,Friendly Scanner from ") in new stack
[2016-06-11 00:12:08] WARNING[7797][C-0000000b]: Ext. 254721983216:2 @ from-pstn: Friendly Scanner from
– Executing [[email protected]:3] Set(“PJSIP/Workstation-0000000d”, “__FROM_DID=254721983216”) in new stack
– Executing [[email protected]:4] Goto(“PJSIP/Workstation-0000000d”, “ext-did,s,1”) in new stack
– Goto (ext-did,s,1)
– Executing [[email protected]:1] Set(“PJSIP/Workstation-0000000d”, “__DIRECTION=INBOUND”) in new stack
– Executing [[email protected]:2] Gosub(“PJSIP/Workstation-0000000d”, “app-blacklist-check,s,1()”) in new stack
– Executing [[email protected]:1] GotoIf(“PJSIP/Workstation-0000000d”, “0?blacklisted”) in new stack
– Executing [[email protected]:2] Set(“PJSIP/Workstation-0000000d”, “CALLED_BLACKLIST=1”) in new stack
– Executing [[email protected]:3] Return(“PJSIP/Workstation-0000000d”, “”) in new stack
– Executing [[email protected]:3] ExecIf(“PJSIP/Workstation-0000000d”, “0?Set(__FROM_DID=s)”) in new stack
– Executing [[email protected]:4] Set(“PJSIP/Workstation-0000000d”, “CDR(did)=254721983216”) in new stack
– Executing [[email protected]:5] ExecIf(“PJSIP/Workstation-0000000d”, “0 ?Set(CALLERID(name)=)”) in new stack
– Executing [[email protected]:6] Set(“PJSIP/Workstation-0000000d”, “__MOHCLASS=”) in new stack
– Executing [[email protected]:7] Set(“PJSIP/Workstation-0000000d”, “__REVERSAL_REJECT=FALSE”) in new stack
– Executing [[email protected]:8] GotoIf(“PJSIP/Workstation-0000000d”, “1?post-reverse-charge”) in new stack
– Goto (ext-did,s,10)
– Executing [[email protected]:10] NoOp(“PJSIP/Workstation-0000000d”, “”) in new stack
– Executing [[email protected]:11] Set(“PJSIP/Workstation-0000000d”, “__CALLINGNAMEPRES_SV=allowed_not_screened”) in new stack
– Executing [[email protected]:12] Set(“PJSIP/Workstation-0000000d”, “__CALLINGNUMPRES_SV=allowed_not_screened”) in new stack
– Executing [[email protected]:13] Set(“PJSIP/Workstation-0000000d”, “CALLERID(name-pres)=allowed_not_screened”) in new stack
– Executing [[email protected]:14] Set(“PJSIP/Workstation-0000000d”, “CALLERID(num-pres)=allowed_not_screened”) in new stack
– Executing [[email protected]:15] NoOp(“PJSIP/Workstation-0000000d”, “CallerID Entry Point”) in new stack
– Executing [[email protected]:16] Goto(“PJSIP/Workstation-0000000d”, “app-blackhole,hangup,1”) in new stack
– Goto (app-blackhole,hangup,1)
– Executing [[email protected]:1] NoOp(“PJSIP/Workstation-0000000d”, “Blackhole Dest: Hangup”) in new stack
– Executing [[email protected]:2] Hangup(“PJSIP/Workstation-0000000d”, “”) in new stack
== Spawn extension (app-blackhole, hangup, 2) exited non-zero on 'PJSIP/Workstation-0000000d’
pbx
CLI>

I don’t see any CID number in your log.

Assuming you don’t want to look at Dicko’s suggestion,
First create a WORKING inbound DID route with the parameters you require. Once you got that working change the CID field of the inbound route to CID = _NXXNXXXXXX
That will allow the route only for CID = 11 digits.
Test it with inbound calls for CID = 11
Now create a catch all route for all other inbound calls that results in hangup.

Dicko’s Suggestion is ok am not familiar with the files to be edited might break everything.

Anyway my simulation setup is as follows and works fine
DID = _254XX
CID = ANY
Destination = Trunk

Neither does it show the CID Number in the logs as posted before nor pass calls it just terminates
DID = _254XX
CID = _NXXNXXXXXX
Destination = Trunk

DID = ANY
CID = ANY
Destination = Terminate

I made a small mistake. My CID pattern was 10 digits so use the one below instead.
CID = _1NXXNXXXXXX matches an area code and phone number preceeded by a one

You say you only want to allow 11 digit CIDs yet the inbound calls in your test log have no CID so when you start screening for CID with my inbound route, those calls obviously fail.

You DID is identified by 254721983216. All calls in Kenya that start with 7 are identified as Cell/Mobile phone numbers they are fixed length of 9 , your DID identifies as a Safaricom number, but it is likely you only have a few DID’s so you should have explicit matches for them.

you need to plan accordingly

DID = _254XX does not match anything

DID = 254721983216 matches your DID

DID = _2547[0129]XXXXXXX matches all Safaricom numbers

slice and dice for the rest

If you want a simple match to all Cell phones in Kenya

DID = _2547XXXXXXXX

will do that

DID _254[2356]XX.

will match all land-lines.

You need to be explicit with inbound calls or you end up nastily in the “s” extension as you discovered.

Edit: is it possible that you have your DID’s and CID’s confused?

dcitelecom
This too did not work for some reasons am not getting the CIDs in the logs I guess I will have to do some further reading and try Dicko’s

Dicko,
The Issue at hand is allowing 11 digit CID you had mentioned on Freepbx GUI it is not possible, we are looking at what you suggested earlier hand editing /etc/asterisk/extensions_custom.conf and hope this wont break the GUI files

Thanks Alot