#include <wipal/pcap/descriptor.hh>
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. }
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_type & | exact () const |
exact_type & | exact () |
const exact_type * | exact_ptr () const |
exact_type * | exact_ptr () |
typedef HIDDEN pcapxx::descriptor< Bottom >::exact_type |
typedef HIDDEN pcapxx::descriptor< Bottom >::iterator |
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.
anonymous enum |
enum pcapxx::descriptor::link_type |
PCAP file link types.
pcapxx::descriptor< Bottom >::descriptor | ( | const std::string & | filename, | |
bool | build_index = false | |||
) | [inline] |
Construct a descriptor from a file name.
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.
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.
[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) ). |
descriptor< Bottom >::iterator pcapxx::descriptor< Bottom >::operator[] | ( | size_t | i | ) | [inline] |
Get an iterator pointing to a specific packet.
size_t pcapxx::descriptor< Bottom >::size | ( | ) | const [inline] |
Get the number of packets in the trace.
bool pcapxx::descriptor< Bottom >::swapped | ( | ) | const [inline] |
Get the trace's endianness w.r.t. the host system.
int32_t pcapxx::descriptor< Bottom >::zone | ( | ) | const [inline] |
Get the trace's time adjustment.
int32_t pcapxx::descriptor< Bottom >::snaplen | ( | ) | const [inline] |
Get the trace's snap length.
descriptor< Bottom >::link_type pcapxx::descriptor< Bottom >::linktype | ( | ) | const [inline] |
Get the trace's link type.
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
.
std::streampos pcapxx::descriptor< Bottom >::file_size | ( | ) | const [inline] |
Get the trace size in bytes.
const std::string & pcapxx::descriptor< Bottom >::file_name | ( | ) | const [inline] |
Get the trace's name.
dumper pcapxx::descriptor< Bottom >::dumper | ( | const std::string & | fname | ) | const [inline] |
Get a dumper object for a given file.
iterable< B >::iterator tool::iterable< B >::begin | ( | ) | const [inline, inherited] |
Get an iterator to the first element.
iterable< B >::iterator tool::iterable< B >::end | ( | ) | const [inline, inherited] |
Get an iterator to the end (past the last element).
void tool::iterable< B >::operator() | ( | const O & | output | ) | const [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.