pcapxx::descriptor< Bottom > Struct Template Reference

#include <wipal/pcap/descriptor.hh>

Inheritance diagram for pcapxx::descriptor< Bottom >:

tool::iterable< Bottom > tool::static_base< Bottom >

List of all members.


Detailed Description

template<class Bottom = tool::bottom>
struct pcapxx::descriptor< Bottom >

Enable various PCAP operations.

A PCAP descriptor allows you to read frames (or packets) from PCAP files. You may also use a PCAP descriptor to retrieve a dumper object, in order to dump frames (or packets) into a PCAP file.

A PCAP descriptor is an iterable object. You may iterate over frames like this:

 pcapxx::descriptor<> d ("file.pcap");

 for (pcapxx::descriptor<>::iterator i = d.begin(); i != d.end(); ++i)
   {
     // Access to i->pcap_header and i->bytes.
     //
     // *i is of type frame_descriptor.
   }

See also:
dumper, frame_descriptor, internals::frame_iterator

Public Types

enum  { mark_step = 4096, junk_len = 4096 }
enum  link_type {
  LOOP = 0, EN10MB = 1, EN3MB = 2, AX25 = 3,
  PRONET = 4, CHAOS = 5, IEEE802 = 6, ARCNET = 7,
  SLIP = 8, PPP = 9, FDDI = 10, IEEE802_11 = 105,
  PRISM_HEADER = 119, IEEE802_11_RADIO = 127, IEEE802_11_RADIO_AVS = 163
}
typedef HIDDEN iterator
typedef iterator const_iterator
typedef std::vector
< std::streampos > 
index_type
Static hierarchies related types.
typedef HIDDEN exact_type
typedef tool::iterable
< exact_type
super_type

Public Member Functions

 descriptor (const std::string &filename, bool build_index=false)
 descriptor (const std::string &filename, const index_type &marks, unsigned pkt_count)
template<typename ProgressInfoSetupType, typename ProgressInfoUpdateType>
 descriptor (const std::string &filename, ProgressInfoSetupType &pi_setup, ProgressInfoUpdateType &pi_update)
iterator operator[] (size_t)
size_t size () const
bool swapped () const
int32_t zone () const
int32_t snaplen () const
link_type linktype () const
void expect (link_type l) const
std::streampos file_size () const
const std::string & file_name () const
pcapxx::dumper dumper (const std::string &fname) const
iterator begin () const
iterator end () const
template<class OutputIterator>
void operator() (const OutputIterator &output) const
Apply a function/functor to each element
template<class Functor>
void for_each (Functor &f) const
template<class Functor>
void for_each (const Functor &f) const
Downcast methods
const exact_typeexact () const
exact_typeexact ()
const exact_typeexact_ptr () const
exact_typeexact_ptr ()

Member Typedef Documentation

template<class Bottom = tool::bottom>
typedef HIDDEN pcapxx::descriptor< Bottom >::exact_type

Exact type for this template instantiation.

Reimplemented from tool::iterable< Bottom >.

template<class Bottom = tool::bottom>
typedef HIDDEN pcapxx::descriptor< Bottom >::iterator

Iterator type for this iterable class.

Reimplemented from tool::iterable< Bottom >.

template<class Bottom = tool::bottom>
typedef std::vector<std::streampos> pcapxx::descriptor< Bottom >::index_type

Internal index type for random frame access.

Only advanced users need to know about this.

See also:
mark_step.


Member Enumeration Documentation

template<class Bottom = tool::bottom>
anonymous enum

Enumerator:
mark_step  Register a mark every mark_step packets.

A mark is an offset in the trace file. Marks are stored in a vector at regular intervals, so fast access to random packets is possible.

This is a trade-off: more marks allows faster access, but fewer marks uses less memory.

junk_len  When loading traces, read packet data with steps of junk_len bytes.

The more the better, but one must be careful not to grow the stack too much. We use reads here instead of seeks not to break the underlying C++ buffering. Tests showed this is faster.

template<class Bottom = tool::bottom>
enum pcapxx::descriptor::link_type

PCAP file link types.

Enumerator:
LOOP  BSD loopback encapsulation.
EN10MB  Ethernet (10Mb).
EN3MB  Experimental Ethernet (3Mb).
AX25  Amateur Radio AX.25.
PRONET  Proteon ProNET Token Ring.
CHAOS  Chaos.
IEEE802  IEEE 802 Networks.
ARCNET  ARCNET, with BSD-style header.
SLIP  Serial Line IP.
PPP  Point-to-point Protocol.
FDDI  FDDI.
IEEE802_11  IEEE 802.11 wireless.
PRISM_HEADER  Prism PHY-layer information.
IEEE802_11_RADIO  Radiotap header.
IEEE802_11_RADIO_AVS  AVS header.


Constructor & Destructor Documentation

template<class Bottom>
pcapxx::descriptor< Bottom >::descriptor ( const std::string &  filename,
bool  build_index = false 
) [inline]

Construct a descriptor from a file name.

template<class Bottom>
pcapxx::descriptor< Bottom >::descriptor ( const std::string &  filename,
const index_type marks,
unsigned  pkt_count 
) [inline]

Construct a descriptor from a file name; use an already constructed index.

template<class Bottom>
template<typename ProgressInfoSetupType, typename ProgressInfoUpdateType>
pcapxx::descriptor< Bottom >::descriptor ( const std::string &  filename,
ProgressInfoSetupType &  pi_setup,
ProgressInfoUpdateType &  pi_update 
) [inline]

Construct a descriptor from a file name, with progress indicator callbacks.

Parameters:
[in] filename The file's name.
[in] pi_setup Called before reading packets with two arguments. The first one is the first packet's offset, the last one is the file size.
[in] pi_update Called periodically when reading packets. The current offset in the file is passed as argument. Returns either 0 (continue) or a pointer to a string (stop and throws interrupted(string) ).


Member Function Documentation

template<class Bottom>
descriptor< Bottom >::iterator pcapxx::descriptor< Bottom >::operator[] ( size_t  i  )  [inline]

Get an iterator pointing to a specific packet.

template<class Bottom>
size_t pcapxx::descriptor< Bottom >::size (  )  const [inline]

Get the number of packets in the trace.

template<class Bottom>
bool pcapxx::descriptor< Bottom >::swapped (  )  const [inline]

Get the trace's endianness w.r.t. the host system.

template<class Bottom>
int32_t pcapxx::descriptor< Bottom >::zone (  )  const [inline]

Get the trace's time adjustment.

template<class Bottom>
int32_t pcapxx::descriptor< Bottom >::snaplen (  )  const [inline]

Get the trace's snap length.

template<class Bottom>
descriptor< Bottom >::link_type pcapxx::descriptor< Bottom >::linktype (  )  const [inline]

Get the trace's link type.

template<class Bottom>
void pcapxx::descriptor< Bottom >::expect ( link_type  l  )  const [inline]

Throw an instance of std::invalid_argument if the descriptor's link type is different from l.

template<class Bottom>
std::streampos pcapxx::descriptor< Bottom >::file_size (  )  const [inline]

Get the trace size in bytes.

template<class Bottom>
const std::string & pcapxx::descriptor< Bottom >::file_name (  )  const [inline]

Get the trace's name.

template<class Bottom>
dumper pcapxx::descriptor< Bottom >::dumper ( const std::string &  fname  )  const [inline]

Get a dumper object for a given file.

template<class B>
iterable< B >::iterator tool::iterable< B >::begin (  )  const [inline, inherited]

Get an iterator to the first element.

template<class B>
iterable< B >::iterator tool::iterable< B >::end (  )  const [inline, inherited]

Get an iterator to the end (past the last element).

template<class B>
template<class O>
void tool::iterable< B >::operator() ( const O &  output  )  const [inline, inherited]

Copy elements to output .

template<class Bottom>
const static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact (  )  const [inline, inherited]

Safely downcast to the exact type as a const reference.

template<class Bottom>
static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact (  )  [inline, inherited]

Safely downcast to the exact type as a non-const reference.

template<class Bottom>
const static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr (  )  const [inline, inherited]

Safely downcast to the exact type as a const pointer.

template<class Bottom>
static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr (  )  [inline, inherited]

Safely downcast to the exact type as a non-const pointer.


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

Generated on Fri Jan 16 11:55:55 2009 for wipal by  doxygen 1.5.6