Question

I'm writing some protocols in ScaPy, but am having difficulty understanding how the len fields work. After reading http://trac.secdev.org/scapy/wiki/LengthFields I'm no less enlightened.

Obviously, we have what they call 'lenfield' (Holds the length of the field) and 'varfield' (Contains the actual variable length field). However, it seems that the only fields that can be varfields are PacketLenField, StrFixedLenField, and StrLenField. Where's the rest of the fields? Why can't you have a variable length BitField, or XBitField?

For example I've got:

BitFieldLenField('lenfield', None, 8, length_of='varfield')

This correctly returns a length of 8 (the field I want in this case is 8 octets/ 4 hex pairs long). All good so far. However, when I try and get that field, it seems like my only option is a StrLenField which returns something like 'A\x81\x11\x11P 3'

So, my question is: How do I get that field back as the actual hex in the packet? Am I missing something in the built in fields, or do I have to create something like an XBitLenField?

Thanks for your help.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top