title: Working with LenFields in ScaPy
body: <p>I'm writing some protocols in ScaPy, but am having difficulty understanding how the len fields work. After reading <a href="http://trac.secdev.org/scapy/wiki/LengthFields" rel="nofollow">http://trac.secdev.org/scapy/wiki/LengthFields</a> I'm no less enlightened.</p>
  
  <p>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?</p>
  
  <p>For example I've got:</p>
  
  <pre><code>BitFieldLenField('lenfield', None, 8, length_of='varfield')
  </code></pre>
  
  <p>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'</p>
  
  <p>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?</p>
  
  <p>Thanks for your help.</p>