DID manipulation on incoming pjsip Trunk


(Kyriakos) #1

Hello to all.

Is there a way that I can prepend a couple of digits at an incoming pjsip trunk DID before I pass it to my inbound route.

The case scenario is the below:
Two carriers will both send me calls at a DID number 2222222222. I want at the calls of the first carrier that come from the 1st pjsip trunk to prepend 11 in front of the 2222222222 so that I have 112222222222 DID and make an inbound route so that I can route the call to my sangoma A104 port1.
At the calls from the second carrier which come form the pjsip trunk 2 I want to prepend 33 infront of the DID so that I will have the DID 332222222222 and create another inbound route to route the call in my A104 port 2.

The easy way of course would be to ask my two carriers to prepend the digits and send me the final DID’s but I’m looking for an alternative in case they can’t.

Thank you in advance for any information.


(Lorne Gaetz) #2

(Kyriakos) #3

Thanks for your immediate answer.

So if I’m getting this right I have to declare at extensions_custom.conf the below:

[from-pstn-1stcarrier]
exten => 2222222222,1,Goto(from-pstn,12222222222,1)

[from-pstn-2stcarrier]
exten => 2222222222,1,Goto(from-pstn,32222222222,1)

And declare at the trunks the appropriate contexts.

Is this right?
And I imagine that I can use wildcards for example xxxxxxxxxx for a 10digit number?
PS. I’m very newbie at this.
Thanks in advance.


(Lorne Gaetz) #4

Yes. If it goes pear shaped, you only need to revert the context back to from-pstn


(Kyriakos) #5

My conf file is the below

[ext-local-custom]

;listen
exten => _*222x.#,1,Macro(user-callerid,)
exten => _*222x.#,n,Answer
exten => _*222x.#,n,NoCDR
exten => _*222x.#,n,Wait(1)
exten => _*222x.#,n,ChanSpy(SIP/${EXTEN:4},q)
exten => _*222x.#,n,Hangup

;whisper
exten => _*223x.#,1,Macro(user-callerid,)
exten => _*223x.#,n,Answer
exten => _*223x.#,n,NoCDR
exten => _*223x.#,n,Wait(1)
exten => _*223x.#,n,ChanSpy(SIP/${EXTEN:4},qw)
exten => _*223x.#,n,Hangup

[from-Forthnet]

exten => xxxxxxxxxx,1,Goto(from-pstn,3xxxxxxxxxx,1)

And I’m getting the error :
NOTICE[3399] res_pjsip_session.c: Call from ‘TrunkDemo’ (UDP:xxxxxxxx:5060) to extension ‘2172171717’ rejected because extension not found in context ‘from-Forthnet’.

Do I have a syntax error or something.
I even tried with explicilty the 2172171717 number


(Communication Technologies) #6

Does it need an _ ?


(Lorne Gaetz) #7

Yes. You need a leading underscore for the exten:

[from-Forthnet]
exten => _xxxxxxxxxx,1,Goto(from-pstn,3xxxxxxxxxx,1)

Personally, I would use an exten of _.


(Kyriakos) #8

Thank you both for the replies. I’ll test the suggestion first thing in the morning and I’ll post the results


(Kyriakos) #9

I made a modification in the conf file :

[from-Forthnet]

exten => _.,1,Goto(from-pstn,3${EXTEN},1)

And it worked like a charm.

So in this way everything that comes from the trunk marked from-Forthnet the system will prepend a 3 infront of the DID.

Thank you for your help.
Hope this will help other users in this situation.
Regards


(system) closed #10

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