Call forwarding - diversion header and pai problem

Hello,

I am testing freepbx on the german research network with German Telecom as provider for SIP-trunks.
They expect me to sent certain headers in case of forwarding.

I have two local phones (ext. 1 and ext. 2)
On ext. 1 forwarding is activated to an external number
Ext. 2 calls Ext. 1 and should be handed over to the external phone.
The headers should look like
PAI <sip:trunk#+ext# of the forwarding phone (1)@my external ip>;privacy=off;sreen=no
Diversion: <sip:trunk# + ext# of the forwarding phone(1)@my external ip>; reason=unconditional
The trunk# is supposed to be in e164 format

instead I get
PAI in e.164 format but with the number of ext. 2 (which should be 1)
diversion # of ext.1 but only the local ext. without e.164

So ,PAI and diversion header should both contain the e.164 number of the forwarding telefone. This seems to be important to prevent the caller from paying costs for the forwarding, as billing is calculated according to the PAI number.

Can anyone help me ?
I am testing with freepbx14/asterisk13, actual patch level and two SNOM phones.
Generating diversion headers = on
(Allthough it doesn´t seem to make any difference, the wireshark logs look the same)
Using forwarding on the PBX is no option for us.

Thanks alot in advance
Tom

Does it work on FreePBX13?

I have a call forwarding bug with 14 because of this commit, which fixed another bug but created a new bug with unattended call transfers. The wrong number gets generated during transfers.

https://git.freepbx.org/projects/FREEPBX/repos/core/commits/454f61be00fc196c0ba7053a57b0286f1641263b#functions.inc/macro-user-callerid.php

Hello @thloesch,

You will need to customize your sip headers in the [macro-dialout-trunk-predial-hook] to achieve what you want.

Thank you,

Daniel Friedman
Trixton LTD

Hi,
I am sorry but I cant tell you because I am using also FPBX14 (with Asterisk 13)

Hi Daniel,
thx for the hint.
I am very new to Asterisk and FreePBX (about 2 weeks :wink: only) and I needed to read and test alot before answering your mail.

I am using PJ_SIP for my trunk.I tried to change my headers with simple things like
[macro-dialout-trunk-predial-hook]
exten => s,1,Set(PJSIP_HEADER(add,x-ezjm)=sip:[email protected])
but I always get an error that PJSIP_Header needs a channel.

So I tried something like
[DFN-Header]
exten => modheader,1,Set(PJSIP_HEADER(add,x-ezjm)=>sip:Hello World>)
same => n,Return()
and called it from the trunk dial options. That works fine, but I can not update the diversion header (no header defined in actual session). Obviously the other headers got defined before and the session was closed.

Any Idea ?
thx alot

Tom

Hello @thloesch,

I suggest you to shift back to SIP channel instead of working with PJSIP on your trunks. You can work with both channel types (SIP and PJSIP), just watch out for the different ports (5060 or 5061).

If you want use the SIP you will need to use it like this (an example):

[macro-dialout-trunk-predial-hook]
exten => s,1,SipAddHeader(P-Asserted-Identity: <sip:[email protected]\;user=phone>)
exten => s,n,SipAddHeader(Diversion: <tel:441234567890>\;reason=unconditional\;screen=no\;privacy=off)
exten => s,n,MacroExit()

Of course you will have to customize it a little bit to suit your needs. Use the console verbosity and the sip debugging to check what you are sending to your provider:

console set verbose 4
sip set debug ip trunk_ip

To cancel the console logging and the sip debugging:

console set verbose 0
sip set debug off

Thank you,

Daniel Friedman
Trixton LTD.

I don’t recommend abandoning PJSIP, I recommend instead learning how to use it properly. You can’t use the predial hook macro for PJSIP trunks, but you can add custom headers to PJSIP trunks using the method described in this post:

Hi Lorne and Daniel,
thx for your interesting posts. Today I finally had more time for testing.
Lorne´s way to add headers with pjsip I already had tested before and it worked. Finally I understand why SIPAddHeader did not not work on pjsip. Also the chan_sip way to add headers works for me now.
Daniels way to check the output I did not knew yet, nice. Up to now I just mirrored the Switch port of the pbx to a Service PC with a wireshark on it.

But the problem is, that I now have double headers. So either I have to kick the double headers or I have to replace them.
Update and remove did not work with PJSIP because I get a message telling me that there were no headers defined in the actual session. So they got defined somewhere else and the session is already closed or they get added later.

with chan_sip I also did not managed to access the headers properly. With sipremoveheader() I can kick the PAI but not the Diversion Header. It also seems to be added later.

So the problem is
1 calls 2, 2 is forwarding on the phone to 3
3 should see 1 on the Display , pai and diversion have to be set to 2
at the moment
pai : [email protected] should be [email protected]
Diversion: [email protected] should als be [email protected]
(0049 Country Code, 511 area Code, 1234567 trunk number)
so pai = Diversion
Any idea ?

To Lorne : I work here at a small music University in Germany. we want to find a reliable, well maintained solution also for other small universities. we are all using the german Research Network, with German telekom offering a SBC for sip trunks inside our network. For using these trunks I have to pass an about 50 pages long test protocol with a tecnician of the german telekom, that is supposed to take about 5 hours. These tests seems to be equal to the newly advertised corporate sip trunks of Telecom. I have no problem to buy commercial support after we passed the test and use fpbx as our new pbx.
If Sangoma is interessted in, I can mail you a copy of this acceptance test.
For the big universities ist fairly easy, they have enough money and just call Cisco :slight_smile:

Greetings
Thomas

Hello @thloesch,

You need to remove the diversion header generation from the advanced settings:

Do it and retest again.

Regarding your proposal for the German universities, please PM me. I can help you with that.

Thank you,

Daniel Friedman
Trixton LTD.

I tested it with on and off, the Diversion Header is always there !!! (like mentionend in the first post)

But I found a hint, when I add Diversion_send = no to the additional SIP Settings, then the Header disappears. Since I tested that also my PAI is gone and refuses to Show up again, independently from the Settings in Advanced Settings.

I will be on vacation for the next three weeks