summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-08-26 14:27:43 +0300
committerDan Klein <danklei@cisco.com>2015-08-26 14:27:43 +0300
commitcdcc62972d42f009f55e6aeb2ca5c60c3acd75eb (patch)
tree5c3fef81ac01407a89740f2d9b8b01b0f3a47c7f /scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py
parent42053c95419042f36242b19d2416d112f7643e14 (diff)
added dpkt package, initial stateless client implementation
Diffstat (limited to 'scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py')
-rw-r--r--scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py b/scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py
deleted file mode 100644
index 282bdd98..00000000
--- a/scripts/automation/trex_control_plane/python_lib/dpkt-1.8.6.2/dpkt/ppp.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# $Id: ppp.py 65 2010-03-26 02:53:51Z dugsong $
-# -*- coding: utf-8 -*-
-"""Point-to-Point Protocol."""
-
-import struct
-import dpkt
-
-# XXX - finish later
-
-# http://www.iana.org/assignments/ppp-numbers
-PPP_IP = 0x21 # Internet Protocol
-PPP_IP6 = 0x57 # Internet Protocol v6
-
-# Protocol field compression
-PFC_BIT = 0x01
-
-
-class PPP(dpkt.Packet):
- __hdr__ = (
- ('p', 'B', PPP_IP),
- )
- _protosw = {}
-
- @classmethod
- def set_p(cls, p, pktclass):
- cls._protosw[p] = pktclass
-
- @classmethod
- def get_p(cls, p):
- return cls._protosw[p]
-
- def unpack(self, buf):
- dpkt.Packet.unpack(self, buf)
- if self.p & PFC_BIT == 0:
- self.p = struct.unpack('>H', buf[:2])[0]
- self.data = self.data[1:]
- try:
- self.data = self._protosw[self.p](self.data)
- setattr(self, self.data.__class__.__name__.lower(), self.data)
- except (KeyError, struct.error, dpkt.UnpackError):
- pass
-
- def pack_hdr(self):
- try:
- if self.p > 0xff:
- return struct.pack('>H', self.p)
- return dpkt.Packet.pack_hdr(self)
- except struct.error, e:
- raise dpkt.PackError(str(e))
-
-
-def __load_protos():
- g = globals()
- for k, v in g.iteritems():
- if k.startswith('PPP_'):
- name = k[4:]
- modname = name.lower()
- try:
- mod = __import__(modname, g)
- except ImportError:
- continue
- PPP.set_p(v, getattr(mod, name))
-
-
-if not PPP._protosw:
- __load_protos()