Representation of the IPv4 header. More...

#include <headers.hpp>

Public Member Functions

uint8_t version () const
 
uint8_t ihl () const
 
void setVersion ()
 Set the version field to 4. More...
 
void setIHL (uint8_t len)
 Sets the IP header length. More...
 
void setPayloadLength (uint16_t len)
 Set the length of the L3-SDU. More...
 
uint16_t getPayloadLength () const
 Get the length of the L3-SDU. More...
 
uint16_t fragmentation () const
 
uint16_t flags () const
 
void setProtoICMP ()
 Set the protocol to ICMP. More...
 
void setProtoTCP ()
 Set the protocol to TCP. More...
 
void setProtoUDP ()
 Set the protocol to UDP. More...
 
void setSrcIP (uint32_t ip)
 Set the source ip. More...
 
void setDstIP (uint32_t ip)
 Set the destination ip. More...
 
uint32_t getSrcIP () const
 Get the source IP. More...
 
uint32_t getDstIP () const
 Get the destination IP. More...
 
void * getPayload ()
 Get the SDU. More...
 
std::string getSrcAddr ()
 
std::string getDstAddr ()
 
void setLength (uint16_t len)
 
uint16_t getLength ()
 
void calcChecksum ()
 Fill out the header checksum for this packet. More...
 

Static Public Member Functions

static std::string addrToStr (uint32_t addr)
 

Public Attributes

uint8_t version_ihl
 Version and IHL. More...
 
uint8_t tos
 Type of Service. More...
 
uint16_t total_length
 L3-PDU length. More...
 
uint16_t id
 Identification. More...
 
uint16_t flags_fragmentation
 flags and fragmentation offset More...
 
uint8_t ttl
 Time to live. More...
 
uint8_t proto
 next protocol More...
 
uint16_t checksum
 header checksum More...
 
uint32_t srcIP
 source IPv4 address More...
 
uint32_t dstIP
 destination IPv4 address More...
 

Static Public Attributes

static constexpr uint8_t PROTO_ICMP = 1
 
static constexpr uint8_t PROTO_TCP = 6
 
static constexpr uint8_t PROTO_UDP = 17
 

Detailed Description

Representation of the IPv4 header.

Definition at line 65 of file headers.hpp.

Member Function Documentation

◆ addrToStr()

static std::string Headers::IPv4::addrToStr ( uint32_t  addr)
inlinestatic

Definition at line 153 of file headers.hpp.

◆ calcChecksum()

void Headers::IPv4::calcChecksum ( )
inline

Fill out the header checksum for this packet.

Definition at line 169 of file headers.hpp.

Here is the call graph for this function:

◆ flags()

uint16_t Headers::IPv4::flags ( ) const
inline

Definition at line 104 of file headers.hpp.

◆ fragmentation()

uint16_t Headers::IPv4::fragmentation ( ) const
inline

Definition at line 103 of file headers.hpp.

◆ getDstAddr()

std::string Headers::IPv4::getDstAddr ( )
inline

Definition at line 162 of file headers.hpp.

Here is the call graph for this function:

◆ getDstIP()

uint32_t Headers::IPv4::getDstIP ( ) const
inline

Get the destination IP.

Returns
Destination IP in host byte order

Definition at line 144 of file headers.hpp.

◆ getLength()

uint16_t Headers::IPv4::getLength ( )
inline

Definition at line 166 of file headers.hpp.

◆ getPayload()

void* Headers::IPv4::getPayload ( )
inline

Get the SDU.

Returns
Pointer to the payload

Definition at line 149 of file headers.hpp.

Here is the call graph for this function:

◆ getPayloadLength()

uint16_t Headers::IPv4::getPayloadLength ( ) const
inline

Get the length of the L3-SDU.

Returns
The length of the payload (host byte order)

Definition at line 98 of file headers.hpp.

Here is the call graph for this function:

◆ getSrcAddr()

std::string Headers::IPv4::getSrcAddr ( )
inline

Definition at line 160 of file headers.hpp.

Here is the call graph for this function:

◆ getSrcIP()

uint32_t Headers::IPv4::getSrcIP ( ) const
inline

Get the source IP.

Returns
Source IP in host byte order

Definition at line 139 of file headers.hpp.

◆ ihl()

uint8_t Headers::IPv4::ihl ( ) const
inline

Definition at line 69 of file headers.hpp.

◆ setDstIP()

void Headers::IPv4::setDstIP ( uint32_t  ip)
inline

Set the destination ip.

Parameters
ipDestination IP in host byte order

Definition at line 134 of file headers.hpp.

◆ setIHL()

void Headers::IPv4::setIHL ( uint8_t  len)
inline

Sets the IP header length.

Parameters
lenlength as it will appear in the header

Definition at line 81 of file headers.hpp.

◆ setLength()

void Headers::IPv4::setLength ( uint16_t  len)
inline

Definition at line 164 of file headers.hpp.

◆ setPayloadLength()

void Headers::IPv4::setPayloadLength ( uint16_t  len)
inline

Set the length of the L3-SDU.

Parameters
lenof the L3-SDU (IP payload length)

Definition at line 93 of file headers.hpp.

Here is the call graph for this function:

◆ setProtoICMP()

void Headers::IPv4::setProtoICMP ( )
inline

Set the protocol to ICMP.

Definition at line 114 of file headers.hpp.

◆ setProtoTCP()

void Headers::IPv4::setProtoTCP ( )
inline

Set the protocol to TCP.

Definition at line 117 of file headers.hpp.

◆ setProtoUDP()

void Headers::IPv4::setProtoUDP ( )
inline

Set the protocol to UDP.

Definition at line 120 of file headers.hpp.

◆ setSrcIP()

void Headers::IPv4::setSrcIP ( uint32_t  ip)
inline

Set the source ip.

Parameters
ipSource IP in host byte order

Definition at line 129 of file headers.hpp.

◆ setVersion()

void Headers::IPv4::setVersion ( )
inline

Set the version field to 4.

Definition at line 73 of file headers.hpp.

◆ version()

uint8_t Headers::IPv4::version ( ) const
inline

Definition at line 68 of file headers.hpp.

Member Data Documentation

◆ checksum

uint16_t Headers::IPv4::checksum

header checksum

Definition at line 122 of file headers.hpp.

◆ dstIP

uint32_t Headers::IPv4::dstIP

destination IPv4 address

Definition at line 124 of file headers.hpp.

◆ flags_fragmentation

uint16_t Headers::IPv4::flags_fragmentation

flags and fragmentation offset

Definition at line 101 of file headers.hpp.

◆ id

uint16_t Headers::IPv4::id

Identification.

Definition at line 100 of file headers.hpp.

◆ proto

uint8_t Headers::IPv4::proto

next protocol

Definition at line 107 of file headers.hpp.

◆ PROTO_ICMP

constexpr uint8_t Headers::IPv4::PROTO_ICMP = 1
static

Definition at line 109 of file headers.hpp.

◆ PROTO_TCP

constexpr uint8_t Headers::IPv4::PROTO_TCP = 6
static

Definition at line 110 of file headers.hpp.

◆ PROTO_UDP

constexpr uint8_t Headers::IPv4::PROTO_UDP = 17
static

Definition at line 111 of file headers.hpp.

◆ srcIP

uint32_t Headers::IPv4::srcIP

source IPv4 address

Definition at line 123 of file headers.hpp.

◆ tos

uint8_t Headers::IPv4::tos

Type of Service.

Definition at line 87 of file headers.hpp.

◆ total_length

uint16_t Headers::IPv4::total_length

L3-PDU length.

Definition at line 88 of file headers.hpp.

◆ ttl

uint8_t Headers::IPv4::ttl

Time to live.

Definition at line 106 of file headers.hpp.

◆ version_ihl

uint8_t Headers::IPv4::version_ihl

Version and IHL.

Definition at line 66 of file headers.hpp.


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