kbandla / dpkt

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

bitfield unittest might be platform dependant #644

Closed AiyionPrime closed 1 year ago

AiyionPrime commented 1 year ago

This test gives me trouble.

https://github.com/kbandla/dpkt/blob/2d30526422d48f83d4f724221d9ae0dcd5ff57fe/dpkt/dpkt.py#L62-L65

I think it should not be called on ph_struct but a concat of the classes __byte_order__ and it, no?

On my system the test tells me L is expected to be 8*8bits instead of 32, I'd expect. https://docs.python.org/3/library/struct.html#format-characters

Am I just overlooking something? I'll provide a PR with a unittest with what I mean tomorrow, if wanted.

obormot commented 1 year ago

A piece of code to replicate the issue would be helpful, yes. __byte_order__ isn't related to sizing, I don't think it needs to be involved.

AiyionPrime commented 1 year ago

I'll provide the example tomorrow morning, then.

AiyionPrime commented 1 year ago

I've got a working unittest, as well as a draft for a fix. It will take a little while longer though, due to company policies - sorry for the wait.

AiyionPrime commented 1 year ago

@obormot This took way longer than anticipated. Future contributions should be faster.