I'm trying to create my own protocol for scapy and have been stuck for the last couple of days.
What I'm looking to do is use the first 14 bytes for the first layer, 6 for dst mac, 6 src mac, 2 for padding. The rest of the packet would be the payload.
The problem is I'm not exactly sure how to make the 5th and 6th byte in the packet to be a field that would give an ShortField value.
class MyEther(Packet):
name = "MyEther"
fields_desc =[
MACField("dst", None),
MACField("src", None),
StrLenField('padding', None, length_from=lambda x: 2)
]
help is much appreciated!
In this case, the use of MACField is not appropriate. You should use an IntField followed by a ShortField, for each MACField.
If you really know what you are doing, however, and you know you need MACField, you can use
(mac2str is imported from scapy)