Internal call forward: missing diversion header

Hello!

Given is an external caller A, who’s calling B, which forwarded on FreePBX unconditional to an internal user C. Now, I want to see in the Invite to C: A’s number (it’s there), B’s number (diversion header or something else - it’s not there). How can I tell FreePBX to add B’s number?

Asterisk 18.x, PJSIP / FreePBX 15.0.17.43

Thanks
Dirk

No answer as of now - because it’s not possible with FreePBX out of the box at all or because the question is too vague / cloudy?

Asterisk is a B2BUA not a router. Don’t expect B to be part of the call that the dialplan connected A to C

The RDNIS should be there in the CALLERID(rdnis) function so it would be trivial to add it.

Some dial plan like (pseudo code):

if CALLERID(rdnis) !== “”, set PJSIP_HEADER(add,Diversion)=CALLERID(rdnis)

that said, I disagree with @dicko’s expectation; seems to me it would be included without having to add the header like this.

To clarify my post, yes to the ‘rdnis’ but no to the ‘extension’ of B

1 Like

Thanks for your help and idea - but it’s definitely not there by default. The diversion header is only added for outgoing calls, that means, if forwarded to an external C, the diversion header is added - but not, if C is internal.
Where should the code be added in the dialplan to get the diversion header even for calls forwarded to internal users?

Just curious, did you do a SIP capture on this to be sure no headers are added on forwarded calls?

It looks like there’s already dialplan that sets up Diversion header information. (grep -i for diversion in the /etc/asterisk/extensions_additional.conf file)

Assuming that the tooltip for Generate Diversion Headers in Advanced Settings is truthful, Diversion is only added to external calls.

Yes - I’m doing always traces!

That’s true - but it’s only added to external calls (as part of the outbound routes):

[sub-diversion-header]
include => sub-diversion-header-custom
exten => s,1,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten => s,n,Gosub(func-set-sipheader,s,1(Diversion,<tel:${FROM_DID}>\;reason=${DIVERSION_REASON}\;screen=no\;privacy=off))
exten => s,n,Return()
exten => s,n,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten => s,n,Gosub(func-set-sipheader,s,1(Diversion,<tel:${FROM_DID}>\;reason=${DIVERSION_REASON}\;screen=no\;privacy=off))
exten => s,n,Return()

;--== end of [sub-diversion-header] ==--;

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