File: loopback.py

package info (click to toggle)
python-dpkt 1.6%2Bsvn54-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 448 kB
  • ctags: 1,950
  • sloc: python: 5,136; makefile: 71
file content (20 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# $Id: loopback.py 38 2007-03-17 03:33:16Z dugsong $

"""Platform-dependent loopback header."""

import dpkt, ethernet, ip, 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)