SatCat5
satcat5::ip::Header Struct Reference

Detailed Description

Structure for holding an IPv4 Header, including options.

For creating new headers, see ip::Dispatch::next_header(...)

Definition at line 180 of file ip_core.h.

#include <ip_core.h>

Public Member Functions

 Header (const Header &t)=default
 
Headeroperator= (const Header &t)=default
 
constexpr unsigned ver () const
 < Header version (i.e., "4")
 
constexpr unsigned ihl () const
 < Header length (4-byte words)
 
constexpr unsigned len_total () const
 < Total bytes including header
 
constexpr u16 id () const
 < Identifier / sequence number
 
constexpr u16 frg () const
 < Fragment offset
 
constexpr unsigned len_inner () const
 < Inner bytes excluding header
 
constexpr u8 ttl () const
 < Time to Live (TTL)
 
constexpr u8 proto () const
 < Inner protocol (UDP/TCP/etc.)
 
constexpr u16 chk () const
 < Checksum (incoming only)
 
constexpr satcat5::ip::Addr src () const
 < Source address
 
constexpr satcat5::ip::Addr dst () const
 < Destination address
 
void chk_incr16 (u16 prev, u16 next)
 Incremental update to checksum when replacing a given field. More...
 
void chk_incr32 (u32 prev, u32 next)
 
void option_alert ()
 } More...
 
void write_to (satcat5::io::Writeable *wr) const
 Write IPv4 header to the designated stream. More...
 
bool read_core (satcat5::io::Readable *rd)
 Read a partial IPv4 header from the designated stream. More...
 
bool read_from (satcat5::io::Readable *rd)
 Read an entire IPv4 header from the designated stream. More...
 

Public Attributes

u16 data [HDR_MAX_SHORTS]
 Raw access to the underlying header contents.
 

Member Function Documentation

◆ chk_incr16()

void Header::chk_incr16 ( u16  prev,
u16  next 
)

Incremental update to checksum when replacing a given field.

Given a before/after change to any field in this IPv4 header, update the header checksum by applying the method of IETF RFC1624 Section 3, i.e., "HC' = ~(~HC + ~m + m')". Variants are provided for changing 16-bit and 32-bit fields. {

Definition at line 94 of file ip_core.cc.

◆ option_alert()

void Header::option_alert ( )

}

Append the "router alert" option (RFC-2113)

Definition at line 106 of file ip_core.cc.

◆ read_core()

bool Header::read_core ( satcat5::io::Readable rd)

Read a partial IPv4 header from the designated stream.

This method reads the first 20 bytes of an IPv4 header, which contains basic header fields but not variable-length options (i.e., IHL > 5). This is used in cases where the full header is unavailable or unnecessary (e.g., due to "peek" limits). To read options and validate the header checksum,

See also
read_from.
Returns
True if the partial header is valid, false otherwise.

Definition at line 115 of file ip_core.cc.

◆ read_from()

bool Header::read_from ( satcat5::io::Readable rd)

Read an entire IPv4 header from the designated stream.

This method calls read_core, then reads variable-length header options and validates the IPv4 header checksum.

Returns
True if header and checksum are valid, false otherwise.

Definition at line 127 of file ip_core.cc.

◆ write_to()

void Header::write_to ( satcat5::io::Writeable wr) const

Write IPv4 header to the designated stream.

If the checksum has not already been calculated, update in-place.

Definition at line 82 of file ip_core.cc.


The documentation for this struct was generated from the following files: