Synopsis
Gets the specified SIP header
Description
SIP_HEADER(<name>)
Notes:
- SIP_HEADER() gives you only access to headers of the initial INVITE request (and not, for example, any progress messages (which may contain call rating information) or the final BYE message)
- This function may only be read from
- CLI> show function SIP_HEADER
Return Value
Returns the resulting strings:
Example 1:
exten => s,1,Set(foo=${SIP_HEADER(headername)})
Example2:
exten => +49123456789,1,Set(DN=${SIP_HEADER(TO):5})
exten => +49123456789,2,Set(DN=${CUT(DN,@,1)})
Example 3:
To get Ip address of From (takes into account no caller id info i.e. no [email protected] in the header):
exten => 1,1,Set(TESTAT=${CUT(SIP_HEADER(From),@,2)})
exten => 1,n,GotoIf($["${TESTAT}" != ""]?hasat)
exten => 1,n,Set(FROM_IP=${CUT(CUT(SIP_HEADER(From),>,1),:,2)})
exten => 1,n,Goto(gotip)
exten => 1,20(hasat),Set(FROM_IP=${CUT(CUT(CUT(SIP_HEADER(From),@,2),>,1),:,1)})
exten => 1,n(gotip),NoOp(Gateway IP is ${FROM_IP})
Example 4:
ip address of local ip phone
exten => s,n,Set(IP=${CUT(CUT(SIP_HEADER(Via), ,2),:,1)})
Bugs and limitations
Contrary to previously claimed,SIP_HEADER is read-only. This example does not work, use SipAddHeader() instead:
exten => s,1,Set(SIP_HEADER(headername)=Foo Fighters)
Bug: SIP_HEADER is timing sensitive, see bug 9516 and the devel-discussion.
See also
- Asterisk cmd SipAddHeader: Typically used to set Alert-Info information, e.g. ring tone .wav files
- Asterisk variable hangupcause and in particular ${HASH(SIP_CAUSE,<channel-name>)} in Asterisk 1.8
- Asterisk variables
- Asterisk functions
- Asterisk – documentation of application commands