diff options
author | Dan Klein <danklei@cisco.com> | 2015-08-26 14:27:43 +0300 |
---|---|---|
committer | Dan Klein <danklei@cisco.com> | 2015-08-26 14:27:43 +0300 |
commit | cdcc62972d42f009f55e6aeb2ca5c60c3acd75eb (patch) | |
tree | 5c3fef81ac01407a89740f2d9b8b01b0f3a47c7f /external_libs/python/dpkt-1.8.6.2/dpkt/loopback.py | |
parent | 42053c95419042f36242b19d2416d112f7643e14 (diff) |
added dpkt package, initial stateless client implementation
Diffstat (limited to 'external_libs/python/dpkt-1.8.6.2/dpkt/loopback.py')
-rw-r--r-- | external_libs/python/dpkt-1.8.6.2/dpkt/loopback.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/external_libs/python/dpkt-1.8.6.2/dpkt/loopback.py b/external_libs/python/dpkt-1.8.6.2/dpkt/loopback.py new file mode 100644 index 00000000..5bf24bf5 --- /dev/null +++ b/external_libs/python/dpkt-1.8.6.2/dpkt/loopback.py @@ -0,0 +1,25 @@ +# $Id: loopback.py 38 2007-03-17 03:33:16Z dugsong $ +# -*- coding: utf-8 -*- +"""Platform-dependent loopback header.""" + +import dpkt +import ethernet +import ip +import ip6 + + +class Loopback(dpkt.Packet): + __hdr__ = (('family', 'I', 0), ) + __byte_order__ = '@' + + def unpack(self, buf): + dpkt.Packet.unpack(self, buf) + if self.family == 2: + self.data = ip.IP(self.data) + elif self.family == 0x02000000: + self.family = 2 + self.data = ip.IP(self.data) + elif self.family in (24, 28, 30): + self.data = ip6.IP6(self.data) + elif self.family > 1500: + self.data = ethernet.Ethernet(self.data) |