Unify test packet payload and allow for manual control
sborkows opened this issue · comments
PTF provides a lot of very convenient functions to form test packets (simple_*_packet()
)
One thing that they do not allow is specifying the actual payload. Not only that, different functions use different payload for whatever reason.
For example, simple_tcp_packet uses:
pkt = pkt / codecs.decode("".join(["%02x" % (x % 256) for x in range(pktlen - len(pkt))]), "hex")
whereas simple_tcpv6_packet uses:
pkt /= "D" * (pktlen - len(pkt))
This makes direct comparisons a little difficult.
Here are two things which can changed:
- Use the same payload across all functions (if applicable)
- Add "payload" parameter so that the user can specify it manually
Good idea 👍 The code of the testutils.py
is in many places redundant. In the beginning, we can extract a "payload method", and standardize it.