Description
The JAIN-SIP library is inconsistent with normalising IPv6 addresses. In SIP URI comparisons, this causes transaction matching to fail when comparing bracketed vs. unbracketed IPv6 address forms. This results in javax.sip.SipException: Response does not belong to this transaction.
Root Cause: The library's HostAndPort equality check treats Host [fe80::1:2:3] (IPv6 literal in brackets) as different from Host fe80::1:2:3 (raw IPv6 address), even though they represent the same host according to RFC 3986 URI syntax rules.
Reproduction Steps
Try to send a response to a message using sendResponse(Response response) in a SIPServerTransaction, whereby the ((SIPRequest) origRequest).getTopmostVia().getSentBy().getHost().getHostname() IPv6 is without square brackets while the response you want to send is with the same IPv6 but in square brackets.
Expected Behavior
Host [fe80::1:2:3] and Host fe80::1:2:3 in a HostAndPort context should be recognised as the same host.
See PR #204 for my proposed solution.
Impact
Breaks IPv6 SIP communication
Interoperability: Different SIP implementations vary in bracket enforcement
Network Reality: Some network devices strip/add brackets during transit
Dual-Stack Environments: Inconsistent handling between IPv4 and IPv6