CID based inbound routing problem

Since i upgraded to 2.5.x i have problems with inbound call routing based on CID.

I removed all routes and started with only an inbound route for CID=0000000000 which leads the caller to an announcement.

I can confirm that this route works for this CID, but when i make an inbound call with another CID i keep getting the “Unavailable” message.

To solve that i added the “catchall” (any DID/ any CID) route. After that addition i can receive calls from any CID, but since then the inbound route for CID=0000000000 is not being triggered anymore.

In version 2.4.x. the “catchall” route was listed at the bottom of the inbound routes, however it is listed on top in this version.
It seems that the “catchall” route takes presedence over (i.e. has a higher priority than) all other routes.

Effectively this would mean that the catchall route cannot be used in combination with any other inbound route, which does not seem to make sense.

Any ideas?

The catchall should be last, it should look like this:

[from-pstn]                                                                                                                         
include => from-pstn-custom                     ; create this context in extensions_custom.conf to include customizations           
include => ext-did                                                                                                                  
include => ext-did-post-custom                                                                                                      
include => from-did-direct    ; MODIFICATOIN (PL) for findmefollow if enabled, should be bofore ext-local                           
include => ext-did-catchall   ; THIS MUST COME AFTER ext-did                                                                        

The auto-generated ext-did route should look like this:

[ext-did]
include => ext-did-custom
include => ext-did-0001
include => ext-did-0002
exten => fax,1,Goto(ext-fax,in_fax,1)

In the case of your CID ONLY route, it will be in either 0001 or 0002 depending on whether you check the Priority CID checkbox or not. In either case, ext-did comes well above ext-did-catchall which is what catches undefined DIDs.

My config looks (almost) similar to your examples, however inbound routing still does not work when catchall (any DID/any CID) is enabled.

Only the line

[b]include => ext-did-post-custom [/b] seems to be missing in the [from-pstn] context. However i suppose that is not the cause of the problems.

Following are the related sections of the config files:

extensions.conf
===============

[from-pstn] include => from-pstn-custom ; create this context in extensions_custom.conf to include customizations include => ext-did include => from-did-direct ; MODIFICATOIN (PL) for findmefollow if enabled, should be bofore ext-local include => ext-did-catchall ; THIS MUST COME AFTER ext-did exten => fax,1,Goto(ext-fax,in_fax,1)

extensions_additional.conf
==========================

[code][ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,GotoIf($[ “${CALLERID(name)}” != “” ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => _./0000000000,1,Set(__FROM_DID=${EXTEN})
exten => _./0000000000,n,Gosub(app-blacklist-check,s,1)
exten => _./0000000000,n,GotoIf($[ “${CALLERID(name)}” != “” ] ?cidok)
exten => _./0000000000,n,Set(CALLERID(name)=${CALLERID(num)})
exten => _./0000000000,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => _./0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => _./0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => _./0000000000,n,Goto(app-announcement-3,s,1)

; end of [ext-did-0001][/code]

extensions_additional.conf
==========================

[code][ext-did]
include => ext-did-custom
include => ext-did-0001
include => ext-did-0002
exten => fax,1,Goto(ext-fax,in_fax,1)

; end of [ext-did][/code]

Now even replaced Trunk version of asterisk by version 1.6.0.1, however catchall keeps breaking callerid-based inbound routing ;-(

try posting a trace of your inbound call.

WITHOUT CATCHALL

    -- Executing [[email protected]:1] Set("SIP/SipuraPSTN-b7517348", "__FROM_DID=s") in new stack
    -- Executing [[email protected]:2] Gosub("SIP/SipuraPSTN-b7517348", "app-blacklist-check,s,1") in new stack
    -- Executing [[email protected]:1] GotoIf("SIP/SipuraPSTN-b7517348", "0?blacklisted") in new stack
    -- Executing [[email protected]:2] Return("SIP/SipuraPSTN-b7517348", "") in new stack
    -- Executing [[email protected]:3] GotoIf("SIP/SipuraPSTN-b7517348", "0 ?cidok") in new stack
    -- Executing [[email protected]:4] Set("SIP/SipuraPSTN-b7517348", "CALLERID(name)=0000000000") in new stack
    -- Executing [[email protected]:5] NoOp("SIP/SipuraPSTN-b7517348", "CallerID is "0000000000" <0000000000>") in new stack
    -- Executing [[email protected]:6] Set("SIP/SipuraPSTN-b7517348", "__CALLINGPRES_SV=allowed_not_screened") in new stack
    -- Executing [[email protected]:7] Set("SIP/SipuraPSTN-b7517348", "CALLERPRES()=allowed_not_screened") in new stack
    -- Executing [[email protected]:8] Goto("SIP/SipuraPSTN-b7517348", "app-announcement-3,s,1") in new stack
    -- Goto (app-announcement-3,s,1)
    -- Executing [[email protected]:1] GotoIf("SIP/SipuraPSTN-b7517348", "0?begin") in new stack
    -- Executing [[email protected]:2] Answer("SIP/SipuraPSTN-b7517348", "") in new stack
    -- Executing [[email protected]:3] Wait("SIP/SipuraPSTN-b7517348", "1") in new stack
    -- Executing [[email protected]:4] NoOp("SIP/SipuraPSTN-b7517348", "Playing announcement callcenter-announce") in new stack
    -- Executing [[email protected]:5] Playback("SIP/SipuraPSTN-b7517348", "custom/callcenter-ivr,noanswer") in new stack
    -- <SIP/SipuraPSTN-b7517348> Playing 'custom/callcenter-ivr.slin' (language 'en')
  == Spawn extension (app-announcement-3, s, 5) exited non-zero on 'SIP/SipuraPSTN-b7517348'

WITH CATCHALL

    -- Executing [[email protected]:1] Set("SIP/SipuraPSTN-b75142c8", "__FROM_DID=s") in new stack
    -- Executing [[email protected]:2] Gosub("SIP/SipuraPSTN-b75142c8", "app-blacklist-check,s,1") in new stack
    -- Executing [[email protected]:1] GotoIf("SIP/SipuraPSTN-b75142c8", "0?blacklisted") in new stack
    -- Executing [[email protected]:2] Return("SIP/SipuraPSTN-b75142c8", "") in new stack
    -- Executing [[email protected]:3] GotoIf("SIP/SipuraPSTN-b75142c8", "0 ?cidok") in new stack
    -- Executing [[email protected]:4] Set("SIP/SipuraPSTN-b75142c8", "CALLERID(name)=0000000000") in new stack
    -- Executing [[email protected]:5] NoOp("SIP/SipuraPSTN-b75142c8", "CallerID is "0000000000" <0000000000>") in new stack
    -- Executing [[email protected]:6] Set("SIP/SipuraPSTN-b75142c8", "__CALLINGPRES_SV=allowed_not_screened") in new stack
    -- Executing [[email protected]:7] Set("SIP/SipuraPSTN-b75142c8", "CALLERPRES()=allowed_not_screened") in new stack
    -- Executing [[email protected]:8] Goto("SIP/SipuraPSTN-b75142c8", "app-announcement-1,s,1") in new stack
    -- Goto (app-announcement-1,s,1)
    -- Executing [[email protected]:1] GotoIf("SIP/SipuraPSTN-b75142c8", "0?begin") in new stack
    -- Executing [[email protected]:2] Answer("SIP/SipuraPSTN-b75142c8", "") in new stack
    -- Executing [[email protected]:3] Wait("SIP/SipuraPSTN-b75142c8", "1") in new stack
    -- Executing [[email protected]:4] NoOp("SIP/SipuraPSTN-b75142c8", "Playing announcement sorry") in new stack
    -- Executing [[email protected]:5] Playback("SIP/SipuraPSTN-b75142c8", "custom/sorry,noanswer") in new stack
    -- <SIP/SipuraPSTN-b75142c8> Playing 'custom/sorry.gsm' (language 'en')
    -- Executing [[email protected]:6] Goto("SIP/SipuraPSTN-b75142c8", "app-blackhole,hangup,1") in new stack
    -- Goto (app-blackhole,hangup,1)
    -- Executing [[email protected]:1] NoOp("SIP/SipuraPSTN-b75142c8", "Blackhole Dest: Hangup") in new stack
    -- Executing [[email protected]:2] Hangup("SIP/SipuraPSTN-b75142c8", "") in new stack
  == Spawn extension (app-blackhole, hangup, 2) exited non-zero on 'SIP/SipuraPSTN-b75142c8'

Also the config when [any CID/any DID] inbound route is enabled:

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => _./0000000000,1,Set(__FROM_DID=${EXTEN})
exten => _./0000000000,n,Gosub(app-blacklist-check,s,1)
exten => _./0000000000,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => _./0000000000,n,Set(CALLERID(name)=${CALLERID(num)})
exten => _./0000000000,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => _./0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => _./0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => _./0000000000,n,Goto(app-announcement-3,s,1)

; end of [ext-did-0001]

the line:
exten => s,n,Goto(timeconditions,2,1)
belongs to the [any DID/any CID] inbound route. Since this comes before the inbound route for [CID=0000000000] the call flows to timeconditions,2,1 instead of app-anouncement-3,s,1

I still don’t understand why the [any DID/any CID] inbound route comes before the other inbound routes. It is also at the top of the list in the GUI, however it was at the bottom in version 2.4.x

I think I see your issue, your Siupra device is sending it to “s” which is therefore going to the s extension. That may be why we have had occasional issues like this. Some providers may be doing the same thing. You should be able to reconfigure your Sipura to send it to a proper DID. But we’ll have to think about this, it may warrant a change back to the old way.

Yes,
try the following patch to core’s functions.inc.php. This should address DIDs that come as ‘s’ as well as those that come as a proper DID.

#3345

Index: functions.inc.php
===================================================================
--- functions.inc.php (revision 7124)
+++ functions.inc.php (working copy)
@@ -885,9 +885,11 @@
          // but we don't want to limit this to just numberic as someone may be trying to
          // route a non-numeric did
          //
+         $cidroute = false;
          if ($cidnum != '' && $exten == '') {
            $exten = '_.';
            $pricid = ($item['pricid']) ? true:false;
+           $cidroute = true;
          } else if (($cidnum != '' && $exten != '') || ($cidnum == '' && $exten == '')) {
            $pricid = true;
          } else {
@@ -898,9 +900,14 @@
          $exten = (empty($exten)?"s":$exten);
          $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it

+         if ($cidroute) {
+           $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
+           $ext->add($context, $exten, '', new ext_goto('L'.$cidnum,'s'));
+           $exten = "s/$cidnum";
+         }
          $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
          // always set callerID name
-         $ext->add($context, $exten, '', new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok'));
+         $ext->add($context, $exten, 'L'.$cidnum, new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok'));
          $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}'));
          $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}'));

Philippe,

thanks for your feedback!
I tried to patch the functions.inc.php but now the patch is getting rejected:

[[email protected] core]# patch functions.inc.php functions.inc.php.patch patching file functions.inc.php Hunk #1 FAILED at 885. Hunk #2 FAILED at 900. 2 out of 2 hunks FAILED -- saving rejects to file functions.inc.php.rej

And this is the content of the file functions.inc.php.rej:

***************
*** 885,893 ****
           // but we don't want to limit this to just numberic as someone may be trying to
           // route a non-numeric did
           //
           if ($cidnum != '' && $exten == '') {
             $exten = '_.';
             $pricid = ($item['pricid']) ? true:false;
           } else if (($cidnum != '' && $exten != '') || ($cidnum == '' && $exten == '')) {
             $pricid = true;
           } else {
--- 885,895 ----
           // but we don't want to limit this to just numberic as someone may be trying to
           // route a non-numeric did
           //
+          $cidroute = false;
           if ($cidnum != '' && $exten == '') {
             $exten = '_.';
             $pricid = ($item['pricid']) ? true:false;
+            $cidroute = true;
           } else if (($cidnum != '' && $exten != '') || ($cidnum == '' && $exten == '')) {
             $pricid = true;
           } else {
***************
*** 898,906 ****
           $exten = (empty($exten)?"s":$exten);
           $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it

           $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
           // always set callerID name
-          $ext->add($context, $exten, '', new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok'));
           $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}'));
           $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}'));

--- 900,913 ----
           $exten = (empty($exten)?"s":$exten);
           $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it

+          if ($cidroute) {
+            $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
+            $ext->add($context, $exten, '', new ext_goto('L'.$cidnum,'s'));
+            $exten = "s/$cidnum";
+          }
           $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
           // always set callerID name
+          $ext->add($context, $exten, 'L'.$cidnum, new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok'));
           $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}'));
           $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}'));

Yvo

Hi Philippe, it works!!

After forcing the patch on the file, i can confirm that the CID-based inbound routing works as before now, which is perfect!

This is how te config looks now:

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n(L),GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => _./0000000000,1,Set(__FROM_DID=${EXTEN})
exten => _./0000000000,n,Gosub(app-blacklist-check,s,1)
exten => _./0000000000,n,Goto(s,L0000000000)
exten => s/0000000000,1,Set(__FROM_DID=${EXTEN})
exten => s/0000000000,n(L0000000000),GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s/0000000000,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s/0000000000,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s/0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s/0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => s/0000000000,n,Goto(app-announcement-3,s,1)

; end of [ext-did-0001]

And this is the new callflow:

    -- Executing [[email protected]:1] Set("SIP/SipuraPSTN-b751a400", "__FROM_DID=s") in new stack
    -- Executing [[email protected]:2] GotoIf("SIP/SipuraPSTN-b751a400", "0 ?cidok") in new stack
    -- Executing [[email protected]:3] Set("SIP/SipuraPSTN-b751a400", "CALLERID(name)=0000000000") in new stack
    -- Executing [[email protected]:4] NoOp("SIP/SipuraPSTN-b751a400", "CallerID is "0000000000" <0000000000>") in new stack
    -- Executing [[email protected]:5] Set("SIP/SipuraPSTN-b751a400", "__CALLINGPRES_SV=allowed_not_screened") in new stack
    -- Executing [[email protected]:6] Set("SIP/SipuraPSTN-b751a400", "CALLERPRES()=allowed_not_screened") in new stack
    -- Executing [[email protected]:7] Goto("SIP/SipuraPSTN-b751a400", "app-announcement-3,s,1") in new stack
    -- Goto (app-announcement-3,s,1)
    -- Executing [[email protected]:1] GotoIf("SIP/SipuraPSTN-b751a400", "0?begin") in new stack
    -- Executing [[email protected]:2] Answer("SIP/SipuraPSTN-b751a400", "") in new stack
    -- Executing [[email protected]:3] Wait("SIP/SipuraPSTN-b751a400", "1") in new stack
    -- Executing [[email protected]:4] NoOp("SIP/SipuraPSTN-b751a400", "Playing announcement callcenter-announce") in new stack
    -- Executing [[email protected]:5] Playback("SIP/SipuraPSTN-b751a400", "custom/callcenter-ivr,noanswer") in new stack
    -- <SIP/SipuraPSTN-b751a400> Playing 'custom/callcenter-ivr.slin' (language 'en')
    -- Executing [[email protected]:6] Goto("SIP/SipuraPSTN-b751a400", "ivr-2,s,1") in new stack
    -- Goto (ivr-2,s,1)
    -- Executing [[email protected]:1] Set("SIP/SipuraPSTN-b751a400", "MSG=custom/callcenter-ivr") in new stack
    -- Executing [[email protected]:2] Set("SIP/SipuraPSTN-b751a400", "LOOPCOUNT=0") in new stack
    -- Executing [[email protected]:3] Set("SIP/SipuraPSTN-b751a400", "__DIR-CONTEXT=default") in new stack
    -- Executing [[email protected]:4] Set("SIP/SipuraPSTN-b751a400", "_IVR_CONTEXT_ivr-2=") in new stack
    -- Executing [[email protected]:5] Set("SIP/SipuraPSTN-b751a400", "_IVR_CONTEXT=ivr-2") in new stack
    -- Executing [[email protected]:6] GotoIf("SIP/SipuraPSTN-b751a400", "1?begin") in new stack
    -- Goto (ivr-2,s,9)
    -- Executing [[email protected]:9] Set("SIP/SipuraPSTN-b751a400", "TIMEOUT(digit)=3") in new stack
    -- Digit timeout set to 3
    -- Executing [[email protected]:10] Set("SIP/SipuraPSTN-b751a400", "TIMEOUT(response)=5") in new stack
    -- Response timeout set to 5
    -- Executing [[email protected]:11] Set("SIP/SipuraPSTN-b751a400", "__IVR_RETVM=") in new stack
    -- Executing [[email protected]:12] ExecIf("SIP/SipuraPSTN-b751a400", "1?Background(custom/callcenter-ivr)") in new stack
    -- <SIP/SipuraPSTN-b751a400> Playing 'custom/callcenter-ivr.slin' (language 'en')
  == Spawn extension (ivr-2, s, 12) exited non-zero on 'SIP/SipuraPSTN-b751a400'
    -- Executing [[email protected]:1] Hangup("SIP/SipuraPSTN-b751a400", "") in new stack
  == Spawn extension (ivr-2, h, 1) exited non-zero on 'SIP/SipuraPSTN-b751a400'

Thanks for your efforts.

Kind regards,
Yvo

I don’t know if the following issue could be related. If not i will start another topic for it to keep things clear:

Now that CID-based inbound routing works i started to re-configure the routes which i previously deleted.
I’m routing the call to the callback module, but although the call is being hung up the callback does not take place.

Even when i start the callback script manually from the commandline nothing happens:

[[email protected] core]# /var/lib/asterisk/bin/callback 0612345678 from-internal.200.1 1

Checking for PEAR Console::Getopt..OK
Reading /etc/amportal.conf..OK
Getting passed arguments:
Array
(
    [0] => 061234567890
    [1] => from-internal.200.1
    [2] => 1
)

the callback issue should not be related, but it looks like the patch is not complete, blacklist still expect to hook into the _. …, that means blacklist is going to have to be patched for this also. Will have to have a closer look and see if there are any other subtle implications (cidlookup is probably another example that is going to have to be effected).

Will be back later today with another update…

See updated to #3345 that now includes 3 patch files for core, blacklist and cidlookup - please test and provide feedback (preferably on the ticket) and if all looks good, we can get these fixes pushed out.

I would like to provide the comments directly on the ticket as you suggest, but it could get messed up there with all the logging & config i’m posting here.
Also i never used the blacklist and cidlookup features before.
But I will try their functionality and provide my findings.

About the patches:

  1. There was an error while applying the cidlookup.patch on functions.inc.php (after the file has already been succesfully patched with both other patches)
[[email protected] core]# patch -l -f -o functions.inc.php.patched functions.inc.php cidlookup.patch
patching file functions.inc.php
Hunk #1 FAILED at 84.
1 out of 1 hunk FAILED -- saving rejects to file functions.inc.php.patched.rej
  1. After applying the 3 patches CID-based inbound routing still works.
  2. The blacklist part looks unchanged to me.

Following is how the ext-did section looks now:

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => _./0000000000,1,Set(__FROM_DID=${EXTEN})
exten => _./0000000000,n,Gosub(app-blacklist-check,s,1)
exten => _./0000000000,n,Goto(s,1)
exten => s/0000000000,1,ExecIf($["${FROM_DID}" = ""]?Set(__FROM_DID=${EXTEN}))
exten => s/0000000000,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s/0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s/0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => s/0000000000,n,Goto(app-announcement-3,s,1)

the blacklist patch did not apply correctly based on your output. It should look something like this (example included cidlookup included in the route as well):

exten => _./0000000000,1,Set(__FROM_DID=${EXTEN})
exten => _./0000000000,n,Goto(s,1)
exten => s/0000000000,1,ExecIf($["${FROM_DID}" = ""],Set,__FROM_DID=${EXTEN})
exten => s/0000000000,n,Gosub(app-blacklist-check,s,1)
exten => s/0000000000,n,Gosub(cidlookup,cidlookup_1,1)
exten => s/0000000000,n,ExecIf($[ "${CALLERID(name)}" = "" ] ,Set,CALLERID(name)=${CALLERID(num)})
exten => s/0000000000,n,Set(__CALLINGPRES_SV=${CALLINGPRES_${CALLINGPRES}})
exten => s/0000000000,n,SetCallerPres(allowed_not_screened)
exten => s/0000000000,n,Goto(from-did-direct,222,1)

the blacklist and cidlookup patches are trivial, you can do them by hand if needed.

The code seems correct though:
The line
$exten = ‘s’;
exists after the patch:

                                        $cidnum = trim($item['cidnum']);

                                        // If the user put in just a cid number for routing, we add _. pattern to catch
                                        // all DIDs with that CID number. Asterisk will complain about _. being dangerous
                                        // but we don't want to limit this to just numberic as someone may be trying to
                                        // route a non-numeric did
                                        //
                                        $cidroute = false;
                                        if ($cidnum != '' && $exten == '') {
                                                $exten = 's';
                                                $pricid = ($item['pricid']) ? true:false;
                                                $cidroute = true;
                                        } else if (($cidnum != '' && $exten != '') || ($cidnum == '' && $exten == '')) {
                                                $pricid = true;
                                        } else {
                                                $pricid = false;
                                        }

well this line:

exten => _./0000000000,n,Gosub(app-blacklist-check,s,1)

seems to indicate that it is not or you would have an ‘s’ there instead of the ‘._’ so I’m not sure what is up and would like to make sure this is all clean before we submit anything. (this code is to central to push out an update that we are not 100% confident with).

Config after ext-did patch:

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => _./0000000000,1,Set(__FROM_DID=${EXTEN})
exten => _./0000000000,n,Gosub(app-blacklist-check,s,1)
exten => _./0000000000,n,Goto(s,1)
exten => s/0000000000,1,ExecIf($["${FROM_DID}" = ""]?Set(__FROM_DID=${EXTEN}))
exten => s/0000000000,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s/0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s/0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => s/0000000000,n,Goto(app-announcement-3,s,1)

Config after ext-did + (manual) blacklist patch:

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => s/0000000000,1,Set(__FROM_DID=${EXTEN})
exten => s/0000000000,n,Goto(s,1)
exten => s/0000000000,n,ExecIf($["${FROM_DID}" = ""]?Set(__FROM_DID=${EXTEN}))
exten => s/0000000000,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s/0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s/0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => s/0000000000,n,Goto(app-announcement-3,s,1)

Now blacklist check disappears ;-(

It looks to me like you have had some problems doing the patch:

exten => s/0000000000,1,Set(__FROM_DID=${EXTEN})
exten => s/0000000000,n,Goto(s,1)

that’s an infinite loop. You should revert your files to the original and then re-apply the patches. The blacklist and cidlookup are very simple, they are just replacing ‘_.’ with ‘s’ - the one for core is a bit more involved.

Ok,

I did all the steps on the original files again and after 1 extra manual adjustment in core everything seem right now.

The core patch misses 1 occurence of ‘_.’ which also needed to be adjusted (line 11 of patch file):

$exten = ‘_.’;

After that adjustment the config looks okay:

Index: functions.inc.php
===================================================================
--- functions.inc.php   (revision 7124)
+++ functions.inc.php   (working copy)
@@ -885,9 +885,11 @@
                                        // but we don't want to limit this to just numberic as someone may be trying to
                                        // route a non-numeric did
                                        //
+                                       $cidroute = false;
                                        if ($cidnum != '' && $exten == '') {
                                                $exten = '_.';
                                                $pricid = ($item['pricid']) ? true:false;
+                                               $cidroute = true;
                                        } else if (($cidnum != '' && $exten != '') || ($cidnum == '' && $exten == '')) {
                                                $pricid = true;
                                        } else {
@@ -898,11 +900,16 @@
                                        $exten = (empty($exten)?"s":$exten);
                                        $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it

-                                       $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
+                                       if ($cidroute) {
+                                               $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
+                                               $ext->add($context, $exten, '', new ext_goto('1','s'));
+                                               $exten = "s/$cidnum";
+                                               $ext->add($context, $exten, '', new ext_execif('$["${FROM_DID}" = ""]','Set','__FROM_DID=${EXTEN}'));
+                                       } else {
+                                               $ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
+                                       }
                                        // always set callerID name
-                                       $ext->add($context, $exten, '', new ext_gotoif('$[ "${CALLERID(name)}" != "" ] ','cidok'));
-                                       $ext->add($context, $exten, '', new ext_setvar('CALLERID(name)','${CALLERID(num)}'));
-                                       $ext->add($context, $exten, 'cidok', new ext_noop('CallerID is ${CALLERID(all)}'));
+                                       $ext->add($context, $exten, '', new ext_execif('$[ "${CALLERID(name)}" = "" ] ','Set','CALLERID(name)=${CALLERID(num)}'));

                                        if (!empty($item['mohclass']) && trim($item['mohclass']) != 'default') {
                                                $ext->add($context, $exten, '', new ext_setmusiconhold($item['mohclass']));

Config file:

[ext-did-0001]
include => ext-did-0001-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s,n,Set(CALLERPRES()=allowed_not_screened)
exten => s,n,Goto(timeconditions,2,1)
exten => s/0000000000,1,Set(__FROM_DID=${EXTEN})
exten => s/0000000000,n,Gosub(app-blacklist-check,s,1)
exten => s/0000000000,n,Goto(s,1)
exten => s/0000000000,n,ExecIf($["${FROM_DID}" = ""]?Set(__FROM_DID=${EXTEN}))
exten => s/0000000000,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => s/0000000000,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => s/0000000000,n,Set(CALLERPRES()=allowed_not_screened)
exten => s/0000000000,n,Goto(app-announcement-3,s,1)