#include <Packet.h>
Public Types | |
typedef u_char | Data |
Unit of packet data (1 byte). | |
typedef struct pcap_pkthdr | Header |
Header of a packet. | |
typedef bpf_u_int32 | Length |
Length of a packet (number of bytes). | |
Public Member Functions | |
Length | get_capture_length () const |
Gets the capture length. | |
Data const * | get_data () const |
Gets a pointer to the data (payload) of the Packet. | |
Header const & | get_header () const |
Gets the Header of the Packet. | |
Length | get_length () const |
Gets the length of the packet. | |
long | get_miliseconds () const |
Gets the time when the packet was captured, in miliseconds. | |
long | get_seconds () const |
Gets the time when the packet was captured, in seconds. | |
void | manage () |
Let the user manage the memory occupied by the payload of the Packet. | |
Packet & | operator= (Packet const &packet) |
Assign another Packet object's contents to this one. | |
Packet (Header const &header, Data const *data) | |
Creates a Packet giving its Header and Data. | |
Packet (Packet const &packet) | |
Creates a Packet object as a copy from another. | |
Packet (Data const *data, Length length) | |
Creates a packet from raw data. | |
Packet () | |
Creates an empty Packet. | |
virtual | ~Packet () |
Destroys a Packet object. |
typedef u_char pcappp::Packet::Data |
Unit of packet data (1 byte).
typedef struct pcap_pkthdr pcappp::Packet::Header [read] |
Header of a packet.
typedef bpf_u_int32 pcappp::Packet::Length |
Length of a packet (number of bytes).
pcappp::Packet::Packet | ( | ) |
Creates an empty Packet.
Creates a packet from raw data.
data | A pointer to the packet data | |
length | The length of the packet data (in bytes) |
pcappp::Packet::Packet | ( | Packet const & | packet | ) | [inline] |
Creates a Packet object as a copy from another.
pcappp::Packet::~Packet | ( | ) | [virtual] |
Destroys a Packet object.
Length pcappp::Packet::get_capture_length | ( | ) | const [inline] |
Gets the capture length.
Data const* pcappp::Packet::get_data | ( | ) | const [inline] |
Length pcappp::Packet::get_length | ( | ) | const [inline] |
Gets the length of the packet.
long pcappp::Packet::get_miliseconds | ( | ) | const [inline] |
Gets the time when the packet was captured, in miliseconds.
long pcappp::Packet::get_seconds | ( | ) | const [inline] |
Gets the time when the packet was captured, in seconds.
void pcappp::Packet::manage | ( | ) |
Let the user manage the memory occupied by the payload of the Packet.
By default the packet data (as returned by get_data()), is owned by libpcap. This means that that data is not persistent among successive calls of a Pcap::Handler.
To overcome this limitation one can create a Packet as a copy of the incoming packet, and call manage() on it.
All the memory allocated by manage() is released when the Packet is destroyed
Assign another Packet object's contents to this one.