#include <wipal/pcap/descriptor.hh>
Static hierarchies related types. | |
typedef tool::iterable < exact_type > | super_type |
typedef | wp_get_exact (Bottom, descriptor< Bottom >) exact_type |
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, RADIOTAP_HEADER = 127 } |
typedef std::vector < std::streampos > | index_type |
Public Member Functions | |
typedef | wp_type (iterator, exact_type) iterator |
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 |
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. }
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) ). |
typedef pcapxx::descriptor< Bottom >::wp_type | ( | iterator | , | |
exact_type | ||||
) |
Iterator type for this iterable class.
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.