P-Asserted-ID and Diversion Header

dear community,

i have a general problem:
my provider (ip based auth) needs, that in each call a correct P-Asserted-ID is set.
P-Asserted-ID Format should be +49XXXXXXXXXXXXXX.

The Diversion Header (if a call will be forwarded) should too +49XXXXXXXXXXX.

But if i activate the call forwarding directly on my snom phone,
in the diversion header i see diversion:20.

but it should be +49MAINNUMBER20

and the P-Asserted-ID must ever be +49MAINNUMBER.

can anybody helps me, how i can set this correctly, so that i dont have any problems (on call forwarding directly on phone (with lines 1 2)?

my provider means i should set sendrpid to pai, or = yes, but is this possible in version 11 from asterisk?

how i can change the diversion header format that if the diversion is set to e.g. 20, i
auto rewrite this header to +49MAINNUMBER?

Thank you very much and many greets

Hello @iceget,

You can activate a diversion header generation in the advanced settings tab:

Also, make sure that your extensions are set to sendrpid=pai and set trustrpid=yes.
Do not use the Snom phones to forward the calls. It is better to use the Freepbx dialplan to do it (Followme module).

Thank you,

Daniel Friedman
Trixton LTD.

hello daniel,

thank you very much!

but i also had a 2nd question:
if i will hide the caller id for each needed extension i must set “from” header to anonymous,
but the p assert id must have the original phone number to hide the caller id.

maybe any idea how i can fix that? my goal: if i call *670049123456789 my caller id should be hidden on called number.

thank you very much

Hello @iceget,

Put this macro in the extensions_custom.conf file (change your main number and your asterisk ip address):

exten => s,1,GotoIf($[ "${CALLERID(name)}" = "anonymous" ] ]?pai-custom:continue)
exten => s,n(pai-custom),SipAddHeader(P-Asserted-Identity: "+49MAINNUMBER20" <sip:[email protected]_ASTERISK_IP_ADDRESS\;user=phone>)
exten => s,n,SipAddHeader(Privacy: id)
exten => s,n,Progress()
exten => s,n,MacroExit()
exten => s,n(continue),MacroExit()

Then add an outbound route with a prefix of *67 to it with a caller id override of anonymous and place it at the top of your outbound rules.

Thank you,

Daniel Friedman
Trixton LTD.


I have added this macro to extensions_custom.conf as you do and create the outbound route:

But when I check the INVITE message request sent by my server is not addinf the “P-Asserted-Identity” field on the header… Any Idea what can be that? Im using FreePBX and Asterisk 16.2.0

Waiting on your help.

Daniel G

Is the P-Asserted-Identity header incorrect when placing a regular call or when trying to place a call using *67, or both?

Hi Robert:

Thank you for expend time on my question. The issue was when using the *67… but I already fix it… I went to the debug and check that when Asterisk was looking for the field ${CALLERID(name)} it was not “Annonimous”, but “Hidden” and that’s why was not adding the P-Asserted-Identity on the header.

Thank you for your support.

Daniel G