[asterisk-users] PJSIP add header not working

Bryant Zimmerman BryantZ at zktech.com
Mon Oct 2 10:33:07 CDT 2017


Andre
  
 For this to work we have had to go to using the b() option in the dial 
legs for the calls that are pasting up.
 You call a context that gets run before the calls are made on each 
channel. This allows you to add headers to the new pjsip channels. 
 It works well. You can also set variables with the _ option to trigger 
which headers you want to add..
  
 The example below would add "ThisHeader", "ThatHeader" and "Call-Info" to 
the new channel created in the dial. You could use combinations of other 
variables and augment these methods to meet almost any need. 
  
 Exp
  
 [OutboundDial]
 exten => _XXXXXXXXXX,1,NoOp(Dial Exp)
 exten => _XXXXXXXXXX,n,Set(_var1setinparrent=1) ;;Set Variable so that 
when you call the b() option context in your dial the first header is 
added
 exten => _XXXXXXXXXX,n,Set(_var2setinparrent=1) ;;Set Variable so that 
when you call the b() option context in your dial the second header is 
added
   exten => _XXXXXXXXXX,n,Set(_varAddSessionInparrent=1) ;;Set Variable so 
that when you call the b() option context in your dial the second header is 
added

 exten => 
_XXXXXXXXXX,n,Dial(pjsip/3332224444 at vendortrunk,b(AddpjsipHeaders^s^1))
  
  
 [AddpjsipHeaders]
  exten =>s,1,Gosubif({"$[var1setinparrent}}"="1"]?ThisHeader,1)

 exten =>s,n,Gosubif({"$[var2setinparrent}}"="1"]?ThatHeader,1)
 exten 
=>s,n,Gosubif({"$[varAddSessionInparrent}}"="1"]?addSessionCallInfo,1)
  
 exten => ThisHeader,1,Set(PJSIP_HEADER(add,ThisHeader)=ValueToSet)
 exten => ThisHeader,n,Return()
  
 exten =>  ThatHeader,1,Set(PJSIP_HEADER(add,ThatHeader)=ValuetoSet)
 exten =>  ThatHeader,n,Return()
  
 exten => 
addSessionCallInfo,1,Set(PJSIP_HEADER(add,Call-Info)=<sip://127.0.0.1>\;answ
er-after=0)
exten => addSessionCallInfo,n,Return()
  
 Thanks

Bryant Zimmerman (ZK Tech Inc.)
616-855-1030 Ext. 2003
  

----------------------------------------
 From: "Andre Gronwald" <andregronwald78 at gmail.com>
Sent: Monday, October 2, 2017 11:07 AM
To: "asterisk-users" <asterisk-users at lists.digium.com>
Subject: [asterisk-users] PJSIP add header not working   

Hi,
I am trying to add a custom header to my calls to map several call-legs 
into a global call for viewing.

For this to work I read the call-id from pjsip-channel and write it into 
X-CID:

######
    -- Executing [s at macro-dialout-trunk-predial-hook:4] 
Set("PJSIP/10-00000006", 
"pjsipCallId=313530363933383438363436353930-1gh0bjceo933") in new stack
    -- Executing [s at macro-dialout-trunk-predial-hook:5] 
Set("PJSIP/10-00000006", 
"PJSIP_HEADER(add,X-CID)=313530363933383438363436353930-1gh0bjceo933") in 
new stack
    -- Executing [s at macro-dialout-trunk:18] GotoIf("PJSIP/10-00000006", 
"0?bypass,1") in new stack
    -- Executing [s at macro-dialout-trunk:19] ExecIf("PJSIP/10-00000006", 
"1?Set(CONNECTEDLINE(num,i)=0xxxxxxxxxxxxxx)") in new stack
    -- Executing [s at macro-dialout-trunk:20] ExecIf("PJSIP/10-00000006", 
"1?Set(CONNECTEDLINE(name,i)=CID:3xxxxx)") in new stack
    -- Executing [s at macro-dialout-trunk:21] ExecIf("PJSIP/10-00000006", 
"0?Set(CONNECTEDLINE(name,i)=CID:(Hidden)3xxxxx)") in new stack
    -- Executing [s at macro-dialout-trunk:22] GotoIf("PJSIP/10-00000006", 
"0?customtrunk") in new stack
    -- Executing [s at macro-dialout-trunk:23] Dial("PJSIP/10-00000006", 
"PJSIP/0xxxxxxxxxxxxxx at 3xxxxx,300,T") in new stack
    -- Called PJSIP/0xxxxxxxxxxxxxx at 3xxxxx
<--- Transmitting SIP request (991 bytes) to UDP:217.23.24.100:5060 --->
INVITE sip:0xxxxxxxxxxxxxx at sip.provid.er:5060 SIP/2.0
Via: SIP/2.0/UDP 
192.168.253.185:15070;rport;branch=z9hG4bKPj453d15e0-de58-4945-8b95-d05b16b9
e4c3
From: 
<sip:+49xxxxxxxxxxx at sip.provid.er>;tag=080788ac-7c10-4cf3-86b3-359764ffb5a2


To: <sip:0xxxxxxxxxxxxxx at sip.provid.er>
Contact: <sip:+49xxxxxxxxx at 192.168.253.185:15070>
Call-ID: de41b93b-51d8-44b5-9c34-f2c0928192b0
CSeq: 1519 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, 
UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: FPBX-14.0.1.10(14.6.2)
Content-Type: application/sdp
Content-Length:   308

v=0
o=- 1719768133 1719768133 IN IP4 192.168.253.185
s=Asterisk
c=IN IP4 192.168.253.185
t=0 0
m=audio 55112 RTP/AVP 107 9 8 3 101
a=rtpmap:107 opus/48000/2
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

<--- Received SIP response (559 bytes) from UDP:217.23.24.100:5060 --->
[...]

######

But I can't see that header anywhere in my call-legs. What am I missing?

kind regards,
andre 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20171002/f8b6e426/attachment.html>


More information about the asterisk-users mailing list