lokinet/llarp/ip.cpp
Jeff Becker 1a1f93c171
* more tun stuff
* use std::unique_ptr where bare pointers aren't absolutely required
2018-08-17 15:49:58 -04:00

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