Problem (Bugs?) when receiving a strange INVITE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a pjsip 2.9 program receiving a (simplified) INVITE like this
over a plain TCP connection.

To: <sip:+44XXXXXXXXXX@xxxxxxx>
From: <sip:+44YYYYYYYYYY@xxxxxxx;user=phone>;tag=p65540t1568381452m158658c1091496s2_1129631035-1670935232
CSeq: 1 INVITE
Via: SIP/2.0/TCP
A.B.C.D:5060;branch=z9hG4bK3a8c7a22da4185c78b180c7a847cd57djaaaaaaiaaaaaa3dg13pq3Zqkv7at2xaftu4gf0xaaaaaabqaaaaaaaq;oc;oc-algo="loss"
Via: SIP/2.0/TCP E.F.G.H:5082;branch=z9hG4bK1129631019-632499267
Route: <sip:LA2.COM;lr>
Record-Route: <sip:3Zqkv7%20caqhGaaaacaaaaaP8UaS6EmxvWaaaaagsip%3A%2B44YYYYYYYYYY%40LA.com@HHHHHHHHHHHHHHHHHH:5060;maddr=A.B.C.D;lr>
Contact: <sip:p65540t1568381452m158658c1091496s2@E.F.G.H:5082;transport=tcp>;ZZZZZZZZZZZZZZZZZZZZZZZZZZZ

Notice that the Record-Route doesn't specify a transport, so it would
be UDP (not arguing it makes a lot sense, just saying that's what I'm
receiving).

In general everything is OK. By default pjsip wants to create an UDP
contact, but I have used pjsua_acc_config::force_contact to keep it
over TCP, I want to keep receiving future requests over TCP. Other
than that my program replies with the "Trying" and "OK" and everything
in the call works as expected. But I have noticed an strange
behaviour: it ALSO tries to establish a direct TCP connection to
E.F.G.H:5082.
As far as I understand it's supposed to send the replies via TCP
A.B.C.D:5060 (as per the top Via header) and requests via UDP
A.B.C.D:5060 (as per the Record-Route header). So it should have no
reason to try to establish a TCP connection to E.F.G.H:5082 (E.F.G.H
is not reachable, so it doesn't goes further than sending the TCP SYN,
no idea what it would do otherwise).

In general my program doesn't have a need to send any request, only
replies, so this would be all good anyway. But sometimes my program
needs to finish the call, so it sends a BYE request. No matter how
strange, it does so over UDP as requested... but it does so with the
wrong Via header. The interesting part:

- When sending the TCP SYN packet the OS has created a socket with a
random source port
- The BYE request generated by my program is perfectly fine except by
one detail: the Via header specifies whatever port was used as source
port when previously sending the TCP SYN packet.

The UDP socket used to send the bye request uses as source port either
a random port or whatever I specify when creating the UDP transport...
but in any case it "never" matches the port randomly selected as
source port when trying to create the E.F.G.H:5082 TCP connection.

The other peer replies to my BYE with an OK... but sending it to the
port specified in the Via header, which my program is not listening
to. So my program doesn't notice the OK and keeps resending the BYE
until it gives up.

Honestly, I have a limtied idea of how SIP works. But could it be that
there are two bugs here?
1) It should never have tried to create the TCP connection to E.F.G.H:5082
2) Somehow the source port gets stored as "THE SOURCE PORT" and used
in all future requests Via headers

Thanks for at least reading this far.

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux