I am trying to define a certain type packet in Scapy. All fields of the packet are of the same type, except the first field which is ByteField, and the the number of the fields will be determined by the value of the that ByteField field. For example, if the value is 8, then there will be 9 fields in the packet totally.
I've looked at Scapy documentation but couldn't find anything relevant there. The problem is that I have to do it inside the definition of the packet itself and I don't think loops and variables are accepted in "fields_desc" structure.
It obviously starts as something:
fields_desc = [
ByteField("NumOfFields", 0),
]
But then I'm stuck as I need to use the actual value of that field and generate other fields probably in loop.
How this could be done?