python - Scapy: TypeError when adding new protocol/ layer -
I am trying to create a new layer / protocol in the scp. I see this error when I'm trying to send / show it.
I have added breakpoints to see what is happening but somehow the interior is being converted into a string tube. I'm not sure what I'm missing. Can anyone help me in this problem nail?
& gt; & Gt; & Gt; P1 = PCEOPOPEN ()> gt; & Gt; & Gt; P1.show2 ()> /usr/local/lib64/python2.6/site-packages/scapy/fields.py (71) Adfield () - & gt; Returns s + struct.pack (self.fmt, self.i2m (pkt, val)) (PDB) Val 1 (PDB) P '' (PDB) C & gt; /usr/local/lib64/python2.6/site-packages/scapy/fields.py (71) Adfield () - & gt; Returns s + struct.pack (self.fmt, self.i2m (pkt, val)) (pdb) ps '\ x01 \ x10' (pdb) val 4 (pdb) ps '\ x01 \ x10' (pdb) c & Gt; /usr/local/lib64/python2.6/site-packages/scapy/fields.py (71) Adfield () - & gt; Returns s + struct.pack (self.fmt, self.i2m (pkt, val)) (PDB) Val 10 (PDB) ps ('\ x01 \ x10 \ x00 \ x04', 3, 1L) (PDB) C traceback (Most recent call final): File "console" gt; line 1, & lt; Module & gt; In the file "/usr/local/lib64/python2.6/site-packages/scapy/packet.py", line 831, show2 self.__ class __ (str (self)). Show () file "/ usr / local / lib64 /python2.6/site-packages/scapy/packet.py", line 262, __tratty return self. "/usr/local/lib64/python2.6/site-packages/scapy/packet.py" in the build () file, line 321, Build P = self.do_build () file "/ usr / local / lib64 / python2. 6 / site-packages / scapy / packet.py ", in line 309, in the do_build pkt = self.self_build () file" /usr/local/lib64/python2.6/site-packages/scapy/packet.py " Line 300, itself in the form of self = build p = f.addfield (self, p, val) file "/ usr / local / lib64 / python2./6/ site-packages / scapy / fields.py", addfield return s + struct Type error in pack (self.fmt, self.i2m (pkt, val)): only toll (only "str") toplepe and gt; & Gt; & Gt; P1.show () ### [Object Open for Open Message] ### oclass = Open Type = 1 Reflags = PfLog = iflag = obLength = 4 ver = 1 kalive = 10 Dead = 40 SID = 1> & gt; & Gt; Class PCEPOPEN (Packet): A PCEP session "Open" field for open message "dccc = [biotechnumfield (" oculus ", 1, _bract_clus), bitfield (" otype ", 1, 4), bitfield (" Flufffilled ("iflag", 0x0, 1, "I"), short field ("obLength" 4), bitfield ("vars", "resflags", 0, 2), flagfield ("pflag", 0x0, 1, "P" (Self, pkt, pay): If self.obLength 4: Bytefield ("kalive", 10), bytefield ("dead", 40), bytefield ("sid", 1) def post_build Returns pkt + pay
It seems that I accidentally removed the area which caused the problem. I used bitfield and had added 3 bits but I was removed from the line which included bitfields with 5 more bits. Because the packet was wrapped by byte in the coalition, there was a complaint. It was good to know that :)