pcappp::Packet Class Reference

#include <Packet.h>

List of all members.

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.
Packetoperator= (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.


Member Typedef Documentation

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


Constructor & Destructor Documentation

pcappp::Packet::Packet (  ) 

Creates an empty Packet.

pcappp::Packet::Packet ( Data const *  data,
Length  length 
)

Creates a packet from raw data.

Parameters:
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 ( Header const &  header,
Data const *  data 
) [inline]

Creates a Packet giving its Header and Data.

Parameters:
header The Header of the Packet
data A pointer to the Packet Data

pcappp::Packet::~Packet (  )  [virtual]

Destroys a Packet object.


Member Function Documentation

Length pcappp::Packet::get_capture_length (  )  const [inline]

Gets the capture length.

Returns:
The number of bytes of the packet that are available from the capture

Data const* pcappp::Packet::get_data (  )  const [inline]

Gets a pointer to the data (payload) of the Packet.

Note that unless the Packet is managed by the user (by calling manage()), the Data pointer is owned by libpcap

Header const& pcappp::Packet::get_header (  )  const [inline]

Gets the Header of the Packet.

Length pcappp::Packet::get_length (  )  const [inline]

Gets the length of the packet.

Returns:
The length of the packet, in bytes, which might be more than the number of bytes available from the capture (given by get_capture_length()), if the length of the packet is larger than the maximum number of bytes to capture.

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

Packet& pcappp::Packet::operator= ( Packet const &  packet  )  [inline]

Assign another Packet object's contents to this one.


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

Generated on Tue Apr 15 17:36:29 2008 for libpcap++ by  doxygen 1.5.5