llarp::net::IPPacket
an Packet
#include <ip_packet.hpp>
Public Classes
| Name | |
|---|---|
| struct | CompareOrder |
| struct | CompareSize |
Public Functions
| Name | |
|---|---|
| IPPacket() | |
| IPPacket(size_t sz) create an ip packet buffer of all zeros of size sz |
|
| IPPacket(byte_view_t ) create an ip packet from a view |
|
| IPPacket(std::vector< byte_t > && ) create an ip packet from a vector we then own |
|
| ~IPPacket() =default | |
| bool | Load(const llarp_buffer_t & buf) |
| llarp_buffer_t | ConstBuffer() const |
| std::vector< byte_t > | steal() steal the underlying vector |
| void | truncate(size_t sz) resize underlying buffer. |
| byte_t * | data() |
| const byte_t * | data() const |
| constexpr size_t | capacity() const |
| size_t | size() const |
| bool | empty() const |
| byte_view_t | view() const |
| size_t | payload_offset() const |
| const byte_t & | icmp_type() const |
| const byte_t & | icmp_code() const |
| byte_t & | icmp_type() |
| byte_t & | icmp_code() |
| const uint16_t & | icmp_checksum() const |
| uint16_t * | icmp_checksum() |
| ip_header * | Header() |
| const ip_header * | Header() const |
| ipv6_header * | HeaderV6() |
| const ipv6_header * | HeaderV6() const |
| int | Version() const |
| byte_t | protocol() const |
| bool | IsV4() const |
| bool | IsV6() const |
| service::ProtocolType | ServiceProtocol() const |
| int | AF() const |
| net::ipv6addr_t | srcv6() const |
| net::ipv6addr_t | dstv6() const |
| net::ipv4addr_t | srcv4() const |
| net::ipv4addr_t | dstv4() const |
| net::ipv6addr_t | src4to6() const |
| net::ipv6addr_t | dst4to6() const |
| net::ipv6addr_t | src4to6Lan() const |
| net::ipv6addr_t | dst4to6Lan() const |
| net::ipaddr_t | srcaddr() const |
| net::ipaddr_t | dstaddr() const |
| SockAddr | src() const |
| SockAddr | dst() const |
| std::optional< nuint16_t > | DstPort() const get destination port if applicable |
| std::optional< nuint16_t > | SrcPort() const get source port if applicable |
| std::optional< std::pair< const char *, size_t > > | L4Data() const get pointer and size of layer 4 data |
| std::optional< OwnedBuffer > | L4OwnedBuffer() const |
| void | UpdateIPv4Address(nuint32_t src, nuint32_t dst) |
| void | UpdateIPv6Address(net::ipv6addr_t src, net::ipv6addr_t dst, std::optional< net::flowlabel_t > flowlabel =std::nullopt) |
| void | ZeroAddresses(std::optional< net::flowlabel_t > flowlabel =std::nullopt) set addresses to zero and recacluate checksums |
| void | ZeroSourceAddress(std::optional< net::flowlabel_t > flowlabel =std::nullopt) zero out source address |
| std::optional< IPPacket > | MakeICMPUnreachable() const make an icmp unreachable reply packet based of this ip packet |
| IPPacket | UDP(nuint32_t srcaddr, nuint16_t srcport, nuint32_t dstaddr, nuint16_t dstport, const llarp_buffer_t & data) |
| IPPacket | make_udp(net::ipaddr_t srcaddr, net::port_t srcport, net::ipaddr_t dstaddr, net::port_t dstport, std::vector< byte_t > udp_body) |
| IPPacket | make_udp(SockAddr src, SockAddr dst, std::variant< OwnedBuffer, std::vector< byte_t > > udp_body) |
| IPPacket | make_icmp_reply(const net::IPPacket & pkt) |
Public Attributes
| Name | |
|---|---|
| constexpr size_t | _max_size |
| constexpr size_t | MaxSize |
| constexpr size_t | MinSize |
| llarp_time_t | timestamp |
| std::vector< byte_t > | _buf |
| std::function< void(net::IPPacket)> | reply |
Public Functions Documentation
function IPPacket
inline IPPacket()
function IPPacket
explicit IPPacket(
size_t sz
)
create an ip packet buffer of all zeros of size sz
function IPPacket
explicit IPPacket(
byte_view_t
)
create an ip packet from a view
function IPPacket
IPPacket(
std::vector< byte_t > &&
)
create an ip packet from a vector we then own
function ~IPPacket
~IPPacket() =default
function Load
inline bool Load(
const llarp_buffer_t & buf
)
function ConstBuffer
inline llarp_buffer_t ConstBuffer() const
function steal
inline std::vector< byte_t > steal()
steal the underlying vector
function truncate
inline void truncate(
size_t sz
)
resize underlying buffer.
function data
inline byte_t * data()
function data
inline const byte_t * data() const
function capacity
inline constexpr size_t capacity() const
function size
inline size_t size() const
function empty
inline bool empty() const
function view
byte_view_t view() const
function payload_offset
inline size_t payload_offset() const
function icmp_type
inline const byte_t & icmp_type() const
function icmp_code
inline const byte_t & icmp_code() const
function icmp_type
inline byte_t & icmp_type()
function icmp_code
inline byte_t & icmp_code()
function icmp_checksum
inline const uint16_t & icmp_checksum() const
function icmp_checksum
inline uint16_t * icmp_checksum()
function Header
inline ip_header * Header()
function Header
inline const ip_header * Header() const
function HeaderV6
inline ipv6_header * HeaderV6()
function HeaderV6
inline const ipv6_header * HeaderV6() const
function Version
inline int Version() const
function protocol
inline byte_t protocol() const
function IsV4
inline bool IsV4() const
function IsV6
inline bool IsV6() const
function ServiceProtocol
inline service::ProtocolType ServiceProtocol() const
function AF
inline int AF() const
function srcv6
net::ipv6addr_t srcv6() const
function dstv6
net::ipv6addr_t dstv6() const
function srcv4
net::ipv4addr_t srcv4() const
function dstv4
net::ipv4addr_t dstv4() const
function src4to6
net::ipv6addr_t src4to6() const
function dst4to6
net::ipv6addr_t dst4to6() const
function src4to6Lan
net::ipv6addr_t src4to6Lan() const
function dst4to6Lan
net::ipv6addr_t dst4to6Lan() const
function srcaddr
inline net::ipaddr_t srcaddr() const
function dstaddr
inline net::ipaddr_t dstaddr() const
function src
SockAddr src() const
function dst
SockAddr dst() const
function DstPort
std::optional< nuint16_t > DstPort() const
get destination port if applicable
function SrcPort
std::optional< nuint16_t > SrcPort() const
get source port if applicable
function L4Data
std::optional< std::pair< const char *, size_t > > L4Data() const
get pointer and size of layer 4 data
function L4OwnedBuffer
inline std::optional< OwnedBuffer > L4OwnedBuffer() const
function UpdateIPv4Address
void UpdateIPv4Address(
nuint32_t src,
nuint32_t dst
)
function UpdateIPv6Address
void UpdateIPv6Address(
net::ipv6addr_t src,
net::ipv6addr_t dst,
std::optional< net::flowlabel_t > flowlabel =std::nullopt
)
function ZeroAddresses
void ZeroAddresses(
std::optional< net::flowlabel_t > flowlabel =std::nullopt
)
set addresses to zero and recacluate checksums
function ZeroSourceAddress
void ZeroSourceAddress(
std::optional< net::flowlabel_t > flowlabel =std::nullopt
)
zero out source address
function MakeICMPUnreachable
std::optional< IPPacket > MakeICMPUnreachable() const
make an icmp unreachable reply packet based of this ip packet
function UDP
static inline IPPacket UDP(
nuint32_t srcaddr,
nuint16_t srcport,
nuint32_t dstaddr,
nuint16_t dstport,
const llarp_buffer_t & data
)
function make_udp
static IPPacket make_udp(
net::ipaddr_t srcaddr,
net::port_t srcport,
net::ipaddr_t dstaddr,
net::port_t dstport,
std::vector< byte_t > udp_body
)
function make_udp
static inline IPPacket make_udp(
SockAddr src,
SockAddr dst,
std::variant< OwnedBuffer, std::vector< byte_t > > udp_body
)
function make_icmp_reply
static IPPacket make_icmp_reply(
const net::IPPacket & pkt
)
Public Attributes Documentation
variable _max_size
static constexpr size_t _max_size = 1500;
variable MaxSize
static constexpr size_t MaxSize = _max_size;
variable MinSize
static constexpr size_t MinSize = 20;
variable timestamp
llarp_time_t timestamp;
variable _buf
std::vector< byte_t > _buf;
variable reply
std::function< void(net::IPPacket)> reply;
Updated on 2026-01-10 at 22:49:45 +0000