Skip to content

IPv4 Packet Creation failed : TypeError: object of type 'NoneType' has no len() #49

Open
@sunilkr

Description

@sunilkr

While crafting IPv4 packet, following exception was raise.
Code:

        pkt = ip.IP(src_s='127.0.0.1', dst_s='127.0.0.2', tos=0, id=12, off=1024, ttl=64)
        pkt.flags = ip.IP_DF|ip.IP_MF
        pkt.body_bytes = b'12345678'
        raw = pkt.bin()

TraceBack:

Traceback (most recent call last):
  File "/home/user/code/py3/project/unittests/test_ip.py", line 57, in test_match_unicast_true
    raw = pkt.bin()
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/pypacker.py", line 820, in bin
    layer._update_fields()
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/layer3/ip.py", line 229, in _update_fields
    self.sum = in_cksum(self._pack_header())
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/checksum.py", line 49, in in_cksum
    return in_cksum_done(in_cksum_add(0, buf))
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/checksum.py", line 23, in in_cksum_add
    n = len(buf)
TypeError: object of type 'NoneType' has no len()

Something I did wrong, or its some corner case. Hoe to access error object from pypacker.PyPacket

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions