aboutsip / pkts

Pure java based pcap library capable of reading and writing to/from pcaps.
Other
196 stars 91 forks source link

Via header fails to parse IPv6 with zero compression #141

Open teerapap opened 1 year ago

teerapap commented 1 year ago

Problem statement

The exception is thrown when it parses a Via header containing an IPv6 which is zero-compressed as it expects a full form IPv6 with certain number of colon(:).

Input

Via: SIP/2.0/TLS [2001:213:ab56::8]:12345;received=2001:213:ab56::8;rport=12345;branch=xxxxxx;alias

Exception

 io.pkts.packet.sip.SipParseException: Found 5 which seems odd. Expecting 0, 1,
 7 or 8 colons in the Via-host:port portion. Please check your traffic
       at io.pkts.packet.sip.impl.SipParser.consumeVia(SipParser.java:1394)
       at io.pkts.packet.sip.header.ViaHeader$Builder.<init>(ViaHeader.java:301)
       at io.pkts.packet.sip.header.ViaHeader.frame(ViaHeader.java:210)
       at io.pkts.packet.sip.impl.SipParser.lambda$static$17(SipParser.java:241)
       at io.pkts.packet.sip.header.impl.SipHeaderImpl.ensure(SipHeaderImpl.java:75)
       at io.pkts.packet.sip.impl.ImmutableSipMessage.getViaHeaders(ImmutableSipMessage.java:184)
       at io.pkts.packet.sip.impl.ImmutableSipRequest.createResponse(ImmutableSipRequest.java:72)
       at io.pkts.packet.sip.SipMessage.createResponse(SipMessage.java:110)