summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/AMQFrame.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-04-30 14:16:38 +0000
committerGordon Sim <gsim@apache.org>2008-04-30 14:16:38 +0000
commita2b413c1c0bea044d0c82ac3e1a99de5036761d1 (patch)
tree01166e7547caf8e5aee5a8569fa53db75f1d24f3 /cpp/src/qpid/framing/AMQFrame.cpp
parentc86a77f2ce6150ce8fc0770604d92502acd996b8 (diff)
downloadqpid-python-a2b413c1c0bea044d0c82ac3e1a99de5036761d1.tar.gz
QPID-988 and QPID-989: fixes to framing for final 0-10 spec
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@652386 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/AMQFrame.cpp')
-rw-r--r--cpp/src/qpid/framing/AMQFrame.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/cpp/src/qpid/framing/AMQFrame.cpp b/cpp/src/qpid/framing/AMQFrame.cpp
index 3ebb61feb5..d861251dba 100644
--- a/cpp/src/qpid/framing/AMQFrame.cpp
+++ b/cpp/src/qpid/framing/AMQFrame.cpp
@@ -37,14 +37,12 @@ void AMQFrame::setBody(const AMQBody& b) { body = new BodyHolder(b); }
void AMQFrame::setMethod(ClassId c, MethodId m) { body = new BodyHolder(c,m); }
-// This is now misleadingly named as it is not the frame size as
-// defined in the spec (as it also includes the end marker)
uint32_t AMQFrame::size() const {
return frameOverhead() + body->size();
}
uint32_t AMQFrame::frameOverhead() {
- return 12 /*frame header*/ + 1/*0xCE*/;
+ return 12 /*frame header*/;
}
void AMQFrame::encode(Buffer& buffer) const
@@ -55,18 +53,17 @@ void AMQFrame::encode(Buffer& buffer) const
uint8_t flags = (bof ? 0x08 : 0) | (eof ? 0x04 : 0) | (bos ? 0x02 : 0) | (eos ? 0x01 : 0);
buffer.putOctet(flags);
buffer.putOctet(getBody()->type());
- buffer.putShort(size() - 1); // Don't include end marker (it's not part of the frame itself)
+ buffer.putShort(size());
buffer.putOctet(0);
buffer.putOctet(0x0f & track);
buffer.putShort(channel);
buffer.putLong(0);
body->encode(buffer);
- buffer.putOctet(0xCE);
}
bool AMQFrame::decode(Buffer& buffer)
{
- if(buffer.available() < frameOverhead() - 1)
+ if(buffer.available() < frameOverhead())
return false;
buffer.record();
@@ -80,7 +77,7 @@ bool AMQFrame::decode(Buffer& buffer)
eos = flags & 0x01;
uint8_t type = buffer.getOctet();
uint16_t frame_size = buffer.getShort();
- if (frame_size < frameOverhead()-1)
+ if (frame_size < frameOverhead())
throw FramingErrorException(QPID_MSG("Frame size too small"));
uint8_t reserved1 = buffer.getOctet();
uint8_t field1 = buffer.getOctet();
@@ -96,16 +93,13 @@ bool AMQFrame::decode(Buffer& buffer)
// TODO: should no longer care about body size and only pass up
// B,E,b,e flags
- uint16_t body_size = frame_size + 1 - frameOverhead();
- if (buffer.available() < body_size+1u){
+ uint16_t body_size = frame_size - frameOverhead();
+ if (buffer.available() < body_size){
buffer.restore();
return false;
}
body = new BodyHolder();
body->decode(type,buffer, body_size);
- uint8_t end = buffer.getOctet();
- if (end != 0xCE)
- throw FramingErrorException(QPID_MSG("Frame end not found"));
return true;
}