crappidy
crappidy

Reputation: 407

Binding custom layers in scapy

I have a python script which assembles and sends AVB (IEEE) packets into a network. The packets will be captured by wireshark. With an other python script I iterate through the capture file. But I can't access a few parameters in a few layers because scapy doesn't know them. So I have to add those layers to scapy.

Here's the packet in wireshark: enter image description here

I added the following code to the file "python2.7/dist-packages/scapy/layers/l2.py"

class ieee(Packet):
  name = "IEEE 1722 Packet"
  fields_desc=[ XByteField("subtype", 0x00),
                XByteField("svfield", 0x81),
                XByteField("verfield", 0x81)]

bind_layers(Dot1Q, ieee1722, type=0x22f0)

When I execute the python script which should grab the parameters in the new layer (IEEE 1722 Protocol), the following error occurs: "IndexError: Layer [ieee1722] not found"

What's wrong?

Upvotes: 1

Views: 4000

Answers (2)

Sirmabus
Sirmabus

Reputation: 736

This is old, maybe they didn't have the doc page but they have it now:
"Adding new protocols"
https://scapy.readthedocs.io/en/latest/build_dissect.html

Upvotes: 1

crappidy
crappidy

Reputation: 407

Ok, found the solution by editing the type value:

  bind_layers(Dot1Q, ieee1722, type=0x88f7) ---> works

Dot1Q is the layer above the created ieee1722 layer (see wireshark). You can see the type value by clicking at the layer of a packet in wireshark.

Upvotes: 2

Related Questions