2018-12-12 02:52:51 +00:00
|
|
|
#include <messages/path_transfer.hpp>
|
2019-01-10 19:41:51 +00:00
|
|
|
|
2019-01-14 21:46:07 +00:00
|
|
|
#include <routing/handler.hpp>
|
2019-01-10 19:41:51 +00:00
|
|
|
#include <util/buffer.hpp>
|
2018-06-29 14:25:09 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace routing
|
|
|
|
{
|
|
|
|
PathTransferMessage::PathTransferMessage() : IMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PathTransferMessage::~PathTransferMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PathTransferMessage::DecodeKey(llarp_buffer_t key, llarp_buffer_t* val)
|
|
|
|
{
|
|
|
|
bool read = false;
|
|
|
|
if(!BEncodeMaybeReadDictEntry("P", P, read, key, val))
|
|
|
|
return false;
|
2018-07-23 21:59:43 +00:00
|
|
|
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
|
|
|
|
return false;
|
2018-08-12 17:22:29 +00:00
|
|
|
if(!BEncodeMaybeReadDictEntry("T", T, read, key, val))
|
|
|
|
return false;
|
2018-09-11 15:28:36 +00:00
|
|
|
if(!BEncodeMaybeReadDictInt("V", version, read, key, val))
|
2018-06-29 14:25:09 +00:00
|
|
|
return false;
|
|
|
|
if(!BEncodeMaybeReadDictEntry("Y", Y, read, key, val))
|
|
|
|
return false;
|
2018-08-12 17:22:29 +00:00
|
|
|
return read;
|
2018-06-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PathTransferMessage::BEncode(llarp_buffer_t* buf) const
|
|
|
|
{
|
|
|
|
if(!bencode_start_dict(buf))
|
|
|
|
return false;
|
|
|
|
if(!BEncodeWriteDictMsgType(buf, "A", "T"))
|
|
|
|
return false;
|
|
|
|
if(!BEncodeWriteDictEntry("P", P, buf))
|
|
|
|
return false;
|
2018-07-22 23:14:29 +00:00
|
|
|
|
2018-07-23 21:59:43 +00:00
|
|
|
if(!BEncodeWriteDictInt("S", S, buf))
|
|
|
|
return false;
|
|
|
|
|
2018-08-12 17:22:29 +00:00
|
|
|
if(!BEncodeWriteDictEntry("T", T, buf))
|
2018-06-29 14:25:09 +00:00
|
|
|
return false;
|
2018-07-22 23:14:29 +00:00
|
|
|
|
2018-07-23 21:59:43 +00:00
|
|
|
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
|
2018-06-29 14:25:09 +00:00
|
|
|
return false;
|
|
|
|
if(!BEncodeWriteDictEntry("Y", Y, buf))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return bencode_end(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PathTransferMessage::HandleMessage(IMessageHandler* h,
|
2018-12-10 16:26:46 +00:00
|
|
|
llarp::Router* r) const
|
2018-06-29 14:25:09 +00:00
|
|
|
{
|
2018-08-12 17:22:29 +00:00
|
|
|
return h->HandlePathTransferMessage(this, r);
|
2018-06-29 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
2018-07-22 23:14:29 +00:00
|
|
|
} // namespace routing
|
|
|
|
} // namespace llarp
|