P-Asserted-Identity Require to set Caller ID

Hi I am running asterisk 16.26; Got a trunk from provider with 100 Block DIDs. However, cannot setup caller ID, the only caller ID can use it the main one. To setup caller ID for each extension, need to P-Asserted-Identity or P-Preferred-Identity headers, tried whole day, but could not work it out.

Here is the instruction from the provider.
eg.Trying to use 0750014912 as CID to 0456789101

From: sip:0750014912@sipdeal.com.au:5061;tag=as4a7dc59b
To: sip:0456789101@sipdeal.com.au
Contact: sip:0750014912@
Call-ID: 03d1d96353a66fa646e3bd580d4fa12f@sipdeal.com.au
CSeq: 103 INVITE
User-Agent: FPBX-12.0.74(13.13.1)
Authorization: Digest username=“0750014900”, realm=“sipdeal.com.au”, algorithm=MD5,
uri=“sip:0456745577@sipdeal.com.au”, nonce="“, response=”“, qop=auth, cnonce=”", nc=**
Date: Mon, 15 May 2017 07:28:06 GMT
Supported: replaces, timer
P-Asserted-Identity: sip:0750014900@sipdeal.com.au  Pilot user identity here and this is the main number
Content-Type: application/sdp
Content-Length: 550

I have tried:
sendrpid = pai
trustrpid = no

Which almost get there, but not quite right:
P-Asserted-Identity: sip:0750014912@sipdeal.com.au, get error message
Assume the correct head add should be P-Asserted-Identity: sip:0750014900@sipdeal.com.au

Given up and tried to add dial plan:
Add the following to extentions_customer.conf to test
*[from-testing] *
exten => _07xxxxxxxx,1,SipAddHeader(P-Asserted-Identity: sip:0750014900@sipdeal.com.au )

Add:context=from-testing in the sip trunk config

Set debug on, P-Asserted-Identity header has not been added.

The trunk is on chan-sip, all extensions are using PJ-sip.

Please help, thank you.

Can I just confirm that the provider wants you to misuse From and PAI headers. Rather than containing the presentation number, they want you to put the account number in PAI, and rather than using From to provide the corresponding account number, they want you to use that for the presentation number (which can sometimes be valid, but not because of putting the account number in PAI).

Also this example could be over specified. E.g. they should not be specifying the user part of the Contact headers, although, unfortunately some providers do read more into this than they should.

Note that Asterisk 13 is end of life, so doesn’t even get security fixes, and chan_sip, is deprecated, and effectively unsupported.

FreePBX 12 is also end of life. Also, solutions you get on this forum may not be compatible with FreePBX.

Hi David,
Thanks for reply. Yes provider reqires “Call from a non-pilot sip-trunk DID through a registered pilot user”, pretty much, i understanding is need to put “P-Asserted-Identity: sip:0750014900@sipdeal.com.au” to head for each call.

I did try use Pj-sip for the sip trunck, but the result is same, the only caller ID is the main number, which I believe it didn’t add the required header.

What error message? I suspect that FreePBX is getting in the way, as, whilst I think it bad practice to manually add headers that Asterisk controls, I think I’ve heard that it does work in this case.

The other way is to define an endpoint for every presentation number, and set the caller ID to the account number, but use the correct endpoint to for the desired caller ID; a pain in Asterisk, probably even more so in FreePBX.

The best solution is to find a provider who understands PAI, properly.

From the RFC:

The P-Asserted-Identity header field is used among trusted SIP entities (typically intermediaries) to carry the identity of the user sending a SIP message as it was verified by authentication.

So it was authorized with 0750014900 so they want that in the PAI, which is 100% acceptable. While PAI can be used for Caller ID it isn’t its only intended use.

Asterisk is an intermediary here. The point of the reference to intermediaries is that the value is not that which identifies the last hop, but rather the original source, which seems very much to be what people would understand by caller ID.

The two typical arrangements are that the ITSP identifies by IP address, in which case both From and PAI are available for caller ID, or it identifies by From in which case From is used up for authentication.

The reference to authentication isn’t saying that it is used for last hop authentication, but rather that the sender of PAI trusts its accuracy.

Can you confirm the header was added by pasting a trace of this INVITE? Check that send_pai=yes in pjsip config file for the trunk’s type=endpoint section? Maybe then clean up the external_signalling_address in the type=transport section and/or contact header in the type=aor section as well (to point to your external DNS name)?

Just to be sure you didn’t have other issues when you attempted to make the trunk PJSIP. Did you attempt to set the header in the dial handler rather than just inline before the Dial command like you would with chan_sip? Also you used PJSIP_HEADER rather than SipAddHeader?

I think I used to do something like this with that P-Asserted-Identity header
same => n,Set(PJSIP_HEADER(add,P-Asserted-Identity)=sip:+${NUMBER}@${MY_DOMAIN})
I don’t use it anymore, but that’s what is commented out in my dial handler where I tried using it before

I have send_pai and trust_id_outbound set on my PJSIP trunks, that may apply to your situation.

I don’t use FreePBX, so my answer may not be appropriate for your situation.

Just remember PJSIP headers have to be set after the outbound channel has been created, not before, or you are setting them on the wrong channel. If you aren’t familiar with it, see the b() option to Dial.

I strongly suspect they didn’t, as there are indications they are using FreePBX (which can make use of the current forum problematic) and they are trying to manipulate things in custom dialplan executed before FreePBX gets control. To do it with PJSIP, they would need to put the code into a specific customisation hook, and really should be using a macro that hides the channel driver difference.

Found the problem and the issue has been fixed. Works in Chan-sip, but not Pjsip.
Problem: I customized the context name to “from-testing”
exten => _07xxxxxxxx,1,SipAddHeader(P-Asserted-Identity: sip:0750014900@sipdeal.com.au )

Found out it has to be “macro-dialout-trunk-predial-hook”; this is the final working config
exten => s,1,SipAddHeader(P-Asserted-Identity: sip:0750014900@sipdeal.com.au )

Of course, need to remove sendrpid = pai.

That’s a FreePBX context, not one that is built into Asterisk in any way.

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