mirror of https://github.com/oxen-io/lokinet
Move remaining messages around
parent
66cf5cc73d
commit
2291d48bcc
@ -1,65 +0,0 @@
|
||||
#include <messages/transfer_traffic.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/bencode.hpp>
|
||||
#include <util/endian.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
bool
|
||||
TransferTrafficMessage::PutBuffer(const llarp_buffer_t& buf,
|
||||
uint64_t counter)
|
||||
{
|
||||
if(buf.sz > MaxExitMTU)
|
||||
return false;
|
||||
X.emplace_back(buf.sz + 8);
|
||||
byte_t* ptr = X.back().data();
|
||||
htobe64buf(ptr, counter);
|
||||
ptr += 8;
|
||||
memcpy(ptr, buf.base, buf.sz);
|
||||
// 8 bytes encoding overhead and 8 bytes counter
|
||||
_size += buf.sz + 16;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TransferTrafficMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "I"))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("V", version, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictList("X", X, buf))
|
||||
return false;
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
TransferTrafficMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* buf)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, buf))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("V", version, read, key, buf))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictList("X", X, read, key, buf))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
bool
|
||||
TransferTrafficMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h->HandleTransferTrafficMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
@ -1 +1,63 @@
|
||||
#include <messages/dht.hpp>
|
||||
|
||||
#include <router/abstractrouter.hpp>
|
||||
#include <routing/handler.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
bool
|
||||
DHTMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val)
|
||||
{
|
||||
llarp::dht::Key_t from;
|
||||
from.Zero();
|
||||
if(key == "M")
|
||||
{
|
||||
return llarp::dht::DecodeMesssageList(from, val, M, true);
|
||||
}
|
||||
else if(key == "S")
|
||||
{
|
||||
return bencode_read_integer(val, &S);
|
||||
}
|
||||
else if(key == "V")
|
||||
{
|
||||
return bencode_read_integer(val, &V);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
DHTMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "M"))
|
||||
return false;
|
||||
if(!BEncodeWriteDictBEncodeList("M", M, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
|
||||
return false;
|
||||
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
DHTMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const
|
||||
{
|
||||
// set source as us
|
||||
llarp::dht::Key_t us{r->pubkey()};
|
||||
for(const auto& msg : M)
|
||||
{
|
||||
msg->From = us;
|
||||
msg->pathID = from;
|
||||
if(!h->HandleDHTMessage(*msg, r))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
@ -0,0 +1,148 @@
|
||||
#include <messages/link_message_parser.hpp>
|
||||
|
||||
#include <messages/dht_immediate.hpp>
|
||||
#include <messages/discard.hpp>
|
||||
#include <messages/link_intro.hpp>
|
||||
#include <messages/link_message.hpp>
|
||||
#include <messages/relay_commit.hpp>
|
||||
#include <messages/relay.hpp>
|
||||
#include <router_contact.hpp>
|
||||
#include <util/buffer.hpp>
|
||||
#include <util/logger.hpp>
|
||||
#include <util/metrics.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct InboundMessageParser::msg_holder_t
|
||||
{
|
||||
LinkIntroMessage i;
|
||||
RelayDownstreamMessage d;
|
||||
RelayUpstreamMessage u;
|
||||
DHTImmediateMessage m;
|
||||
LR_CommitMessage c;
|
||||
DiscardMessage x;
|
||||
|
||||
msg_holder_t() = default;
|
||||
};
|
||||
|
||||
InboundMessageParser::InboundMessageParser(AbstractRouter* _router)
|
||||
: router(_router), from(nullptr), msg(nullptr), holder(new msg_holder_t())
|
||||
{
|
||||
}
|
||||
|
||||
InboundMessageParser::~InboundMessageParser()
|
||||
{
|
||||
delete holder;
|
||||
}
|
||||
|
||||
bool
|
||||
InboundMessageParser::operator()(llarp_buffer_t* buffer, llarp_buffer_t* key)
|
||||
{
|
||||
// we are reading the first key
|
||||
if(firstkey)
|
||||
{
|
||||
llarp_buffer_t strbuf;
|
||||
// check for empty dict
|
||||
if(!key)
|
||||
return false;
|
||||
// we are expecting the first key to be 'a'
|
||||
if(!(*key == "a"))
|
||||
{
|
||||
llarp::LogWarn("message has no message type");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!bencode_read_string(buffer, &strbuf))
|
||||
{
|
||||
llarp::LogWarn("could not read value of message type");
|
||||
return false;
|
||||
}
|
||||
// bad key size
|
||||
if(strbuf.sz != 1)
|
||||
{
|
||||
llarp::LogWarn("bad mesage type size: ", strbuf.sz);
|
||||
return false;
|
||||
}
|
||||
// create the message to parse based off message type
|
||||
llarp::LogDebug("inbound message ", *strbuf.cur);
|
||||
bool isLIM = false;
|
||||
switch(*strbuf.cur)
|
||||
{
|
||||
case 'i':
|
||||
msg = &holder->i;
|
||||
isLIM = true;
|
||||
break;
|
||||
case 'd':
|
||||
msg = &holder->d;
|
||||
break;
|
||||
case 'u':
|
||||
msg = &holder->u;
|
||||
break;
|
||||
case 'm':
|
||||
msg = &holder->m;
|
||||
break;
|
||||
case 'c':
|
||||
msg = &holder->c;
|
||||
break;
|
||||
case 'x':
|
||||
msg = &holder->x;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isLIM)
|
||||
{
|
||||
metrics::integerTick(msg->Name(), "RX", 1, "id",
|
||||
RouterID(from->GetPubKey()).ToString());
|
||||
}
|
||||
|
||||
msg->session = from;
|
||||
firstkey = false;
|
||||
return true;
|
||||
}
|
||||
// check for last element
|
||||
if(!key)
|
||||
return MessageDone();
|
||||
|
||||
return msg->DecodeKey(*key, buffer);
|
||||
}
|
||||
|
||||
bool
|
||||
InboundMessageParser::MessageDone()
|
||||
{
|
||||
bool result = false;
|
||||
if(msg)
|
||||
{
|
||||
result = msg->HandleMessage(router);
|
||||
}
|
||||
Reset();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
InboundMessageParser::ProcessFrom(ILinkSession* src,
|
||||
const llarp_buffer_t& buf)
|
||||
{
|
||||
if(!src)
|
||||
{
|
||||
llarp::LogWarn("no link session");
|
||||
return false;
|
||||
}
|
||||
|
||||
from = src;
|
||||
firstkey = true;
|
||||
ManagedBuffer copy(buf);
|
||||
return bencode_read_dict(*this, ©.underlying);
|
||||
}
|
||||
|
||||
void
|
||||
InboundMessageParser::Reset()
|
||||
{
|
||||
if(msg)
|
||||
msg->Clear();
|
||||
msg = nullptr;
|
||||
}
|
||||
} // namespace llarp
|
@ -1 +1,58 @@
|
||||
#include <messages/path_confirm.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/bencode.hpp>
|
||||
#include <util/time.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
PathConfirmMessage::PathConfirmMessage(uint64_t lifetime)
|
||||
: pathLifetime(lifetime), pathCreated(time_now_ms())
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* val)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictInt("L", pathLifetime, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("T", pathCreated, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("V", version, read, key, val))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "P"))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("L", pathLifetime, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("T", pathCreated, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("V", version, buf))
|
||||
return false;
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h && h->HandlePathConfirmMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
@ -1 +1,58 @@
|
||||
#include <messages/path_latency.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/bencode.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
PathLatencyMessage::PathLatencyMessage()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
PathLatencyMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* val)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictInt("L", L, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("T", T, read, key, val))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
bool
|
||||
PathLatencyMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "L"))
|
||||
return false;
|
||||
if(L)
|
||||
{
|
||||
if(!BEncodeWriteDictInt("L", L, buf))
|
||||
return false;
|
||||
}
|
||||
if(T)
|
||||
{
|
||||
if(!BEncodeWriteDictInt("T", T, buf))
|
||||
return false;
|
||||
}
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
PathLatencyMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h && h->HandlePathLatencyMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
@ -1 +1,60 @@
|
||||
#include <messages/path_transfer.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/buffer.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
bool
|
||||
PathTransferMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* val)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictEntry("P", P, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictEntry("T", T, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("V", version, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictEntry("Y", Y, read, key, val))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
|
||||
if(!BEncodeWriteDictEntry("T", T, buf))
|
||||
return false;
|
||||
|
||||
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictEntry("Y", Y, buf))
|
||||
return false;
|
||||
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
PathTransferMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h->HandlePathTransferMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
@ -1 +1,65 @@
|
||||
#include <messages/transfer_traffic.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/bencode.hpp>
|
||||
#include <util/endian.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
bool
|
||||
TransferTrafficMessage::PutBuffer(const llarp_buffer_t& buf,
|
||||
uint64_t counter)
|
||||
{
|
||||
if(buf.sz > MaxExitMTU)
|
||||
return false;
|
||||
X.emplace_back(buf.sz + 8);
|
||||
byte_t* ptr = X.back().data();
|
||||
htobe64buf(ptr, counter);
|
||||
ptr += 8;
|
||||
memcpy(ptr, buf.base, buf.sz);
|
||||
// 8 bytes encoding overhead and 8 bytes counter
|
||||
_size += buf.sz + 16;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TransferTrafficMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "I"))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("V", version, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictList("X", X, buf))
|
||||
return false;
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
TransferTrafficMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* buf)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, buf))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("V", version, read, key, buf))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictList("X", X, read, key, buf))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
bool
|
||||
TransferTrafficMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h->HandleTransferTrafficMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
@ -1,68 +0,0 @@
|
||||
#include <messages/dht.hpp>
|
||||
|
||||
#include <router/abstractrouter.hpp>
|
||||
#include <routing/handler.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
DHTMessage::~DHTMessage()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
DHTMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val)
|
||||
{
|
||||
llarp::dht::Key_t from;
|
||||
from.Zero();
|
||||
if(key == "M")
|
||||
{
|
||||
return llarp::dht::DecodeMesssageList(from, val, M, true);
|
||||
}
|
||||
else if(key == "S")
|
||||
{
|
||||
return bencode_read_integer(val, &S);
|
||||
}
|
||||
else if(key == "V")
|
||||
{
|
||||
return bencode_read_integer(val, &V);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
DHTMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "M"))
|
||||
return false;
|
||||
if(!BEncodeWriteDictBEncodeList("M", M, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
|
||||
return false;
|
||||
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
DHTMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const
|
||||
{
|
||||
// set source as us
|
||||
llarp::dht::Key_t us{r->pubkey()};
|
||||
for(const auto& msg : M)
|
||||
{
|
||||
msg->From = us;
|
||||
msg->pathID = from;
|
||||
if(!h->HandleDHTMessage(*msg, r))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
@ -1,62 +0,0 @@
|
||||
#include <messages/path_confirm.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/bencode.hpp>
|
||||
#include <util/time.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
PathConfirmMessage::PathConfirmMessage() : pathLifetime(0), pathCreated(0)
|
||||
{
|
||||
}
|
||||
|
||||
PathConfirmMessage::PathConfirmMessage(uint64_t lifetime)
|
||||
: pathLifetime(lifetime), pathCreated(time_now_ms())
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* val)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictInt("L", pathLifetime, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("T", pathCreated, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("V", version, read, key, val))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::BEncode(llarp_buffer_t* buf) const
|
||||
{
|
||||
if(!bencode_start_dict(buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictMsgType(buf, "A", "P"))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("L", pathLifetime, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("T", pathCreated, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictInt("V", version, buf))
|
||||
return false;
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h && h->HandlePathConfirmMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
@ -1,68 +0,0 @@
|
||||
#include <messages/path_transfer.hpp>
|
||||
|
||||
#include <routing/handler.hpp>
|
||||
#include <util/buffer.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace routing
|
||||
{
|
||||
PathTransferMessage::PathTransferMessage() : IMessage()
|
||||
{
|
||||
}
|
||||
|
||||
PathTransferMessage::~PathTransferMessage()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
PathTransferMessage::DecodeKey(const llarp_buffer_t& key,
|
||||
llarp_buffer_t* val)
|
||||
{
|
||||
bool read = false;
|
||||
if(!BEncodeMaybeReadDictEntry("P", P, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictEntry("T", T, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictInt("V", version, read, key, val))
|
||||
return false;
|
||||
if(!BEncodeMaybeReadDictEntry("Y", Y, read, key, val))
|
||||
return false;
|
||||
return read;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if(!BEncodeWriteDictInt("S", S, buf))
|
||||
return false;
|
||||
|
||||
if(!BEncodeWriteDictEntry("T", T, buf))
|
||||
return false;
|
||||
|
||||
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
|
||||
return false;
|
||||
if(!BEncodeWriteDictEntry("Y", Y, buf))
|
||||
return false;
|
||||
|
||||
return bencode_end(buf);
|
||||
}
|
||||
|
||||
bool
|
||||
PathTransferMessage::HandleMessage(IMessageHandler* h,
|
||||
AbstractRouter* r) const
|
||||
{
|
||||
return h->HandlePathTransferMessage(*this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
Loading…
Reference in New Issue