lokinet/llarp/utp/inbound_message.cpp

28 lines
498 B
C++
Raw Normal View History

2019-03-29 14:23:19 +00:00
#include <utp/inbound_message.hpp>
2019-03-29 14:03:07 +00:00
#include <cstring>
2019-03-29 14:03:07 +00:00
namespace llarp
{
namespace utp
{
bool
InboundMessage::IsExpired(llarp_time_t now) const
2019-03-29 14:03:07 +00:00
{
return now > lastActive && now - lastActive >= 2000;
}
bool
InboundMessage::AppendData(const byte_t* ptr, uint16_t sz)
2019-03-29 14:03:07 +00:00
{
if(buffer.size_left() < sz)
return false;
std::copy_n(ptr, sz, buffer.cur);
2019-03-29 14:03:07 +00:00
buffer.cur += sz;
return true;
}
2019-03-29 14:03:07 +00:00
} // namespace utp
} // namespace llarp