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"

Public Member Functions | |
| ~Pkt (void) | |
| Destructor. More... | |
| Pkt (Pkt &&rhs) | |
| Move constructor. More... | |
| Pkt & | operator= (Pkt &&rhs) |
| Move operator. More... | |
| Pkt (const size_t requested_capacity=2 *KiB) | |
| Normal default constructor. More... | |
| Pkt & | reallocate (void) |
| Assume the raw pointer has been handed off to someone else, and allocate a new one to use. More... | |
| Pkt & | set_len (const size_t new_len) |
| Set the number of bytes that were read (aka length of packet) and re-initialize info. More... | |
| 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. More... | |
| Pkt & | clear (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... | |
| Pkt & | operator= (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... | |
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.
| Myra::Pkt::~Pkt | ( | void | ) |
Destructor.
|
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.

| Myra::Pkt::Pkt | ( | const size_t | requested_capacity = 2 * KiB | ) |
Normal default constructor.

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

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

| Myra::Pkt & Myra::Pkt::clear | ( | void | ) |
|
inline |
Get read-write access to the raw buffer.
Prevent copies so the raw pointer isn't shared between multiple objects.

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.

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


| 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.


| 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