node_pcap icon indicating copy to clipboard operation
node_pcap copied to clipboard

decode/tcp.js throws error on valid TCP option kind numbers

Open jschulenklopper opened this issue 8 years ago • 2 comments

In decode/tcp.js an error is thrown when an unknown TCP option is encountered, https://github.com/node-pcap/node_pcap/blob/master/decode/tcp.js#L150.

I regularly see that error when encountering option kind 34, an IANA approved option kind number for TCP Fast Open (which is experimental, but apparently used by some network device.) See https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml#tcp-parameters-1 for the IANA documentation with a reference to the RFC at https://tools.ietf.org/html/rfc7413.

Obviously, I can try ... catch ... around a pcap.decode(rawPacket) call to prevent raising an error I can't handle in my code as well... but it would be better if decode/tcp.js logs an error (instead of throwing one), just like is done in this module when encountering unknown ether types.

jschulenklopper avatar Apr 06 '18 21:04 jschulenklopper

Yes, please. It's a pity I have to drop so many packages by try ... catch ...ing around pcap.decode(rawPacket).

jscheffner avatar Jul 09 '18 11:07 jscheffner

Logging the error would be an improvement but as mentioned in #183, the cleanest solution would be to replace all console.log statements and thrown Errors with emitted events. If there is agreement about that I'd be glad to make a pull request as soon as I find the time. Obviously such a change could only be released with the next major version.

jscheffner avatar Oct 26 '18 09:10 jscheffner