Upgrade 3CX to v18 and get it hosted free!

Asterisk func sip_header

Author image

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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.