Fernando Ortiz - 2010-08-12

Hi all
I need some help with an error that have been for three days in my log.

This is the situation; I needed to "mask" the from header of everything that
comes from a given ip address. So, everything that comes from ip address
x.x.x.x, with from header: anypeer at x.x.x.x, opensips change the from header
to sip:otherpeer at mydomain.com <sip%3Aotherpeer at mydomain.com>

These are the lines of interest in opensips.cfg

#-- Routing to the PSTN section --#

if (uri=~"^sip:(00|011|09|555|995|996|997|998)*@")
{

if(check_source_address("1")){
uac_replace_from("sip:8647242678 at my_gateway_ip");
}
route(1);
}

Now, some calls coming from this ip, are established without problems, but
some other don't showing this error

Aug 11 15:26:04 ippbx /sbin/opensips: Pattern recognized: PSTN
Aug 11 15:26:04 ippbx /sbin/opensips: Call from
sip:8664606yyy at x.x.x.x:5060
to sip:0013202292yyy at opensips_ip:5060
Aug 11 15:26:04 ippbx /sbin/opensips: Rewriting host to asterisk-gw
Aug 11 15:26:04 ippbx /sbin/opensips: new branch at
sip:0013202292yyy at gateway_ip
Aug 11 15:26:06 ippbx /sbin/opensips:
*CRITICAL:dialog:log_next_state_dlg:
bogus event 7 in state 2 for dlg 0xafbd4c14  with clid
'ZTYwMjliN2Y5NDM0OWQzY2Y3MjUwMWU2YWM3MGFhNDQ.' and tags 'a29f6e3e'
'as5065f2a1' *
*
*
Now, doing some google on that error, i found out that it is caused by a BYE
sending before a call is established, something like this:
INVITE  ---->
            <--- trying, ringing
BYE     ----->

The BYE message is being send bye the UAC instead of a CANCEL message. I
don't know why, it seems to be a UAC missfunctioning

As I said before, not every call coming from this ip fails in this error.
And it is not a problem of a single peer or group of peers. Sometimes peer
123456 succeds and sometimes don't.
I*s there something else i can check in opensips that i am missing out?*

Here a capture of packets of one call that give error.

U x.x.x.x:5060 -> opensips_ip:5060
INVITE sip:0013202292xxx at opensips_ip:5060 SIP/2.0.
To: <sip:0013202292xxx at opensips_ip:5060>.
From: "V0811162536019339921"<sip:8664606xxx at x.x.x.x:5060>;tag=a29f6e3e.

#
U opensips_ip:5060 -> gateway_ip:5060
INVITE sip:0013202292xxx at gateway_ip SIP/2.0.
To: <sip:0013202292xxx at opensips_ip:5060>.
From: "V0811162536019339921"<sip:8647242xxx at gateway_ip>;tag=a29f6e3e.

U gateway_ip:5060 -> opensips_ip:5060
SIP/2.0 180 Ringing.
From: "V0811162536019339921"<sip:8647242xxx at gateway_ip>;tag=a29f6e3e.
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.

#
U opensips_ip:5060 -> x.x.x.x:5060
SIP/2.0 180 Ringing.
From: "V0811162536019339921"<sip:8664606xxx at x.x.x.x:5060>;tag=a29f6e3e.
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.

U x.x.x.x:5060 -> opensips_ip:5060
BYE sip:0013202292xxx at gateway_ip SIP/2.0.
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.
From: "V0811162536019339921"<sip:8664606xxx at x.x.x.x:5060>;tag=a29f6e3e.

#
U opensips_ip:5060 -> gateway_ip:5060
BYE sip:0013202292xxx at gateway_ip SIP/2.0.
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.
From: "V0811162536019339921"<sip:8647242xxx at gateway_ip>;tag=a29f6e3e.

#
U gateway_ip:5060 -> opensips_ip:5060
SIP/2.0 487 Request Terminated.
From: "V0811162536019339921"<sip:8647242xxx at gateway_ip>;tag=a29f6e3e.
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.

#
U gateway_ip:5060 -> opensips_ip:5060
SIP/2.0 200 OK.
From: "V0811162536019339921"<sip:8647242xxx at gateway_ip>;tag=a29f6e3e.
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.

#
U opensips_ip:5060 -> gateway_ip:5060
ACK sip:0013202292xxx at gateway_ip SIP/2.0.
From: "V0811162536019339921"<sip:8647242xxx at gateway_ip>;tag=a29f6e3e.
Call-ID: ZTYwMjliN2Y5NDM0OWQzY2Y3MjUwMWU2YWM3MGFhNDQ..
To: <sip:0013202292xxx at opensips_ip:5060>;tag=as5065f2a1.