[Home]

Summary:ASTERISK-25790: Unable to set X-P-Asserted-Identity with PJSIP_HEADER - the header doesn't make it into the SIP packet.
Reporter:Oliver Nauliv (nauliv)Labels:
Date Opened:2016-02-13 11:39:54.000-0600Date Closed:2020-01-14 11:14:09.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Channels/chan_pjsip
Versions:13.1.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:We are unable to send the X-P-Asserted-Identity, because while the dialplan runs PJSIP_HEADER without error, the option doesn't make it into the SIP packet.


h2. SIP TRACE FOR OUTBOUND CALL
{noformat}
<--- Transmitting SIP request (891 bytes) to UDP:208.73.140.70:5060 --->
INVITE sip:9492345566@208.73.140.70:5060 SIP/2.0
Via: SIP/2.0/UDP 107.207.90.90:5060;rport;branch=z9hG4bKPja-5qMYTknEobutnWKzOTPpSrCg3swCz
From: "Manager Office"
<sip:7143861212@107.207.90.90>;tag=slIrplpaQV6S.tpB64u4BEbK-.7HBEis
To: <sip:9492345566@208.73.140.70>
Contact: <sip:ec89dc3e-90df-4fbd-99bd-f5b225f8da3d@107.207.90.90:5060>
Call-ID: QmF69h0tpNPtZhE6IrwYqtoQ67kcJ5pn
CSeq: 9147 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE,
PRACK, REFER, REGISTER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length: 237
v=0
o=- 455864548 455864548 IN IP4 107.207.90.90
s=Asterisk
c=IN IP4 107.207.90.90
t=0 0
m=audio 19628 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
{noformat}

h2. DIALPLAN FOR OUTBOUND CALL
{noformat}
[dial-out]
exten => _X.,1,NoOp()
same => n,Set(PJSIP_HEADER(add,X-P-Asserted-Identity)=sip:7147890101)
same => n,Set(CALLERID(num)=7143861212)
same => n,Dial(PJSIP/${EXTEN}@nextiva1,45,r)
same => n,Hangup()
{noformat}

h2. PJSIP CONFIGURATION FOR SIP TRUNK
{noformat}
[nextiva1]
type=endpoint
transport=transport-udp
context=from-nextiva
disallow=all
allow=ulaw
aors=nextiva1-aor

[nextiva1-auth]
type=auth
auth_type=userpass
username=7143861212
password=NotMyRealPassword

[nextiva1-reg]
type=registration
outbound_auth=nextiva1-auth
server_uri=sip:bt.voipdnsservers.com
client_uri=sip:7143861212@bt.voipdnsservers.com


[nextiva1]
type=identify
endpoint=nextiva1
match=208.73.140.70

[nextiva1-aor]
type=aor
contact=sip:bt.voipdnsservers.com:5060
{noformat}
Comments:By: Richard Mudgett (rmudgett) 2016-02-15 09:52:17.390-0600

This is a configuration issue.  You must use PJSIP_HEADER on the correct channel.  To do that you must use a pre-dial handler to add the SIP header to the outgoing channel.

{noformat}
[dial-out]
exten => _X.,1,NoOp()
same => n,Set(CALLERID(num)=7143861212)
same => n,Dial(PJSIP/${EXTEN}@nextiva1,45,rb(dial-out^predial^1))
same => n,Hangup()

exten => predial,1,NoOp()
same => n,Set(PJSIP_HEADER(add,X-P-Asserted-Identity)=sip:7147890101)
same => Return()
{noformat}

See https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_PJSIP_HEADER
Also the CLI "core show function PJSIP_HEADER"

By: Joshua C. Colp (jcolp) 2016-02-15 10:55:11.847-0600

If you use the functionality in the manner [~rmudgett] described does the behavior change?

By: Oliver Nauliv (nauliv) 2016-02-15 19:08:42.504-0600

Hello Josh,

Yes, we changed the dialplan in accordance to Richard's recommendation. See the last test we did below:

{code}
[dial-out-nextiva]
exten => _X.,1,NoOp()
same => n,Set(CALLERID(num)=7143861234)
same => n,Dial(PJSIP/${EXTEN}@nextiva1,,B(addh^1^1))
same => n,NoOp(Status: ${DIALSTATUS})
same => n,Hangup()

[addh]
exten => 1,1,NoOp()
same => n,Verbose(0, In caller pre-dial handler!)
same => n,Set(PJSIP_HEADER(add,X-Nextiva-SayHello)=Hello)
same => n,Return()
{code}


When placing a call, we see that all the dialplan is being executed without error, and that the handler is being executed:

{code}
-nextiva:3] Set("PJSIP/100-00000025", "CALLERID(num)=7143861234") in new stack
-- Executing [9497951234@dial-out-nextiva:4] Dial("PJSIP/100-00000025", "PJSIP/9497951234@nextiva1,,B(addh^1^1)") in new stack
-- PJSIP/100-00000025 Internal Gosub(addh,1,1) start
-- Executing [1@addh:1] NoOp("PJSIP/100-00000025", "") in new stack
-- Executing [1@addh:2] Verbose("PJSIP/100-00000025", "0, In caller pre-dial handler!") in new stack
In caller pre-dial handler!
-- Executing [1@addh:3] Set("PJSIP/100-00000025", "PJSIP_HEADER(add,X-Nextiva-SayHello)=Hello") in new stack
-- Executing [1@addh:4] Return("PJSIP/100-00000025", "") in new stack
== Spawn extension (dial-out-nextiva, 9497951234, 4) exited non-zero on 'PJSIP/100-00000025'
-- PJSIP/100-00000025 Internal Gosub(addh,1,1) complete GOSUB_RETVAL=
-- Called PJSIP/9497951234@nextiva1
{code}

However when we look at the SIP packet, there is still no header in it.
We tried all sort of combinations with the header, make it as simple as X-Test=hello; it's always executed without error, but never been added to the headers of the SIP transaction.

{code}
<--- Transmitting SIP request (901 bytes) to UDP:208.73.123.45:5060 --->
INVITE sip:9497951234@bt.voipdnsservers.com:5060 SIP/2.0
Via: SIP/2.0/UDP 107.207.12.34:5060;rport;branch=z9hG4bKPjRXQkKMQGIZtMGkCMdxtYGPZ-JPsPVj0n
From: "Desk" ;tag=17Huzx1HCGrq-cMOeuldTY
To: sip:9497951234@bt.voipdnsservers.com
Contact:
Call-ID: RMn2GlpyVFPyxPZ5VCn.ZJrjE9vm
CSeq: 16525 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REFER, REGISTER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 453472723 453472723 IN IP4 107.207.12.34
s=Asterisk
c=IN IP4 107.207.12.34
t=0 0
m=audio 15224 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
{code}

By: Richard Mudgett (rmudgett) 2016-02-15 19:14:28.536-0600

You must use lowercase 'b'.  There is a difference between upper and lower case for that Dial flag.  Uppercase operates on the calling channel.  Lowercase operates on the callee channel.

By: Joshua C. Colp (jcolp) 2016-02-16 18:54:49.697-0600

As [~rmudgett] mentioned - did you try with the lowercase b?

By: Oliver Nauliv (nauliv) 2016-02-16 21:28:07.628-0600

Hello,

I have changed to lower case b as below:

Dialplan:
{code}
[dial-out-nextiva]
exten => _X.,1,NoOp()
same => n,Dial(PJSIP/${EXTEN}@nextiva1,,b(addh^1^1))
same => n,Hangup()

[addh]
exten => 1,1,NoOp()
same => n,Verbose(0, In caller pre-dial handler!)
same => n,Set(PJSIP_HEADER(add,P-Asserted-Identity)=<sip:7143456789@bt.voipdnsservers.com>)
same => n,Set(PJSIP_HEADER(add,X-Test-this)=just-a-test)
same => n,Return()
{code}

Placing a test outbound call generated the following CLI result:
{code}
   -- Executing [9492567890@dial-out-nextiva:4] Dial("PJSIP/202-0000016b", "PJSIP/9492567890@nextiva1,,b(addh^1^1)") in new stack
   -- PJSIP/nextiva1-0000016c Internal Gosub(addh,1,1) start
   -- Executing [1@addh:1] NoOp("PJSIP/nextiva1-0000016c", "") in new stack
   -- Executing [1@addh:2] Verbose("PJSIP/nextiva1-0000016c", "0, In caller pre-dial handler!") in new stack
In caller pre-dial handler!
   -- Executing [1@addh:3] Set("PJSIP/nextiva1-0000016c", "PJSIP_HEADER(add,P-Asserted-Identity)=<sip:7143456789@bt.voipdnsservers.com>") in new stack
   -- Executing [1@addh:4] Set("PJSIP/nextiva1-0000016c", "PJSIP_HEADER(add,X-Test-this)=just-a-test") in new stack
   -- Executing [1@addh:5] Return("PJSIP/nextiva1-0000016c", "") in new stack
 == Spawn extension (from-nextiva, 9492567890, 1) exited non-zero on 'PJSIP/nextiva1-0000016c'
   -- PJSIP/nextiva1-0000016c Internal Gosub(addh,1,1) complete GOSUB_RETVAL=
   -- Called PJSIP/9492567890@nextiva1
{code}

And as you can see the SIP packet didn't contain any of the headers:
{code}
<--- Transmitting SIP request (1005 bytes) to UDP:208.73.145.67:5060 --->
INVITE sip:9492567890@bt.voipdnsservers.com:5060 SIP/2.0
Via: SIP/2.0/UDP 107.207.12.34:5060;rport;branch=z9hG4bKPjstqdJQZe6op2cBc1ZtJVTgk5TCGcA.Do
From: "Manager Office" <sip:7143861234@bt.voipdnsservers.com>;tag=fXHXnOWFma.DAv7VFGhIrV2ol4cwXu8S
To: <sip:9492567890@bt.voipdnsservers.com>
Contact: <sip:b919dc72-712d-4cbd-93fe-c10122e07879@107.207.12.34:5060>
Call-ID: cVQ5Or3eF7JriebR41gpiO852wgIX7M6
CSeq: 28505 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REFER, REGISTER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length:   239

v=0
o=- 1707069940 1707069940 IN IP4 107.207.12.34
s=Asterisk
c=IN IP4 107.207.12.34
t=0 0
m=audio 18526 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
{code}

By: George Joseph (gjoseph) 2016-02-22 12:11:00.584-0600

I've tried to reproduce the issue using your exact config and can't.  I get both headers.  This is in 13.4 and 13.7.2.  I can't test 13.1 as it's too old to compile.

Try a later version perhaps?


By: Asterisk Team (asteriskteam) 2016-03-08 12:00:01.465-0600

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines