summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2007-09-12 00:37:17 +0000
committerAndrew Stitcher <astitcher@apache.org>2007-09-12 00:37:17 +0000
commit8b455df678dcdac6107fa6861603f99bc1bbe1f5 (patch)
tree751360624179c4996e3070c27fba23346db81306 /qpid/python
parent26cd2b67b267b69ece35458d1d3cc4c4bc5707cc (diff)
downloadqpid-python-8b455df678dcdac6107fa6861603f99bc1bbe1f5.tar.gz
* python/qpid/codec.py
Comment typo * cpp/src/qpid/broker/RecoveryManagerImpl.cpp Cruft removal * python/qpid/codec.py * python/qpid/connection.py * cpp/src/qpid/framing/AMQFrame.h * cpp/src/qpid/framing/AMQFrame.cpp Initial implementation of 0-10 framing - This uses the new 12 byte frame header, but doesn't support splitting segments/framesets over multiple frames yet. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@574735 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/codec.py2
-rw-r--r--qpid/python/qpid/connection.py28
2 files changed, 26 insertions, 4 deletions
diff --git a/qpid/python/qpid/codec.py b/qpid/python/qpid/codec.py
index ae113619ae..c1a912f5d0 100644
--- a/qpid/python/qpid/codec.py
+++ b/qpid/python/qpid/codec.py
@@ -53,7 +53,7 @@ class Codec:
def read(self, n):
"""
- reads in 'n' bytes from the stream. Can raise EFO exception
+ reads in 'n' bytes from the stream. Can raise EOF exception
"""
data = self.stream.read(n)
if n > 0 and len(data) == 0:
diff --git a/qpid/python/qpid/connection.py b/qpid/python/qpid/connection.py
index 39bcde17df..11a0d3ec6a 100644
--- a/qpid/python/qpid/connection.py
+++ b/qpid/python/qpid/connection.py
@@ -92,23 +92,44 @@ class Connection:
def write(self, frame):
c = self.codec
+ c.encode_octet(0x0f) # TODO: currently fixed at ver=0, B=E=b=e=1
c.encode_octet(self.spec.constants.byname[frame.type].id)
- c.encode_short(frame.channel)
body = StringIO()
enc = codec.Codec(body, self.spec)
frame.encode(enc)
enc.flush()
- c.encode_longstr(body.getvalue())
+ frame_size = len(body.getvalue()) + 12 # TODO: Magic number (frame header size)
+ c.encode_short(frame_size)
+ c.encode_octet(0) # Reserved
+ c.encode_octet(frame.subchannel & 0x0f)
+ c.encode_short(frame.channel)
+ c.encode_long(0) # Reserved
+ c.write(body.getvalue())
c.encode_octet(self.FRAME_END)
def read(self):
c = self.codec
+ flags = c.decode_octet() # TODO: currently ignoring flags
+ framing_version = (flags & 0xc0) >> 6
+ if framing_version != 0:
+ raise "frame error: unknown framing version"
type = self.spec.constants.byid[c.decode_octet()].name
+ frame_size = c.decode_short()
+ if frame_size < 12: # TODO: Magic number (frame header size)
+ raise "frame error: frame size too small"
+ reserved1 = c.decode_octet()
+ field = c.decode_octet()
+ subchannel = field & 0x0f
channel = c.decode_short()
- body = c.decode_longstr()
+ reserved2 = c.decode_long() # TODO: reserved maybe need to ensure 0
+ if (flags & 0x30) != 0 or reserved1 != 0 or (field & 0xf0) != 0:
+ raise "frame error: reserved bits not all zero"
+ body_size = frame_size - 12 # TODO: Magic number (frame header size)
+ body = c.read(body_size)
dec = codec.Codec(StringIO(body), self.spec)
frame = Frame.DECODERS[type].decode(self.spec, dec, len(body))
frame.channel = channel
+ frame.subchannel = subchannel
end = c.decode_octet()
if end != self.FRAME_END:
garbage = ""
@@ -145,6 +166,7 @@ class Frame:
def init(self, args, kwargs):
self.channel = kwargs.pop("channel", 0)
+ self.subchannel = kwargs.pop("subchannel", 0)
def encode(self, enc): abstract