Commit 85bad0b7 authored by Julien Muchembled's avatar Julien Muchembled

Simplify protocol version

parent 531a7df7
...@@ -24,8 +24,7 @@ try: ...@@ -24,8 +24,7 @@ try:
except ImportError: except ImportError:
pass pass
# The protocol version (major, minor). PROTOCOL_VERSION = 1
PROTOCOL_VERSION = (15, 1)
# Size restrictions. # Size restrictions.
MIN_PACKET_SIZE = 10 MIN_PACKET_SIZE = 10
...@@ -570,21 +569,18 @@ class PPTID(PStructItem): ...@@ -570,21 +569,18 @@ class PPTID(PStructItem):
value = None value = None
return value return value
class PProtocol(PStructItem): class PProtocol(PNumber):
""" """
The protocol version definition The protocol version definition
""" """
def __init__(self, name):
PStructItem.__init__(self, name, '!LL')
def _encode(self, writer, version): def _encode(self, writer, version):
writer(self.pack(*version)) writer(self.pack(version))
def _decode(self, reader): def _decode(self, reader):
major, minor = self.unpack(reader(self.size)) version = self.unpack(reader(self.size))
if (major, minor) != PROTOCOL_VERSION: if version != (PROTOCOL_VERSION,):
raise ProtocolError('protocol version mismatch') raise ProtocolError('protocol version mismatch')
return (major, minor) return version
class PChecksum(PItem): class PChecksum(PItem):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment