pcapxx::descriptor< Bottom > Struct Template Reference

Enable various PCAP operations. More...

#include <trace-tools/pcap/descriptor.hh>

Inheritance diagram for pcapxx::descriptor< Bottom >:

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

List of all members.

Public Types

typedef HIDDEN exact_type
typedef HIDDEN iterator

Public Member Functions

 descriptor (const std::string &device, int snaplen, int promisc, int to_ms)
 descriptor (const std::string &fname)
 descriptor (int linktype, int snaplen)
int datalink () const
bool is_swapped () const
std::string error () const
pcapxx::dumper dumper (const std::string &fname) const
template<handler Callback>
int loop (void *user=0, int cnt=-1)
iterator begin ()
iterator end ()
template<class OutputIterator>
void operator() (const OutputIterator &output)
Downcast methods
const exact_typeexact () const
exact_typeexact ()
const exact_typeexact_ptr () const
exact_typeexact_ptr ()

Classes

struct  shared_data
 Data shared by identical PCAP descriptors.
struct  wrapper_data
 User data for handler_wrapper().


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) either from PCAP files or network interfaces. 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

Member Typedef Documentation

template<class Bottom = bottom>
typedef HIDDEN tool::iterable< Bottom >::exact_type [inherited]

Exact type for this template instantiation.

Reimplemented from tool::static_base< Bottom >.

template<class Bottom = bottom>
typedef HIDDEN tool::iterable< Bottom >::iterator [inherited]

Iterator type for this template instantiation.


Constructor & Destructor Documentation

template<class B>
pcapxx::descriptor< B >::descriptor ( const std::string &  device,
int  snaplen,
int  promisc,
int  to_ms 
) [inline]

Construct a descriptor for live packet capture.

Parameters:
[in] device Network device's name.
[in] snaplen Maximum number of bytes to capture per frame.
[in] promisc Put the interface in promiscuous mode if true.
[in] to_ms Read timeout, in milliseconds.

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

Construct a descriptor for offline file access.

template<class B>
pcapxx::descriptor< B >::descriptor ( int  linktype,
int  snaplen 
) [inline]

Construct a descriptor not for packet capture.

Parameters:
[in] linktype Frames' link type.
[in] snaplen Maximum number of bytes to dump per frame.


Member Function Documentation

template<class B>
int pcapxx::descriptor< B >::datalink (  )  const [inline]

Frames' link type.

See also:
libpcap documentation about link types.

template<class B>
bool pcapxx::descriptor< B >::is_swapped (  )  const [inline]

File endianness w.r.t this machine.

template<class B>
std::string pcapxx::descriptor< B >::error (  )  const [inline]

Last error message.

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

Get a dumper object for a given file.

template<class B>
template<handler Callback>
int pcapxx::descriptor< B >::loop ( void *  user = 0,
int  cnt = -1 
) [inline]

Read frames.

Parameters:
[in] Callback Function to call on each frame.
[in] user User data for callback.
[in] cnt Maximum number of frames to read. -1 is unlimited.

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

Get an iterator to the first element.

template<class B>
iterable< B >::iterator tool::iterable< B >::end (  )  [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  )  [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 Wed Sep 12 16:02:47 2007 for trace-tools by  doxygen 1.5.3