26 lines
588 B
Python
26 lines
588 B
Python
|
from scapy.all import *
|
||
|
import sys, os
|
||
|
|
||
|
CALC_TYPE = 0x1212
|
||
|
|
||
|
ADD_OP = 0
|
||
|
SUB_OP = 1
|
||
|
LOOKUP_OP = 2
|
||
|
ADD_REG_OP = 3
|
||
|
SET_REG_OP = 4
|
||
|
|
||
|
class Calc(Packet):
|
||
|
name = "Calc"
|
||
|
fields_desc = [
|
||
|
IntField("op1", 0),
|
||
|
ByteEnumField("opCode", 0, {ADD_OP:"ADD", SUB_OP:"SUB", LOOKUP_OP:"LOOKUP", ADD_REG_OP:"ADD_REG", SET_REG_OP:"SET_REG"}),
|
||
|
IntField("op2", 0),
|
||
|
IntField("result", 0)
|
||
|
]
|
||
|
def mysummary(self):
|
||
|
return self.sprintf("op1=%op1% %opCode% op2=%op2% result=%result%")
|
||
|
|
||
|
|
||
|
bind_layers(Ether, Calc, type=CALC_TYPE)
|
||
|
bind_layers(Calc, Raw)
|