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