summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r--cpp/src/qpid/framing/FieldValue.cpp14
-rw-r--r--cpp/src/qpid/framing/FrameSet.h8
-rw-r--r--cpp/src/qpid/framing/Handler.h43
-rw-r--r--cpp/src/qpid/framing/ProtocolInitiation.cpp31
-rw-r--r--cpp/src/qpid/framing/ProtocolVersion.cpp8
5 files changed, 69 insertions, 35 deletions
diff --git a/cpp/src/qpid/framing/FieldValue.cpp b/cpp/src/qpid/framing/FieldValue.cpp
index ce5a50117c..4abed0f77f 100644
--- a/cpp/src/qpid/framing/FieldValue.cpp
+++ b/cpp/src/qpid/framing/FieldValue.cpp
@@ -23,6 +23,7 @@
#include "qpid/framing/Buffer.h"
#include "qpid/framing/Endian.h"
#include "qpid/framing/List.h"
+#include "qpid/framing/Uuid.h"
#include "qpid/framing/reply_exceptions.h"
#include "qpid/Msg.h"
@@ -43,7 +44,9 @@ void FieldValue::setType(uint8_t type)
data.reset(new EncodedValue<List>());
} else if (typeOctet == 0xAA) {
data.reset(new EncodedValue<Array>());
- } else {
+ } else if (typeOctet == 0x48) {
+ data.reset(new UuidData());
+ } else {
uint8_t lenType = typeOctet >> 4;
switch(lenType){
case 0:
@@ -213,9 +216,12 @@ Integer8Value::Integer8Value(int8_t v) :
Integer16Value::Integer16Value(int16_t v) :
FieldValue(0x11, new FixedWidthValue<2>(v))
{}
-UuidValue::UuidValue(const unsigned char* v) :
- FieldValue(0x48, new FixedWidthValue<16>(v))
-{}
+
+UuidData::UuidData() {}
+UuidData::UuidData(const unsigned char* bytes) : FixedWidthValue<16>(bytes) {}
+bool UuidData::convertsToString() const { return true; }
+std::string UuidData::getString() const { return Uuid(rawOctets()).str(); }
+UuidValue::UuidValue(const unsigned char* v) : FieldValue(0x48, new UuidData(v)) {}
void FieldValue::print(std::ostream& out) const {
data->print(out);
diff --git a/cpp/src/qpid/framing/FrameSet.h b/cpp/src/qpid/framing/FrameSet.h
index 3b9f60950b..9640abb7ac 100644
--- a/cpp/src/qpid/framing/FrameSet.h
+++ b/cpp/src/qpid/framing/FrameSet.h
@@ -1,3 +1,5 @@
+#ifndef QPID_FRAMING_FRAMESET_H
+#define QPID_FRAMING_FRAMESET_H
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -18,6 +20,7 @@
* under the License.
*
*/
+
#include <string>
#include "qpid/InlineVector.h"
#include "qpid/framing/amqp_framing.h"
@@ -25,9 +28,6 @@
#include "qpid/framing/SequenceNumber.h"
#include "qpid/CommonImportExport.h"
-#ifndef _FrameSet_
-#define _FrameSet_
-
namespace qpid {
namespace framing {
@@ -117,4 +117,4 @@ public:
}
-#endif
+#endif /*!QPID_FRAMING_FRAMESET_H*/
diff --git a/cpp/src/qpid/framing/Handler.h b/cpp/src/qpid/framing/Handler.h
index fa8db36f49..e0c0e59d09 100644
--- a/cpp/src/qpid/framing/Handler.h
+++ b/cpp/src/qpid/framing/Handler.h
@@ -49,29 +49,12 @@ struct Handler {
* Functor<F>(f) will copy f.
* Functor<F&>(f) will only take a reference to x.
*/
- template <class F> class Functor : public Handler<T> {
- public:
- Functor(F f, Handler<T>* next=0) : Handler<T>(next), functor(f) {}
- void handle(T t) { functor(t); }
- private:
- F functor;
- };
+ template <class F> class Functor;
/** Adapt a member function of X as a Handler.
* Only holds a reference to its target, not a copy.
*/
- template <class X, void (X::*F)(T)>
- class MemFunRef : public Handler<T> {
- public:
- MemFunRef(X& x, Handler<T>* next=0) : Handler(next), target(&x) {}
- void handle(T t) { (target->*F)(t); }
-
- /** Allow calling with -> syntax */
- MemFunRef* operator->() { return this; }
-
- private:
- X* target;
- };
+ template <class X, void (X::*F)(T)> class MemFunRef;
/** Interface for a handler that implements a
* pair of in/out handle operations.
@@ -94,7 +77,29 @@ struct Handler {
};
};
+template <class T>
+template <class F>
+class Handler<T>::Functor : public Handler<T> {
+ public:
+ Functor(F f, Handler<T>* next=0) : Handler<T>(next), functor(f) {}
+ void handle(T t) { functor(t); }
+ private:
+ F functor;
+};
+
+template <class T>
+template <class X, void (X::*F)(T)>
+class Handler<T>::MemFunRef : public Handler<T> {
+ public:
+ MemFunRef(X& x, Handler<T>* next=0) : Handler(next), target(&x) {}
+ void handle(T t) { (target->*F)(t); }
+
+ /** Allow calling with -> syntax */
+ MemFunRef* operator->() { return this; }
+ private:
+ X* target;
+};
}}
#endif /*!QPID_FRAMING_HANDLER_H*/
diff --git a/cpp/src/qpid/framing/ProtocolInitiation.cpp b/cpp/src/qpid/framing/ProtocolInitiation.cpp
index 00ddb55a3b..19cb3f0e3d 100644
--- a/cpp/src/qpid/framing/ProtocolInitiation.cpp
+++ b/cpp/src/qpid/framing/ProtocolInitiation.cpp
@@ -38,10 +38,17 @@ void ProtocolInitiation::encode(Buffer& buffer) const {
buffer.putOctet('M');
buffer.putOctet('Q');
buffer.putOctet('P');
- buffer.putOctet(1);//class
- buffer.putOctet(1);//instance
- buffer.putOctet(version.getMajor());
- buffer.putOctet(version.getMinor());
+ if (version.getMajor() == 1) {
+ buffer.putOctet(version.getProtocol());
+ buffer.putOctet(version.getMajor());
+ buffer.putOctet(version.getMinor());
+ buffer.putOctet(0);//revision
+ } else {
+ buffer.putOctet(1);//class
+ buffer.putOctet(1);//instance
+ buffer.putOctet(version.getMajor());
+ buffer.putOctet(version.getMinor());
+ }
}
bool ProtocolInitiation::decode(Buffer& buffer){
@@ -50,10 +57,18 @@ bool ProtocolInitiation::decode(Buffer& buffer){
buffer.getOctet();//M
buffer.getOctet();//Q
buffer.getOctet();//P
- buffer.getOctet();//class
- buffer.getOctet();//instance
- version.setMajor(buffer.getOctet());
- version.setMinor(buffer.getOctet());
+ uint8_t protocolClass = buffer.getOctet();//class
+ version.setProtocol(protocolClass);
+ if (protocolClass == 1) {
+ //old (pre-1.0) style
+ buffer.getOctet();//instance
+ version.setMajor(buffer.getOctet());
+ version.setMinor(buffer.getOctet());
+ } else {
+ version.setMajor(buffer.getOctet());
+ version.setMinor(buffer.getOctet());
+ buffer.getOctet();//revision
+ }
return true;
}else{
return false;
diff --git a/cpp/src/qpid/framing/ProtocolVersion.cpp b/cpp/src/qpid/framing/ProtocolVersion.cpp
index c63cddb4cc..174fc3e65b 100644
--- a/cpp/src/qpid/framing/ProtocolVersion.cpp
+++ b/cpp/src/qpid/framing/ProtocolVersion.cpp
@@ -27,6 +27,10 @@ const std::string ProtocolVersion::toString() const
{
std::stringstream ss;
ss << major_ << "-" << minor_;
+ if (major_ == 1) {
+ if (protocol_ == SASL) ss << " (SASL)";
+ else if (protocol_ == TLS) ss << " (TLS)";
+ }
return ss.str();
}
@@ -42,3 +46,7 @@ bool ProtocolVersion::operator==(ProtocolVersion p) const
return major_ == p.major_ && minor_ == p.minor_;
}
+uint8_t ProtocolVersion::AMQP(0);
+uint8_t ProtocolVersion::LEGACY_AMQP(1);
+uint8_t ProtocolVersion::TLS(2);
+uint8_t ProtocolVersion::SASL(3);