sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.43k stars 432 forks source link

SIP-Cancel:Ok Via Headers are not updated with Remote Endpoint #1169

Open JanHyteraMobilfunk opened 2 weeks ago

JanHyteraMobilfunk commented 2 weeks ago

Observation:

When canceling a call via an IMS the Ok-Response of the SIP-Cancel is not correctly send back to the originating server as the "Via-Header" is strictly followed.

08:29:30.164 [DBG] Request received: udp:0.0.0.0:5060<-udp:A.B.C.215:6060 08:29:30.164 [DBG] CANCEL sip:gcas@A.B.C.229 SIP/2.0 Via: SIP/2.0/UDP dockerInternal.11:6060;branch=z9hG4bK5804.501ee7181bc2b6ee5bba08336fcebad6.0 To: sip:gcas@A.B.C.229 From: sip:testuser1@network.org;tag=pvrFpBQNNeD7B Call-ID: 7c45afea-dfba-123d-b7b0-000c29006824 CSeq: 983455649 CANCEL Max-Forwards: 68 Route: sip:gcas@A.B.C.229:30560;lr,sip:iscmark@network.org;lr;s=3;h=1;d=0;a=7369703a636c69656e743140696d732e6d6e633030312e6d63633030312e336770706e6574776f726b2e6f7267 Content-Length: 0

08:29:30.168 [DBG] Response sent: udp:------:5060->udp:dockerInternal.11:6060 08:29:30.168 [DBG] SIP/2.0 200 Ok Via: SIP/2.0/UDP dockerInternal.11:6060;branch=z9hG4bK5804.501ee7181bc2b6ee5bba08336fcebad6.0 To: sip:gcas@A.B.C.229;tag=QYLSAGSDCT From: sip:testuser1@network.org;tag=pvrFpBQNNeD7B Call-ID: 7c45afea-dfba-123d-b7b0-000c29006824 CSeq: 983455649 CANCEL Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, PRACK, REFER, REGISTER, SUBSCRIBE Content-Length: 0

Expected behaviour:

Ok-Response is send back to A.B.C.215:6060 and not to dockerInternal.11:6060

A possible solution, though not fully tested will be provided with a PR. I am not fully satisfied with the solution as it might not cover all scenarios especially as the TopViaHeader should probably get an update everytime a message is received from a foreign network?