kbandla / dpkt

fast, simple packet creation / parsing, with definitions for the basic TCP/IP protocols
Other
1.08k stars 270 forks source link

Review snoop code #535

Closed crocogorical closed 3 years ago

crocogorical commented 3 years ago

I took a look at the snoop code and put in an implementation of reader/writer for the snoop filetype Issue #524.

This also introduces FileReader and FileWriter superclasses which the snoop Reader and Writer classes inherit from. These encapsulate some of the accessors and control to the underlying file objects, rather than re-implementing them with every new filetype.

As these classes are tested independently from the specific file type class (in this case snoop), it simplifies the developing/testing of new filetypes as these parts are already tested.

Longer term, these probably make more sense to sit in dpkt.py alongside the Packet class, and have pcap / pcapng Reader/Writer inherit from them too. I've kept them in snoop.py at the moment pending review.

The coverage report will by default consider abstract method bodies (the pass statement) un-covered code, so this PR also include a change to tox.ini to ignore any abstract methods.