admin管理员组

文章数量:1201199

I am trying to extend Scapy's protocol parsing capabilities. Here is my code:

from scapy.all import *

class IEEE1722(Packet):
    name = "ieee1722"
    fields_desc = [
        BitField("subtype", 0, 8),
        BitField("header_specific", 0, 1),
        BitField("version", 0, 3),
        Raw("payload")
    ]

bind_layers(Ether, IEEE1722, type=0x22f0)

However, when I use it, packet.haslayer(IEEE1722) returns 0. When I run packet.show(), it prints:

###[ Ethernet ]### 
  dst       = 91:e0:f0:01:00:00
  src       = 00:fc:70:00:00:02
  type      = 0x22f0
###[ Raw ]### 
......

I can see that Ether().payload_guess can print out the protocol class I bound, and the type is also correct. I expect to be able to correctly parse and obtain the layer of my custom protocol.

本文标签: Why does not scapy bindlayers recognize my custom layerStack Overflow