Skip to content

PJSIP_INHERITABLE_HEADER()

Synopsis

Adds, updates or removes the specified SIP header from a PJSIP or non-PJSIP channel to be inherited to an outbound PJSIP channel.

Since

20.19.0, 22.9.0, 23.3.0

Description

PJSIP_INHERITABLE_HEADER allows you to write specific SIP headers on a calling channel to be inherited by an outbound PJSIP channel.

Examples:

Example: Add an inheritable X-Myheader header with the value of myvalue
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(add,X-MyHeader)=myvalue)
Example: Add an inheritable X-Myheader header with an empty value
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(add,X-MyHeader)=)
Example: Add an inheritable X-MyHeader that will be inherited by child channel
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(add,X-MyHeader)=myvalue)
Example: Update the value of the inheritable header named X-Myheader to newvalue
; 'X-Myheader' must already exist or the call will fail.
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(update,X-MyHeader)=newvalue)
Example: Remove all inheritable headers whose names exactly match X-MyHeader
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(remove,X-MyHeader)=)
Example: Remove all inheritable headers that begin with X-My
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(remove,X-My*)=)

Note

If you call PJSIP_INHERITABLE_HEADER in a normal dialplan context you'll be operating on the caller's channel which will then be inherited to the callee's (outgoing) channel. Inherited headers can be updated or removed via PJSIP_INHERITABLE_HEADER in a pre-dial handler. Headers added via PJSIP_INHERITABLE_HEADER are separate from headers added via PJSIP_HEADER. A header added via PJSIP_INHERITABLE_HEADER can only be or removed modified by PJSIP_INHERITABLE_HEADER. A header added via PJSIP_HEADER can only be modified or removed by PJSIP_HEADER.

Example: Set and modify headers on callee channel
[handler]
exten => modheader,1,Set(PJSIP_INHERITABLE_HEADER(update,X-MyHeader)=myvalue)
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-MyHeader2)=myvalueX)
same => n,Set(PJSIP_INHERITABLE_HEADER(remove,X-MyHeader2)=)

[somecontext]
exten => 1,1,Set(PJSIP_INHERITABLE_HEADER(add,X-MyHeader1)=myvalue1)
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-MyHeader2)=myvalue2)
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-MyHeader3)=myvalue3)
same => n,Dial(PJSIP/${EXTEN},,b(handler^modheader^1))

Syntax

PJSIP_INHERITABLE_HEADER(action,name[,number])
Arguments
  • action

    • add - Adds a new header name to this channel.

    • update - Updates instance number of header name to a new value. The header must already exist.

    • remove - Removes all instances of previously added headers whose names match name. A '' may be appended to name to remove all headers *beginning with name. name may be set to a single '' to clear *all previously added headers. In all cases, the number of headers actually removed is returned.

  • name - The name of the header.

  • number - If there's more than 1 header with the same name, this specifies which header to read or update. If not specified, defaults to '1' meaning the first matching header. Not valid for 'add' or 'remove'.

Generated Version

This documentation was generated from Asterisk branch 23 using version GIT