Myra Canyon  v0.0.1-768
network control
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Myra::Pkt Class Referencefinal

The Pkt class contains both the raw storage for all the bytes in the packet, as well as the information/analysis on the packet. More...

#include "Pkt.hpp"

Collaboration diagram for Myra::Pkt:

Public Member Functions

 ~Pkt (void)
 Destructor. More...
 
 Pkt (Pkt &&rhs)
 Move constructor. More...
 
Pktoperator= (Pkt &&rhs)
 Move operator. More...
 
 Pkt (const size_t requested_capacity=2 *KiB)
 Normal default constructor. More...
 
Pktreallocate (void)
 Assume the raw pointer has been handed off to someone else, and allocate a new one to use. More...
 
Pktset_len (const size_t new_len)
 Set the number of bytes that were read (aka length of packet) and re-initialize info. More...
 
Pktset_len_and_offset (const std::size_t new_len, const std::size_t new_offset)
 Same as set_len() but also sets an offset into the raw buffer. More...
 
Pktclear (void)
 Keep the existing raw buffer allocation, but clear len and info so the Pkt can be re-used. More...
 
boost::asio::mutable_buffers_1 asio_mutable_buffer (void)
 Convert the raw buffer into something we can easily use when using boost::asio to read. More...
 
boost::asio::const_buffers_1 asio_const_buffer (void) const
 Convert the raw buffer into something we can easily use when using boost::asio to write. More...
 
uint8_t * data (void)
 Get read-write access to the raw buffer. More...
 
 Pkt (const Pkt &rhs)=delete
 Prevent copies so the raw pointer isn't shared between multiple objects. More...
 
Pktoperator= (const Pkt &rhs)=delete
 Prevent copies so the raw pointer isn't shared between multiple objects. More...
 

Public Attributes

uint8_t * raw
 pointer to raw bytes More...
 
std::size_t capacity
 length of raw buffer More...
 
std::size_t len
 number of bytes in raw that have been initialized More...
 
std::size_t offset
 offset into the buffer (skip raw bytes) More...
 
PktInfo info
 packet analysis, including pointers to various headers More...
 

Detailed Description

The Pkt class contains both the raw storage for all the bytes in the packet, as well as the information/analysis on the packet.

Objects of this class can easily be passed to ASIO for reading and writing.

Constructor & Destructor Documentation

Myra::Pkt::~Pkt ( void  )

Destructor.

Myra::Pkt::Pkt ( const Pkt rhs)
delete

Prevent copies so the raw pointer isn't shared between multiple objects.

Myra::Pkt::Pkt ( Myra::Pkt &&  rhs)

Move constructor.

Implemented in terms of move assignment, which in this case does a swap. This ensures that raw isn't shared between objects.

Here is the call graph for this function:

Myra::Pkt::Pkt ( const size_t  requested_capacity = 2 * KiB)

Normal default constructor.

Todo:
the maximum packet capacity size may need to be revised once we take jumbo frames into consideration

Here is the call graph for this function:

Member Function Documentation

boost::asio::const_buffers_1 Myra::Pkt::asio_const_buffer ( void  ) const
inline

Convert the raw buffer into something we can easily use when using boost::asio to write.

Here is the caller graph for this function:

boost::asio::mutable_buffers_1 Myra::Pkt::asio_mutable_buffer ( void  )
inline

Convert the raw buffer into something we can easily use when using boost::asio to read.

Here is the caller graph for this function:

Myra::Pkt & Myra::Pkt::clear ( void  )

Keep the existing raw buffer allocation, but clear len and info so the Pkt can be re-used.

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t* Myra::Pkt::data ( void  )
inline

Get read-write access to the raw buffer.

Pkt& Myra::Pkt::operator= ( const Pkt rhs)
delete

Prevent copies so the raw pointer isn't shared between multiple objects.

Here is the caller graph for this function:

Myra::Pkt & Myra::Pkt::operator= ( Myra::Pkt &&  rhs)

Move operator.

Swap the contents of rhs into this object.

Myra::Pkt & Myra::Pkt::reallocate ( void  )

Assume the raw pointer has been handed off to someone else, and allocate a new one to use.

Here is the caller graph for this function:

Pkt& Myra::Pkt::set_len ( const size_t  new_len)
inline

Set the number of bytes that were read (aka length of packet) and re-initialize info.

Here is the call graph for this function:

Here is the caller graph for this function:

Myra::Pkt & Myra::Pkt::set_len_and_offset ( const std::size_t  new_len,
const std::size_t  new_offset 
)

Same as set_len() but also sets an offset into the raw buffer.

This allows for some additional bytes to precede the ethernet header, such as when reading from netfilter queues.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::size_t Myra::Pkt::capacity

length of raw buffer

PktInfo Myra::Pkt::info

packet analysis, including pointers to various headers

std::size_t Myra::Pkt::len

number of bytes in raw that have been initialized

std::size_t Myra::Pkt::offset

offset into the buffer (skip raw bytes)

uint8_t* Myra::Pkt::raw

pointer to raw bytes


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