Main Page Class Hierarchy Compound List File List Compound Members Examples

# usipp::Pcap Class Reference

`#include <datalink.h>`

Inheritance diagram for usipp::Pcap:

List of all members.

## Public Methods
| Pcap (char *)
| Pcap ()
| Pcap (const Pcap &)
virtual | ~Pcap ()
Pcap& | operator= (const Pcap &)
char* | get_hwsrc (char *, size_t)
char* | get_hwdst (char *, size_t)
u_int16_t | get_etype ()
int | get_datalink ()
int | get_framelen ()
virtual int | init_device (char *dev, int promisc, size_t snaplen)
virtual int | setfilter (char *filter)
virtual int | sniffpack (void *, size_t)
void* | get_frame (void *, size_t)
pcap_t* | pcap ()
int | timeout (struct timeval)
bool | timeout ()
## Protected Attributes
struct ether_header | d_ether
char | d_filter_string [1000]

## Detailed Description

Describing a Datalink.

## Constructor & Destructor Documentation

usipp::Pcap::Pcap ( | char * )

| This constructor should be used to initialize raw-datalink-objects, means not IP/TCP/ICMP etc. We need this b/c unlike in derived classes, datalink::init_device() cannot set a filter!

usipp::Pcap::Pcap ( | const Pcap & )

| Copy-constructor

## Member Function Documentation

int usipp::Pcap::get_datalink ( | )

| Return the actual datalink of the object.

u_int16_t usipp::Pcap::get_etype ( | )

| Get protocol-type of ethernet-frame Maybe moves to ethernet-class in future?

void * usipp::Pcap::get_frame ( | void *,
| size_t )

| Return HW-frame

int usipp::Pcap::get_framelen ( | )

| Return the actual framlen of the object. (framelen depends on datalink)

char * usipp::Pcap::get_hwdst ( | char *,
| size_t )

| Fill buffer with dst-hardware-adress of actuall packet, use 'datalink' to determine what HW the device is. Now only ethernet s supportet, but it's extensinable.

char * usipp::Pcap::get_hwsrc ( | char *,
| size_t )

| Fill buffer with src-hardware-adress of actuall packet, use 'datalink' to determine what HW the device is. Now only ethernet s supportet, but it's extensinable.

int usipp::Pcap::init_device ( | char * dev,
| int promisc,
| size_t snaplen )`[virtual]`

| Initialize a device ("eth0" for example) for packet- capturing. It MUST be called before sniffpack() is launched. Set 'promisc' to 1 if you want the device running in promiscous mode. Fetch at most 'snaplen' bytes per call. Reimplemented from usipp::RX.

pcap_t * usipp::Pcap::pcap ( | )`[inline]`

| Get pcap_t struct to obtain fileno etc for select.

int usipp::Pcap::setfilter ( | char * filter )`[virtual]`

| set a new filter for capturing Reimplemented from usipp::RX.

int usipp::Pcap::sniffpack ( | void *,
| size_t )`[virtual]`

| sniff a packet Reimplemented from usipp::RX.

bool usipp::Pcap::timeout ( | )`[virtual]`

| Returns true when recv() timed out Reimplemented from usipp::RX.

int usipp::Pcap::timeout ( | struct timeval )`[virtual]`

| Set a timeout. Implements RX::timeout() = 0. Reimplemented from usipp::RX.

The documentation for this class was generated from the following file:

- datalink.h