Setting X-Tenant in SIP Header

I am using Freepbx 13 and trying to add/set the X-Tenant in the SIP Header. I have found topics that should work and have added the following lines to extensions_custom.config

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(CUSTOM: Setting x_tenant for source ${CALLERID(number)}))
exten => s,n,GoSub(func-set-sipheader,s,1(X-Tenant,${CALLERID(number)}))
exten => s,n,MacroExit()

setting the X-Tenant to the outgoing callerID.

In the asterisk log files I see the following:

– Executing [[email protected]:18] Macro(“SIP/1111-00000000”, “dialout-trunk-predial-hook,”) in new stack
– Executing [[email protected]:1] NoOp(“SIP/1111-00000000”, “CUSTOM: Setting x_tenant to 1234567890)”) in new stack
– Executing [[email protected]:2] Gosub(“SIP/1111-00000000”, “func-set-sipheader,s,1(X-Tenant,1234567890)”) in new stack
– Executing [[email protected]:1] NoOp(“SIP/1111-00000000”, “Sip Add Header function called. Adding X-Tenant = 1234567890”) in new stack
– Executing [[email protected]:2] Set(“SIP/1111-00000000”, “HASH(__SIPHEADERS,X-Tenant)=1234567890”) in new stack
– Executing [[email protected]:3] Return(“SIP/1111-00000000”, “”) in new stack
– Executing [[email protected]:3] MacroExit(“SIP/1111-00000000”, “”) in new stack
– Executing [[email protected]:19] GotoIf(“SIP/1111-00000000”, “0?bypass,1”) in new stack

So it appears that it is working but then I capture the INVITE traffic and I don’t see the X-Tenant header in the traffic.

INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP localipaddress:5062;rport;branch=z9hG4bKPj498e797f-573f-461f-a74e-102e4f6a7108
From: sip:[email protected];tag=6d394146-1fdc-4d73-b405-cd7499d3d9d3
To: sip:[email protected]
Contact: sip:[email protected]:5062
Call-ID: 8ee7610a-a03c-465d-ba8d-605062ee4113
CSeq: 23421 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, REF
, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
P-Asserted-Identity: sip:[email protected]
Remote-Party-ID: sip:[email protected];privacy=off;screen=no
Max-Forwards: 70
User-Agent: Asterisk PBX 13.22.0
Content-Type: application/sdp
Content-Length: 341

v=0
o=- 1158752519 1158752519 IN IP4 192.168.0.111
s=Asterisk
c=IN IP4 localipaddress
t=0 0
m=audio 12184 RTP/AVP 0 8 3 111 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

I’m sure I am missing something simple but it seems to be alluding me. I would appreciate it if someone could please help me find the problem?

Thanks

This shouldn’t matter but the trunk is a PJSIP. My understanding is that the function func-set-sipheader is agnostic and should work on either SIP or PJSIP.

Thanks

I was able to figure out the problem. It seems that Asterisk13 with Freepbx13 does not work with adding the X-Tenant header. Once I updated to Asterisk16 with Freepbx15, it works just fine. I was hesitating to upgrade because of all the work that would have to be done but this gave me the excuse to do it.

Thanks for the help and advice.

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