Asterisk func sip_header

Business SIP Providers
Provider Plan Details Monthly Rate *
Vonage Business SIP Trunking
  • One provider & nationwide coverage
  • Easily integrated into your existing infrastructure
  • More uptime, flexibility and disaster recovery options
$25.00
Details
8x8 8x8 IP Trunking
  • Unlimited calls to US and Canada
  • Softphone and mobile app available
  • 2012 Market Leader Award
$29.99
Details

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 string.

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 555@192.168.1.1 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



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 string.

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 555@192.168.1.1 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



Created by: murf, Last modification: Fri 27 of Jan, 2012 (11:46 UTC) by bcnit
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+