diff --git a/crypto.cc b/crypto.cc index bd9ac24..fb1fd69 100644 --- a/crypto.cc +++ b/crypto.cc @@ -302,11 +302,24 @@ void CryptoPubServerConnection::OnHandshake(const TLVNode& decoded) { bool CryptoPubServerConnection::OnMessage(const TLVNode& message) { switch (message.GetType()) { + case TLV_TYPE_TUNNEL_REQUEST: + return OnTunnelRequest(message); default: return false; } } +bool CryptoPubServerConnection::OnTunnelRequest(const TLVNode& message) { + Log() << "New tunnel request" << std::endl; + for (auto child : message.GetChildren()) { + if (child->GetType() != TLV_TYPE_CHANNEL) { + continue; + } + Log() << "Channel" << std::endl; + } + return true; +} + void CryptoPubServerConnection::SendHandshake() { auto handshake = BuildSecureHandshake(); std::string out; diff --git a/crypto.h b/crypto.h index d497623..43d2311 100644 --- a/crypto.h +++ b/crypto.h @@ -80,6 +80,7 @@ class CryptoPubServerConnection : public CryptoPubConnBase { private: void OnHandshake(const TLVNode& decoded); bool OnMessage(const TLVNode& node); + bool OnTunnelRequest(const TLVNode& node); static void OnError_(struct bufferevent* bev, const short what, void* this__); void OnError(const short what); diff --git a/tlv.cc b/tlv.cc index d269808..58a56c3 100644 --- a/tlv.cc +++ b/tlv.cc @@ -105,3 +105,8 @@ const std::string& TLVNode::GetValue() const { assert(!this->IsContainer()); return value_; } + +const std::list& TLVNode::GetChildren() const { + assert(this->IsContainer()); + return children_; +} diff --git a/tlv.h b/tlv.h index df421c1..f46894a 100644 --- a/tlv.h +++ b/tlv.h @@ -18,6 +18,7 @@ class TLVNode { bool IsContainer() const; uint16_t GetType() const; const std::string& GetValue() const; + const std::list& GetChildren() const; private: const uint16_t type_;