The German DID Durchwahl (part 2)

All,

I’ve another question about The German Durchwahl DID

from-did-direct context is what I’m looking for, but

  • only the last 3 digits are used as extension and DID
  • the DID is most probably provided in the to-header.

Is it possible to use the DID from the to-header without creating a route for each extension?

Do I have to create separate routes for each ext. when using from-pstn-toheader context?

Thank you in advance!

Chris

You can do this with a little custom code in extensions_custom.conf

I suggest adding two contexts: The first is identical to from-pstn-toheader except that it transfers control to your Durchwahl check. The second checks for the range of numbers used for direct dial extensions. Called numbers outside this range are treated normally (routed to your IVR, queue, attendant, etc.)

[from-pstn-toheader-durchwahl]
exten =>  _.,1,NoOp(Attempting to extract DID from SIP To header)
exten =>  _.,n,gotoif($["${CHANNEL(channeltype)}"="SIP"]?SIP)
exten =>  _.,n,gotoif($["${CHANNEL(channeltype)}"="PJSIP"]?PJSIP)
exten =>  _.,n,NoOp(Unable to determine SIP channel type)
exten =>  _.,n,goto(from-pstn-durchwahl,${EXTEN},1))
exten =>  _.,n(SIP),Goto(from-pstn-durchwahl,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
exten =>  _.,n(PJSIP),Goto(from-pstn-durchwahl,${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)},1)

[from-pstn-durchwahl]
exten => _08923456XXX,1,Goto(from-did-direct,${EXTEN:8},1)  ;strip the first 8 numbers so we can match the 3-digit extensions
include => from-pstn

Replace the 08923456 with the actual digits your trunking provider sends before the extension number and change the number after EXTEN: to the number of digits before the extension number.

Then, set the context for the trunk(s) involved to from-pstn-toheader-durchwahl.

Note that I did not test this code and it may contain typos or other errors. If you have trouble, post a log of a failing incoming call.

Thank you. I’ll try this ASAP. I wouldn’t have found this, let alone that SIP_HEADER and PJSIP_HEADER require different parameters! I guess you have to have a good understanding of Asterisk and not only the FreePBX wiki that mostly just describes the GUI.

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