#include <trace-tools/pcap/descriptor.hh>
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_type & | exact () const |
exact_type & | exact () |
const exact_type * | exact_ptr () const |
exact_type * | exact_ptr () |
Classes | |
struct | shared_data |
Data shared by identical PCAP descriptors. | |
struct | wrapper_data |
User data for handler_wrapper() . |
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. }
typedef HIDDEN tool::iterable< Bottom >::exact_type [inherited] |
typedef HIDDEN tool::iterable< Bottom >::iterator [inherited] |
Iterator type for this template instantiation.
pcapxx::descriptor< B >::descriptor | ( | const std::string & | device, | |
int | snaplen, | |||
int | promisc, | |||
int | to_ms | |||
) | [inline] |
Construct a descriptor for live packet capture.
[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. |
pcapxx::descriptor< B >::descriptor | ( | const std::string & | fname | ) | [inline] |
Construct a descriptor for offline file access.
pcapxx::descriptor< B >::descriptor | ( | int | linktype, | |
int | snaplen | |||
) | [inline] |
Construct a descriptor not for packet capture.
[in] | linktype | Frames' link type. |
[in] | snaplen | Maximum number of bytes to dump per frame. |
int pcapxx::descriptor< B >::datalink | ( | ) | const [inline] |
Frames' link type.
libpcap
documentation about link types. bool pcapxx::descriptor< B >::is_swapped | ( | ) | const [inline] |
File endianness w.r.t this machine.
std::string pcapxx::descriptor< B >::error | ( | ) | const [inline] |
Last error message.
pcapxx::dumper pcapxx::descriptor< B >::dumper | ( | const std::string & | fname | ) | const [inline] |
Get a dumper object for a given file.
int pcapxx::descriptor< B >::loop | ( | void * | user = 0 , |
|
int | cnt = -1 | |||
) | [inline] |
Read frames.
[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. |
iterable< B >::iterator tool::iterable< B >::begin | ( | ) | [inline, inherited] |
Get an iterator to the first element.
iterable< B >::iterator tool::iterable< B >::end | ( | ) | [inline, inherited] |
Get an iterator to the end (past the last element).
void tool::iterable< B >::operator() | ( | const O & | output | ) | [inline, inherited] |
Copy elements to output
.
const static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact | ( | ) | const [inline, inherited] |
Safely downcast to the exact type as a const reference.
static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact | ( | ) | [inline, inherited] |
Safely downcast to the exact type as a non-const reference.
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.
static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr | ( | ) | [inline, inherited] |
Safely downcast to the exact type as a non-const pointer.