I am writing a python script that creates UDP packets at layer 2 with Scapy.
However, I continually get a "TypeError" when including UDP() options/attributes in the definition of the packet.
Code:
Return_Data = sendp( Ether(dst="ff:ff:ff:ff:ff:ff", type=0x800) \
/ IP(version=4L, ihl=5L, tos=0x0, len=64, \
id=0, flags=0, frag=0L, ttl=64, proto=UDP, \
chksum = 30495, src="xxx.xxx.xx.xxx", dst="xxx.xxx.x.x") / \
UDP(sport=31123, dport=31123, chksum=0x6f21, len=30) / Raw(load=Payload) )
Traceback (most recent call last):
File "EthCfgRx_Test_3.py", line 20, in UDP(sport=31123, dport=31123, chksum=0x6f21, len=30) / Raw(load=Payload) )
File "/home/watouser/.local/lib/python2.7/site-packages/scapy/packet.py", line 349, in div cloneB = other.copy()
File "/home/watouser/.local/lib/python2.7/site-packages/scapy/packet.py", line 200, in copy clone.fields = self.copy_fields_dict(self.fields)
File "/home/watouser/.local/lib/python2.7/site-packages/scapy/packet.py", line 382, in copy_fields_dict for fname, fval in six.iteritems(fields)}
File "/home/watouser/.local/lib/python2.7/site-packages/scapy/packet.py", line 382, in for fname, fval in six.iteritems(fields)}
File "/home/watouser/.local/lib/python2.7/site-packages/scapy/packet.py", line 377, in copy_field_value return self.get_field(fieldname).do_copy(value)
File "/home/watouser/.local/lib/python2.7/site-packages/scapy/fields.py", line 86, in do_copy return x.copy()
TypeError: unbound method copy() must be called with UDP instance as first argument (got nothing instead)
Any Advice?
Thanks in Advance!