Skip to content

show() can't resolve Net6 hostname to ip6 address #643

@qin-nz

Description

@qin-nz

The following code run well. (only version 2.3.3, not 2.3.3dev432)

a4=Ether()/IP(dst="mirrors4.tuna.tsinghua.edu.cn")/TCP()/"GET /index.html HTTP/1.0 \n\n"
a4.show()

But when I change it to IPv6 version. Some error occurred.

a6=Ether()/IPv6(dst="mirrors6.tuna.tsinghua.edu.cn")/TCP()/"GET /index.html HTTP/1.0 \n\n"
a6.show()

Error in version 2.3.3:

>>> a6=Ether()/IPv6(dst="mirrors6.tuna.tsinghua.edu.cn")/TCP()/"GET /index.html HTTP/1.0 \n\n"
>>> a6.show()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/scapy/packet.py", line 892, in show
    return self._show_or_dump(dump, indent, lvl, label_lvl)
  File "/usr/local/lib/python2.7/site-packages/scapy/packet.py", line 875, in _show_or_dump
    reprval = f.i2repr(self,fvalue)
  File "/usr/local/lib/python2.7/site-packages/scapy/fields.py", line 213, in i2repr
    x = self.i2h(pkt, x)
  File "/usr/local/lib/python2.7/site-packages/scapy/layers/l2.py", line 97, in i2h
    x = conf.neighbor.resolve(pkt,pkt.payload)
  File "/usr/local/lib/python2.7/site-packages/scapy/layers/l2.py", line 45, in resolve
    return self.resolvers[k](l2inst,l3inst)
  File "/usr/local/lib/python2.7/site-packages/scapy/layers/inet6.py", line 503, in inet6_register_l3
    return getmacbyip6(l3.dst)
  File "/usr/local/lib/python2.7/site-packages/scapy/layers/inet6.py", line 105, in getmacbyip6
    if in6_ismaddr(ip6): # Multicast
  File "/usr/local/lib/python2.7/site-packages/scapy/utils6.py", line 715, in in6_ismaddr
    return in6_isincluded(str, 'ff00::', 8)
  File "/usr/local/lib/python2.7/site-packages/scapy/utils6.py", line 651, in in6_isincluded
    temp = inet_pton(socket.AF_INET6, addr)
  File "/usr/local/lib/python2.7/site-packages/scapy/pton_ntop.py", line 33, in inet_pton
    parts = addr.split(":")
AttributeError: 'Net6' object has no attribute 'split'

Error in version 2.3.3dev432

>>> a6=Ether()/IPv6(dst="mirrors6.tuna.tsinghua.edu.cn")/TCP()/"GET /index.html HTTP/1.0 \n\n"
>>> a6.show()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/scapy/packet.py", line 1005, in show
    return self._show_or_dump(dump, indent, lvl, label_lvl)
  File "/Library/Python/2.7/site-packages/scapy/packet.py", line 979, in _show_or_dump
    reprval = f.i2repr(self,fvalue)
  File "/Library/Python/2.7/site-packages/scapy/fields.py", line 215, in i2repr
    x = self.i2h(pkt, x)
  File "/Library/Python/2.7/site-packages/scapy/layers/l2.py", line 98, in i2h
    x = conf.neighbor.resolve(pkt,pkt.payload)
  File "/Library/Python/2.7/site-packages/scapy/layers/l2.py", line 46, in resolve
    return self.resolvers[k](l2inst,l3inst)
  File "/Library/Python/2.7/site-packages/scapy/layers/inet6.py", line 544, in inet6_register_l3
    return getmacbyip6(l3.dst)
  File "/Library/Python/2.7/site-packages/scapy/layers/inet6.py", line 106, in getmacbyip6
    if in6_ismaddr(ip6): # Multicast
  File "/Library/Python/2.7/site-packages/scapy/utils6.py", line 678, in in6_ismaddr
    return in6_isincluded(str, 'ff00::', 8)
  File "/Library/Python/2.7/site-packages/scapy/utils6.py", line 614, in in6_isincluded
    temp = inet_pton(socket.AF_INET6, addr)
  File "/Library/Python/2.7/site-packages/scapy/pton_ntop.py", line 79, in inet_pton
    return socket.inet_pton(af, addr)
TypeError: must be string, not Net6

Error in version 2.3.3dev432

>>> a4=Ether()/IP(dst="mirrors4.tuna.tsinghua.edu.cn")/TCP()/"GET /index.html HTTP/1.0 \n\n"
>>> a4.show()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "scapy/packet.py", line 1005, in show
    return self._show_or_dump(dump, indent, lvl, label_lvl)
  File "scapy/packet.py", line 979, in _show_or_dump
    reprval = f.i2repr(self,fvalue)
  File "scapy/fields.py", line 215, in i2repr
    x = self.i2h(pkt, x)
  File "scapy/layers/l2.py", line 98, in i2h
    x = conf.neighbor.resolve(pkt,pkt.payload)
  File "scapy/layers/l2.py", line 46, in resolve
    return self.resolvers[k](l2inst,l3inst)
  File "scapy/layers/inet.py", line 817, in inet_register_l3
    return getmacbyip(l3.dst)
  File "scapy/layers/l2.py", line 81, in getmacbyip
    nofilter=1)
  File "scapy/sendrecv.py", line 402, in srp1
    a,b=srp(*args,**kargs)
  File "scapy/sendrecv.py", line 384, in srp
    s = conf.L2socket(promisc=promisc, iface=iface, filter=filter, nofilter=nofilter, type=type)
  File "scapy/arch/bpf/supersocket.py", line 53, in __init__
    (self.ins, self.dev_bpf) = get_dev_bpf()
  File "scapy/arch/bpf/core.py", line 110, in get_dev_bpf
    raise Scapy_Exception("No /dev/bpf handle is available !")
Scapy_Exception: No /dev/bpf handle is available !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions