|
SatCat5
|
Structure for holding an IPv4 Header, including options.
For creating new headers, see ip::Dispatch::next_header(...)
#include <ip_core.h>
Public Member Functions | |
| Header (const Header &t)=default | |
| Header & | operator= (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. | |
| 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.
| void Header::option_alert | ( | ) |
| 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,
Definition at line 115 of file ip_core.cc.
| 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.
Definition at line 127 of file ip_core.cc.
| 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.