mengzurui / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

problem with mpls decapsulation #62

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Analyzing mpls encapsulated packets

What is the expected output? What do you see instead?
I open a pcap file with multiple mpls layers on each packet.  When I try to 
iterate through, it has eth.data as a type str instead of dpkt.ip.IP.  If I try 
forcing ip on eth(data) I get "dpkt.dpkt.UnpackError: invalid header length"

for ts, data in pcapreader:
    try: eth = dpkt.ethernet.Ethernet(data)
    except: continue
    print eth.type
    ip = dpkt.ip.IP(eth.data)

2048
Traceback (most recent call last):
  File "pcap-parse.py"
, line 14, in <module>
    ip = dpkt.ip.IP(eth.data)
  File "c:\Python27\lib\site-packages\dpkt\dpkt.py", line 72, in __init__
    self.unpack(args[0])
  File "c:\Python27\lib\site-packages\dpkt\ip.py", line 56, in unpack
    raise dpkt.UnpackError, 'invalid header length'
dpkt.dpkt.UnpackError: invalid header length

What version of the product are you using? On what operating system?
1.7

Please provide any additional information below.

Original issue reported on code.google.com by toby.bea...@gmail.com on 23 Jan 2011 at 10:06

GoogleCodeExporter commented 9 years ago
Seems to be breaking in ip.py during the unpack.

def unpack(self, buf):
        dpkt.Packet.unpack(self, buf)
        ol = ((self.v_hl & 0xf) << 2) - self.__hdr_len__
        if ol < 0:  

in my debug self.v_hl = 1, self.__hdr_len__ = 20, and ol = -16.

Original comment by toby.bea...@gmail.com on 24 Jan 2011 at 10:25