scapy icon indicating copy to clipboard operation
scapy copied to clipboard

PadField missing from rfc() output

Open guedou opened this issue 2 years ago • 1 comments

While playing with rfc(), I noticed that the PadField is not displayed. I believe that it is a bug.

Code

class Test(Packet):
  fields_desc = [IntField("f1", 0),
                 ByteField("f2", 1)]

class TestPad(Packet):
  fields_desc = [IntField("f1", 0),
                 PadField(ByteField("f2", 1), 4)]

print(raw(Test()))
rfc(Test)

print(raw(TestPad()))
rfc(TestPad)

Output

b'\x00\x00\x00\x00\x01'
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               F1                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       F2      |
+-+-+-+-+-+-+-+-+

                            Fig. Test                             
b'\x00\x00\x00\x00\x01\x00\x00\x00'
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               F1                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       F2      |
+-+-+-+-+-+-+-+-+

                           Fig. TestPad

guedou avatar Jan 06 '23 11:01 guedou

Good point. There might be some other complex fields that currently aren't handled.

gpotter2 avatar Jan 06 '23 11:01 gpotter2