Inherited PJSIP Headers are here

Up until now, if you wanted to add a header to a callee channel to appear in an outgoing INVITE this had to be done via pre-dial handler.

This worked well, but made it complicated to set those headers from the caller or intermediate channel(s).  It could be done, but it required setting inherited channel variables that would then have to be read and converted by the pre-dial handler.

However, with the addition of a new dialplan function: PJSIP_INHERITABLE_HEADER it is now possible to set those headers directly on the callee or local bridged channel and have them inherit to the caller channel automatically.

This functions almost exactly like the PJSIP_HEADER dialplan application, but only the add, modify and remove actions are available:

same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=one)
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom)=two)
same => n,Set(PJSIP_INHERITABLE_HEADER(remove,X-custom))

This dialplan application is still available in a pre-dial handler, so it is possible to add from a caller channel, then remove or modify them from a bridge local channel or via pre-dial handler.

[default]
exten => 564,1,noOp()
    same => n,Answer()
    same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=one)
    same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=two)
    same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=tres)
    same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom)=four)
    same => n,Dial(PJSIP/Carrot,,tTb(obheaderhandler^obheader^1))
    same => n,Hangup()


[obheaderhandler]
exten => obheader,1,noOp()
    same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom,3)=three)
    same => n,Set(PJSIP_HEADER(add,X-custom-OB)=one)
    same => n,Return()
As you can see in the previous example, these headers co-exist beside the existing PJSIP_HEADER added headers.  This means that if a header is added via the PJSIP_INHERITABLE_HEADER application, it can only be removed or modified by the PJSIP_INHERITABLE_HEADER application.
We hope this makes adding SIP headers to your outbound calls easier than ever!

About the Author

What can we help you find?