mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-03 23:15:52 +00:00
19 lines
421 B
C++
19 lines
421 B
C++
|
#include <llarp/endian.h>
|
||
|
#include <llarp/ip.hpp>
|
||
|
|
||
|
namespace llarp
|
||
|
{
|
||
|
namespace net
|
||
|
{
|
||
|
std::unique_ptr< IPv4Packet >
|
||
|
ParseIPv4Packet(const void* buf, size_t sz)
|
||
|
{
|
||
|
if(sz < 16 || sz > IPv4Packet::MaxSize)
|
||
|
return nullptr;
|
||
|
IPv4Packet* pkt = new IPv4Packet();
|
||
|
memcpy(pkt->buf, buf, sz);
|
||
|
return std::unique_ptr< IPv4Packet >(pkt);
|
||
|
}
|
||
|
} // namespace net
|
||
|
} // namespace llarp
|