libtins  4.4
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Tins::ICMPExtensionsStructure Class Reference

Class that represents an ICMP extensions structure. More...

#include <icmp_extension.h>

Public Types

typedef ICMPExtension::serialization_type serialization_type
 
typedef std::vector< ICMPExtensionextensions_type
 

Public Member Functions

 ICMPExtensionsStructure ()
 Default constructor. More...
 
 ICMPExtensionsStructure (const uint8_t *buffer, uint32_t total_sz)
 Constructor from a buffer. More...
 
void version (small_uint< 4 > value)
 Setter for the version field. More...
 
void reserved (small_uint< 12 > value)
 Setter for the reserved field. More...
 
small_uint< 4 > version () const
 Getter for the version field. More...
 
small_uint< 12 > reserved () const
 Getter for the reserved field. More...
 
uint16_t checksum () const
 Getter for the checksum field. More...
 
const extensions_typeextensions () const
 Getter for the extensions stored by this structure. More...
 
void add_extension (const ICMPExtension &extension)
 Adds an extension to this structure. More...
 
void add_extension (MPLS &mpls)
 Adds an MPLS extension to this structure. More...
 
uint32_t size () const
 Gets the size of this ICMP extensions structure. More...
 
void serialize (uint8_t *buffer, uint32_t buffer_size)
 Serializes this extension structure into a buffer. More...
 
serialization_type serialize ()
 Serializes this extension structure. More...
 

Static Public Member Functions

static bool validate_extensions (const uint8_t *buffer, uint32_t total_sz)
 Validates if the given input contains a valid extension structure. More...
 

Static Public Attributes

static const uint32_t MINIMUM_ICMP_PAYLOAD = 128
 

Detailed Description

Class that represents an ICMP extensions structure.

Member Typedef Documentation

◆ extensions_type

The type used to store the list of ICMP extensions in this structure

◆ serialization_type

The type that will be returned when serializing an extensions structure object

Constructor & Destructor Documentation

◆ ICMPExtensionsStructure() [1/2]

Tins::ICMPExtensionsStructure::ICMPExtensionsStructure ( )

Default constructor.

This sets the version to 2, as specified in RFC 4884

◆ ICMPExtensionsStructure() [2/2]

Tins::ICMPExtensionsStructure::ICMPExtensionsStructure ( const uint8_t *  buffer,
uint32_t  total_sz 
)

Constructor from a buffer.

This constructor will find, parse and store the extension stack in the buffer.

Member Function Documentation

◆ add_extension() [1/2]

void Tins::ICMPExtensionsStructure::add_extension ( const ICMPExtension extension)

Adds an extension to this structure.

Parameters
extensionThe extension to be added

◆ add_extension() [2/2]

void Tins::ICMPExtensionsStructure::add_extension ( MPLS mpls)

Adds an MPLS extension to this structure.

This will construct an extension using the provided MPLS packet as its payload. The class and type fields will be set appropriately.

Parameters
extensionThe MPLS payload to be used for the new extension

◆ checksum()

uint16_t Tins::ICMPExtensionsStructure::checksum ( ) const
inline

Getter for the checksum field.

Returns
The checksum field value

◆ extensions()

const extensions_type& Tins::ICMPExtensionsStructure::extensions ( ) const
inline

Getter for the extensions stored by this structure.

Returns
The extensions stored in this structure

◆ reserved() [1/2]

small_uint<12> Tins::ICMPExtensionsStructure::reserved ( ) const
inline

Getter for the reserved field.

Returns
The reserved field value

◆ reserved() [2/2]

void Tins::ICMPExtensionsStructure::reserved ( small_uint< 12 >  value)

Setter for the reserved field.

Parameters
valueThe new reserved field value

◆ serialize() [1/2]

ICMPExtensionsStructure::serialization_type Tins::ICMPExtensionsStructure::serialize ( )

Serializes this extension structure.

Returns
The serialized extension structure

◆ serialize() [2/2]

void Tins::ICMPExtensionsStructure::serialize ( uint8_t *  buffer,
uint32_t  buffer_size 
)

Serializes this extension structure into a buffer.

Parameters
bufferThe output buffer in which to store the serialization
buffer_sizeThe size of the output buffer

◆ size()

uint32_t Tins::ICMPExtensionsStructure::size ( ) const

Gets the size of this ICMP extensions structure.

Returns
The size of this structure

◆ validate_extensions()

bool Tins::ICMPExtensionsStructure::validate_extensions ( const uint8_t *  buffer,
uint32_t  total_sz 
)
static

Validates if the given input contains a valid extension structure.

The validation is performed by calculating the checksum of the input and comparing to the checksum value in the input buffer.

Parameters
bufferThe input buffer
total_szThe size of the input buffer
Returns
true iff the buffer contains a valid ICMP extensions structure

◆ version() [1/2]

small_uint<4> Tins::ICMPExtensionsStructure::version ( ) const
inline

Getter for the version field.

Returns
The version field value

◆ version() [2/2]

void Tins::ICMPExtensionsStructure::version ( small_uint< 4 >  value)

Setter for the version field.

Parameters
valueThe new version field value

Member Data Documentation

◆ MINIMUM_ICMP_PAYLOAD

const uint32_t Tins::ICMPExtensionsStructure::MINIMUM_ICMP_PAYLOAD = 128
static

The minimum ICMP payload size that has to be present when the PDU contains extensions.


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