[OpenSIPS-Users] Help with is_present_hf
Tyler Merritt
tyler at fonality.com
Tue Feb 8 06:51:04 CET 2011
Jeff,
Yeah xlog shows the avp being set - and I figured out why the call wasn't
looping through that piece of code.
I'm sorry that I didn't mention I had created the $avp(oriUri) alias higher
up in the code but didn't paste it. It's aliased to an integer value.
Oddly - all of my append_hf("BLAH") are called without saying where to
insert them after - and they all get inserted after Allow by default:
Allow: INVITE, ACK, CANCEL, BYE
GW: ALPHA
GW: CHARLIE
GW: EPSILONEPSILON
GW: NOVEMBER
GW: SIERRA
GW: TANGO
GW: WILCO
GW: XRAY
GW: ZULU
That's without specifying the header. This is default behavior I just
stumbled on - I would have expected them to be added at the top of the
packet as well.
On Tue, Feb 8, 2011 at 2:59 AM, Jeff Pyle <jpyle at fidelityvoice.com> wrote:
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20110208/1984205d/attachment-0001.htm>
More information about the Users
mailing list