Asterisk
P-Asserted-Identity header in a SIP INVITE
11 views
Code
π pjsip.conf Sample:
[yourprovider]
type=endpoint
aors=yourprovider
send_pai=yes ; <-- Important: Enables P-Asserted-Identity
trust_id_inbound=yes ; Trust incoming identity headers
trust_id_outbound=yes ; Send identity headers
β
For chan_pjsip (recommended for Asterisk 13+):
π In your extensions.conf:
STATIC PAI
exten => _X.,1,NoOp(Outgoing call)
same => n,Set(PJSIP_HEADER(add,P-Asserted-Identity)=<sip:1234567890@yourdomain.com>)
same => n,Dial(PJSIP/yourprovider/${EXTEN})
same => n,Hangup()
DYNAMIC PAI
exten => _X.,1,NoOp(Dialing ${EXTEN} with dynamic PAI)
same => n,Set(CALLER=sip:${CALLERID(num)}@yourdomain.com)
same => n,Set(PJSIP_HEADER(add,P-Asserted-Identity)=<${CALLER}>)
same => n,Dial(PJSIP/yourprovider/${EXTEN})
same => n,Hangup()
This sends:
P-Asserted-Identity: <sip:1234567890@yourdomain.com>
β οΈ For chan_sip:
chan_sip doesnβt natively support P-Asserted-Identity headers the same way. However, you can try:
π In extensions.conf:
exten => _X.,1,NoOp(Outgoing SIP call)
same => n,SIPAddHeader(P-Asserted-Identity: <sip:1234567890@yourdomain.com>)
same => n,Dial(SIP/yourpeer/${EXTEN},,g)
same => n,Hangup()
Explanation
To add the P-Asserted-Identity header in a SIP INVITE in Asterisk, you can do this using the PJSIP_HEADER function if you're using chan_pjsip. For chan_sip, it's a bit more limited and often requires patching or custom SIP headers with SIPAddHeader.
π Explanation:
send_pai=yes β Tells Asterisk to include P-Asserted-Identity header.
trust_id_outbound=yes β Required to let Asterisk pass outbound identity headers.
PJSIP_HEADER function lets you manually add or override headers in a call.
π οΈ Additional Notes:
Ensure your outbound SIP peer configuration (pjsip.conf or sip.conf) allows sending custom headers.
Your SIP trunk provider must allow P-Asserted-Identity and not strip or override it.
If you're behind NAT or using anonymous SIP, some headers may be dropped.
π Explanation:
send_pai=yes β Tells Asterisk to include P-Asserted-Identity header.
trust_id_outbound=yes β Required to let Asterisk pass outbound identity headers.
PJSIP_HEADER function lets you manually add or override headers in a call.
π οΈ Additional Notes:
Ensure your outbound SIP peer configuration (pjsip.conf or sip.conf) allows sending custom headers.
Your SIP trunk provider must allow P-Asserted-Identity and not strip or override it.
If you're behind NAT or using anonymous SIP, some headers may be dropped.
Rate this snippet
Have a Better Solution?
Know a more efficient way to solve this problem? Share your own code snippet and help the community!
Submit Your Version