FreePBX | Register | Issues | Wiki | Portal | Support

Manipulate inbound route at a trunk level


(a12) #1

Hi,

I have set an inbound route of +390744087128, which goes to extension 1001. When the call comes in as +390744087128 it matches the inbound route and goes to extension 1001 as expected.

When the call comes in as 00744087128 there is not a matching inbound route to send the call (it works for example when I add an additional inbound route of 00744087128 to extension 1001)

Instead of having multiple inbound routes, I would like to manipulate the call as it comes in, so add +39 and strip one 0…

On my trunk I have tried the following:

The call is still being presented inbound as 00744087128 as you can see in the SIP trace.

[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [+390744087128;trunk-context=390744087128.ims.vf.it;tgrp=tg390744087128@from-pstn-toheader:2] GotoIf(“PJSIP/to_voda_pri-00000041”, “0?SIP”) in new stack
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [+390744087128;trunk-context=390744087128.ims.vf.it;tgrp=tg390744087128@from-pstn-toheader:3] GotoIf(“PJSIP/to_voda_pri-00000041”, “1?PJSIP”) in new stack
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx_builtins.c: Goto (from-pstn-toheader,+390744087128;trunk-context=390744087128.ims.vf.it;tgrp=tg390744087128,7)
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [+390744087128;trunk-context=390744087128.ims.vf.it;tgrp=tg390744087128@from-pstn-toheader:7] Goto(“PJSIP/to_voda_pri-00000041”, “from-pstn,00744087128,1”) in new stack
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx_builtins.c: Goto (from-pstn,00744087128,1)
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [00744087128@from-pstn:1] Set(“PJSIP/to_voda_pri-00000041”, “__FROM_DID=00744087128”) in new stack
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [00744087128@from-pstn:2] NoOp(“PJSIP/to_voda_pri-00000041”, “Received an unknown call with DID set to 00744087128”) in new stack
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [00744087128@from-pstn:3] Goto(“PJSIP/to_voda_pri-00000041”, “s,a2”) in new stack
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx_builtins.c: Goto (from-pstn,s,2)
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@from-pstn:2] Answer(“PJSIP/to_voda_pri-00000041”, “”) in new stack
[2019-07-24 13:05:07] WARNING[4727][C-0000002a] chan_sip.c: This function can only be used on SIP channels.
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@from-pstn:3] Log(“PJSIP/to_voda_pri-00000041”, "WARNING,Friendly Scanner from ") in new stack
[2019-07-24 13:05:07] WARNING[4727][C-0000002a] Ext. s: Friendly Scanner from
[2019-07-24 13:05:07] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@from-pstn:4] Wait(“PJSIP/to_voda_pri-00000041”, “2”) in new stack
[2019-07-24 13:05:09] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@from-pstn:5] Playback(“PJSIP/to_voda_pri-00000041”, “ss-noservice”) in new stack
[2019-07-24 13:05:09] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘ss-noservice.slin16’ (language ‘en’)
[2019-07-24 13:05:14] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@from-pstn:6] SayAlpha(“PJSIP/to_voda_pri-00000041”, “00744087128”) in new stack
[2019-07-24 13:05:14] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/0.slin16’ (language ‘en’)
[2019-07-24 13:05:15] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/0.slin16’ (language ‘en’)
[2019-07-24 13:05:16] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/7.slin16’ (language ‘en’)
[2019-07-24 13:05:17] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/4.slin16’ (language ‘en’)
[2019-07-24 13:05:17] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/4.slin16’ (language ‘en’)
[2019-07-24 13:05:18] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/0.slin16’ (language ‘en’)
[2019-07-24 13:05:19] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/8.slin16’ (language ‘en’)
[2019-07-24 13:05:20] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/7.slin16’ (language ‘en’)
[2019-07-24 13:05:21] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/1.slin16’ (language ‘en’)
[2019-07-24 13:05:21] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/2.slin16’ (language ‘en’)
[2019-07-24 13:05:22] VERBOSE[4727][C-0000002a] file.c: <PJSIP/to_voda_pri-00000041> Playing ‘digits/8.slin16’ (language ‘en’)
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@from-pstn:7] Hangup(“PJSIP/to_voda_pri-00000041”, “”) in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Spawn extension (from-pstn, s, 7) exited non-zero on ‘PJSIP/to_voda_pri-00000041’
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [h@from-pstn:1] Macro(“PJSIP/to_voda_pri-00000041”, “hangupcall,”) in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@macro-hangupcall:1] GotoIf(“PJSIP/to_voda_pri-00000041”, “1?theend”) in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx_builtins.c: Goto (macro-hangupcall,s,3)
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@macro-hangupcall:3] ExecIf(“PJSIP/to_voda_pri-00000041”, “0?Set(CDR(recordingfile)=)”) in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@macro-hangupcall:4] NoOp(“PJSIP/to_voda_pri-00000041”, " montior file= ") in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@macro-hangupcall:5] GotoIf(“PJSIP/to_voda_pri-00000041”, “1?skipagi”) in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx_builtins.c: Goto (macro-hangupcall,s,7)
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Executing [s@macro-hangupcall:7] Hangup(“PJSIP/to_voda_pri-00000041”, “”) in new stack
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] app_macro.c: Spawn extension (macro-hangupcall, s, 7) exited non-zero on ‘PJSIP/to_voda_pri-00000041’ in macro ‘hangupcall’
[2019-07-24 13:05:23] VERBOSE[4727][C-0000002a] pbx.c: Spawn extension (from-pstn, h, 1) exited non-zero on ‘PJSIP/to_voda_pri-00000041’

Is there a way I can manipulate this permanently rather than have 2 different inbound routes??

Thanks in advance for any help!


#2

Prefix will strip, prepend will add.


(a12) #3

We have tried with Prefix 0 and Prepend of +39
The call still comes in as 00744087128


(a12) #4

So in theory 00744087128 should then be +39744087128
It’s still 00744087128 as per the logs above :frowning:


#5

I did not see it on you’re example. Is it the first pattern? The fist matching pattern is what will be used.


(Lorne Gaetz) #6

The trunk dial rules in the GUI are only for outbound calls. To normalize CID/DID on inbound calls requires a block of custom code. There are several threads here describing how people have done this. This is not exactly what you need, but the basics are here: DID from provider breaks incoming routes (DID matching)


(a12) #7

Thanks Lorne, my only problem here is that I am already using the from-pstn-toheader context to allow for the +39 to be accepted in the system…

Is there any way I can use this along with a custom one?

Thanks


(Lorne Gaetz) #8

You would have to incorporate the dialplan from from-pstn-toheader into your custom dialplan.


(a12) #9

So I would create a new context named from-pstn-toheader-custom and point my trunk to this…

Add the below:
[from-pstn-toheader-custom]
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,${EXTEN},1))
exten => _.,n(SIP),Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
exten => _.,n(PJSIP),Goto(from-pstn,${CUT(CUT(PJSIP_HEADER(read,To),@,1),:,2)},1)

But then not sure how I will format to remove 00 and add +39… any ideas?

Thanks for all your help


(a12) #10

More so that normal inbound numbers match to the inbound route and then any different formatting take the context as above, not sure how I would apply this in a custom context.


(Dave Burgess) #11

There’s another context that does that:

Take the one you wrote above and add code like the e164 context to chop up the CID.


(system) closed #12

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