[OpenSIPS-Users] Help with is_present_hf

Jeff Pyle jpyle at fidelityvoice.com
Mon Feb 7 18:59:57 CET 2011


Dave,

Nah.  We use a mix of P- and X- headers with no problem.


Tyler,

I have a similar requirement where I need to pull the user from a
P-Charge-Info field.  I use:

  if (is_present_hf("P-Charge-Info")) {
    ...
    $var(whatever) = $(hdr(P-Charge-Info){uri.user});
    ...
  }

This works pretty well.  I should pull the NUMBER out of
"P-Called-Party-Id: <sip:NUMBER at HOST:5060>" for you; just don't forget to
change it to P-Called-Party-Id.

Elsewhere in the script we use {uri.domain} with equal success to pull
what you've shown as HOST.  No problems there either.

Does the xlog statement show anything at all?

An append_hf statement without a second parameter will put the header at
the very top.  I know I've missed it there a time or three.  I find it
easier to deal with visually if I put it around the Contact header.
Something like:
  append_hf("GW: EPSILON\r\n", "Contact");

Another thing I noticed is $avp(oriUri).  You may want to try
$avp(s:oriUri) instead.  Perhaps it's changed recently, but it at least
used to be you had to identify AVPs with a s:string or i:integer (i.e.
I:19).


- Jeff



On 2/7/11 12:48 PM, "Dave Singer" <dave.singer at wideideas.com> wrote:

>Tyler,
>
>Not sure but I believe custom headers are supposed to start with "X-"
>and it may be that opensips is rejecting putting it in because it is
>not a standard SIP header and it does not start with "X-".
>Turning up the debug would probably show why.
>
>Dave
>
>On Mon, Feb 7, 2011 at 6:02 AM, Tyler Merritt <tyler at fonality.com> wrote:
>> Using Opensips 1.6 ->
>> Can anyone tell me what I'm doing wrong here?
>> if (is_present_hf("P-Called-Party-Id")) {
>>                          append_hf("GW: EPSILON\r\n");
>>                          $avp(oriUri) =
>> $(hdr(P-Called-Party-Id){s.substr,5,12});
>>                          xlog("L_INFO", "Reply user now equals
>>$avp(oriUri)
>> from P-Called-Party-Id");
>>   }
>>
>> Here is the packet that should hit this block:
>> E..... at ...u.................INVITE sip:NUMBER at HOST:5060 SIP/2.0
>> Via: SIP/2.0/UDP REMOTEHOST:5060;branch=z9hG4bKbkr26a0010bgsbs5b640.1
>> Max-Forwards: 66
>> From: "NUMBER" <sip:NUMBER at HOST>;tag=SDd4l3002-as19e30264
>> To: <sip:NUMBER at HOST>
>> Contact: <sip:NUMBER at HOST:5060;transport=udp>;nat=yes
>> CSeq: 103 INVITE
>> P-Called-Party-Id: <sip:NUMBER at HOST:5060>
>> Allow: INVITE, ACK, CANCEL, BYE
>> As you can see - there is definitely a P-Called-Party-Id...
>> The daemon.log actually shows the avp being set:
>> /usr/sbin/opensips[13365]: Reply user now equals NUMBER from
>> P-Called-Party-Id
>> That's the only place in my config where I'm setting the $avp at all.
>> And yet - I've added a bunch of header fields that help me watch where a
>> packet routes through the code:
>> GW: ALPHA
>> GW: CHARLIE
>> GW: NOVEMBER
>> GW: SIERRA
>> GW: TANGO
>> GW: WILCO
>> GW: XRAY
>> GW: ZULU
>>
>> The header "GW: EPSILON" should be added if the packet were routed
>>through
>> that block of code - and it's not...
>> I don't get it.  The functionality that I'm aiming for isn't working
>> (resetting the outbound Contact to the inbound URI of the original
>>request -
>> but there's an Asterisk box in the way so it's the same as referencing
>>two
>> requests prior).
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
>_______________________________________________
>Users mailing list
>Users at lists.opensips.org
>http://lists.opensips.org/cgi-bin/mailman/listinfo/users




More information about the Users mailing list